PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.8.5
ووسلام – همگام سازی ووکامرس و باسلام v1.8.5
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / assets / chat / chat-app-bundle.js

chat-app-bundle.js in ووسلام – همگام سازی ووکامرس و باسلام 1.8.5, at assets/chat/chat-app-bundle.js

390 lines 1.6 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var ChatWidget=function(mo){"use strict";var tde=Object.defineProperty;var nde=(mo,go,Bi)=>go in mo?tde(mo,go,{enumerable:!0,configurable:!0,writable:!0,value:Bi}):mo[go]=Bi;var UC=(mo,go,Bi)=>nde(mo,typeof go!="symbol"?go+"":go,Bi);function go(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var Bi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ba(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Tz(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),t}var x_={exports:{}},Wu={},S_={exports:{}},hn={};/**
2 * @license React
3 * react.production.min.js
4 *
5 * Copyright (c) Facebook, Inc. and its affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */var $C;function Cz(){if($C)return hn;$C=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.iterator;function p(P){return P===null||typeof P!="object"?null:(P=f&&P[f]||P["@@iterator"],typeof P=="function"?P:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,v={};function y(P,H,Z){this.props=P,this.context=H,this.refs=v,this.updater=Z||m}y.prototype.isReactComponent={},y.prototype.setState=function(P,H){if(typeof P!="object"&&typeof P!="function"&&P!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,P,H,"setState")},y.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function b(){}b.prototype=y.prototype;function S(P,H,Z){this.props=P,this.context=H,this.refs=v,this.updater=Z||m}var E=S.prototype=new b;E.constructor=S,g(E,y.prototype),E.isPureReactComponent=!0;var C=Array.isArray,R=Object.prototype.hasOwnProperty,I={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function k(P,H,Z){var Q,J={},ee=null,K=null;if(H!=null)for(Q in H.ref!==void 0&&(K=H.ref),H.key!==void 0&&(ee=""+H.key),H)R.call(H,Q)&&!A.hasOwnProperty(Q)&&(J[Q]=H[Q]);var W=arguments.length-2;if(W===1)J.children=Z;else if(1<W){for(var te=Array(W),re=0;re<W;re++)te[re]=arguments[re+2];J.children=te}if(P&&P.defaultProps)for(Q in W=P.defaultProps,W)J[Q]===void 0&&(J[Q]=W[Q]);return{$$typeof:n,type:P,key:ee,ref:K,props:J,_owner:I.current}}function N(P,H){return{$$typeof:n,type:P.type,key:H,ref:P.ref,props:P.props,_owner:P._owner}}function D(P){return typeof P=="object"&&P!==null&&P.$$typeof===n}function M(P){var H={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(Z){return H[Z]})}var F=/\/+/g;function U(P,H){return typeof P=="object"&&P!==null&&P.key!=null?M(""+P.key):H.toString(36)}function $(P,H,Z,Q,J){var ee=typeof P;(ee==="undefined"||ee==="boolean")&&(P=null);var K=!1;if(P===null)K=!0;else switch(ee){case"string":case"number":K=!0;break;case"object":switch(P.$$typeof){case n:case e:K=!0}}if(K)return K=P,J=J(K),P=Q===""?"."+U(K,0):Q,C(J)?(Z="",P!=null&&(Z=P.replace(F,"$&/")+"/"),$(J,H,Z,"",function(re){return re})):J!=null&&(D(J)&&(J=N(J,Z+(!J.key||K&&K.key===J.key?"":(""+J.key).replace(F,"$&/")+"/")+P)),H.push(J)),1;if(K=0,Q=Q===""?".":Q+":",C(P))for(var W=0;W<P.length;W++){ee=P[W];var te=Q+U(ee,W);K+=$(ee,H,Z,te,J)}else if(te=p(P),typeof te=="function")for(P=te.call(P),W=0;!(ee=P.next()).done;)ee=ee.value,te=Q+U(ee,W++),K+=$(ee,H,Z,te,J);else if(ee==="object")throw H=String(P),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.");return K}function q(P,H,Z){if(P==null)return P;var Q=[],J=0;return $(P,Q,"","",function(ee){return H.call(Z,ee,J++)}),Q}function G(P){if(P._status===-1){var H=P._result;H=H(),H.then(function(Z){(P._status===0||P._status===-1)&&(P._status=1,P._result=Z)},function(Z){(P._status===0||P._status===-1)&&(P._status=2,P._result=Z)}),P._status===-1&&(P._status=0,P._result=H)}if(P._status===1)return P._result.default;throw P._result}var V={current:null},z={transition:null},B={ReactCurrentDispatcher:V,ReactCurrentBatchConfig:z,ReactCurrentOwner:I};return hn.Children={map:q,forEach:function(P,H,Z){q(P,function(){H.apply(this,arguments)},Z)},count:function(P){var H=0;return q(P,function(){H++}),H},toArray:function(P){return q(P,function(H){return H})||[]},only:function(P){if(!D(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},hn.Component=y,hn.Fragment=t,hn.Profiler=s,hn.PureComponent=S,hn.StrictMode=r,hn.Suspense=l,hn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=B,hn.cloneElement=function(P,H,Z){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var Q=g({},P.props),J=P.key,ee=P.ref,K=P._owner;if(H!=null){if(H.ref!==void 0&&(ee=H.ref,K=I.current),H.key!==void 0&&(J=""+H.key),P.type&&P.type.defaultProps)var W=P.type.defaultProps;for(te in H)R.call(H,te)&&!A.hasOwnProperty(te)&&(Q[te]=H[te]===void 0&&W!==void 0?W[te]:H[te])}var te=arguments.length-2;if(te===1)Q.children=Z;else if(1<te){W=Array(te);for(var re=0;re<te;re++)W[re]=arguments[re+2];Q.children=W}return{$$typeof:n,type:P.type,key:J,ref:ee,props:Q,_owner:K}},hn.createContext=function(P){return P={$$typeof:o,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:i,_context:P},P.Consumer=P},hn.createElement=k,hn.createFactory=function(P){var H=k.bind(null,P);return H.type=P,H},hn.createRef=function(){return{current:null}},hn.forwardRef=function(P){return{$$typeof:a,render:P}},hn.isValidElement=D,hn.lazy=function(P){return{$$typeof:d,_payload:{_status:-1,_result:P},_init:G}},hn.memo=function(P,H){return{$$typeof:c,type:P,compare:H===void 0?null:H}},hn.startTransition=function(P){var H=z.transition;z.transition={};try{P()}finally{z.transition=H}},hn.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},hn.useCallback=function(P,H){return V.current.useCallback(P,H)},hn.useContext=function(P){return V.current.useContext(P)},hn.useDebugValue=function(){},hn.useDeferredValue=function(P){return V.current.useDeferredValue(P)},hn.useEffect=function(P,H){return V.current.useEffect(P,H)},hn.useId=function(){return V.current.useId()},hn.useImperativeHandle=function(P,H,Z){return V.current.useImperativeHandle(P,H,Z)},hn.useInsertionEffect=function(P,H){return V.current.useInsertionEffect(P,H)},hn.useLayoutEffect=function(P,H){return V.current.useLayoutEffect(P,H)},hn.useMemo=function(P,H){return V.current.useMemo(P,H)},hn.useReducer=function(P,H,Z){return V.current.useReducer(P,H,Z)},hn.useRef=function(P){return V.current.useRef(P)},hn.useState=function(P){return V.current.useState(P)},hn.useSyncExternalStore=function(P,H,Z){return V.current.useSyncExternalStore(P,H,Z)},hn.useTransition=function(){return V.current.useTransition()},hn.version="18.2.0",hn}var zC;function ar(){return zC||(zC=1,S_.exports=Cz()),S_.exports}/**
10 * @license React
11 * react-jsx-runtime.production.min.js
12 *
13 * Copyright (c) Facebook, Inc. and its affiliates.
14 *
15 * This source code is licensed under the MIT license found in the
16 * LICENSE file in the root directory of this source tree.
17 */var qC;function Iz(){if(qC)return Wu;qC=1;var n=ar(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(a,l,c){var d,f={},p=null,m=null;c!==void 0&&(p=""+c),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(m=l.ref);for(d in l)r.call(l,d)&&!i.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:e,type:a,key:p,ref:m,props:f,_owner:s.current}}return Wu.Fragment=t,Wu.jsx=o,Wu.jsxs=o,Wu}var HC;function Rz(){return HC||(HC=1,x_.exports=Iz()),x_.exports}var _=Rz();/*! js-cookie v3.0.5 | MIT */function Sh(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)n[r]=t[r]}return n}var Az={read:function(n){return n[0]==='"'&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(n){return encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function E_(n,e){function t(s,i,o){if(!(typeof document>"u")){o=Sh({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=s+"="+n.write(i,s)+a}}function r(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var i=document.cookie?document.cookie.split("; "):[],o={},a=0;a<i.length;a++){var l=i[a].split("="),c=l.slice(1).join("=");try{var d=decodeURIComponent(l[0]);if(o[d]=n.read(c,d),s===d)break}catch{}}return s?o[s]:o}}return Object.create({set:t,get:r,remove:function(s,i){t(s,"",Sh({},i,{expires:-1}))},withAttributes:function(s){return E_(this.converter,Sh({},this.attributes,s))},withConverter:function(s){return E_(Sh({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(n)}})}var xa=E_(Az,{path:"/"}),Ku={exports:{}},kz=Ku.exports,GC;function Lz(){return GC||(GC=1,function(n,e){(function(t,r){var s="1.0.36",i="",o="?",a="function",l="undefined",c="object",d="string",f="major",p="model",m="name",g="type",v="vendor",y="version",b="architecture",S="console",E="mobile",C="tablet",R="smarttv",I="wearable",A="embedded",k=350,N="Amazon",D="Apple",M="ASUS",F="BlackBerry",U="Browser",$="Chrome",q="Edge",G="Firefox",V="Google",z="Huawei",B="LG",P="Microsoft",H="Motorola",Z="Opera",Q="Samsung",J="Sharp",ee="Sony",K="Xiaomi",W="Zebra",te="Facebook",re="Chromium OS",pe="Mac OS",Ee=function(Ue,it){var nt={};for(var dt in Ue)it[dt]&&it[dt].length%2===0?nt[dt]=it[dt].concat(Ue[dt]):nt[dt]=Ue[dt];return nt},le=function(Ue){for(var it={},nt=0;nt<Ue.length;nt++)it[Ue[nt].toUpperCase()]=Ue[nt];return it},Ie=function(Ue,it){return typeof Ue===d?be(it).indexOf(be(Ue))!==-1:!1},be=function(Ue){return Ue.toLowerCase()},ge=function(Ue){return typeof Ue===d?Ue.replace(/[^\d\.]/g,i).split(".")[0]:r},Ae=function(Ue,it){if(typeof Ue===d)return Ue=Ue.replace(/^\s\s*/,i),typeof it===l?Ue:Ue.substring(0,k)},Re=function(Ue,it){for(var nt=0,dt,Ot,xt,rt,Me,lt;nt<it.length&&!Me;){var Vt=it[nt],vn=it[nt+1];for(dt=Ot=0;dt<Vt.length&&!Me&&Vt[dt];)if(Me=Vt[dt++].exec(Ue),Me)for(xt=0;xt<vn.length;xt++)lt=Me[++Ot],rt=vn[xt],typeof rt===c&&rt.length>0?rt.length===2?typeof rt[1]==a?this[rt[0]]=rt[1].call(this,lt):this[rt[0]]=rt[1]:rt.length===3?typeof rt[1]===a&&!(rt[1].exec&&rt[1].test)?this[rt[0]]=lt?rt[1].call(this,lt,rt[2]):r:this[rt[0]]=lt?lt.replace(rt[1],rt[2]):r:rt.length===4&&(this[rt[0]]=lt?rt[3].call(this,lt.replace(rt[1],rt[2])):r):this[rt]=lt||r;nt+=2}},tt=function(Ue,it){for(var nt in it)if(typeof it[nt]===c&&it[nt].length>0){for(var dt=0;dt<it[nt].length;dt++)if(Ie(it[nt][dt],Ue))return nt===o?r:nt}else if(Ie(it[nt],Ue))return nt===o?r:nt;return Ue},et={"1.0":"/8","1.2":"/1","1.3":"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"},Oe={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2","8.1":"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},ht={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[y,[m,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[y,[m,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[m,y],[/opios[\/ ]+([\w\.]+)/i],[y,[m,Z+" Mini"]],[/\bopr\/([\w\.]+)/i],[y,[m,Z]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[m,y],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[y,[m,"UC"+U]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[y,[m,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[y,[m,"WeChat"]],[/konqueror\/([\w\.]+)/i],[y,[m,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[y,[m,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[y,[m,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[m,/(.+)/,"$1 Secure "+U],y],[/\bfocus\/([\w\.]+)/i],[y,[m,G+" Focus"]],[/\bopt\/([\w\.]+)/i],[y,[m,Z+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[y,[m,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[y,[m,"Dolphin"]],[/coast\/([\w\.]+)/i],[y,[m,Z+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[y,[m,"MIUI "+U]],[/fxios\/([-\w\.]+)/i],[y,[m,G]],[/\bqihu|(qi?ho?o?|360)browser/i],[[m,"360 "+U]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[m,/(.+)/,"$1 "+U],y],[/(comodo_dragon)\/([\w\.]+)/i],[[m,/_/g," "],y],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[m,y],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[m],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[m,te],y],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[m,y],[/\bgsa\/([\w\.]+) .*safari\//i],[y,[m,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[y,[m,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[y,[m,$+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[m,$+" WebView"],y],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[y,[m,"Android "+U]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[m,y],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[y,[m,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[y,m],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[m,[y,tt,et]],[/(webkit|khtml)\/([\w\.]+)/i],[m,y],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[m,"Netscape"],y],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[y,[m,G+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[m,y],[/(cobalt)\/([\w\.]+)/i],[m,[y,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[b,"amd64"]],[/(ia32(?=;))/i],[[b,be]],[/((?:i[346]|x)86)[;\)]/i],[[b,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[b,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[b,"armhf"]],[/windows (ce|mobile); ppc;/i],[[b,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[b,/ower/,i,be]],[/(sun4\w)[;\)]/i],[[b,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[b,be]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[p,[v,Q],[g,C]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[p,[v,Q],[g,E]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[p,[v,D],[g,E]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[p,[v,D],[g,C]],[/(macintosh);/i],[p,[v,D]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[p,[v,J],[g,E]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[p,[v,z],[g,C]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[p,[v,z],[g,E]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[p,/_/g," "],[v,K],[g,E]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[p,/_/g," "],[v,K],[g,C]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[p,[v,"OPPO"],[g,E]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[p,[v,"Vivo"],[g,E]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[p,[v,"Realme"],[g,E]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[p,[v,H],[g,E]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[p,[v,H],[g,C]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[p,[v,B],[g,C]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[p,[v,B],[g,E]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[p,[v,"Lenovo"],[g,C]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[p,/_/g," "],[v,"Nokia"],[g,E]],[/(pixel c)\b/i],[p,[v,V],[g,C]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[p,[v,V],[g,E]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[p,[v,ee],[g,E]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[p,"Xperia Tablet"],[v,ee],[g,C]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[p,[v,"OnePlus"],[g,E]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[p,[v,N],[g,C]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[p,/(.+)/g,"Fire Phone $1"],[v,N],[g,E]],[/(playbook);[-\w\),; ]+(rim)/i],[p,v,[g,C]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[p,[v,F],[g,E]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[p,[v,M],[g,C]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[p,[v,M],[g,E]],[/(nexus 9)/i],[p,[v,"HTC"],[g,C]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[v,[p,/_/g," "],[g,E]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[p,[v,"Acer"],[g,C]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[p,[v,"Meizu"],[g,E]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[v,p,[g,E]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[v,p,[g,C]],[/(surface duo)/i],[p,[v,P],[g,C]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[p,[v,"Fairphone"],[g,E]],[/(u304aa)/i],[p,[v,"AT&T"],[g,E]],[/\bsie-(\w*)/i],[p,[v,"Siemens"],[g,E]],[/\b(rct\w+) b/i],[p,[v,"RCA"],[g,C]],[/\b(venue[\d ]{2,7}) b/i],[p,[v,"Dell"],[g,C]],[/\b(q(?:mv|ta)\w+) b/i],[p,[v,"Verizon"],[g,C]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[p,[v,"Barnes & Noble"],[g,C]],[/\b(tm\d{3}\w+) b/i],[p,[v,"NuVision"],[g,C]],[/\b(k88) b/i],[p,[v,"ZTE"],[g,C]],[/\b(nx\d{3}j) b/i],[p,[v,"ZTE"],[g,E]],[/\b(gen\d{3}) b.+49h/i],[p,[v,"Swiss"],[g,E]],[/\b(zur\d{3}) b/i],[p,[v,"Swiss"],[g,C]],[/\b((zeki)?tb.*\b) b/i],[p,[v,"Zeki"],[g,C]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[v,"Dragon Touch"],p,[g,C]],[/\b(ns-?\w{0,9}) b/i],[p,[v,"Insignia"],[g,C]],[/\b((nxa|next)-?\w{0,9}) b/i],[p,[v,"NextBook"],[g,C]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[v,"Voice"],p,[g,E]],[/\b(lvtel\-)?(v1[12]) b/i],[[v,"LvTel"],p,[g,E]],[/\b(ph-1) /i],[p,[v,"Essential"],[g,E]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[p,[v,"Envizen"],[g,C]],[/\b(trio[-\w\. ]+) b/i],[p,[v,"MachSpeed"],[g,C]],[/\btu_(1491) b/i],[p,[v,"Rotor"],[g,C]],[/(shield[\w ]+) b/i],[p,[v,"Nvidia"],[g,C]],[/(sprint) (\w+)/i],[v,p,[g,E]],[/(kin\.[onetw]{3})/i],[[p,/\./g," "],[v,P],[g,E]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[p,[v,W],[g,C]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[p,[v,W],[g,E]],[/smart-tv.+(samsung)/i],[v,[g,R]],[/hbbtv.+maple;(\d+)/i],[[p,/^/,"SmartTV"],[v,Q],[g,R]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[v,B],[g,R]],[/(apple) ?tv/i],[v,[p,D+" TV"],[g,R]],[/crkey/i],[[p,$+"cast"],[v,V],[g,R]],[/droid.+aft(\w+)( bui|\))/i],[p,[v,N],[g,R]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[p,[v,J],[g,R]],[/(bravia[\w ]+)( bui|\))/i],[p,[v,ee],[g,R]],[/(mitv-\w{5}) bui/i],[p,[v,K],[g,R]],[/Hbbtv.*(technisat) (.*);/i],[v,p,[g,R]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[v,Ae],[p,Ae],[g,R]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[g,R]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[v,p,[g,S]],[/droid.+; (shield) bui/i],[p,[v,"Nvidia"],[g,S]],[/(playstation [345portablevi]+)/i],[p,[v,ee],[g,S]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[p,[v,P],[g,S]],[/((pebble))app/i],[v,p,[g,I]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[p,[v,D],[g,I]],[/droid.+; (glass) \d/i],[p,[v,V],[g,I]],[/droid.+; (wt63?0{2,3})\)/i],[p,[v,W],[g,I]],[/(quest( 2| pro)?)/i],[p,[v,te],[g,I]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[v,[g,A]],[/(aeobc)\b/i],[p,[v,N],[g,A]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[p,[g,E]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[p,[g,C]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[g,C]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[g,E]],[/(android[-\w\. ]{0,9});.+buil/i],[p,[v,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[y,[m,q+"HTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[y,[m,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[m,y],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[y,m]],os:[[/microsoft (windows) (vista|xp)/i],[m,y],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[m,[y,tt,Oe]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[m,"Windows"],[y,tt,Oe]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[y,/_/g,"."],[m,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[m,pe],[y,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[y,m],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[m,y],[/\(bb(10);/i],[y,[m,F]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[y,[m,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[y,[m,G+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[y,[m,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[y,[m,"watchOS"]],[/crkey\/([\d\.]+)/i],[y,[m,$+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[m,re],y],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[m,y],[/(sunos) ?([\w\.\d]*)/i],[[m,"Solaris"],y],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[m,y]]},Xe=function(Ue,it){if(typeof Ue===c&&(it=Ue,Ue=r),!(this instanceof Xe))return new Xe(Ue,it).getResult();var nt=typeof t!==l&&t.navigator?t.navigator:r,dt=Ue||(nt&&nt.userAgent?nt.userAgent:i),Ot=nt&&nt.userAgentData?nt.userAgentData:r,xt=it?Ee(ht,it):ht,rt=nt&&nt.userAgent==dt;return this.getBrowser=function(){var Me={};return Me[m]=r,Me[y]=r,Re.call(Me,dt,xt.browser),Me[f]=ge(Me[y]),rt&&nt&&nt.brave&&typeof nt.brave.isBrave==a&&(Me[m]="Brave"),Me},this.getCPU=function(){var Me={};return Me[b]=r,Re.call(Me,dt,xt.cpu),Me},this.getDevice=function(){var Me={};return Me[v]=r,Me[p]=r,Me[g]=r,Re.call(Me,dt,xt.device),rt&&!Me[g]&&Ot&&Ot.mobile&&(Me[g]=E),rt&&Me[p]=="Macintosh"&&nt&&typeof nt.standalone!==l&&nt.maxTouchPoints&&nt.maxTouchPoints>2&&(Me[p]="iPad",Me[g]=C),Me},this.getEngine=function(){var Me={};return Me[m]=r,Me[y]=r,Re.call(Me,dt,xt.engine),Me},this.getOS=function(){var Me={};return Me[m]=r,Me[y]=r,Re.call(Me,dt,xt.os),rt&&!Me[m]&&Ot&&Ot.platform!="Unknown"&&(Me[m]=Ot.platform.replace(/chrome os/i,re).replace(/macos/i,pe)),Me},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return dt},this.setUA=function(Me){return dt=typeof Me===d&&Me.length>k?Ae(Me,k):Me,this},this.setUA(dt),this};Xe.VERSION=s,Xe.BROWSER=le([m,y,f]),Xe.CPU=le([b]),Xe.DEVICE=le([p,v,g,S,E,R,C,I,A]),Xe.ENGINE=Xe.OS=le([m,y]),n.exports&&(e=n.exports=Xe),e.UAParser=Xe;var Je=typeof t!==l&&(t.jQuery||t.Zepto);if(Je&&!Je.ua){var qe=new Xe;Je.ua=qe.getResult(),Je.ua.get=function(){return qe.getUA()},Je.ua.set=function(Ue){qe.setUA(Ue);var it=qe.getResult();for(var nt in it)Je.ua[nt]=it[nt]}}})(typeof window=="object"?window:kz)}(Ku,Ku.exports)),Ku.exports}var Mz=Lz();const Dr=()=>window.dalanWidgetConfig?window.dalanWidgetConfig:null;function At(){var i,o,a,l,c;const e=new Mz.UAParser(window.navigator.userAgent).getResult(),t=Dr(),r=(t==null?void 0:t.forcedDeviceType)==="mobile",s=r||((i=e.device)==null?void 0:i.type)==="mobile";return{...e,isMobile:s,isForceMobile:r,isCrawler:!((o=e.browser)!=null&&o.name),isTablet:((a=e.device)==null?void 0:a.type)==="tablet",isPc:!s&&((l=e.device)==null?void 0:l.type)!=="tablet",isIOS:((c=e.os)==null?void 0:c.name)==="iOS"||xa.get("isIosApp")==="true"||xa.get("isIosApp")===!0}}function VC(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n))for(e=0;e<n.length;e++)n[e]&&(t=VC(n[e]))&&(r&&(r+=" "),r+=t);else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function Te(){for(var n,e,t=0,r="";t<arguments.length;)(n=arguments[t++])&&(e=VC(n))&&(r&&(r+=" "),r+=e);return r}const ss={"chat-page":"_chat-page_1061e_6","chat-page__container":"_chat-page__container_1061e_9","chat-page__container-grid":"_chat-page__container-grid_1061e_12","chat-page__container-grid-list":"_chat-page__container-grid-list_1061e_23","chat-page__list":"_chat-page__list_1061e_87","chat-page__main":"_chat-page__main_1061e_90","chat-widget-mobile":"_chat-widget-mobile_1061e_1","chat-page__container-grid-main":"_chat-page__container-grid-main_1061e_44","chat-page__container-grid-list--open":"_chat-page__container-grid-list--open_1061e_57","chat-page__container-grid-list--close":"_chat-page__container-grid-list--close_1061e_66","chat-page__container-grid-main--open":"_chat-page__container-grid-main--open_1061e_78","chat-page__container-grid-main--close":"_chat-page__container-grid-main--close_1061e_82"},Nz={},WC=n=>{let e;const t=new Set,r=(d,f)=>{const p=typeof d=="function"?d(e):d;if(!Object.is(p,e)){const m=e;e=f??(typeof p!="object"||p===null)?p:Object.assign({},e,p),t.forEach(g=>g(e,m))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>c,subscribe:d=>(t.add(d),()=>t.delete(d)),destroy:()=>{(Nz?"widget":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}},c=e=n(r,s,l);return l},Oz=n=>n?WC(n):WC;var T=ar();const Ne=ba(T),Pz=go({__proto__:null,default:Ne},[T]);var w_={exports:{}},T_={},C_={exports:{}},I_={};/**
18 * @license React
19 * use-sync-external-store-shim.production.min.js
20 *
21 * Copyright (c) Facebook, Inc. and its affiliates.
22 *
23 * This source code is licensed under the MIT license found in the
24 * LICENSE file in the root directory of this source tree.
25 */var KC;function Dz(){if(KC)return I_;KC=1;var n=ar();function e(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,s=n.useEffect,i=n.useLayoutEffect,o=n.useDebugValue;function a(f,p){var m=p(),g=r({inst:{value:m,getSnapshot:p}}),v=g[0].inst,y=g[1];return i(function(){v.value=m,v.getSnapshot=p,l(v)&&y({inst:v})},[f,m,p]),s(function(){return l(v)&&y({inst:v}),f(function(){l(v)&&y({inst:v})})},[f]),o(m),m}function l(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!t(f,m)}catch{return!0}}function c(f,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return I_.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:d,I_}var YC;function XC(){return YC||(YC=1,C_.exports=Dz()),C_.exports}/**
26 * @license React
27 * use-sync-external-store-shim/with-selector.production.min.js
28 *
29 * Copyright (c) Facebook, Inc. and its affiliates.
30 *
31 * This source code is licensed under the MIT license found in the
32 * LICENSE file in the root directory of this source tree.
33 */var QC;function jz(){if(QC)return T_;QC=1;var n=ar(),e=XC();function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,i=n.useRef,o=n.useEffect,a=n.useMemo,l=n.useDebugValue;return T_.useSyncExternalStoreWithSelector=function(c,d,f,p,m){var g=i(null);if(g.current===null){var v={hasValue:!1,value:null};g.current=v}else v=g.current;g=a(function(){function b(I){if(!S){if(S=!0,E=I,I=p(I),m!==void 0&&v.hasValue){var A=v.value;if(m(A,I))return C=A}return C=I}if(A=C,r(E,I))return A;var k=p(I);return m!==void 0&&m(A,k)?A:(E=I,C=k)}var S=!1,E,C,R=f===void 0?null:f;return[function(){return b(d())},R===null?void 0:function(){return b(R())}]},[d,f,p,m]);var y=s(c,g[0],g[1]);return o(function(){v.hasValue=!0,v.value=y},[y]),l(y),y},T_}var JC;function Fz(){return JC||(JC=1,w_.exports=jz()),w_.exports}var Uz=Fz();const Bz=ba(Uz),ZC={},{useDebugValue:$z}=Ne,{useSyncExternalStoreWithSelector:zz}=Bz;let eI=!1;const qz=n=>n;function Hz(n,e=qz,t){(ZC?"widget":void 0)!=="production"&&t&&!eI&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),eI=!0);const r=zz(n.subscribe,n.getState,n.getServerState||n.getInitialState,e,t);return $z(r),r}const tI=n=>{(ZC?"widget":void 0)!=="production"&&typeof n!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof n=="function"?Oz(n):n,t=(r,s)=>Hz(e,r,s);return Object.assign(t,e),t},R_=n=>n?tI(n):tI;function Gz(n){if(typeof n!="string"||n.length===0)throw new Error("Invalid input: expected a non-empty string.");return n.charAt(0).toUpperCase()+n.slice(1)}function A_(n){return e=>{const t={};return e.forEach(r=>{const i=`use${Gz(r)}`;n[i]&&(t[r]=n[i]())}),t}}const is=R_(n=>({user:void 0,toastOptions:{},target:void 0,options:void 0,socketMessages:[],chatModalData:null,injection:void 0,isLoggedIn:void 0,directModalData:null,chatSocketMessages:{},pagesBasePath:"/chat",currentUser:void 0,isShowChatModal:!1,socketConnected:!1,featureFlags:void 0,isLoadingCurrentUserOrFeatureFlags:!1,unseenMessages:{chat:0,notification:0},actions:{setIsLoggedIn:e=>n({isLogged:e}),setCurrentUser:e=>n({currentUser:e}),closeDirectModal:()=>n({directModalData:null}),setFeatureFlags:e=>n({featureFlags:e}),setToastOptions:e=>n({toastOptions:e}),setPagesBasePath:e=>n({pagesBasePath:e}),openDirectModal:e=>n({directModalData:e}),setSocketMessages:e=>n({socketMessages:e}),setSocketConnected:e=>n({socketConnected:e}),setChatSocketMessages:e=>n({chatSocketMessages:e}),closeChatModal:()=>n({chatModalData:null,isShowChatModal:!1}),openChatModal:(e,t)=>n({chatModalData:{identifier:e,...t},isShowChatModal:!0}),setUnseenMessages:e=>n(t=>({unseenMessages:typeof e=="function"?e(t.unseenMessages):e})),setDefaultValue:e=>n({user:e.user,target:e.target,options:e.options,injection:e.injection,isLoggedIn:e.isLoggedIn,featureFlags:e.featureFlags,toastOptions:e.toastOptions,pagesBasePath:e.pagesBasePath})}})),$i=()=>is(n=>n.actions),Lt=A_({useUser:()=>is(n=>n.user),useTarget:()=>is(n=>n.target),useOptions:()=>is(n=>n.options),useInjection:()=>is(n=>n.injection),useIsLoggedIn:()=>is(n=>n.isLoggedIn),useCurrentUser:()=>is(n=>n.currentUser),useFeatureFlags:()=>is(n=>n.featureFlags),useToastOptions:()=>is(n=>n.toastOptions),usePagesBasePath:()=>is(n=>n.pagesBasePath),useChatModalData:()=>is(n=>n.chatModalData),useSocketMessages:()=>is(n=>n.socketMessages),useUnseenMessages:()=>is(n=>n.unseenMessages),useDirectModalData:()=>is(n=>n.directModalData),useIsShowChatModal:()=>is(n=>n.isShowChatModal),useSocketConnected:()=>is(n=>n.socketConnected),useChatSocketMessages:()=>is(n=>n.chatSocketMessages)});/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:nI,setPrototypeOf:rI,isFrozen:Vz,getPrototypeOf:Wz,getOwnPropertyDescriptor:Kz}=Object;let{freeze:As,seal:_i,create:sI}=Object,{apply:k_,construct:L_}=typeof Reflect<"u"&&Reflect;As||(As=function(e){return e}),_i||(_i=function(e){return e}),k_||(k_=function(e,t,r){return e.apply(t,r)}),L_||(L_=function(e,t){return new e(...t)});const Eh=ni(Array.prototype.forEach),iI=ni(Array.prototype.pop),Yu=ni(Array.prototype.push),wh=ni(String.prototype.toLowerCase),M_=ni(String.prototype.toString),oI=ni(String.prototype.match),Xu=ni(String.prototype.replace),Yz=ni(String.prototype.indexOf),Xz=ni(String.prototype.trim),zi=ni(Object.prototype.hasOwnProperty),ks=ni(RegExp.prototype.test),Qu=Qz(TypeError);function ni(n){return function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];return k_(n,e,r)}}function Qz(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return L_(n,t)}}function pn(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wh;rI&&rI(n,null);let r=e.length;for(;r--;){let s=e[r];if(typeof s=="string"){const i=t(s);i!==s&&(Vz(e)||(e[r]=i),s=i)}n[s]=!0}return n}function Jz(n){for(let e=0;e<n.length;e++)zi(n,e)||(n[e]=null);return n}function gl(n){const e=sI(null);for(const[t,r]of nI(n))zi(n,t)&&(Array.isArray(r)?e[t]=Jz(r):r&&typeof r=="object"&&r.constructor===Object?e[t]=gl(r):e[t]=r);return e}function Ju(n,e){for(;n!==null;){const r=Kz(n,e);if(r){if(r.get)return ni(r.get);if(typeof r.value=="function")return ni(r.value)}n=Wz(n)}function t(){return null}return t}const aI=As(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),N_=As(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),O_=As(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Zz=As(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),P_=As(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),e6=As(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),lI=As(["#text"]),cI=As(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),D_=As(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),uI=As(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Th=As(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),t6=_i(/\{\{[\w\W]*|[\w\W]*\}\}/gm),n6=_i(/<%[\w\W]*|[\w\W]*%>/gm),r6=_i(/\$\{[\w\W]*}/gm),s6=_i(/^data-[\-\w.\u00B7-\uFFFF]+$/),i6=_i(/^aria-[\-\w]+$/),dI=_i(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),o6=_i(/^(?:\w+script|data):/i),a6=_i(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),fI=_i(/^html$/i),l6=_i(/^[a-z][.\w]*(-[.\w]+)+$/i);var hI=Object.freeze({__proto__:null,ARIA_ATTR:i6,ATTR_WHITESPACE:a6,CUSTOM_ELEMENT:l6,DATA_ATTR:s6,DOCTYPE_NAME:fI,ERB_EXPR:n6,IS_ALLOWED_URI:dI,IS_SCRIPT_OR_DATA:o6,MUSTACHE_EXPR:t6,TMPLIT_EXPR:r6});const Zu={element:1,text:3,progressingInstruction:7,comment:8,document:9},c6=function(){return typeof window>"u"?null:window},u6=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(r=t.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},pI=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function mI(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:c6();const e=De=>mI(De);if(e.version="3.2.3",e.removed=[],!n||!n.document||n.document.nodeType!==Zu.document)return e.isSupported=!1,e;let{document:t}=n;const r=t,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:d=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:p,trustedTypes:m}=n,g=l.prototype,v=Ju(g,"cloneNode"),y=Ju(g,"remove"),b=Ju(g,"nextSibling"),S=Ju(g,"childNodes"),E=Ju(g,"parentNode");if(typeof o=="function"){const De=t.createElement("template");De.content&&De.content.ownerDocument&&(t=De.content.ownerDocument)}let C,R="";const{implementation:I,createNodeIterator:A,createDocumentFragment:k,getElementsByTagName:N}=t,{importNode:D}=r;let M=pI();e.isSupported=typeof nI=="function"&&typeof E=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:F,ERB_EXPR:U,TMPLIT_EXPR:$,DATA_ATTR:q,ARIA_ATTR:G,IS_SCRIPT_OR_DATA:V,ATTR_WHITESPACE:z,CUSTOM_ELEMENT:B}=hI;let{IS_ALLOWED_URI:P}=hI,H=null;const Z=pn({},[...aI,...N_,...O_,...P_,...lI]);let Q=null;const J=pn({},[...cI,...D_,...uI,...Th]);let ee=Object.seal(sI(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),K=null,W=null,te=!0,re=!0,pe=!1,Ee=!0,le=!1,Ie=!0,be=!1,ge=!1,Ae=!1,Re=!1,tt=!1,et=!1,Oe=!0,ht=!1;const Xe="user-content-";let Je=!0,qe=!1,Ue={},it=null;const nt=pn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let dt=null;const Ot=pn({},["audio","video","img","source","image","track"]);let xt=null;const rt=pn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Me="http://www.w3.org/1998/Math/MathML",lt="http://www.w3.org/2000/svg",Vt="http://www.w3.org/1999/xhtml";let vn=Vt,pt=!1,mt=null;const gt=pn({},[Me,lt,Vt],M_);let Wt=pn({},["mi","mo","mn","ms","mtext"]),ot=pn({},["annotation-xml"]);const nn=pn({},["title","style","font","a","script"]);let tn=null;const En=["application/xhtml+xml","text/html"],$n="text/html";let _n=null,sr=null;const wr=t.createElement("form"),ws=function(se){return se instanceof RegExp||se instanceof Function},es=function(){let se=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(sr&&sr===se)){if((!se||typeof se!="object")&&(se={}),se=gl(se),tn=En.indexOf(se.PARSER_MEDIA_TYPE)===-1?$n:se.PARSER_MEDIA_TYPE,_n=tn==="application/xhtml+xml"?M_:wh,H=zi(se,"ALLOWED_TAGS")?pn({},se.ALLOWED_TAGS,_n):Z,Q=zi(se,"ALLOWED_ATTR")?pn({},se.ALLOWED_ATTR,_n):J,mt=zi(se,"ALLOWED_NAMESPACES")?pn({},se.ALLOWED_NAMESPACES,M_):gt,xt=zi(se,"ADD_URI_SAFE_ATTR")?pn(gl(rt),se.ADD_URI_SAFE_ATTR,_n):rt,dt=zi(se,"ADD_DATA_URI_TAGS")?pn(gl(Ot),se.ADD_DATA_URI_TAGS,_n):Ot,it=zi(se,"FORBID_CONTENTS")?pn({},se.FORBID_CONTENTS,_n):nt,K=zi(se,"FORBID_TAGS")?pn({},se.FORBID_TAGS,_n):{},W=zi(se,"FORBID_ATTR")?pn({},se.FORBID_ATTR,_n):{},Ue=zi(se,"USE_PROFILES")?se.USE_PROFILES:!1,te=se.ALLOW_ARIA_ATTR!==!1,re=se.ALLOW_DATA_ATTR!==!1,pe=se.ALLOW_UNKNOWN_PROTOCOLS||!1,Ee=se.ALLOW_SELF_CLOSE_IN_ATTR!==!1,le=se.SAFE_FOR_TEMPLATES||!1,Ie=se.SAFE_FOR_XML!==!1,be=se.WHOLE_DOCUMENT||!1,Re=se.RETURN_DOM||!1,tt=se.RETURN_DOM_FRAGMENT||!1,et=se.RETURN_TRUSTED_TYPE||!1,Ae=se.FORCE_BODY||!1,Oe=se.SANITIZE_DOM!==!1,ht=se.SANITIZE_NAMED_PROPS||!1,Je=se.KEEP_CONTENT!==!1,qe=se.IN_PLACE||!1,P=se.ALLOWED_URI_REGEXP||dI,vn=se.NAMESPACE||Vt,Wt=se.MATHML_TEXT_INTEGRATION_POINTS||Wt,ot=se.HTML_INTEGRATION_POINTS||ot,ee=se.CUSTOM_ELEMENT_HANDLING||{},se.CUSTOM_ELEMENT_HANDLING&&ws(se.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ee.tagNameCheck=se.CUSTOM_ELEMENT_HANDLING.tagNameCheck),se.CUSTOM_ELEMENT_HANDLING&&ws(se.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ee.attributeNameCheck=se.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),se.CUSTOM_ELEMENT_HANDLING&&typeof se.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=se.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),le&&(re=!1),tt&&(Re=!0),Ue&&(H=pn({},lI),Q=[],Ue.html===!0&&(pn(H,aI),pn(Q,cI)),Ue.svg===!0&&(pn(H,N_),pn(Q,D_),pn(Q,Th)),Ue.svgFilters===!0&&(pn(H,O_),pn(Q,D_),pn(Q,Th)),Ue.mathMl===!0&&(pn(H,P_),pn(Q,uI),pn(Q,Th))),se.ADD_TAGS&&(H===Z&&(H=gl(H)),pn(H,se.ADD_TAGS,_n)),se.ADD_ATTR&&(Q===J&&(Q=gl(Q)),pn(Q,se.ADD_ATTR,_n)),se.ADD_URI_SAFE_ATTR&&pn(xt,se.ADD_URI_SAFE_ATTR,_n),se.FORBID_CONTENTS&&(it===nt&&(it=gl(it)),pn(it,se.FORBID_CONTENTS,_n)),Je&&(H["#text"]=!0),be&&pn(H,["html","head","body"]),H.table&&(pn(H,["tbody"]),delete K.tbody),se.TRUSTED_TYPES_POLICY){if(typeof se.TRUSTED_TYPES_POLICY.createHTML!="function")throw Qu('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof se.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Qu('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=se.TRUSTED_TYPES_POLICY,R=C.createHTML("")}else C===void 0&&(C=u6(m,s)),C!==null&&typeof R=="string"&&(R=C.createHTML(""));As&&As(se),sr=se}},ds=pn({},[...N_,...O_,...Zz]),fs=pn({},[...P_,...e6]),oe=function(se){let Pe=E(se);(!Pe||!Pe.tagName)&&(Pe={namespaceURI:vn,tagName:"template"});const We=wh(se.tagName),an=wh(Pe.tagName);return mt[se.namespaceURI]?se.namespaceURI===lt?Pe.namespaceURI===Vt?We==="svg":Pe.namespaceURI===Me?We==="svg"&&(an==="annotation-xml"||Wt[an]):!!ds[We]:se.namespaceURI===Me?Pe.namespaceURI===Vt?We==="math":Pe.namespaceURI===lt?We==="math"&&ot[an]:!!fs[We]:se.namespaceURI===Vt?Pe.namespaceURI===lt&&!ot[an]||Pe.namespaceURI===Me&&!Wt[an]?!1:!fs[We]&&(nn[We]||!ds[We]):!!(tn==="application/xhtml+xml"&&mt[se.namespaceURI]):!1},ce=function(se){Yu(e.removed,{element:se});try{E(se).removeChild(se)}catch{y(se)}},_e=function(se,Pe){try{Yu(e.removed,{attribute:Pe.getAttributeNode(se),from:Pe})}catch{Yu(e.removed,{attribute:null,from:Pe})}if(Pe.removeAttribute(se),se==="is")if(Re||tt)try{ce(Pe)}catch{}else try{Pe.setAttribute(se,"")}catch{}},ie=function(se){let Pe=null,We=null;if(Ae)se="<remove></remove>"+se;else{const Ft=oI(se,/^[\r\n\t ]+/);We=Ft&&Ft[0]}tn==="application/xhtml+xml"&&vn===Vt&&(se='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+se+"</body></html>");const an=C?C.createHTML(se):se;if(vn===Vt)try{Pe=new p().parseFromString(an,tn)}catch{}if(!Pe||!Pe.documentElement){Pe=I.createDocument(vn,"template",null);try{Pe.documentElement.innerHTML=pt?R:an}catch{}}const yn=Pe.body||Pe.documentElement;return se&&We&&yn.insertBefore(t.createTextNode(We),yn.childNodes[0]||null),vn===Vt?N.call(Pe,be?"html":"body")[0]:be?Pe.documentElement:yn},xe=function(se){return A.call(se.ownerDocument||se,se,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Le=function(se){return se instanceof f&&(typeof se.nodeName!="string"||typeof se.textContent!="string"||typeof se.removeChild!="function"||!(se.attributes instanceof d)||typeof se.removeAttribute!="function"||typeof se.setAttribute!="function"||typeof se.namespaceURI!="string"||typeof se.insertBefore!="function"||typeof se.hasChildNodes!="function")},Be=function(se){return typeof a=="function"&&se instanceof a};function Se(De,se,Pe){Eh(De,We=>{We.call(e,se,Pe,sr)})}const ct=function(se){let Pe=null;if(Se(M.beforeSanitizeElements,se,null),Le(se))return ce(se),!0;const We=_n(se.nodeName);if(Se(M.uponSanitizeElement,se,{tagName:We,allowedTags:H}),se.hasChildNodes()&&!Be(se.firstElementChild)&&ks(/<[/\w]/g,se.innerHTML)&&ks(/<[/\w]/g,se.textContent)||se.nodeType===Zu.progressingInstruction||Ie&&se.nodeType===Zu.comment&&ks(/<[/\w]/g,se.data))return ce(se),!0;if(!H[We]||K[We]){if(!K[We]&&ut(We)&&(ee.tagNameCheck instanceof RegExp&&ks(ee.tagNameCheck,We)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(We)))return!1;if(Je&&!it[We]){const an=E(se)||se.parentNode,yn=S(se)||se.childNodes;if(yn&&an){const Ft=yn.length;for(let zn=Ft-1;zn>=0;--zn){const wn=v(yn[zn],!0);wn.__removalCount=(se.__removalCount||0)+1,an.insertBefore(wn,b(se))}}}return ce(se),!0}return se instanceof l&&!oe(se)||(We==="noscript"||We==="noembed"||We==="noframes")&&ks(/<\/no(script|embed|frames)/i,se.innerHTML)?(ce(se),!0):(le&&se.nodeType===Zu.text&&(Pe=se.textContent,Eh([F,U,$],an=>{Pe=Xu(Pe,an," ")}),se.textContent!==Pe&&(Yu(e.removed,{element:se.cloneNode()}),se.textContent=Pe)),Se(M.afterSanitizeElements,se,null),!1)},at=function(se,Pe,We){if(Oe&&(Pe==="id"||Pe==="name")&&(We in t||We in wr))return!1;if(!(re&&!W[Pe]&&ks(q,Pe))){if(!(te&&ks(G,Pe))){if(!Q[Pe]||W[Pe]){if(!(ut(se)&&(ee.tagNameCheck instanceof RegExp&&ks(ee.tagNameCheck,se)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(se))&&(ee.attributeNameCheck instanceof RegExp&&ks(ee.attributeNameCheck,Pe)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(Pe))||Pe==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&ks(ee.tagNameCheck,We)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(We))))return!1}else if(!xt[Pe]){if(!ks(P,Xu(We,z,""))){if(!((Pe==="src"||Pe==="xlink:href"||Pe==="href")&&se!=="script"&&Yz(We,"data:")===0&&dt[se])){if(!(pe&&!ks(V,Xu(We,z,"")))){if(We)return!1}}}}}}return!0},ut=function(se){return se!=="annotation-xml"&&oI(se,B)},St=function(se){Se(M.beforeSanitizeAttributes,se,null);const{attributes:Pe}=se;if(!Pe||Le(se))return;const We={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Q,forceKeepAttr:void 0};let an=Pe.length;for(;an--;){const yn=Pe[an],{name:Ft,namespaceURI:zn,value:wn}=yn,Wn=_n(Ft);let kn=Ft==="value"?wn:Xz(wn);if(We.attrName=Wn,We.attrValue=kn,We.keepAttr=!0,We.forceKeepAttr=void 0,Se(M.uponSanitizeAttribute,se,We),kn=We.attrValue,ht&&(Wn==="id"||Wn==="name")&&(_e(Ft,se),kn=Xe+kn),Ie&&ks(/((--!?|])>)|<\/(style|title)/i,kn)){_e(Ft,se);continue}if(We.forceKeepAttr||(_e(Ft,se),!We.keepAttr))continue;if(!Ee&&ks(/\/>/i,kn)){_e(Ft,se);continue}le&&Eh([F,U,$],fi=>{kn=Xu(kn,fi," ")});const Fs=_n(se.nodeName);if(at(Fs,Wn,kn)){if(C&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!zn)switch(m.getAttributeType(Fs,Wn)){case"TrustedHTML":{kn=C.createHTML(kn);break}case"TrustedScriptURL":{kn=C.createScriptURL(kn);break}}try{zn?se.setAttributeNS(zn,Ft,kn):se.setAttribute(Ft,kn),Le(se)?ce(se):iI(e.removed)}catch{}}}Se(M.afterSanitizeAttributes,se,null)},ft=function De(se){let Pe=null;const We=xe(se);for(Se(M.beforeSanitizeShadowDOM,se,null);Pe=We.nextNode();)Se(M.uponSanitizeShadowNode,Pe,null),ct(Pe),St(Pe),Pe.content instanceof i&&De(Pe.content);Se(M.afterSanitizeShadowDOM,se,null)};return e.sanitize=function(De){let se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Pe=null,We=null,an=null,yn=null;if(pt=!De,pt&&(De="<!-->"),typeof De!="string"&&!Be(De))if(typeof De.toString=="function"){if(De=De.toString(),typeof De!="string")throw Qu("dirty is not a string, aborting")}else throw Qu("toString is not a function");if(!e.isSupported)return De;if(ge||es(se),e.removed=[],typeof De=="string"&&(qe=!1),qe){if(De.nodeName){const wn=_n(De.nodeName);if(!H[wn]||K[wn])throw Qu("root node is forbidden and cannot be sanitized in-place")}}else if(De instanceof a)Pe=ie("<!---->"),We=Pe.ownerDocument.importNode(De,!0),We.nodeType===Zu.element&&We.nodeName==="BODY"||We.nodeName==="HTML"?Pe=We:Pe.appendChild(We);else{if(!Re&&!le&&!be&&De.indexOf("<")===-1)return C&&et?C.createHTML(De):De;if(Pe=ie(De),!Pe)return Re?null:et?R:""}Pe&&Ae&&ce(Pe.firstChild);const Ft=xe(qe?De:Pe);for(;an=Ft.nextNode();)ct(an),St(an),an.content instanceof i&&ft(an.content);if(qe)return De;if(Re){if(tt)for(yn=k.call(Pe.ownerDocument);Pe.firstChild;)yn.appendChild(Pe.firstChild);else yn=Pe;return(Q.shadowroot||Q.shadowrootmode)&&(yn=D.call(r,yn,!0)),yn}let zn=be?Pe.outerHTML:Pe.innerHTML;return be&&H["!doctype"]&&Pe.ownerDocument&&Pe.ownerDocument.doctype&&Pe.ownerDocument.doctype.name&&ks(fI,Pe.ownerDocument.doctype.name)&&(zn="<!DOCTYPE "+Pe.ownerDocument.doctype.name+`>
34 `+zn),le&&Eh([F,U,$],wn=>{zn=Xu(zn,wn," ")}),C&&et?C.createHTML(zn):zn},e.setConfig=function(){let De=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};es(De),ge=!0},e.clearConfig=function(){sr=null,ge=!1},e.isValidAttribute=function(De,se,Pe){sr||es({});const We=_n(De),an=_n(se);return at(We,an,Pe)},e.addHook=function(De,se){typeof se=="function"&&Yu(M[De],se)},e.removeHook=function(De){return iI(M[De])},e.removeHooks=function(De){M[De]=[]},e.removeAllHooks=function(){M=pI()},e}var Ec=mI();const Ln={"chat-list-item-container":"_chat-list-item-container_1x42d_6","chat-list-item-container--notification":"_chat-list-item-container--notification_1x42d_23","chat-list-item-container--deleted":"_chat-list-item-container--deleted_1x42d_31","chat-list-item-container--active":"_chat-list-item-container--active_1x42d_37","chat-list-item":"_chat-list-item_1x42d_6","chat-list-item--active":"_chat-list-item--active_1x42d_72","chat-list-item--bottom-bordered":"_chat-list-item--bottom-bordered_1x42d_80","chat-list-item__top":"_chat-list-item__top_1x42d_89","chat-list-item__top__saved-message__avatar":"_chat-list-item__top__saved-message__avatar_1x42d_94","chat-list-item__top__saved-message__avatar--compact":"_chat-list-item__top__saved-message__avatar--compact_1x42d_103","chat-list-item--compact":"_chat-list-item--compact_1x42d_107","chat-list-item__compact-indicators":"_chat-list-item__compact-indicators_1x42d_118","chat-list-item__compact-unseen":"_chat-list-item__compact-unseen_1x42d_126","chat-list-item__compact-mark":"_chat-list-item__compact-mark_1x42d_139","chat-list-item__top-avatar":"_chat-list-item__top-avatar_1x42d_146","chat-list-item__top-sender":"_chat-list-item__top-sender_1x42d_149","chat-list-item__top-sender-name":"_chat-list-item__top-sender-name_1x42d_165","chat-list-item__top-sender-name-basalmi-badge":"_chat-list-item__top-sender-name-basalmi-badge_1x42d_193","chat-list-item__top-sender-name-snippet":"_chat-list-item__top-sender-name-snippet_1x42d_196","chat-list-item__top-sender-name-official":"_chat-list-item__top-sender-name-official_1x42d_199","chat-list-item__top-sender-vendor":"_chat-list-item__top-sender-vendor_1x42d_212","chat-list-item__top-time":"_chat-list-item__top-time_1x42d_228","chat-list-item__top-time--unseen":"_chat-list-item__top-time--unseen_1x42d_241","chat-list-item__bottom":"_chat-list-item__bottom_1x42d_248","chat-list-item__bottom-message":"_chat-list-item__bottom-message_1x42d_261","chat-list-item__bottom-message-snippet":"_chat-list-item__bottom-message-snippet_1x42d_292","chat-list-item__bottom-seen":"_chat-list-item__bottom-seen_1x42d_323","chat-list-item__bottom-unseen":"_chat-list-item__bottom-unseen_1x42d_334","chat-list-item__bottom-mark":"_chat-list-item__bottom-mark_1x42d_346"};var _l={},vl={},gI;function d6(){if(gI)return vl;gI=1;var n=vl&&vl.__assign||function(){return n=Object.assign||function(t){for(var r,s=1,i=arguments.length;s<i;s++){r=arguments[s];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},n.apply(this,arguments)};Object.defineProperty(vl,"__esModule",{value:!0}),vl.removeWindowUrlHash=void 0;var e=function(){var t=n({},window.history.state);"as"in t&&(t.as=t.as.replace(/#(.+)$/,"")),window.history.replaceState(t,""," ")};return vl.removeWindowUrlHash=e,vl}var Gr={},_I;function vI(){if(_I)return Gr;_I=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.getScrollbarWidth=t,Gr.isElementInView=r,Gr.elementHasClass=s,Gr.addClass=i,Gr.removeClass=o,Gr.getElementOffset=a,Gr.pageScrollTop=l,Gr.scrollToElement=c,Gr.scrollToElementIfNeeded=d,Gr.getElementOuterHeight=f,Gr.isStandaloneMode=p,Gr.lockBodyOverflow=m,Gr.unlockBodyOverflow=g,Gr.lockBodyScroll=v,Gr.unlockBodyScroll=y;var n=typeof window<"u",e;function t(){if(typeof window>"u")return 0;if(e!==void 0)return e;var b=document.createElement("div");b.style.visibility="hidden",b.style.width="100px",b.style.position="absolute",b.style.top="-9999px",document.body.append(b);var S=b.offsetWidth;b.style.overflow="scroll";var E=document.createElement("div");E.style.width="100%",b.append(E);var C=E.offsetWidth;return b==null||b.remove(),e=S-C,e}function r(b){var S=b.getBoundingClientRect(),E=S.top,C=S.bottom;return E>=0&&C<=window.innerHeight}function s(b,S){return b.classList?b.classList.contains(S):new RegExp("(^| )".concat(S,"( |$)"),"gi").test(b.className)}function i(b,S){if(b.classList)b.classList.add(S);else{var E=b.className.split(" ");E.includes(S)||E.push(S),b.className=E.join(" ")}}function o(b,S){b.classList?b.classList.remove(S):b.className=b.className.replace(new RegExp("(^|\\b)".concat(S.split(" ").join("|"),"(\\b|$)"),"gi")," ")}function a(b){var S=b.getBoundingClientRect();return{width:S.width,height:S.height,top:S.top+(window.pageYOffset||document.documentElement.scrollTop),left:S.left+(window.pageXOffset||document.documentElement.scrollTop)}}function l(){return window.pageYOffset||document.documentElement.scrollTop}function c(b,S,E){S===void 0&&(S=10),E===void 0&&(E="top");var C=typeof b=="string"?document.querySelector(b):b;if(C){var R;if(E==="top"){var I=document.querySelector("header"),A=I?I.offsetHeight:0;R=a(C).top-A-S}else{var k=document.querySelector(".button-navigation"),N=k?k.offsetHeight:0;R=a(C).top+a(C).height-window.innerHeight+N+S}window.scroll({top:R,left:0,behavior:"smooth"})}}function d(b,S,E,C){C===void 0&&(C=10);var R=b.getBoundingClientRect();(R.top<C||R.top+C>window.innerHeight)&&c(b,S,E)}function f(b){var S=b.getBoundingClientRect(),E=S.height,C=getComputedStyle(b);return E+=Number.parseFloat(C.marginTop)+Number.parseFloat(C.marginBottom),E}function p(){return window.matchMedia("(display-mode: standalone)").matches||"standalone"in window.navigator&&window.navigator.standalone===!0}function m(){var b;if(n){var S=document.body,E=document.documentElement,C=t(),R=E.clientHeight<S.scrollHeight;R&&S.classList.add("bs--lock-scroll-overflow"),R&&C>0&&S.classList.add("bs--has-scroll-padding"),(b=E.style)===null||b===void 0||b.setProperty("--scrollbar-width","".concat(C,"px"))}}function g(){if(n){var b=document.body;b.classList.remove("bs--lock-scroll-overflow"),b.classList.remove("bs--has-scroll-padding")}}function v(){var b;if(n){var S=document.body,E=document.documentElement;i(S,"bs--has-popup"),S.setAttribute("bs--has-popup","true");var C=t(),R=E.clientHeight<S.scrollHeight;R&&(i(S,"bs--lock-scroll-overflow"),S.setAttribute("bs--lock-scroll-overflow","true")),R&&C>0&&(i(S,"bs--has-scroll-padding"),S.setAttribute("bs--has-scroll-padding","true")),(b=E.style)===null||b===void 0||b.setProperty("--scrollbar-width","".concat(C,"px"))}}function y(){if(n){var b=document.body;o(b,"bs--has-popup"),b.removeAttribute("bs--has-popup"),o(b,"bs--has-scroll-padding"),o(b,"bs--lock-scroll-overflow"),b.removeAttribute("bs--has-scroll-padding"),b.removeAttribute("bs--lock-scroll-overflow")}}return Gr}var qi={},Ch={exports:{}},Ih={exports:{}},f6=Ih.exports,yI;function j_(){return yI||(yI=1,function(n,e){(function(t,r){n.exports=r()})(f6,function(){var t=1e3,r=6e4,s=36e5,i="millisecond",o="second",a="minute",l="hour",c="day",d="week",f="month",p="quarter",m="year",g="date",v="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,S={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var q=["th","st","nd","rd"],G=$%100;return"["+$+(q[(G-20)%10]||q[G]||q[0])+"]"}},E=function($,q,G){var V=String($);return!V||V.length>=q?$:""+Array(q+1-V.length).join(G)+$},C={s:E,z:function($){var q=-$.utcOffset(),G=Math.abs(q),V=Math.floor(G/60),z=G%60;return(q<=0?"+":"-")+E(V,2,"0")+":"+E(z,2,"0")},m:function $(q,G){if(q.date()<G.date())return-$(G,q);var V=12*(G.year()-q.year())+(G.month()-q.month()),z=q.clone().add(V,f),B=G-z<0,P=q.clone().add(V+(B?-1:1),f);return+(-(V+(G-z)/(B?z-P:P-z))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:f,y:m,w:d,d:c,D:g,h:l,m:a,s:o,ms:i,Q:p}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},R="en",I={};I[R]=S;var A="$isDayjsObject",k=function($){return $ instanceof F||!(!$||!$[A])},N=function $(q,G,V){var z;if(!q)return R;if(typeof q=="string"){var B=q.toLowerCase();I[B]&&(z=B),G&&(I[B]=G,z=B);var P=q.split("-");if(!z&&P.length>1)return $(P[0])}else{var H=q.name;I[H]=q,z=H}return!V&&z&&(R=z),z||!V&&R},D=function($,q){if(k($))return $.clone();var G=typeof q=="object"?q:{};return G.date=$,G.args=arguments,new F(G)},M=C;M.l=N,M.i=k,M.w=function($,q){return D($,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var F=function(){function $(G){this.$L=N(G.locale,null,!0),this.parse(G),this.$x=this.$x||G.x||{},this[A]=!0}var q=$.prototype;return q.parse=function(G){this.$d=function(V){var z=V.date,B=V.utc;if(z===null)return new Date(NaN);if(M.u(z))return new Date;if(z instanceof Date)return new Date(z);if(typeof z=="string"&&!/Z$/i.test(z)){var P=z.match(y);if(P){var H=P[2]-1||0,Z=(P[7]||"0").substring(0,3);return B?new Date(Date.UTC(P[1],H,P[3]||1,P[4]||0,P[5]||0,P[6]||0,Z)):new Date(P[1],H,P[3]||1,P[4]||0,P[5]||0,P[6]||0,Z)}}return new Date(z)}(G),this.init()},q.init=function(){var G=this.$d;this.$y=G.getFullYear(),this.$M=G.getMonth(),this.$D=G.getDate(),this.$W=G.getDay(),this.$H=G.getHours(),this.$m=G.getMinutes(),this.$s=G.getSeconds(),this.$ms=G.getMilliseconds()},q.$utils=function(){return M},q.isValid=function(){return this.$d.toString()!==v},q.isSame=function(G,V){var z=D(G);return this.startOf(V)<=z&&z<=this.endOf(V)},q.isAfter=function(G,V){return D(G)<this.startOf(V)},q.isBefore=function(G,V){return this.endOf(V)<D(G)},q.$g=function(G,V,z){return M.u(G)?this[V]:this.set(z,G)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(G,V){var z=this,B=!!M.u(V)||V,P=M.p(G),H=function(re,pe){var Ee=M.w(z.$u?Date.UTC(z.$y,pe,re):new Date(z.$y,pe,re),z);return B?Ee:Ee.endOf(c)},Z=function(re,pe){return M.w(z.toDate()[re].apply(z.toDate("s"),(B?[0,0,0,0]:[23,59,59,999]).slice(pe)),z)},Q=this.$W,J=this.$M,ee=this.$D,K="set"+(this.$u?"UTC":"");switch(P){case m:return B?H(1,0):H(31,11);case f:return B?H(1,J):H(0,J+1);case d:var W=this.$locale().weekStart||0,te=(Q<W?Q+7:Q)-W;return H(B?ee-te:ee+(6-te),J);case c:case g:return Z(K+"Hours",0);case l:return Z(K+"Minutes",1);case a:return Z(K+"Seconds",2);case o:return Z(K+"Milliseconds",3);default:return this.clone()}},q.endOf=function(G){return this.startOf(G,!1)},q.$set=function(G,V){var z,B=M.p(G),P="set"+(this.$u?"UTC":""),H=(z={},z[c]=P+"Date",z[g]=P+"Date",z[f]=P+"Month",z[m]=P+"FullYear",z[l]=P+"Hours",z[a]=P+"Minutes",z[o]=P+"Seconds",z[i]=P+"Milliseconds",z)[B],Z=B===c?this.$D+(V-this.$W):V;if(B===f||B===m){var Q=this.clone().set(g,1);Q.$d[H](Z),Q.init(),this.$d=Q.set(g,Math.min(this.$D,Q.daysInMonth())).$d}else H&&this.$d[H](Z);return this.init(),this},q.set=function(G,V){return this.clone().$set(G,V)},q.get=function(G){return this[M.p(G)]()},q.add=function(G,V){var z,B=this;G=Number(G);var P=M.p(V),H=function(J){var ee=D(B);return M.w(ee.date(ee.date()+Math.round(J*G)),B)};if(P===f)return this.set(f,this.$M+G);if(P===m)return this.set(m,this.$y+G);if(P===c)return H(1);if(P===d)return H(7);var Z=(z={},z[a]=r,z[l]=s,z[o]=t,z)[P]||1,Q=this.$d.getTime()+G*Z;return M.w(Q,this)},q.subtract=function(G,V){return this.add(-1*G,V)},q.format=function(G){var V=this,z=this.$locale();if(!this.isValid())return z.invalidDate||v;var B=G||"YYYY-MM-DDTHH:mm:ssZ",P=M.z(this),H=this.$H,Z=this.$m,Q=this.$M,J=z.weekdays,ee=z.months,K=z.meridiem,W=function(pe,Ee,le,Ie){return pe&&(pe[Ee]||pe(V,B))||le[Ee].slice(0,Ie)},te=function(pe){return M.s(H%12||12,pe,"0")},re=K||function(pe,Ee,le){var Ie=pe<12?"AM":"PM";return le?Ie.toLowerCase():Ie};return B.replace(b,function(pe,Ee){return Ee||function(le){switch(le){case"YY":return String(V.$y).slice(-2);case"YYYY":return M.s(V.$y,4,"0");case"M":return Q+1;case"MM":return M.s(Q+1,2,"0");case"MMM":return W(z.monthsShort,Q,ee,3);case"MMMM":return W(ee,Q);case"D":return V.$D;case"DD":return M.s(V.$D,2,"0");case"d":return String(V.$W);case"dd":return W(z.weekdaysMin,V.$W,J,2);case"ddd":return W(z.weekdaysShort,V.$W,J,3);case"dddd":return J[V.$W];case"H":return String(H);case"HH":return M.s(H,2,"0");case"h":return te(1);case"hh":return te(2);case"a":return re(H,Z,!0);case"A":return re(H,Z,!1);case"m":return String(Z);case"mm":return M.s(Z,2,"0");case"s":return String(V.$s);case"ss":return M.s(V.$s,2,"0");case"SSS":return M.s(V.$ms,3,"0");case"Z":return P}return null}(pe)||P.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(G,V,z){var B,P=this,H=M.p(V),Z=D(G),Q=(Z.utcOffset()-this.utcOffset())*r,J=this-Z,ee=function(){return M.m(P,Z)};switch(H){case m:B=ee()/12;break;case f:B=ee();break;case p:B=ee()/3;break;case d:B=(J-Q)/6048e5;break;case c:B=(J-Q)/864e5;break;case l:B=J/s;break;case a:B=J/r;break;case o:B=J/t;break;default:B=J}return z?B:M.a(B)},q.daysInMonth=function(){return this.endOf(f).$D},q.$locale=function(){return I[this.$L]},q.locale=function(G,V){if(!G)return this.$L;var z=this.clone(),B=N(G,V,!0);return B&&(z.$L=B),z},q.clone=function(){return M.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},$}(),U=F.prototype;return D.prototype=U,[["$ms",i],["$s",o],["$m",a],["$H",l],["$W",c],["$M",f],["$y",m],["$D",g]].forEach(function($){U[$[1]]=function(q){return this.$g(q,$[0],$[1])}}),D.extend=function($,q){return $.$i||($(q,F,D),$.$i=!0),D},D.locale=N,D.isDayjs=k,D.unix=function($){return D(1e3*$)},D.en=I[R],D.Ls=I,D.p={},D})}(Ih)),Ih.exports}var h6=Ch.exports,bI;function p6(){return bI||(bI=1,function(n,e){(function(t,r){n.exports=r(j_())})(h6,function(t){function r(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var s=r(t),i={name:"fa",weekdays:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysShort:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),weekStart:6,months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),ordinal:function(o){return o},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return s.default.locale(i,null,!0),i})}(Ch)),Ch.exports}var _o={},xI;function SI(){if(xI)return _o;xI=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.faLocale=void 0,_o.isValidJalaliDate=m,_o.toGregorian=g,_o.jalaliWeek=y,_o.getRemainingDaysInJalaliMonth=S;var n=[-61,9,38,199,426,686,756,818,1111,1181,1210,1635,2060,2097,2192,2262,2324,2394,2456,3178],e=/^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?([Zz]|([+-])([01]\d|2[0-3])\D?([0-5]\d)?)?)?$/,t=/\[.*?]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;function r(C,R){return Math.trunc(C/R)}function s(C,R){return C-Math.trunc(C/R)*R}function i(C,R,I){var A=r((C+r(R-8,6)+100100)*1461,4)+r(153*s(R+9,12)+2,5)+I-34840408;return A=A-r(r(C+100100+r(R-8,6),100)*3,4)+752,A}function o(C){var R;R=4*C+139361631,R=R+r(r(4*C+183187720,146097)*3,4)*4-3908;var I=r(s(R,1461),4)*5+308,A=r(s(I,153),5)+1,k=s(r(I,153),12)+1,N=r(R,1461)-100100+r(8-k,6);return{gy:N,gm:k,gd:A}}function a(C,R){var I=n.length,A=C+621,k=-14,N=n[0],D,M=0,F,U,$;if(C<N||C>=n[I-1])throw new Error("Invalid Jalaali year ".concat(C));for($=1;$<I&&(D=n[$],M=D-N,!(C<D));$+=1)k=k+r(M,33)*8+r(s(M,33),4),N=D;U=C-N,k=k+r(U,33)*8+r(s(U,33)+3,4),s(M,33)===4&&M-U===4&&(k+=1);var q=r(A,4)-r((r(A,100)+1)*3,4)-150,G=20+k-q;return R?{gy:A,march:G}:(M-U<6&&(U=U-M+r(M+4,33)*33),F=s(s(U+1,33)-1,4),F===-1&&(F=4),{leap:F,gy:A,march:G})}function l(C){var R=o(C).gy,I=R-621,A=a(I,!1),k=i(R,3,A.march),N,D,M;if(M=C-k,M>=0){if(M<=185)return D=1+r(M,31),N=s(M,31)+1,{jy:I,jm:D,jd:N};M-=186}else I-=1,M+=179,A.leap===1&&(M+=1);return D=7+r(M,30),N=s(M,30)+1,{jy:I,jm:D,jd:N}}function c(C,R,I){var A=a(C,!0);return i(A.gy,3,A.march)+(R-1)*31-r(R,7)*(R-7)+I-1}function d(C){var R=n.length,I=n[0],A,k=0,N,D,M;if(C<I||C>=n[R-1])throw new Error("Invalid Jalali year ".concat(C));for(M=1;M<R&&(A=n[M],k=A-I,!(C<A));M+=1)I=A;return D=C-I,k-D<6&&(D=D-k+r(k+4,33)*33),N=s(s(D+1,33)-1,4),N===-1&&(N=4),N}function f(C){return d(C)===0}function p(C,R){return R<=6?31:R<=11||f(C)?30:29}function m(C,R,I){return C>=-61&&C<=3177&&R>=1&&R<=12&&I>=1&&I<=p(C,R)}function g(C,R,I){return o(c(C,R,I))}function v(C,R,I,A,k,N,D){var M=g(C,R,I);return new Date(M.gy,M.gm-1,M.gd,0,0,0,0)}function y(C,R,I){var A=v(C,R,I).getDay(),k=A===6?0:-(A+1),N=6+k;return{friday:l(c(C,R,I+N)),saturday:l(c(C,R,I+k))}}function b(C,R,I){if(Object.prototype.toString.call(C)==="[object Date]"){var A=C;I=A.getDate(),R=A.getMonth()+1,C=A.getFullYear()}return l(i(C,R,I))}function S(C,R,I){var A=[31,31,31,31,31,31,30,30,30,30,30,29],k=b(C,R,I);(k.jy%33===1||k.jy%4===0&&k.jy%100!==0)&&(A[11]=30);var N=A[k.jm-1]-k.jd+1;return N}_o.faLocale={monthsShort:"فرو_ارد_خرد_تیر_مرد_شهر_مهر_آبا_آذر_دی_بهم_اسف".split("_"),months:"فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_")};var E=function(C,R,I){var A=R.prototype,k=A.format,N=A.parse;A.parse=function(D){D.date=D.date||new Date;var M=D.date,F=D.jalali;if(F&&typeof M=="string"&&/.*$/i.test(M)){var U=M.match(e);if(U){var $=U[1],q=U[2],G=U[3],V=U[4],z=g(Number($),Number(q),Number(G)),B=z.gy,P=z.gm,H=z.gd;D.date="".concat(B,"-").concat(String(P).padStart(2,"0"),"-").concat(String(H).padStart(2,"0")).concat(V||"")}}return N.bind(this)(D)},A.format=function(D){var M=this.$locale();if(M.name==="fa"){var F=D||"YYYY-MM-DDTHH:mm:ssZ",U=b(this.$y,this.$M+1,this.$D),$=U.jy,q=U.jm,G=U.jd,V=function(z,B,P,H){return z&&z[B]||P[B].slice(0,Math.max(0,H))};D=F.replace(t,function(z){switch(z){case"YY":return String($).slice(-2);case"YYYY":return String($);case"M":return String(q);case"MM":return String(q).padStart(2,"0");case"MMM":return V(M.monthsShort,q-1,M.months,3);case"MMMM":return M.months[q-1];case"D":return String(G);case"DD":return String(G).padStart(2,"0");default:return z}})}return k.bind(this)(D)}};return _o.default=E,_o}var Rh={exports:{}},m6=Rh.exports,EI;function g6(){return EI||(EI=1,function(n,e){(function(t,r){n.exports=r()})(m6,function(){var t="week",r="year";return function(s,i,o){var a=i.prototype;a.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var c=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var d=o(this).startOf(r).add(1,r).date(c),f=o(this).endOf(t);if(d.isBefore(f))return 1}var p=o(this).startOf(r).date(c).startOf(t).subtract(1,"millisecond"),m=this.diff(p,t,!0);return m<0?o(this).startOf("week").week():Math.ceil(m)},a.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}})}(Rh)),Rh.exports}var Ah={exports:{}},_6=Ah.exports,wI;function v6(){return wI||(wI=1,function(n,e){(function(t,r){n.exports=r()})(_6,function(){return function(t,r,s){s.updateLocale=function(i,o){var a=s.Ls[i];if(a)return(o?Object.keys(o):[]).forEach(function(l){a[l]=o[l]}),a}}})}(Ah)),Ah.exports}var kh={exports:{}},y6=kh.exports,TI;function b6(){return TI||(TI=1,function(n,e){(function(t,r){n.exports=r()})(y6,function(){return function(t,r,s){t=t||{};var i=r.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function a(c,d,f,p){return i.fromToBase(c,d,f,p)}s.en.relativeTime=o,i.fromToBase=function(c,d,f,p,m){for(var g,v,y,b=f.$locale().relativeTime||o,S=t.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],E=S.length,C=0;C<E;C+=1){var R=S[C];R.d&&(g=p?s(c).diff(f,R.d,!0):f.diff(c,R.d,!0));var I=(t.rounding||Math.round)(Math.abs(g));if(y=g>0,I<=R.r||!R.r){I<=1&&C>0&&(R=S[C-1]);var A=b[R.l];m&&(I=m(""+I)),v=typeof A=="string"?A.replace("%d",I):A(I,d,R.l,y);break}}if(d)return v;var k=y?b.future:b.past;return typeof k=="function"?k(v):k.replace("%s",v)},i.to=function(c,d){return a(c,d,this,!0)},i.from=function(c,d){return a(c,d,this)};var l=function(c){return c.$u?s.utc():s()};i.toNow=function(c){return this.to(l(this),c)},i.fromNow=function(c){return this.from(l(this),c)}}})}(kh)),kh.exports}var Lh={exports:{}},x6=Lh.exports,CI;function S6(){return CI||(CI=1,function(n,e){(function(t,r){n.exports=r()})(x6,function(){var t,r,s=1e3,i=6e4,o=36e5,a=864e5,l=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c=31536e6,d=2628e6,f=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,p={years:c,months:d,days:a,hours:o,minutes:i,seconds:s,milliseconds:1,weeks:6048e5},m=function(I){return I instanceof C},g=function(I,A,k){return new C(I,k,A.$l)},v=function(I){return r.p(I)+"s"},y=function(I){return I<0},b=function(I){return y(I)?Math.ceil(I):Math.floor(I)},S=function(I){return Math.abs(I)},E=function(I,A){return I?y(I)?{negative:!0,format:""+S(I)+A}:{negative:!1,format:""+I+A}:{negative:!1,format:""}},C=function(){function I(k,N,D){var M=this;if(this.$d={},this.$l=D,k===void 0&&(this.$ms=0,this.parseFromMilliseconds()),N)return g(k*p[v(N)],this);if(typeof k=="number")return this.$ms=k,this.parseFromMilliseconds(),this;if(typeof k=="object")return Object.keys(k).forEach(function($){M.$d[v($)]=k[$]}),this.calMilliseconds(),this;if(typeof k=="string"){var F=k.match(f);if(F){var U=F.slice(2).map(function($){return $!=null?Number($):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var A=I.prototype;return A.calMilliseconds=function(){var k=this;this.$ms=Object.keys(this.$d).reduce(function(N,D){return N+(k.$d[D]||0)*p[D]},0)},A.parseFromMilliseconds=function(){var k=this.$ms;this.$d.years=b(k/c),k%=c,this.$d.months=b(k/d),k%=d,this.$d.days=b(k/a),k%=a,this.$d.hours=b(k/o),k%=o,this.$d.minutes=b(k/i),k%=i,this.$d.seconds=b(k/s),k%=s,this.$d.milliseconds=k},A.toISOString=function(){var k=E(this.$d.years,"Y"),N=E(this.$d.months,"M"),D=+this.$d.days||0;this.$d.weeks&&(D+=7*this.$d.weeks);var M=E(D,"D"),F=E(this.$d.hours,"H"),U=E(this.$d.minutes,"M"),$=this.$d.seconds||0;this.$d.milliseconds&&($+=this.$d.milliseconds/1e3,$=Math.round(1e3*$)/1e3);var q=E($,"S"),G=k.negative||N.negative||M.negative||F.negative||U.negative||q.negative,V=F.format||U.format||q.format?"T":"",z=(G?"-":"")+"P"+k.format+N.format+M.format+V+F.format+U.format+q.format;return z==="P"||z==="-P"?"P0D":z},A.toJSON=function(){return this.toISOString()},A.format=function(k){var N=k||"YYYY-MM-DDTHH:mm:ss",D={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return N.replace(l,function(M,F){return F||String(D[M])})},A.as=function(k){return this.$ms/p[v(k)]},A.get=function(k){var N=this.$ms,D=v(k);return D==="milliseconds"?N%=1e3:N=D==="weeks"?b(N/p[D]):this.$d[D],N||0},A.add=function(k,N,D){var M;return M=N?k*p[v(N)]:m(k)?k.$ms:g(k,this).$ms,g(this.$ms+M*(D?-1:1),this)},A.subtract=function(k,N){return this.add(k,N,!0)},A.locale=function(k){var N=this.clone();return N.$l=k,N},A.clone=function(){return g(this.$ms,this)},A.humanize=function(k){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!k)},A.valueOf=function(){return this.asMilliseconds()},A.milliseconds=function(){return this.get("milliseconds")},A.asMilliseconds=function(){return this.as("milliseconds")},A.seconds=function(){return this.get("seconds")},A.asSeconds=function(){return this.as("seconds")},A.minutes=function(){return this.get("minutes")},A.asMinutes=function(){return this.as("minutes")},A.hours=function(){return this.get("hours")},A.asHours=function(){return this.as("hours")},A.days=function(){return this.get("days")},A.asDays=function(){return this.as("days")},A.weeks=function(){return this.get("weeks")},A.asWeeks=function(){return this.as("weeks")},A.months=function(){return this.get("months")},A.asMonths=function(){return this.as("months")},A.years=function(){return this.get("years")},A.asYears=function(){return this.as("years")},I}(),R=function(I,A,k){return I.add(A.years()*k,"y").add(A.months()*k,"M").add(A.days()*k,"d").add(A.hours()*k,"h").add(A.minutes()*k,"m").add(A.seconds()*k,"s").add(A.milliseconds()*k,"ms")};return function(I,A,k){t=k,r=k().$utils(),k.duration=function(M,F){var U=k.locale();return g(M,{$l:U},F)},k.isDuration=m;var N=A.prototype.add,D=A.prototype.subtract;A.prototype.add=function(M,F){return m(M)?R(this,M,1):N.bind(this)(M,F)},A.prototype.subtract=function(M,F){return m(M)?R(this,M,-1):D.bind(this)(M,F)}}})}(Lh)),Lh.exports}var II;function E6(){return II||(II=1,function(n){var e=qi&&qi.__createBinding||(Object.create?function(y,b,S,E){E===void 0&&(E=S);var C=Object.getOwnPropertyDescriptor(b,S);(!C||("get"in C?!b.__esModule:C.writable||C.configurable))&&(C={enumerable:!0,get:function(){return b[S]}}),Object.defineProperty(y,E,C)}:function(y,b,S,E){E===void 0&&(E=S),y[E]=b[S]}),t=qi&&qi.__setModuleDefault||(Object.create?function(y,b){Object.defineProperty(y,"default",{enumerable:!0,value:b})}:function(y,b){y.default=b}),r=qi&&qi.__importStar||function(){var y=function(b){return y=Object.getOwnPropertyNames||function(S){var E=[];for(var C in S)Object.prototype.hasOwnProperty.call(S,C)&&(E[E.length]=C);return E},y(b)};return function(b){if(b&&b.__esModule)return b;var S={};if(b!=null)for(var E=y(b),C=0;C<E.length;C++)E[C]!=="default"&&e(S,b,E[C]);return t(S,b),S}}(),s=qi&&qi.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(n,"__esModule",{value:!0}),n.date=n.getRemainingDaysInJalaliMonth=n.toGregorian=void 0,n.jalaliDate=f,n.gregoryDate=p,n.durationDate=m,p6();var i=s(j_()),o=r(SI()),a=s(g6()),l=s(v6()),c=s(b6()),d=s(S6());i.default.locale("fa"),i.default.extend(d.default),i.default.extend(a.default),i.default.extend(c.default),i.default.extend(o.default),i.default.extend(l.default),i.default.updateLocale("fa",o.faLocale);function f(){for(var y=[],b=0;b<arguments.length;b++)y[b]=arguments[b];return i.default.apply(void 0,y)}function p(){for(var y=[],b=0;b<arguments.length;b++)y[b]=arguments[b];return i.default.apply(void 0,y).locale("en")}function m(){for(var y,b=[],S=0;S<arguments.length;S++)b[S]=arguments[S];return(y=i.default).duration.apply(y,b)}var g=SI();Object.defineProperty(n,"toGregorian",{enumerable:!0,get:function(){return g.toGregorian}}),Object.defineProperty(n,"getRemainingDaysInJalaliMonth",{enumerable:!0,get:function(){return g.getRemainingDaysInJalaliMonth}});var v=j_();Object.defineProperty(n,"date",{enumerable:!0,get:function(){return s(v).default}})}(qi)),qi}var Go={},Vo={},RI;function AI(){if(RI)return Vo;RI=1,Object.defineProperty(Vo,"__esModule",{value:!0}),Vo.isObject=n,Vo.arrayToObject=e,Vo.removeEmpty=t,Vo.pickProperties=r,Vo.omitProperties=s,Vo.safeParseJson=i;function n(o){return!!(o&&typeof o=="object"&&o.constructor===Object)}function e(o,a){var l={};return o.forEach(function(c){var d=c[a];(typeof d=="string"||typeof d=="number")&&(l[d]=c)}),l}function t(o){return Object.keys(o).filter(function(a){var l=o[a];return l==null?!1:typeof l=="string"||Array.isArray(l)?l.length>0:!0}).reduce(function(a,l){var c=a;return c[l]=o[l],a},{})}function r(o,a){return!o||typeof o!="object"||Array.isArray(o)?{}:!Array.isArray(a)||a.length===0?{}:a.reduce(function(l,c){return o&&Object.prototype.hasOwnProperty.call(o,c)&&(l[c]=o[c]),l},{})}function s(o,a){return Object.fromEntries(Object.entries(o).filter(function(l){var c=l[0];return!a.includes(c)}))}function i(o){if(!o)return null;try{return JSON.parse(o)}catch{return null}}return Vo}var F_,kI;function LI(){if(kI)return F_;kI=1;function n(e,t){for(var r=-1,s=e==null?0:e.length;++r<s&&t(e[r],r,e)!==!1;);return e}return F_=n,F_}var U_,MI;function Wo(){if(MI)return U_;MI=1;function n(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}return U_=n,U_}var B_,NI;function OI(){if(NI)return B_;NI=1;var n=Wo(),e=Object.create,t=function(){function r(){}return function(s){if(!n(s))return{};if(e)return e(s);r.prototype=s;var i=new r;return r.prototype=void 0,i}}();return B_=t,B_}var $_,PI;function w6(){if(PI)return $_;PI=1;function n(e){return function(t,r,s){for(var i=-1,o=Object(t),a=s(t),l=a.length;l--;){var c=a[e?l:++i];if(r(o[c],c,o)===!1)break}return t}}return $_=n,$_}var z_,DI;function T6(){if(DI)return z_;DI=1;var n=w6(),e=n();return z_=e,z_}var q_,jI;function C6(){if(jI)return q_;jI=1;function n(e,t){for(var r=-1,s=Array(e);++r<e;)s[r]=t(r);return s}return q_=n,q_}var H_,FI;function UI(){if(FI)return H_;FI=1;var n=typeof Bi=="object"&&Bi&&Bi.Object===Object&&Bi;return H_=n,H_}var G_,BI;function Hi(){if(BI)return G_;BI=1;var n=UI(),e=typeof self=="object"&&self&&self.Object===Object&&self,t=n||e||Function("return this")();return G_=t,G_}var V_,$I;function ed(){if($I)return V_;$I=1;var n=Hi(),e=n.Symbol;return V_=e,V_}var W_,zI;function I6(){if(zI)return W_;zI=1;var n=ed(),e=Object.prototype,t=e.hasOwnProperty,r=e.toString,s=n?n.toStringTag:void 0;function i(o){var a=t.call(o,s),l=o[s];try{o[s]=void 0;var c=!0}catch{}var d=r.call(o);return c&&(a?o[s]=l:delete o[s]),d}return W_=i,W_}var K_,qI;function R6(){if(qI)return K_;qI=1;var n=Object.prototype,e=n.toString;function t(r){return e.call(r)}return K_=t,K_}var Y_,HI;function td(){if(HI)return Y_;HI=1;var n=ed(),e=I6(),t=R6(),r="[object Null]",s="[object Undefined]",i=n?n.toStringTag:void 0;function o(a){return a==null?a===void 0?s:r:i&&i in Object(a)?e(a):t(a)}return Y_=o,Y_}var X_,GI;function yl(){if(GI)return X_;GI=1;function n(e){return e!=null&&typeof e=="object"}return X_=n,X_}var Q_,VI;function A6(){if(VI)return Q_;VI=1;var n=td(),e=yl(),t="[object Arguments]";function r(s){return e(s)&&n(s)==t}return Q_=r,Q_}var J_,WI;function KI(){if(WI)return J_;WI=1;var n=A6(),e=yl(),t=Object.prototype,r=t.hasOwnProperty,s=t.propertyIsEnumerable,i=n(function(){return arguments}())?n:function(o){return e(o)&&r.call(o,"callee")&&!s.call(o,"callee")};return J_=i,J_}var Z_,YI;function vo(){if(YI)return Z_;YI=1;var n=Array.isArray;return Z_=n,Z_}var nd={exports:{}},ev,XI;function k6(){if(XI)return ev;XI=1;function n(){return!1}return ev=n,ev}nd.exports;var QI;function Mh(){return QI||(QI=1,function(n,e){var t=Hi(),r=k6(),s=e&&!e.nodeType&&e,i=s&&!0&&n&&!n.nodeType&&n,o=i&&i.exports===s,a=o?t.Buffer:void 0,l=a?a.isBuffer:void 0,c=l||r;n.exports=c}(nd,nd.exports)),nd.exports}var tv,JI;function ZI(){if(JI)return tv;JI=1;var n=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function t(r,s){var i=typeof r;return s=s??n,!!s&&(i=="number"||i!="symbol"&&e.test(r))&&r>-1&&r%1==0&&r<s}return tv=t,tv}var nv,eR;function rv(){if(eR)return nv;eR=1;var n=9007199254740991;function e(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=n}return nv=e,nv}var sv,tR;function L6(){if(tR)return sv;tR=1;var n=td(),e=rv(),t=yl(),r="[object Arguments]",s="[object Array]",i="[object Boolean]",o="[object Date]",a="[object Error]",l="[object Function]",c="[object Map]",d="[object Number]",f="[object Object]",p="[object RegExp]",m="[object Set]",g="[object String]",v="[object WeakMap]",y="[object ArrayBuffer]",b="[object DataView]",S="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",A="[object Uint8Array]",k="[object Uint8ClampedArray]",N="[object Uint16Array]",D="[object Uint32Array]",M={};M[S]=M[E]=M[C]=M[R]=M[I]=M[A]=M[k]=M[N]=M[D]=!0,M[r]=M[s]=M[y]=M[i]=M[b]=M[o]=M[a]=M[l]=M[c]=M[d]=M[f]=M[p]=M[m]=M[g]=M[v]=!1;function F(U){return t(U)&&e(U.length)&&!!M[n(U)]}return sv=F,sv}var iv,nR;function ov(){if(nR)return iv;nR=1;function n(e){return function(t){return e(t)}}return iv=n,iv}var rd={exports:{}};rd.exports;var rR;function av(){return rR||(rR=1,function(n,e){var t=UI(),r=e&&!e.nodeType&&e,s=r&&!0&&n&&!n.nodeType&&n,i=s&&s.exports===r,o=i&&t.process,a=function(){try{var l=s&&s.require&&s.require("util").types;return l||o&&o.binding&&o.binding("util")}catch{}}();n.exports=a}(rd,rd.exports)),rd.exports}var lv,sR;function cv(){if(sR)return lv;sR=1;var n=L6(),e=ov(),t=av(),r=t&&t.isTypedArray,s=r?e(r):n;return lv=s,lv}var uv,iR;function oR(){if(iR)return uv;iR=1;var n=C6(),e=KI(),t=vo(),r=Mh(),s=ZI(),i=cv(),o=Object.prototype,a=o.hasOwnProperty;function l(c,d){var f=t(c),p=!f&&e(c),m=!f&&!p&&r(c),g=!f&&!p&&!m&&i(c),v=f||p||m||g,y=v?n(c.length,String):[],b=y.length;for(var S in c)(d||a.call(c,S))&&!(v&&(S=="length"||m&&(S=="offset"||S=="parent")||g&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||s(S,b)))&&y.push(S);return y}return uv=l,uv}var dv,aR;function fv(){if(aR)return dv;aR=1;var n=Object.prototype;function e(t){var r=t&&t.constructor,s=typeof r=="function"&&r.prototype||n;return t===s}return dv=e,dv}var hv,lR;function cR(){if(lR)return hv;lR=1;function n(e,t){return function(r){return e(t(r))}}return hv=n,hv}var pv,uR;function M6(){if(uR)return pv;uR=1;var n=cR(),e=n(Object.keys,Object);return pv=e,pv}var mv,dR;function N6(){if(dR)return mv;dR=1;var n=fv(),e=M6(),t=Object.prototype,r=t.hasOwnProperty;function s(i){if(!n(i))return e(i);var o=[];for(var a in Object(i))r.call(i,a)&&a!="constructor"&&o.push(a);return o}return mv=s,mv}var gv,fR;function _v(){if(fR)return gv;fR=1;var n=td(),e=Wo(),t="[object AsyncFunction]",r="[object Function]",s="[object GeneratorFunction]",i="[object Proxy]";function o(a){if(!e(a))return!1;var l=n(a);return l==r||l==s||l==t||l==i}return gv=o,gv}var vv,hR;function pR(){if(hR)return vv;hR=1;var n=_v(),e=rv();function t(r){return r!=null&&e(r.length)&&!n(r)}return vv=t,vv}var yv,mR;function sd(){if(mR)return yv;mR=1;var n=oR(),e=N6(),t=pR();function r(s){return t(s)?n(s):e(s)}return yv=r,yv}var bv,gR;function O6(){if(gR)return bv;gR=1;var n=T6(),e=sd();function t(r,s){return r&&n(r,s,e)}return bv=t,bv}var xv,_R;function P6(){if(_R)return xv;_R=1;function n(){this.__data__=[],this.size=0}return xv=n,xv}var Sv,vR;function Ev(){if(vR)return Sv;vR=1;function n(e,t){return e===t||e!==e&&t!==t}return Sv=n,Sv}var wv,yR;function Nh(){if(yR)return wv;yR=1;var n=Ev();function e(t,r){for(var s=t.length;s--;)if(n(t[s][0],r))return s;return-1}return wv=e,wv}var Tv,bR;function D6(){if(bR)return Tv;bR=1;var n=Nh(),e=Array.prototype,t=e.splice;function r(s){var i=this.__data__,o=n(i,s);if(o<0)return!1;var a=i.length-1;return o==a?i.pop():t.call(i,o,1),--this.size,!0}return Tv=r,Tv}var Cv,xR;function j6(){if(xR)return Cv;xR=1;var n=Nh();function e(t){var r=this.__data__,s=n(r,t);return s<0?void 0:r[s][1]}return Cv=e,Cv}var Iv,SR;function F6(){if(SR)return Iv;SR=1;var n=Nh();function e(t){return n(this.__data__,t)>-1}return Iv=e,Iv}var Rv,ER;function U6(){if(ER)return Rv;ER=1;var n=Nh();function e(t,r){var s=this.__data__,i=n(s,t);return i<0?(++this.size,s.push([t,r])):s[i][1]=r,this}return Rv=e,Rv}var Av,wR;function Oh(){if(wR)return Av;wR=1;var n=P6(),e=D6(),t=j6(),r=F6(),s=U6();function i(o){var a=-1,l=o==null?0:o.length;for(this.clear();++a<l;){var c=o[a];this.set(c[0],c[1])}}return i.prototype.clear=n,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=r,i.prototype.set=s,Av=i,Av}var kv,TR;function B6(){if(TR)return kv;TR=1;var n=Oh();function e(){this.__data__=new n,this.size=0}return kv=e,kv}var Lv,CR;function $6(){if(CR)return Lv;CR=1;function n(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}return Lv=n,Lv}var Mv,IR;function z6(){if(IR)return Mv;IR=1;function n(e){return this.__data__.get(e)}return Mv=n,Mv}var Nv,RR;function q6(){if(RR)return Nv;RR=1;function n(e){return this.__data__.has(e)}return Nv=n,Nv}var Ov,AR;function H6(){if(AR)return Ov;AR=1;var n=Hi(),e=n["__core-js_shared__"];return Ov=e,Ov}var Pv,kR;function G6(){if(kR)return Pv;kR=1;var n=H6(),e=function(){var r=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function t(r){return!!e&&e in r}return Pv=t,Pv}var Dv,LR;function MR(){if(LR)return Dv;LR=1;var n=Function.prototype,e=n.toString;function t(r){if(r!=null){try{return e.call(r)}catch{}try{return r+""}catch{}}return""}return Dv=t,Dv}var jv,NR;function V6(){if(NR)return jv;NR=1;var n=_v(),e=G6(),t=Wo(),r=MR(),s=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,l=o.toString,c=a.hasOwnProperty,d=RegExp("^"+l.call(c).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(p){if(!t(p)||e(p))return!1;var m=n(p)?d:i;return m.test(r(p))}return jv=f,jv}var Fv,OR;function W6(){if(OR)return Fv;OR=1;function n(e,t){return e==null?void 0:e[t]}return Fv=n,Fv}var Uv,PR;function bl(){if(PR)return Uv;PR=1;var n=V6(),e=W6();function t(r,s){var i=e(r,s);return n(i)?i:void 0}return Uv=t,Uv}var Bv,DR;function $v(){if(DR)return Bv;DR=1;var n=bl(),e=Hi(),t=n(e,"Map");return Bv=t,Bv}var zv,jR;function Ph(){if(jR)return zv;jR=1;var n=bl(),e=n(Object,"create");return zv=e,zv}var qv,FR;function K6(){if(FR)return qv;FR=1;var n=Ph();function e(){this.__data__=n?n(null):{},this.size=0}return qv=e,qv}var Hv,UR;function Y6(){if(UR)return Hv;UR=1;function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}return Hv=n,Hv}var Gv,BR;function X6(){if(BR)return Gv;BR=1;var n=Ph(),e="__lodash_hash_undefined__",t=Object.prototype,r=t.hasOwnProperty;function s(i){var o=this.__data__;if(n){var a=o[i];return a===e?void 0:a}return r.call(o,i)?o[i]:void 0}return Gv=s,Gv}var Vv,$R;function Q6(){if($R)return Vv;$R=1;var n=Ph(),e=Object.prototype,t=e.hasOwnProperty;function r(s){var i=this.__data__;return n?i[s]!==void 0:t.call(i,s)}return Vv=r,Vv}var Wv,zR;function J6(){if(zR)return Wv;zR=1;var n=Ph(),e="__lodash_hash_undefined__";function t(r,s){var i=this.__data__;return this.size+=this.has(r)?0:1,i[r]=n&&s===void 0?e:s,this}return Wv=t,Wv}var Kv,qR;function Z6(){if(qR)return Kv;qR=1;var n=K6(),e=Y6(),t=X6(),r=Q6(),s=J6();function i(o){var a=-1,l=o==null?0:o.length;for(this.clear();++a<l;){var c=o[a];this.set(c[0],c[1])}}return i.prototype.clear=n,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=r,i.prototype.set=s,Kv=i,Kv}var Yv,HR;function eq(){if(HR)return Yv;HR=1;var n=Z6(),e=Oh(),t=$v();function r(){this.size=0,this.__data__={hash:new n,map:new(t||e),string:new n}}return Yv=r,Yv}var Xv,GR;function tq(){if(GR)return Xv;GR=1;function n(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}return Xv=n,Xv}var Qv,VR;function Dh(){if(VR)return Qv;VR=1;var n=tq();function e(t,r){var s=t.__data__;return n(r)?s[typeof r=="string"?"string":"hash"]:s.map}return Qv=e,Qv}var Jv,WR;function nq(){if(WR)return Jv;WR=1;var n=Dh();function e(t){var r=n(this,t).delete(t);return this.size-=r?1:0,r}return Jv=e,Jv}var Zv,KR;function rq(){if(KR)return Zv;KR=1;var n=Dh();function e(t){return n(this,t).get(t)}return Zv=e,Zv}var ey,YR;function sq(){if(YR)return ey;YR=1;var n=Dh();function e(t){return n(this,t).has(t)}return ey=e,ey}var ty,XR;function iq(){if(XR)return ty;XR=1;var n=Dh();function e(t,r){var s=n(this,t),i=s.size;return s.set(t,r),this.size+=s.size==i?0:1,this}return ty=e,ty}var ny,QR;function ry(){if(QR)return ny;QR=1;var n=eq(),e=nq(),t=rq(),r=sq(),s=iq();function i(o){var a=-1,l=o==null?0:o.length;for(this.clear();++a<l;){var c=o[a];this.set(c[0],c[1])}}return i.prototype.clear=n,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=r,i.prototype.set=s,ny=i,ny}var sy,JR;function oq(){if(JR)return sy;JR=1;var n=Oh(),e=$v(),t=ry(),r=200;function s(i,o){var a=this.__data__;if(a instanceof n){var l=a.__data__;if(!e||l.length<r-1)return l.push([i,o]),this.size=++a.size,this;a=this.__data__=new t(l)}return a.set(i,o),this.size=a.size,this}return sy=s,sy}var iy,ZR;function oy(){if(ZR)return iy;ZR=1;var n=Oh(),e=B6(),t=$6(),r=z6(),s=q6(),i=oq();function o(a){var l=this.__data__=new n(a);this.size=l.size}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=s,o.prototype.set=i,iy=o,iy}var ay,eA;function aq(){if(eA)return ay;eA=1;var n="__lodash_hash_undefined__";function e(t){return this.__data__.set(t,n),this}return ay=e,ay}var ly,tA;function lq(){if(tA)return ly;tA=1;function n(e){return this.__data__.has(e)}return ly=n,ly}var cy,nA;function cq(){if(nA)return cy;nA=1;var n=ry(),e=aq(),t=lq();function r(s){var i=-1,o=s==null?0:s.length;for(this.__data__=new n;++i<o;)this.add(s[i])}return r.prototype.add=r.prototype.push=e,r.prototype.has=t,cy=r,cy}var uy,rA;function uq(){if(rA)return uy;rA=1;function n(e,t){for(var r=-1,s=e==null?0:e.length;++r<s;)if(t(e[r],r,e))return!0;return!1}return uy=n,uy}var dy,sA;function dq(){if(sA)return dy;sA=1;function n(e,t){return e.has(t)}return dy=n,dy}var fy,iA;function oA(){if(iA)return fy;iA=1;var n=cq(),e=uq(),t=dq(),r=1,s=2;function i(o,a,l,c,d,f){var p=l&r,m=o.length,g=a.length;if(m!=g&&!(p&&g>m))return!1;var v=f.get(o),y=f.get(a);if(v&&y)return v==a&&y==o;var b=-1,S=!0,E=l&s?new n:void 0;for(f.set(o,a),f.set(a,o);++b<m;){var C=o[b],R=a[b];if(c)var I=p?c(R,C,b,a,o,f):c(C,R,b,o,a,f);if(I!==void 0){if(I)continue;S=!1;break}if(E){if(!e(a,function(A,k){if(!t(E,k)&&(C===A||d(C,A,l,c,f)))return E.push(k)})){S=!1;break}}else if(!(C===R||d(C,R,l,c,f))){S=!1;break}}return f.delete(o),f.delete(a),S}return fy=i,fy}var hy,aA;function lA(){if(aA)return hy;aA=1;var n=Hi(),e=n.Uint8Array;return hy=e,hy}var py,cA;function fq(){if(cA)return py;cA=1;function n(e){var t=-1,r=Array(e.size);return e.forEach(function(s,i){r[++t]=[i,s]}),r}return py=n,py}var my,uA;function hq(){if(uA)return my;uA=1;function n(e){var t=-1,r=Array(e.size);return e.forEach(function(s){r[++t]=s}),r}return my=n,my}var gy,dA;function pq(){if(dA)return gy;dA=1;var n=ed(),e=lA(),t=Ev(),r=oA(),s=fq(),i=hq(),o=1,a=2,l="[object Boolean]",c="[object Date]",d="[object Error]",f="[object Map]",p="[object Number]",m="[object RegExp]",g="[object Set]",v="[object String]",y="[object Symbol]",b="[object ArrayBuffer]",S="[object DataView]",E=n?n.prototype:void 0,C=E?E.valueOf:void 0;function R(I,A,k,N,D,M,F){switch(k){case S:if(I.byteLength!=A.byteLength||I.byteOffset!=A.byteOffset)return!1;I=I.buffer,A=A.buffer;case b:return!(I.byteLength!=A.byteLength||!M(new e(I),new e(A)));case l:case c:case p:return t(+I,+A);case d:return I.name==A.name&&I.message==A.message;case m:case v:return I==A+"";case f:var U=s;case g:var $=N&o;if(U||(U=i),I.size!=A.size&&!$)return!1;var q=F.get(I);if(q)return q==A;N|=a,F.set(I,A);var G=r(U(I),U(A),N,D,M,F);return F.delete(I),G;case y:if(C)return C.call(I)==C.call(A)}return!1}return gy=R,gy}var _y,fA;function hA(){if(fA)return _y;fA=1;function n(e,t){for(var r=-1,s=t.length,i=e.length;++r<s;)e[i+r]=t[r];return e}return _y=n,_y}var vy,pA;function mA(){if(pA)return vy;pA=1;var n=hA(),e=vo();function t(r,s,i){var o=s(r);return e(r)?o:n(o,i(r))}return vy=t,vy}var yy,gA;function mq(){if(gA)return yy;gA=1;function n(e,t){for(var r=-1,s=e==null?0:e.length,i=0,o=[];++r<s;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}return yy=n,yy}var by,_A;function vA(){if(_A)return by;_A=1;function n(){return[]}return by=n,by}var xy,yA;function Sy(){if(yA)return xy;yA=1;var n=mq(),e=vA(),t=Object.prototype,r=t.propertyIsEnumerable,s=Object.getOwnPropertySymbols,i=s?function(o){return o==null?[]:(o=Object(o),n(s(o),function(a){return r.call(o,a)}))}:e;return xy=i,xy}var Ey,bA;function xA(){if(bA)return Ey;bA=1;var n=mA(),e=Sy(),t=sd();function r(s){return n(s,t,e)}return Ey=r,Ey}var wy,SA;function gq(){if(SA)return wy;SA=1;var n=xA(),e=1,t=Object.prototype,r=t.hasOwnProperty;function s(i,o,a,l,c,d){var f=a&e,p=n(i),m=p.length,g=n(o),v=g.length;if(m!=v&&!f)return!1;for(var y=m;y--;){var b=p[y];if(!(f?b in o:r.call(o,b)))return!1}var S=d.get(i),E=d.get(o);if(S&&E)return S==o&&E==i;var C=!0;d.set(i,o),d.set(o,i);for(var R=f;++y<m;){b=p[y];var I=i[b],A=o[b];if(l)var k=f?l(A,I,b,o,i,d):l(I,A,b,i,o,d);if(!(k===void 0?I===A||c(I,A,a,l,d):k)){C=!1;break}R||(R=b=="constructor")}if(C&&!R){var N=i.constructor,D=o.constructor;N!=D&&"constructor"in i&&"constructor"in o&&!(typeof N=="function"&&N instanceof N&&typeof D=="function"&&D instanceof D)&&(C=!1)}return d.delete(i),d.delete(o),C}return wy=s,wy}var Ty,EA;function _q(){if(EA)return Ty;EA=1;var n=bl(),e=Hi(),t=n(e,"DataView");return Ty=t,Ty}var Cy,wA;function vq(){if(wA)return Cy;wA=1;var n=bl(),e=Hi(),t=n(e,"Promise");return Cy=t,Cy}var Iy,TA;function yq(){if(TA)return Iy;TA=1;var n=bl(),e=Hi(),t=n(e,"Set");return Iy=t,Iy}var Ry,CA;function bq(){if(CA)return Ry;CA=1;var n=bl(),e=Hi(),t=n(e,"WeakMap");return Ry=t,Ry}var Ay,IA;function jh(){if(IA)return Ay;IA=1;var n=_q(),e=$v(),t=vq(),r=yq(),s=bq(),i=td(),o=MR(),a="[object Map]",l="[object Object]",c="[object Promise]",d="[object Set]",f="[object WeakMap]",p="[object DataView]",m=o(n),g=o(e),v=o(t),y=o(r),b=o(s),S=i;return(n&&S(new n(new ArrayBuffer(1)))!=p||e&&S(new e)!=a||t&&S(t.resolve())!=c||r&&S(new r)!=d||s&&S(new s)!=f)&&(S=function(E){var C=i(E),R=C==l?E.constructor:void 0,I=R?o(R):"";if(I)switch(I){case m:return p;case g:return a;case v:return c;case y:return d;case b:return f}return C}),Ay=S,Ay}var ky,RA;function xq(){if(RA)return ky;RA=1;var n=oy(),e=oA(),t=pq(),r=gq(),s=jh(),i=vo(),o=Mh(),a=cv(),l=1,c="[object Arguments]",d="[object Array]",f="[object Object]",p=Object.prototype,m=p.hasOwnProperty;function g(v,y,b,S,E,C){var R=i(v),I=i(y),A=R?d:s(v),k=I?d:s(y);A=A==c?f:A,k=k==c?f:k;var N=A==f,D=k==f,M=A==k;if(M&&o(v)){if(!o(y))return!1;R=!0,N=!1}if(M&&!N)return C||(C=new n),R||a(v)?e(v,y,b,S,E,C):t(v,y,A,b,S,E,C);if(!(b&l)){var F=N&&m.call(v,"__wrapped__"),U=D&&m.call(y,"__wrapped__");if(F||U){var $=F?v.value():v,q=U?y.value():y;return C||(C=new n),E($,q,b,S,C)}}return M?(C||(C=new n),r(v,y,b,S,E,C)):!1}return ky=g,ky}var Ly,AA;function kA(){if(AA)return Ly;AA=1;var n=xq(),e=yl();function t(r,s,i,o,a){return r===s?!0:r==null||s==null||!e(r)&&!e(s)?r!==r&&s!==s:n(r,s,i,o,t,a)}return Ly=t,Ly}var My,LA;function Sq(){if(LA)return My;LA=1;var n=oy(),e=kA(),t=1,r=2;function s(i,o,a,l){var c=a.length,d=c,f=!l;if(i==null)return!d;for(i=Object(i);c--;){var p=a[c];if(f&&p[2]?p[1]!==i[p[0]]:!(p[0]in i))return!1}for(;++c<d;){p=a[c];var m=p[0],g=i[m],v=p[1];if(f&&p[2]){if(g===void 0&&!(m in i))return!1}else{var y=new n;if(l)var b=l(g,v,m,i,o,y);if(!(b===void 0?e(v,g,t|r,l,y):b))return!1}}return!0}return My=s,My}var Ny,MA;function NA(){if(MA)return Ny;MA=1;var n=Wo();function e(t){return t===t&&!n(t)}return Ny=e,Ny}var Oy,OA;function Eq(){if(OA)return Oy;OA=1;var n=NA(),e=sd();function t(r){for(var s=e(r),i=s.length;i--;){var o=s[i],a=r[o];s[i]=[o,a,n(a)]}return s}return Oy=t,Oy}var Py,PA;function DA(){if(PA)return Py;PA=1;function n(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}return Py=n,Py}var Dy,jA;function wq(){if(jA)return Dy;jA=1;var n=Sq(),e=Eq(),t=DA();function r(s){var i=e(s);return i.length==1&&i[0][2]?t(i[0][0],i[0][1]):function(o){return o===s||n(o,s,i)}}return Dy=r,Dy}var jy,FA;function Fh(){if(FA)return jy;FA=1;var n=td(),e=yl(),t="[object Symbol]";function r(s){return typeof s=="symbol"||e(s)&&n(s)==t}return jy=r,jy}var Fy,UA;function Uy(){if(UA)return Fy;UA=1;var n=vo(),e=Fh(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function s(i,o){if(n(i))return!1;var a=typeof i;return a=="number"||a=="symbol"||a=="boolean"||i==null||e(i)?!0:r.test(i)||!t.test(i)||o!=null&&i in Object(o)}return Fy=s,Fy}var By,BA;function Tq(){if(BA)return By;BA=1;var n=ry(),e="Expected a function";function t(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new TypeError(e);var i=function(){var o=arguments,a=s?s.apply(this,o):o[0],l=i.cache;if(l.has(a))return l.get(a);var c=r.apply(this,o);return i.cache=l.set(a,c)||l,c};return i.cache=new(t.Cache||n),i}return t.Cache=n,By=t,By}var $y,$A;function Cq(){if($A)return $y;$A=1;var n=Tq(),e=500;function t(r){var s=n(r,function(o){return i.size===e&&i.clear(),o}),i=s.cache;return s}return $y=t,$y}var zy,zA;function Iq(){if(zA)return zy;zA=1;var n=Cq(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=n(function(s){var i=[];return s.charCodeAt(0)===46&&i.push(""),s.replace(e,function(o,a,l,c){i.push(l?c.replace(t,"$1"):a||o)}),i});return zy=r,zy}var qy,qA;function Rq(){if(qA)return qy;qA=1;function n(e,t){for(var r=-1,s=e==null?0:e.length,i=Array(s);++r<s;)i[r]=t(e[r],r,e);return i}return qy=n,qy}var Hy,HA;function Aq(){if(HA)return Hy;HA=1;var n=ed(),e=Rq(),t=vo(),r=Fh(),s=n?n.prototype:void 0,i=s?s.toString:void 0;function o(a){if(typeof a=="string")return a;if(t(a))return e(a,o)+"";if(r(a))return i?i.call(a):"";var l=a+"";return l=="0"&&1/a==-1/0?"-0":l}return Hy=o,Hy}var Gy,GA;function id(){if(GA)return Gy;GA=1;var n=Aq();function e(t){return t==null?"":n(t)}return Gy=e,Gy}var Vy,VA;function WA(){if(VA)return Vy;VA=1;var n=vo(),e=Uy(),t=Iq(),r=id();function s(i,o){return n(i)?i:e(i,o)?[i]:t(r(i))}return Vy=s,Vy}var Wy,KA;function Uh(){if(KA)return Wy;KA=1;var n=Fh();function e(t){if(typeof t=="string"||n(t))return t;var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}return Wy=e,Wy}var Ky,YA;function XA(){if(YA)return Ky;YA=1;var n=WA(),e=Uh();function t(r,s){s=n(s,r);for(var i=0,o=s.length;r!=null&&i<o;)r=r[e(s[i++])];return i&&i==o?r:void 0}return Ky=t,Ky}var Yy,QA;function kq(){if(QA)return Yy;QA=1;var n=XA();function e(t,r,s){var i=t==null?void 0:n(t,r);return i===void 0?s:i}return Yy=e,Yy}var Xy,JA;function Lq(){if(JA)return Xy;JA=1;function n(e,t){return e!=null&&t in Object(e)}return Xy=n,Xy}var Qy,ZA;function Mq(){if(ZA)return Qy;ZA=1;var n=WA(),e=KI(),t=vo(),r=ZI(),s=rv(),i=Uh();function o(a,l,c){l=n(l,a);for(var d=-1,f=l.length,p=!1;++d<f;){var m=i(l[d]);if(!(p=a!=null&&c(a,m)))break;a=a[m]}return p||++d!=f?p:(f=a==null?0:a.length,!!f&&s(f)&&r(m,f)&&(t(a)||e(a)))}return Qy=o,Qy}var Jy,ek;function Nq(){if(ek)return Jy;ek=1;var n=Lq(),e=Mq();function t(r,s){return r!=null&&e(r,s,n)}return Jy=t,Jy}var Zy,tk;function Oq(){if(tk)return Zy;tk=1;var n=kA(),e=kq(),t=Nq(),r=Uy(),s=NA(),i=DA(),o=Uh(),a=1,l=2;function c(d,f){return r(d)&&s(f)?i(o(d),f):function(p){var m=e(p,d);return m===void 0&&m===f?t(p,d):n(f,m,a|l)}}return Zy=c,Zy}var e0,nk;function Pq(){if(nk)return e0;nk=1;function n(e){return e}return e0=n,e0}var t0,rk;function Dq(){if(rk)return t0;rk=1;function n(e){return function(t){return t==null?void 0:t[e]}}return t0=n,t0}var n0,sk;function jq(){if(sk)return n0;sk=1;var n=XA();function e(t){return function(r){return n(r,t)}}return n0=e,n0}var r0,ik;function Fq(){if(ik)return r0;ik=1;var n=Dq(),e=jq(),t=Uy(),r=Uh();function s(i){return t(i)?n(r(i)):e(i)}return r0=s,r0}var s0,ok;function Uq(){if(ok)return s0;ok=1;var n=wq(),e=Oq(),t=Pq(),r=vo(),s=Fq();function i(o){return typeof o=="function"?o:o==null?t:typeof o=="object"?r(o)?e(o[0],o[1]):n(o):s(o)}return s0=i,s0}var i0,ak;function o0(){if(ak)return i0;ak=1;var n=cR(),e=n(Object.getPrototypeOf,Object);return i0=e,i0}var a0,lk;function Bq(){if(lk)return a0;lk=1;var n=LI(),e=OI(),t=O6(),r=Uq(),s=o0(),i=vo(),o=Mh(),a=_v(),l=Wo(),c=cv();function d(f,p,m){var g=i(f),v=g||o(f)||c(f);if(p=r(p,4),m==null){var y=f&&f.constructor;v?m=g?new y:[]:l(f)?m=a(y)?e(s(f)):{}:m={}}return(v?n:t)(f,function(b,S,E){return p(m,b,S,E)}),m}return a0=d,a0}var l0,ck;function $q(){if(ck)return l0;ck=1;function n(e,t,r){var s=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++s<i;)o[s]=e[s+t];return o}return l0=n,l0}var c0,uk;function zq(){if(uk)return c0;uk=1;var n=$q();function e(t,r,s){var i=t.length;return s=s===void 0?i:s,!r&&s>=i?t:n(t,r,s)}return c0=e,c0}var u0,dk;function fk(){if(dk)return u0;dk=1;var n="\\ud800-\\udfff",e="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=e+t+r,i="\\ufe0e\\ufe0f",o="\\u200d",a=RegExp("["+o+n+s+i+"]");function l(c){return a.test(c)}return u0=l,u0}var d0,hk;function qq(){if(hk)return d0;hk=1;function n(e){return e.split("")}return d0=n,d0}var f0,pk;function Hq(){if(pk)return f0;pk=1;var n="\\ud800-\\udfff",e="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=e+t+r,i="\\ufe0e\\ufe0f",o="["+n+"]",a="["+s+"]",l="\\ud83c[\\udffb-\\udfff]",c="(?:"+a+"|"+l+")",d="[^"+n+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",m="\\u200d",g=c+"?",v="["+i+"]?",y="(?:"+m+"(?:"+[d,f,p].join("|")+")"+v+g+")*",b=v+g+y,S="(?:"+[d+a+"?",a,f,p,o].join("|")+")",E=RegExp(l+"(?="+l+")|"+S+b,"g");function C(R){return R.match(E)||[]}return f0=C,f0}var h0,mk;function Gq(){if(mk)return h0;mk=1;var n=qq(),e=fk(),t=Hq();function r(s){return e(s)?t(s):n(s)}return h0=r,h0}var p0,gk;function Vq(){if(gk)return p0;gk=1;var n=zq(),e=fk(),t=Gq(),r=id();function s(i){return function(o){o=r(o);var a=e(o)?t(o):void 0,l=a?a[0]:o.charAt(0),c=a?n(a,1).join(""):o.slice(1);return l[i]()+c}}return p0=s,p0}var m0,_k;function Wq(){if(_k)return m0;_k=1;var n=Vq(),e=n("toUpperCase");return m0=e,m0}var g0,vk;function Kq(){if(vk)return g0;vk=1;var n=id(),e=Wq();function t(r){return e(n(r).toLowerCase())}return g0=t,g0}var _0,yk;function Yq(){if(yk)return _0;yk=1;function n(e,t,r,s){var i=-1,o=e==null?0:e.length;for(s&&o&&(r=e[++i]);++i<o;)r=t(r,e[i],i,e);return r}return _0=n,_0}var v0,bk;function Xq(){if(bk)return v0;bk=1;function n(e){return function(t){return e==null?void 0:e[t]}}return v0=n,v0}var y0,xk;function Qq(){if(xk)return y0;xk=1;var n=Xq(),e={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},t=n(e);return y0=t,y0}var b0,Sk;function Jq(){if(Sk)return b0;Sk=1;var n=Qq(),e=id(),t=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,r="\\u0300-\\u036f",s="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=r+s+i,a="["+o+"]",l=RegExp(a,"g");function c(d){return d=e(d),d&&d.replace(t,n).replace(l,"")}return b0=c,b0}var x0,Ek;function Zq(){if(Ek)return x0;Ek=1;var n=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function e(t){return t.match(n)||[]}return x0=e,x0}var S0,wk;function e8(){if(wk)return S0;wk=1;var n=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function e(t){return n.test(t)}return S0=e,S0}var E0,Tk;function t8(){if(Tk)return E0;Tk=1;var n="\\ud800-\\udfff",e="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=e+t+r,i="\\u2700-\\u27bf",o="a-z\\xdf-\\xf6\\xf8-\\xff",a="\\xac\\xb1\\xd7\\xf7",l="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",c="\\u2000-\\u206f",d=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",f="A-Z\\xc0-\\xd6\\xd8-\\xde",p="\\ufe0e\\ufe0f",m=a+l+c+d,g="['’]",v="["+m+"]",y="["+s+"]",b="\\d+",S="["+i+"]",E="["+o+"]",C="[^"+n+m+b+i+o+f+"]",R="\\ud83c[\\udffb-\\udfff]",I="(?:"+y+"|"+R+")",A="[^"+n+"]",k="(?:\\ud83c[\\udde6-\\uddff]){2}",N="[\\ud800-\\udbff][\\udc00-\\udfff]",D="["+f+"]",M="\\u200d",F="(?:"+E+"|"+C+")",U="(?:"+D+"|"+C+")",$="(?:"+g+"(?:d|ll|m|re|s|t|ve))?",q="(?:"+g+"(?:D|LL|M|RE|S|T|VE))?",G=I+"?",V="["+p+"]?",z="(?:"+M+"(?:"+[A,k,N].join("|")+")"+V+G+")*",B="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",P="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",H=V+G+z,Z="(?:"+[S,k,N].join("|")+")"+H,Q=RegExp([D+"?"+E+"+"+$+"(?="+[v,D,"$"].join("|")+")",U+"+"+q+"(?="+[v,D+F,"$"].join("|")+")",D+"?"+F+"+"+$,D+"+"+q,P,B,b,Z].join("|"),"g");function J(ee){return ee.match(Q)||[]}return E0=J,E0}var w0,Ck;function n8(){if(Ck)return w0;Ck=1;var n=Zq(),e=e8(),t=id(),r=t8();function s(i,o,a){return i=t(i),o=a?void 0:o,o===void 0?e(i)?r(i):n(i):i.match(o)||[]}return w0=s,w0}var T0,Ik;function Rk(){if(Ik)return T0;Ik=1;var n=Yq(),e=Jq(),t=n8(),r="['’]",s=RegExp(r,"g");function i(o){return function(a){return n(t(e(a).replace(s,"")),o,"")}}return T0=i,T0}var C0,Ak;function r8(){if(Ak)return C0;Ak=1;var n=Kq(),e=Rk(),t=e(function(r,s,i){return s=s.toLowerCase(),r+(i?n(s):s)});return C0=t,C0}var I0,kk;function s8(){if(kk)return I0;kk=1;var n=Rk(),e=n(function(t,r,s){return t+(s?"_":"")+r.toLowerCase()});return I0=e,I0}var Lk;function i8(){if(Lk)return Go;Lk=1;var n=Go&&Go.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(Go,"__esModule",{value:!0}),Go.camelize=a,Go.snakize=l,Go.snakeToCamelCase=c,Go.lowerSnakeToCamelCase=d;var e=AI(),t=n(Bq()),r=n(r8()),s=n(s8()),i=function(f){return f.replace(/(_\w)/g,function(p){return p[1].toUpperCase()})},o=function(f){return f===f.toUpperCase()&&f!==f.toLowerCase()?f.toLowerCase().replace(/(_\w)/g,function(p){return p[1].toUpperCase()}):f.replace(/(_\w)/g,function(p){return p[1].toUpperCase()})};function a(f,p){return f&&(typeof f=="string"?(0,r.default)(f):Array.isArray(f)?f.map(function(m){return p&&p.includes(m)?m:(0,e.isObject)(m)||Array.isArray(m)?a(m):m}):(0,e.isObject)(f)?(0,t.default)(f,function(m,g,v){var y=p&&p.includes(v)?v:(0,r.default)(v);m[y]=(0,e.isObject)(g)||Array.isArray(g)?a(g):g},{}):f)}function l(f,p){return f&&(typeof f=="string"?(0,s.default)(f):Array.isArray(f)?f.map(function(m){return p&&p.includes(m)?m:(0,e.isObject)(m)||Array.isArray(m)?l(m,p):m}):(0,e.isObject)(f)?(0,t.default)(f,function(m,g,v){var y=p&&p.includes(v)?v:(0,s.default)(v);m[y]=(0,e.isObject)(g)||Array.isArray(g)?l(g,p):g},{}):f)}function c(f){if(typeof f=="string")return i(f);if((0,e.isObject)(f)){var p={};for(var m in f)p[i(m)]=typeof f[m]=="string"?f[m]:c(f[m]);return p}return Array.isArray(f)?f.map(function(g){return c(g)}):f}function d(f){if((0,e.isObject)(f)){var p={};for(var m in f)p[o(m)]=typeof f[m]=="string"?f[m]:d(f[m]);return p}return Array.isArray(f)?f.map(function(g){return d(g)}):f}return Go}var Bh={},Mk;function o8(){if(Mk)return Bh;Mk=1,Object.defineProperty(Bh,"__esModule",{value:!0}),Bh.castValue=n;function n(e,t){if(e===null||typeof t!="object")return e;var r=t.type;if(Array.isArray(r)){if(e===null&&r.includes("null"))return e;r=r.find(function(d){return d!=="null"})||r[0]}switch(r){case"integer":case"number":{if(typeof e=="string"){var s=e.replace(/\s/g,"");if(s==="")return e;var i=Number(s);if(!Number.isNaN(i))return i;var o=Number.parseFloat(s);if(!Number.isNaN(o))return o}return e}case"boolean":{if(typeof e=="string"){var a=e.trim().toLowerCase();if(a==="true"||a==="1"||a==="yes"||a==="on")return!0;if(a==="false"||a==="0"||a==="no"||a==="off"||a==="")return!1}return typeof e=="number"?e!==0:e}case"string":return typeof e!="string"?e==null?"":String(e):e;case"object":{if(typeof e=="object"&&!Array.isArray(e)&&t.properties&&typeof t.properties=="object"){var l={};for(var c in t.properties)Object.prototype.hasOwnProperty.call(e,c)&&(l[c]=n(e[c],t.properties[c]));for(var c in e)Object.prototype.hasOwnProperty.call(e,c)&&!Object.prototype.hasOwnProperty.call(l,c)&&(l[c]=e[c]);return l}return e}case"array":return Array.isArray(e)&&t.items?e.map(function(d){return n(d,t.items)}):e;default:return e}}return Bh}var $h={},Nk;function a8(){if(Nk)return $h;Nk=1,Object.defineProperty($h,"__esModule",{value:!0}),$h.copy=t;function n(r){navigator.clipboard.writeText("".concat(r))}function e(r){var s=document.createElement("input");s.value="".concat(r),document.body.append(s),s.select(),document.execCommand("copy"),s.remove()}function t(r){navigator.clipboard?n(r):e(r)}return $h}var Sa={},Gi={},Ok;function Pk(){if(Ok)return Gi;Ok=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.formatSalesCount=n,Gi.generateRandomNumber=e,Gi.numberSeparator=t,Gi.convertToEnDigit=r,Gi.digitsToPersianWords=s,Gi.digitsToPersianSuffixWords=i,Gi.digitsToPersianOrdinalWords=o,Gi.roundBigNumber=a;function n(l){return Number.isNaN(l)?"":Number(l)<10?"".concat(Number(l)):Number(l)<100?"+".concat(Math.floor(Number(l)/10)*10):Number(l)<1e3?"+".concat(Math.floor(Number(l)/100)*100):Number(l)<1e5?"+".concat(Math.floor(Number(l)/100)/10,"k"):"+".concat(Math.floor(Number(l)/1e3),"k")}function e(l,c){return c===void 0&&(c=1),Math.floor(Math.random()*(l-c+1))+c}function t(l){return typeof l!="number"&&typeof l!="string"?"":typeof l=="number"?l.toString().replace(/\B(?=(\d{3})+(?!\d))/g,"٬"):l.replace(/\B(?=(\d{3})+(?!\d))/g,"٬")}function r(l){var c=l;return typeof c!="string"&&typeof c!="number"?c:(typeof c=="number"&&(c="".concat(c)),c.replace(/۰/g,"0").replace(/۱/g,"1").replace(/۲/g,"2").replace(/۳/g,"3").replace(/۴/g,"4").replace(/۵/g,"5").replace(/۶/g,"6").replace(/۷/g,"7").replace(/۸/g,"8").replace(/۹/g,"9").replace(/٠/g,"0").replace(/١/g,"1").replace(/٢/g,"2").replace(/٣/g,"3").replace(/٤/g,"4").replace(/٥/g,"5").replace(/٦/g,"6").replace(/٧/g,"7").replace(/٨/g,"8").replace(/٩/g,"9"))}function s(l){for(var c=["","هزار","میلیون","میلیارد","تریلیون","کوادریلیون","کویینتیلیون","سکستیلیون"],d={0:["","یک","دو","سه","چهار","پنج","شش","هفت","هشت","نه"],1:["","ده","بیست","سی","چهل","پنجاه","شصت","هفتاد","هشتاد","نود"],2:["","صد","دویست","سیصد","چهارصد","پانصد","ششصد","هفتصد","هشتصد","نهصد"],exceptions:{0:"صفر",17:"هفده",18:"هجده",11:"یازده",13:"سیزده",19:"نوزده",12:"دوازده",14:"چهارده",15:"پانزده",16:"شانزده"}},f=l,p=f.toString().length,m=Math.ceil(p/3),g=[],v=0;v<m;v++){var y=[],b=Math.floor(f/100)%10,S=d[2][b]||"";S&&y.push(S);var E=f%100;if(E>10&&E<20){var C=E,R=d.exceptions[C]||"";R&&y.push(R)}else{var I=Math.floor(f/10)%10,A=d[1][I]||"";A&&y.push(A);var k=f%10,N=!S&&!A&&k===1&&v===1,D=N||!d[0][k]?"":d[0][k];D&&y.push(D)}var M=y.join(" و "),F=b||E,U=F?"".concat(M).concat(c[v]?"".concat(M?" ".concat(c[v]):c[v]):""):"";U&&g.push(U),f=Math.floor(f/1e3)}return l===0?"صفر":g.reverse().join(" و ")}function i(l){var c="",d=/3$/,f=/30$/;if(l===1)c="اولین";else if(f.test(l.toString()))c="".concat(s(l),"‌امین");else if(d.test(l.toString())&&!"".concat(l).endsWith("13")){var p=s(l).length;c="".concat(s(l).slice(0,Math.max(0,p-1)),"ومین")}else c="".concat(s(l),"مین");return c}function o(l){var c="",d=/3$/,f=/30$/;if(l===1)c="اول";else if(f.test(l.toString()))c="".concat(s(l),"‌ام");else if(d.test(l.toString())&&!"".concat(l).endsWith("13")){var p=s(l).length;c="".concat(s(l).slice(0,Math.max(0,p-1)),"وم")}else c="".concat(s(l),"م");return c}function a(l,c){return c===void 0&&(c=10),Number.isNaN(l)?"":l<=c?l:l<100?"+".concat(Math.floor(l/10)*10):l<1e3?"+".concat(Math.floor(l/100)*100):l<1e5?"+".concat(Math.floor(l/100)/10,"k"):"+".concat(Math.floor(l/1e3),"k")}return Gi}var Dk;function l8(){if(Dk)return Sa;Dk=1,Object.defineProperty(Sa,"__esModule",{value:!0}),Sa.rialToToman=e,Sa.rialToHumanizeToman=t,Sa.getDiscountPercent=r,Sa.currencyFormat=s,Sa.priceFormat=i;var n=Pk();function e(o,a){if(o===void 0&&(o=""),typeof o!="number"&&typeof o!="string")return"";var l=a==null?void 0:a.currency,c=a==null?void 0:a.separator,d=typeof o=="string"?Number.parseInt(o)/10:o/10;return l&&c?"".concat((0,n.numberSeparator)(d)," تومان"):!l&&c?(0,n.numberSeparator)(d):l&&!c?"".concat(d," تومان"):d}function t(o){return e(o,{currency:!0,separator:!0})}function r(o,a){if(!o)return 0;var l=o-a;return Math.round(l*100/o)}function s(o){return o===void 0&&(o=0),(0,n.numberSeparator)(e(o))}function i(o){return o===void 0&&(o=0),(0,n.numberSeparator)(Math.trunc(Number(e(o))))}return Sa}var wc={},jk;function c8(){if(jk)return wc;jk=1,Object.defineProperty(wc,"__esModule",{value:!0}),wc.generateArray=n,wc.range=e,wc.chunkArray=t;function n(r){try{return Array.from({length:r},function(s,i){return i})}catch{return[]}}function e(r,s,i){if(i===void 0&&(i=1),s===void 0&&(s=r,r=0),typeof r!="number"||typeof s!="number"||typeof i!="number")throw new TypeError("The start,end or step in range function must be number.");return Array.from({length:Math.ceil(s-r)/i},function(o,a){return r+a*i})}function t(r,s){for(var i=[],o=0;o<r.length;o+=s)i.push(r.slice(o,o+s));return i}return wc}var xl={},Fk;function u8(){if(Fk)return xl;Fk=1,Object.defineProperty(xl,"__esModule",{value:!0}),xl.popupManager=xl.PopupManager=void 0;var n=vI(),e=function(){function t(){this.maxZIndex=0,this.initialized=!1,this.topElements=[],this.setBodyOverflowTimeout=null}return t.prototype.init=function(){this.initialized||(this.maxZIndex=t.getMaxZIndex(),this.initialized=!0)},t.getMaxZIndex=function(){for(var r=1,s=document.querySelectorAll("body *"),i=0,o=s.length;i<o;i+=1){var a=s[i],l=Number.parseFloat(window.getComputedStyle(a).zIndex||a.style.zIndex);l>r&&(r=l)}return r},t.prototype.getNewZIndex=function(){return this.initialized||this.init(),this.maxZIndex+=1,this.maxZIndex},t.prototype.dispatchChangeEvent=function(){window.dispatchEvent(new CustomEvent("bs--top-elements-change",{detail:this.topElements}))},t.prototype.setBodyOverflow=function(r){r===void 0&&(r=0),this.setBodyOverflowTimeout&&clearTimeout(this.setBodyOverflowTimeout),this.topElements.length>0?(0,n.lockBodyScroll)():this.setBodyOverflowTimeout=setTimeout(function(){(0,n.unlockBodyScroll)()},r)},t.prototype.addToTopElements=function(r){this.topElements=this.topElements.filter(function(s){return s.uid!==r.uid}),this.topElements.unshift(r),this.dispatchChangeEvent()},t.prototype.removeFromTopElements=function(r){this.topElements=this.topElements.filter(function(s){return s.uid!==r.uid}),this.dispatchChangeEvent()},t.prototype.setIsOpen=function(r){this.addToTopElements(r),this.setBodyOverflow()},t.prototype.setIsClosed=function(r,s){s===void 0&&(s=0),this.topElements.some(function(i){return i.uid===r.uid})&&(this.removeFromTopElements(r),this.setBodyOverflow(s))},t.prototype.subscribe=function(r){window.addEventListener("bs--top-elements-change",r)},t.prototype.unsubscribe=function(r){window.removeEventListener("bs--top-elements-change",r)},t}();return xl.PopupManager=e,xl.popupManager=new e,xl}var Ko={},Uk;function d8(){if(Uk)return Ko;Uk=1;var n=Ko&&Ko.__extends||function(){var r=function(s,i){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,a){o.__proto__=a}||function(o,a){for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(o[l]=a[l])},r(s,i)};return function(s,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");r(s,i);function o(){this.constructor=s}s.prototype=i===null?Object.create(i):(o.prototype=i.prototype,new o)}}();Object.defineProperty(Ko,"__esModule",{value:!0}),Ko.bsSessionStorage=Ko.bsLocalStorage=void 0;var e=function(){function r(s){var i=s===void 0?{}:s,o=i.prefix,a=o===void 0?"bs::":o,l=i.storeType,c=l===void 0?"localStorage":l,d=i.eventName,f=d===void 0?"bs::localStorageChange":d;this.prefix=a,this.eventName=f;try{if(typeof window<"u"&&window[c]!==void 0){var p={localStorage:window==null?void 0:window.localStorage,sessionStorage:window==null?void 0:window.sessionStorage};this.store=p[c]}}catch{console.error("BsStore: Failed to access ".concat(c))}}return r.prototype.generateKey=function(s){return"".concat(this.prefix).concat(s)},r.prototype.getItem=function(s,i){var o;i===void 0&&(i=null);try{var a=(o=this.store)===null||o===void 0?void 0:o.getItem(this.generateKey(s));return typeof a=="string"?JSON.parse(a):i}catch{return i}},r.prototype.setItem=function(s,i){var o;try{return(o=this.store)===null||o===void 0||o.setItem(this.generateKey(s),JSON.stringify(i)),this.dispatchChangeEvent(),i}catch{return!1}},r.prototype.getOrSet=function(s,i){i===void 0&&(i=null);try{var o=this.generateKey(s);return this.store&&o in this.store?this.getItem(s):(this.setItem(s,i),i)}catch{return i}},r.prototype.removeItem=function(s){var i;try{return(i=this.store)===null||i===void 0||i.removeItem(this.generateKey(s)),this.dispatchChangeEvent(),!0}catch{return!1}},r.prototype.clear=function(){var s=this;try{return Object.keys(this.store||{}).forEach(function(i){var o;i.startsWith(s.prefix)&&((o=s.store)===null||o===void 0||o.removeItem(i))}),this.dispatchChangeEvent(),!0}catch{return!1}},r.prototype.dispatchChangeEvent=function(){typeof window<"u"&&window.dispatchEvent(new Event(this.eventName))},r}(),t=function(r){n(s,r);function s(){return r!==null&&r.apply(this,arguments)||this}return s.prototype.getItem=function(i,o){o===void 0&&(o=null);var a=r.prototype.getItem.call(this,i,o);return a&&typeof a=="object"&&"ttl"in a?a.ttl===-1||a.ttl>=Date.now()?a.value:(this.removeItem(i),null):a},s.prototype.setItem=function(i,o,a){a===void 0&&(a=-1);var l=a*1e3,c=r.prototype.setItem.call(this,i,{value:o,ttl:a===-1?-1:Date.now()+l});return c===!1?!1:o},s}(e);return Ko.bsLocalStorage=new t({storeType:"localStorage",eventName:"bs::localStorageChange"}),Ko.bsSessionStorage=new e({storeType:"sessionStorage",eventName:"bs::sessionStorageChange"}),Ko}var Yo={},Bk;function f8(){if(Bk)return Yo;Bk=1,Object.defineProperty(Yo,"__esModule",{value:!0}),Yo.generateRandomString=n,Yo.stripText=e,Yo.toEnglishDigits=t,Yo.trimText=s,Yo.hasPersianCharacter=i,Yo.replaceAllMatchedKeys=o;function n(a){return a===void 0&&(a=8),Math.random().toString(36).slice(2,2+a)}function e(a){return a===void 0&&(a=""),a.replace(/(<([^>]+)>)/gi,"")}function t(a){var l=/[\u0660-\u0669\u06F0-\u06F9]/g;return a.replace(l,function(c){var d;return String(((d=c.codePointAt(0))!==null&&d!==void 0?d:0)&15)})}var r=function(a){return a===" "};function s(a,l,c,d){l===void 0&&(l=80),c===void 0&&(c=100),d===void 0&&(d=200);var f=new Set([".",",","!","?","'","{","}","(",")","[","]","/"]),p=function(E,C){return f.has(C[E])&&r(C[E+1])},m=function(E,C,R,I){return E<R&&E>I&&p(E,C)};if(d<l||c>d||c<l)throw new Error("The minimum length must be less than the maximum, and the ideal must be between the minimum and maximum.");if(a.length<=c)return[a,""];for(var g=c,v=c,y=0,b,S=function(E){r(a[E])&&(y=y||E)};g<d||v>l;){if(m(g,a,d,l)){b=g+1;break}else if(m(v,a,d,l)){b=v+1;break}else S(g),S(v);g+=1,v-=1}return b===void 0&&(y&&y>=l&&y<=d?b=y:c-l<d-c?b=l:b=d),[a.slice(0,b),a.slice(b).trim()]}function i(a){return/[\u0600-\u06FF]/g.test(a)}function o(a,l){if(typeof l!="object")return a;var c=a;return Object.entries(l).forEach(function(d){var f=d[0],p=d[1];c=c.replace(new RegExp(f,"g"),p)}),c}return Yo}var yo={},$k;function h8(){if($k)return yo;$k=1;var n=yo&&yo.__awaiter||function(i,o,a,l){function c(d){return d instanceof a?d:new a(function(f){f(d)})}return new(a||(a=Promise))(function(d,f){function p(v){try{g(l.next(v))}catch(y){f(y)}}function m(v){try{g(l.throw(v))}catch(y){f(y)}}function g(v){v.done?d(v.value):c(v.value).then(p,m)}g((l=l.apply(i,o||[])).next())})},e=yo&&yo.__generator||function(i,o){var a={label:0,sent:function(){if(d[0]&1)throw d[1];return d[1]},trys:[],ops:[]},l,c,d,f=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return f.next=p(0),f.throw=p(1),f.return=p(2),typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function p(g){return function(v){return m([g,v])}}function m(g){if(l)throw new TypeError("Generator is already executing.");for(;f&&(f=0,g[0]&&(a=0)),a;)try{if(l=1,c&&(d=g[0]&2?c.return:g[0]?c.throw||((d=c.return)&&d.call(c),0):c.next)&&!(d=d.call(c,g[1])).done)return d;switch(c=0,d&&(g=[g[0]&2,d.value]),g[0]){case 0:case 1:d=g;break;case 4:return a.label++,{value:g[1],done:!1};case 5:a.label++,c=g[1],g=[0];continue;case 7:g=a.ops.pop(),a.trys.pop();continue;default:if(d=a.trys,!(d=d.length>0&&d[d.length-1])&&(g[0]===6||g[0]===2)){a=0;continue}if(g[0]===3&&(!d||g[1]>d[0]&&g[1]<d[3])){a.label=g[1];break}if(g[0]===6&&a.label<d[1]){a.label=d[1],d=g;break}if(d&&a.label<d[2]){a.label=d[2],a.ops.push(g);break}d[2]&&a.ops.pop(),a.trys.pop();continue}g=o.call(i,a)}catch(v){g=[6,v],c=0}finally{l=d=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}};Object.defineProperty(yo,"__esModule",{value:!0}),yo.sleep=t,yo.addTimeoutToPromise=r,yo.waitUntil=s;function t(i){return i===void 0&&(i=500),new Promise(function(o){setTimeout(o,i)})}function r(i){return n(this,arguments,void 0,function(o,a,l){var c,d,f;return a===void 0&&(a=100),l===void 0&&(l="Redis"),e(this,function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),d=new Promise(function(m,g){c=setTimeout(g,a)}),[4,Promise.race([d,o()])];case 1:return f=p.sent(),clearTimeout(c),[2,f];case 2:throw p.sent(),new Error("".concat(l," timed out"));case 3:return[2]}})})}function s(i,o){var a=o===void 0?{}:o,l=a.threshold,c=l===void 0?10:l,d=a.waitTime,f=d===void 0?1e4:d,p=0;return new Promise(function(m,g){function v(){var y=i();y?m(y):p*c<=f?setTimeout(v,c):g(),p+=1}v()})}return yo}var Tc={},zk;function p8(){if(zk)return Tc;zk=1,Object.defineProperty(Tc,"__esModule",{value:!0}),Tc.animateValue=void 0,Tc.easeOutSine=n;function n(r){return Math.sin(r*Math.PI/2)}var e={easeOutSine:n},t=function(r){return new Promise(function(s){var i=r.from,o=i===void 0?0:i,a=r.to,l=r.duration,c=r.step,d=r.easing,f=d===void 0?"easeOutSine":d,p,m=function(y){return o+(a-o)*y},g=function(y){return typeof c=="function"&&c(m(y))},v=typeof f=="function"?f:e[f];if(!l){g(1),s(null);return}window.requestAnimationFrame(function y(b){p||(p=b);var S=b-p,E=Math.min(S/l,1),C=v(E);g(C),S<l?window.requestAnimationFrame(y):s(null)})})};return Tc.animateValue=t,Tc}var R0={},qk;function m8(){return qk||(qk=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.DataSize=n.UNITS=void 0,n.UNITS={bit:[8],byte:[1],kilobyte:[1024],megabyte:[1024,1024],gigabyte:[1024,1024,1024]};var e=function(){function t(r,s){r===void 0&&(r=0),s===void 0&&(s="byte");try{if(typeof r!="number")throw new TypeError("Size must be a number");if(!(s in n.UNITS))throw new TypeError("Unit must be a valid unit: bit | byte | kilobyte | megabyte | gigabyte");this.size=n.UNITS[s].reduce(function(i,o){return i*o},r)}catch(i){console.error(i)}}return t.prototype.toBytes=function(){var r;return(r=this.size)!==null&&r!==void 0?r:0},t}();n.DataSize=e}(R0)),R0}var Ea={},Hk;function g8(){if(Hk)return Ea;Hk=1;var n={NODE_ENV:"production"};Object.defineProperty(Ea,"__esModule",{value:!0}),Ea.isServerSide=e,Ea.isClientSide=t,Ea.isProduction=r,Ea.isDevelopment=s,Ea.isStaging=i;function e(){return typeof window>"u"}function t(){return typeof window<"u"}function r(){return n.NODE_ENV==="production"}function s(){return n.NODE_ENV==="development"}function i(o){return/\.dev\b/g.test(o)}return Ea}var od={},A0,Gk;function _8(){if(Gk)return A0;Gk=1;function n(r,s,i){return Math.min(Math.max(r,s),i)}function e(r){return typeof r=="number"&&!isNaN(r)}function t(r={}){let a,l=[],c,d=0,f=0,p=0,m=!1,g,v;function y(V){a=V;const z=a.selectedScrollSnap(),{scrollBody:B,containerRect:P,axis:H}=a.internalEngine(),Z=H.measureSize(P);c=n(Z*.75,200,500),m=!1,l=a.scrollSnapList().map((Q,J)=>J===z?1:0),g=B.settled,v=a.scrollProgress,B.settled=$,a.scrollProgress=q,a.on("select",R).on("slideFocus",S).on("pointerDown",C).on("pointerUp",E),A(),S()}function b(){const{scrollBody:V}=a.internalEngine();V.settled=g,a.scrollProgress=v,a.off("select",R).off("slideFocus",S).off("pointerDown",C).off("pointerUp",E),a.slideNodes().forEach(z=>{const B=z.style;B.opacity="",B.transform="",B.pointerEvents="",z.getAttribute("style")||z.removeAttribute("style")})}function S(){const V=a.selectedScrollSnap();N(V,1)}function E(){m=!1}function C(){m=!1,d=0,f=0}function R(){const V=a.internalEngine().scrollBody.duration();f=V?0:1,m=!0,V||S()}function I(V){const{axis:z}=a.internalEngine();return`translate${z.scroll.toUpperCase()}(${z.direction(V)}px)`}function A(){const{translate:V,slideLooper:z}=a.internalEngine();V.clear(),V.toggleActive(!1),z.loopPoints.forEach(({translate:B})=>{B.clear(),B.toggleActive(!1)})}function k(V){const{scrollSnaps:z,location:B,target:P}=a.internalEngine();!e(V)||l[V]<.5||(B.set(z[V]),P.set(B))}function N(V,z){a.scrollSnapList().forEach((P,H)=>{const Z=Math.abs(z),Q=l[H],J=H===V,ee=J?Q+Z:Q-Z,K=n(ee,0,1);l[H]=K;const W=J&&m,te=a.previousScrollSnap();W&&(l[te]=1-K),J&&M(V,K),D(H)})}function D(V){const z=a.internalEngine().slideRegistry[V],{scrollSnaps:B,containerRect:P}=a.internalEngine(),H=l[V];z.forEach(Z=>{const Q=a.slideNodes()[Z].style,J=parseFloat(H.toFixed(2)),ee=J>0,K=ee?B[V]:P.width+2,W=I(K);ee&&(Q.transform=W),Q.opacity=J.toString(),Q.pointerEvents=H>.5?"auto":"none",ee||(Q.transform=W)})}function M(V,z){const{index:B,dragHandler:P,scrollSnaps:H}=a.internalEngine(),Z=P.pointerDown(),Q=1/(H.length-1);let J=V,ee=Z?a.selectedScrollSnap():a.previousScrollSnap();if(Z&&J===ee){const te=Math.sign(d)*-1;J=ee,ee=B.clone().set(ee).add(te).get()}const K=ee*Q,W=(J-ee)*Q;p=K+W*z}function F(){const{dragHandler:V,index:z,scrollBody:B}=a.internalEngine(),P=a.selectedScrollSnap();if(!V.pointerDown())return P;const H=Math.sign(B.velocity()),Z=Math.sign(d),Q=z.clone().set(P).add(H*-1).get();return!H||!Z?null:Z===H?Q:P}function U(V){const{dragHandler:z,scrollBody:B}=V.internalEngine(),P=z.pointerDown(),H=B.velocity(),Z=B.duration(),Q=F(),J=!e(Q);if(P){if(!H)return;d+=H,f=Math.abs(H/c),k(Q)}if(!P){if(!Z||J)return;f+=(1-l[Q])/Z,f*=.68}J||N(Q,f)}function $(){const{target:V,location:z}=a.internalEngine(),B=V.get()-z.get(),P=Math.abs(B)>=1,H=F(),Z=!e(H);return U(a),Z||P?!1:l[H]>.999}function q(){return p}return{name:"fade",options:r,init:y,destroy:b}}return t.globalOptions=void 0,A0=t,A0}var k0,Vk;function v8(){if(Vk)return k0;Vk=1;const n={active:!0,breakpoints:{},delay:4e3,jump:!1,playOnInit:!0,stopOnFocusIn:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,stopOnLastSnap:!1,rootNode:null};function e(s,i){const o=s.scrollSnapList();return typeof i=="number"?o.map(()=>i):i(o,s)}function t(s,i){const o=s.rootNode();return i&&i(o)||o}function r(s={}){let i,o,a,l,c=null,d=0,f=!1,p=!1,m=!1,g=!1;function v(z,B){o=z;const{mergeOptions:P,optionsAtMedia:H}=B,Z=P(n,r.globalOptions),Q=P(Z,s);if(i=H(Q),o.scrollSnapList().length<=1)return;g=i.jump,a=!1,l=e(o,i.delay);const{eventStore:J,ownerDocument:ee}=o.internalEngine(),K=!!o.internalEngine().options.watchDrag,W=t(o,i.rootNode);J.add(ee,"visibilitychange",R),K&&o.on("pointerDown",A),K&&!i.stopOnInteraction&&o.on("pointerUp",k),i.stopOnMouseEnter&&J.add(W,"mouseenter",N),i.stopOnMouseEnter&&!i.stopOnInteraction&&J.add(W,"mouseleave",D),i.stopOnFocusIn&&o.on("slideFocusStart",C),i.stopOnFocusIn&&!i.stopOnInteraction&&J.add(o.containerNode(),"focusout",E),i.playOnInit&&E()}function y(){o.off("pointerDown",A).off("pointerUp",k).off("slideFocusStart",C),C(),a=!0,f=!1}function b(){const{ownerWindow:z}=o.internalEngine();z.clearTimeout(d),d=z.setTimeout(q,l[o.selectedScrollSnap()]),c=new Date().getTime(),o.emit("autoplay:timerset")}function S(){const{ownerWindow:z}=o.internalEngine();z.clearTimeout(d),d=0,c=null,o.emit("autoplay:timerstopped")}function E(){if(!a){if(I()){m=!0;return}f||o.emit("autoplay:play"),b(),f=!0}}function C(){a||(f&&o.emit("autoplay:stop"),S(),f=!1)}function R(){if(I())return m=f,C();m&&E()}function I(){const{ownerDocument:z}=o.internalEngine();return z.visibilityState==="hidden"}function A(){p||C()}function k(){p||E()}function N(){p=!0,C()}function D(){p=!1,E()}function M(z){typeof z<"u"&&(g=z),E()}function F(){f&&C()}function U(){f&&E()}function $(){return f}function q(){const{index:z}=o.internalEngine(),B=z.clone().add(1).get(),P=o.scrollSnapList().length-1,H=i.stopOnLastSnap&&B===P;if(o.canScrollNext()?o.scrollNext(g):o.scrollTo(0,g),o.emit("autoplay:select"),H)return C();E()}function G(){if(!c)return null;const z=l[o.selectedScrollSnap()],B=new Date().getTime()-c;return z-B}return{name:"autoplay",options:s,init:v,destroy:y,play:M,stop:F,reset:U,isPlaying:$,timeUntilNext:G}}return r.globalOptions=void 0,k0=r,k0}var L0,Wk;function y8(){if(Wk)return L0;Wk=1;const n={direction:"forward",speed:2,startDelay:1e3,active:!0,breakpoints:{},playOnInit:!0,stopOnFocusIn:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,rootNode:null};function e(r,s){const i=r.rootNode();return s&&s(i)||i}function t(r={}){let s,i,o,a,l=0,c=!1,d=!1,f;function p(F,U){i=F;const{mergeOptions:$,optionsAtMedia:q}=U,G=$(n,t.globalOptions),V=$(G,r);if(s=q(V),i.scrollSnapList().length<=1)return;a=s.startDelay,o=!1,f=i.internalEngine().scrollBody;const{eventStore:z}=i.internalEngine(),B=!!i.internalEngine().options.watchDrag,P=e(i,s.rootNode);B&&i.on("pointerDown",b),B&&!s.stopOnInteraction&&i.on("pointerUp",S),s.stopOnMouseEnter&&z.add(P,"mouseenter",E),s.stopOnMouseEnter&&!s.stopOnInteraction&&z.add(P,"mouseleave",C),s.stopOnFocusIn&&i.on("slideFocusStart",v),s.stopOnFocusIn&&!s.stopOnInteraction&&z.add(i.containerNode(),"focusout",g),s.playOnInit&&g()}function m(){i.off("pointerDown",b).off("pointerUp",S).off("slideFocusStart",v).off("settle",R),v(),o=!0,c=!1}function g(){if(o||c)return;i.emit("autoScroll:play");const F=i.internalEngine(),{ownerWindow:U}=F;l=U.setTimeout(()=>{F.scrollBody=y(F),F.animation.start()},a),c=!0}function v(){if(o||!c)return;i.emit("autoScroll:stop");const F=i.internalEngine(),{ownerWindow:U}=F;F.scrollBody=f,U.clearTimeout(l),l=0,c=!1}function y(F){const{location:U,previousLocation:$,offsetLocation:q,target:G,scrollTarget:V,index:z,indexPrevious:B,limit:{reachedMin:P,reachedMax:H,constrain:Z},options:{loop:Q}}=F,J=s.direction==="forward"?-1:1,ee=()=>le;let K=0,W=0,te=U.get(),re=0,pe=!1;function Ee(){let Ie=0;$.set(U),K=J*s.speed,te+=K,U.add(K),G.set(U),Ie=te-re,W=Math.sign(Ie),re=te;const be=V.byDistance(0,!1).index;z.get()!==be&&(B.set(z.get()),z.set(be),i.emit("select"));const ge=s.direction==="forward"?P(q.get()):H(q.get());if(!Q&&ge){pe=!0;const Ae=Z(U.get());U.set(Ae),G.set(U),v()}return le}const le={direction:()=>W,duration:()=>-1,velocity:()=>K,settled:()=>pe,seek:Ee,useBaseFriction:ee,useBaseDuration:ee,useFriction:ee,useDuration:ee};return le}function b(){d||v()}function S(){d||I()}function E(){d=!0,v()}function C(){d=!1,g()}function R(){i.off("settle",R),g()}function I(){i.on("settle",R)}function A(F){typeof F<"u"&&(a=F),g()}function k(){c&&v()}function N(){c&&(v(),I())}function D(){return c}return{name:"autoScroll",options:r,init:p,destroy:m,play:A,stop:k,reset:N,isPlaying:D}}return t.globalOptions=void 0,L0=t,L0}var M0,Kk;function b8(){if(Kk)return M0;Kk=1;function n(e={}){let t,r=[];const s=["select","slideFocus"];function i(d){t=d;const{options:{axis:f},slideRects:p}=t.internalEngine();f!=="y"&&(r=p.map(m=>m.height),s.forEach(m=>t.on(m,l)),l())}function o(){s.forEach(f=>t.off(f,l));const d=t.containerNode();d.style.height="",d.getAttribute("style")||d.removeAttribute("style")}function a(){const{slideRegistry:d}=t.internalEngine(),f=d[t.selectedScrollSnap()];return f?f.map(p=>r[p]).reduce((p,m)=>Math.max(p,m),0):null}function l(){a()!==null&&(t.containerNode().style.height=`${a()}px`)}return{name:"autoHeight",options:e,init:i,destroy:o}}return n.globalOptions=void 0,M0=n,M0}var N0,Yk;function x8(){if(Yk)return N0;Yk=1;const n={active:!0,breakpoints:{},snapped:"is-snapped",inView:"is-in-view",draggable:"is-draggable",dragging:"is-dragging",loop:"is-loop"};function e(i){return(Array.isArray(i)?i:[i]).filter(Boolean)}function t(i,o){!i||!o.length||i.classList.remove(...o)}function r(i,o){!i||!o.length||i.classList.add(...o)}function s(i={}){let o,a,l,c,d=[],f=[];const p=["select"],m=["pointerDown","pointerUp"],g=["slidesInView"],v={snapped:[],inView:[],draggable:[],dragging:[],loop:[]};function y(A,k){a=A;const{mergeOptions:N,optionsAtMedia:D}=k,M=N(n,s.globalOptions),F=N(M,i);o=D(F),l=a.rootNode(),c=a.slideNodes();const{watchDrag:U,loop:$}=a.internalEngine().options,q=!!U;o.loop&&$&&(v.loop=e(o.loop),r(l,v.loop)),o.draggable&&q&&(v.draggable=e(o.draggable),r(l,v.draggable)),o.dragging&&(v.dragging=e(o.dragging),m.forEach(G=>a.on(G,S))),o.snapped&&(v.snapped=e(o.snapped),p.forEach(G=>a.on(G,C)),C()),o.inView&&(v.inView=e(o.inView),g.forEach(G=>a.on(G,R)),R())}function b(){m.forEach(A=>a.off(A,S)),p.forEach(A=>a.off(A,C)),g.forEach(A=>a.off(A,R)),t(l,v.loop),t(l,v.draggable),t(l,v.dragging),E([],d,v.snapped),E([],f,v.inView),Object.keys(v).forEach(A=>{const k=A;v[k]=[]})}function S(A,k){(k==="pointerDown"?r:t)(l,v.dragging)}function E(A=[],k=[],N){const D=k.map(F=>c[F]),M=A.map(F=>c[F]);return D.forEach(F=>t(F,N)),M.forEach(F=>r(F,N)),A}function C(){const{slideRegistry:A}=a.internalEngine(),k=A[a.selectedScrollSnap()];d=E(k,d,v.snapped)}function R(){const A=a.slidesInView();f=E(A,f,v.inView)}return{name:"classNames",options:i,init:y,destroy:b}}return s.globalOptions=void 0,N0=s,N0}var Xk;function S8(){return Xk||(Xk=1,function(n){var e=od&&od.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(n,"__esModule",{value:!0}),n.BsLightCarouselClassNamesPlugin=n.BsLightCarouselAutoHeightPlugin=n.BsLightCarouselAutoScrollPlugin=n.BsLightCarouselAutoplayPlugin=n.BsLightCarouselFadePlugin=void 0;var t=_8();Object.defineProperty(n,"BsLightCarouselFadePlugin",{enumerable:!0,get:function(){return e(t).default}});var r=v8();Object.defineProperty(n,"BsLightCarouselAutoplayPlugin",{enumerable:!0,get:function(){return e(r).default}});var s=y8();Object.defineProperty(n,"BsLightCarouselAutoScrollPlugin",{enumerable:!0,get:function(){return e(s).default}});var i=b8();Object.defineProperty(n,"BsLightCarouselAutoHeightPlugin",{enumerable:!0,get:function(){return e(i).default}});var o=x8();Object.defineProperty(n,"BsLightCarouselClassNamesPlugin",{enumerable:!0,get:function(){return e(o).default}})}(od)),od}var Qk;function O0(){return Qk||(Qk=1,function(n){var e=_l&&_l.__createBinding||(Object.create?function(r,s,i,o){o===void 0&&(o=i);var a=Object.getOwnPropertyDescriptor(s,i);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[i]}}),Object.defineProperty(r,o,a)}:function(r,s,i,o){o===void 0&&(o=i),r[o]=s[i]}),t=_l&&_l.__exportStar||function(r,s){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(s,i)&&e(s,r,i)};Object.defineProperty(n,"__esModule",{value:!0}),t(d6(),n),t(vI(),n),t(E6(),n),t(i8(),n),t(o8(),n),t(a8(),n),t(l8(),n),t(c8(),n),t(u8(),n),t(d8(),n),t(f8(),n),t(AI(),n),t(Pk(),n),t(h8(),n),t(p8(),n),t(m8(),n),t(g8(),n),t(S8(),n)}(_l)),_l}var de=O0();function E8(n){return{...n,message:(n==null?void 0:n.message)||(n==null?void 0:n.content)}}function ad(n){if(!n)return"offline";const e=de.gregoryDate().diff(n,"minutes");return e<5?"online":e<30?"recently":"offline"}function w8(n){const e=de.jalaliDate(),t=de.jalaliDate(n),r=e.diff(t,"minute"),s="آخرین بازدید ";return r<=30?"به تازگی آنلاین بوده":e.isSame(t,"day")?`${s} ${t.format("HH:mm")}`:e.subtract(1,"day").isSame(t,"day")?`${s}دیروز ساعت ${t.format("HH:mm")}`:`${s} ${t.fromNow()}`}var T8={};const C8={CLIENT_ID:11},Pt=typeof process>"u"?{}:T8,I8={baseUrl:Pt.NEXT_PUBLIC_BASE_URL||"https://basalam.com",coreUrl:Pt.NEXT_PUBLIC_CORE_URL||"https://core.basalam.com",authUrl:Pt.NEXT_PUBLIC_AUTH_URL||"https://auth.basalam.com",listUrl:Pt.NEXT_PUBLIC_LIST_URL||"https://list.basalam.com",liveUrl:Pt.NEXT_PUBLIC_LIVE_URL||"https://live.basalam.com",appsUrl:Pt.NEXT_PUBLIC_APPS_URL||"https://apps.basalam.com",storyUrl:Pt.NEXT_PUBLIC_STORY_URL||"https://story.basalam.com",gamesUrl:Pt.NEXT_PUBLIC_GAMES_URL||"https://games.basalam.com",statsUrl:Pt.NEXT_PUBLIC_STATS_URL||"https://stats.basalam.com",badgeUrl:Pt.NEXT_PUBLIC_BADGE_URL||"https://badge.basalam.com",orderUrl:Pt.NEXT_PUBLIC_ORDER_URL||"https://order.basalam.com",chatUrl:Pt.NEXT_PUBLIC_BASE_CHAT_URL||"https://chat.basalam.com",walletUrl:Pt.NEXT_PUBLIC_WALLET_URL||"https://wallet.basalam.com",reportUrl:Pt.NEXT_PUBLIC_REPORT_URL||"https://report.basalam.com",reviewUrl:Pt.NEXT_PUBLIC_REVIEW_URL||"https://review.basalam.com",searchUrl:Pt.NEXT_PUBLIC_SEARCH_URL||"https://search.basalam.com",lotteryUrl:Pt.NEXT_PUBLIC_LOTTERY_URL||"https://lottery.basalam.com",staticsUrl:Pt.NEXT_PUBLIC_STATICS_URL||"https://statics.basalam.com",graphqlUrl:Pt.NEXT_PUBLIC_GRAPHQL_URL||"https://api.basalam.com/user",appsApiUrl:Pt.NEXT_PUBLIC_APPS_API_URL||"https://apps-api.basalam.com",activityUrl:Pt.NEXT_PUBLIC_ACTIVITY_URL||"https://activity.basalam.com",kashkoolUrl:Pt.NEXT_PUBLIC_KASHKOOL_URL||"https://kashkool.basalam.com",feedbackUrl:Pt.NEXT_PUBLIC_FEEDBACK_URL||"https://feedback.basalam.com",uploadioUrl:Pt.NEXT_PUBLIC_UPLOADIO_URL||"https://uploadio.basalam.com",exploreUrl:Pt.NEXT_PUBLIC_EXPLORE_URL||"https://api.basalam.com/explore",WebsocketUrl:Pt.NEXT_PUBLIC_CENTRIFUGO_WS_URL||"wss://wsocket.basalam.com",uploadUrl:Pt.NEXT_PUBLIC_UPLOAD_URL||"https://api.basalam.com/file/upload",discoveryUrl:Pt.NEXT_PUBLIC_DISCOVERY_URL||"https://discovery.basalam.com",logisticUrl:Pt.NEXT_PUBLIC_LOGISTIC_URL||"https://logistic.basalam.com/v1",aggregator:Pt.NEXT_PUBLIC_AGGREGATOR_URL||"https://aggregator.basalam.com",voucherServiceUrl:Pt.NEXT_PUBLIC_VOCHER_URL||"https://voucher.basalam.com",automationUrl:Pt.NEXT_PUBLIC_AUTOMATION_URL||"https://automation.basalam.com",khabarchinUrl:Pt.NEXT_PUBLIC_KHABARCHIN_URL||"https://khabarchin.basalam.com",scoreUrl:Pt.NEXT_PUBLIC_SCORE_URL||"https://score-system.basalam.com/api_v1.0",featureFlagUrl:Pt.NEXT_PUBLIC_FEATURE_FLAG||"https://feature-flag.basalam.com",growthbookApiKey:Pt.NEXT_PUBLIC_GROWTHBOOK_API_KEY||"key_web__08438f21d1f29e31",conversation:Pt.NEXT_PUBLIC_NEW_BASE_CHAT_URL||"https://conversation.basalam.com",customerClubUrl:Pt.NEXT_PUBLIC_CUSTOMER_CLUB||"https://customer-club.basalam.com",orderProcess:Pt.NEXT_PUBLIC_ORDER_PROCESS||"https://order-processing.basalam.com",promotionServiceUrl:Pt.NEXT_PUBLIC_PROMOTION_URL||"https://promotion.basalam.com",arvanLiveKey:Pt.NEXT_PUBLIC_ARVAN_LIVE_KEY||"56e825be-5940-59db-95d6-86eff4ec5bc7",notificationUrl:Pt.NEXT_PUBLIC_NOTIFICATION_URL||"https://notification.basalam.com",paymentUrl:Pt.NEXT_PUBLIC_BASALAM_PAYMENT_URL||"https://payment.basalam.com/payment",vendorDashboardUrl:Pt.NEXT_PUBLIC_VENDOR_DASHBOARD_URL||"https://vendor.basalam.com",graphqlAdminUrl:Pt.NEXT_PUBLIC_GRAPHQL_ADMIN_URL||"https://api.basalam.com/api/admin",userActivityUrl:Pt.NEXT_PUBLIC_USER_ACTIVITY_URL||"https://user-activity.basalam.com",chatResourcesUrl:Pt.NEXT_PUBLIC_CHAT_RESOURCES_URL||"https://dal.basalam.com/api_v1.0/chat",gameCenterUrl:Pt.NEXT_PUBLIC_GAME_CENTER_URL||"https://gamecenter.basalam.com/api_v1.0/users",posthogInstanceAddress:Pt.NEXT_PUBLIC_POSTHOG_INSTANCE_ADDRESS||"https://posthog.basalam.com",currentUserUrl:Pt.NEXT_PUBLIC_CURRENT_USER_URL||"https://api.basalam.com/api/user/getCurrentUser",gamesExploreUrl:Pt.NEXT_PUBLIC_GAMES_EXPLORE_URL||"https://api.basalam.com/explore/api_v1.0/games",logClickBoost:Pt.NEXT_PUBLIC_BASALAM_LOG_CLICK_ADS_URL||"https://api-intheeye.basalam.com/v1/hit/click",identityInformationUrl:Pt.NEXT_PUBLIC_IDENTITY_INFORMATION_URL||"https://identity-information.basalam.com",feedSuggestionUrl:Pt.NEXT_PUBLIC_FEED_SUGGESTION_URL||"https://activity.basalam.com/api_v1.0/users/suggestion"},mn={...C8,...I8},Cc=()=>{const{injection:n}=Lt(["injection"]),e=Dr();return t=>{if(n!=null&&n.routerPush)n.routerPush(t);else{const r=mn.baseUrl+t;e?window.open(t,"_blank"):window.location.href=r}}};function wa({to:n,children:e,onClick:t,...r}){const{closeChatModal:s}=$i(),{isShowChatModal:i}=Lt(["isShowChatModal"]),o=Cc(),a=l=>{l.preventDefault(),t==null||t(l),i?(setTimeout(()=>{s()},0),setTimeout(()=>o(n),200)):o(n)};return _.jsx("a",{href:n,...r,onClick:a,children:e})}function Jk(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n))for(e=0;e<n.length;e++)n[e]&&(t=Jk(n[e]))&&(r&&(r+=" "),r+=t);else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function jt(){for(var n,e,t=0,r="";t<arguments.length;)(n=arguments[t++])&&(e=Jk(n))&&(r&&(r+=" "),r+=e);return r}var ld={},cd={},ud={},Zk;function eL(){if(Zk)return ud;Zk=1,Object.defineProperty(ud,"__esModule",{value:!0}),ud.useWindowSize=void 0;var n=ar();function e(){var t=(0,n.useState)(typeof window>"u"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}),r=t[0],s=t[1],i=r.width<=576;return(0,n.useEffect)(function(){function o(){var a=window.innerWidth,l=window.innerHeight;a&&l&&(a!==r.width||l!==r.height)&&s({width:a,height:l})}return o(),window.addEventListener("resize",o),function(){return window.removeEventListener("resize",o)}},[]),{windowSize:r,isPhone:i}}return ud.useWindowSize=e,ud}var tL;function R8(){if(tL)return cd;tL=1,Object.defineProperty(cd,"__esModule",{value:!0}),cd.useScreen=void 0;var n=eL();function e(){var t=(0,n.useWindowSize)(),r=t.isPhone,s=t.windowSize.width,i=s>992,o=!i,a=!r&&!i;return{isTablet:a,isMobile:o,isDesktop:i}}return cd.useScreen=e,cd}var dd={},fd={},nL;function rL(){if(nL)return fd;nL=1,Object.defineProperty(fd,"__esModule",{value:!0}),fd.useEffectOnce=void 0;var n=ar(),e=function(t){(0,n.useEffect)(t,[])};return fd.useEffectOnce=e,fd}var sL;function A8(){if(sL)return dd;sL=1,Object.defineProperty(dd,"__esModule",{value:!0}),dd.useUnmount=void 0;var n=ar(),e=rL(),t=function(s){return function(){var i;return(i=s.current)===null||i===void 0?void 0:i.call(s)}},r=function(s){var i=(0,n.useRef)(s);i.current=s,(0,e.useEffectOnce)(function(){return t(i)})};return dd.useUnmount=r,dd}var Sl={};function k8(n){return{all:n=n||new Map,on:function(e,t){var r=n.get(e);r?r.push(t):n.set(e,[t])},off:function(e,t){var r=n.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var r=n.get(e);r&&r.slice().map(function(s){s(t)}),(r=n.get("*"))&&r.slice().map(function(s){s(e,t)})}}}const L8=Tz(Object.freeze(Object.defineProperty({__proto__:null,default:k8},Symbol.toStringTag,{value:"Module"})));var iL;function oL(){if(iL)return Sl;iL=1;var n=Sl&&Sl.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(Sl,"__esModule",{value:!0}),Sl.useEmitter=void 0;var e=n(L8),t=ar(),r=O0(),s;if((0,r.isClientSide)()){var i=window;i.emitter?s=i.emitter:(s=(0,e.default)(),i.emitter=s)}var o=function(c,d){if((0,r.isServerSide)())return console.warn("emit event works only on client-side");s.emit(c,d)},a=function(c,d){s.off(c,d)};function l(){var c=(0,t.useState)(null),d=c[0],f=c[1],p={autoOff:!0},m=function(g,v,y){y===void 0&&(y=p),y!=null&&y.autoOff?d||f({key:g,handler:v}):s.on(g,v)};return(0,t.useEffect)(function(){if(d){var g=d.key,v=d.handler;return s.on(g,v),function(){return s.off(g,v)}}},[d]),{emitEvent:o,subEvent:m,offEvent:a}}return Sl.useEmitter=l,Sl}var hd={},aL;function M8(){if(aL)return hd;aL=1,Object.defineProperty(hd,"__esModule",{value:!0}),hd.useCountUp=void 0;var n=ar(),e=function(r){var s=r%60,i=Math.floor(r/(3600*24)),o=Math.floor(r%(3600*24)/3600),a=Math.floor(r%3600/60);return{days:i,total:r,hours:o,seconds:s,minutes:a,formattedDays:"0".concat(i).slice(-2),formattedHours:"0".concat(o).slice(-2),formattedSeconds:"0".concat(s).slice(-2),formattedMinutes:"0".concat(a).slice(-2)}},t=function(r,s){var i=s===void 0?{}:s,o=i.onTimesUp,a=(0,n.useRef)({timeSpent:0,timeoutID:void 0}),l=(0,n.useState)(e(0)),c=l[0],d=l[1],f=(0,n.useCallback)(function(){a.current.timeoutID=setTimeout(function(){a.current.timeSpent<r&&d(function(v){return a.current.timeSpent=v.total+1,e(a.current.timeSpent)}),a.current.timeSpent&&a.current.timeSpent<r?f():a.current.timeSpent===r&&(o==null||o())},1e3)},[o,r]),p=(0,n.useCallback)(function(){clearTimeout(a.current.timeoutID),f()},[f]),m=(0,n.useCallback)(function(){clearTimeout(a.current.timeoutID)},[]),g=(0,n.useCallback)(function(){clearTimeout(a.current.timeoutID),d(e(0)),a.current={timeSpent:0}},[]);return{timeSpent:c,start:p,stop:m,reset:g}};return hd.useCountUp=t,hd}var pd={},lL;function N8(){if(lL)return pd;lL=1,Object.defineProperty(pd,"__esModule",{value:!0}),pd.useDebounce=void 0;var n=ar();function e(t,r){var s=(0,n.useState)(t),i=s[0],o=s[1];return(0,n.useEffect)(function(){var a=setTimeout(function(){return o(t)},r||500);return function(){clearTimeout(a)}},[t,r]),i}return pd.useDebounce=e,pd}var El={},cL;function O8(){if(cL)return El;cL=1;var n=El&&El.__assign||function(){return n=Object.assign||function(r){for(var s,i=1,o=arguments.length;i<o;i++){s=arguments[i];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])}return r},n.apply(this,arguments)};Object.defineProperty(El,"__esModule",{value:!0}),El.useSnackbar=void 0;var e=oL();function t(){var r=(0,e.useEmitter)().emitEvent,s=function(d){r("bs-snackbar-hide",{id:d})},i=function(d,f){f===void 0&&(f={}),r("bs-snackbar-show",n(n({},f),{text:d,type:"success"}))},o=function(d,f){f===void 0&&(f={}),r("bs-snackbar-show",n(n({},f),{text:d,type:"warning"}))},a=function(d,f){f===void 0&&(f={}),r("bs-snackbar-show",n(n({},f),{text:d,type:"error"}))},l=function(d,f){f===void 0&&(f={}),r("bs-snackbar-show",n(n({},f),{text:d,type:"info"}))},c=function(d,f){f===void 0&&(f={}),r("bs-snackbar-show",n(n({},f),{text:null,type:"custom",customComponentCallback:d}))};return{hideSnackbar:s,showInfoSnackbar:l,showErrorSnackbar:a,showCustomSnackbar:c,showSuccessSnackbar:i,showWarningSnackbar:o}}return El.useSnackbar=t,El}var vi={},uL;function P8(){if(uL)return vi;uL=1;var n=vi&&vi.__assign||function(){return n=Object.assign||function(a){for(var l,c=1,d=arguments.length;c<d;c++){l=arguments[c];for(var f in l)Object.prototype.hasOwnProperty.call(l,f)&&(a[f]=l[f])}return a},n.apply(this,arguments)},e=vi&&vi.__awaiter||function(a,l,c,d){function f(p){return p instanceof c?p:new c(function(m){m(p)})}return new(c||(c=Promise))(function(p,m){function g(b){try{y(d.next(b))}catch(S){m(S)}}function v(b){try{y(d.throw(b))}catch(S){m(S)}}function y(b){b.done?p(b.value):f(b.value).then(g,v)}y((d=d.apply(a,l||[])).next())})},t=vi&&vi.__generator||function(a,l){var c={label:0,sent:function(){if(p[0]&1)throw p[1];return p[1]},trys:[],ops:[]},d,f,p,m;return m={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(m[Symbol.iterator]=function(){return this}),m;function g(y){return function(b){return v([y,b])}}function v(y){if(d)throw new TypeError("Generator is already executing.");for(;m&&(m=0,y[0]&&(c=0)),c;)try{if(d=1,f&&(p=y[0]&2?f.return:y[0]?f.throw||((p=f.return)&&p.call(f),0):f.next)&&!(p=p.call(f,y[1])).done)return p;switch(f=0,p&&(y=[y[0]&2,p.value]),y[0]){case 0:case 1:p=y;break;case 4:return c.label++,{value:y[1],done:!1};case 5:c.label++,f=y[1],y=[0];continue;case 7:y=c.ops.pop(),c.trys.pop();continue;default:if(p=c.trys,!(p=p.length>0&&p[p.length-1])&&(y[0]===6||y[0]===2)){c=0;continue}if(y[0]===3&&(!p||y[1]>p[0]&&y[1]<p[3])){c.label=y[1];break}if(y[0]===6&&c.label<p[1]){c.label=p[1],p=y;break}if(p&&c.label<p[2]){c.label=p[2],c.ops.push(y);break}p[2]&&c.ops.pop(),c.trys.pop();continue}y=l.call(a,c)}catch(b){y=[6,b],f=0}finally{d=p=0}if(y[0]&5)throw y[1];return{value:y[0]?y[1]:void 0,done:!0}}},r=vi&&vi.__spreadArray||function(a,l,c){if(c||arguments.length===2)for(var d=0,f=l.length,p;d<f;d++)(p||!(d in l))&&(p||(p=Array.prototype.slice.call(l,0,d)),p[d]=l[d]);return a.concat(p||Array.prototype.slice.call(l))};Object.defineProperty(vi,"__esModule",{value:!0});var s=ar(),i={abortEarly:!1},o=function(a,l){l===void 0&&(l=i);var c=(0,s.useState)([]),d=c[0],f=c[1],p=function(E){var C=d.find(function(R){return R.path===E});return C?C.message:""},m=function(E){return e(void 0,void 0,void 0,function(){var C;return t(this,function(R){switch(R.label){case 0:return R.trys.push([0,2,,3]),[4,a.validate(E,l)];case 1:return R.sent(),f([]),[2,!0];case 2:return C=R.sent(),f(C.inner),[2,!1];case 3:return[2]}})})},g=(0,s.useMemo)(function(){return d.reduce(function(E,C){var R;return C.path?n(n({},E),(R={},R[C.path]=C==null?void 0:C.message,R)):n(n({},E),{error:C==null?void 0:C.message})},{})},[d]),v=function(E,C){return e(void 0,void 0,void 0,function(){var R,I,A,k;return t(this,function(N){switch(N.label){case 0:R=d.find(function(D){return D.path===E}),N.label=1;case 1:return N.trys.push([1,3,,4]),[4,a.validateAt(E,C)];case 2:return I=N.sent(),f(function(D){return D.filter(function(M){return Array.isArray(I)?!M.path.includes("".concat(E,"[")):M.path!==E})}),[2,!0];case 3:return A=N.sent(),k=A,f(function(D){return R?D.map(function(M){return M.path===E?k:M}):r(r([],D,!0),[k],!1)}),[2,!1];case 4:return[2]}})})},y=function(E,C){return e(void 0,void 0,void 0,function(){var R;return t(this,function(I){switch(I.label){case 0:return E.length===0?[2,!0]:[4,Promise.all(E.map(function(A){return v(A,C)}))];case 1:return R=I.sent(),[2,!R.includes(!1)]}})})},b=(0,s.useCallback)(function(){f([])},[]),S=(0,s.useCallback)(function(E){f(function(C){return C.filter(function(R){return R.path!==E})})},[]);return{validate:m,validateAt:v,objectError:g,clearErrors:b,errorTextFor:p,validateFields:y,clearFieldError:S}};return vi.default=o,vi}var wl={},dL;function D8(){if(dL)return wl;dL=1;var n=wl&&wl.__spreadArray||function(r,s,i){if(i||arguments.length===2)for(var o=0,a=s.length,l;o<a;o++)(l||!(o in s))&&(l||(l=Array.prototype.slice.call(s,0,o)),l[o]=s[o]);return r.concat(l||Array.prototype.slice.call(s))};Object.defineProperty(wl,"__esModule",{value:!0}),wl.useDidUpdate=void 0;var e=ar();function t(r,s){var i=(0,e.useRef)(!1);(0,e.useEffect)(function(){return function(){i.current=!1}},[]),(0,e.useEffect)(function(){if(i.current)return r();i.current=!0},n([],s||[],!0))}return wl.useDidUpdate=t,wl}var md={},fL;function j8(){if(fL)return md;fL=1,Object.defineProperty(md,"__esModule",{value:!0}),md.useCountDown=void 0;var n=ar(),e=function(r){var s=r%60,i=Math.floor(r/(3600*24)),o=Math.floor(r%(3600*24)/3600),a=Math.floor(r%3600/60);return{days:i,total:r,hours:o,seconds:s,minutes:a,formattedDays:"0".concat(i).slice(-2),formattedHours:"0".concat(o).slice(-2),formattedSeconds:"0".concat(s).slice(-2),formattedMinutes:"0".concat(a).slice(-2)}},t=function(r,s){var i=s===void 0?{}:s,o=i.onTimesUp,a=i.startOnMount,l=a===void 0?!0:a,c=(0,n.useRef)({timeLeft:void 0,timeoutID:void 0}),d=(0,n.useState)(e(r)),f=d[0],p=d[1],m=(0,n.useCallback)(function(y){y===void 0&&(y=r),c.current.timeLeft===void 0&&(c.current.timeLeft=y),c.current.timeoutID=setTimeout(function(){c.current.timeLeft&&c.current.timeLeft>0&&p(function(b){return c.current.timeLeft=b.total-1,e(c.current.timeLeft)}),c.current.timeLeft&&c.current.timeLeft>0?m():c.current.timeLeft===0&&(o==null||o())},1e3)},[o,r]),g=(0,n.useCallback)(function(y){clearTimeout(c.current.timeoutID),m(y)},[m]),v=(0,n.useCallback)(function(y){y===void 0&&(y=r),clearTimeout(c.current.timeoutID),p(e(y)),c.current={},g(y)},[r,g]);return(0,n.useEffect)(function(){return l&&g(r),function(){return clearTimeout(c.current.timeoutID)}},[g,l]),{timeLeft:f,start:g,reset:v}};return md.useCountDown=t,md}var gd={},hL;function F8(){if(hL)return gd;hL=1,Object.defineProperty(gd,"__esModule",{value:!0}),gd.useDisclosure=void 0;var n=ar();function e(t,r){t===void 0&&(t=!1);var s=r||{},i=s.onOpen,o=s.onClose,a=(0,n.useState)(t),l=a[0],c=a[1],d=(0,n.useCallback)(function(){c(function(m){return m||(i==null||i(),!0)})},[i]),f=(0,n.useCallback)(function(){c(function(m){return m&&(o==null||o(),!1)})},[o]),p=(0,n.useCallback)(function(){l?f():d()},[f,d,l]);return[l,{open:d,close:f,toggle:p}]}return gd.useDisclosure=e,gd}var _d={},pL;function U8(){if(pL)return _d;pL=1,Object.defineProperty(_d,"__esModule",{value:!0}),_d.useFallbackRef=void 0;var n=ar();function e(t){var r=(0,n.useRef)(null);return(0,n.useImperativeHandle)(t,function(){return r.current}),r}return _d.useFallbackRef=e,_d}var vd={},mL;function B8(){if(mL)return vd;mL=1,Object.defineProperty(vd,"__esModule",{value:!0}),vd.useUncontrolled=void 0;var n=ar();function e(t){var r=t.value,s=t.finalValue,i=t.defaultValue,o=t.onChange,a=o===void 0?function(){}:o,l=(0,n.useState)(i===void 0?s:i),c=l[0],d=l[1],f=function(p){d(p),a==null||a(p)};return r!==void 0?[r,a,!0]:[c,f,!1]}return vd.useUncontrolled=e,vd}var yd={},gL;function $8(){if(gL)return yd;gL=1,Object.defineProperty(yd,"__esModule",{value:!0}),yd.useLocalStorage=void 0;var n=O0(),e=ar();function t(r,s){s===void 0&&(s=null);var i=(0,e.useCallback)(function(){return n.bsLocalStorage.getItem(r,s)},[r,s]),o=(0,e.useState)(i),a=o[0],l=o[1],c=(0,e.useCallback)(function(f){var p=typeof f=="function"?f(a):f;n.bsLocalStorage.setItem(r,p),l(p)},[r,a]),d=(0,e.useCallback)(function(f){f!=null&&f.key&&f.key!==r||l(i())},[r]);return(0,e.useEffect)(function(){return window.addEventListener("storage",d),function(){window.removeEventListener("storage",d)}},[]),[a,c]}return yd.useLocalStorage=t,yd}var bd={},_L;function z8(){if(_L)return bd;_L=1,Object.defineProperty(bd,"__esModule",{value:!0}),bd.useElementHeight=void 0;var n=ar(),e=function(t){var r=(0,n.useState)(0),s=r[0],i=r[1],o=(0,n.useCallback)(function(){var a,l=((a=t.current)===null||a===void 0?void 0:a.offsetHeight)||0;i(l)},[t]);return(0,n.useEffect)(function(){if(t.current){o();var a=new MutationObserver(o);return a.observe(t.current,{subtree:!0,childList:!0,attributes:!1}),function(){return a.disconnect()}}},[t,o]),s};return bd.useElementHeight=e,bd}var xd={},vL;function q8(){if(vL)return xd;vL=1,Object.defineProperty(xd,"__esModule",{value:!0}),xd.useHistoryChange=void 0;var n=ar(),e={},t=!1;function r(s){var i=s===void 0?{}:s,o=i.onPushState,a=i.onPopState,l=(0,n.useRef)(null),c=(0,n.useRef)(null),d=Math.random().toString(36).slice(7),f=(0,n.useCallback)(function(p){c.current=l.current,l.current=p},[]);return(0,n.useEffect)(function(){e[d]={onPopState:a,onPushState:o},t||(window.history.pushState=new Proxy(window.history.pushState,{apply:function(m,g,v){var y,b,S,E=(y=v==null?void 0:v[0])!==null&&y!==void 0?y:null;for(var C in e)(S=(b=e[C]).onPushState)===null||S===void 0||S.call(b,{state:E},{state:l.current});return f(E),m.apply(g,v)}}),t=!0);var p=function(m){var g,v;for(var y in e)(v=(g=e[y]).onPopState)===null||v===void 0||v.call(g,m,{state:l.current});f(m.state)};return window.addEventListener("popstate",p),function(){delete e[d],window.removeEventListener("popstate",p)}},[a,o,d]),(0,n.useEffect)(function(){l.current=window.history.state},[]),{prevHistoryState:c,currentHistoryState:l}}return xd.useHistoryChange=r,xd}var zh={},yL;function H8(){if(yL)return zh;yL=1,Object.defineProperty(zh,"__esModule",{value:!0});var n=ar();function e(){var t=(0,n.useRef)(!1);return(0,n.useEffect)(function(){return t.current=!0,function(){t.current=!1}},[]),(0,n.useCallback)(function(){return t.current},[])}return zh.default=e,zh}var Sd={},bL;function G8(){if(bL)return Sd;bL=1,Object.defineProperty(Sd,"__esModule",{value:!0}),Sd.useIsomorphicEffect=void 0;var n=ar();return Sd.useIsomorphicEffect=typeof document>"u"?n.useEffect:n.useLayoutEffect,Sd}var Tl={},xL;function V8(){if(xL)return Tl;xL=1;var n=Tl&&Tl.__spreadArray||function(r,s,i){if(i||arguments.length===2)for(var o=0,a=s.length,l;o<a;o++)(l||!(o in s))&&(l||(l=Array.prototype.slice.call(s,0,o)),l[o]=s[o]);return r.concat(l||Array.prototype.slice.call(s))};Object.defineProperty(Tl,"__esModule",{value:!0}),Tl.useEffectNoImmediate=void 0;var e=ar(),t=function(r,s){var i=(0,e.useRef)(!1);(0,e.useEffect)(function(){if(i.current){var o=r();return function(){return o&&o()}}i.current=!0},n([],s||[],!0)),(0,e.useEffect)(function(){return function(){i.current=!1}},[])};return Tl.useEffectNoImmediate=t,Tl}var qh={},SL;function W8(){if(SL)return qh;SL=1,Object.defineProperty(qh,"__esModule",{value:!0});var n=ar();function e(t){var r=t===void 0?{}:t,s=r.threshold,i=s===void 0?.1:s,o=(0,n.useState)(!1),a=o[0],l=o[1],c=(0,n.useRef)(null);(0,n.useEffect)(function(){return typeof IntersectionObserver<"u"&&(c.current=new IntersectionObserver(function(p){p.forEach(function(m){l(m.isIntersecting)})},{threshold:i})),function(){c.current&&c.current.disconnect()}},[i]);var d=function(p){c.current&&p&&c.current.observe(p)},f=function(p){c.current&&p&&c.current.unobserve(p)};return{observe:d,unobserve:f,isInViewport:a}}return qh.default=e,qh}var EL;function K8(){return EL||(EL=1,function(n){var e=ld&&ld.__importDefault||function(A){return A&&A.__esModule?A:{default:A}};Object.defineProperty(n,"__esModule",{value:!0}),n.useIntersectionObserver=n.useEffectNoImmediate=n.useIsomorphicEffect=n.useIsMounted=n.useHistoryChange=n.useElementHeight=n.useLocalStorage=n.useUncontrolled=n.useFallbackRef=n.useEffectOnce=n.useWindowSize=n.useDisclosure=n.useCountDown=n.useDidUpdate=n.useYup=n.useSnackbar=n.useDebounce=n.useCountUp=n.useEmitter=n.useUnmount=n.useScreen=void 0;var t=R8();Object.defineProperty(n,"useScreen",{enumerable:!0,get:function(){return t.useScreen}});var r=A8();Object.defineProperty(n,"useUnmount",{enumerable:!0,get:function(){return r.useUnmount}});var s=oL();Object.defineProperty(n,"useEmitter",{enumerable:!0,get:function(){return s.useEmitter}});var i=M8();Object.defineProperty(n,"useCountUp",{enumerable:!0,get:function(){return i.useCountUp}});var o=N8();Object.defineProperty(n,"useDebounce",{enumerable:!0,get:function(){return o.useDebounce}});var a=O8();Object.defineProperty(n,"useSnackbar",{enumerable:!0,get:function(){return a.useSnackbar}});var l=P8();Object.defineProperty(n,"useYup",{enumerable:!0,get:function(){return e(l).default}});var c=D8();Object.defineProperty(n,"useDidUpdate",{enumerable:!0,get:function(){return c.useDidUpdate}});var d=j8();Object.defineProperty(n,"useCountDown",{enumerable:!0,get:function(){return d.useCountDown}});var f=F8();Object.defineProperty(n,"useDisclosure",{enumerable:!0,get:function(){return f.useDisclosure}});var p=eL();Object.defineProperty(n,"useWindowSize",{enumerable:!0,get:function(){return p.useWindowSize}});var m=rL();Object.defineProperty(n,"useEffectOnce",{enumerable:!0,get:function(){return m.useEffectOnce}});var g=U8();Object.defineProperty(n,"useFallbackRef",{enumerable:!0,get:function(){return g.useFallbackRef}});var v=B8();Object.defineProperty(n,"useUncontrolled",{enumerable:!0,get:function(){return v.useUncontrolled}});var y=$8();Object.defineProperty(n,"useLocalStorage",{enumerable:!0,get:function(){return y.useLocalStorage}});var b=z8();Object.defineProperty(n,"useElementHeight",{enumerable:!0,get:function(){return b.useElementHeight}});var S=q8();Object.defineProperty(n,"useHistoryChange",{enumerable:!0,get:function(){return S.useHistoryChange}});var E=H8();Object.defineProperty(n,"useIsMounted",{enumerable:!0,get:function(){return e(E).default}});var C=G8();Object.defineProperty(n,"useIsomorphicEffect",{enumerable:!0,get:function(){return C.useIsomorphicEffect}});var R=V8();Object.defineProperty(n,"useEffectNoImmediate",{enumerable:!0,get:function(){return R.useEffectNoImmediate}});var I=W8();Object.defineProperty(n,"useIntersectionObserver",{enumerable:!0,get:function(){return e(I).default}})}(ld)),ld}var Mt=K8(),P0={exports:{}},D0,wL;function Y8(){if(wL)return D0;wL=1;var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return D0=n,D0}var j0,TL;function X8(){if(TL)return j0;TL=1;var n=Y8();function e(){}function t(){}return t.resetWarningCache=e,j0=function(){function r(o,a,l,c,d,f){if(f!==n){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}r.isRequired=r;function s(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:s,element:r,elementType:r,instanceOf:s,node:r,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:t,resetWarningCache:e};return i.PropTypes=i,i},j0}var CL;function Q8(){return CL||(CL=1,P0.exports=X8()()),P0.exports}var J8=Q8();const O=ba(J8);O.bool,O.node,O.func,O.bool,O.node,O.string,O.number,O.bool,O.string,O.string,O.func,O.node,O.bool,T.createContext({_value:"",setValue:()=>{}});var F0={exports:{}},$s={},U0={exports:{}},B0={};/**
35 * @license React
36 * scheduler.production.min.js
37 *
38 * Copyright (c) Facebook, Inc. and its affiliates.
39 *
40 * This source code is licensed under the MIT license found in the
41 * LICENSE file in the root directory of this source tree.
42 */var IL;function Z8(){return IL||(IL=1,function(n){function e(z,B){var P=z.length;z.push(B);e:for(;0<P;){var H=P-1>>>1,Z=z[H];if(0<s(Z,B))z[H]=B,z[P]=Z,P=H;else break e}}function t(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var B=z[0],P=z.pop();if(P!==B){z[0]=P;e:for(var H=0,Z=z.length,Q=Z>>>1;H<Q;){var J=2*(H+1)-1,ee=z[J],K=J+1,W=z[K];if(0>s(ee,P))K<Z&&0>s(W,ee)?(z[H]=W,z[K]=P,H=K):(z[H]=ee,z[J]=P,H=J);else if(K<Z&&0>s(W,P))z[H]=W,z[K]=P,H=K;else break e}}return B}function s(z,B){var P=z.sortIndex-B.sortIndex;return P!==0?P:z.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;n.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],c=[],d=1,f=null,p=3,m=!1,g=!1,v=!1,y=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(z){for(var B=t(c);B!==null;){if(B.callback===null)r(c);else if(B.startTime<=z)r(c),B.sortIndex=B.expirationTime,e(l,B);else break;B=t(c)}}function C(z){if(v=!1,E(z),!g)if(t(l)!==null)g=!0,G(R);else{var B=t(c);B!==null&&V(C,B.startTime-z)}}function R(z,B){g=!1,v&&(v=!1,b(k),k=-1),m=!0;var P=p;try{for(E(B),f=t(l);f!==null&&(!(f.expirationTime>B)||z&&!M());){var H=f.callback;if(typeof H=="function"){f.callback=null,p=f.priorityLevel;var Z=H(f.expirationTime<=B);B=n.unstable_now(),typeof Z=="function"?f.callback=Z:f===t(l)&&r(l),E(B)}else r(l);f=t(l)}if(f!==null)var Q=!0;else{var J=t(c);J!==null&&V(C,J.startTime-B),Q=!1}return Q}finally{f=null,p=P,m=!1}}var I=!1,A=null,k=-1,N=5,D=-1;function M(){return!(n.unstable_now()-D<N)}function F(){if(A!==null){var z=n.unstable_now();D=z;var B=!0;try{B=A(!0,z)}finally{B?U():(I=!1,A=null)}}else I=!1}var U;if(typeof S=="function")U=function(){S(F)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,q=$.port2;$.port1.onmessage=F,U=function(){q.postMessage(null)}}else U=function(){y(F,0)};function G(z){A=z,I||(I=!0,U())}function V(z,B){k=y(function(){z(n.unstable_now())},B)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(z){z.callback=null},n.unstable_continueExecution=function(){g||m||(g=!0,G(R))},n.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):N=0<z?Math.floor(1e3/z):5},n.unstable_getCurrentPriorityLevel=function(){return p},n.unstable_getFirstCallbackNode=function(){return t(l)},n.unstable_next=function(z){switch(p){case 1:case 2:case 3:var B=3;break;default:B=p}var P=p;p=B;try{return z()}finally{p=P}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(z,B){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var P=p;p=z;try{return B()}finally{p=P}},n.unstable_scheduleCallback=function(z,B,P){var H=n.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?H+P:H):P=H,z){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=P+Z,z={id:d++,callback:B,priorityLevel:z,startTime:P,expirationTime:Z,sortIndex:-1},P>H?(z.sortIndex=P,e(c,z),t(l)===null&&z===t(c)&&(v?(b(k),k=-1):v=!0,V(C,P-H))):(z.sortIndex=Z,e(l,z),g||m||(g=!0,G(R))),z},n.unstable_shouldYield=M,n.unstable_wrapCallback=function(z){var B=p;return function(){var P=p;p=B;try{return z.apply(this,arguments)}finally{p=P}}}}(B0)),B0}var RL;function eH(){return RL||(RL=1,U0.exports=Z8()),U0.exports}/**
43 * @license React
44 * react-dom.production.min.js
45 *
46 * Copyright (c) Facebook, Inc. and its affiliates.
47 *
48 * This source code is licensed under the MIT license found in the
49 * LICENSE file in the root directory of this source tree.
50 */var AL;function tH(){if(AL)return $s;AL=1;var n=ar(),e=eH();function t(u){for(var h="https://reactjs.org/docs/error-decoder.html?invariant="+u,x=1;x<arguments.length;x++)h+="&args[]="+encodeURIComponent(arguments[x]);return"Minified React error #"+u+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function i(u,h){o(u,h),o(u+"Capture",h)}function o(u,h){for(s[u]=h,u=0;u<h.length;u++)r.add(h[u])}var a=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),l=Object.prototype.hasOwnProperty,c=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},f={};function p(u){return l.call(f,u)?!0:l.call(d,u)?!1:c.test(u)?f[u]=!0:(d[u]=!0,!1)}function m(u,h,x,w){if(x!==null&&x.type===0)return!1;switch(typeof h){case"function":case"symbol":return!0;case"boolean":return w?!1:x!==null?!x.acceptsBooleans:(u=u.toLowerCase().slice(0,5),u!=="data-"&&u!=="aria-");default:return!1}}function g(u,h,x,w){if(h===null||typeof h>"u"||m(u,h,x,w))return!0;if(w)return!1;if(x!==null)switch(x.type){case 3:return!h;case 4:return h===!1;case 5:return isNaN(h);case 6:return isNaN(h)||1>h}return!1}function v(u,h,x,w,L,j,X){this.acceptsBooleans=h===2||h===3||h===4,this.attributeName=w,this.attributeNamespace=L,this.mustUseProperty=x,this.propertyName=u,this.type=h,this.sanitizeURL=j,this.removeEmptyString=X}var y={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(u){y[u]=new v(u,0,!1,u,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(u){var h=u[0];y[h]=new v(h,1,!1,u[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(u){y[u]=new v(u,2,!1,u.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(u){y[u]=new v(u,2,!1,u,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(u){y[u]=new v(u,3,!1,u.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(u){y[u]=new v(u,3,!0,u,null,!1,!1)}),["capture","download"].forEach(function(u){y[u]=new v(u,4,!1,u,null,!1,!1)}),["cols","rows","size","span"].forEach(function(u){y[u]=new v(u,6,!1,u,null,!1,!1)}),["rowSpan","start"].forEach(function(u){y[u]=new v(u,5,!1,u.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function S(u){return u[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(u){var h=u.replace(b,S);y[h]=new v(h,1,!1,u,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(u){var h=u.replace(b,S);y[h]=new v(h,1,!1,u,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(u){var h=u.replace(b,S);y[h]=new v(h,1,!1,u,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(u){y[u]=new v(u,1,!1,u.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(u){y[u]=new v(u,1,!1,u.toLowerCase(),null,!0,!0)});function E(u,h,x,w){var L=y.hasOwnProperty(h)?y[h]:null;(L!==null?L.type!==0:w||!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(g(h,x,L,w)&&(x=null),w||L===null?p(h)&&(x===null?u.removeAttribute(h):u.setAttribute(h,""+x)):L.mustUseProperty?u[L.propertyName]=x===null?L.type===3?!1:"":x:(h=L.attributeName,w=L.attributeNamespace,x===null?u.removeAttribute(h):(L=L.type,x=L===3||L===4&&x===!0?"":""+x,w?u.setAttributeNS(w,h,x):u.setAttribute(h,x))))}var C=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),I=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),M=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),z=Symbol.iterator;function B(u){return u===null||typeof u!="object"?null:(u=z&&u[z]||u["@@iterator"],typeof u=="function"?u:null)}var P=Object.assign,H;function Z(u){if(H===void 0)try{throw Error()}catch(x){var h=x.stack.trim().match(/\n( *(at )?)/);H=h&&h[1]||""}return`
51 `+H+u}var Q=!1;function J(u,h){if(!u||Q)return"";Q=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(h)if(h=function(){throw Error()},Object.defineProperty(h.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(h,[])}catch(we){var w=we}Reflect.construct(u,[],h)}else{try{h.call()}catch(we){w=we}u.call(h.prototype)}else{try{throw Error()}catch(we){w=we}u()}}catch(we){if(we&&w&&typeof we.stack=="string"){for(var L=we.stack.split(`
52 `),j=w.stack.split(`
53 `),X=L.length-1,ne=j.length-1;1<=X&&0<=ne&&L[X]!==j[ne];)ne--;for(;1<=X&&0<=ne;X--,ne--)if(L[X]!==j[ne]){if(X!==1||ne!==1)do if(X--,ne--,0>ne||L[X]!==j[ne]){var ae=`
54 `+L[X].replace(" at new "," at ");return u.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",u.displayName)),ae}while(1<=X&&0<=ne);break}}}finally{Q=!1,Error.prepareStackTrace=x}return(u=u?u.displayName||u.name:"")?Z(u):""}function ee(u){switch(u.tag){case 5:return Z(u.type);case 16:return Z("Lazy");case 13:return Z("Suspense");case 19:return Z("SuspenseList");case 0:case 2:case 15:return u=J(u.type,!1),u;case 11:return u=J(u.type.render,!1),u;case 1:return u=J(u.type,!0),u;default:return""}}function K(u){if(u==null)return null;if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case A:return"Fragment";case I:return"Portal";case N:return"Profiler";case k:return"StrictMode";case U:return"Suspense";case $:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case M:return(u.displayName||"Context")+".Consumer";case D:return(u._context.displayName||"Context")+".Provider";case F:var h=u.render;return u=u.displayName,u||(u=h.displayName||h.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case q:return h=u.displayName||null,h!==null?h:K(u.type)||"Memo";case G:h=u._payload,u=u._init;try{return K(u(h))}catch{}}return null}function W(u){var h=u.type;switch(u.tag){case 24:return"Cache";case 9:return(h.displayName||"Context")+".Consumer";case 10:return(h._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=h.render,u=u.displayName||u.name||"",h.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return h;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return K(h);case 8:return h===k?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h}return null}function te(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function re(u){var h=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(h==="checkbox"||h==="radio")}function pe(u){var h=re(u)?"checked":"value",x=Object.getOwnPropertyDescriptor(u.constructor.prototype,h),w=""+u[h];if(!u.hasOwnProperty(h)&&typeof x<"u"&&typeof x.get=="function"&&typeof x.set=="function"){var L=x.get,j=x.set;return Object.defineProperty(u,h,{configurable:!0,get:function(){return L.call(this)},set:function(X){w=""+X,j.call(this,X)}}),Object.defineProperty(u,h,{enumerable:x.enumerable}),{getValue:function(){return w},setValue:function(X){w=""+X},stopTracking:function(){u._valueTracker=null,delete u[h]}}}}function Ee(u){u._valueTracker||(u._valueTracker=pe(u))}function le(u){if(!u)return!1;var h=u._valueTracker;if(!h)return!0;var x=h.getValue(),w="";return u&&(w=re(u)?u.checked?"true":"false":u.value),u=w,u!==x?(h.setValue(u),!0):!1}function Ie(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}function be(u,h){var x=h.checked;return P({},h,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:x??u._wrapperState.initialChecked})}function ge(u,h){var x=h.defaultValue==null?"":h.defaultValue,w=h.checked!=null?h.checked:h.defaultChecked;x=te(h.value!=null?h.value:x),u._wrapperState={initialChecked:w,initialValue:x,controlled:h.type==="checkbox"||h.type==="radio"?h.checked!=null:h.value!=null}}function Ae(u,h){h=h.checked,h!=null&&E(u,"checked",h,!1)}function Re(u,h){Ae(u,h);var x=te(h.value),w=h.type;if(x!=null)w==="number"?(x===0&&u.value===""||u.value!=x)&&(u.value=""+x):u.value!==""+x&&(u.value=""+x);else if(w==="submit"||w==="reset"){u.removeAttribute("value");return}h.hasOwnProperty("value")?et(u,h.type,x):h.hasOwnProperty("defaultValue")&&et(u,h.type,te(h.defaultValue)),h.checked==null&&h.defaultChecked!=null&&(u.defaultChecked=!!h.defaultChecked)}function tt(u,h,x){if(h.hasOwnProperty("value")||h.hasOwnProperty("defaultValue")){var w=h.type;if(!(w!=="submit"&&w!=="reset"||h.value!==void 0&&h.value!==null))return;h=""+u._wrapperState.initialValue,x||h===u.value||(u.value=h),u.defaultValue=h}x=u.name,x!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,x!==""&&(u.name=x)}function et(u,h,x){(h!=="number"||Ie(u.ownerDocument)!==u)&&(x==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+x&&(u.defaultValue=""+x))}var Oe=Array.isArray;function ht(u,h,x,w){if(u=u.options,h){h={};for(var L=0;L<x.length;L++)h["$"+x[L]]=!0;for(x=0;x<u.length;x++)L=h.hasOwnProperty("$"+u[x].value),u[x].selected!==L&&(u[x].selected=L),L&&w&&(u[x].defaultSelected=!0)}else{for(x=""+te(x),h=null,L=0;L<u.length;L++){if(u[L].value===x){u[L].selected=!0,w&&(u[L].defaultSelected=!0);return}h!==null||u[L].disabled||(h=u[L])}h!==null&&(h.selected=!0)}}function Xe(u,h){if(h.dangerouslySetInnerHTML!=null)throw Error(t(91));return P({},h,{value:void 0,defaultValue:void 0,children:""+u._wrapperState.initialValue})}function Je(u,h){var x=h.value;if(x==null){if(x=h.children,h=h.defaultValue,x!=null){if(h!=null)throw Error(t(92));if(Oe(x)){if(1<x.length)throw Error(t(93));x=x[0]}h=x}h==null&&(h=""),x=h}u._wrapperState={initialValue:te(x)}}function qe(u,h){var x=te(h.value),w=te(h.defaultValue);x!=null&&(x=""+x,x!==u.value&&(u.value=x),h.defaultValue==null&&u.defaultValue!==x&&(u.defaultValue=x)),w!=null&&(u.defaultValue=""+w)}function Ue(u){var h=u.textContent;h===u._wrapperState.initialValue&&h!==""&&h!==null&&(u.value=h)}function it(u){switch(u){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function nt(u,h){return u==null||u==="http://www.w3.org/1999/xhtml"?it(h):u==="http://www.w3.org/2000/svg"&&h==="foreignObject"?"http://www.w3.org/1999/xhtml":u}var dt,Ot=function(u){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(h,x,w,L){MSApp.execUnsafeLocalFunction(function(){return u(h,x,w,L)})}:u}(function(u,h){if(u.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in u)u.innerHTML=h;else{for(dt=dt||document.createElement("div"),dt.innerHTML="<svg>"+h.valueOf().toString()+"</svg>",h=dt.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;h.firstChild;)u.appendChild(h.firstChild)}});function xt(u,h){if(h){var x=u.firstChild;if(x&&x===u.lastChild&&x.nodeType===3){x.nodeValue=h;return}}u.textContent=h}var rt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Me=["Webkit","ms","Moz","O"];Object.keys(rt).forEach(function(u){Me.forEach(function(h){h=h+u.charAt(0).toUpperCase()+u.substring(1),rt[h]=rt[u]})});function lt(u,h,x){return h==null||typeof h=="boolean"||h===""?"":x||typeof h!="number"||h===0||rt.hasOwnProperty(u)&&rt[u]?(""+h).trim():h+"px"}function Vt(u,h){u=u.style;for(var x in h)if(h.hasOwnProperty(x)){var w=x.indexOf("--")===0,L=lt(x,h[x],w);x==="float"&&(x="cssFloat"),w?u.setProperty(x,L):u[x]=L}}var vn=P({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function pt(u,h){if(h){if(vn[u]&&(h.children!=null||h.dangerouslySetInnerHTML!=null))throw Error(t(137,u));if(h.dangerouslySetInnerHTML!=null){if(h.children!=null)throw Error(t(60));if(typeof h.dangerouslySetInnerHTML!="object"||!("__html"in h.dangerouslySetInnerHTML))throw Error(t(61))}if(h.style!=null&&typeof h.style!="object")throw Error(t(62))}}function mt(u,h){if(u.indexOf("-")===-1)return typeof h.is=="string";switch(u){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var gt=null;function Wt(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var ot=null,nn=null,tn=null;function En(u){if(u=ah(u)){if(typeof ot!="function")throw Error(t(280));var h=u.stateNode;h&&(h=Dg(h),ot(u.stateNode,u.type,h))}}function $n(u){nn?tn?tn.push(u):tn=[u]:nn=u}function _n(){if(nn){var u=nn,h=tn;if(tn=nn=null,En(u),h)for(u=0;u<h.length;u++)En(h[u])}}function sr(u,h){return u(h)}function wr(){}var ws=!1;function es(u,h,x){if(ws)return u(h,x);ws=!0;try{return sr(u,h,x)}finally{ws=!1,(nn!==null||tn!==null)&&(wr(),_n())}}function ds(u,h){var x=u.stateNode;if(x===null)return null;var w=Dg(x);if(w===null)return null;x=w[h];e:switch(h){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(u=u.type,w=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!w;break e;default:u=!1}if(u)return null;if(x&&typeof x!="function")throw Error(t(231,h,typeof x));return x}var fs=!1;if(a)try{var oe={};Object.defineProperty(oe,"passive",{get:function(){fs=!0}}),window.addEventListener("test",oe,oe),window.removeEventListener("test",oe,oe)}catch{fs=!1}function ce(u,h,x,w,L,j,X,ne,ae){var we=Array.prototype.slice.call(arguments,3);try{h.apply(x,we)}catch(Ge){this.onError(Ge)}}var _e=!1,ie=null,xe=!1,Le=null,Be={onError:function(u){_e=!0,ie=u}};function Se(u,h,x,w,L,j,X,ne,ae){_e=!1,ie=null,ce.apply(Be,arguments)}function ct(u,h,x,w,L,j,X,ne,ae){if(Se.apply(this,arguments),_e){if(_e){var we=ie;_e=!1,ie=null}else throw Error(t(198));xe||(xe=!0,Le=we)}}function at(u){var h=u,x=u;if(u.alternate)for(;h.return;)h=h.return;else{u=h;do h=u,(h.flags&4098)!==0&&(x=h.return),u=h.return;while(u)}return h.tag===3?x:null}function ut(u){if(u.tag===13){var h=u.memoizedState;if(h===null&&(u=u.alternate,u!==null&&(h=u.memoizedState)),h!==null)return h.dehydrated}return null}function St(u){if(at(u)!==u)throw Error(t(188))}function ft(u){var h=u.alternate;if(!h){if(h=at(u),h===null)throw Error(t(188));return h!==u?null:u}for(var x=u,w=h;;){var L=x.return;if(L===null)break;var j=L.alternate;if(j===null){if(w=L.return,w!==null){x=w;continue}break}if(L.child===j.child){for(j=L.child;j;){if(j===x)return St(L),u;if(j===w)return St(L),h;j=j.sibling}throw Error(t(188))}if(x.return!==w.return)x=L,w=j;else{for(var X=!1,ne=L.child;ne;){if(ne===x){X=!0,x=L,w=j;break}if(ne===w){X=!0,w=L,x=j;break}ne=ne.sibling}if(!X){for(ne=j.child;ne;){if(ne===x){X=!0,x=j,w=L;break}if(ne===w){X=!0,w=j,x=L;break}ne=ne.sibling}if(!X)throw Error(t(189))}}if(x.alternate!==w)throw Error(t(190))}if(x.tag!==3)throw Error(t(188));return x.stateNode.current===x?u:h}function De(u){return u=ft(u),u!==null?se(u):null}function se(u){if(u.tag===5||u.tag===6)return u;for(u=u.child;u!==null;){var h=se(u);if(h!==null)return h;u=u.sibling}return null}var Pe=e.unstable_scheduleCallback,We=e.unstable_cancelCallback,an=e.unstable_shouldYield,yn=e.unstable_requestPaint,Ft=e.unstable_now,zn=e.unstable_getCurrentPriorityLevel,wn=e.unstable_ImmediatePriority,Wn=e.unstable_UserBlockingPriority,kn=e.unstable_NormalPriority,Fs=e.unstable_LowPriority,fi=e.unstable_IdlePriority,Qt=null,fe=null;function Ve(u){if(fe&&typeof fe.onCommitFiberRoot=="function")try{fe.onCommitFiberRoot(Qt,u,void 0,(u.current.flags&128)===128)}catch{}}var ze=Math.clz32?Math.clz32:rn,It=Math.log,Yt=Math.LN2;function rn(u){return u>>>=0,u===0?32:31-(It(u)/Yt|0)|0}var dn=64,jn=4194304;function $r(u){switch(u&-u){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function zr(u,h){var x=u.pendingLanes;if(x===0)return 0;var w=0,L=u.suspendedLanes,j=u.pingedLanes,X=x&268435455;if(X!==0){var ne=X&~L;ne!==0?w=$r(ne):(j&=X,j!==0&&(w=$r(j)))}else X=x&~L,X!==0?w=$r(X):j!==0&&(w=$r(j));if(w===0)return 0;if(h!==0&&h!==w&&(h&L)===0&&(L=w&-w,j=h&-h,L>=j||L===16&&(j&4194240)!==0))return h;if((w&4)!==0&&(w|=x&16),h=u.entangledLanes,h!==0)for(u=u.entanglements,h&=w;0<h;)x=31-ze(h),L=1<<x,w|=u[x],h&=~L;return w}function ua(u,h){switch(u){case 1:case 2:case 4:return h+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return h+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function bg(u,h){for(var x=u.suspendedLanes,w=u.pingedLanes,L=u.expirationTimes,j=u.pendingLanes;0<j;){var X=31-ze(j),ne=1<<X,ae=L[X];ae===-1?((ne&x)===0||(ne&w)!==0)&&(L[X]=ua(ne,h)):ae<=h&&(u.expiredLanes|=ne),j&=~ne}}function Xs(u){return u=u.pendingLanes&-1073741825,u!==0?u:u&1073741824?1073741824:0}function wu(){var u=dn;return dn<<=1,(dn&4194240)===0&&(dn=64),u}function qf(u){for(var h=[],x=0;31>x;x++)h.push(u);return h}function Hf(u,h,x){u.pendingLanes|=h,h!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,h=31-ze(h),u[h]=x}function Sce(u,h){var x=u.pendingLanes&~h;u.pendingLanes=h,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=h,u.mutableReadLanes&=h,u.entangledLanes&=h,h=u.entanglements;var w=u.eventTimes;for(u=u.expirationTimes;0<x;){var L=31-ze(x),j=1<<L;h[L]=0,w[L]=-1,u[L]=-1,x&=~j}}function l1(u,h){var x=u.entangledLanes|=h;for(u=u.entanglements;x;){var w=31-ze(x),L=1<<w;L&h|u[w]&h&&(u[w]|=h),x&=~L}}var Fn=0;function t3(u){return u&=-u,1<u?4<u?(u&268435455)!==0?16:536870912:4:1}var n3,c1,r3,s3,i3,u1=!1,xg=[],Qa=null,Ja=null,Za=null,Gf=new Map,Vf=new Map,el=[],Ece="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function o3(u,h){switch(u){case"focusin":case"focusout":Qa=null;break;case"dragenter":case"dragleave":Ja=null;break;case"mouseover":case"mouseout":Za=null;break;case"pointerover":case"pointerout":Gf.delete(h.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vf.delete(h.pointerId)}}function Wf(u,h,x,w,L,j){return u===null||u.nativeEvent!==j?(u={blockedOn:h,domEventName:x,eventSystemFlags:w,nativeEvent:j,targetContainers:[L]},h!==null&&(h=ah(h),h!==null&&c1(h)),u):(u.eventSystemFlags|=w,h=u.targetContainers,L!==null&&h.indexOf(L)===-1&&h.push(L),u)}function wce(u,h,x,w,L){switch(h){case"focusin":return Qa=Wf(Qa,u,h,x,w,L),!0;case"dragenter":return Ja=Wf(Ja,u,h,x,w,L),!0;case"mouseover":return Za=Wf(Za,u,h,x,w,L),!0;case"pointerover":var j=L.pointerId;return Gf.set(j,Wf(Gf.get(j)||null,u,h,x,w,L)),!0;case"gotpointercapture":return j=L.pointerId,Vf.set(j,Wf(Vf.get(j)||null,u,h,x,w,L)),!0}return!1}function a3(u){var h=dc(u.target);if(h!==null){var x=at(h);if(x!==null){if(h=x.tag,h===13){if(h=ut(x),h!==null){u.blockedOn=h,i3(u.priority,function(){r3(x)});return}}else if(h===3&&x.stateNode.current.memoizedState.isDehydrated){u.blockedOn=x.tag===3?x.stateNode.containerInfo:null;return}}}u.blockedOn=null}function Sg(u){if(u.blockedOn!==null)return!1;for(var h=u.targetContainers;0<h.length;){var x=f1(u.domEventName,u.eventSystemFlags,h[0],u.nativeEvent);if(x===null){x=u.nativeEvent;var w=new x.constructor(x.type,x);gt=w,x.target.dispatchEvent(w),gt=null}else return h=ah(x),h!==null&&c1(h),u.blockedOn=x,!1;h.shift()}return!0}function l3(u,h,x){Sg(u)&&x.delete(h)}function Tce(){u1=!1,Qa!==null&&Sg(Qa)&&(Qa=null),Ja!==null&&Sg(Ja)&&(Ja=null),Za!==null&&Sg(Za)&&(Za=null),Gf.forEach(l3),Vf.forEach(l3)}function Kf(u,h){u.blockedOn===h&&(u.blockedOn=null,u1||(u1=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Tce)))}function Yf(u){function h(L){return Kf(L,u)}if(0<xg.length){Kf(xg[0],u);for(var x=1;x<xg.length;x++){var w=xg[x];w.blockedOn===u&&(w.blockedOn=null)}}for(Qa!==null&&Kf(Qa,u),Ja!==null&&Kf(Ja,u),Za!==null&&Kf(Za,u),Gf.forEach(h),Vf.forEach(h),x=0;x<el.length;x++)w=el[x],w.blockedOn===u&&(w.blockedOn=null);for(;0<el.length&&(x=el[0],x.blockedOn===null);)a3(x),x.blockedOn===null&&el.shift()}var Tu=C.ReactCurrentBatchConfig,Eg=!0;function Cce(u,h,x,w){var L=Fn,j=Tu.transition;Tu.transition=null;try{Fn=1,d1(u,h,x,w)}finally{Fn=L,Tu.transition=j}}function Ice(u,h,x,w){var L=Fn,j=Tu.transition;Tu.transition=null;try{Fn=4,d1(u,h,x,w)}finally{Fn=L,Tu.transition=j}}function d1(u,h,x,w){if(Eg){var L=f1(u,h,x,w);if(L===null)A1(u,h,w,wg,x),o3(u,w);else if(wce(L,u,h,x,w))w.stopPropagation();else if(o3(u,w),h&4&&-1<Ece.indexOf(u)){for(;L!==null;){var j=ah(L);if(j!==null&&n3(j),j=f1(u,h,x,w),j===null&&A1(u,h,w,wg,x),j===L)break;L=j}L!==null&&w.stopPropagation()}else A1(u,h,w,null,x)}}var wg=null;function f1(u,h,x,w){if(wg=null,u=Wt(w),u=dc(u),u!==null)if(h=at(u),h===null)u=null;else if(x=h.tag,x===13){if(u=ut(h),u!==null)return u;u=null}else if(x===3){if(h.stateNode.current.memoizedState.isDehydrated)return h.tag===3?h.stateNode.containerInfo:null;u=null}else h!==u&&(u=null);return wg=u,null}function c3(u){switch(u){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(zn()){case wn:return 1;case Wn:return 4;case kn:case Fs:return 16;case fi:return 536870912;default:return 16}default:return 16}}var tl=null,h1=null,Tg=null;function u3(){if(Tg)return Tg;var u,h=h1,x=h.length,w,L="value"in tl?tl.value:tl.textContent,j=L.length;for(u=0;u<x&&h[u]===L[u];u++);var X=x-u;for(w=1;w<=X&&h[x-w]===L[j-w];w++);return Tg=L.slice(u,1<w?1-w:void 0)}function Cg(u){var h=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&h===13&&(u=13)):u=h,u===10&&(u=13),32<=u||u===13?u:0}function Ig(){return!0}function d3(){return!1}function hi(u){function h(x,w,L,j,X){this._reactName=x,this._targetInst=L,this.type=w,this.nativeEvent=j,this.target=X,this.currentTarget=null;for(var ne in u)u.hasOwnProperty(ne)&&(x=u[ne],this[ne]=x?x(j):j[ne]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?Ig:d3,this.isPropagationStopped=d3,this}return P(h.prototype,{preventDefault:function(){this.defaultPrevented=!0;var x=this.nativeEvent;x&&(x.preventDefault?x.preventDefault():typeof x.returnValue!="unknown"&&(x.returnValue=!1),this.isDefaultPrevented=Ig)},stopPropagation:function(){var x=this.nativeEvent;x&&(x.stopPropagation?x.stopPropagation():typeof x.cancelBubble!="unknown"&&(x.cancelBubble=!0),this.isPropagationStopped=Ig)},persist:function(){},isPersistent:Ig}),h}var Cu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},p1=hi(Cu),Xf=P({},Cu,{view:0,detail:0}),Rce=hi(Xf),m1,g1,Qf,Rg=P({},Xf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:v1,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==Qf&&(Qf&&u.type==="mousemove"?(m1=u.screenX-Qf.screenX,g1=u.screenY-Qf.screenY):g1=m1=0,Qf=u),m1)},movementY:function(u){return"movementY"in u?u.movementY:g1}}),f3=hi(Rg),Ace=P({},Rg,{dataTransfer:0}),kce=hi(Ace),Lce=P({},Xf,{relatedTarget:0}),_1=hi(Lce),Mce=P({},Cu,{animationName:0,elapsedTime:0,pseudoElement:0}),Nce=hi(Mce),Oce=P({},Cu,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),Pce=hi(Oce),Dce=P({},Cu,{data:0}),h3=hi(Dce),jce={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fce={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Uce={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bce(u){var h=this.nativeEvent;return h.getModifierState?h.getModifierState(u):(u=Uce[u])?!!h[u]:!1}function v1(){return Bce}var $ce=P({},Xf,{key:function(u){if(u.key){var h=jce[u.key]||u.key;if(h!=="Unidentified")return h}return u.type==="keypress"?(u=Cg(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?Fce[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:v1,charCode:function(u){return u.type==="keypress"?Cg(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?Cg(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),zce=hi($ce),qce=P({},Rg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),p3=hi(qce),Hce=P({},Xf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:v1}),Gce=hi(Hce),Vce=P({},Cu,{propertyName:0,elapsedTime:0,pseudoElement:0}),Wce=hi(Vce),Kce=P({},Rg,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),Yce=hi(Kce),Xce=[9,13,27,32],y1=a&&"CompositionEvent"in window,Jf=null;a&&"documentMode"in document&&(Jf=document.documentMode);var Qce=a&&"TextEvent"in window&&!Jf,m3=a&&(!y1||Jf&&8<Jf&&11>=Jf),g3=" ",_3=!1;function v3(u,h){switch(u){case"keyup":return Xce.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function y3(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var Iu=!1;function Jce(u,h){switch(u){case"compositionend":return y3(h);case"keypress":return h.which!==32?null:(_3=!0,g3);case"textInput":return u=h.data,u===g3&&_3?null:u;default:return null}}function Zce(u,h){if(Iu)return u==="compositionend"||!y1&&v3(u,h)?(u=u3(),Tg=h1=tl=null,Iu=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1<h.char.length)return h.char;if(h.which)return String.fromCharCode(h.which)}return null;case"compositionend":return m3&&h.locale!=="ko"?null:h.data;default:return null}}var eue={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function b3(u){var h=u&&u.nodeName&&u.nodeName.toLowerCase();return h==="input"?!!eue[u.type]:h==="textarea"}function x3(u,h,x,w){$n(w),h=Ng(h,"onChange"),0<h.length&&(x=new p1("onChange","change",null,x,w),u.push({event:x,listeners:h}))}var Zf=null,eh=null;function tue(u){U3(u,0)}function Ag(u){var h=Mu(u);if(le(h))return u}function nue(u,h){if(u==="change")return h}var S3=!1;if(a){var b1;if(a){var x1="oninput"in document;if(!x1){var E3=document.createElement("div");E3.setAttribute("oninput","return;"),x1=typeof E3.oninput=="function"}b1=x1}else b1=!1;S3=b1&&(!document.documentMode||9<document.documentMode)}function w3(){Zf&&(Zf.detachEvent("onpropertychange",T3),eh=Zf=null)}function T3(u){if(u.propertyName==="value"&&Ag(eh)){var h=[];x3(h,eh,u,Wt(u)),es(tue,h)}}function rue(u,h,x){u==="focusin"?(w3(),Zf=h,eh=x,Zf.attachEvent("onpropertychange",T3)):u==="focusout"&&w3()}function sue(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return Ag(eh)}function iue(u,h){if(u==="click")return Ag(h)}function oue(u,h){if(u==="input"||u==="change")return Ag(h)}function aue(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var ao=typeof Object.is=="function"?Object.is:aue;function th(u,h){if(ao(u,h))return!0;if(typeof u!="object"||u===null||typeof h!="object"||h===null)return!1;var x=Object.keys(u),w=Object.keys(h);if(x.length!==w.length)return!1;for(w=0;w<x.length;w++){var L=x[w];if(!l.call(h,L)||!ao(u[L],h[L]))return!1}return!0}function C3(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function I3(u,h){var x=C3(u);u=0;for(var w;x;){if(x.nodeType===3){if(w=u+x.textContent.length,u<=h&&w>=h)return{node:x,offset:h-u};u=w}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=C3(x)}}function R3(u,h){return u&&h?u===h?!0:u&&u.nodeType===3?!1:h&&h.nodeType===3?R3(u,h.parentNode):"contains"in u?u.contains(h):u.compareDocumentPosition?!!(u.compareDocumentPosition(h)&16):!1:!1}function A3(){for(var u=window,h=Ie();h instanceof u.HTMLIFrameElement;){try{var x=typeof h.contentWindow.location.href=="string"}catch{x=!1}if(x)u=h.contentWindow;else break;h=Ie(u.document)}return h}function S1(u){var h=u&&u.nodeName&&u.nodeName.toLowerCase();return h&&(h==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||h==="textarea"||u.contentEditable==="true")}function lue(u){var h=A3(),x=u.focusedElem,w=u.selectionRange;if(h!==x&&x&&x.ownerDocument&&R3(x.ownerDocument.documentElement,x)){if(w!==null&&S1(x)){if(h=w.start,u=w.end,u===void 0&&(u=h),"selectionStart"in x)x.selectionStart=h,x.selectionEnd=Math.min(u,x.value.length);else if(u=(h=x.ownerDocument||document)&&h.defaultView||window,u.getSelection){u=u.getSelection();var L=x.textContent.length,j=Math.min(w.start,L);w=w.end===void 0?j:Math.min(w.end,L),!u.extend&&j>w&&(L=w,w=j,j=L),L=I3(x,j);var X=I3(x,w);L&&X&&(u.rangeCount!==1||u.anchorNode!==L.node||u.anchorOffset!==L.offset||u.focusNode!==X.node||u.focusOffset!==X.offset)&&(h=h.createRange(),h.setStart(L.node,L.offset),u.removeAllRanges(),j>w?(u.addRange(h),u.extend(X.node,X.offset)):(h.setEnd(X.node,X.offset),u.addRange(h)))}}for(h=[],u=x;u=u.parentNode;)u.nodeType===1&&h.push({element:u,left:u.scrollLeft,top:u.scrollTop});for(typeof x.focus=="function"&&x.focus(),x=0;x<h.length;x++)u=h[x],u.element.scrollLeft=u.left,u.element.scrollTop=u.top}}var cue=a&&"documentMode"in document&&11>=document.documentMode,Ru=null,E1=null,nh=null,w1=!1;function k3(u,h,x){var w=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;w1||Ru==null||Ru!==Ie(w)||(w=Ru,"selectionStart"in w&&S1(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),nh&&th(nh,w)||(nh=w,w=Ng(E1,"onSelect"),0<w.length&&(h=new p1("onSelect","select",null,h,x),u.push({event:h,listeners:w}),h.target=Ru)))}function kg(u,h){var x={};return x[u.toLowerCase()]=h.toLowerCase(),x["Webkit"+u]="webkit"+h,x["Moz"+u]="moz"+h,x}var Au={animationend:kg("Animation","AnimationEnd"),animationiteration:kg("Animation","AnimationIteration"),animationstart:kg("Animation","AnimationStart"),transitionend:kg("Transition","TransitionEnd")},T1={},L3={};a&&(L3=document.createElement("div").style,"AnimationEvent"in window||(delete Au.animationend.animation,delete Au.animationiteration.animation,delete Au.animationstart.animation),"TransitionEvent"in window||delete Au.transitionend.transition);function Lg(u){if(T1[u])return T1[u];if(!Au[u])return u;var h=Au[u],x;for(x in h)if(h.hasOwnProperty(x)&&x in L3)return T1[u]=h[x];return u}var M3=Lg("animationend"),N3=Lg("animationiteration"),O3=Lg("animationstart"),P3=Lg("transitionend"),D3=new Map,j3="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function nl(u,h){D3.set(u,h),i(h,[u])}for(var C1=0;C1<j3.length;C1++){var I1=j3[C1],uue=I1.toLowerCase(),due=I1[0].toUpperCase()+I1.slice(1);nl(uue,"on"+due)}nl(M3,"onAnimationEnd"),nl(N3,"onAnimationIteration"),nl(O3,"onAnimationStart"),nl("dblclick","onDoubleClick"),nl("focusin","onFocus"),nl("focusout","onBlur"),nl(P3,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var rh="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),fue=new Set("cancel close invalid load scroll toggle".split(" ").concat(rh));function F3(u,h,x){var w=u.type||"unknown-event";u.currentTarget=x,ct(w,h,void 0,u),u.currentTarget=null}function U3(u,h){h=(h&4)!==0;for(var x=0;x<u.length;x++){var w=u[x],L=w.event;w=w.listeners;e:{var j=void 0;if(h)for(var X=w.length-1;0<=X;X--){var ne=w[X],ae=ne.instance,we=ne.currentTarget;if(ne=ne.listener,ae!==j&&L.isPropagationStopped())break e;F3(L,ne,we),j=ae}else for(X=0;X<w.length;X++){if(ne=w[X],ae=ne.instance,we=ne.currentTarget,ne=ne.listener,ae!==j&&L.isPropagationStopped())break e;F3(L,ne,we),j=ae}}}if(xe)throw u=Le,xe=!1,Le=null,u}function ir(u,h){var x=h[P1];x===void 0&&(x=h[P1]=new Set);var w=u+"__bubble";x.has(w)||(B3(h,u,2,!1),x.add(w))}function R1(u,h,x){var w=0;h&&(w|=4),B3(x,u,w,h)}var Mg="_reactListening"+Math.random().toString(36).slice(2);function sh(u){if(!u[Mg]){u[Mg]=!0,r.forEach(function(x){x!=="selectionchange"&&(fue.has(x)||R1(x,!1,u),R1(x,!0,u))});var h=u.nodeType===9?u:u.ownerDocument;h===null||h[Mg]||(h[Mg]=!0,R1("selectionchange",!1,h))}}function B3(u,h,x,w){switch(c3(h)){case 1:var L=Cce;break;case 4:L=Ice;break;default:L=d1}x=L.bind(null,h,x,u),L=void 0,!fs||h!=="touchstart"&&h!=="touchmove"&&h!=="wheel"||(L=!0),w?L!==void 0?u.addEventListener(h,x,{capture:!0,passive:L}):u.addEventListener(h,x,!0):L!==void 0?u.addEventListener(h,x,{passive:L}):u.addEventListener(h,x,!1)}function A1(u,h,x,w,L){var j=w;if((h&1)===0&&(h&2)===0&&w!==null)e:for(;;){if(w===null)return;var X=w.tag;if(X===3||X===4){var ne=w.stateNode.containerInfo;if(ne===L||ne.nodeType===8&&ne.parentNode===L)break;if(X===4)for(X=w.return;X!==null;){var ae=X.tag;if((ae===3||ae===4)&&(ae=X.stateNode.containerInfo,ae===L||ae.nodeType===8&&ae.parentNode===L))return;X=X.return}for(;ne!==null;){if(X=dc(ne),X===null)return;if(ae=X.tag,ae===5||ae===6){w=j=X;continue e}ne=ne.parentNode}}w=w.return}es(function(){var we=j,Ge=Wt(x),Ke=[];e:{var He=D3.get(u);if(He!==void 0){var _t=p1,Tt=u;switch(u){case"keypress":if(Cg(x)===0)break e;case"keydown":case"keyup":_t=zce;break;case"focusin":Tt="focus",_t=_1;break;case"focusout":Tt="blur",_t=_1;break;case"beforeblur":case"afterblur":_t=_1;break;case"click":if(x.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":_t=f3;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":_t=kce;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":_t=Gce;break;case M3:case N3:case O3:_t=Nce;break;case P3:_t=Wce;break;case"scroll":_t=Rce;break;case"wheel":_t=Yce;break;case"copy":case"cut":case"paste":_t=Pce;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":_t=p3}var Rt=(h&4)!==0,Lr=!Rt&&u==="scroll",me=Rt?He!==null?He+"Capture":null:He;Rt=[];for(var ue=we,ye;ue!==null;){ye=ue;var Ze=ye.stateNode;if(ye.tag===5&&Ze!==null&&(ye=Ze,me!==null&&(Ze=ds(ue,me),Ze!=null&&Rt.push(ih(ue,Ze,ye)))),Lr)break;ue=ue.return}0<Rt.length&&(He=new _t(He,Tt,null,x,Ge),Ke.push({event:He,listeners:Rt}))}}if((h&7)===0){e:{if(He=u==="mouseover"||u==="pointerover",_t=u==="mouseout"||u==="pointerout",He&&x!==gt&&(Tt=x.relatedTarget||x.fromElement)&&(dc(Tt)||Tt[da]))break e;if((_t||He)&&(He=Ge.window===Ge?Ge:(He=Ge.ownerDocument)?He.defaultView||He.parentWindow:window,_t?(Tt=x.relatedTarget||x.toElement,_t=we,Tt=Tt?dc(Tt):null,Tt!==null&&(Lr=at(Tt),Tt!==Lr||Tt.tag!==5&&Tt.tag!==6)&&(Tt=null)):(_t=null,Tt=we),_t!==Tt)){if(Rt=f3,Ze="onMouseLeave",me="onMouseEnter",ue="mouse",(u==="pointerout"||u==="pointerover")&&(Rt=p3,Ze="onPointerLeave",me="onPointerEnter",ue="pointer"),Lr=_t==null?He:Mu(_t),ye=Tt==null?He:Mu(Tt),He=new Rt(Ze,ue+"leave",_t,x,Ge),He.target=Lr,He.relatedTarget=ye,Ze=null,dc(Ge)===we&&(Rt=new Rt(me,ue+"enter",Tt,x,Ge),Rt.target=ye,Rt.relatedTarget=Lr,Ze=Rt),Lr=Ze,_t&&Tt)t:{for(Rt=_t,me=Tt,ue=0,ye=Rt;ye;ye=ku(ye))ue++;for(ye=0,Ze=me;Ze;Ze=ku(Ze))ye++;for(;0<ue-ye;)Rt=ku(Rt),ue--;for(;0<ye-ue;)me=ku(me),ye--;for(;ue--;){if(Rt===me||me!==null&&Rt===me.alternate)break t;Rt=ku(Rt),me=ku(me)}Rt=null}else Rt=null;_t!==null&&$3(Ke,He,_t,Rt,!1),Tt!==null&&Lr!==null&&$3(Ke,Lr,Tt,Rt,!0)}}e:{if(He=we?Mu(we):window,_t=He.nodeName&&He.nodeName.toLowerCase(),_t==="select"||_t==="input"&&He.type==="file")var kt=nue;else if(b3(He))if(S3)kt=oue;else{kt=sue;var qt=rue}else(_t=He.nodeName)&&_t.toLowerCase()==="input"&&(He.type==="checkbox"||He.type==="radio")&&(kt=iue);if(kt&&(kt=kt(u,we))){x3(Ke,kt,x,Ge);break e}qt&&qt(u,He,we),u==="focusout"&&(qt=He._wrapperState)&&qt.controlled&&He.type==="number"&&et(He,"number",He.value)}switch(qt=we?Mu(we):window,u){case"focusin":(b3(qt)||qt.contentEditable==="true")&&(Ru=qt,E1=we,nh=null);break;case"focusout":nh=E1=Ru=null;break;case"mousedown":w1=!0;break;case"contextmenu":case"mouseup":case"dragend":w1=!1,k3(Ke,x,Ge);break;case"selectionchange":if(cue)break;case"keydown":case"keyup":k3(Ke,x,Ge)}var Ht;if(y1)e:{switch(u){case"compositionstart":var Jt="onCompositionStart";break e;case"compositionend":Jt="onCompositionEnd";break e;case"compositionupdate":Jt="onCompositionUpdate";break e}Jt=void 0}else Iu?v3(u,x)&&(Jt="onCompositionEnd"):u==="keydown"&&x.keyCode===229&&(Jt="onCompositionStart");Jt&&(m3&&x.locale!=="ko"&&(Iu||Jt!=="onCompositionStart"?Jt==="onCompositionEnd"&&Iu&&(Ht=u3()):(tl=Ge,h1="value"in tl?tl.value:tl.textContent,Iu=!0)),qt=Ng(we,Jt),0<qt.length&&(Jt=new h3(Jt,u,null,x,Ge),Ke.push({event:Jt,listeners:qt}),Ht?Jt.data=Ht:(Ht=y3(x),Ht!==null&&(Jt.data=Ht)))),(Ht=Qce?Jce(u,x):Zce(u,x))&&(we=Ng(we,"onBeforeInput"),0<we.length&&(Ge=new h3("onBeforeInput","beforeinput",null,x,Ge),Ke.push({event:Ge,listeners:we}),Ge.data=Ht))}U3(Ke,h)})}function ih(u,h,x){return{instance:u,listener:h,currentTarget:x}}function Ng(u,h){for(var x=h+"Capture",w=[];u!==null;){var L=u,j=L.stateNode;L.tag===5&&j!==null&&(L=j,j=ds(u,x),j!=null&&w.unshift(ih(u,j,L)),j=ds(u,h),j!=null&&w.push(ih(u,j,L))),u=u.return}return w}function ku(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5);return u||null}function $3(u,h,x,w,L){for(var j=h._reactName,X=[];x!==null&&x!==w;){var ne=x,ae=ne.alternate,we=ne.stateNode;if(ae!==null&&ae===w)break;ne.tag===5&&we!==null&&(ne=we,L?(ae=ds(x,j),ae!=null&&X.unshift(ih(x,ae,ne))):L||(ae=ds(x,j),ae!=null&&X.push(ih(x,ae,ne)))),x=x.return}X.length!==0&&u.push({event:h,listeners:X})}var hue=/\r\n?/g,pue=/\u0000|\uFFFD/g;function z3(u){return(typeof u=="string"?u:""+u).replace(hue,`
55 `).replace(pue,"")}function Og(u,h,x){if(h=z3(h),z3(u)!==h&&x)throw Error(t(425))}function Pg(){}var k1=null,L1=null;function M1(u,h){return u==="textarea"||u==="noscript"||typeof h.children=="string"||typeof h.children=="number"||typeof h.dangerouslySetInnerHTML=="object"&&h.dangerouslySetInnerHTML!==null&&h.dangerouslySetInnerHTML.__html!=null}var N1=typeof setTimeout=="function"?setTimeout:void 0,mue=typeof clearTimeout=="function"?clearTimeout:void 0,q3=typeof Promise=="function"?Promise:void 0,gue=typeof queueMicrotask=="function"?queueMicrotask:typeof q3<"u"?function(u){return q3.resolve(null).then(u).catch(_ue)}:N1;function _ue(u){setTimeout(function(){throw u})}function O1(u,h){var x=h,w=0;do{var L=x.nextSibling;if(u.removeChild(x),L&&L.nodeType===8)if(x=L.data,x==="/$"){if(w===0){u.removeChild(L),Yf(h);return}w--}else x!=="$"&&x!=="$?"&&x!=="$!"||w++;x=L}while(x);Yf(h)}function rl(u){for(;u!=null;u=u.nextSibling){var h=u.nodeType;if(h===1||h===3)break;if(h===8){if(h=u.data,h==="$"||h==="$!"||h==="$?")break;if(h==="/$")return null}}return u}function H3(u){u=u.previousSibling;for(var h=0;u;){if(u.nodeType===8){var x=u.data;if(x==="$"||x==="$!"||x==="$?"){if(h===0)return u;h--}else x==="/$"&&h++}u=u.previousSibling}return null}var Lu=Math.random().toString(36).slice(2),$o="__reactFiber$"+Lu,oh="__reactProps$"+Lu,da="__reactContainer$"+Lu,P1="__reactEvents$"+Lu,vue="__reactListeners$"+Lu,yue="__reactHandles$"+Lu;function dc(u){var h=u[$o];if(h)return h;for(var x=u.parentNode;x;){if(h=x[da]||x[$o]){if(x=h.alternate,h.child!==null||x!==null&&x.child!==null)for(u=H3(u);u!==null;){if(x=u[$o])return x;u=H3(u)}return h}u=x,x=u.parentNode}return null}function ah(u){return u=u[$o]||u[da],!u||u.tag!==5&&u.tag!==6&&u.tag!==13&&u.tag!==3?null:u}function Mu(u){if(u.tag===5||u.tag===6)return u.stateNode;throw Error(t(33))}function Dg(u){return u[oh]||null}var D1=[],Nu=-1;function sl(u){return{current:u}}function or(u){0>Nu||(u.current=D1[Nu],D1[Nu]=null,Nu--)}function Zn(u,h){Nu++,D1[Nu]=u.current,u.current=h}var il={},Ts=sl(il),Qs=sl(!1),fc=il;function Ou(u,h){var x=u.type.contextTypes;if(!x)return il;var w=u.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===h)return w.__reactInternalMemoizedMaskedChildContext;var L={},j;for(j in x)L[j]=h[j];return w&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=h,u.__reactInternalMemoizedMaskedChildContext=L),L}function Js(u){return u=u.childContextTypes,u!=null}function jg(){or(Qs),or(Ts)}function G3(u,h,x){if(Ts.current!==il)throw Error(t(168));Zn(Ts,h),Zn(Qs,x)}function V3(u,h,x){var w=u.stateNode;if(h=h.childContextTypes,typeof w.getChildContext!="function")return x;w=w.getChildContext();for(var L in w)if(!(L in h))throw Error(t(108,W(u)||"Unknown",L));return P({},x,w)}function Fg(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||il,fc=Ts.current,Zn(Ts,u),Zn(Qs,Qs.current),!0}function W3(u,h,x){var w=u.stateNode;if(!w)throw Error(t(169));x?(u=V3(u,h,fc),w.__reactInternalMemoizedMergedChildContext=u,or(Qs),or(Ts),Zn(Ts,u)):or(Qs),Zn(Qs,x)}var fa=null,Ug=!1,j1=!1;function K3(u){fa===null?fa=[u]:fa.push(u)}function bue(u){Ug=!0,K3(u)}function ol(){if(!j1&&fa!==null){j1=!0;var u=0,h=Fn;try{var x=fa;for(Fn=1;u<x.length;u++){var w=x[u];do w=w(!0);while(w!==null)}fa=null,Ug=!1}catch(L){throw fa!==null&&(fa=fa.slice(u+1)),Pe(wn,ol),L}finally{Fn=h,j1=!1}}return null}var Pu=[],Du=0,Bg=null,$g=0,Oi=[],Pi=0,hc=null,ha=1,pa="";function pc(u,h){Pu[Du++]=$g,Pu[Du++]=Bg,Bg=u,$g=h}function Y3(u,h,x){Oi[Pi++]=ha,Oi[Pi++]=pa,Oi[Pi++]=hc,hc=u;var w=ha;u=pa;var L=32-ze(w)-1;w&=~(1<<L),x+=1;var j=32-ze(h)+L;if(30<j){var X=L-L%5;j=(w&(1<<X)-1).toString(32),w>>=X,L-=X,ha=1<<32-ze(h)+L|x<<L|w,pa=j+u}else ha=1<<j|x<<L|w,pa=u}function F1(u){u.return!==null&&(pc(u,1),Y3(u,1,0))}function U1(u){for(;u===Bg;)Bg=Pu[--Du],Pu[Du]=null,$g=Pu[--Du],Pu[Du]=null;for(;u===hc;)hc=Oi[--Pi],Oi[Pi]=null,pa=Oi[--Pi],Oi[Pi]=null,ha=Oi[--Pi],Oi[Pi]=null}var pi=null,mi=null,ur=!1,lo=null;function X3(u,h){var x=Ui(5,null,null,0);x.elementType="DELETED",x.stateNode=h,x.return=u,h=u.deletions,h===null?(u.deletions=[x],u.flags|=16):h.push(x)}function Q3(u,h){switch(u.tag){case 5:var x=u.type;return h=h.nodeType!==1||x.toLowerCase()!==h.nodeName.toLowerCase()?null:h,h!==null?(u.stateNode=h,pi=u,mi=rl(h.firstChild),!0):!1;case 6:return h=u.pendingProps===""||h.nodeType!==3?null:h,h!==null?(u.stateNode=h,pi=u,mi=null,!0):!1;case 13:return h=h.nodeType!==8?null:h,h!==null?(x=hc!==null?{id:ha,overflow:pa}:null,u.memoizedState={dehydrated:h,treeContext:x,retryLane:1073741824},x=Ui(18,null,null,0),x.stateNode=h,x.return=u,u.child=x,pi=u,mi=null,!0):!1;default:return!1}}function B1(u){return(u.mode&1)!==0&&(u.flags&128)===0}function $1(u){if(ur){var h=mi;if(h){var x=h;if(!Q3(u,h)){if(B1(u))throw Error(t(418));h=rl(x.nextSibling);var w=pi;h&&Q3(u,h)?X3(w,x):(u.flags=u.flags&-4097|2,ur=!1,pi=u)}}else{if(B1(u))throw Error(t(418));u.flags=u.flags&-4097|2,ur=!1,pi=u}}}function J3(u){for(u=u.return;u!==null&&u.tag!==5&&u.tag!==3&&u.tag!==13;)u=u.return;pi=u}function zg(u){if(u!==pi)return!1;if(!ur)return J3(u),ur=!0,!1;var h;if((h=u.tag!==3)&&!(h=u.tag!==5)&&(h=u.type,h=h!=="head"&&h!=="body"&&!M1(u.type,u.memoizedProps)),h&&(h=mi)){if(B1(u))throw Z3(),Error(t(418));for(;h;)X3(u,h),h=rl(h.nextSibling)}if(J3(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(t(317));e:{for(u=u.nextSibling,h=0;u;){if(u.nodeType===8){var x=u.data;if(x==="/$"){if(h===0){mi=rl(u.nextSibling);break e}h--}else x!=="$"&&x!=="$!"&&x!=="$?"||h++}u=u.nextSibling}mi=null}}else mi=pi?rl(u.stateNode.nextSibling):null;return!0}function Z3(){for(var u=mi;u;)u=rl(u.nextSibling)}function ju(){mi=pi=null,ur=!1}function z1(u){lo===null?lo=[u]:lo.push(u)}var xue=C.ReactCurrentBatchConfig;function co(u,h){if(u&&u.defaultProps){h=P({},h),u=u.defaultProps;for(var x in u)h[x]===void 0&&(h[x]=u[x]);return h}return h}var qg=sl(null),Hg=null,Fu=null,q1=null;function H1(){q1=Fu=Hg=null}function G1(u){var h=qg.current;or(qg),u._currentValue=h}function V1(u,h,x){for(;u!==null;){var w=u.alternate;if((u.childLanes&h)!==h?(u.childLanes|=h,w!==null&&(w.childLanes|=h)):w!==null&&(w.childLanes&h)!==h&&(w.childLanes|=h),u===x)break;u=u.return}}function Uu(u,h){Hg=u,q1=Fu=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&h)!==0&&(Zs=!0),u.firstContext=null)}function Di(u){var h=u._currentValue;if(q1!==u)if(u={context:u,memoizedValue:h,next:null},Fu===null){if(Hg===null)throw Error(t(308));Fu=u,Hg.dependencies={lanes:0,firstContext:u}}else Fu=Fu.next=u;return h}var mc=null;function W1(u){mc===null?mc=[u]:mc.push(u)}function e4(u,h,x,w){var L=h.interleaved;return L===null?(x.next=x,W1(h)):(x.next=L.next,L.next=x),h.interleaved=x,ma(u,w)}function ma(u,h){u.lanes|=h;var x=u.alternate;for(x!==null&&(x.lanes|=h),x=u,u=u.return;u!==null;)u.childLanes|=h,x=u.alternate,x!==null&&(x.childLanes|=h),x=u,u=u.return;return x.tag===3?x.stateNode:null}var al=!1;function K1(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function t4(u,h){u=u.updateQueue,h.updateQueue===u&&(h.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function ga(u,h){return{eventTime:u,lane:h,tag:0,payload:null,callback:null,next:null}}function ll(u,h,x){var w=u.updateQueue;if(w===null)return null;if(w=w.shared,(Cn&2)!==0){var L=w.pending;return L===null?h.next=h:(h.next=L.next,L.next=h),w.pending=h,ma(u,x)}return L=w.interleaved,L===null?(h.next=h,W1(w)):(h.next=L.next,L.next=h),w.interleaved=h,ma(u,x)}function Gg(u,h,x){if(h=h.updateQueue,h!==null&&(h=h.shared,(x&4194240)!==0)){var w=h.lanes;w&=u.pendingLanes,x|=w,h.lanes=x,l1(u,x)}}function n4(u,h){var x=u.updateQueue,w=u.alternate;if(w!==null&&(w=w.updateQueue,x===w)){var L=null,j=null;if(x=x.firstBaseUpdate,x!==null){do{var X={eventTime:x.eventTime,lane:x.lane,tag:x.tag,payload:x.payload,callback:x.callback,next:null};j===null?L=j=X:j=j.next=X,x=x.next}while(x!==null);j===null?L=j=h:j=j.next=h}else L=j=h;x={baseState:w.baseState,firstBaseUpdate:L,lastBaseUpdate:j,shared:w.shared,effects:w.effects},u.updateQueue=x;return}u=x.lastBaseUpdate,u===null?x.firstBaseUpdate=h:u.next=h,x.lastBaseUpdate=h}function Vg(u,h,x,w){var L=u.updateQueue;al=!1;var j=L.firstBaseUpdate,X=L.lastBaseUpdate,ne=L.shared.pending;if(ne!==null){L.shared.pending=null;var ae=ne,we=ae.next;ae.next=null,X===null?j=we:X.next=we,X=ae;var Ge=u.alternate;Ge!==null&&(Ge=Ge.updateQueue,ne=Ge.lastBaseUpdate,ne!==X&&(ne===null?Ge.firstBaseUpdate=we:ne.next=we,Ge.lastBaseUpdate=ae))}if(j!==null){var Ke=L.baseState;X=0,Ge=we=ae=null,ne=j;do{var He=ne.lane,_t=ne.eventTime;if((w&He)===He){Ge!==null&&(Ge=Ge.next={eventTime:_t,lane:0,tag:ne.tag,payload:ne.payload,callback:ne.callback,next:null});e:{var Tt=u,Rt=ne;switch(He=h,_t=x,Rt.tag){case 1:if(Tt=Rt.payload,typeof Tt=="function"){Ke=Tt.call(_t,Ke,He);break e}Ke=Tt;break e;case 3:Tt.flags=Tt.flags&-65537|128;case 0:if(Tt=Rt.payload,He=typeof Tt=="function"?Tt.call(_t,Ke,He):Tt,He==null)break e;Ke=P({},Ke,He);break e;case 2:al=!0}}ne.callback!==null&&ne.lane!==0&&(u.flags|=64,He=L.effects,He===null?L.effects=[ne]:He.push(ne))}else _t={eventTime:_t,lane:He,tag:ne.tag,payload:ne.payload,callback:ne.callback,next:null},Ge===null?(we=Ge=_t,ae=Ke):Ge=Ge.next=_t,X|=He;if(ne=ne.next,ne===null){if(ne=L.shared.pending,ne===null)break;He=ne,ne=He.next,He.next=null,L.lastBaseUpdate=He,L.shared.pending=null}}while(!0);if(Ge===null&&(ae=Ke),L.baseState=ae,L.firstBaseUpdate=we,L.lastBaseUpdate=Ge,h=L.shared.interleaved,h!==null){L=h;do X|=L.lane,L=L.next;while(L!==h)}else j===null&&(L.shared.lanes=0);vc|=X,u.lanes=X,u.memoizedState=Ke}}function r4(u,h,x){if(u=h.effects,h.effects=null,u!==null)for(h=0;h<u.length;h++){var w=u[h],L=w.callback;if(L!==null){if(w.callback=null,w=x,typeof L!="function")throw Error(t(191,L));L.call(w)}}}var s4=new n.Component().refs;function Y1(u,h,x,w){h=u.memoizedState,x=x(w,h),x=x==null?h:P({},h,x),u.memoizedState=x,u.lanes===0&&(u.updateQueue.baseState=x)}var Wg={isMounted:function(u){return(u=u._reactInternals)?at(u)===u:!1},enqueueSetState:function(u,h,x){u=u._reactInternals;var w=Bs(),L=fl(u),j=ga(w,L);j.payload=h,x!=null&&(j.callback=x),h=ll(u,j,L),h!==null&&(ho(h,u,L,w),Gg(h,u,L))},enqueueReplaceState:function(u,h,x){u=u._reactInternals;var w=Bs(),L=fl(u),j=ga(w,L);j.tag=1,j.payload=h,x!=null&&(j.callback=x),h=ll(u,j,L),h!==null&&(ho(h,u,L,w),Gg(h,u,L))},enqueueForceUpdate:function(u,h){u=u._reactInternals;var x=Bs(),w=fl(u),L=ga(x,w);L.tag=2,h!=null&&(L.callback=h),h=ll(u,L,w),h!==null&&(ho(h,u,w,x),Gg(h,u,w))}};function i4(u,h,x,w,L,j,X){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(w,j,X):h.prototype&&h.prototype.isPureReactComponent?!th(x,w)||!th(L,j):!0}function o4(u,h,x){var w=!1,L=il,j=h.contextType;return typeof j=="object"&&j!==null?j=Di(j):(L=Js(h)?fc:Ts.current,w=h.contextTypes,j=(w=w!=null)?Ou(u,L):il),h=new h(x,j),u.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Wg,u.stateNode=h,h._reactInternals=u,w&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=L,u.__reactInternalMemoizedMaskedChildContext=j),h}function a4(u,h,x,w){u=h.state,typeof h.componentWillReceiveProps=="function"&&h.componentWillReceiveProps(x,w),typeof h.UNSAFE_componentWillReceiveProps=="function"&&h.UNSAFE_componentWillReceiveProps(x,w),h.state!==u&&Wg.enqueueReplaceState(h,h.state,null)}function X1(u,h,x,w){var L=u.stateNode;L.props=x,L.state=u.memoizedState,L.refs=s4,K1(u);var j=h.contextType;typeof j=="object"&&j!==null?L.context=Di(j):(j=Js(h)?fc:Ts.current,L.context=Ou(u,j)),L.state=u.memoizedState,j=h.getDerivedStateFromProps,typeof j=="function"&&(Y1(u,h,j,x),L.state=u.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(h=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),h!==L.state&&Wg.enqueueReplaceState(L,L.state,null),Vg(u,x,L,w),L.state=u.memoizedState),typeof L.componentDidMount=="function"&&(u.flags|=4194308)}function lh(u,h,x){if(u=x.ref,u!==null&&typeof u!="function"&&typeof u!="object"){if(x._owner){if(x=x._owner,x){if(x.tag!==1)throw Error(t(309));var w=x.stateNode}if(!w)throw Error(t(147,u));var L=w,j=""+u;return h!==null&&h.ref!==null&&typeof h.ref=="function"&&h.ref._stringRef===j?h.ref:(h=function(X){var ne=L.refs;ne===s4&&(ne=L.refs={}),X===null?delete ne[j]:ne[j]=X},h._stringRef=j,h)}if(typeof u!="string")throw Error(t(284));if(!x._owner)throw Error(t(290,u))}return u}function Kg(u,h){throw u=Object.prototype.toString.call(h),Error(t(31,u==="[object Object]"?"object with keys {"+Object.keys(h).join(", ")+"}":u))}function l4(u){var h=u._init;return h(u._payload)}function c4(u){function h(me,ue){if(u){var ye=me.deletions;ye===null?(me.deletions=[ue],me.flags|=16):ye.push(ue)}}function x(me,ue){if(!u)return null;for(;ue!==null;)h(me,ue),ue=ue.sibling;return null}function w(me,ue){for(me=new Map;ue!==null;)ue.key!==null?me.set(ue.key,ue):me.set(ue.index,ue),ue=ue.sibling;return me}function L(me,ue){return me=pl(me,ue),me.index=0,me.sibling=null,me}function j(me,ue,ye){return me.index=ye,u?(ye=me.alternate,ye!==null?(ye=ye.index,ye<ue?(me.flags|=2,ue):ye):(me.flags|=2,ue)):(me.flags|=1048576,ue)}function X(me){return u&&me.alternate===null&&(me.flags|=2),me}function ne(me,ue,ye,Ze){return ue===null||ue.tag!==6?(ue=NC(ye,me.mode,Ze),ue.return=me,ue):(ue=L(ue,ye),ue.return=me,ue)}function ae(me,ue,ye,Ze){var kt=ye.type;return kt===A?Ge(me,ue,ye.props.children,Ze,ye.key):ue!==null&&(ue.elementType===kt||typeof kt=="object"&&kt!==null&&kt.$$typeof===G&&l4(kt)===ue.type)?(Ze=L(ue,ye.props),Ze.ref=lh(me,ue,ye),Ze.return=me,Ze):(Ze=h_(ye.type,ye.key,ye.props,null,me.mode,Ze),Ze.ref=lh(me,ue,ye),Ze.return=me,Ze)}function we(me,ue,ye,Ze){return ue===null||ue.tag!==4||ue.stateNode.containerInfo!==ye.containerInfo||ue.stateNode.implementation!==ye.implementation?(ue=OC(ye,me.mode,Ze),ue.return=me,ue):(ue=L(ue,ye.children||[]),ue.return=me,ue)}function Ge(me,ue,ye,Ze,kt){return ue===null||ue.tag!==7?(ue=Sc(ye,me.mode,Ze,kt),ue.return=me,ue):(ue=L(ue,ye),ue.return=me,ue)}function Ke(me,ue,ye){if(typeof ue=="string"&&ue!==""||typeof ue=="number")return ue=NC(""+ue,me.mode,ye),ue.return=me,ue;if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case R:return ye=h_(ue.type,ue.key,ue.props,null,me.mode,ye),ye.ref=lh(me,null,ue),ye.return=me,ye;case I:return ue=OC(ue,me.mode,ye),ue.return=me,ue;case G:var Ze=ue._init;return Ke(me,Ze(ue._payload),ye)}if(Oe(ue)||B(ue))return ue=Sc(ue,me.mode,ye,null),ue.return=me,ue;Kg(me,ue)}return null}function He(me,ue,ye,Ze){var kt=ue!==null?ue.key:null;if(typeof ye=="string"&&ye!==""||typeof ye=="number")return kt!==null?null:ne(me,ue,""+ye,Ze);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case R:return ye.key===kt?ae(me,ue,ye,Ze):null;case I:return ye.key===kt?we(me,ue,ye,Ze):null;case G:return kt=ye._init,He(me,ue,kt(ye._payload),Ze)}if(Oe(ye)||B(ye))return kt!==null?null:Ge(me,ue,ye,Ze,null);Kg(me,ye)}return null}function _t(me,ue,ye,Ze,kt){if(typeof Ze=="string"&&Ze!==""||typeof Ze=="number")return me=me.get(ye)||null,ne(ue,me,""+Ze,kt);if(typeof Ze=="object"&&Ze!==null){switch(Ze.$$typeof){case R:return me=me.get(Ze.key===null?ye:Ze.key)||null,ae(ue,me,Ze,kt);case I:return me=me.get(Ze.key===null?ye:Ze.key)||null,we(ue,me,Ze,kt);case G:var qt=Ze._init;return _t(me,ue,ye,qt(Ze._payload),kt)}if(Oe(Ze)||B(Ze))return me=me.get(ye)||null,Ge(ue,me,Ze,kt,null);Kg(ue,Ze)}return null}function Tt(me,ue,ye,Ze){for(var kt=null,qt=null,Ht=ue,Jt=ue=0,rs=null;Ht!==null&&Jt<ye.length;Jt++){Ht.index>Jt?(rs=Ht,Ht=null):rs=Ht.sibling;var Rn=He(me,Ht,ye[Jt],Ze);if(Rn===null){Ht===null&&(Ht=rs);break}u&&Ht&&Rn.alternate===null&&h(me,Ht),ue=j(Rn,ue,Jt),qt===null?kt=Rn:qt.sibling=Rn,qt=Rn,Ht=rs}if(Jt===ye.length)return x(me,Ht),ur&&pc(me,Jt),kt;if(Ht===null){for(;Jt<ye.length;Jt++)Ht=Ke(me,ye[Jt],Ze),Ht!==null&&(ue=j(Ht,ue,Jt),qt===null?kt=Ht:qt.sibling=Ht,qt=Ht);return ur&&pc(me,Jt),kt}for(Ht=w(me,Ht);Jt<ye.length;Jt++)rs=_t(Ht,me,Jt,ye[Jt],Ze),rs!==null&&(u&&rs.alternate!==null&&Ht.delete(rs.key===null?Jt:rs.key),ue=j(rs,ue,Jt),qt===null?kt=rs:qt.sibling=rs,qt=rs);return u&&Ht.forEach(function(ml){return h(me,ml)}),ur&&pc(me,Jt),kt}function Rt(me,ue,ye,Ze){var kt=B(ye);if(typeof kt!="function")throw Error(t(150));if(ye=kt.call(ye),ye==null)throw Error(t(151));for(var qt=kt=null,Ht=ue,Jt=ue=0,rs=null,Rn=ye.next();Ht!==null&&!Rn.done;Jt++,Rn=ye.next()){Ht.index>Jt?(rs=Ht,Ht=null):rs=Ht.sibling;var ml=He(me,Ht,Rn.value,Ze);if(ml===null){Ht===null&&(Ht=rs);break}u&&Ht&&ml.alternate===null&&h(me,Ht),ue=j(ml,ue,Jt),qt===null?kt=ml:qt.sibling=ml,qt=ml,Ht=rs}if(Rn.done)return x(me,Ht),ur&&pc(me,Jt),kt;if(Ht===null){for(;!Rn.done;Jt++,Rn=ye.next())Rn=Ke(me,Rn.value,Ze),Rn!==null&&(ue=j(Rn,ue,Jt),qt===null?kt=Rn:qt.sibling=Rn,qt=Rn);return ur&&pc(me,Jt),kt}for(Ht=w(me,Ht);!Rn.done;Jt++,Rn=ye.next())Rn=_t(Ht,me,Jt,Rn.value,Ze),Rn!==null&&(u&&Rn.alternate!==null&&Ht.delete(Rn.key===null?Jt:Rn.key),ue=j(Rn,ue,Jt),qt===null?kt=Rn:qt.sibling=Rn,qt=Rn);return u&&Ht.forEach(function(ede){return h(me,ede)}),ur&&pc(me,Jt),kt}function Lr(me,ue,ye,Ze){if(typeof ye=="object"&&ye!==null&&ye.type===A&&ye.key===null&&(ye=ye.props.children),typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case R:e:{for(var kt=ye.key,qt=ue;qt!==null;){if(qt.key===kt){if(kt=ye.type,kt===A){if(qt.tag===7){x(me,qt.sibling),ue=L(qt,ye.props.children),ue.return=me,me=ue;break e}}else if(qt.elementType===kt||typeof kt=="object"&&kt!==null&&kt.$$typeof===G&&l4(kt)===qt.type){x(me,qt.sibling),ue=L(qt,ye.props),ue.ref=lh(me,qt,ye),ue.return=me,me=ue;break e}x(me,qt);break}else h(me,qt);qt=qt.sibling}ye.type===A?(ue=Sc(ye.props.children,me.mode,Ze,ye.key),ue.return=me,me=ue):(Ze=h_(ye.type,ye.key,ye.props,null,me.mode,Ze),Ze.ref=lh(me,ue,ye),Ze.return=me,me=Ze)}return X(me);case I:e:{for(qt=ye.key;ue!==null;){if(ue.key===qt)if(ue.tag===4&&ue.stateNode.containerInfo===ye.containerInfo&&ue.stateNode.implementation===ye.implementation){x(me,ue.sibling),ue=L(ue,ye.children||[]),ue.return=me,me=ue;break e}else{x(me,ue);break}else h(me,ue);ue=ue.sibling}ue=OC(ye,me.mode,Ze),ue.return=me,me=ue}return X(me);case G:return qt=ye._init,Lr(me,ue,qt(ye._payload),Ze)}if(Oe(ye))return Tt(me,ue,ye,Ze);if(B(ye))return Rt(me,ue,ye,Ze);Kg(me,ye)}return typeof ye=="string"&&ye!==""||typeof ye=="number"?(ye=""+ye,ue!==null&&ue.tag===6?(x(me,ue.sibling),ue=L(ue,ye),ue.return=me,me=ue):(x(me,ue),ue=NC(ye,me.mode,Ze),ue.return=me,me=ue),X(me)):x(me,ue)}return Lr}var Bu=c4(!0),u4=c4(!1),ch={},zo=sl(ch),uh=sl(ch),dh=sl(ch);function gc(u){if(u===ch)throw Error(t(174));return u}function Q1(u,h){switch(Zn(dh,h),Zn(uh,u),Zn(zo,ch),u=h.nodeType,u){case 9:case 11:h=(h=h.documentElement)?h.namespaceURI:nt(null,"");break;default:u=u===8?h.parentNode:h,h=u.namespaceURI||null,u=u.tagName,h=nt(h,u)}or(zo),Zn(zo,h)}function $u(){or(zo),or(uh),or(dh)}function d4(u){gc(dh.current);var h=gc(zo.current),x=nt(h,u.type);h!==x&&(Zn(uh,u),Zn(zo,x))}function J1(u){uh.current===u&&(or(zo),or(uh))}var _r=sl(0);function Yg(u){for(var h=u;h!==null;){if(h.tag===13){var x=h.memoizedState;if(x!==null&&(x=x.dehydrated,x===null||x.data==="$?"||x.data==="$!"))return h}else if(h.tag===19&&h.memoizedProps.revealOrder!==void 0){if((h.flags&128)!==0)return h}else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===u)break;for(;h.sibling===null;){if(h.return===null||h.return===u)return null;h=h.return}h.sibling.return=h.return,h=h.sibling}return null}var Z1=[];function eC(){for(var u=0;u<Z1.length;u++)Z1[u]._workInProgressVersionPrimary=null;Z1.length=0}var Xg=C.ReactCurrentDispatcher,tC=C.ReactCurrentBatchConfig,_c=0,vr=null,qr=null,ts=null,Qg=!1,fh=!1,hh=0,Sue=0;function Cs(){throw Error(t(321))}function nC(u,h){if(h===null)return!1;for(var x=0;x<h.length&&x<u.length;x++)if(!ao(u[x],h[x]))return!1;return!0}function rC(u,h,x,w,L,j){if(_c=j,vr=h,h.memoizedState=null,h.updateQueue=null,h.lanes=0,Xg.current=u===null||u.memoizedState===null?Cue:Iue,u=x(w,L),fh){j=0;do{if(fh=!1,hh=0,25<=j)throw Error(t(301));j+=1,ts=qr=null,h.updateQueue=null,Xg.current=Rue,u=x(w,L)}while(fh)}if(Xg.current=e_,h=qr!==null&&qr.next!==null,_c=0,ts=qr=vr=null,Qg=!1,h)throw Error(t(300));return u}function sC(){var u=hh!==0;return hh=0,u}function qo(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ts===null?vr.memoizedState=ts=u:ts=ts.next=u,ts}function ji(){if(qr===null){var u=vr.alternate;u=u!==null?u.memoizedState:null}else u=qr.next;var h=ts===null?vr.memoizedState:ts.next;if(h!==null)ts=h,qr=u;else{if(u===null)throw Error(t(310));qr=u,u={memoizedState:qr.memoizedState,baseState:qr.baseState,baseQueue:qr.baseQueue,queue:qr.queue,next:null},ts===null?vr.memoizedState=ts=u:ts=ts.next=u}return ts}function ph(u,h){return typeof h=="function"?h(u):h}function iC(u){var h=ji(),x=h.queue;if(x===null)throw Error(t(311));x.lastRenderedReducer=u;var w=qr,L=w.baseQueue,j=x.pending;if(j!==null){if(L!==null){var X=L.next;L.next=j.next,j.next=X}w.baseQueue=L=j,x.pending=null}if(L!==null){j=L.next,w=w.baseState;var ne=X=null,ae=null,we=j;do{var Ge=we.lane;if((_c&Ge)===Ge)ae!==null&&(ae=ae.next={lane:0,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null}),w=we.hasEagerState?we.eagerState:u(w,we.action);else{var Ke={lane:Ge,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null};ae===null?(ne=ae=Ke,X=w):ae=ae.next=Ke,vr.lanes|=Ge,vc|=Ge}we=we.next}while(we!==null&&we!==j);ae===null?X=w:ae.next=ne,ao(w,h.memoizedState)||(Zs=!0),h.memoizedState=w,h.baseState=X,h.baseQueue=ae,x.lastRenderedState=w}if(u=x.interleaved,u!==null){L=u;do j=L.lane,vr.lanes|=j,vc|=j,L=L.next;while(L!==u)}else L===null&&(x.lanes=0);return[h.memoizedState,x.dispatch]}function oC(u){var h=ji(),x=h.queue;if(x===null)throw Error(t(311));x.lastRenderedReducer=u;var w=x.dispatch,L=x.pending,j=h.memoizedState;if(L!==null){x.pending=null;var X=L=L.next;do j=u(j,X.action),X=X.next;while(X!==L);ao(j,h.memoizedState)||(Zs=!0),h.memoizedState=j,h.baseQueue===null&&(h.baseState=j),x.lastRenderedState=j}return[j,w]}function f4(){}function h4(u,h){var x=vr,w=ji(),L=h(),j=!ao(w.memoizedState,L);if(j&&(w.memoizedState=L,Zs=!0),w=w.queue,aC(g4.bind(null,x,w,u),[u]),w.getSnapshot!==h||j||ts!==null&&ts.memoizedState.tag&1){if(x.flags|=2048,mh(9,m4.bind(null,x,w,L,h),void 0,null),ns===null)throw Error(t(349));(_c&30)!==0||p4(x,h,L)}return L}function p4(u,h,x){u.flags|=16384,u={getSnapshot:h,value:x},h=vr.updateQueue,h===null?(h={lastEffect:null,stores:null},vr.updateQueue=h,h.stores=[u]):(x=h.stores,x===null?h.stores=[u]:x.push(u))}function m4(u,h,x,w){h.value=x,h.getSnapshot=w,_4(h)&&v4(u)}function g4(u,h,x){return x(function(){_4(h)&&v4(u)})}function _4(u){var h=u.getSnapshot;u=u.value;try{var x=h();return!ao(u,x)}catch{return!0}}function v4(u){var h=ma(u,1);h!==null&&ho(h,u,1,-1)}function y4(u){var h=qo();return typeof u=="function"&&(u=u()),h.memoizedState=h.baseState=u,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ph,lastRenderedState:u},h.queue=u,u=u.dispatch=Tue.bind(null,vr,u),[h.memoizedState,u]}function mh(u,h,x,w){return u={tag:u,create:h,destroy:x,deps:w,next:null},h=vr.updateQueue,h===null?(h={lastEffect:null,stores:null},vr.updateQueue=h,h.lastEffect=u.next=u):(x=h.lastEffect,x===null?h.lastEffect=u.next=u:(w=x.next,x.next=u,u.next=w,h.lastEffect=u)),u}function b4(){return ji().memoizedState}function Jg(u,h,x,w){var L=qo();vr.flags|=u,L.memoizedState=mh(1|h,x,void 0,w===void 0?null:w)}function Zg(u,h,x,w){var L=ji();w=w===void 0?null:w;var j=void 0;if(qr!==null){var X=qr.memoizedState;if(j=X.destroy,w!==null&&nC(w,X.deps)){L.memoizedState=mh(h,x,j,w);return}}vr.flags|=u,L.memoizedState=mh(1|h,x,j,w)}function x4(u,h){return Jg(8390656,8,u,h)}function aC(u,h){return Zg(2048,8,u,h)}function S4(u,h){return Zg(4,2,u,h)}function E4(u,h){return Zg(4,4,u,h)}function w4(u,h){if(typeof h=="function")return u=u(),h(u),function(){h(null)};if(h!=null)return u=u(),h.current=u,function(){h.current=null}}function T4(u,h,x){return x=x!=null?x.concat([u]):null,Zg(4,4,w4.bind(null,h,u),x)}function lC(){}function C4(u,h){var x=ji();h=h===void 0?null:h;var w=x.memoizedState;return w!==null&&h!==null&&nC(h,w[1])?w[0]:(x.memoizedState=[u,h],u)}function I4(u,h){var x=ji();h=h===void 0?null:h;var w=x.memoizedState;return w!==null&&h!==null&&nC(h,w[1])?w[0]:(u=u(),x.memoizedState=[u,h],u)}function R4(u,h,x){return(_c&21)===0?(u.baseState&&(u.baseState=!1,Zs=!0),u.memoizedState=x):(ao(x,h)||(x=wu(),vr.lanes|=x,vc|=x,u.baseState=!0),h)}function Eue(u,h){var x=Fn;Fn=x!==0&&4>x?x:4,u(!0);var w=tC.transition;tC.transition={};try{u(!1),h()}finally{Fn=x,tC.transition=w}}function A4(){return ji().memoizedState}function wue(u,h,x){var w=fl(u);if(x={lane:w,action:x,hasEagerState:!1,eagerState:null,next:null},k4(u))L4(h,x);else if(x=e4(u,h,x,w),x!==null){var L=Bs();ho(x,u,w,L),M4(x,h,w)}}function Tue(u,h,x){var w=fl(u),L={lane:w,action:x,hasEagerState:!1,eagerState:null,next:null};if(k4(u))L4(h,L);else{var j=u.alternate;if(u.lanes===0&&(j===null||j.lanes===0)&&(j=h.lastRenderedReducer,j!==null))try{var X=h.lastRenderedState,ne=j(X,x);if(L.hasEagerState=!0,L.eagerState=ne,ao(ne,X)){var ae=h.interleaved;ae===null?(L.next=L,W1(h)):(L.next=ae.next,ae.next=L),h.interleaved=L;return}}catch{}finally{}x=e4(u,h,L,w),x!==null&&(L=Bs(),ho(x,u,w,L),M4(x,h,w))}}function k4(u){var h=u.alternate;return u===vr||h!==null&&h===vr}function L4(u,h){fh=Qg=!0;var x=u.pending;x===null?h.next=h:(h.next=x.next,x.next=h),u.pending=h}function M4(u,h,x){if((x&4194240)!==0){var w=h.lanes;w&=u.pendingLanes,x|=w,h.lanes=x,l1(u,x)}}var e_={readContext:Di,useCallback:Cs,useContext:Cs,useEffect:Cs,useImperativeHandle:Cs,useInsertionEffect:Cs,useLayoutEffect:Cs,useMemo:Cs,useReducer:Cs,useRef:Cs,useState:Cs,useDebugValue:Cs,useDeferredValue:Cs,useTransition:Cs,useMutableSource:Cs,useSyncExternalStore:Cs,useId:Cs,unstable_isNewReconciler:!1},Cue={readContext:Di,useCallback:function(u,h){return qo().memoizedState=[u,h===void 0?null:h],u},useContext:Di,useEffect:x4,useImperativeHandle:function(u,h,x){return x=x!=null?x.concat([u]):null,Jg(4194308,4,w4.bind(null,h,u),x)},useLayoutEffect:function(u,h){return Jg(4194308,4,u,h)},useInsertionEffect:function(u,h){return Jg(4,2,u,h)},useMemo:function(u,h){var x=qo();return h=h===void 0?null:h,u=u(),x.memoizedState=[u,h],u},useReducer:function(u,h,x){var w=qo();return h=x!==void 0?x(h):h,w.memoizedState=w.baseState=h,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:h},w.queue=u,u=u.dispatch=wue.bind(null,vr,u),[w.memoizedState,u]},useRef:function(u){var h=qo();return u={current:u},h.memoizedState=u},useState:y4,useDebugValue:lC,useDeferredValue:function(u){return qo().memoizedState=u},useTransition:function(){var u=y4(!1),h=u[0];return u=Eue.bind(null,u[1]),qo().memoizedState=u,[h,u]},useMutableSource:function(){},useSyncExternalStore:function(u,h,x){var w=vr,L=qo();if(ur){if(x===void 0)throw Error(t(407));x=x()}else{if(x=h(),ns===null)throw Error(t(349));(_c&30)!==0||p4(w,h,x)}L.memoizedState=x;var j={value:x,getSnapshot:h};return L.queue=j,x4(g4.bind(null,w,j,u),[u]),w.flags|=2048,mh(9,m4.bind(null,w,j,x,h),void 0,null),x},useId:function(){var u=qo(),h=ns.identifierPrefix;if(ur){var x=pa,w=ha;x=(w&~(1<<32-ze(w)-1)).toString(32)+x,h=":"+h+"R"+x,x=hh++,0<x&&(h+="H"+x.toString(32)),h+=":"}else x=Sue++,h=":"+h+"r"+x.toString(32)+":";return u.memoizedState=h},unstable_isNewReconciler:!1},Iue={readContext:Di,useCallback:C4,useContext:Di,useEffect:aC,useImperativeHandle:T4,useInsertionEffect:S4,useLayoutEffect:E4,useMemo:I4,useReducer:iC,useRef:b4,useState:function(){return iC(ph)},useDebugValue:lC,useDeferredValue:function(u){var h=ji();return R4(h,qr.memoizedState,u)},useTransition:function(){var u=iC(ph)[0],h=ji().memoizedState;return[u,h]},useMutableSource:f4,useSyncExternalStore:h4,useId:A4,unstable_isNewReconciler:!1},Rue={readContext:Di,useCallback:C4,useContext:Di,useEffect:aC,useImperativeHandle:T4,useInsertionEffect:S4,useLayoutEffect:E4,useMemo:I4,useReducer:oC,useRef:b4,useState:function(){return oC(ph)},useDebugValue:lC,useDeferredValue:function(u){var h=ji();return qr===null?h.memoizedState=u:R4(h,qr.memoizedState,u)},useTransition:function(){var u=oC(ph)[0],h=ji().memoizedState;return[u,h]},useMutableSource:f4,useSyncExternalStore:h4,useId:A4,unstable_isNewReconciler:!1};function zu(u,h){try{var x="",w=h;do x+=ee(w),w=w.return;while(w);var L=x}catch(j){L=`
56 Error generating stack: `+j.message+`
57 `+j.stack}return{value:u,source:h,stack:L,digest:null}}function cC(u,h,x){return{value:u,source:null,stack:x??null,digest:h??null}}function uC(u,h){try{console.error(h.value)}catch(x){setTimeout(function(){throw x})}}var Aue=typeof WeakMap=="function"?WeakMap:Map;function N4(u,h,x){x=ga(-1,x),x.tag=3,x.payload={element:null};var w=h.value;return x.callback=function(){a_||(a_=!0,TC=w),uC(u,h)},x}function O4(u,h,x){x=ga(-1,x),x.tag=3;var w=u.type.getDerivedStateFromError;if(typeof w=="function"){var L=h.value;x.payload=function(){return w(L)},x.callback=function(){uC(u,h)}}var j=u.stateNode;return j!==null&&typeof j.componentDidCatch=="function"&&(x.callback=function(){uC(u,h),typeof w!="function"&&(ul===null?ul=new Set([this]):ul.add(this));var X=h.stack;this.componentDidCatch(h.value,{componentStack:X!==null?X:""})}),x}function P4(u,h,x){var w=u.pingCache;if(w===null){w=u.pingCache=new Aue;var L=new Set;w.set(h,L)}else L=w.get(h),L===void 0&&(L=new Set,w.set(h,L));L.has(x)||(L.add(x),u=que.bind(null,u,h,x),h.then(u,u))}function D4(u){do{var h;if((h=u.tag===13)&&(h=u.memoizedState,h=h!==null?h.dehydrated!==null:!0),h)return u;u=u.return}while(u!==null);return null}function j4(u,h,x,w,L){return(u.mode&1)===0?(u===h?u.flags|=65536:(u.flags|=128,x.flags|=131072,x.flags&=-52805,x.tag===1&&(x.alternate===null?x.tag=17:(h=ga(-1,1),h.tag=2,ll(x,h,1))),x.lanes|=1),u):(u.flags|=65536,u.lanes=L,u)}var kue=C.ReactCurrentOwner,Zs=!1;function Us(u,h,x,w){h.child=u===null?u4(h,null,x,w):Bu(h,u.child,x,w)}function F4(u,h,x,w,L){x=x.render;var j=h.ref;return Uu(h,L),w=rC(u,h,x,w,j,L),x=sC(),u!==null&&!Zs?(h.updateQueue=u.updateQueue,h.flags&=-2053,u.lanes&=~L,_a(u,h,L)):(ur&&x&&F1(h),h.flags|=1,Us(u,h,w,L),h.child)}function U4(u,h,x,w,L){if(u===null){var j=x.type;return typeof j=="function"&&!MC(j)&&j.defaultProps===void 0&&x.compare===null&&x.defaultProps===void 0?(h.tag=15,h.type=j,B4(u,h,j,w,L)):(u=h_(x.type,null,w,h,h.mode,L),u.ref=h.ref,u.return=h,h.child=u)}if(j=u.child,(u.lanes&L)===0){var X=j.memoizedProps;if(x=x.compare,x=x!==null?x:th,x(X,w)&&u.ref===h.ref)return _a(u,h,L)}return h.flags|=1,u=pl(j,w),u.ref=h.ref,u.return=h,h.child=u}function B4(u,h,x,w,L){if(u!==null){var j=u.memoizedProps;if(th(j,w)&&u.ref===h.ref)if(Zs=!1,h.pendingProps=w=j,(u.lanes&L)!==0)(u.flags&131072)!==0&&(Zs=!0);else return h.lanes=u.lanes,_a(u,h,L)}return dC(u,h,x,w,L)}function $4(u,h,x){var w=h.pendingProps,L=w.children,j=u!==null?u.memoizedState:null;if(w.mode==="hidden")if((h.mode&1)===0)h.memoizedState={baseLanes:0,cachePool:null,transitions:null},Zn(Hu,gi),gi|=x;else{if((x&1073741824)===0)return u=j!==null?j.baseLanes|x:x,h.lanes=h.childLanes=1073741824,h.memoizedState={baseLanes:u,cachePool:null,transitions:null},h.updateQueue=null,Zn(Hu,gi),gi|=u,null;h.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=j!==null?j.baseLanes:x,Zn(Hu,gi),gi|=w}else j!==null?(w=j.baseLanes|x,h.memoizedState=null):w=x,Zn(Hu,gi),gi|=w;return Us(u,h,L,x),h.child}function z4(u,h){var x=h.ref;(u===null&&x!==null||u!==null&&u.ref!==x)&&(h.flags|=512,h.flags|=2097152)}function dC(u,h,x,w,L){var j=Js(x)?fc:Ts.current;return j=Ou(h,j),Uu(h,L),x=rC(u,h,x,w,j,L),w=sC(),u!==null&&!Zs?(h.updateQueue=u.updateQueue,h.flags&=-2053,u.lanes&=~L,_a(u,h,L)):(ur&&w&&F1(h),h.flags|=1,Us(u,h,x,L),h.child)}function q4(u,h,x,w,L){if(Js(x)){var j=!0;Fg(h)}else j=!1;if(Uu(h,L),h.stateNode===null)n_(u,h),o4(h,x,w),X1(h,x,w,L),w=!0;else if(u===null){var X=h.stateNode,ne=h.memoizedProps;X.props=ne;var ae=X.context,we=x.contextType;typeof we=="object"&&we!==null?we=Di(we):(we=Js(x)?fc:Ts.current,we=Ou(h,we));var Ge=x.getDerivedStateFromProps,Ke=typeof Ge=="function"||typeof X.getSnapshotBeforeUpdate=="function";Ke||typeof X.UNSAFE_componentWillReceiveProps!="function"&&typeof X.componentWillReceiveProps!="function"||(ne!==w||ae!==we)&&a4(h,X,w,we),al=!1;var He=h.memoizedState;X.state=He,Vg(h,w,X,L),ae=h.memoizedState,ne!==w||He!==ae||Qs.current||al?(typeof Ge=="function"&&(Y1(h,x,Ge,w),ae=h.memoizedState),(ne=al||i4(h,x,ne,w,He,ae,we))?(Ke||typeof X.UNSAFE_componentWillMount!="function"&&typeof X.componentWillMount!="function"||(typeof X.componentWillMount=="function"&&X.componentWillMount(),typeof X.UNSAFE_componentWillMount=="function"&&X.UNSAFE_componentWillMount()),typeof X.componentDidMount=="function"&&(h.flags|=4194308)):(typeof X.componentDidMount=="function"&&(h.flags|=4194308),h.memoizedProps=w,h.memoizedState=ae),X.props=w,X.state=ae,X.context=we,w=ne):(typeof X.componentDidMount=="function"&&(h.flags|=4194308),w=!1)}else{X=h.stateNode,t4(u,h),ne=h.memoizedProps,we=h.type===h.elementType?ne:co(h.type,ne),X.props=we,Ke=h.pendingProps,He=X.context,ae=x.contextType,typeof ae=="object"&&ae!==null?ae=Di(ae):(ae=Js(x)?fc:Ts.current,ae=Ou(h,ae));var _t=x.getDerivedStateFromProps;(Ge=typeof _t=="function"||typeof X.getSnapshotBeforeUpdate=="function")||typeof X.UNSAFE_componentWillReceiveProps!="function"&&typeof X.componentWillReceiveProps!="function"||(ne!==Ke||He!==ae)&&a4(h,X,w,ae),al=!1,He=h.memoizedState,X.state=He,Vg(h,w,X,L);var Tt=h.memoizedState;ne!==Ke||He!==Tt||Qs.current||al?(typeof _t=="function"&&(Y1(h,x,_t,w),Tt=h.memoizedState),(we=al||i4(h,x,we,w,He,Tt,ae)||!1)?(Ge||typeof X.UNSAFE_componentWillUpdate!="function"&&typeof X.componentWillUpdate!="function"||(typeof X.componentWillUpdate=="function"&&X.componentWillUpdate(w,Tt,ae),typeof X.UNSAFE_componentWillUpdate=="function"&&X.UNSAFE_componentWillUpdate(w,Tt,ae)),typeof X.componentDidUpdate=="function"&&(h.flags|=4),typeof X.getSnapshotBeforeUpdate=="function"&&(h.flags|=1024)):(typeof X.componentDidUpdate!="function"||ne===u.memoizedProps&&He===u.memoizedState||(h.flags|=4),typeof X.getSnapshotBeforeUpdate!="function"||ne===u.memoizedProps&&He===u.memoizedState||(h.flags|=1024),h.memoizedProps=w,h.memoizedState=Tt),X.props=w,X.state=Tt,X.context=ae,w=we):(typeof X.componentDidUpdate!="function"||ne===u.memoizedProps&&He===u.memoizedState||(h.flags|=4),typeof X.getSnapshotBeforeUpdate!="function"||ne===u.memoizedProps&&He===u.memoizedState||(h.flags|=1024),w=!1)}return fC(u,h,x,w,j,L)}function fC(u,h,x,w,L,j){z4(u,h);var X=(h.flags&128)!==0;if(!w&&!X)return L&&W3(h,x,!1),_a(u,h,j);w=h.stateNode,kue.current=h;var ne=X&&typeof x.getDerivedStateFromError!="function"?null:w.render();return h.flags|=1,u!==null&&X?(h.child=Bu(h,u.child,null,j),h.child=Bu(h,null,ne,j)):Us(u,h,ne,j),h.memoizedState=w.state,L&&W3(h,x,!0),h.child}function H4(u){var h=u.stateNode;h.pendingContext?G3(u,h.pendingContext,h.pendingContext!==h.context):h.context&&G3(u,h.context,!1),Q1(u,h.containerInfo)}function G4(u,h,x,w,L){return ju(),z1(L),h.flags|=256,Us(u,h,x,w),h.child}var hC={dehydrated:null,treeContext:null,retryLane:0};function pC(u){return{baseLanes:u,cachePool:null,transitions:null}}function V4(u,h,x){var w=h.pendingProps,L=_r.current,j=!1,X=(h.flags&128)!==0,ne;if((ne=X)||(ne=u!==null&&u.memoizedState===null?!1:(L&2)!==0),ne?(j=!0,h.flags&=-129):(u===null||u.memoizedState!==null)&&(L|=1),Zn(_r,L&1),u===null)return $1(h),u=h.memoizedState,u!==null&&(u=u.dehydrated,u!==null)?((h.mode&1)===0?h.lanes=1:u.data==="$!"?h.lanes=8:h.lanes=1073741824,null):(X=w.children,u=w.fallback,j?(w=h.mode,j=h.child,X={mode:"hidden",children:X},(w&1)===0&&j!==null?(j.childLanes=0,j.pendingProps=X):j=p_(X,w,0,null),u=Sc(u,w,x,null),j.return=h,u.return=h,j.sibling=u,h.child=j,h.child.memoizedState=pC(x),h.memoizedState=hC,u):mC(h,X));if(L=u.memoizedState,L!==null&&(ne=L.dehydrated,ne!==null))return Lue(u,h,X,w,ne,L,x);if(j){j=w.fallback,X=h.mode,L=u.child,ne=L.sibling;var ae={mode:"hidden",children:w.children};return(X&1)===0&&h.child!==L?(w=h.child,w.childLanes=0,w.pendingProps=ae,h.deletions=null):(w=pl(L,ae),w.subtreeFlags=L.subtreeFlags&14680064),ne!==null?j=pl(ne,j):(j=Sc(j,X,x,null),j.flags|=2),j.return=h,w.return=h,w.sibling=j,h.child=w,w=j,j=h.child,X=u.child.memoizedState,X=X===null?pC(x):{baseLanes:X.baseLanes|x,cachePool:null,transitions:X.transitions},j.memoizedState=X,j.childLanes=u.childLanes&~x,h.memoizedState=hC,w}return j=u.child,u=j.sibling,w=pl(j,{mode:"visible",children:w.children}),(h.mode&1)===0&&(w.lanes=x),w.return=h,w.sibling=null,u!==null&&(x=h.deletions,x===null?(h.deletions=[u],h.flags|=16):x.push(u)),h.child=w,h.memoizedState=null,w}function mC(u,h){return h=p_({mode:"visible",children:h},u.mode,0,null),h.return=u,u.child=h}function t_(u,h,x,w){return w!==null&&z1(w),Bu(h,u.child,null,x),u=mC(h,h.pendingProps.children),u.flags|=2,h.memoizedState=null,u}function Lue(u,h,x,w,L,j,X){if(x)return h.flags&256?(h.flags&=-257,w=cC(Error(t(422))),t_(u,h,X,w)):h.memoizedState!==null?(h.child=u.child,h.flags|=128,null):(j=w.fallback,L=h.mode,w=p_({mode:"visible",children:w.children},L,0,null),j=Sc(j,L,X,null),j.flags|=2,w.return=h,j.return=h,w.sibling=j,h.child=w,(h.mode&1)!==0&&Bu(h,u.child,null,X),h.child.memoizedState=pC(X),h.memoizedState=hC,j);if((h.mode&1)===0)return t_(u,h,X,null);if(L.data==="$!"){if(w=L.nextSibling&&L.nextSibling.dataset,w)var ne=w.dgst;return w=ne,j=Error(t(419)),w=cC(j,w,void 0),t_(u,h,X,w)}if(ne=(X&u.childLanes)!==0,Zs||ne){if(w=ns,w!==null){switch(X&-X){case 4:L=2;break;case 16:L=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:L=32;break;case 536870912:L=268435456;break;default:L=0}L=(L&(w.suspendedLanes|X))!==0?0:L,L!==0&&L!==j.retryLane&&(j.retryLane=L,ma(u,L),ho(w,u,L,-1))}return LC(),w=cC(Error(t(421))),t_(u,h,X,w)}return L.data==="$?"?(h.flags|=128,h.child=u.child,h=Hue.bind(null,u),L._reactRetry=h,null):(u=j.treeContext,mi=rl(L.nextSibling),pi=h,ur=!0,lo=null,u!==null&&(Oi[Pi++]=ha,Oi[Pi++]=pa,Oi[Pi++]=hc,ha=u.id,pa=u.overflow,hc=h),h=mC(h,w.children),h.flags|=4096,h)}function W4(u,h,x){u.lanes|=h;var w=u.alternate;w!==null&&(w.lanes|=h),V1(u.return,h,x)}function gC(u,h,x,w,L){var j=u.memoizedState;j===null?u.memoizedState={isBackwards:h,rendering:null,renderingStartTime:0,last:w,tail:x,tailMode:L}:(j.isBackwards=h,j.rendering=null,j.renderingStartTime=0,j.last=w,j.tail=x,j.tailMode=L)}function K4(u,h,x){var w=h.pendingProps,L=w.revealOrder,j=w.tail;if(Us(u,h,w.children,x),w=_r.current,(w&2)!==0)w=w&1|2,h.flags|=128;else{if(u!==null&&(u.flags&128)!==0)e:for(u=h.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&W4(u,x,h);else if(u.tag===19)W4(u,x,h);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===h)break e;for(;u.sibling===null;){if(u.return===null||u.return===h)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}w&=1}if(Zn(_r,w),(h.mode&1)===0)h.memoizedState=null;else switch(L){case"forwards":for(x=h.child,L=null;x!==null;)u=x.alternate,u!==null&&Yg(u)===null&&(L=x),x=x.sibling;x=L,x===null?(L=h.child,h.child=null):(L=x.sibling,x.sibling=null),gC(h,!1,L,x,j);break;case"backwards":for(x=null,L=h.child,h.child=null;L!==null;){if(u=L.alternate,u!==null&&Yg(u)===null){h.child=L;break}u=L.sibling,L.sibling=x,x=L,L=u}gC(h,!0,x,null,j);break;case"together":gC(h,!1,null,null,void 0);break;default:h.memoizedState=null}return h.child}function n_(u,h){(h.mode&1)===0&&u!==null&&(u.alternate=null,h.alternate=null,h.flags|=2)}function _a(u,h,x){if(u!==null&&(h.dependencies=u.dependencies),vc|=h.lanes,(x&h.childLanes)===0)return null;if(u!==null&&h.child!==u.child)throw Error(t(153));if(h.child!==null){for(u=h.child,x=pl(u,u.pendingProps),h.child=x,x.return=h;u.sibling!==null;)u=u.sibling,x=x.sibling=pl(u,u.pendingProps),x.return=h;x.sibling=null}return h.child}function Mue(u,h,x){switch(h.tag){case 3:H4(h),ju();break;case 5:d4(h);break;case 1:Js(h.type)&&Fg(h);break;case 4:Q1(h,h.stateNode.containerInfo);break;case 10:var w=h.type._context,L=h.memoizedProps.value;Zn(qg,w._currentValue),w._currentValue=L;break;case 13:if(w=h.memoizedState,w!==null)return w.dehydrated!==null?(Zn(_r,_r.current&1),h.flags|=128,null):(x&h.child.childLanes)!==0?V4(u,h,x):(Zn(_r,_r.current&1),u=_a(u,h,x),u!==null?u.sibling:null);Zn(_r,_r.current&1);break;case 19:if(w=(x&h.childLanes)!==0,(u.flags&128)!==0){if(w)return K4(u,h,x);h.flags|=128}if(L=h.memoizedState,L!==null&&(L.rendering=null,L.tail=null,L.lastEffect=null),Zn(_r,_r.current),w)break;return null;case 22:case 23:return h.lanes=0,$4(u,h,x)}return _a(u,h,x)}var Y4,_C,X4,Q4;Y4=function(u,h){for(var x=h.child;x!==null;){if(x.tag===5||x.tag===6)u.appendChild(x.stateNode);else if(x.tag!==4&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===h)break;for(;x.sibling===null;){if(x.return===null||x.return===h)return;x=x.return}x.sibling.return=x.return,x=x.sibling}},_C=function(){},X4=function(u,h,x,w){var L=u.memoizedProps;if(L!==w){u=h.stateNode,gc(zo.current);var j=null;switch(x){case"input":L=be(u,L),w=be(u,w),j=[];break;case"select":L=P({},L,{value:void 0}),w=P({},w,{value:void 0}),j=[];break;case"textarea":L=Xe(u,L),w=Xe(u,w),j=[];break;default:typeof L.onClick!="function"&&typeof w.onClick=="function"&&(u.onclick=Pg)}pt(x,w);var X;x=null;for(we in L)if(!w.hasOwnProperty(we)&&L.hasOwnProperty(we)&&L[we]!=null)if(we==="style"){var ne=L[we];for(X in ne)ne.hasOwnProperty(X)&&(x||(x={}),x[X]="")}else we!=="dangerouslySetInnerHTML"&&we!=="children"&&we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&we!=="autoFocus"&&(s.hasOwnProperty(we)?j||(j=[]):(j=j||[]).push(we,null));for(we in w){var ae=w[we];if(ne=L!=null?L[we]:void 0,w.hasOwnProperty(we)&&ae!==ne&&(ae!=null||ne!=null))if(we==="style")if(ne){for(X in ne)!ne.hasOwnProperty(X)||ae&&ae.hasOwnProperty(X)||(x||(x={}),x[X]="");for(X in ae)ae.hasOwnProperty(X)&&ne[X]!==ae[X]&&(x||(x={}),x[X]=ae[X])}else x||(j||(j=[]),j.push(we,x)),x=ae;else we==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,ne=ne?ne.__html:void 0,ae!=null&&ne!==ae&&(j=j||[]).push(we,ae)):we==="children"?typeof ae!="string"&&typeof ae!="number"||(j=j||[]).push(we,""+ae):we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&(s.hasOwnProperty(we)?(ae!=null&&we==="onScroll"&&ir("scroll",u),j||ne===ae||(j=[])):(j=j||[]).push(we,ae))}x&&(j=j||[]).push("style",x);var we=j;(h.updateQueue=we)&&(h.flags|=4)}},Q4=function(u,h,x,w){x!==w&&(h.flags|=4)};function gh(u,h){if(!ur)switch(u.tailMode){case"hidden":h=u.tail;for(var x=null;h!==null;)h.alternate!==null&&(x=h),h=h.sibling;x===null?u.tail=null:x.sibling=null;break;case"collapsed":x=u.tail;for(var w=null;x!==null;)x.alternate!==null&&(w=x),x=x.sibling;w===null?h||u.tail===null?u.tail=null:u.tail.sibling=null:w.sibling=null}}function Is(u){var h=u.alternate!==null&&u.alternate.child===u.child,x=0,w=0;if(h)for(var L=u.child;L!==null;)x|=L.lanes|L.childLanes,w|=L.subtreeFlags&14680064,w|=L.flags&14680064,L.return=u,L=L.sibling;else for(L=u.child;L!==null;)x|=L.lanes|L.childLanes,w|=L.subtreeFlags,w|=L.flags,L.return=u,L=L.sibling;return u.subtreeFlags|=w,u.childLanes=x,h}function Nue(u,h,x){var w=h.pendingProps;switch(U1(h),h.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Is(h),null;case 1:return Js(h.type)&&jg(),Is(h),null;case 3:return w=h.stateNode,$u(),or(Qs),or(Ts),eC(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(u===null||u.child===null)&&(zg(h)?h.flags|=4:u===null||u.memoizedState.isDehydrated&&(h.flags&256)===0||(h.flags|=1024,lo!==null&&(RC(lo),lo=null))),_C(u,h),Is(h),null;case 5:J1(h);var L=gc(dh.current);if(x=h.type,u!==null&&h.stateNode!=null)X4(u,h,x,w,L),u.ref!==h.ref&&(h.flags|=512,h.flags|=2097152);else{if(!w){if(h.stateNode===null)throw Error(t(166));return Is(h),null}if(u=gc(zo.current),zg(h)){w=h.stateNode,x=h.type;var j=h.memoizedProps;switch(w[$o]=h,w[oh]=j,u=(h.mode&1)!==0,x){case"dialog":ir("cancel",w),ir("close",w);break;case"iframe":case"object":case"embed":ir("load",w);break;case"video":case"audio":for(L=0;L<rh.length;L++)ir(rh[L],w);break;case"source":ir("error",w);break;case"img":case"image":case"link":ir("error",w),ir("load",w);break;case"details":ir("toggle",w);break;case"input":ge(w,j),ir("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!j.multiple},ir("invalid",w);break;case"textarea":Je(w,j),ir("invalid",w)}pt(x,j),L=null;for(var X in j)if(j.hasOwnProperty(X)){var ne=j[X];X==="children"?typeof ne=="string"?w.textContent!==ne&&(j.suppressHydrationWarning!==!0&&Og(w.textContent,ne,u),L=["children",ne]):typeof ne=="number"&&w.textContent!==""+ne&&(j.suppressHydrationWarning!==!0&&Og(w.textContent,ne,u),L=["children",""+ne]):s.hasOwnProperty(X)&&ne!=null&&X==="onScroll"&&ir("scroll",w)}switch(x){case"input":Ee(w),tt(w,j,!0);break;case"textarea":Ee(w),Ue(w);break;case"select":case"option":break;default:typeof j.onClick=="function"&&(w.onclick=Pg)}w=L,h.updateQueue=w,w!==null&&(h.flags|=4)}else{X=L.nodeType===9?L:L.ownerDocument,u==="http://www.w3.org/1999/xhtml"&&(u=it(x)),u==="http://www.w3.org/1999/xhtml"?x==="script"?(u=X.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild)):typeof w.is=="string"?u=X.createElement(x,{is:w.is}):(u=X.createElement(x),x==="select"&&(X=u,w.multiple?X.multiple=!0:w.size&&(X.size=w.size))):u=X.createElementNS(u,x),u[$o]=h,u[oh]=w,Y4(u,h,!1,!1),h.stateNode=u;e:{switch(X=mt(x,w),x){case"dialog":ir("cancel",u),ir("close",u),L=w;break;case"iframe":case"object":case"embed":ir("load",u),L=w;break;case"video":case"audio":for(L=0;L<rh.length;L++)ir(rh[L],u);L=w;break;case"source":ir("error",u),L=w;break;case"img":case"image":case"link":ir("error",u),ir("load",u),L=w;break;case"details":ir("toggle",u),L=w;break;case"input":ge(u,w),L=be(u,w),ir("invalid",u);break;case"option":L=w;break;case"select":u._wrapperState={wasMultiple:!!w.multiple},L=P({},w,{value:void 0}),ir("invalid",u);break;case"textarea":Je(u,w),L=Xe(u,w),ir("invalid",u);break;default:L=w}pt(x,L),ne=L;for(j in ne)if(ne.hasOwnProperty(j)){var ae=ne[j];j==="style"?Vt(u,ae):j==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,ae!=null&&Ot(u,ae)):j==="children"?typeof ae=="string"?(x!=="textarea"||ae!=="")&&xt(u,ae):typeof ae=="number"&&xt(u,""+ae):j!=="suppressContentEditableWarning"&&j!=="suppressHydrationWarning"&&j!=="autoFocus"&&(s.hasOwnProperty(j)?ae!=null&&j==="onScroll"&&ir("scroll",u):ae!=null&&E(u,j,ae,X))}switch(x){case"input":Ee(u),tt(u,w,!1);break;case"textarea":Ee(u),Ue(u);break;case"option":w.value!=null&&u.setAttribute("value",""+te(w.value));break;case"select":u.multiple=!!w.multiple,j=w.value,j!=null?ht(u,!!w.multiple,j,!1):w.defaultValue!=null&&ht(u,!!w.multiple,w.defaultValue,!0);break;default:typeof L.onClick=="function"&&(u.onclick=Pg)}switch(x){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(h.flags|=4)}h.ref!==null&&(h.flags|=512,h.flags|=2097152)}return Is(h),null;case 6:if(u&&h.stateNode!=null)Q4(u,h,u.memoizedProps,w);else{if(typeof w!="string"&&h.stateNode===null)throw Error(t(166));if(x=gc(dh.current),gc(zo.current),zg(h)){if(w=h.stateNode,x=h.memoizedProps,w[$o]=h,(j=w.nodeValue!==x)&&(u=pi,u!==null))switch(u.tag){case 3:Og(w.nodeValue,x,(u.mode&1)!==0);break;case 5:u.memoizedProps.suppressHydrationWarning!==!0&&Og(w.nodeValue,x,(u.mode&1)!==0)}j&&(h.flags|=4)}else w=(x.nodeType===9?x:x.ownerDocument).createTextNode(w),w[$o]=h,h.stateNode=w}return Is(h),null;case 13:if(or(_r),w=h.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(ur&&mi!==null&&(h.mode&1)!==0&&(h.flags&128)===0)Z3(),ju(),h.flags|=98560,j=!1;else if(j=zg(h),w!==null&&w.dehydrated!==null){if(u===null){if(!j)throw Error(t(318));if(j=h.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(t(317));j[$o]=h}else ju(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;Is(h),j=!1}else lo!==null&&(RC(lo),lo=null),j=!0;if(!j)return h.flags&65536?h:null}return(h.flags&128)!==0?(h.lanes=x,h):(w=w!==null,w!==(u!==null&&u.memoizedState!==null)&&w&&(h.child.flags|=8192,(h.mode&1)!==0&&(u===null||(_r.current&1)!==0?Hr===0&&(Hr=3):LC())),h.updateQueue!==null&&(h.flags|=4),Is(h),null);case 4:return $u(),_C(u,h),u===null&&sh(h.stateNode.containerInfo),Is(h),null;case 10:return G1(h.type._context),Is(h),null;case 17:return Js(h.type)&&jg(),Is(h),null;case 19:if(or(_r),j=h.memoizedState,j===null)return Is(h),null;if(w=(h.flags&128)!==0,X=j.rendering,X===null)if(w)gh(j,!1);else{if(Hr!==0||u!==null&&(u.flags&128)!==0)for(u=h.child;u!==null;){if(X=Yg(u),X!==null){for(h.flags|=128,gh(j,!1),w=X.updateQueue,w!==null&&(h.updateQueue=w,h.flags|=4),h.subtreeFlags=0,w=x,x=h.child;x!==null;)j=x,u=w,j.flags&=14680066,X=j.alternate,X===null?(j.childLanes=0,j.lanes=u,j.child=null,j.subtreeFlags=0,j.memoizedProps=null,j.memoizedState=null,j.updateQueue=null,j.dependencies=null,j.stateNode=null):(j.childLanes=X.childLanes,j.lanes=X.lanes,j.child=X.child,j.subtreeFlags=0,j.deletions=null,j.memoizedProps=X.memoizedProps,j.memoizedState=X.memoizedState,j.updateQueue=X.updateQueue,j.type=X.type,u=X.dependencies,j.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),x=x.sibling;return Zn(_r,_r.current&1|2),h.child}u=u.sibling}j.tail!==null&&Ft()>Gu&&(h.flags|=128,w=!0,gh(j,!1),h.lanes=4194304)}else{if(!w)if(u=Yg(X),u!==null){if(h.flags|=128,w=!0,x=u.updateQueue,x!==null&&(h.updateQueue=x,h.flags|=4),gh(j,!0),j.tail===null&&j.tailMode==="hidden"&&!X.alternate&&!ur)return Is(h),null}else 2*Ft()-j.renderingStartTime>Gu&&x!==1073741824&&(h.flags|=128,w=!0,gh(j,!1),h.lanes=4194304);j.isBackwards?(X.sibling=h.child,h.child=X):(x=j.last,x!==null?x.sibling=X:h.child=X,j.last=X)}return j.tail!==null?(h=j.tail,j.rendering=h,j.tail=h.sibling,j.renderingStartTime=Ft(),h.sibling=null,x=_r.current,Zn(_r,w?x&1|2:x&1),h):(Is(h),null);case 22:case 23:return kC(),w=h.memoizedState!==null,u!==null&&u.memoizedState!==null!==w&&(h.flags|=8192),w&&(h.mode&1)!==0?(gi&1073741824)!==0&&(Is(h),h.subtreeFlags&6&&(h.flags|=8192)):Is(h),null;case 24:return null;case 25:return null}throw Error(t(156,h.tag))}function Oue(u,h){switch(U1(h),h.tag){case 1:return Js(h.type)&&jg(),u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 3:return $u(),or(Qs),or(Ts),eC(),u=h.flags,(u&65536)!==0&&(u&128)===0?(h.flags=u&-65537|128,h):null;case 5:return J1(h),null;case 13:if(or(_r),u=h.memoizedState,u!==null&&u.dehydrated!==null){if(h.alternate===null)throw Error(t(340));ju()}return u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 19:return or(_r),null;case 4:return $u(),null;case 10:return G1(h.type._context),null;case 22:case 23:return kC(),null;case 24:return null;default:return null}}var r_=!1,Rs=!1,Pue=typeof WeakSet=="function"?WeakSet:Set,Et=null;function qu(u,h){var x=u.ref;if(x!==null)if(typeof x=="function")try{x(null)}catch(w){Tr(u,h,w)}else x.current=null}function vC(u,h,x){try{x()}catch(w){Tr(u,h,w)}}var J4=!1;function Due(u,h){if(k1=Eg,u=A3(),S1(u)){if("selectionStart"in u)var x={start:u.selectionStart,end:u.selectionEnd};else e:{x=(x=u.ownerDocument)&&x.defaultView||window;var w=x.getSelection&&x.getSelection();if(w&&w.rangeCount!==0){x=w.anchorNode;var L=w.anchorOffset,j=w.focusNode;w=w.focusOffset;try{x.nodeType,j.nodeType}catch{x=null;break e}var X=0,ne=-1,ae=-1,we=0,Ge=0,Ke=u,He=null;t:for(;;){for(var _t;Ke!==x||L!==0&&Ke.nodeType!==3||(ne=X+L),Ke!==j||w!==0&&Ke.nodeType!==3||(ae=X+w),Ke.nodeType===3&&(X+=Ke.nodeValue.length),(_t=Ke.firstChild)!==null;)He=Ke,Ke=_t;for(;;){if(Ke===u)break t;if(He===x&&++we===L&&(ne=X),He===j&&++Ge===w&&(ae=X),(_t=Ke.nextSibling)!==null)break;Ke=He,He=Ke.parentNode}Ke=_t}x=ne===-1||ae===-1?null:{start:ne,end:ae}}else x=null}x=x||{start:0,end:0}}else x=null;for(L1={focusedElem:u,selectionRange:x},Eg=!1,Et=h;Et!==null;)if(h=Et,u=h.child,(h.subtreeFlags&1028)!==0&&u!==null)u.return=h,Et=u;else for(;Et!==null;){h=Et;try{var Tt=h.alternate;if((h.flags&1024)!==0)switch(h.tag){case 0:case 11:case 15:break;case 1:if(Tt!==null){var Rt=Tt.memoizedProps,Lr=Tt.memoizedState,me=h.stateNode,ue=me.getSnapshotBeforeUpdate(h.elementType===h.type?Rt:co(h.type,Rt),Lr);me.__reactInternalSnapshotBeforeUpdate=ue}break;case 3:var ye=h.stateNode.containerInfo;ye.nodeType===1?ye.textContent="":ye.nodeType===9&&ye.documentElement&&ye.removeChild(ye.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Ze){Tr(h,h.return,Ze)}if(u=h.sibling,u!==null){u.return=h.return,Et=u;break}Et=h.return}return Tt=J4,J4=!1,Tt}function _h(u,h,x){var w=h.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var L=w=w.next;do{if((L.tag&u)===u){var j=L.destroy;L.destroy=void 0,j!==void 0&&vC(h,x,j)}L=L.next}while(L!==w)}}function s_(u,h){if(h=h.updateQueue,h=h!==null?h.lastEffect:null,h!==null){var x=h=h.next;do{if((x.tag&u)===u){var w=x.create;x.destroy=w()}x=x.next}while(x!==h)}}function yC(u){var h=u.ref;if(h!==null){var x=u.stateNode;switch(u.tag){case 5:u=x;break;default:u=x}typeof h=="function"?h(u):h.current=u}}function Z4(u){var h=u.alternate;h!==null&&(u.alternate=null,Z4(h)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(h=u.stateNode,h!==null&&(delete h[$o],delete h[oh],delete h[P1],delete h[vue],delete h[yue])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function ez(u){return u.tag===5||u.tag===3||u.tag===4}function tz(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||ez(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function bC(u,h,x){var w=u.tag;if(w===5||w===6)u=u.stateNode,h?x.nodeType===8?x.parentNode.insertBefore(u,h):x.insertBefore(u,h):(x.nodeType===8?(h=x.parentNode,h.insertBefore(u,x)):(h=x,h.appendChild(u)),x=x._reactRootContainer,x!=null||h.onclick!==null||(h.onclick=Pg));else if(w!==4&&(u=u.child,u!==null))for(bC(u,h,x),u=u.sibling;u!==null;)bC(u,h,x),u=u.sibling}function xC(u,h,x){var w=u.tag;if(w===5||w===6)u=u.stateNode,h?x.insertBefore(u,h):x.appendChild(u);else if(w!==4&&(u=u.child,u!==null))for(xC(u,h,x),u=u.sibling;u!==null;)xC(u,h,x),u=u.sibling}var hs=null,uo=!1;function cl(u,h,x){for(x=x.child;x!==null;)nz(u,h,x),x=x.sibling}function nz(u,h,x){if(fe&&typeof fe.onCommitFiberUnmount=="function")try{fe.onCommitFiberUnmount(Qt,x)}catch{}switch(x.tag){case 5:Rs||qu(x,h);case 6:var w=hs,L=uo;hs=null,cl(u,h,x),hs=w,uo=L,hs!==null&&(uo?(u=hs,x=x.stateNode,u.nodeType===8?u.parentNode.removeChild(x):u.removeChild(x)):hs.removeChild(x.stateNode));break;case 18:hs!==null&&(uo?(u=hs,x=x.stateNode,u.nodeType===8?O1(u.parentNode,x):u.nodeType===1&&O1(u,x),Yf(u)):O1(hs,x.stateNode));break;case 4:w=hs,L=uo,hs=x.stateNode.containerInfo,uo=!0,cl(u,h,x),hs=w,uo=L;break;case 0:case 11:case 14:case 15:if(!Rs&&(w=x.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){L=w=w.next;do{var j=L,X=j.destroy;j=j.tag,X!==void 0&&((j&2)!==0||(j&4)!==0)&&vC(x,h,X),L=L.next}while(L!==w)}cl(u,h,x);break;case 1:if(!Rs&&(qu(x,h),w=x.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=x.memoizedProps,w.state=x.memoizedState,w.componentWillUnmount()}catch(ne){Tr(x,h,ne)}cl(u,h,x);break;case 21:cl(u,h,x);break;case 22:x.mode&1?(Rs=(w=Rs)||x.memoizedState!==null,cl(u,h,x),Rs=w):cl(u,h,x);break;default:cl(u,h,x)}}function rz(u){var h=u.updateQueue;if(h!==null){u.updateQueue=null;var x=u.stateNode;x===null&&(x=u.stateNode=new Pue),h.forEach(function(w){var L=Gue.bind(null,u,w);x.has(w)||(x.add(w),w.then(L,L))})}}function fo(u,h){var x=h.deletions;if(x!==null)for(var w=0;w<x.length;w++){var L=x[w];try{var j=u,X=h,ne=X;e:for(;ne!==null;){switch(ne.tag){case 5:hs=ne.stateNode,uo=!1;break e;case 3:hs=ne.stateNode.containerInfo,uo=!0;break e;case 4:hs=ne.stateNode.containerInfo,uo=!0;break e}ne=ne.return}if(hs===null)throw Error(t(160));nz(j,X,L),hs=null,uo=!1;var ae=L.alternate;ae!==null&&(ae.return=null),L.return=null}catch(we){Tr(L,h,we)}}if(h.subtreeFlags&12854)for(h=h.child;h!==null;)sz(h,u),h=h.sibling}function sz(u,h){var x=u.alternate,w=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:if(fo(h,u),Ho(u),w&4){try{_h(3,u,u.return),s_(3,u)}catch(Rt){Tr(u,u.return,Rt)}try{_h(5,u,u.return)}catch(Rt){Tr(u,u.return,Rt)}}break;case 1:fo(h,u),Ho(u),w&512&&x!==null&&qu(x,x.return);break;case 5:if(fo(h,u),Ho(u),w&512&&x!==null&&qu(x,x.return),u.flags&32){var L=u.stateNode;try{xt(L,"")}catch(Rt){Tr(u,u.return,Rt)}}if(w&4&&(L=u.stateNode,L!=null)){var j=u.memoizedProps,X=x!==null?x.memoizedProps:j,ne=u.type,ae=u.updateQueue;if(u.updateQueue=null,ae!==null)try{ne==="input"&&j.type==="radio"&&j.name!=null&&Ae(L,j),mt(ne,X);var we=mt(ne,j);for(X=0;X<ae.length;X+=2){var Ge=ae[X],Ke=ae[X+1];Ge==="style"?Vt(L,Ke):Ge==="dangerouslySetInnerHTML"?Ot(L,Ke):Ge==="children"?xt(L,Ke):E(L,Ge,Ke,we)}switch(ne){case"input":Re(L,j);break;case"textarea":qe(L,j);break;case"select":var He=L._wrapperState.wasMultiple;L._wrapperState.wasMultiple=!!j.multiple;var _t=j.value;_t!=null?ht(L,!!j.multiple,_t,!1):He!==!!j.multiple&&(j.defaultValue!=null?ht(L,!!j.multiple,j.defaultValue,!0):ht(L,!!j.multiple,j.multiple?[]:"",!1))}L[oh]=j}catch(Rt){Tr(u,u.return,Rt)}}break;case 6:if(fo(h,u),Ho(u),w&4){if(u.stateNode===null)throw Error(t(162));L=u.stateNode,j=u.memoizedProps;try{L.nodeValue=j}catch(Rt){Tr(u,u.return,Rt)}}break;case 3:if(fo(h,u),Ho(u),w&4&&x!==null&&x.memoizedState.isDehydrated)try{Yf(h.containerInfo)}catch(Rt){Tr(u,u.return,Rt)}break;case 4:fo(h,u),Ho(u);break;case 13:fo(h,u),Ho(u),L=u.child,L.flags&8192&&(j=L.memoizedState!==null,L.stateNode.isHidden=j,!j||L.alternate!==null&&L.alternate.memoizedState!==null||(wC=Ft())),w&4&&rz(u);break;case 22:if(Ge=x!==null&&x.memoizedState!==null,u.mode&1?(Rs=(we=Rs)||Ge,fo(h,u),Rs=we):fo(h,u),Ho(u),w&8192){if(we=u.memoizedState!==null,(u.stateNode.isHidden=we)&&!Ge&&(u.mode&1)!==0)for(Et=u,Ge=u.child;Ge!==null;){for(Ke=Et=Ge;Et!==null;){switch(He=Et,_t=He.child,He.tag){case 0:case 11:case 14:case 15:_h(4,He,He.return);break;case 1:qu(He,He.return);var Tt=He.stateNode;if(typeof Tt.componentWillUnmount=="function"){w=He,x=He.return;try{h=w,Tt.props=h.memoizedProps,Tt.state=h.memoizedState,Tt.componentWillUnmount()}catch(Rt){Tr(w,x,Rt)}}break;case 5:qu(He,He.return);break;case 22:if(He.memoizedState!==null){az(Ke);continue}}_t!==null?(_t.return=He,Et=_t):az(Ke)}Ge=Ge.sibling}e:for(Ge=null,Ke=u;;){if(Ke.tag===5){if(Ge===null){Ge=Ke;try{L=Ke.stateNode,we?(j=L.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none"):(ne=Ke.stateNode,ae=Ke.memoizedProps.style,X=ae!=null&&ae.hasOwnProperty("display")?ae.display:null,ne.style.display=lt("display",X))}catch(Rt){Tr(u,u.return,Rt)}}}else if(Ke.tag===6){if(Ge===null)try{Ke.stateNode.nodeValue=we?"":Ke.memoizedProps}catch(Rt){Tr(u,u.return,Rt)}}else if((Ke.tag!==22&&Ke.tag!==23||Ke.memoizedState===null||Ke===u)&&Ke.child!==null){Ke.child.return=Ke,Ke=Ke.child;continue}if(Ke===u)break e;for(;Ke.sibling===null;){if(Ke.return===null||Ke.return===u)break e;Ge===Ke&&(Ge=null),Ke=Ke.return}Ge===Ke&&(Ge=null),Ke.sibling.return=Ke.return,Ke=Ke.sibling}}break;case 19:fo(h,u),Ho(u),w&4&&rz(u);break;case 21:break;default:fo(h,u),Ho(u)}}function Ho(u){var h=u.flags;if(h&2){try{e:{for(var x=u.return;x!==null;){if(ez(x)){var w=x;break e}x=x.return}throw Error(t(160))}switch(w.tag){case 5:var L=w.stateNode;w.flags&32&&(xt(L,""),w.flags&=-33);var j=tz(u);xC(u,j,L);break;case 3:case 4:var X=w.stateNode.containerInfo,ne=tz(u);bC(u,ne,X);break;default:throw Error(t(161))}}catch(ae){Tr(u,u.return,ae)}u.flags&=-3}h&4096&&(u.flags&=-4097)}function jue(u,h,x){Et=u,iz(u)}function iz(u,h,x){for(var w=(u.mode&1)!==0;Et!==null;){var L=Et,j=L.child;if(L.tag===22&&w){var X=L.memoizedState!==null||r_;if(!X){var ne=L.alternate,ae=ne!==null&&ne.memoizedState!==null||Rs;ne=r_;var we=Rs;if(r_=X,(Rs=ae)&&!we)for(Et=L;Et!==null;)X=Et,ae=X.child,X.tag===22&&X.memoizedState!==null?lz(L):ae!==null?(ae.return=X,Et=ae):lz(L);for(;j!==null;)Et=j,iz(j),j=j.sibling;Et=L,r_=ne,Rs=we}oz(u)}else(L.subtreeFlags&8772)!==0&&j!==null?(j.return=L,Et=j):oz(u)}}function oz(u){for(;Et!==null;){var h=Et;if((h.flags&8772)!==0){var x=h.alternate;try{if((h.flags&8772)!==0)switch(h.tag){case 0:case 11:case 15:Rs||s_(5,h);break;case 1:var w=h.stateNode;if(h.flags&4&&!Rs)if(x===null)w.componentDidMount();else{var L=h.elementType===h.type?x.memoizedProps:co(h.type,x.memoizedProps);w.componentDidUpdate(L,x.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var j=h.updateQueue;j!==null&&r4(h,j,w);break;case 3:var X=h.updateQueue;if(X!==null){if(x=null,h.child!==null)switch(h.child.tag){case 5:x=h.child.stateNode;break;case 1:x=h.child.stateNode}r4(h,X,x)}break;case 5:var ne=h.stateNode;if(x===null&&h.flags&4){x=ne;var ae=h.memoizedProps;switch(h.type){case"button":case"input":case"select":case"textarea":ae.autoFocus&&x.focus();break;case"img":ae.src&&(x.src=ae.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(h.memoizedState===null){var we=h.alternate;if(we!==null){var Ge=we.memoizedState;if(Ge!==null){var Ke=Ge.dehydrated;Ke!==null&&Yf(Ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}Rs||h.flags&512&&yC(h)}catch(He){Tr(h,h.return,He)}}if(h===u){Et=null;break}if(x=h.sibling,x!==null){x.return=h.return,Et=x;break}Et=h.return}}function az(u){for(;Et!==null;){var h=Et;if(h===u){Et=null;break}var x=h.sibling;if(x!==null){x.return=h.return,Et=x;break}Et=h.return}}function lz(u){for(;Et!==null;){var h=Et;try{switch(h.tag){case 0:case 11:case 15:var x=h.return;try{s_(4,h)}catch(ae){Tr(h,x,ae)}break;case 1:var w=h.stateNode;if(typeof w.componentDidMount=="function"){var L=h.return;try{w.componentDidMount()}catch(ae){Tr(h,L,ae)}}var j=h.return;try{yC(h)}catch(ae){Tr(h,j,ae)}break;case 5:var X=h.return;try{yC(h)}catch(ae){Tr(h,X,ae)}}}catch(ae){Tr(h,h.return,ae)}if(h===u){Et=null;break}var ne=h.sibling;if(ne!==null){ne.return=h.return,Et=ne;break}Et=h.return}}var Fue=Math.ceil,i_=C.ReactCurrentDispatcher,SC=C.ReactCurrentOwner,Fi=C.ReactCurrentBatchConfig,Cn=0,ns=null,Pr=null,ps=0,gi=0,Hu=sl(0),Hr=0,vh=null,vc=0,o_=0,EC=0,yh=null,ei=null,wC=0,Gu=1/0,va=null,a_=!1,TC=null,ul=null,l_=!1,dl=null,c_=0,bh=0,CC=null,u_=-1,d_=0;function Bs(){return(Cn&6)!==0?Ft():u_!==-1?u_:u_=Ft()}function fl(u){return(u.mode&1)===0?1:(Cn&2)!==0&&ps!==0?ps&-ps:xue.transition!==null?(d_===0&&(d_=wu()),d_):(u=Fn,u!==0||(u=window.event,u=u===void 0?16:c3(u.type)),u)}function ho(u,h,x,w){if(50<bh)throw bh=0,CC=null,Error(t(185));Hf(u,x,w),((Cn&2)===0||u!==ns)&&(u===ns&&((Cn&2)===0&&(o_|=x),Hr===4&&hl(u,ps)),ti(u,w),x===1&&Cn===0&&(h.mode&1)===0&&(Gu=Ft()+500,Ug&&ol()))}function ti(u,h){var x=u.callbackNode;bg(u,h);var w=zr(u,u===ns?ps:0);if(w===0)x!==null&&We(x),u.callbackNode=null,u.callbackPriority=0;else if(h=w&-w,u.callbackPriority!==h){if(x!=null&&We(x),h===1)u.tag===0?bue(uz.bind(null,u)):K3(uz.bind(null,u)),gue(function(){(Cn&6)===0&&ol()}),x=null;else{switch(t3(w)){case 1:x=wn;break;case 4:x=Wn;break;case 16:x=kn;break;case 536870912:x=fi;break;default:x=kn}x=vz(x,cz.bind(null,u))}u.callbackPriority=h,u.callbackNode=x}}function cz(u,h){if(u_=-1,d_=0,(Cn&6)!==0)throw Error(t(327));var x=u.callbackNode;if(Vu()&&u.callbackNode!==x)return null;var w=zr(u,u===ns?ps:0);if(w===0)return null;if((w&30)!==0||(w&u.expiredLanes)!==0||h)h=f_(u,w);else{h=w;var L=Cn;Cn|=2;var j=fz();(ns!==u||ps!==h)&&(va=null,Gu=Ft()+500,bc(u,h));do try{$ue();break}catch(ne){dz(u,ne)}while(!0);H1(),i_.current=j,Cn=L,Pr!==null?h=0:(ns=null,ps=0,h=Hr)}if(h!==0){if(h===2&&(L=Xs(u),L!==0&&(w=L,h=IC(u,L))),h===1)throw x=vh,bc(u,0),hl(u,w),ti(u,Ft()),x;if(h===6)hl(u,w);else{if(L=u.current.alternate,(w&30)===0&&!Uue(L)&&(h=f_(u,w),h===2&&(j=Xs(u),j!==0&&(w=j,h=IC(u,j))),h===1))throw x=vh,bc(u,0),hl(u,w),ti(u,Ft()),x;switch(u.finishedWork=L,u.finishedLanes=w,h){case 0:case 1:throw Error(t(345));case 2:xc(u,ei,va);break;case 3:if(hl(u,w),(w&130023424)===w&&(h=wC+500-Ft(),10<h)){if(zr(u,0)!==0)break;if(L=u.suspendedLanes,(L&w)!==w){Bs(),u.pingedLanes|=u.suspendedLanes&L;break}u.timeoutHandle=N1(xc.bind(null,u,ei,va),h);break}xc(u,ei,va);break;case 4:if(hl(u,w),(w&4194240)===w)break;for(h=u.eventTimes,L=-1;0<w;){var X=31-ze(w);j=1<<X,X=h[X],X>L&&(L=X),w&=~j}if(w=L,w=Ft()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*Fue(w/1960))-w,10<w){u.timeoutHandle=N1(xc.bind(null,u,ei,va),w);break}xc(u,ei,va);break;case 5:xc(u,ei,va);break;default:throw Error(t(329))}}}return ti(u,Ft()),u.callbackNode===x?cz.bind(null,u):null}function IC(u,h){var x=yh;return u.current.memoizedState.isDehydrated&&(bc(u,h).flags|=256),u=f_(u,h),u!==2&&(h=ei,ei=x,h!==null&&RC(h)),u}function RC(u){ei===null?ei=u:ei.push.apply(ei,u)}function Uue(u){for(var h=u;;){if(h.flags&16384){var x=h.updateQueue;if(x!==null&&(x=x.stores,x!==null))for(var w=0;w<x.length;w++){var L=x[w],j=L.getSnapshot;L=L.value;try{if(!ao(j(),L))return!1}catch{return!1}}}if(x=h.child,h.subtreeFlags&16384&&x!==null)x.return=h,h=x;else{if(h===u)break;for(;h.sibling===null;){if(h.return===null||h.return===u)return!0;h=h.return}h.sibling.return=h.return,h=h.sibling}}return!0}function hl(u,h){for(h&=~EC,h&=~o_,u.suspendedLanes|=h,u.pingedLanes&=~h,u=u.expirationTimes;0<h;){var x=31-ze(h),w=1<<x;u[x]=-1,h&=~w}}function uz(u){if((Cn&6)!==0)throw Error(t(327));Vu();var h=zr(u,0);if((h&1)===0)return ti(u,Ft()),null;var x=f_(u,h);if(u.tag!==0&&x===2){var w=Xs(u);w!==0&&(h=w,x=IC(u,w))}if(x===1)throw x=vh,bc(u,0),hl(u,h),ti(u,Ft()),x;if(x===6)throw Error(t(345));return u.finishedWork=u.current.alternate,u.finishedLanes=h,xc(u,ei,va),ti(u,Ft()),null}function AC(u,h){var x=Cn;Cn|=1;try{return u(h)}finally{Cn=x,Cn===0&&(Gu=Ft()+500,Ug&&ol())}}function yc(u){dl!==null&&dl.tag===0&&(Cn&6)===0&&Vu();var h=Cn;Cn|=1;var x=Fi.transition,w=Fn;try{if(Fi.transition=null,Fn=1,u)return u()}finally{Fn=w,Fi.transition=x,Cn=h,(Cn&6)===0&&ol()}}function kC(){gi=Hu.current,or(Hu)}function bc(u,h){u.finishedWork=null,u.finishedLanes=0;var x=u.timeoutHandle;if(x!==-1&&(u.timeoutHandle=-1,mue(x)),Pr!==null)for(x=Pr.return;x!==null;){var w=x;switch(U1(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&jg();break;case 3:$u(),or(Qs),or(Ts),eC();break;case 5:J1(w);break;case 4:$u();break;case 13:or(_r);break;case 19:or(_r);break;case 10:G1(w.type._context);break;case 22:case 23:kC()}x=x.return}if(ns=u,Pr=u=pl(u.current,null),ps=gi=h,Hr=0,vh=null,EC=o_=vc=0,ei=yh=null,mc!==null){for(h=0;h<mc.length;h++)if(x=mc[h],w=x.interleaved,w!==null){x.interleaved=null;var L=w.next,j=x.pending;if(j!==null){var X=j.next;j.next=L,w.next=X}x.pending=w}mc=null}return u}function dz(u,h){do{var x=Pr;try{if(H1(),Xg.current=e_,Qg){for(var w=vr.memoizedState;w!==null;){var L=w.queue;L!==null&&(L.pending=null),w=w.next}Qg=!1}if(_c=0,ts=qr=vr=null,fh=!1,hh=0,SC.current=null,x===null||x.return===null){Hr=1,vh=h,Pr=null;break}e:{var j=u,X=x.return,ne=x,ae=h;if(h=ps,ne.flags|=32768,ae!==null&&typeof ae=="object"&&typeof ae.then=="function"){var we=ae,Ge=ne,Ke=Ge.tag;if((Ge.mode&1)===0&&(Ke===0||Ke===11||Ke===15)){var He=Ge.alternate;He?(Ge.updateQueue=He.updateQueue,Ge.memoizedState=He.memoizedState,Ge.lanes=He.lanes):(Ge.updateQueue=null,Ge.memoizedState=null)}var _t=D4(X);if(_t!==null){_t.flags&=-257,j4(_t,X,ne,j,h),_t.mode&1&&P4(j,we,h),h=_t,ae=we;var Tt=h.updateQueue;if(Tt===null){var Rt=new Set;Rt.add(ae),h.updateQueue=Rt}else Tt.add(ae);break e}else{if((h&1)===0){P4(j,we,h),LC();break e}ae=Error(t(426))}}else if(ur&&ne.mode&1){var Lr=D4(X);if(Lr!==null){(Lr.flags&65536)===0&&(Lr.flags|=256),j4(Lr,X,ne,j,h),z1(zu(ae,ne));break e}}j=ae=zu(ae,ne),Hr!==4&&(Hr=2),yh===null?yh=[j]:yh.push(j),j=X;do{switch(j.tag){case 3:j.flags|=65536,h&=-h,j.lanes|=h;var me=N4(j,ae,h);n4(j,me);break e;case 1:ne=ae;var ue=j.type,ye=j.stateNode;if((j.flags&128)===0&&(typeof ue.getDerivedStateFromError=="function"||ye!==null&&typeof ye.componentDidCatch=="function"&&(ul===null||!ul.has(ye)))){j.flags|=65536,h&=-h,j.lanes|=h;var Ze=O4(j,ne,h);n4(j,Ze);break e}}j=j.return}while(j!==null)}pz(x)}catch(kt){h=kt,Pr===x&&x!==null&&(Pr=x=x.return);continue}break}while(!0)}function fz(){var u=i_.current;return i_.current=e_,u===null?e_:u}function LC(){(Hr===0||Hr===3||Hr===2)&&(Hr=4),ns===null||(vc&268435455)===0&&(o_&268435455)===0||hl(ns,ps)}function f_(u,h){var x=Cn;Cn|=2;var w=fz();(ns!==u||ps!==h)&&(va=null,bc(u,h));do try{Bue();break}catch(L){dz(u,L)}while(!0);if(H1(),Cn=x,i_.current=w,Pr!==null)throw Error(t(261));return ns=null,ps=0,Hr}function Bue(){for(;Pr!==null;)hz(Pr)}function $ue(){for(;Pr!==null&&!an();)hz(Pr)}function hz(u){var h=_z(u.alternate,u,gi);u.memoizedProps=u.pendingProps,h===null?pz(u):Pr=h,SC.current=null}function pz(u){var h=u;do{var x=h.alternate;if(u=h.return,(h.flags&32768)===0){if(x=Nue(x,h,gi),x!==null){Pr=x;return}}else{if(x=Oue(x,h),x!==null){x.flags&=32767,Pr=x;return}if(u!==null)u.flags|=32768,u.subtreeFlags=0,u.deletions=null;else{Hr=6,Pr=null;return}}if(h=h.sibling,h!==null){Pr=h;return}Pr=h=u}while(h!==null);Hr===0&&(Hr=5)}function xc(u,h,x){var w=Fn,L=Fi.transition;try{Fi.transition=null,Fn=1,zue(u,h,x,w)}finally{Fi.transition=L,Fn=w}return null}function zue(u,h,x,w){do Vu();while(dl!==null);if((Cn&6)!==0)throw Error(t(327));x=u.finishedWork;var L=u.finishedLanes;if(x===null)return null;if(u.finishedWork=null,u.finishedLanes=0,x===u.current)throw Error(t(177));u.callbackNode=null,u.callbackPriority=0;var j=x.lanes|x.childLanes;if(Sce(u,j),u===ns&&(Pr=ns=null,ps=0),(x.subtreeFlags&2064)===0&&(x.flags&2064)===0||l_||(l_=!0,vz(kn,function(){return Vu(),null})),j=(x.flags&15990)!==0,(x.subtreeFlags&15990)!==0||j){j=Fi.transition,Fi.transition=null;var X=Fn;Fn=1;var ne=Cn;Cn|=4,SC.current=null,Due(u,x),sz(x,u),lue(L1),Eg=!!k1,L1=k1=null,u.current=x,jue(x),yn(),Cn=ne,Fn=X,Fi.transition=j}else u.current=x;if(l_&&(l_=!1,dl=u,c_=L),j=u.pendingLanes,j===0&&(ul=null),Ve(x.stateNode),ti(u,Ft()),h!==null)for(w=u.onRecoverableError,x=0;x<h.length;x++)L=h[x],w(L.value,{componentStack:L.stack,digest:L.digest});if(a_)throw a_=!1,u=TC,TC=null,u;return(c_&1)!==0&&u.tag!==0&&Vu(),j=u.pendingLanes,(j&1)!==0?u===CC?bh++:(bh=0,CC=u):bh=0,ol(),null}function Vu(){if(dl!==null){var u=t3(c_),h=Fi.transition,x=Fn;try{if(Fi.transition=null,Fn=16>u?16:u,dl===null)var w=!1;else{if(u=dl,dl=null,c_=0,(Cn&6)!==0)throw Error(t(331));var L=Cn;for(Cn|=4,Et=u.current;Et!==null;){var j=Et,X=j.child;if((Et.flags&16)!==0){var ne=j.deletions;if(ne!==null){for(var ae=0;ae<ne.length;ae++){var we=ne[ae];for(Et=we;Et!==null;){var Ge=Et;switch(Ge.tag){case 0:case 11:case 15:_h(8,Ge,j)}var Ke=Ge.child;if(Ke!==null)Ke.return=Ge,Et=Ke;else for(;Et!==null;){Ge=Et;var He=Ge.sibling,_t=Ge.return;if(Z4(Ge),Ge===we){Et=null;break}if(He!==null){He.return=_t,Et=He;break}Et=_t}}}var Tt=j.alternate;if(Tt!==null){var Rt=Tt.child;if(Rt!==null){Tt.child=null;do{var Lr=Rt.sibling;Rt.sibling=null,Rt=Lr}while(Rt!==null)}}Et=j}}if((j.subtreeFlags&2064)!==0&&X!==null)X.return=j,Et=X;else e:for(;Et!==null;){if(j=Et,(j.flags&2048)!==0)switch(j.tag){case 0:case 11:case 15:_h(9,j,j.return)}var me=j.sibling;if(me!==null){me.return=j.return,Et=me;break e}Et=j.return}}var ue=u.current;for(Et=ue;Et!==null;){X=Et;var ye=X.child;if((X.subtreeFlags&2064)!==0&&ye!==null)ye.return=X,Et=ye;else e:for(X=ue;Et!==null;){if(ne=Et,(ne.flags&2048)!==0)try{switch(ne.tag){case 0:case 11:case 15:s_(9,ne)}}catch(kt){Tr(ne,ne.return,kt)}if(ne===X){Et=null;break e}var Ze=ne.sibling;if(Ze!==null){Ze.return=ne.return,Et=Ze;break e}Et=ne.return}}if(Cn=L,ol(),fe&&typeof fe.onPostCommitFiberRoot=="function")try{fe.onPostCommitFiberRoot(Qt,u)}catch{}w=!0}return w}finally{Fn=x,Fi.transition=h}}return!1}function mz(u,h,x){h=zu(x,h),h=N4(u,h,1),u=ll(u,h,1),h=Bs(),u!==null&&(Hf(u,1,h),ti(u,h))}function Tr(u,h,x){if(u.tag===3)mz(u,u,x);else for(;h!==null;){if(h.tag===3){mz(h,u,x);break}else if(h.tag===1){var w=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(ul===null||!ul.has(w))){u=zu(x,u),u=O4(h,u,1),h=ll(h,u,1),u=Bs(),h!==null&&(Hf(h,1,u),ti(h,u));break}}h=h.return}}function que(u,h,x){var w=u.pingCache;w!==null&&w.delete(h),h=Bs(),u.pingedLanes|=u.suspendedLanes&x,ns===u&&(ps&x)===x&&(Hr===4||Hr===3&&(ps&130023424)===ps&&500>Ft()-wC?bc(u,0):EC|=x),ti(u,h)}function gz(u,h){h===0&&((u.mode&1)===0?h=1:(h=jn,jn<<=1,(jn&130023424)===0&&(jn=4194304)));var x=Bs();u=ma(u,h),u!==null&&(Hf(u,h,x),ti(u,x))}function Hue(u){var h=u.memoizedState,x=0;h!==null&&(x=h.retryLane),gz(u,x)}function Gue(u,h){var x=0;switch(u.tag){case 13:var w=u.stateNode,L=u.memoizedState;L!==null&&(x=L.retryLane);break;case 19:w=u.stateNode;break;default:throw Error(t(314))}w!==null&&w.delete(h),gz(u,x)}var _z;_z=function(u,h,x){if(u!==null)if(u.memoizedProps!==h.pendingProps||Qs.current)Zs=!0;else{if((u.lanes&x)===0&&(h.flags&128)===0)return Zs=!1,Mue(u,h,x);Zs=(u.flags&131072)!==0}else Zs=!1,ur&&(h.flags&1048576)!==0&&Y3(h,$g,h.index);switch(h.lanes=0,h.tag){case 2:var w=h.type;n_(u,h),u=h.pendingProps;var L=Ou(h,Ts.current);Uu(h,x),L=rC(null,h,w,u,L,x);var j=sC();return h.flags|=1,typeof L=="object"&&L!==null&&typeof L.render=="function"&&L.$$typeof===void 0?(h.tag=1,h.memoizedState=null,h.updateQueue=null,Js(w)?(j=!0,Fg(h)):j=!1,h.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,K1(h),L.updater=Wg,h.stateNode=L,L._reactInternals=h,X1(h,w,u,x),h=fC(null,h,w,!0,j,x)):(h.tag=0,ur&&j&&F1(h),Us(null,h,L,x),h=h.child),h;case 16:w=h.elementType;e:{switch(n_(u,h),u=h.pendingProps,L=w._init,w=L(w._payload),h.type=w,L=h.tag=Wue(w),u=co(w,u),L){case 0:h=dC(null,h,w,u,x);break e;case 1:h=q4(null,h,w,u,x);break e;case 11:h=F4(null,h,w,u,x);break e;case 14:h=U4(null,h,w,co(w.type,u),x);break e}throw Error(t(306,w,""))}return h;case 0:return w=h.type,L=h.pendingProps,L=h.elementType===w?L:co(w,L),dC(u,h,w,L,x);case 1:return w=h.type,L=h.pendingProps,L=h.elementType===w?L:co(w,L),q4(u,h,w,L,x);case 3:e:{if(H4(h),u===null)throw Error(t(387));w=h.pendingProps,j=h.memoizedState,L=j.element,t4(u,h),Vg(h,w,null,x);var X=h.memoizedState;if(w=X.element,j.isDehydrated)if(j={element:w,isDehydrated:!1,cache:X.cache,pendingSuspenseBoundaries:X.pendingSuspenseBoundaries,transitions:X.transitions},h.updateQueue.baseState=j,h.memoizedState=j,h.flags&256){L=zu(Error(t(423)),h),h=G4(u,h,w,x,L);break e}else if(w!==L){L=zu(Error(t(424)),h),h=G4(u,h,w,x,L);break e}else for(mi=rl(h.stateNode.containerInfo.firstChild),pi=h,ur=!0,lo=null,x=u4(h,null,w,x),h.child=x;x;)x.flags=x.flags&-3|4096,x=x.sibling;else{if(ju(),w===L){h=_a(u,h,x);break e}Us(u,h,w,x)}h=h.child}return h;case 5:return d4(h),u===null&&$1(h),w=h.type,L=h.pendingProps,j=u!==null?u.memoizedProps:null,X=L.children,M1(w,L)?X=null:j!==null&&M1(w,j)&&(h.flags|=32),z4(u,h),Us(u,h,X,x),h.child;case 6:return u===null&&$1(h),null;case 13:return V4(u,h,x);case 4:return Q1(h,h.stateNode.containerInfo),w=h.pendingProps,u===null?h.child=Bu(h,null,w,x):Us(u,h,w,x),h.child;case 11:return w=h.type,L=h.pendingProps,L=h.elementType===w?L:co(w,L),F4(u,h,w,L,x);case 7:return Us(u,h,h.pendingProps,x),h.child;case 8:return Us(u,h,h.pendingProps.children,x),h.child;case 12:return Us(u,h,h.pendingProps.children,x),h.child;case 10:e:{if(w=h.type._context,L=h.pendingProps,j=h.memoizedProps,X=L.value,Zn(qg,w._currentValue),w._currentValue=X,j!==null)if(ao(j.value,X)){if(j.children===L.children&&!Qs.current){h=_a(u,h,x);break e}}else for(j=h.child,j!==null&&(j.return=h);j!==null;){var ne=j.dependencies;if(ne!==null){X=j.child;for(var ae=ne.firstContext;ae!==null;){if(ae.context===w){if(j.tag===1){ae=ga(-1,x&-x),ae.tag=2;var we=j.updateQueue;if(we!==null){we=we.shared;var Ge=we.pending;Ge===null?ae.next=ae:(ae.next=Ge.next,Ge.next=ae),we.pending=ae}}j.lanes|=x,ae=j.alternate,ae!==null&&(ae.lanes|=x),V1(j.return,x,h),ne.lanes|=x;break}ae=ae.next}}else if(j.tag===10)X=j.type===h.type?null:j.child;else if(j.tag===18){if(X=j.return,X===null)throw Error(t(341));X.lanes|=x,ne=X.alternate,ne!==null&&(ne.lanes|=x),V1(X,x,h),X=j.sibling}else X=j.child;if(X!==null)X.return=j;else for(X=j;X!==null;){if(X===h){X=null;break}if(j=X.sibling,j!==null){j.return=X.return,X=j;break}X=X.return}j=X}Us(u,h,L.children,x),h=h.child}return h;case 9:return L=h.type,w=h.pendingProps.children,Uu(h,x),L=Di(L),w=w(L),h.flags|=1,Us(u,h,w,x),h.child;case 14:return w=h.type,L=co(w,h.pendingProps),L=co(w.type,L),U4(u,h,w,L,x);case 15:return B4(u,h,h.type,h.pendingProps,x);case 17:return w=h.type,L=h.pendingProps,L=h.elementType===w?L:co(w,L),n_(u,h),h.tag=1,Js(w)?(u=!0,Fg(h)):u=!1,Uu(h,x),o4(h,w,L),X1(h,w,L,x),fC(null,h,w,!0,u,x);case 19:return K4(u,h,x);case 22:return $4(u,h,x)}throw Error(t(156,h.tag))};function vz(u,h){return Pe(u,h)}function Vue(u,h,x,w){this.tag=u,this.key=x,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=h,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ui(u,h,x,w){return new Vue(u,h,x,w)}function MC(u){return u=u.prototype,!(!u||!u.isReactComponent)}function Wue(u){if(typeof u=="function")return MC(u)?1:0;if(u!=null){if(u=u.$$typeof,u===F)return 11;if(u===q)return 14}return 2}function pl(u,h){var x=u.alternate;return x===null?(x=Ui(u.tag,h,u.key,u.mode),x.elementType=u.elementType,x.type=u.type,x.stateNode=u.stateNode,x.alternate=u,u.alternate=x):(x.pendingProps=h,x.type=u.type,x.flags=0,x.subtreeFlags=0,x.deletions=null),x.flags=u.flags&14680064,x.childLanes=u.childLanes,x.lanes=u.lanes,x.child=u.child,x.memoizedProps=u.memoizedProps,x.memoizedState=u.memoizedState,x.updateQueue=u.updateQueue,h=u.dependencies,x.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext},x.sibling=u.sibling,x.index=u.index,x.ref=u.ref,x}function h_(u,h,x,w,L,j){var X=2;if(w=u,typeof u=="function")MC(u)&&(X=1);else if(typeof u=="string")X=5;else e:switch(u){case A:return Sc(x.children,L,j,h);case k:X=8,L|=8;break;case N:return u=Ui(12,x,h,L|2),u.elementType=N,u.lanes=j,u;case U:return u=Ui(13,x,h,L),u.elementType=U,u.lanes=j,u;case $:return u=Ui(19,x,h,L),u.elementType=$,u.lanes=j,u;case V:return p_(x,L,j,h);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case D:X=10;break e;case M:X=9;break e;case F:X=11;break e;case q:X=14;break e;case G:X=16,w=null;break e}throw Error(t(130,u==null?u:typeof u,""))}return h=Ui(X,x,h,L),h.elementType=u,h.type=w,h.lanes=j,h}function Sc(u,h,x,w){return u=Ui(7,u,w,h),u.lanes=x,u}function p_(u,h,x,w){return u=Ui(22,u,w,h),u.elementType=V,u.lanes=x,u.stateNode={isHidden:!1},u}function NC(u,h,x){return u=Ui(6,u,null,h),u.lanes=x,u}function OC(u,h,x){return h=Ui(4,u.children!==null?u.children:[],u.key,h),h.lanes=x,h.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},h}function Kue(u,h,x,w,L){this.tag=h,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qf(0),this.expirationTimes=qf(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qf(0),this.identifierPrefix=w,this.onRecoverableError=L,this.mutableSourceEagerHydrationData=null}function PC(u,h,x,w,L,j,X,ne,ae){return u=new Kue(u,h,x,ne,ae),h===1?(h=1,j===!0&&(h|=8)):h=0,j=Ui(3,null,null,h),u.current=j,j.stateNode=u,j.memoizedState={element:w,isDehydrated:x,cache:null,transitions:null,pendingSuspenseBoundaries:null},K1(j),u}function Yue(u,h,x){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:w==null?null:""+w,children:u,containerInfo:h,implementation:x}}function yz(u){if(!u)return il;u=u._reactInternals;e:{if(at(u)!==u||u.tag!==1)throw Error(t(170));var h=u;do{switch(h.tag){case 3:h=h.stateNode.context;break e;case 1:if(Js(h.type)){h=h.stateNode.__reactInternalMemoizedMergedChildContext;break e}}h=h.return}while(h!==null);throw Error(t(171))}if(u.tag===1){var x=u.type;if(Js(x))return V3(u,x,h)}return h}function bz(u,h,x,w,L,j,X,ne,ae){return u=PC(x,w,!0,u,L,j,X,ne,ae),u.context=yz(null),x=u.current,w=Bs(),L=fl(x),j=ga(w,L),j.callback=h??null,ll(x,j,L),u.current.lanes=L,Hf(u,L,w),ti(u,w),u}function m_(u,h,x,w){var L=h.current,j=Bs(),X=fl(L);return x=yz(x),h.context===null?h.context=x:h.pendingContext=x,h=ga(j,X),h.payload={element:u},w=w===void 0?null:w,w!==null&&(h.callback=w),u=ll(L,h,X),u!==null&&(ho(u,L,X,j),Gg(u,L,X)),X}function g_(u){if(u=u.current,!u.child)return null;switch(u.child.tag){case 5:return u.child.stateNode;default:return u.child.stateNode}}function xz(u,h){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var x=u.retryLane;u.retryLane=x!==0&&x<h?x:h}}function DC(u,h){xz(u,h),(u=u.alternate)&&xz(u,h)}function Xue(){return null}var Sz=typeof reportError=="function"?reportError:function(u){console.error(u)};function jC(u){this._internalRoot=u}__.prototype.render=jC.prototype.render=function(u){var h=this._internalRoot;if(h===null)throw Error(t(409));m_(u,h,null,null)},__.prototype.unmount=jC.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var h=u.containerInfo;yc(function(){m_(null,u,null,null)}),h[da]=null}};function __(u){this._internalRoot=u}__.prototype.unstable_scheduleHydration=function(u){if(u){var h=s3();u={blockedOn:null,target:u,priority:h};for(var x=0;x<el.length&&h!==0&&h<el[x].priority;x++);el.splice(x,0,u),x===0&&a3(u)}};function FC(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function v_(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11&&(u.nodeType!==8||u.nodeValue!==" react-mount-point-unstable "))}function Ez(){}function Que(u,h,x,w,L){if(L){if(typeof w=="function"){var j=w;w=function(){var we=g_(X);j.call(we)}}var X=bz(h,w,u,0,null,!1,!1,"",Ez);return u._reactRootContainer=X,u[da]=X.current,sh(u.nodeType===8?u.parentNode:u),yc(),X}for(;L=u.lastChild;)u.removeChild(L);if(typeof w=="function"){var ne=w;w=function(){var we=g_(ae);ne.call(we)}}var ae=PC(u,0,!1,null,null,!1,!1,"",Ez);return u._reactRootContainer=ae,u[da]=ae.current,sh(u.nodeType===8?u.parentNode:u),yc(function(){m_(h,ae,x,w)}),ae}function y_(u,h,x,w,L){var j=x._reactRootContainer;if(j){var X=j;if(typeof L=="function"){var ne=L;L=function(){var ae=g_(X);ne.call(ae)}}m_(h,X,u,L)}else X=Que(x,h,u,L,w);return g_(X)}n3=function(u){switch(u.tag){case 3:var h=u.stateNode;if(h.current.memoizedState.isDehydrated){var x=$r(h.pendingLanes);x!==0&&(l1(h,x|1),ti(h,Ft()),(Cn&6)===0&&(Gu=Ft()+500,ol()))}break;case 13:yc(function(){var w=ma(u,1);if(w!==null){var L=Bs();ho(w,u,1,L)}}),DC(u,1)}},c1=function(u){if(u.tag===13){var h=ma(u,134217728);if(h!==null){var x=Bs();ho(h,u,134217728,x)}DC(u,134217728)}},r3=function(u){if(u.tag===13){var h=fl(u),x=ma(u,h);if(x!==null){var w=Bs();ho(x,u,h,w)}DC(u,h)}},s3=function(){return Fn},i3=function(u,h){var x=Fn;try{return Fn=u,h()}finally{Fn=x}},ot=function(u,h,x){switch(h){case"input":if(Re(u,x),h=x.name,x.type==="radio"&&h!=null){for(x=u;x.parentNode;)x=x.parentNode;for(x=x.querySelectorAll("input[name="+JSON.stringify(""+h)+'][type="radio"]'),h=0;h<x.length;h++){var w=x[h];if(w!==u&&w.form===u.form){var L=Dg(w);if(!L)throw Error(t(90));le(w),Re(w,L)}}}break;case"textarea":qe(u,x);break;case"select":h=x.value,h!=null&&ht(u,!!x.multiple,h,!1)}},sr=AC,wr=yc;var Jue={usingClientEntryPoint:!1,Events:[ah,Mu,Dg,$n,_n,AC]},xh={findFiberByHostInstance:dc,bundleType:0,version:"18.2.0",rendererPackageName:"react-dom"},Zue={bundleType:xh.bundleType,version:xh.version,rendererPackageName:xh.rendererPackageName,rendererConfig:xh.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(u){return u=De(u),u===null?null:u.stateNode},findFiberByHostInstance:xh.findFiberByHostInstance||Xue,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.2.0-next-9e3b772b8-20220608"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var b_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!b_.isDisabled&&b_.supportsFiber)try{Qt=b_.inject(Zue),fe=b_}catch{}}return $s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Jue,$s.createPortal=function(u,h){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!FC(h))throw Error(t(200));return Yue(u,h,null,x)},$s.createRoot=function(u,h){if(!FC(u))throw Error(t(299));var x=!1,w="",L=Sz;return h!=null&&(h.unstable_strictMode===!0&&(x=!0),h.identifierPrefix!==void 0&&(w=h.identifierPrefix),h.onRecoverableError!==void 0&&(L=h.onRecoverableError)),h=PC(u,1,!1,null,null,x,!1,w,L),u[da]=h.current,sh(u.nodeType===8?u.parentNode:u),new jC(h)},$s.findDOMNode=function(u){if(u==null)return null;if(u.nodeType===1)return u;var h=u._reactInternals;if(h===void 0)throw typeof u.render=="function"?Error(t(188)):(u=Object.keys(u).join(","),Error(t(268,u)));return u=De(h),u=u===null?null:u.stateNode,u},$s.flushSync=function(u){return yc(u)},$s.hydrate=function(u,h,x){if(!v_(h))throw Error(t(200));return y_(null,u,h,!0,x)},$s.hydrateRoot=function(u,h,x){if(!FC(u))throw Error(t(405));var w=x!=null&&x.hydratedSources||null,L=!1,j="",X=Sz;if(x!=null&&(x.unstable_strictMode===!0&&(L=!0),x.identifierPrefix!==void 0&&(j=x.identifierPrefix),x.onRecoverableError!==void 0&&(X=x.onRecoverableError)),h=bz(h,null,u,1,x??null,L,!1,j,X),u[da]=h.current,sh(u),w)for(u=0;u<w.length;u++)x=w[u],L=x._getVersion,L=L(x._source),h.mutableSourceEagerHydrationData==null?h.mutableSourceEagerHydrationData=[x,L]:h.mutableSourceEagerHydrationData.push(x,L);return new __(h)},$s.render=function(u,h,x){if(!v_(h))throw Error(t(200));return y_(null,u,h,!1,x)},$s.unmountComponentAtNode=function(u){if(!v_(u))throw Error(t(40));return u._reactRootContainer?(yc(function(){y_(null,null,u,!1,function(){u._reactRootContainer=null,u[da]=null})}),!0):!1},$s.unstable_batchedUpdates=AC,$s.unstable_renderSubtreeIntoContainer=function(u,h,x,w){if(!v_(x))throw Error(t(200));if(u==null||u._reactInternals===void 0)throw Error(t(38));return y_(u,h,x,!1,w)},$s.version="18.2.0-next-9e3b772b8-20220608",$s}var kL;function LL(){if(kL)return F0.exports;kL=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),F0.exports=tH(),F0.exports}var $0=LL();const ML=ba($0),nH=go({__proto__:null,default:ML},[$0]),rH={children:O.node.isRequired,target:O.oneOfType([O.string,O.element,O.func])},Ed=({children:n,target:e})=>{const[t,r]=T.useState(!1),s=T.useRef();return Mt.useIsomorphicEffect(()=>{if(r(!0),s.current=e?typeof e=="string"?document.querySelector(e):e:document.createElement("div"),s.current===null)throw new Error("target must be determined");return e||document.body.append(s.current),()=>{!e&&s.current&&s.current.remove()}},[e]),t&&s.current?$0.createPortal(_.jsx(_.Fragment,{children:n}),s.current):null};Ed.propTypes=rH,Ed.displayName="BsPortal";function sH({onExit:n,mounted:e,onEnter:t,duration:r,onExited:s,onEntered:i,exitDuration:o,timingFunction:a}){const[l,c]=T.useState(r),[d,f]=T.useState(e?"entered":"exited"),p=T.useRef(-1);return Mt.useDidUpdate(()=>{(m=>{const g=m?t:n,v=m?i:s;f(m?"pre-entering":"pre-exiting"),window.clearTimeout(p.current);const y=m?r:o;if(c(y),y===0)typeof g=="function"&&g(),typeof v=="function"&&v(),f(m?"entered":"exited");else{const b=window.setTimeout(()=>{typeof g=="function"&&g(),f(m?"entering":"exiting")},10);p.current=window.setTimeout(()=>{window.clearTimeout(b),typeof v=="function"&&v(),f(m?"entered":"exited")},y)}})(e)},[e]),T.useEffect(()=>()=>window.clearTimeout(p.current),[]),{transitionStatus:d,transitionDuration:l,transitionTimingFunction:a||"ease"}}const NL=O.oneOfType([O.oneOf(["fade","skew-up","skew-down","rotate-right","rotate-left","slide-down","slide-up","slide-right","slide-left","scale-y","scale-x","scale","pop","pop-top-left","pop-top-right","pop-bottom-left","pop-bottom-right"]),O.shape({common:O.object,in:O.object.isRequired,out:O.object.isRequired,transitionProperty:O.string.isRequired})]),iH={onExit:O.func,onEnter:O.func,onExited:O.func,onEntered:O.func,duration:O.number,keepMounted:O.bool,exitDuration:O.number,transition:NL,timingFunction:O.string,mounted:O.bool.isRequired,children:O.func.isRequired},wd={transitionProperty:"transform, opacity",in:{opacity:1,transform:"scale(1)"},out:{opacity:0,transform:"scale(.9)"}},Hh={pop:{...wd,common:{transformOrigin:"center center"}},"pop-top-left":{...wd,common:{transformOrigin:"top left"}},"pop-top-right":{...wd,common:{transformOrigin:"top right"}},"pop-bottom-left":{...wd,common:{transformOrigin:"bottom left"}},"pop-bottom-right":{...wd,common:{transformOrigin:"bottom right"}},fade:{in:{opacity:1},out:{opacity:0},transitionProperty:"opacity"},scale:{common:{transformOrigin:"top"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"scale(1)"},out:{opacity:0,transform:"scale(0)"}},"scale-y":{common:{transformOrigin:"top"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"scaleY(1)"},out:{opacity:0,transform:"scaleY(0)"}},"scale-x":{common:{transformOrigin:"left"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"scaleX(1)"},out:{opacity:0,transform:"scaleX(0)"}},"slide-down":{common:{transformOrigin:"top"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(-100%)"}},"slide-up":{common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(100%)"}},"slide-left":{common:{transformOrigin:"left"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(100%)"}},"slide-right":{common:{transformOrigin:"right"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(-100%)"}},"rotate-right":{common:{transformOrigin:"top"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateY(0) rotate(0deg)"},out:{opacity:0,transform:"translateY(20px}) rotate(5deg)"}},"rotate-left":{common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateY(0) rotate(0deg)"},out:{opacity:0,transform:"translateY(20px}) rotate(-5deg)"}},"skew-up":{common:{transformOrigin:"top"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateY(0) skew(0deg, 0deg)"},out:{opacity:0,transform:"translateY(-20px}) skew(-10deg, -5deg)"}},"skew-down":{common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity",in:{opacity:1,transform:"translateY(0) skew(0deg, 0deg)"},out:{opacity:0,transform:"translateY(20px}) skew(-10deg, -5deg)"}}},OL={entered:"in",exited:"out",entering:"in",exiting:"out","pre-exiting":"out","pre-entering":"out"};function oH({state:n,duration:e,transition:t,timingFunction:r}){const s={transitionDuration:`${e}ms`,transitionTimingFunction:r};return typeof t=="string"?t in Hh?{transitionProperty:Hh[t].transitionProperty,...s,...Hh[t].common,...Hh[t][OL[n]]}:{}:{transitionProperty:t.transitionProperty,...s,...t.common,...t[OL[n]]}}function Mr({onExit:n,mounted:e,onEnter:t,children:r,onExited:s,onEntered:i,keepMounted:o,duration:a=250,transition:l="fade",timingFunction:c="fade",exitDuration:d=a}){const{transitionDuration:f,transitionStatus:p,transitionTimingFunction:m}=sH({onExit:n,mounted:e,onEnter:t,duration:a,onExited:s,onEntered:i,exitDuration:d,timingFunction:c});return f===0?e?_.jsx(_.Fragment,{children:r({})}):o?r({display:"none"}):null:p==="exited"?o?r({display:"none"}):null:_.jsx(_.Fragment,{children:r(oH({transition:l,state:p,duration:f,timingFunction:m}))})}Mr.propTypes=iH,Mr.displayName="BsTransition";const aH={show:O.bool,delay:O.number,onClick:O.func,disabled:O.bool,timeout:O.number,className:O.string,tooltipClass:O.string,onTooltipClick:O.func,label:O.node.isRequired,children:O.node.isRequired,color:O.oneOf(["gray","green"]),size:O.oneOf(["sm","md","lg"]),tag:O.oneOfType([O.element,O.string,O.func])};let Td,z0;const q0="hide-tooltip";let lH=class BC{constructor(){this.stacks=0,this.initialized=!1,this.isVisible=!1}init(){this.stacks+=1,this.initEventListeners()}onLeave(){this.isVisible&&(this.isVisible=!1,BC.dispatchHideEvent())}onClick(){this.onLeave(),this.isVisible||BC.dispatchHideEvent()}static dispatchHideEvent(){window.dispatchEvent(new Event(q0))}onTooltipVisible(){this.isVisible=!0}initEventListeners(){this.initialized||(Td=this.onLeave.bind(this),z0=this.onClick.bind(this),window.addEventListener("mousedown",Td),window.addEventListener("mouseup",Td),window.addEventListener("click",z0),this.initialized=!0)}destroy(){this.stacks-=1,!this.initialized||this.stacks>0||(window.removeEventListener("mousedown",Td),window.removeEventListener("mouseup",Td),window.removeEventListener("click",z0))}},cH=class{constructor(){this.hoverTimeout=null,this.onLeave=null,this.eventHandler=()=>{var e;return(e=this.onLeave)==null?void 0:e.call(this)}}init(e){this.onLeave=e,this.initEventListeners()}initEventListeners(){window.addEventListener(q0,this.eventHandler)}clearTimeout(){this.hoverTimeout&&window.clearTimeout(this.hoverTimeout)}destroy(){window.removeEventListener(q0,this.eventHandler),window.clearTimeout(this.hoverTimeout??0)}};const uH=new lH,Cd=({show:n,label:e,onClick:t,children:r,className:s,size:i="lg",delay:o=400,_tag:a="div",tooltipClass:l,timeout:c=null,color:d="gray",onTooltipClick:f,disabled:p=!1})=>{const[m,g]=T.useState(!1),v=T.useRef(null),y=T.useRef(null),b=T.useRef(null),S=T.useRef(null),E=T.useRef(null),C=T.useMemo(()=>n===void 0?m:n,[m,n]),R=()=>{p||(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{n===void 0&&g(!0)},o))},I=T.useCallback(()=>{E.current&&clearTimeout(E.current),n===void 0&&g(!1)},[n]),A=uH,k=new cH,N=T.useCallback(()=>{setTimeout(()=>{if(!C||!b.current||!y.current)return;const F=b.current.getBoundingClientRect();let U=!0;const $=b.current.offsetWidth/2,q=y.current.offsetWidth/2;let G=F.left+$-q,V=F.top-y.current.offsetHeight-10;G<5?G=5:G+y.current.offsetWidth>window.innerWidth-20&&(G=window.innerWidth-y.current.offsetWidth-20),V<5&&(V=F.top+b.current.offsetHeight+10,U=!1),y.current.style.top=`${V}px`,y.current.style.left=`${G}px`,y.current.style.zIndex=de.popupManager.getNewZIndex().toString(),y.current.dataset.bsTooltipTop=`${U}`;const z=y.current.getBoundingClientRect(),B=b.current.getBoundingClientRect(),P=z.x+z.width/2;if(P<B.left||P>B.right){const H=B.x+B.width/2;v.current&&(v.current.style.right=z.right-H+"px")}},0)},[C]),D=T.useCallback(()=>{c&&(S.current=setTimeout(()=>{I()},c))},[c,I]),M=T.useCallback(()=>{typeof document<"u"&&(C?(A.onTooltipVisible(),N(),c&&D(),window.addEventListener("scroll",N)):window.removeEventListener("scroll",N))},[C,c,N,A,D]);return T.useEffect(()=>(A.init(),k.init(I),()=>{typeof window<"u"&&(A.destroy(),k.destroy(),window.removeEventListener("scroll",N),E.current&&clearTimeout(E.current),S.current&&clearTimeout(S.current))}),[]),T.useEffect(()=>{M()},[C]),_.jsxs("div",{className:jt("bs-tooltip-wrapper",{"bs-tooltip-wrapper--disabled":p},s),onMouseOver:R,onFocus:R,onTouchStart:R,onMouseLeave:I,onTouchEnd:I,onTouchCancel:I,onClick:F=>t==null?void 0:t(F),onBlur:I,ref:b,children:[r,_.jsx(Ed,{children:_.jsx(Mr,{mounted:C,transition:"fade",duration:400,children:F=>_.jsxs("div",{style:F,ref:y,role:"tooltip",className:jt([l,"bs-tooltip",`bs-tooltip--${i}`,`bs-tooltip--${d}`,{"bs-tooltip--active":C}]),onClick:f,onKeyDown:f,children:[_.jsx("div",{className:"bs-tooltip__inner",children:e}),_.jsx("div",{className:"bs-tooltip__arrow",ref:v})]})})})]})};Cd.propTypes=aH,Cd.displayName="BsTooltip";const dH={lazy:O.bool,src:O.string,alt:O.string,onLoad:O.func,onClick:O.func,className:O.string,hasAddStoryButton:O.bool,onAddStoryButtonClick:O.func,storyStatus:O.oneOf(["seen","unseen","none"]),storyRingColor:O.oneOf(["primary","secondary"]),status:O.oneOf(["offline","recently","online"]).isRequired,size:O.oneOf(["28","32","40","44","48","56","64","72","96"]).isRequired},Gh=({src:n,alt:e,size:t,status:r,onLoad:s,onClick:i,className:o,lazy:a=!1,storyStatus:l="none",onAddStoryButtonClick:c,hasAddStoryButton:d=!1,storyRingColor:f="primary"})=>{const p=T.useRef(null),m=r==="online"||r==="recently",[g,v]=T.useState(!1);return T.useEffect(()=>{const y=p.current;if(!y)return;const{complete:b,naturalHeight:S}=y;b&&!S&&v(!0)},[]),_.jsxs("div",{onClick:i,className:jt(`bs-avatar bs-avatar--${t} bs-avatar--${l}`,o),children:[l!=="none"&&_.jsxs("svg",{className:"bs-avatar__story-ring",children:[_.jsxs("linearGradient",{id:`${l}-${f}`,x1:"0",y1:"0",x2:"1",y2:"1",children:[_.jsx("stop",{className:jt(`bs-avatar__gradient-first-stop bs-avatar__gradient-first-stop--${f}`),offset:"64%"}),_.jsx("stop",{className:jt(`bs-avatar__gradient-first-stop bs-avatar__gradient-second-stop--${f}`),offset:"100%"})]}),_.jsx("g",{children:_.jsx("circle",{className:"bs-avatar__story-ring-circle",cx:"50%",cy:"50%",stroke:`url(#${l}-${f})`,fill:"transparent"})})]}),n&&!g?_.jsx("img",{ref:p,src:n,onLoad:s,alt:e??"",className:"bs-avatar__image",loading:a?"lazy":void 0,onError:()=>v(!0)}):_.jsx("div",{className:"bs-avatar__icon-bg",children:_.jsx("i",{className:"bi bi-no-avatar bs-avatar__icon"})}),d&&_.jsx("div",{onClick:y=>{y.stopPropagation(),c==null||c(y)},className:"bs-avatar__add-story-button",children:_.jsx("span",{className:"bi-plus bs-avatar__add-story-button-icon"})}),m&&_.jsx("div",{className:"bs-avatar__badge",children:_.jsx(Cd,{label:r==="online"?"آنلاین":"به تازگی آنلاین بوده است",size:["28","32","40"].includes(t)?"sm":"md",children:_.jsx("span",{className:`bs-avatar__badge-bullet bs-avatar__badge-bullet--${r} `})})})]})};Gh.propTypes=dH,Gh.defaultProps={size:"32",status:"offline",storyStatus:"none",showAddStoryButton:!1},Gh.displayName="BsAvatar";var zs=T.memo(Gh);const fH={m:O.number,p:O.number,my:O.number,mx:O.number,mt:O.number,mb:O.number,mr:O.number,ml:O.number,py:O.number,px:O.number,pt:O.number,pb:O.number,pr:O.number,pl:O.number,gap:O.number,className:O.string,alignItems:O.oneOf(["center","flex-start","flex-end"]),flexDirection:O.oneOf(["row","column","row-reverse","column-reverse"]),display:O.oneOf(["block","flex","grid","inline","inline-block","inline-flex","inline-grid"]),justifyContent:O.oneOf(["center","flex-start","flex-end","space-between","space-around","space-evenly"])},PL={m:"bs-box--m-",p:"bs-box--p-",my:"bs-box--my-",mx:"bs-box--mx-",mt:"bs-box--mt-",mb:"bs-box--mb-",mr:"bs-box--mr-",ml:"bs-box--ml-",py:"bs-box--py-",px:"bs-box--px-",pt:"bs-box--pt-",pb:"bs-box--pb-",pr:"bs-box--pr-",pl:"bs-box--pl-",gap:"bs-box--gap-",display:"bs-box--",alignItems:"bs-box--ai-",flexDirection:"bs-box--fd-",justifyContent:"bs-box--jc-"},je=({style:n,className:e,children:t,...r})=>{const s=T.useMemo(()=>{const i=["bs-box"];for(const o in PL){const a=r[o];a!=null&&i.push(PL[o]+a)}return i},[r.m,r.p,r.gap,r.my,r.mx,r.mt,r.mb,r.mr,r.ml,r.py,r.px,r.pt,r.pb,r.pr,r.pl,r.display,r.alignItems,r.flexDirection,r.justifyContent]);return _.jsx("div",{style:n,className:jt(s,e),children:t})};je.propTypes=fH,je.defaultProps={},je.displayName="BsBox";const hH={className:O.string,variant:O.oneOf(["circle","ellipsis","logo"]),size:O.oneOf(["xs","sm","md","lg","xl","xx"]),color:O.oneOf(["primary","black","white","blue"])},Cr=({className:n,size:e="lg",color:t="primary",variant:r="circle"})=>_.jsxs("div",{className:jt("bs-loading",n),children:[r==="logo"&&_.jsx("img",{alt:"در حال بارگذاری",className:`bs-loading__logo bs-loading__logo--${e}`,src:"https://statics.basalam.com/public-94/admin/j50O7/06-10/LiBNLu4jlEfsjvuRFPtd9KukBAuNjCXVOiJPw5NJTMgdHJ17Ey.gif"}),r==="circle"&&_.jsxs("svg",{viewBox:"0 0 25 24",xmlns:"http://www.w3.org/2000/svg",className:`bs-loading__circle bs-loading__circle--${e}`,children:[_.jsx("path",{d:"M17.3396 21.9227C17.572 22.3992 17.3753 22.9778 16.8817 23.1714C15.2785 23.8002 13.555 24.078 11.8281 23.9812C9.78099 23.8664 7.79743 23.229 6.06664 22.1298C4.33586 21.0305 2.91559 19.5062 1.94131 17.7021C0.967042 15.898 0.471268 13.8744 0.501286 11.8243C0.531304 9.77419 1.08611 7.76596 2.11279 5.99119C3.13946 4.21641 4.60376 2.7343 6.36598 1.68623C8.12821 0.638165 10.1296 0.0591041 12.1792 0.0042892C13.9082 -0.0419508 15.6228 0.286165 17.2069 0.96165C17.6946 1.16961 17.8743 1.75374 17.6281 2.22326C17.3818 2.69279 16.8029 2.86912 16.312 2.66861C15.0211 2.14126 13.6314 1.88614 12.2305 1.9236C10.5088 1.96965 8.82769 2.45606 7.34742 3.33644C5.86715 4.21681 4.63715 5.46179 3.77474 6.9526C2.91234 8.44341 2.4463 10.1303 2.42108 11.8524C2.39587 13.5745 2.81232 15.2744 3.6307 16.7898C4.44909 18.3052 5.64212 19.5857 7.09598 20.509C8.54984 21.4323 10.216 21.9678 11.9356 22.0642C13.3348 22.1427 14.7314 21.9283 16.0372 21.439C16.5337 21.2529 17.1072 21.4462 17.3396 21.9227Z",className:`bs-loading__circle-path bs-loading__circle-path--${t}`}),_.jsx("path",{d:"M23.266 14.4445C23.783 14.5619 24.3014 14.2381 24.3771 13.7133C24.6508 11.8157 24.4665 9.87501 23.8332 8.05546C23.1999 6.2359 22.1394 4.60016 20.7466 3.28256C20.3614 2.9182 19.7541 2.98624 19.4217 3.39929C19.0892 3.81233 19.1584 4.41357 19.5379 4.78375C20.6534 5.87168 21.5048 7.20677 22.0199 8.68658C22.5349 10.1664 22.6965 11.7416 22.4975 13.287C22.4298 13.8129 22.7489 14.3271 23.266 14.4445Z",className:`bs-loading__circle-path bs-loading__circle-path--${t}`}),_.jsx("path",{d:"M18.5966 21.204C18.8894 21.646 19.4878 21.7699 19.905 21.4428C21.2441 20.3927 22.3447 19.0696 23.1333 17.5617C23.3791 17.0919 23.1482 16.526 22.6603 16.3186C22.1723 16.1112 21.6126 16.3414 21.3598 16.8074C20.7274 17.9728 19.8712 19.0022 18.8404 19.8362C18.4282 20.1697 18.3038 20.762 18.5966 21.204Z",className:`bs-loading__circle-path bs-loading__circle-path--${t}`})]}),r==="ellipsis"&&_.jsxs("div",{className:"bs-loading__ellipsis",children:[_.jsx("span",{className:`bs-loading__ellipsis-thing bs-loading__ellipsis-thing--${t} bs-loading__ellipsis-thing--${e}`}),_.jsx("span",{className:`bs-loading__ellipsis-thing bs-loading__ellipsis-thing--${t} bs-loading__ellipsis-thing--${e}`}),_.jsx("span",{className:`bs-loading__ellipsis-thing bs-loading__ellipsis-thing--${t} bs-loading__ellipsis-thing--${e}`})]})]});Cr.propTypes=hH,Cr.displayName="BsLoading",O.bool,O.node,O.object,O.string,O.bool,O.object,O.string,O.bool,O.string,O.oneOf(["sm","md","lg"]),O.oneOf(["primary","black","neutral"]),O.oneOfType([O.string,O.number]),O.string,O.string,O.oneOfType([O.string,O.element,O.func]),O.arrayOf(O.shape({icon:O.string,active:O.bool,attrs:O.object,title:O.string.isRequired,component:O.oneOfType([O.string,O.element,O.func])})).isRequired;const pH={form:O.string,href:O.string,inline:O.bool,square:O.bool,icon:O.string,loading:O.bool,onClick:O.func,disabled:O.bool,target:O.string,fullWidth:O.bool,className:O.string,"data-from":O.string,"data-meta":O.string,"data-component":O.string,color:O.oneOf(["primary","secondary"]),type:O.oneOf(["submit","reset","button"]),label:O.oneOfType([O.string,O.number]),size:O.oneOf(["xxs","xs","sm","md","lg","xl","xx"]),iconPosition:O.oneOf(["start","center-start","center-end","end"]),component:O.oneOfType([O.string,O.element,O.func]),variant:O.oneOf(["fill","outline","text","disabled","text-link","plain"])},H0=({href:n,icon:e,form:t,inline:r,square:s,target:i,loading:o,onClick:a,disabled:l,children:c,fullWidth:d,underlined:f,label:p="",size:m="lg",className:g="",type:v="button",variant:y="fill",color:b="primary",component:S="button","data-from":E,"data-meta":C,iconPosition:R="center-start","data-component":I})=>{const A=S,k=c||p,N=e&&_.jsx("i",{className:jt(e,"bs-button__icon",`bs-button__icon--${d?R:R==="start"?"center-start":R==="end"?"center-end":R}`,{"bs-button__icon--only":c===void 0&&p===""&&e})});let D="primary";D=y==="text-link"?"blue":y==="fill"&&b==="primary"?l?"primary":"white":b==="secondary"?"black":b;const M=jt(g,"bs-button",`bs-button--${m}`,`bs-button--${y}`,`bs-button--${y}`,`bs-button--${y}--${b}`,{"bs-button--inline":r,"bs-button--square":s,"bs-button--loading":o,"bs-button--full-width":d});return _.jsxs(A,{to:n,form:t,type:v,href:n,target:i,onClick:a,"data-from":E,"data-meta":C,className:M,disabled:l||o,"data-component":I,rel:i==="_blank"?"noopener noreferrer":void 0,children:[N,f&&(y==="text"||y==="text-link")?_.jsx("span",{className:"bs-button__underline",children:k}):k,o?_.jsx(Cr,{color:D}):null]})};H0.propTypes=pH,H0.displayName="BsButton";var Qe=T.memo(H0);const DL=({isLtr:n,isVertical:e,spaceBetween:t,slidesPerView:r})=>{const s=e?"margin-bottom":n?"margin-right":"margin-left";if(r==="auto")return`${s}: ${t??0}px;`;const i=typeof r=="number"?r:1,o=typeof t=="number"?t:0;return`flex: ${`0 0 calc(${100/i}% - ${Math.floor((i-1)*o/i)}px)`}; ${s}: ${o}px;`};function jL(n){return n!==null&&typeof n=="object"&&"constructor"in n&&n.constructor===Object}function G0(n,e){n===void 0&&(n={}),e===void 0&&(e={}),Object.keys(e).forEach(t=>{n[t]===void 0?n[t]=e[t]:jL(e[t])&&jL(n[t])&&Object.keys(e[t]).length>0&&G0(n[t],e[t])})}const FL={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function ri(){const n=typeof document<"u"?document:{};return G0(n,FL),n}const mH={document:FL,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:n=>typeof setTimeout>"u"?(n(),null):setTimeout(n,0),cancelAnimationFrame(n){typeof setTimeout<"u"&&clearTimeout(n)}};function ms(){const n=typeof window<"u"?window:{};return G0(n,mH),n}function Id(n,e){return e===void 0&&(e=0),setTimeout(n,e)}function yi(){return Date.now()}function gH(n,e){e===void 0&&(e="x");const t=ms();let r,s,i;const o=function(a){const l=ms();let c;return l.getComputedStyle&&(c=l.getComputedStyle(a,null)),!c&&a.currentStyle&&(c=a.currentStyle),c||(c=a.style),c}(n);return t.WebKitCSSMatrix?(s=o.transform||o.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(a=>a.replace(",",".")).join(", ")),i=new t.WebKitCSSMatrix(s==="none"?"":s)):(i=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),r=i.toString().split(",")),e==="x"&&(s=t.WebKitCSSMatrix?i.m41:r.length===16?parseFloat(r[12]):parseFloat(r[4])),e==="y"&&(s=t.WebKitCSSMatrix?i.m42:r.length===16?parseFloat(r[13]):parseFloat(r[5])),s||0}function Vh(n){return typeof n=="object"&&n!==null&&n.constructor&&Object.prototype.toString.call(n).slice(8,-1)==="Object"}function _H(n){return typeof window<"u"&&window.HTMLElement!==void 0?n instanceof HTMLElement:n&&(n.nodeType===1||n.nodeType===11)}function si(){const n=Object(arguments.length<=0?void 0:arguments[0]),e=["__proto__","constructor","prototype"];for(let t=1;t<arguments.length;t+=1){const r=t<0||arguments.length<=t?void 0:arguments[t];if(r!=null&&!_H(r)){const s=Object.keys(Object(r)).filter(i=>e.indexOf(i)<0);for(let i=0,o=s.length;i<o;i+=1){const a=s[i],l=Object.getOwnPropertyDescriptor(r,a);l!==void 0&&l.enumerable&&(Vh(n[a])&&Vh(r[a])?r[a].__swiper__?n[a]=r[a]:si(n[a],r[a]):!Vh(n[a])&&Vh(r[a])?(n[a]={},r[a].__swiper__?n[a]=r[a]:si(n[a],r[a])):n[a]=r[a])}}}return n}function Rd(n,e,t){n.style.setProperty(e,t)}function UL(n){let{swiper:e,targetPosition:t,side:r}=n;const s=ms(),i=-e.translate;let o,a=null;const l=e.params.speed;e.wrapperEl.style.scrollSnapType="none",s.cancelAnimationFrame(e.cssModeFrameID);const c=t>i?"next":"prev",d=(p,m)=>c==="next"&&p>=m||c==="prev"&&p<=m,f=()=>{o=new Date().getTime(),a===null&&(a=o);const p=Math.max(Math.min((o-a)/l,1),0),m=.5-Math.cos(p*Math.PI)/2;let g=i+m*(t-i);if(d(g,t)&&(g=t),e.wrapperEl.scrollTo({[r]:g}),d(g,t))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[r]:g})}),void s.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=s.requestAnimationFrame(f)};f()}function Vi(n,e){return e===void 0&&(e=""),[...n.children].filter(t=>t.matches(e))}function Wh(n,e){e===void 0&&(e=[]);const t=document.createElement(n);return t.classList.add(...Array.isArray(e)?e:[e]),t}function Ta(n,e){return ms().getComputedStyle(n,null).getPropertyValue(e)}function Kh(n){let e,t=n;if(t){for(e=0;(t=t.previousSibling)!==null;)t.nodeType===1&&(e+=1);return e}}function Yh(n,e){const t=[];let r=n.parentElement;for(;r;)e?r.matches(e)&&t.push(r):t.push(r),r=r.parentElement;return t}function V0(n,e){e&&n.addEventListener("transitionend",function t(r){r.target===n&&(e.call(n,r),n.removeEventListener("transitionend",t))})}function W0(n,e,t){const r=ms();return t?n[e==="width"?"offsetWidth":"offsetHeight"]+parseFloat(r.getComputedStyle(n,null).getPropertyValue(e==="width"?"margin-right":"margin-top"))+parseFloat(r.getComputedStyle(n,null).getPropertyValue(e==="width"?"margin-left":"margin-bottom")):n.offsetWidth}let K0,Y0,X0;function BL(){return K0||(K0=function(){const n=ms(),e=ri();return{smoothScroll:e.documentElement&&e.documentElement.style&&"scrollBehavior"in e.documentElement.style,touch:!!("ontouchstart"in n||n.DocumentTouch&&e instanceof n.DocumentTouch)}}()),K0}function vH(n){return n===void 0&&(n={}),Y0||(Y0=function(e){let{userAgent:t}=e===void 0?{}:e;const r=BL(),s=ms(),i=s.navigator.platform,o=t||s.navigator.userAgent,a={ios:!1,android:!1},l=s.screen.width,c=s.screen.height,d=o.match(/(Android);?[\s\/]+([\d.]+)?/);let f=o.match(/(iPad).*OS\s([\d_]+)/);const p=o.match(/(iPod)(.*OS\s([\d_]+))?/),m=!f&&o.match(/(iPhone\sOS|iOS)\s([\d_]+)/),g=i==="Win32";let v=i==="MacIntel";return!f&&v&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${l}x${c}`)>=0&&(f=o.match(/(Version)\/([\d.]+)/),f||(f=[0,1,"13_0_0"]),v=!1),d&&!g&&(a.os="android",a.android=!0),(f||m||p)&&(a.os="ios",a.ios=!0),a}(n)),Y0}function yH(){return X0||(X0=function(){const n=ms();let e=!1;function t(){const r=n.navigator.userAgent.toLowerCase();return r.indexOf("safari")>=0&&r.indexOf("chrome")<0&&r.indexOf("android")<0}if(t()){const r=String(n.navigator.userAgent);if(r.includes("Version/")){const[s,i]=r.split("Version/")[1].split(" ")[0].split(".").map(o=>Number(o));e=s<16||s===16&&i<2}}return{isSafari:e||t(),needPerspectiveFix:e,isWebView:/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(n.navigator.userAgent)}}()),X0}var bH={on(n,e,t){const r=this;if(!r.eventsListeners||r.destroyed||typeof e!="function")return r;const s=t?"unshift":"push";return n.split(" ").forEach(i=>{r.eventsListeners[i]||(r.eventsListeners[i]=[]),r.eventsListeners[i][s](e)}),r},once(n,e,t){const r=this;if(!r.eventsListeners||r.destroyed||typeof e!="function")return r;function s(){r.off(n,s),s.__emitterProxy&&delete s.__emitterProxy;for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];e.apply(r,o)}return s.__emitterProxy=e,r.on(n,s,t)},onAny(n,e){const t=this;if(!t.eventsListeners||t.destroyed||typeof n!="function")return t;const r=e?"unshift":"push";return t.eventsAnyListeners.indexOf(n)<0&&t.eventsAnyListeners[r](n),t},offAny(n){const e=this;if(!e.eventsListeners||e.destroyed||!e.eventsAnyListeners)return e;const t=e.eventsAnyListeners.indexOf(n);return t>=0&&e.eventsAnyListeners.splice(t,1),e},off(n,e){const t=this;return!t.eventsListeners||t.destroyed||t.eventsListeners&&n.split(" ").forEach(r=>{e===void 0?t.eventsListeners[r]=[]:t.eventsListeners[r]&&t.eventsListeners[r].forEach((s,i)=>{(s===e||s.__emitterProxy&&s.__emitterProxy===e)&&t.eventsListeners[r].splice(i,1)})}),t},emit(){const n=this;if(!n.eventsListeners||n.destroyed||!n.eventsListeners)return n;let e,t,r;for(var s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];return typeof i[0]=="string"||Array.isArray(i[0])?(e=i[0],t=i.slice(1,i.length),r=n):(e=i[0].events,t=i[0].data,r=i[0].context||n),t.unshift(r),(Array.isArray(e)?e:e.split(" ")).forEach(a=>{n.eventsAnyListeners&&n.eventsAnyListeners.length&&n.eventsAnyListeners.forEach(l=>{l.apply(r,[a,...t])}),n.eventsListeners&&n.eventsListeners[a]&&n.eventsListeners[a].forEach(l=>{l.apply(r,t)})}),n}};const Xh=(n,e)=>{if(!n||n.destroyed||!n.params)return;const t=e.closest(n.isElement?"swiper-slide":`.${n.params.slideClass}`);if(t){const r=t.querySelector(`.${n.params.lazyPreloaderClass}`);r&&r.remove()}},Q0=(n,e)=>{if(!n.slides[e])return;const t=n.slides[e].querySelector('[loading="lazy"]');t&&t.removeAttribute("loading")},J0=n=>{if(!n||n.destroyed||!n.params)return;let e=n.params.lazyPreloadPrevNext;const t=n.slides.length;if(!t||!e||e<0)return;e=Math.min(e,t);const r=n.params.slidesPerView==="auto"?n.slidesPerViewDynamic():Math.ceil(n.params.slidesPerView),s=n.activeIndex;if(n.params.grid&&n.params.grid.rows>1){const o=s,a=[o-e];return a.push(...Array.from({length:e}).map((l,c)=>o+r+c)),void n.slides.forEach((l,c)=>{a.includes(l.column)&&Q0(n,c)})}const i=s+r-1;if(n.params.rewind||n.params.loop)for(let o=s-e;o<=i+e;o+=1){const a=(o%t+t)%t;(a<s||a>i)&&Q0(n,a)}else for(let o=Math.max(s-e,0);o<=Math.min(i+e,t-1);o+=1)o!==s&&(o>i||o<s)&&Q0(n,o)};var xH={updateSize:function(){const n=this;let e,t;const r=n.el;e=n.params.width!==void 0&&n.params.width!==null?n.params.width:r.clientWidth,t=n.params.height!==void 0&&n.params.height!==null?n.params.height:r.clientHeight,e===0&&n.isHorizontal()||t===0&&n.isVertical()||(e=e-parseInt(Ta(r,"padding-left")||0,10)-parseInt(Ta(r,"padding-right")||0,10),t=t-parseInt(Ta(r,"padding-top")||0,10)-parseInt(Ta(r,"padding-bottom")||0,10),Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Object.assign(n,{width:e,height:t,size:n.isHorizontal()?e:t}))},updateSlides:function(){const n=this;function e(M){return n.isHorizontal()?M:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[M]}function t(M,F){return parseFloat(M.getPropertyValue(e(F))||0)}const r=n.params,{wrapperEl:s,slidesEl:i,size:o,rtlTranslate:a,wrongRTL:l}=n,c=n.virtual&&r.virtual.enabled,d=c?n.virtual.slides.length:n.slides.length,f=Vi(i,`.${n.params.slideClass}, swiper-slide`),p=c?n.virtual.slides.length:f.length;let m=[];const g=[],v=[];let y=r.slidesOffsetBefore;typeof y=="function"&&(y=r.slidesOffsetBefore.call(n));let b=r.slidesOffsetAfter;typeof b=="function"&&(b=r.slidesOffsetAfter.call(n));const S=n.snapGrid.length,E=n.slidesGrid.length;let C=r.spaceBetween,R=-y,I=0,A=0;if(o===void 0)return;typeof C=="string"&&C.indexOf("%")>=0?C=parseFloat(C.replace("%",""))/100*o:typeof C=="string"&&(C=parseFloat(C)),n.virtualSize=-C,f.forEach(M=>{a?M.style.marginLeft="":M.style.marginRight="",M.style.marginBottom="",M.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(Rd(s,"--swiper-centered-offset-before",""),Rd(s,"--swiper-centered-offset-after",""));const k=r.grid&&r.grid.rows>1&&n.grid;let N;k&&n.grid.initSlides(p);const D=r.slidesPerView==="auto"&&r.breakpoints&&Object.keys(r.breakpoints).filter(M=>r.breakpoints[M].slidesPerView!==void 0).length>0;for(let M=0;M<p;M+=1){let F;if(N=0,f[M]&&(F=f[M]),k&&n.grid.updateSlide(M,F,p,e),!f[M]||Ta(F,"display")!=="none"){if(r.slidesPerView==="auto"){D&&(f[M].style[e("width")]="");const U=getComputedStyle(F),$=F.style.transform,q=F.style.webkitTransform;if($&&(F.style.transform="none"),q&&(F.style.webkitTransform="none"),r.roundLengths)N=n.isHorizontal()?W0(F,"width",!0):W0(F,"height",!0);else{const G=t(U,"width"),V=t(U,"padding-left"),z=t(U,"padding-right"),B=t(U,"margin-left"),P=t(U,"margin-right"),H=U.getPropertyValue("box-sizing");if(H&&H==="border-box")N=G+B+P;else{const{clientWidth:Z,offsetWidth:Q}=F;N=G+V+z+B+P+(Q-Z)}}$&&(F.style.transform=$),q&&(F.style.webkitTransform=q),r.roundLengths&&(N=Math.floor(N))}else N=(o-(r.slidesPerView-1)*C)/r.slidesPerView,r.roundLengths&&(N=Math.floor(N)),f[M]&&(f[M].style[e("width")]=`${N}px`);f[M]&&(f[M].swiperSlideSize=N),v.push(N),r.centeredSlides?(R=R+N/2+I/2+C,I===0&&M!==0&&(R=R-o/2-C),M===0&&(R=R-o/2-C),Math.abs(R)<.001&&(R=0),r.roundLengths&&(R=Math.floor(R)),A%r.slidesPerGroup===0&&m.push(R),g.push(R)):(r.roundLengths&&(R=Math.floor(R)),(A-Math.min(n.params.slidesPerGroupSkip,A))%n.params.slidesPerGroup===0&&m.push(R),g.push(R),R=R+N+C),n.virtualSize+=N+C,I=N,A+=1}}if(n.virtualSize=Math.max(n.virtualSize,o)+b,a&&l&&(r.effect==="slide"||r.effect==="coverflow")&&(s.style.width=`${n.virtualSize+C}px`),r.setWrapperSize&&(s.style[e("width")]=`${n.virtualSize+C}px`),k&&n.grid.updateWrapperSize(N,m,e),!r.centeredSlides){const M=[];for(let F=0;F<m.length;F+=1){let U=m[F];r.roundLengths&&(U=Math.floor(U)),m[F]<=n.virtualSize-o&&M.push(U)}m=M,Math.floor(n.virtualSize-o)-Math.floor(m[m.length-1])>1&&m.push(n.virtualSize-o)}if(c&&r.loop){const M=v[0]+C;if(r.slidesPerGroup>1){const F=Math.ceil((n.virtual.slidesBefore+n.virtual.slidesAfter)/r.slidesPerGroup),U=M*r.slidesPerGroup;for(let $=0;$<F;$+=1)m.push(m[m.length-1]+U)}for(let F=0;F<n.virtual.slidesBefore+n.virtual.slidesAfter;F+=1)r.slidesPerGroup===1&&m.push(m[m.length-1]+M),g.push(g[g.length-1]+M),n.virtualSize+=M}if(m.length===0&&(m=[0]),C!==0){const M=n.isHorizontal()&&a?"marginLeft":e("marginRight");f.filter((F,U)=>!(r.cssMode&&!r.loop)||U!==f.length-1).forEach(F=>{F.style[M]=`${C}px`})}if(r.centeredSlides&&r.centeredSlidesBounds){let M=0;v.forEach(U=>{M+=U+(C||0)}),M-=C;const F=M-o;m=m.map(U=>U<=0?-y:U>F?F+b:U)}if(r.centerInsufficientSlides){let M=0;if(v.forEach(F=>{M+=F+(C||0)}),M-=C,M<o){const F=(o-M)/2;m.forEach((U,$)=>{m[$]=U-F}),g.forEach((U,$)=>{g[$]=U+F})}}if(Object.assign(n,{slides:f,snapGrid:m,slidesGrid:g,slidesSizesGrid:v}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){Rd(s,"--swiper-centered-offset-before",-m[0]+"px"),Rd(s,"--swiper-centered-offset-after",n.size/2-v[v.length-1]/2+"px");const M=-n.snapGrid[0],F=-n.slidesGrid[0];n.snapGrid=n.snapGrid.map(U=>U+M),n.slidesGrid=n.slidesGrid.map(U=>U+F)}if(p!==d&&n.emit("slidesLengthChange"),m.length!==S&&(n.params.watchOverflow&&n.checkOverflow(),n.emit("snapGridLengthChange")),g.length!==E&&n.emit("slidesGridLengthChange"),r.watchSlidesProgress&&n.updateSlidesOffset(),!(c||r.cssMode||r.effect!=="slide"&&r.effect!=="fade")){const M=`${r.containerModifierClass}backface-hidden`,F=n.el.classList.contains(M);p<=r.maxBackfaceHiddenSlides?F||n.el.classList.add(M):F&&n.el.classList.remove(M)}},updateAutoHeight:function(n){const e=this,t=[],r=e.virtual&&e.params.virtual.enabled;let s,i=0;typeof n=="number"?e.setTransition(n):n===!0&&e.setTransition(e.params.speed);const o=a=>r?e.slides[e.getSlideIndexByData(a)]:e.slides[a];if(e.params.slidesPerView!=="auto"&&e.params.slidesPerView>1)if(e.params.centeredSlides)(e.visibleSlides||[]).forEach(a=>{t.push(a)});else for(s=0;s<Math.ceil(e.params.slidesPerView);s+=1){const a=e.activeIndex+s;if(a>e.slides.length&&!r)break;t.push(o(a))}else t.push(o(e.activeIndex));for(s=0;s<t.length;s+=1)if(t[s]!==void 0){const a=t[s].offsetHeight;i=a>i?a:i}(i||i===0)&&(e.wrapperEl.style.height=`${i}px`)},updateSlidesOffset:function(){const n=this,e=n.slides,t=n.isElement?n.isHorizontal()?n.wrapperEl.offsetLeft:n.wrapperEl.offsetTop:0;for(let r=0;r<e.length;r+=1)e[r].swiperSlideOffset=(n.isHorizontal()?e[r].offsetLeft:e[r].offsetTop)-t-n.cssOverflowAdjustment()},updateSlidesProgress:function(n){n===void 0&&(n=this&&this.translate||0);const e=this,t=e.params,{slides:r,rtlTranslate:s,snapGrid:i}=e;if(r.length===0)return;r[0].swiperSlideOffset===void 0&&e.updateSlidesOffset();let o=-n;s&&(o=n),r.forEach(l=>{l.classList.remove(t.slideVisibleClass)}),e.visibleSlidesIndexes=[],e.visibleSlides=[];let a=t.spaceBetween;typeof a=="string"&&a.indexOf("%")>=0?a=parseFloat(a.replace("%",""))/100*e.size:typeof a=="string"&&(a=parseFloat(a));for(let l=0;l<r.length;l+=1){const c=r[l];let d=c.swiperSlideOffset;t.cssMode&&t.centeredSlides&&(d-=r[0].swiperSlideOffset);const f=(o+(t.centeredSlides?e.minTranslate():0)-d)/(c.swiperSlideSize+a),p=(o-i[0]+(t.centeredSlides?e.minTranslate():0)-d)/(c.swiperSlideSize+a),m=-(o-d),g=m+e.slidesSizesGrid[l];(m>=0&&m<e.size-1||g>1&&g<=e.size||m<=0&&g>=e.size)&&(e.visibleSlides.push(c),e.visibleSlidesIndexes.push(l),r[l].classList.add(t.slideVisibleClass)),c.progress=s?-f:f,c.originalProgress=s?-p:p}},updateProgress:function(n){const e=this;if(n===void 0){const d=e.rtlTranslate?-1:1;n=e&&e.translate&&e.translate*d||0}const t=e.params,r=e.maxTranslate()-e.minTranslate();let{progress:s,isBeginning:i,isEnd:o,progressLoop:a}=e;const l=i,c=o;if(r===0)s=0,i=!0,o=!0;else{s=(n-e.minTranslate())/r;const d=Math.abs(n-e.minTranslate())<1,f=Math.abs(n-e.maxTranslate())<1;i=d||s<=0,o=f||s>=1,d&&(s=0),f&&(s=1)}if(t.loop){const d=e.getSlideIndexByData(0),f=e.getSlideIndexByData(e.slides.length-1),p=e.slidesGrid[d],m=e.slidesGrid[f],g=e.slidesGrid[e.slidesGrid.length-1],v=Math.abs(n);a=v>=p?(v-p)/g:(v+g-m)/g,a>1&&(a-=1)}Object.assign(e,{progress:s,progressLoop:a,isBeginning:i,isEnd:o}),(t.watchSlidesProgress||t.centeredSlides&&t.autoHeight)&&e.updateSlidesProgress(n),i&&!l&&e.emit("reachBeginning toEdge"),o&&!c&&e.emit("reachEnd toEdge"),(l&&!i||c&&!o)&&e.emit("fromEdge"),e.emit("progress",s)},updateSlidesClasses:function(){const n=this,{slides:e,params:t,slidesEl:r,activeIndex:s}=n,i=n.virtual&&t.virtual.enabled,o=l=>Vi(r,`.${t.slideClass}${l}, swiper-slide${l}`)[0];let a;if(e.forEach(l=>{l.classList.remove(t.slideActiveClass,t.slideNextClass,t.slidePrevClass)}),i)if(t.loop){let l=s-n.virtual.slidesBefore;l<0&&(l=n.virtual.slides.length+l),l>=n.virtual.slides.length&&(l-=n.virtual.slides.length),a=o(`[data-swiper-slide-index="${l}"]`)}else a=o(`[data-swiper-slide-index="${s}"]`);else a=e[s];if(a){a.classList.add(t.slideActiveClass);let l=function(d,f){const p=[];for(;d.nextElementSibling;){const m=d.nextElementSibling;f?m.matches(f)&&p.push(m):p.push(m),d=m}return p}(a,`.${t.slideClass}, swiper-slide`)[0];t.loop&&!l&&(l=e[0]),l&&l.classList.add(t.slideNextClass);let c=function(d,f){const p=[];for(;d.previousElementSibling;){const m=d.previousElementSibling;f?m.matches(f)&&p.push(m):p.push(m),d=m}return p}(a,`.${t.slideClass}, swiper-slide`)[0];t.loop&&!c===0&&(c=e[e.length-1]),c&&c.classList.add(t.slidePrevClass)}n.emitSlidesClasses()},updateActiveIndex:function(n){const e=this,t=e.rtlTranslate?e.translate:-e.translate,{snapGrid:r,params:s,activeIndex:i,realIndex:o,snapIndex:a}=e;let l,c=n;const d=p=>{let m=p-e.virtual.slidesBefore;return m<0&&(m=e.virtual.slides.length+m),m>=e.virtual.slides.length&&(m-=e.virtual.slides.length),m};if(c===void 0&&(c=function(p){const{slidesGrid:m,params:g}=p,v=p.rtlTranslate?p.translate:-p.translate;let y;for(let b=0;b<m.length;b+=1)m[b+1]!==void 0?v>=m[b]&&v<m[b+1]-(m[b+1]-m[b])/2?y=b:v>=m[b]&&v<m[b+1]&&(y=b+1):v>=m[b]&&(y=b);return g.normalizeSlideIndex&&(y<0||y===void 0)&&(y=0),y}(e)),r.indexOf(t)>=0)l=r.indexOf(t);else{const p=Math.min(s.slidesPerGroupSkip,c);l=p+Math.floor((c-p)/s.slidesPerGroup)}if(l>=r.length&&(l=r.length-1),c===i)return l!==a&&(e.snapIndex=l,e.emit("snapIndexChange")),void(e.params.loop&&e.virtual&&e.params.virtual.enabled&&(e.realIndex=d(c)));let f;f=e.virtual&&s.virtual.enabled&&s.loop?d(c):e.slides[c]?parseInt(e.slides[c].getAttribute("data-swiper-slide-index")||c,10):c,Object.assign(e,{previousSnapIndex:a,snapIndex:l,previousRealIndex:o,realIndex:f,previousIndex:i,activeIndex:c}),e.initialized&&J0(e),e.emit("activeIndexChange"),e.emit("snapIndexChange"),o!==f&&e.emit("realIndexChange"),(e.initialized||e.params.runCallbacksOnInit)&&e.emit("slideChange")},updateClickedSlide:function(n){const e=this,t=e.params,r=n.closest(`.${t.slideClass}, swiper-slide`);let s,i=!1;if(r){for(let o=0;o<e.slides.length;o+=1)if(e.slides[o]===r){i=!0,s=o;break}}if(!r||!i)return e.clickedSlide=void 0,void(e.clickedIndex=void 0);e.clickedSlide=r,e.virtual&&e.params.virtual.enabled?e.clickedIndex=parseInt(r.getAttribute("data-swiper-slide-index"),10):e.clickedIndex=s,t.slideToClickedSlide&&e.clickedIndex!==void 0&&e.clickedIndex!==e.activeIndex&&e.slideToClickedSlide()}},SH={getTranslate:function(n){n===void 0&&(n=this.isHorizontal()?"x":"y");const{params:e,rtlTranslate:t,translate:r,wrapperEl:s}=this;if(e.virtualTranslate)return t?-r:r;if(e.cssMode)return r;let i=gH(s,n);return i+=this.cssOverflowAdjustment(),t&&(i=-i),i||0},setTranslate:function(n,e){const t=this,{rtlTranslate:r,params:s,wrapperEl:i,progress:o}=t;let a,l=0,c=0;t.isHorizontal()?l=r?-n:n:c=n,s.roundLengths&&(l=Math.floor(l),c=Math.floor(c)),t.previousTranslate=t.translate,t.translate=t.isHorizontal()?l:c,s.cssMode?i[t.isHorizontal()?"scrollLeft":"scrollTop"]=t.isHorizontal()?-l:-c:s.virtualTranslate||(t.isHorizontal()?l-=t.cssOverflowAdjustment():c-=t.cssOverflowAdjustment(),i.style.transform=`translate3d(${l}px, ${c}px, 0px)`);const d=t.maxTranslate()-t.minTranslate();a=d===0?0:(n-t.minTranslate())/d,a!==o&&t.updateProgress(n),t.emit("setTranslate",t.translate,e)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(n,e,t,r,s){n===void 0&&(n=0),e===void 0&&(e=this.params.speed),t===void 0&&(t=!0),r===void 0&&(r=!0);const i=this,{params:o,wrapperEl:a}=i;if(i.animating&&o.preventInteractionOnTransition)return!1;const l=i.minTranslate(),c=i.maxTranslate();let d;if(d=r&&n>l?l:r&&n<c?c:n,i.updateProgress(d),o.cssMode){const f=i.isHorizontal();if(e===0)a[f?"scrollLeft":"scrollTop"]=-d;else{if(!i.support.smoothScroll)return UL({swiper:i,targetPosition:-d,side:f?"left":"top"}),!0;a.scrollTo({[f?"left":"top"]:-d,behavior:"smooth"})}return!0}return e===0?(i.setTransition(0),i.setTranslate(d),t&&(i.emit("beforeTransitionStart",e,s),i.emit("transitionEnd"))):(i.setTransition(e),i.setTranslate(d),t&&(i.emit("beforeTransitionStart",e,s),i.emit("transitionStart")),i.animating||(i.animating=!0,i.onTranslateToWrapperTransitionEnd||(i.onTranslateToWrapperTransitionEnd=function(f){i&&!i.destroyed&&f.target===this&&(i.wrapperEl.removeEventListener("transitionend",i.onTranslateToWrapperTransitionEnd),i.onTranslateToWrapperTransitionEnd=null,delete i.onTranslateToWrapperTransitionEnd,t&&i.emit("transitionEnd"))}),i.wrapperEl.addEventListener("transitionend",i.onTranslateToWrapperTransitionEnd))),!0}};function $L(n){let{swiper:e,runCallbacks:t,direction:r,step:s}=n;const{activeIndex:i,previousIndex:o}=e;let a=r;if(a||(a=i>o?"next":i<o?"prev":"reset"),e.emit(`transition${s}`),t&&i!==o){if(a==="reset")return void e.emit(`slideResetTransition${s}`);e.emit(`slideChangeTransition${s}`),a==="next"?e.emit(`slideNextTransition${s}`):e.emit(`slidePrevTransition${s}`)}}var EH={slideTo:function(n,e,t,r,s){n===void 0&&(n=0),e===void 0&&(e=this.params.speed),t===void 0&&(t=!0),typeof n=="string"&&(n=parseInt(n,10));const i=this;let o=n;o<0&&(o=0);const{params:a,snapGrid:l,slidesGrid:c,previousIndex:d,activeIndex:f,rtlTranslate:p,wrapperEl:m,enabled:g}=i;if(i.animating&&a.preventInteractionOnTransition||!g&&!r&&!s)return!1;const v=Math.min(i.params.slidesPerGroupSkip,o);let y=v+Math.floor((o-v)/i.params.slidesPerGroup);y>=l.length&&(y=l.length-1);const b=-l[y];if(a.normalizeSlideIndex)for(let E=0;E<c.length;E+=1){const C=-Math.floor(100*b),R=Math.floor(100*c[E]),I=Math.floor(100*c[E+1]);c[E+1]!==void 0?C>=R&&C<I-(I-R)/2?o=E:C>=R&&C<I&&(o=E+1):C>=R&&(o=E)}if(i.initialized&&o!==f&&(!i.allowSlideNext&&(p?b>i.translate&&b>i.minTranslate():b<i.translate&&b<i.minTranslate())||!i.allowSlidePrev&&b>i.translate&&b>i.maxTranslate()&&(f||0)!==o))return!1;let S;if(o!==(d||0)&&t&&i.emit("beforeSlideChangeStart"),i.updateProgress(b),S=o>f?"next":o<f?"prev":"reset",p&&-b===i.translate||!p&&b===i.translate)return i.updateActiveIndex(o),a.autoHeight&&i.updateAutoHeight(),i.updateSlidesClasses(),a.effect!=="slide"&&i.setTranslate(b),S!=="reset"&&(i.transitionStart(t,S),i.transitionEnd(t,S)),!1;if(a.cssMode){const E=i.isHorizontal(),C=p?b:-b;if(e===0){const R=i.virtual&&i.params.virtual.enabled;R&&(i.wrapperEl.style.scrollSnapType="none",i._immediateVirtual=!0),R&&!i._cssModeVirtualInitialSet&&i.params.initialSlide>0?(i._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{m[E?"scrollLeft":"scrollTop"]=C})):m[E?"scrollLeft":"scrollTop"]=C,R&&requestAnimationFrame(()=>{i.wrapperEl.style.scrollSnapType="",i._immediateVirtual=!1})}else{if(!i.support.smoothScroll)return UL({swiper:i,targetPosition:C,side:E?"left":"top"}),!0;m.scrollTo({[E?"left":"top"]:C,behavior:"smooth"})}return!0}return i.setTransition(e),i.setTranslate(b),i.updateActiveIndex(o),i.updateSlidesClasses(),i.emit("beforeTransitionStart",e,r),i.transitionStart(t,S),e===0?i.transitionEnd(t,S):i.animating||(i.animating=!0,i.onSlideToWrapperTransitionEnd||(i.onSlideToWrapperTransitionEnd=function(E){i&&!i.destroyed&&E.target===this&&(i.wrapperEl.removeEventListener("transitionend",i.onSlideToWrapperTransitionEnd),i.onSlideToWrapperTransitionEnd=null,delete i.onSlideToWrapperTransitionEnd,i.transitionEnd(t,S))}),i.wrapperEl.addEventListener("transitionend",i.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(n,e,t,r){n===void 0&&(n=0),e===void 0&&(e=this.params.speed),t===void 0&&(t=!0),typeof n=="string"&&(n=parseInt(n,10));const s=this;let i=n;return s.params.loop&&(s.virtual&&s.params.virtual.enabled?i+=s.virtual.slidesBefore:i=s.getSlideIndexByData(i)),s.slideTo(i,e,t,r)},slideNext:function(n,e,t){n===void 0&&(n=this.params.speed),e===void 0&&(e=!0);const r=this,{enabled:s,params:i,animating:o}=r;if(!s)return r;let a=i.slidesPerGroup;i.slidesPerView==="auto"&&i.slidesPerGroup===1&&i.slidesPerGroupAuto&&(a=Math.max(r.slidesPerViewDynamic("current",!0),1));const l=r.activeIndex<i.slidesPerGroupSkip?1:a,c=r.virtual&&i.virtual.enabled;if(i.loop){if(o&&!c&&i.loopPreventsSliding)return!1;r.loopFix({direction:"next"}),r._clientLeft=r.wrapperEl.clientLeft}return i.rewind&&r.isEnd?r.slideTo(0,n,e,t):r.slideTo(r.activeIndex+l,n,e,t)},slidePrev:function(n,e,t){n===void 0&&(n=this.params.speed),e===void 0&&(e=!0);const r=this,{params:s,snapGrid:i,slidesGrid:o,rtlTranslate:a,enabled:l,animating:c}=r;if(!l)return r;const d=r.virtual&&s.virtual.enabled;if(s.loop){if(c&&!d&&s.loopPreventsSliding)return!1;r.loopFix({direction:"prev"}),r._clientLeft=r.wrapperEl.clientLeft}function f(y){return y<0?-Math.floor(Math.abs(y)):Math.floor(y)}const p=f(a?r.translate:-r.translate),m=i.map(y=>f(y));let g=i[m.indexOf(p)-1];if(g===void 0&&s.cssMode){let y;i.forEach((b,S)=>{p>=b&&(y=S)}),y!==void 0&&(g=i[y>0?y-1:y])}let v=0;if(g!==void 0&&(v=o.indexOf(g),v<0&&(v=r.activeIndex-1),s.slidesPerView==="auto"&&s.slidesPerGroup===1&&s.slidesPerGroupAuto&&(v=v-r.slidesPerViewDynamic("previous",!0)+1,v=Math.max(v,0))),s.rewind&&r.isBeginning){const y=r.params.virtual&&r.params.virtual.enabled&&r.virtual?r.virtual.slides.length-1:r.slides.length-1;return r.slideTo(y,n,e,t)}return r.slideTo(v,n,e,t)},slideReset:function(n,e,t){return n===void 0&&(n=this.params.speed),e===void 0&&(e=!0),this.slideTo(this.activeIndex,n,e,t)},slideToClosest:function(n,e,t,r){n===void 0&&(n=this.params.speed),e===void 0&&(e=!0),r===void 0&&(r=.5);const s=this;let i=s.activeIndex;const o=Math.min(s.params.slidesPerGroupSkip,i),a=o+Math.floor((i-o)/s.params.slidesPerGroup),l=s.rtlTranslate?s.translate:-s.translate;if(l>=s.snapGrid[a]){const c=s.snapGrid[a];l-c>(s.snapGrid[a+1]-c)*r&&(i+=s.params.slidesPerGroup)}else{const c=s.snapGrid[a-1];l-c<=(s.snapGrid[a]-c)*r&&(i-=s.params.slidesPerGroup)}return i=Math.max(i,0),i=Math.min(i,s.slidesGrid.length-1),s.slideTo(i,n,e,t)},slideToClickedSlide:function(){const n=this,{params:e,slidesEl:t}=n,r=e.slidesPerView==="auto"?n.slidesPerViewDynamic():e.slidesPerView;let s,i=n.clickedIndex;const o=n.isElement?"swiper-slide":`.${e.slideClass}`;if(e.loop){if(n.animating)return;s=parseInt(n.clickedSlide.getAttribute("data-swiper-slide-index"),10),e.centeredSlides?i<n.loopedSlides-r/2||i>n.slides.length-n.loopedSlides+r/2?(n.loopFix(),i=n.getSlideIndex(Vi(t,`${o}[data-swiper-slide-index="${s}"]`)[0]),Id(()=>{n.slideTo(i)})):n.slideTo(i):i>n.slides.length-r?(n.loopFix(),i=n.getSlideIndex(Vi(t,`${o}[data-swiper-slide-index="${s}"]`)[0]),Id(()=>{n.slideTo(i)})):n.slideTo(i)}else n.slideTo(i)}},wH={loopCreate:function(n){const e=this,{params:t,slidesEl:r}=e;!t.loop||e.virtual&&e.params.virtual.enabled||(Vi(r,`.${t.slideClass}, swiper-slide`).forEach((s,i)=>{s.setAttribute("data-swiper-slide-index",i)}),e.loopFix({slideRealIndex:n,direction:t.centeredSlides?void 0:"next"}))},loopFix:function(n){let{slideRealIndex:e,slideTo:t=!0,direction:r,setTranslate:s,activeSlideIndex:i,byController:o,byMousewheel:a}=n===void 0?{}:n;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:c,allowSlidePrev:d,allowSlideNext:f,slidesEl:p,params:m}=l;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&m.virtual.enabled)return t&&(m.centeredSlides||l.snapIndex!==0?m.centeredSlides&&l.snapIndex<m.slidesPerView?l.slideTo(l.virtual.slides.length+l.snapIndex,0,!1,!0):l.snapIndex===l.snapGrid.length-1&&l.slideTo(l.virtual.slidesBefore,0,!1,!0):l.slideTo(l.virtual.slides.length,0,!1,!0)),l.allowSlidePrev=d,l.allowSlideNext=f,void l.emit("loopFix");const g=m.slidesPerView==="auto"?l.slidesPerViewDynamic():Math.ceil(parseFloat(m.slidesPerView,10));let v=m.loopedSlides||g;v%m.slidesPerGroup!==0&&(v+=m.slidesPerGroup-v%m.slidesPerGroup),l.loopedSlides=v;const y=[],b=[];let S=l.activeIndex;i===void 0?i=l.getSlideIndex(l.slides.filter(A=>A.classList.contains(m.slideActiveClass))[0]):S=i;const E=r==="next"||!r,C=r==="prev"||!r;let R=0,I=0;if(i<v){R=Math.max(v-i,m.slidesPerGroup);for(let A=0;A<v-i;A+=1){const k=A-Math.floor(A/c.length)*c.length;y.push(c.length-k-1)}}else if(i>l.slides.length-2*v){I=Math.max(i-(l.slides.length-2*v),m.slidesPerGroup);for(let A=0;A<I;A+=1){const k=A-Math.floor(A/c.length)*c.length;b.push(k)}}if(C&&y.forEach(A=>{l.slides[A].swiperLoopMoveDOM=!0,p.prepend(l.slides[A]),l.slides[A].swiperLoopMoveDOM=!1}),E&&b.forEach(A=>{l.slides[A].swiperLoopMoveDOM=!0,p.append(l.slides[A]),l.slides[A].swiperLoopMoveDOM=!1}),l.recalcSlides(),m.slidesPerView==="auto"&&l.updateSlides(),m.watchSlidesProgress&&l.updateSlidesOffset(),t){if(y.length>0&&C)if(e===void 0){const A=l.slidesGrid[S],k=l.slidesGrid[S+R]-A;a?l.setTranslate(l.translate-k):(l.slideTo(S+R,0,!1,!0),s&&(l.touches[l.isHorizontal()?"startX":"startY"]+=k))}else s&&l.slideToLoop(e,0,!1,!0);else if(b.length>0&&E)if(e===void 0){const A=l.slidesGrid[S],k=l.slidesGrid[S-I]-A;a?l.setTranslate(l.translate-k):(l.slideTo(S-I,0,!1,!0),s&&(l.touches[l.isHorizontal()?"startX":"startY"]+=k))}else l.slideToLoop(e,0,!1,!0)}if(l.allowSlidePrev=d,l.allowSlideNext=f,l.controller&&l.controller.control&&!o){const A={slideRealIndex:e,slideTo:!1,direction:r,setTranslate:s,activeSlideIndex:i,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach(k=>{!k.destroyed&&k.params.loop&&k.loopFix(A)}):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix(A)}l.emit("loopFix")},loopDestroy:function(){const n=this,{params:e,slidesEl:t}=n;if(!e.loop||n.virtual&&n.params.virtual.enabled)return;n.recalcSlides();const r=[];n.slides.forEach(s=>{const i=s.swiperSlideIndex===void 0?1*s.getAttribute("data-swiper-slide-index"):s.swiperSlideIndex;r[i]=s}),n.slides.forEach(s=>{s.removeAttribute("data-swiper-slide-index")}),r.forEach(s=>{t.append(s)}),n.recalcSlides(),n.slideTo(n.realIndex,0)}};function TH(n){const e=this,t=ri(),r=ms(),s=e.touchEventsData;s.evCache.push(n);const{params:i,touches:o,enabled:a}=e;if(!a||!i.simulateTouch&&n.pointerType==="mouse"||e.animating&&i.preventInteractionOnTransition)return;!e.animating&&i.cssMode&&i.loop&&e.loopFix();let l=n;l.originalEvent&&(l=l.originalEvent);let c=l.target;if(i.touchEventsTarget==="wrapper"&&!e.wrapperEl.contains(c)||"which"in l&&l.which===3||"button"in l&&l.button>0||s.isTouched&&s.isMoved)return;const d=!!i.noSwipingClass&&i.noSwipingClass!=="",f=n.composedPath?n.composedPath():n.path;d&&l.target&&l.target.shadowRoot&&f&&(c=f[0]);const p=i.noSwipingSelector?i.noSwipingSelector:`.${i.noSwipingClass}`,m=!(!l.target||!l.target.shadowRoot);if(i.noSwiping&&(m?function(C,R){return R===void 0&&(R=this),function I(A){if(!A||A===ri()||A===ms())return null;A.assignedSlot&&(A=A.assignedSlot);const k=A.closest(C);return k||A.getRootNode?k||I(A.getRootNode().host):null}(R)}(p,c):c.closest(p)))return void(e.allowClick=!0);if(i.swipeHandler&&!c.closest(i.swipeHandler))return;o.currentX=l.pageX,o.currentY=l.pageY;const g=o.currentX,v=o.currentY,y=i.edgeSwipeDetection||i.iOSEdgeSwipeDetection,b=i.edgeSwipeThreshold||i.iOSEdgeSwipeThreshold;if(y&&(g<=b||g>=r.innerWidth-b)){if(y!=="prevent")return;n.preventDefault()}Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=g,o.startY=v,s.touchStartTime=yi(),e.allowClick=!0,e.updateSize(),e.swipeDirection=void 0,i.threshold>0&&(s.allowThresholdMove=!1);let S=!0;c.matches(s.focusableElements)&&(S=!1,c.nodeName==="SELECT"&&(s.isTouched=!1)),t.activeElement&&t.activeElement.matches(s.focusableElements)&&t.activeElement!==c&&t.activeElement.blur();const E=S&&e.allowTouchMove&&i.touchStartPreventDefault;!i.touchStartForcePreventDefault&&!E||c.isContentEditable||l.preventDefault(),i.freeMode&&i.freeMode.enabled&&e.freeMode&&e.animating&&!i.cssMode&&e.freeMode.onTouchStart(),e.emit("touchStart",l)}function CH(n){const e=ri(),t=this,r=t.touchEventsData,{params:s,touches:i,rtlTranslate:o,enabled:a}=t;if(!a||!s.simulateTouch&&n.pointerType==="mouse")return;let l=n;if(l.originalEvent&&(l=l.originalEvent),!r.isTouched)return void(r.startMoving&&r.isScrolling&&t.emit("touchMoveOpposite",l));const c=r.evCache.findIndex(I=>I.pointerId===l.pointerId);c>=0&&(r.evCache[c]=l);const d=r.evCache.length>1?r.evCache[0]:l,f=d.pageX,p=d.pageY;if(l.preventedByNestedSwiper)return i.startX=f,void(i.startY=p);if(!t.allowTouchMove)return l.target.matches(r.focusableElements)||(t.allowClick=!1),void(r.isTouched&&(Object.assign(i,{startX:f,startY:p,prevX:t.touches.currentX,prevY:t.touches.currentY,currentX:f,currentY:p}),r.touchStartTime=yi()));if(s.touchReleaseOnEdges&&!s.loop){if(t.isVertical()){if(p<i.startY&&t.translate<=t.maxTranslate()||p>i.startY&&t.translate>=t.minTranslate())return r.isTouched=!1,void(r.isMoved=!1)}else if(f<i.startX&&t.translate<=t.maxTranslate()||f>i.startX&&t.translate>=t.minTranslate())return}if(e.activeElement&&l.target===e.activeElement&&l.target.matches(r.focusableElements))return r.isMoved=!0,void(t.allowClick=!1);if(r.allowTouchCallbacks&&t.emit("touchMove",l),l.targetTouches&&l.targetTouches.length>1)return;i.currentX=f,i.currentY=p;const m=i.currentX-i.startX,g=i.currentY-i.startY;if(t.params.threshold&&Math.sqrt(m**2+g**2)<t.params.threshold)return;if(r.isScrolling===void 0){let I;t.isHorizontal()&&i.currentY===i.startY||t.isVertical()&&i.currentX===i.startX?r.isScrolling=!1:m*m+g*g>=25&&(I=180*Math.atan2(Math.abs(g),Math.abs(m))/Math.PI,r.isScrolling=t.isHorizontal()?I>s.touchAngle:90-I>s.touchAngle)}if(r.isScrolling&&t.emit("touchMoveOpposite",l),r.startMoving===void 0&&(i.currentX===i.startX&&i.currentY===i.startY||(r.startMoving=!0)),r.isScrolling||t.zoom&&t.params.zoom&&t.params.zoom.enabled&&r.evCache.length>1)return void(r.isTouched=!1);if(!r.startMoving)return;t.allowClick=!1,!s.cssMode&&l.cancelable&&l.preventDefault(),s.touchMoveStopPropagation&&!s.nested&&l.stopPropagation();let v=t.isHorizontal()?m:g,y=t.isHorizontal()?i.currentX-i.previousX:i.currentY-i.previousY;s.oneWayMovement&&(v=Math.abs(v)*(o?1:-1),y=Math.abs(y)*(o?1:-1)),i.diff=v,v*=s.touchRatio,o&&(v=-v,y=-y);const b=t.touchesDirection;t.swipeDirection=v>0?"prev":"next",t.touchesDirection=y>0?"prev":"next";const S=t.params.loop&&!s.cssMode;if(!r.isMoved){if(S&&t.loopFix({direction:t.swipeDirection}),r.startTranslate=t.getTranslate(),t.setTransition(0),t.animating){const I=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0});t.wrapperEl.dispatchEvent(I)}r.allowMomentumBounce=!1,!s.grabCursor||t.allowSlideNext!==!0&&t.allowSlidePrev!==!0||t.setGrabCursor(!0),t.emit("sliderFirstMove",l)}let E;r.isMoved&&b!==t.touchesDirection&&S&&Math.abs(v)>=1&&(t.loopFix({direction:t.swipeDirection,setTranslate:!0}),E=!0),t.emit("sliderMove",l),r.isMoved=!0,r.currentTranslate=v+r.startTranslate;let C=!0,R=s.resistanceRatio;if(s.touchReleaseOnEdges&&(R=0),v>0?(S&&!E&&r.currentTranslate>(s.centeredSlides?t.minTranslate()-t.size/2:t.minTranslate())&&t.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),r.currentTranslate>t.minTranslate()&&(C=!1,s.resistance&&(r.currentTranslate=t.minTranslate()-1+(-t.minTranslate()+r.startTranslate+v)**R))):v<0&&(S&&!E&&r.currentTranslate<(s.centeredSlides?t.maxTranslate()+t.size/2:t.maxTranslate())&&t.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:t.slides.length-(s.slidesPerView==="auto"?t.slidesPerViewDynamic():Math.ceil(parseFloat(s.slidesPerView,10)))}),r.currentTranslate<t.maxTranslate()&&(C=!1,s.resistance&&(r.currentTranslate=t.maxTranslate()+1-(t.maxTranslate()-r.startTranslate-v)**R))),C&&(l.preventedByNestedSwiper=!0),!t.allowSlideNext&&t.swipeDirection==="next"&&r.currentTranslate<r.startTranslate&&(r.currentTranslate=r.startTranslate),!t.allowSlidePrev&&t.swipeDirection==="prev"&&r.currentTranslate>r.startTranslate&&(r.currentTranslate=r.startTranslate),t.allowSlidePrev||t.allowSlideNext||(r.currentTranslate=r.startTranslate),s.threshold>0){if(!(Math.abs(v)>s.threshold||r.allowThresholdMove))return void(r.currentTranslate=r.startTranslate);if(!r.allowThresholdMove)return r.allowThresholdMove=!0,i.startX=i.currentX,i.startY=i.currentY,r.currentTranslate=r.startTranslate,void(i.diff=t.isHorizontal()?i.currentX-i.startX:i.currentY-i.startY)}s.followFinger&&!s.cssMode&&((s.freeMode&&s.freeMode.enabled&&t.freeMode||s.watchSlidesProgress)&&(t.updateActiveIndex(),t.updateSlidesClasses()),s.freeMode&&s.freeMode.enabled&&t.freeMode&&t.freeMode.onTouchMove(),t.updateProgress(r.currentTranslate),t.setTranslate(r.currentTranslate))}function IH(n){const e=this,t=e.touchEventsData,r=t.evCache.findIndex(E=>E.pointerId===n.pointerId);if(r>=0&&t.evCache.splice(r,1),["pointercancel","pointerout","pointerleave"].includes(n.type)&&!(n.type==="pointercancel"&&(e.browser.isSafari||e.browser.isWebView)))return;const{params:s,touches:i,rtlTranslate:o,slidesGrid:a,enabled:l}=e;if(!l||!s.simulateTouch&&n.pointerType==="mouse")return;let c=n;if(c.originalEvent&&(c=c.originalEvent),t.allowTouchCallbacks&&e.emit("touchEnd",c),t.allowTouchCallbacks=!1,!t.isTouched)return t.isMoved&&s.grabCursor&&e.setGrabCursor(!1),t.isMoved=!1,void(t.startMoving=!1);s.grabCursor&&t.isMoved&&t.isTouched&&(e.allowSlideNext===!0||e.allowSlidePrev===!0)&&e.setGrabCursor(!1);const d=yi(),f=d-t.touchStartTime;if(e.allowClick){const E=c.path||c.composedPath&&c.composedPath();e.updateClickedSlide(E&&E[0]||c.target),e.emit("tap click",c),f<300&&d-t.lastClickTime<300&&e.emit("doubleTap doubleClick",c)}if(t.lastClickTime=yi(),Id(()=>{e.destroyed||(e.allowClick=!0)}),!t.isTouched||!t.isMoved||!e.swipeDirection||i.diff===0||t.currentTranslate===t.startTranslate)return t.isTouched=!1,t.isMoved=!1,void(t.startMoving=!1);let p;if(t.isTouched=!1,t.isMoved=!1,t.startMoving=!1,p=s.followFinger?o?e.translate:-e.translate:-t.currentTranslate,s.cssMode)return;if(s.freeMode&&s.freeMode.enabled)return void e.freeMode.onTouchEnd({currentPos:p});let m=0,g=e.slidesSizesGrid[0];for(let E=0;E<a.length;E+=E<s.slidesPerGroupSkip?1:s.slidesPerGroup){const C=E<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;a[E+C]!==void 0?p>=a[E]&&p<a[E+C]&&(m=E,g=a[E+C]-a[E]):p>=a[E]&&(m=E,g=a[a.length-1]-a[a.length-2])}let v=null,y=null;s.rewind&&(e.isBeginning?y=s.virtual&&s.virtual.enabled&&e.virtual?e.virtual.slides.length-1:e.slides.length-1:e.isEnd&&(v=0));const b=(p-a[m])/g,S=m<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;if(f>s.longSwipesMs){if(!s.longSwipes)return void e.slideTo(e.activeIndex);e.swipeDirection==="next"&&(b>=s.longSwipesRatio?e.slideTo(s.rewind&&e.isEnd?v:m+S):e.slideTo(m)),e.swipeDirection==="prev"&&(b>1-s.longSwipesRatio?e.slideTo(m+S):y!==null&&b<0&&Math.abs(b)>s.longSwipesRatio?e.slideTo(y):e.slideTo(m))}else{if(!s.shortSwipes)return void e.slideTo(e.activeIndex);e.navigation&&(c.target===e.navigation.nextEl||c.target===e.navigation.prevEl)?c.target===e.navigation.nextEl?e.slideTo(m+S):e.slideTo(m):(e.swipeDirection==="next"&&e.slideTo(v!==null?v:m+S),e.swipeDirection==="prev"&&e.slideTo(y!==null?y:m))}}function zL(){const n=this,{params:e,el:t}=n;if(t&&t.offsetWidth===0)return;e.breakpoints&&n.setBreakpoint();const{allowSlideNext:r,allowSlidePrev:s,snapGrid:i}=n,o=n.virtual&&n.params.virtual.enabled;n.allowSlideNext=!0,n.allowSlidePrev=!0,n.updateSize(),n.updateSlides(),n.updateSlidesClasses();const a=o&&e.loop;!(e.slidesPerView==="auto"||e.slidesPerView>1)||!n.isEnd||n.isBeginning||n.params.centeredSlides||a?n.params.loop&&!o?n.slideToLoop(n.realIndex,0,!1,!0):n.slideTo(n.activeIndex,0,!1,!0):n.slideTo(n.slides.length-1,0,!1,!0),n.autoplay&&n.autoplay.running&&n.autoplay.paused&&(clearTimeout(n.autoplay.resizeTimeout),n.autoplay.resizeTimeout=setTimeout(()=>{n.autoplay&&n.autoplay.running&&n.autoplay.paused&&n.autoplay.resume()},500)),n.allowSlidePrev=s,n.allowSlideNext=r,n.params.watchOverflow&&i!==n.snapGrid&&n.checkOverflow()}function RH(n){const e=this;e.enabled&&(e.allowClick||(e.params.preventClicks&&n.preventDefault(),e.params.preventClicksPropagation&&e.animating&&(n.stopPropagation(),n.stopImmediatePropagation())))}function AH(){const n=this,{wrapperEl:e,rtlTranslate:t,enabled:r}=n;if(!r)return;let s;n.previousTranslate=n.translate,n.isHorizontal()?n.translate=-e.scrollLeft:n.translate=-e.scrollTop,n.translate===0&&(n.translate=0),n.updateActiveIndex(),n.updateSlidesClasses();const i=n.maxTranslate()-n.minTranslate();s=i===0?0:(n.translate-n.minTranslate())/i,s!==n.progress&&n.updateProgress(t?-n.translate:n.translate),n.emit("setTranslate",n.translate,!1)}function kH(n){const e=this;Xh(e,n.target),e.params.cssMode||e.params.slidesPerView!=="auto"&&!e.params.autoHeight||e.update()}let qL=!1;function LH(){}const HL=(n,e)=>{const t=ri(),{params:r,el:s,wrapperEl:i,device:o}=n,a=!!r.nested,l=e==="on"?"addEventListener":"removeEventListener",c=e;s[l]("pointerdown",n.onTouchStart,{passive:!1}),t[l]("pointermove",n.onTouchMove,{passive:!1,capture:a}),t[l]("pointerup",n.onTouchEnd,{passive:!0}),t[l]("pointercancel",n.onTouchEnd,{passive:!0}),t[l]("pointerout",n.onTouchEnd,{passive:!0}),t[l]("pointerleave",n.onTouchEnd,{passive:!0}),(r.preventClicks||r.preventClicksPropagation)&&s[l]("click",n.onClick,!0),r.cssMode&&i[l]("scroll",n.onScroll),r.updateOnWindowResize?n[c](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",zL,!0):n[c]("observerUpdate",zL,!0),s[l]("load",n.onLoad,{capture:!0})},GL=(n,e)=>n.grid&&e.grid&&e.grid.rows>1;var MH={setBreakpoint:function(){const n=this,{realIndex:e,initialized:t,params:r,el:s}=n,i=r.breakpoints;if(!i||i&&Object.keys(i).length===0)return;const o=n.getBreakpoint(i,n.params.breakpointsBase,n.el);if(!o||n.currentBreakpoint===o)return;const a=(o in i?i[o]:void 0)||n.originalParams,l=GL(n,r),c=GL(n,a),d=r.enabled;l&&!c?(s.classList.remove(`${r.containerModifierClass}grid`,`${r.containerModifierClass}grid-column`),n.emitContainerClasses()):!l&&c&&(s.classList.add(`${r.containerModifierClass}grid`),(a.grid.fill&&a.grid.fill==="column"||!a.grid.fill&&r.grid.fill==="column")&&s.classList.add(`${r.containerModifierClass}grid-column`),n.emitContainerClasses()),["navigation","pagination","scrollbar"].forEach(g=>{if(a[g]===void 0)return;const v=r[g]&&r[g].enabled,y=a[g]&&a[g].enabled;v&&!y&&n[g].disable(),!v&&y&&n[g].enable()});const f=a.direction&&a.direction!==r.direction,p=r.loop&&(a.slidesPerView!==r.slidesPerView||f);f&&t&&n.changeDirection(),si(n.params,a);const m=n.params.enabled;Object.assign(n,{allowTouchMove:n.params.allowTouchMove,allowSlideNext:n.params.allowSlideNext,allowSlidePrev:n.params.allowSlidePrev}),d&&!m?n.disable():!d&&m&&n.enable(),n.currentBreakpoint=o,n.emit("_beforeBreakpoint",a),p&&t&&(n.loopDestroy(),n.loopCreate(e),n.updateSlides()),n.emit("breakpoint",a)},getBreakpoint:function(n,e,t){if(e===void 0&&(e="window"),!n||e==="container"&&!t)return;let r=!1;const s=ms(),i=e==="window"?s.innerHeight:t.clientHeight,o=Object.keys(n).map(a=>{if(typeof a=="string"&&a.indexOf("@")===0){const l=parseFloat(a.substr(1));return{value:i*l,point:a}}return{value:a,point:a}});o.sort((a,l)=>parseInt(a.value,10)-parseInt(l.value,10));for(let a=0;a<o.length;a+=1){const{point:l,value:c}=o[a];e==="window"?s.matchMedia(`(min-width: ${c}px)`).matches&&(r=l):c<=t.clientWidth&&(r=l)}return r||"max"}},VL={init:!0,direction:"horizontal",oneWayMovement:!1,touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopedSlides:null,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function NH(n,e){return function(t){t===void 0&&(t={});const r=Object.keys(t)[0],s=t[r];typeof s=="object"&&s!==null?(["navigation","pagination","scrollbar"].indexOf(r)>=0&&n[r]===!0&&(n[r]={auto:!0}),r in n&&"enabled"in s&&(n[r]===!0&&(n[r]={enabled:!0}),typeof n[r]!="object"||"enabled"in n[r]||(n[r].enabled=!0),n[r]||(n[r]={enabled:!1})),si(e,t)):si(e,t)}}const Z0={eventsEmitter:bH,update:xH,translate:SH,transition:{setTransition:function(n,e){const t=this;t.params.cssMode||(t.wrapperEl.style.transitionDuration=`${n}ms`),t.emit("setTransition",n,e)},transitionStart:function(n,e){n===void 0&&(n=!0);const t=this,{params:r}=t;r.cssMode||(r.autoHeight&&t.updateAutoHeight(),$L({swiper:t,runCallbacks:n,direction:e,step:"Start"}))},transitionEnd:function(n,e){n===void 0&&(n=!0);const t=this,{params:r}=t;t.animating=!1,r.cssMode||(t.setTransition(0),$L({swiper:t,runCallbacks:n,direction:e,step:"End"}))}},slide:EH,loop:wH,grabCursor:{setGrabCursor:function(n){const e=this;if(!e.params.simulateTouch||e.params.watchOverflow&&e.isLocked||e.params.cssMode)return;const t=e.params.touchEventsTarget==="container"?e.el:e.wrapperEl;e.isElement&&(e.__preventObserver__=!0),t.style.cursor="move",t.style.cursor=n?"grabbing":"grab",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1})},unsetGrabCursor:function(){const n=this;n.params.watchOverflow&&n.isLocked||n.params.cssMode||(n.isElement&&(n.__preventObserver__=!0),n[n.params.touchEventsTarget==="container"?"el":"wrapperEl"].style.cursor="",n.isElement&&requestAnimationFrame(()=>{n.__preventObserver__=!1}))}},events:{attachEvents:function(){const n=this,e=ri(),{params:t}=n;n.onTouchStart=TH.bind(n),n.onTouchMove=CH.bind(n),n.onTouchEnd=IH.bind(n),t.cssMode&&(n.onScroll=AH.bind(n)),n.onClick=RH.bind(n),n.onLoad=kH.bind(n),qL||(e.addEventListener("touchstart",LH),qL=!0),HL(n,"on")},detachEvents:function(){HL(this,"off")}},breakpoints:MH,checkOverflow:{checkOverflow:function(){const n=this,{isLocked:e,params:t}=n,{slidesOffsetBefore:r}=t;if(r){const s=n.slides.length-1,i=n.slidesGrid[s]+n.slidesSizesGrid[s]+2*r;n.isLocked=n.size>i}else n.isLocked=n.snapGrid.length===1;t.allowSlideNext===!0&&(n.allowSlideNext=!n.isLocked),t.allowSlidePrev===!0&&(n.allowSlidePrev=!n.isLocked),e&&e!==n.isLocked&&(n.isEnd=!1),e!==n.isLocked&&n.emit(n.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const n=this,{classNames:e,params:t,rtl:r,el:s,device:i}=n,o=function(a,l){const c=[];return a.forEach(d=>{typeof d=="object"?Object.keys(d).forEach(f=>{d[f]&&c.push(l+f)}):typeof d=="string"&&c.push(l+d)}),c}(["initialized",t.direction,{"free-mode":n.params.freeMode&&t.freeMode.enabled},{autoheight:t.autoHeight},{rtl:r},{grid:t.grid&&t.grid.rows>1},{"grid-column":t.grid&&t.grid.rows>1&&t.grid.fill==="column"},{android:i.android},{ios:i.ios},{"css-mode":t.cssMode},{centered:t.cssMode&&t.centeredSlides},{"watch-progress":t.watchSlidesProgress}],t.containerModifierClass);e.push(...o),s.classList.add(...e),n.emitContainerClasses()},removeClasses:function(){const{el:n,classNames:e}=this;n.classList.remove(...e),this.emitContainerClasses()}}},eb={};let Ad=class ya{constructor(){let e,t;for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];s.length===1&&s[0].constructor&&Object.prototype.toString.call(s[0]).slice(8,-1)==="Object"?t=s[0]:[e,t]=s,t||(t={}),t=si({},t),e&&!t.el&&(t.el=e);const o=ri();if(t.el&&typeof t.el=="string"&&o.querySelectorAll(t.el).length>1){const d=[];return o.querySelectorAll(t.el).forEach(f=>{const p=si({},t,{el:f});d.push(new ya(p))}),d}const a=this;a.__swiper__=!0,a.support=BL(),a.device=vH({userAgent:t.userAgent}),a.browser=yH(),a.eventsListeners={},a.eventsAnyListeners=[],a.modules=[...a.__modules__],t.modules&&Array.isArray(t.modules)&&a.modules.push(...t.modules);const l={};a.modules.forEach(d=>{d({params:t,swiper:a,extendParams:NH(t,l),on:a.on.bind(a),once:a.once.bind(a),off:a.off.bind(a),emit:a.emit.bind(a)})});const c=si({},VL,l);return a.params=si({},c,eb,t),a.originalParams=si({},a.params),a.passedParams=si({},t),a.params&&a.params.on&&Object.keys(a.params.on).forEach(d=>{a.on(d,a.params.on[d])}),a.params&&a.params.onAny&&a.onAny(a.params.onAny),Object.assign(a,{enabled:a.params.enabled,el:e,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>a.params.direction==="horizontal",isVertical:()=>a.params.direction==="vertical",activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:a.params.allowSlideNext,allowSlidePrev:a.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:a.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,evCache:[]},allowClick:!0,allowTouchMove:a.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),a.emit("_swiper"),a.params.init&&a.init(),a}getSlideIndex(e){const{slidesEl:t,params:r}=this,s=Kh(Vi(t,`.${r.slideClass}, swiper-slide`)[0]);return Kh(e)-s}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0])}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=Vi(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const r=this;e=Math.min(Math.max(e,0),1);const s=r.minTranslate(),i=(r.maxTranslate()-s)*e+s;r.translateTo(i,t===void 0?0:t),r.updateActiveIndex(),r.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter(r=>r.indexOf("swiper")===0||r.indexOf(e.params.containerModifierClass)===0);e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter(r=>r.indexOf("swiper-slide")===0||r.indexOf(t.params.slideClass)===0).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach(r=>{const s=e.getSlideClasses(r);t.push({slideEl:r,classNames:s}),e.emit("_slideClass",r,s)}),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){e===void 0&&(e="current"),t===void 0&&(t=!1);const{params:r,slides:s,slidesGrid:i,slidesSizesGrid:o,size:a,activeIndex:l}=this;let c=1;if(r.centeredSlides){let d,f=s[l]?s[l].swiperSlideSize:0;for(let p=l+1;p<s.length;p+=1)s[p]&&!d&&(f+=s[p].swiperSlideSize,c+=1,f>a&&(d=!0));for(let p=l-1;p>=0;p-=1)s[p]&&!d&&(f+=s[p].swiperSlideSize,c+=1,f>a&&(d=!0))}else if(e==="current")for(let d=l+1;d<s.length;d+=1)(t?i[d]+o[d]-i[l]<a:i[d]-i[l]<a)&&(c+=1);else for(let d=l-1;d>=0;d-=1)i[l]-i[d]<a&&(c+=1);return c}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:r}=e;function s(){const o=e.rtlTranslate?-1*e.translate:e.translate,a=Math.min(Math.max(o,e.maxTranslate()),e.minTranslate());e.setTranslate(a),e.updateActiveIndex(),e.updateSlidesClasses()}let i;if(r.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(o=>{o.complete&&Xh(e,o)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),r.freeMode&&r.freeMode.enabled&&!r.cssMode)s(),r.autoHeight&&e.updateAutoHeight();else{if((r.slidesPerView==="auto"||r.slidesPerView>1)&&e.isEnd&&!r.centeredSlides){const o=e.virtual&&r.virtual.enabled?e.virtual.slides:e.slides;i=e.slideTo(o.length-1,0,!1,!0)}else i=e.slideTo(e.activeIndex,0,!1,!0);i||s()}r.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){t===void 0&&(t=!0);const r=this,s=r.params.direction;return e||(e=s==="horizontal"?"vertical":"horizontal"),e===s||e!=="horizontal"&&e!=="vertical"||(r.el.classList.remove(`${r.params.containerModifierClass}${s}`),r.el.classList.add(`${r.params.containerModifierClass}${e}`),r.emitContainerClasses(),r.params.direction=e,r.slides.forEach(i=>{e==="vertical"?i.style.width="":i.style.height=""}),r.emit("changeDirection"),t&&r.update()),r}changeLanguageDirection(e){const t=this;t.rtl&&e==="rtl"||!t.rtl&&e==="ltr"||(t.rtl=e==="rtl",t.rtlTranslate=t.params.direction==="horizontal"&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}mount(e){const t=this;if(t.mounted)return!0;let r=e||t.params.el;if(typeof r=="string"&&(r=document.querySelector(r)),!r)return!1;r.swiper=t,r.parentNode&&r.parentNode.host&&(t.isElement=!0);const s=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let i=r&&r.shadowRoot&&r.shadowRoot.querySelector?r.shadowRoot.querySelector(s()):Vi(r,s())[0];return!i&&t.params.createElements&&(i=Wh("div",t.params.wrapperClass),r.append(i),Vi(r,`.${t.params.slideClass}`).forEach(o=>{i.append(o)})),Object.assign(t,{el:r,wrapperEl:i,slidesEl:t.isElement?r.parentNode.host:i,hostEl:t.isElement?r.parentNode.host:r,mounted:!0,rtl:r.dir.toLowerCase()==="rtl"||Ta(r,"direction")==="rtl",rtlTranslate:t.params.direction==="horizontal"&&(r.dir.toLowerCase()==="rtl"||Ta(r,"direction")==="rtl"),wrongRTL:Ta(i,"display")==="-webkit-box"}),!0}init(e){const t=this;return t.initialized||t.mount(e)===!1||(t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(),t.attachEvents(),[...t.el.querySelectorAll('[loading="lazy"]')].forEach(r=>{r.complete?Xh(t,r):r.addEventListener("load",s=>{Xh(t,s.target)})}),J0(t),t.initialized=!0,J0(t),t.emit("init"),t.emit("afterInit")),t}destroy(e,t){e===void 0&&(e=!0),t===void 0&&(t=!0);const r=this,{params:s,el:i,wrapperEl:o,slides:a}=r;return r.params===void 0||r.destroyed||(r.emit("beforeDestroy"),r.initialized=!1,r.detachEvents(),s.loop&&r.loopDestroy(),t&&(r.removeClasses(),i.removeAttribute("style"),o.removeAttribute("style"),a&&a.length&&a.forEach(l=>{l.classList.remove(s.slideVisibleClass,s.slideActiveClass,s.slideNextClass,s.slidePrevClass),l.removeAttribute("style"),l.removeAttribute("data-swiper-slide-index")})),r.emit("destroy"),Object.keys(r.eventsListeners).forEach(l=>{r.off(l)}),e!==!1&&(r.el.swiper=null,function(l){const c=l;Object.keys(c).forEach(d=>{try{c[d]=null}catch{}try{delete c[d]}catch{}})}(r)),r.destroyed=!0),null}static extendDefaults(e){si(eb,e)}static get extendedDefaults(){return eb}static get defaults(){return VL}static installModule(e){ya.prototype.__modules__||(ya.prototype.__modules__=[]);const t=ya.prototype.__modules__;typeof e=="function"&&t.indexOf(e)<0&&t.push(e)}static use(e){return Array.isArray(e)?(e.forEach(t=>ya.installModule(t)),ya):(ya.installModule(e),ya)}};Object.keys(Z0).forEach(n=>{Object.keys(Z0[n]).forEach(e=>{Ad.prototype[e]=Z0[n][e]})}),Ad.use([function(n){let{swiper:e,on:t,emit:r}=n;const s=ms();let i=null,o=null;const a=()=>{e&&!e.destroyed&&e.initialized&&(r("beforeResize"),r("resize"))},l=()=>{e&&!e.destroyed&&e.initialized&&r("orientationchange")};t("init",()=>{e.params.resizeObserver&&s.ResizeObserver!==void 0?e&&!e.destroyed&&e.initialized&&(i=new ResizeObserver(c=>{o=s.requestAnimationFrame(()=>{const{width:d,height:f}=e;let p=d,m=f;c.forEach(g=>{let{contentBoxSize:v,contentRect:y,target:b}=g;b&&b!==e.el||(p=y?y.width:(v[0]||v).inlineSize,m=y?y.height:(v[0]||v).blockSize)}),p===d&&m===f||a()})}),i.observe(e.el)):(s.addEventListener("resize",a),s.addEventListener("orientationchange",l))}),t("destroy",()=>{o&&s.cancelAnimationFrame(o),i&&i.unobserve&&e.el&&(i.unobserve(e.el),i=null),s.removeEventListener("resize",a),s.removeEventListener("orientationchange",l)})},function(n){let{swiper:e,extendParams:t,on:r,emit:s}=n;const i=[],o=ms(),a=function(l,c){c===void 0&&(c={});const d=new(o.MutationObserver||o.WebkitMutationObserver)(f=>{if(e.__preventObserver__)return;if(f.length===1)return void s("observerUpdate",f[0]);const p=function(){s("observerUpdate",f[0])};o.requestAnimationFrame?o.requestAnimationFrame(p):o.setTimeout(p,0)});d.observe(l,{attributes:c.attributes===void 0||c.attributes,childList:c.childList===void 0||c.childList,characterData:c.characterData===void 0||c.characterData}),i.push(d)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),r("init",()=>{if(e.params.observer){if(e.params.observeParents){const l=Yh(e.el);for(let c=0;c<l.length;c+=1)a(l[c])}a(e.el,{childList:e.params.observeSlideChildren}),a(e.wrapperEl,{attributes:!1})}}),r("destroy",()=>{i.forEach(l=>{l.disconnect()}),i.splice(0,i.length)})}]);const WL=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","_spaceBetween","_slidesPerView","maxBackfaceHiddenSlides","_grid","_slidesPerGroup","_slidesPerGroupSkip","_slidesPerGroupAuto","_centeredSlides","_centeredSlidesBounds","_slidesOffsetBefore","_slidesOffsetAfter","normalizeSlideIndex","_centerInsufficientSlides","_watchOverflow","roundLengths","touchRatio","touchAngle","simulateTouch","_shortSwipes","_longSwipes","longSwipesRatio","longSwipesMs","_followFinger","allowTouchMove","_threshold","touchMoveStopPropagation","touchStartPreventDefault","touchStartForcePreventDefault","touchReleaseOnEdges","uniqueNavElements","_resistance","_resistanceRatio","_watchSlidesProgress","_grabCursor","preventClicks","preventClicksPropagation","_slideToClickedSlide","_loop","loopedSlides","loopPreventsSliding","_rewind","_allowSlidePrev","_allowSlideNext","_swipeHandler","_noSwiping","noSwipingClass","noSwipingSelector","passiveListeners","containerModifierClass","slideClass","slideActiveClass","slideVisibleClass","slideNextClass","slidePrevClass","wrapperClass","lazyPreloaderClass","lazyPreloadPrevNext","runCallbacksOnInit","observer","observeParents","observeSlideChildren","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function Cl(n){return typeof n=="object"&&n!==null&&n.constructor&&Object.prototype.toString.call(n).slice(8,-1)==="Object"}function Ca(n,e){const t=["__proto__","constructor","prototype"];Object.keys(e).filter(r=>t.indexOf(r)<0).forEach(r=>{n[r]===void 0?n[r]=e[r]:Cl(e[r])&&Cl(n[r])&&Object.keys(e[r]).length>0?e[r].__swiper__?n[r]=e[r]:Ca(n[r],e[r]):n[r]=e[r]})}function KL(n){return n===void 0&&(n={}),n.navigation&&n.navigation.nextEl===void 0&&n.navigation.prevEl===void 0}function YL(n){return n===void 0&&(n={}),n.pagination&&n.pagination.el===void 0}function XL(n){return n===void 0&&(n={}),n.scrollbar&&n.scrollbar.el===void 0}function QL(n){n===void 0&&(n="");const e=n.split(" ").map(r=>r.trim()).filter(r=>!!r),t=[];return e.forEach(r=>{t.indexOf(r)<0&&t.push(r)}),t.join(" ")}function OH(n){return n===void 0&&(n=""),n?n.includes("swiper-wrapper")?n:`swiper-wrapper ${n}`:"swiper-wrapper"}function Qh(){return Qh=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Qh.apply(this,arguments)}function JL(n){return n.type&&n.type.displayName&&n.type.displayName.includes("SwiperSlide")}function ZL(n){const e=[];return Ne.Children.toArray(n).forEach(t=>{JL(t)?e.push(t):t.props&&t.props.children&&ZL(t.props.children).forEach(r=>e.push(r))}),e}function PH(n){const e=[],t={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return Ne.Children.toArray(n).forEach(r=>{if(JL(r))e.push(r);else if(r.props&&r.props.slot&&t[r.props.slot])t[r.props.slot].push(r);else if(r.props&&r.props.children){const s=ZL(r.props.children);s.length>0?s.forEach(i=>e.push(i)):t["container-end"].push(r)}else t["container-end"].push(r)}),{slides:e,slots:t}}function kd(n,e){return typeof window>"u"?T.useEffect(n,e):T.useLayoutEffect(n,e)}const eM=T.createContext(null),DH=T.createContext(null),tM=T.forwardRef(function(n,e){let{className:t,tag:r="div",wrapperTag:s="div",children:i,onSwiper:o,...a}=n===void 0?{}:n,l=!1;const[c,d]=T.useState("swiper"),[f,p]=T.useState(null),[m,g]=T.useState(!1),v=T.useRef(!1),y=T.useRef(null),b=T.useRef(null),S=T.useRef(null),E=T.useRef(null),C=T.useRef(null),R=T.useRef(null),I=T.useRef(null),A=T.useRef(null),{params:k,passedParams:N,rest:D,events:M}=function(G,V){G===void 0&&(G={}),V===void 0&&(V=!0);const z={on:{}},B={},P={};Ca(z,Ad.defaults),Ca(z,Ad.extendedDefaults),z._emitClasses=!0,z.init=!1;const H={},Z=WL.map(J=>J.replace(/_/,"")),Q=Object.assign({},G);return Object.keys(Q).forEach(J=>{G[J]!==void 0&&(Z.indexOf(J)>=0?Cl(G[J])?(z[J]={},P[J]={},Ca(z[J],G[J]),Ca(P[J],G[J])):(z[J]=G[J],P[J]=G[J]):J.search(/on[A-Z]/)===0&&typeof G[J]=="function"?V?B[`${J[2].toLowerCase()}${J.substr(3)}`]=G[J]:z.on[`${J[2].toLowerCase()}${J.substr(3)}`]=G[J]:H[J]=G[J])}),["navigation","pagination","scrollbar"].forEach(J=>{z[J]===!0&&(z[J]={}),z[J]===!1&&delete z[J]}),{params:z,passedParams:P,rest:H,events:B}}(a),{slides:F,slots:U}=PH(i),$=()=>{g(!m)};Object.assign(k.on,{_containerClasses(G,V){d(V)}});const q=()=>{Object.assign(k.on,M),l=!0;const G={...k};if(delete G.wrapperClass,b.current=new Ad(G),b.current.virtual&&b.current.params.virtual.enabled){b.current.virtual.slides=F;const V={cache:!1,slides:F,renderExternal:p,renderExternalUpdate:!1};Ca(b.current.params.virtual,V),Ca(b.current.originalParams.virtual,V)}};return y.current||q(),b.current&&b.current.on("_beforeBreakpoint",$),T.useEffect(()=>()=>{b.current&&b.current.off("_beforeBreakpoint",$)}),T.useEffect(()=>{!v.current&&b.current&&(b.current.emitSlidesClasses(),v.current=!0)}),kd(()=>{if(e&&(e.current=y.current),y.current)return b.current.destroyed&&q(),function(G,V){let{el:z,nextEl:B,prevEl:P,paginationEl:H,scrollbarEl:Z,swiper:Q}=G;KL(V)&&B&&P&&(Q.params.navigation.nextEl=B,Q.originalParams.navigation.nextEl=B,Q.params.navigation.prevEl=P,Q.originalParams.navigation.prevEl=P),YL(V)&&H&&(Q.params.pagination.el=H,Q.originalParams.pagination.el=H),XL(V)&&Z&&(Q.params.scrollbar.el=Z,Q.originalParams.scrollbar.el=Z),Q.init(z)}({el:y.current,nextEl:C.current,prevEl:R.current,paginationEl:I.current,scrollbarEl:A.current,swiper:b.current},k),o&&o(b.current),()=>{b.current&&!b.current.destroyed&&b.current.destroy(!0,!1)}},[]),kd(()=>{!l&&M&&b.current&&Object.keys(M).forEach(V=>{b.current.on(V,M[V])});const G=function(V,z,B,P,H){const Z=[];if(!z)return Z;const Q=J=>{Z.indexOf(J)<0&&Z.push(J)};if(B&&P){const J=P.map(H),ee=B.map(H);J.join("")!==ee.join("")&&Q("children"),P.length!==B.length&&Q("children")}return WL.filter(J=>J[0]==="_").map(J=>J.replace(/_/,"")).forEach(J=>{if(J in V&&J in z)if(Cl(V[J])&&Cl(z[J])){const ee=Object.keys(V[J]),K=Object.keys(z[J]);ee.length!==K.length?Q(J):(ee.forEach(W=>{V[J][W]!==z[J][W]&&Q(J)}),K.forEach(W=>{V[J][W]!==z[J][W]&&Q(J)}))}else V[J]!==z[J]&&Q(J)}),Z}(N,S.current,F,E.current,V=>V.key);return S.current=N,E.current=F,G.length&&b.current&&!b.current.destroyed&&function(V){let{swiper:z,slides:B,passedParams:P,changedParams:H,nextEl:Z,prevEl:Q,scrollbarEl:J,paginationEl:ee}=V;const K=H.filter(Xe=>Xe!=="children"&&Xe!=="direction"&&Xe!=="wrapperClass"),{params:W,pagination:te,navigation:re,scrollbar:pe,virtual:Ee,thumbs:le}=z;let Ie,be,ge,Ae,Re,tt,et,Oe;H.includes("thumbs")&&P.thumbs&&P.thumbs.swiper&&W.thumbs&&!W.thumbs.swiper&&(Ie=!0),H.includes("controller")&&P.controller&&P.controller.control&&W.controller&&!W.controller.control&&(be=!0),H.includes("pagination")&&P.pagination&&(P.pagination.el||ee)&&(W.pagination||W.pagination===!1)&&te&&!te.el&&(ge=!0),H.includes("scrollbar")&&P.scrollbar&&(P.scrollbar.el||J)&&(W.scrollbar||W.scrollbar===!1)&&pe&&!pe.el&&(Ae=!0),H.includes("navigation")&&P.navigation&&(P.navigation.prevEl||Q)&&(P.navigation.nextEl||Z)&&(W.navigation||W.navigation===!1)&&re&&!re.prevEl&&!re.nextEl&&(Re=!0);const ht=Xe=>{z[Xe]&&(z[Xe].destroy(),Xe==="navigation"?(z.isElement&&(z[Xe].prevEl.remove(),z[Xe].nextEl.remove()),W[Xe].prevEl=void 0,W[Xe].nextEl=void 0,z[Xe].prevEl=void 0,z[Xe].nextEl=void 0):(z.isElement&&z[Xe].el.remove(),W[Xe].el=void 0,z[Xe].el=void 0))};H.includes("loop")&&z.isElement&&(W.loop&&!P.loop?tt=!0:!W.loop&&P.loop?et=!0:Oe=!0),K.forEach(Xe=>{if(Cl(W[Xe])&&Cl(P[Xe]))Ca(W[Xe],P[Xe]),Xe!=="navigation"&&Xe!=="pagination"&&Xe!=="scrollbar"||!("enabled"in P[Xe])||P[Xe].enabled||ht(Xe);else{const Je=P[Xe];Je!==!0&&Je!==!1||Xe!=="navigation"&&Xe!=="pagination"&&Xe!=="scrollbar"?W[Xe]=P[Xe]:Je===!1&&ht(Xe)}}),K.includes("controller")&&!be&&z.controller&&z.controller.control&&W.controller&&W.controller.control&&(z.controller.control=W.controller.control),H.includes("children")&&B&&Ee&&W.virtual.enabled&&(Ee.slides=B,Ee.update(!0)),H.includes("children")&&B&&W.loop&&(Oe=!0),Ie&&le.init()&&le.update(!0),be&&(z.controller.control=W.controller.control),ge&&(!z.isElement||ee&&typeof ee!="string"||(ee=document.createElement("div"),ee.classList.add("swiper-pagination"),z.el.appendChild(ee)),ee&&(W.pagination.el=ee),te.init(),te.render(),te.update()),Ae&&(!z.isElement||J&&typeof J!="string"||(J=document.createElement("div"),J.classList.add("swiper-scrollbar"),z.el.appendChild(J)),J&&(W.scrollbar.el=J),pe.init(),pe.updateSize(),pe.setTranslate()),Re&&(z.isElement&&(Z&&typeof Z!="string"||(Z=document.createElement("div"),Z.classList.add("swiper-button-next"),Z.innerHTML=z.hostEl.nextButtonSvg,z.el.appendChild(Z)),Q&&typeof Q!="string"||(Q=document.createElement("div"),Q.classList.add("swiper-button-prev"),Z.innerHTML=z.hostEl.prevButtonSvg,z.el.appendChild(Q))),Z&&(W.navigation.nextEl=Z),Q&&(W.navigation.prevEl=Q),re.init(),re.update()),H.includes("allowSlideNext")&&(z.allowSlideNext=P.allowSlideNext),H.includes("allowSlidePrev")&&(z.allowSlidePrev=P.allowSlidePrev),H.includes("direction")&&z.changeDirection(P.direction,!1),(tt||Oe)&&z.loopDestroy(),(et||Oe)&&z.loopCreate(),z.update()}({swiper:b.current,slides:F,passedParams:N,changedParams:G,nextEl:C.current,prevEl:R.current,scrollbarEl:A.current,paginationEl:I.current}),()=>{M&&b.current&&Object.keys(M).forEach(V=>{b.current.off(V,M[V])})}}),kd(()=>{var G;!(G=b.current)||G.destroyed||!G.params.virtual||G.params.virtual&&!G.params.virtual.enabled||(G.updateSlides(),G.updateProgress(),G.updateSlidesClasses(),G.parallax&&G.params.parallax&&G.params.parallax.enabled&&G.parallax.setTranslate())},[f]),Ne.createElement(r,Qh({ref:y,className:QL(`${c}${t?` ${t}`:""}`)},D),Ne.createElement(DH.Provider,{value:b.current},U["container-start"],Ne.createElement(s,{className:OH(k.wrapperClass)},U["wrapper-start"],k.virtual?function(G,V,z){if(!z)return null;const B=K=>{let W=K;return K<0?W=V.length+K:W>=V.length&&(W-=V.length),W},P=G.isHorizontal()?{[G.rtlTranslate?"right":"left"]:`${z.offset}px`}:{top:`${z.offset}px`},{from:H,to:Z}=z,Q=G.params.loop?-V.length:0,J=G.params.loop?2*V.length:V.length,ee=[];for(let K=Q;K<J;K+=1)K>=H&&K<=Z&&ee.push(V[B(K)]);return ee.map((K,W)=>Ne.cloneElement(K,{swiper:G,style:P,key:`slide-${W}`}))}(b.current,F,f):F.map((G,V)=>Ne.cloneElement(G,{swiper:b.current,swiperSlideIndex:V})),U["wrapper-end"]),KL(k)&&Ne.createElement(Ne.Fragment,null,Ne.createElement("div",{ref:R,className:"swiper-button-prev"}),Ne.createElement("div",{ref:C,className:"swiper-button-next"})),XL(k)&&Ne.createElement("div",{ref:A,className:"swiper-scrollbar"}),YL(k)&&Ne.createElement("div",{ref:I,className:"swiper-pagination"}),U["container-end"]))});tM.displayName="Swiper";const tb=T.forwardRef(function(n,e){let{tag:t="div",children:r,className:s="",swiper:i,zoom:o,lazy:a,virtualIndex:l,swiperSlideIndex:c,...d}=n===void 0?{}:n;const f=T.useRef(null),[p,m]=T.useState("swiper-slide"),[g,v]=T.useState(!1);function y(E,C,R){C===f.current&&m(R)}kd(()=>{if(c!==void 0&&(f.current.swiperSlideIndex=c),e&&(e.current=f.current),f.current&&i){if(!i.destroyed)return i.on("_slideClass",y),()=>{i&&i.off("_slideClass",y)};p!=="swiper-slide"&&m("swiper-slide")}}),kd(()=>{i&&f.current&&!i.destroyed&&m(i.getSlideClasses(f.current))},[i]);const b={isActive:p.indexOf("swiper-slide-active")>=0,isVisible:p.indexOf("swiper-slide-visible")>=0,isPrev:p.indexOf("swiper-slide-prev")>=0,isNext:p.indexOf("swiper-slide-next")>=0},S=()=>typeof r=="function"?r(b):r;return Ne.createElement(t,Qh({ref:f,className:QL(`${p}${s?` ${s}`:""}`),"data-swiper-slide-index":l,onLoad:()=>{v(!0)}},d),o&&Ne.createElement(eM.Provider,{value:b},Ne.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":typeof o=="number"?o:void 0},S(),a&&!g&&Ne.createElement("div",{className:"swiper-lazy-preloader"}))),!o&&Ne.createElement(eM.Provider,{value:b},S(),a&&!g&&Ne.createElement("div",{className:"swiper-lazy-preloader"})))});tb.displayName="SwiperSlide";const nM={xs:"320px",sm:"576px",md:"768px",lg:"992px",xl:"1280px",xx:"1500px"},jH={isLtr:O.bool,style:O.object,children:O.node,isVertical:O.bool,className:O.string,userAgent:O.string,breakpoints:O.object,onSlideChange:O.func,otherOptions:O.object,carouselStyle:O.object,carouselClassName:O.string,autoplay:O.oneOfType([O.bool,O.object]),keyboard:O.oneOfType([O.bool,O.object]),pagination:O.oneOfType([O.bool,O.object]),navigation:O.oneOfType([O.bool,O.object]),spaceBetween:O.oneOfType([O.string,O.number]),slidesPerView:O.oneOfType([O.string,O.number])};function FH(n){let e,{swiper:t,extendParams:r,on:s,emit:i}=n;r({virtual:{enabled:!1,slides:[],cache:!0,renderSlide:null,renderExternal:null,renderExternalUpdate:!0,addSlidesBefore:0,addSlidesAfter:0}});const o=ri();t.virtual={cache:{},from:void 0,to:void 0,slides:[],offset:0,slidesGrid:[]};const a=o.createElement("div");function l(d,f){const p=t.params.virtual;if(p.cache&&t.virtual.cache[f])return t.virtual.cache[f];let m;return p.renderSlide?(m=p.renderSlide.call(t,d,f),typeof m=="string"&&(a.innerHTML=m,m=a.children[0])):m=t.isElement?Wh("swiper-slide"):Wh("div",t.params.slideClass),m.setAttribute("data-swiper-slide-index",f),p.renderSlide||(m.innerHTML=d),p.cache&&(t.virtual.cache[f]=m),m}function c(d){const{slidesPerView:f,slidesPerGroup:p,centeredSlides:m,loop:g}=t.params,{addSlidesBefore:v,addSlidesAfter:y}=t.params.virtual,{from:b,to:S,slides:E,slidesGrid:C,offset:R}=t.virtual;t.params.cssMode||t.updateActiveIndex();const I=t.activeIndex||0;let A,k,N;A=t.rtlTranslate?"right":t.isHorizontal()?"left":"top",m?(k=Math.floor(f/2)+p+y,N=Math.floor(f/2)+p+v):(k=f+(p-1)+y,N=(g?f:p)+v);let D=I-N,M=I+k;g||(D=Math.max(D,0),M=Math.min(M,E.length-1));let F=(t.slidesGrid[D]||0)-(t.slidesGrid[0]||0);function U(){t.updateSlides(),t.updateProgress(),t.updateSlidesClasses(),i("virtualUpdate")}if(g&&I>=N?(D-=N,m||(F+=t.slidesGrid[0])):g&&I<N&&(D=-N,m&&(F+=t.slidesGrid[0])),Object.assign(t.virtual,{from:D,to:M,offset:F,slidesGrid:t.slidesGrid,slidesBefore:N,slidesAfter:k}),b===D&&S===M&&!d)return t.slidesGrid!==C&&F!==R&&t.slides.forEach(B=>{B.style[A]=F-Math.abs(t.cssOverflowAdjustment())+"px"}),t.updateProgress(),void i("virtualUpdate");if(t.params.virtual.renderExternal)return t.params.virtual.renderExternal.call(t,{offset:F,from:D,to:M,slides:function(){const B=[];for(let P=D;P<=M;P+=1)B.push(E[P]);return B}()}),void(t.params.virtual.renderExternalUpdate?U():i("virtualUpdate"));const $=[],q=[],G=B=>{let P=B;return B<0?P=E.length+B:P>=E.length&&(P-=E.length),P};if(d)t.slidesEl.querySelectorAll(`.${t.params.slideClass}, swiper-slide`).forEach(B=>{B.remove()});else for(let B=b;B<=S;B+=1)if(B<D||B>M){const P=G(B);t.slidesEl.querySelectorAll(`.${t.params.slideClass}[data-swiper-slide-index="${P}"], swiper-slide[data-swiper-slide-index="${P}"]`).forEach(H=>{H.remove()})}const V=g?-E.length:0,z=g?2*E.length:E.length;for(let B=V;B<z;B+=1)if(B>=D&&B<=M){const P=G(B);S===void 0||d?q.push(P):(B>S&&q.push(P),B<b&&$.push(P))}if(q.forEach(B=>{t.slidesEl.append(l(E[B],B))}),g)for(let B=$.length-1;B>=0;B-=1){const P=$[B];t.slidesEl.prepend(l(E[P],P))}else $.sort((B,P)=>P-B),$.forEach(B=>{t.slidesEl.prepend(l(E[B],B))});Vi(t.slidesEl,".swiper-slide, swiper-slide").forEach(B=>{B.style[A]=F-Math.abs(t.cssOverflowAdjustment())+"px"}),U()}s("beforeInit",()=>{if(!t.params.virtual.enabled)return;let d;if(t.passedParams.virtual.slides===void 0){const f=[...t.slidesEl.children].filter(p=>p.matches(`.${t.params.slideClass}, swiper-slide`));f&&f.length&&(t.virtual.slides=[...f],d=!0,f.forEach((p,m)=>{p.setAttribute("data-swiper-slide-index",m),t.virtual.cache[m]=p,p.remove()}))}d||(t.virtual.slides=t.params.virtual.slides),t.classNames.push(`${t.params.containerModifierClass}virtual`),t.params.watchSlidesProgress=!0,t.originalParams.watchSlidesProgress=!0,t.params.initialSlide||c()}),s("setTranslate",()=>{t.params.virtual.enabled&&(t.params.cssMode&&!t._immediateVirtual?(clearTimeout(e),e=setTimeout(()=>{c()},100)):c())}),s("init update resize",()=>{t.params.virtual.enabled&&t.params.cssMode&&Rd(t.wrapperEl,"--swiper-virtual-size",`${t.virtualSize}px`)}),Object.assign(t.virtual,{appendSlide:function(d){if(typeof d=="object"&&"length"in d)for(let f=0;f<d.length;f+=1)d[f]&&t.virtual.slides.push(d[f]);else t.virtual.slides.push(d);c(!0)},prependSlide:function(d){const f=t.activeIndex;let p=f+1,m=1;if(Array.isArray(d)){for(let g=0;g<d.length;g+=1)d[g]&&t.virtual.slides.unshift(d[g]);p=f+d.length,m=d.length}else t.virtual.slides.unshift(d);if(t.params.virtual.cache){const g=t.virtual.cache,v={};Object.keys(g).forEach(y=>{const b=g[y],S=b.getAttribute("data-swiper-slide-index");S&&b.setAttribute("data-swiper-slide-index",parseInt(S,10)+m),v[parseInt(y,10)+m]=b}),t.virtual.cache=v}c(!0),t.slideTo(p,0)},removeSlide:function(d){if(d==null)return;let f=t.activeIndex;if(Array.isArray(d))for(let p=d.length-1;p>=0;p-=1)t.virtual.slides.splice(d[p],1),t.params.virtual.cache&&delete t.virtual.cache[d[p]],d[p]<f&&(f-=1),f=Math.max(f,0);else t.virtual.slides.splice(d,1),t.params.virtual.cache&&delete t.virtual.cache[d],d<f&&(f-=1),f=Math.max(f,0);c(!0),t.slideTo(f,0)},removeAllSlides:function(){t.virtual.slides=[],t.params.virtual.cache&&(t.virtual.cache={}),c(!0),t.slideTo(0,0)},update:c})}function UH(n){let{swiper:e,extendParams:t,on:r,emit:s}=n;const i=ri(),o=ms();function a(d){if(!e.enabled)return;const{rtlTranslate:f}=e;let p=d;p.originalEvent&&(p=p.originalEvent);const m=p.keyCode||p.charCode,g=e.params.keyboard.pageUpDown,v=g&&m===33,y=g&&m===34,b=m===37,S=m===39,E=m===38,C=m===40;if(!e.allowSlideNext&&(e.isHorizontal()&&S||e.isVertical()&&C||y)||!e.allowSlidePrev&&(e.isHorizontal()&&b||e.isVertical()&&E||v))return!1;if(!(p.shiftKey||p.altKey||p.ctrlKey||p.metaKey||i.activeElement&&i.activeElement.nodeName&&(i.activeElement.nodeName.toLowerCase()==="input"||i.activeElement.nodeName.toLowerCase()==="textarea"))){if(e.params.keyboard.onlyInViewport&&(v||y||b||S||E||C)){let R=!1;if(Yh(e.el,`.${e.params.slideClass}, swiper-slide`).length>0&&Yh(e.el,`.${e.params.slideActiveClass}`).length===0)return;const I=e.el,A=I.clientWidth,k=I.clientHeight,N=o.innerWidth,D=o.innerHeight,M=function(U){const $=ms(),q=ri(),G=U.getBoundingClientRect(),V=q.body,z=U.clientTop||V.clientTop||0,B=U.clientLeft||V.clientLeft||0,P=U===$?$.scrollY:U.scrollTop,H=U===$?$.scrollX:U.scrollLeft;return{top:G.top+P-z,left:G.left+H-B}}(I);f&&(M.left-=I.scrollLeft);const F=[[M.left,M.top],[M.left+A,M.top],[M.left,M.top+k],[M.left+A,M.top+k]];for(let U=0;U<F.length;U+=1){const $=F[U];if($[0]>=0&&$[0]<=N&&$[1]>=0&&$[1]<=D){if($[0]===0&&$[1]===0)continue;R=!0}}if(!R)return}e.isHorizontal()?((v||y||b||S)&&(p.preventDefault?p.preventDefault():p.returnValue=!1),((y||S)&&!f||(v||b)&&f)&&e.slideNext(),((v||b)&&!f||(y||S)&&f)&&e.slidePrev()):((v||y||E||C)&&(p.preventDefault?p.preventDefault():p.returnValue=!1),(y||C)&&e.slideNext(),(v||E)&&e.slidePrev()),s("keyPress",m)}}function l(){e.keyboard.enabled||(i.addEventListener("keydown",a),e.keyboard.enabled=!0)}function c(){e.keyboard.enabled&&(i.removeEventListener("keydown",a),e.keyboard.enabled=!1)}e.keyboard={enabled:!1},t({keyboard:{enabled:!1,onlyInViewport:!0,pageUpDown:!0}}),r("init",()=>{e.params.keyboard.enabled&&l()}),r("destroy",()=>{e.keyboard.enabled&&c()}),Object.assign(e.keyboard,{enable:l,disable:c})}function BH(n){let{swiper:e,extendParams:t,on:r,emit:s}=n;const i=ms();let o;t({mousewheel:{enabled:!1,releaseOnEdges:!1,invert:!1,forceToAxis:!1,sensitivity:1,eventsTarget:"container",thresholdDelta:null,thresholdTime:null,noMousewheelClass:"swiper-no-mousewheel"}}),e.mousewheel={enabled:!1};let a,l=yi();const c=[];function d(){e.enabled&&(e.mouseEntered=!0)}function f(){e.enabled&&(e.mouseEntered=!1)}function p(b){return!(e.params.mousewheel.thresholdDelta&&b.delta<e.params.mousewheel.thresholdDelta)&&!(e.params.mousewheel.thresholdTime&&yi()-l<e.params.mousewheel.thresholdTime)&&(b.delta>=6&&yi()-l<60||(b.direction<0?e.isEnd&&!e.params.loop||e.animating||(e.slideNext(),s("scroll",b.raw)):e.isBeginning&&!e.params.loop||e.animating||(e.slidePrev(),s("scroll",b.raw)),l=new i.Date().getTime(),!1))}function m(b){let S=b,E=!0;if(!e.enabled||b.target.closest(`.${e.params.mousewheel.noMousewheelClass}`))return;const C=e.params.mousewheel;e.params.cssMode&&S.preventDefault();let R=e.el;e.params.mousewheel.eventsTarget!=="container"&&(R=document.querySelector(e.params.mousewheel.eventsTarget));const I=R&&R.contains(S.target);if(!e.mouseEntered&&!I&&!C.releaseOnEdges)return!0;S.originalEvent&&(S=S.originalEvent);let A=0;const k=e.rtlTranslate?-1:1,N=function(M){let F=0,U=0,$=0,q=0;return"detail"in M&&(U=M.detail),"wheelDelta"in M&&(U=-M.wheelDelta/120),"wheelDeltaY"in M&&(U=-M.wheelDeltaY/120),"wheelDeltaX"in M&&(F=-M.wheelDeltaX/120),"axis"in M&&M.axis===M.HORIZONTAL_AXIS&&(F=U,U=0),$=10*F,q=10*U,"deltaY"in M&&(q=M.deltaY),"deltaX"in M&&($=M.deltaX),M.shiftKey&&!$&&($=q,q=0),($||q)&&M.deltaMode&&(M.deltaMode===1?($*=40,q*=40):($*=800,q*=800)),$&&!F&&(F=$<1?-1:1),q&&!U&&(U=q<1?-1:1),{spinX:F,spinY:U,pixelX:$,pixelY:q}}(S);if(C.forceToAxis)if(e.isHorizontal()){if(!(Math.abs(N.pixelX)>Math.abs(N.pixelY)))return!0;A=-N.pixelX*k}else{if(!(Math.abs(N.pixelY)>Math.abs(N.pixelX)))return!0;A=-N.pixelY}else A=Math.abs(N.pixelX)>Math.abs(N.pixelY)?-N.pixelX*k:-N.pixelY;if(A===0)return!0;C.invert&&(A=-A);let D=e.getTranslate()+A*C.sensitivity;if(D>=e.minTranslate()&&(D=e.minTranslate()),D<=e.maxTranslate()&&(D=e.maxTranslate()),E=!!e.params.loop||!(D===e.minTranslate()||D===e.maxTranslate()),E&&e.params.nested&&S.stopPropagation(),e.params.freeMode&&e.params.freeMode.enabled){const M={time:yi(),delta:Math.abs(A),direction:Math.sign(A)},F=a&&M.time<a.time+500&&M.delta<=a.delta&&M.direction===a.direction;if(!F){a=void 0;let U=e.getTranslate()+A*C.sensitivity;const $=e.isBeginning,q=e.isEnd;if(U>=e.minTranslate()&&(U=e.minTranslate()),U<=e.maxTranslate()&&(U=e.maxTranslate()),e.setTransition(0),e.setTranslate(U),e.updateProgress(),e.updateActiveIndex(),e.updateSlidesClasses(),(!$&&e.isBeginning||!q&&e.isEnd)&&e.updateSlidesClasses(),e.params.loop&&e.loopFix({direction:M.direction<0?"next":"prev",byMousewheel:!0}),e.params.freeMode.sticky){clearTimeout(o),o=void 0,c.length>=15&&c.shift();const G=c.length?c[c.length-1]:void 0,V=c[0];if(c.push(M),G&&(M.delta>G.delta||M.direction!==G.direction))c.splice(0);else if(c.length>=15&&M.time-V.time<500&&V.delta-M.delta>=1&&M.delta<=6){const z=A>0?.8:.2;a=M,c.splice(0),o=Id(()=>{e.slideToClosest(e.params.speed,!0,void 0,z)},0)}o||(o=Id(()=>{a=M,c.splice(0),e.slideToClosest(e.params.speed,!0,void 0,.5)},500))}if(F||s("scroll",S),e.params.autoplay&&e.params.autoplayDisableOnInteraction&&e.autoplay.stop(),U===e.minTranslate()||U===e.maxTranslate())return!0}}else{const M={time:yi(),delta:Math.abs(A),direction:Math.sign(A),raw:b};c.length>=2&&c.shift();const F=c.length?c[c.length-1]:void 0;if(c.push(M),F?(M.direction!==F.direction||M.delta>F.delta||M.time>F.time+150)&&p(M):p(M),function(U){const $=e.params.mousewheel;if(U.direction<0){if(e.isEnd&&!e.params.loop&&$.releaseOnEdges)return!0}else if(e.isBeginning&&!e.params.loop&&$.releaseOnEdges)return!0;return!1}(M))return!0}return S.preventDefault?S.preventDefault():S.returnValue=!1,!1}function g(b){let S=e.el;e.params.mousewheel.eventsTarget!=="container"&&(S=document.querySelector(e.params.mousewheel.eventsTarget)),S[b]("mouseenter",d),S[b]("mouseleave",f),S[b]("wheel",m)}function v(){return e.params.cssMode?(e.wrapperEl.removeEventListener("wheel",m),!0):!e.mousewheel.enabled&&(g("addEventListener"),e.mousewheel.enabled=!0,!0)}function y(){return e.params.cssMode?(e.wrapperEl.addEventListener(event,m),!0):!!e.mousewheel.enabled&&(g("removeEventListener"),e.mousewheel.enabled=!1,!0)}r("init",()=>{!e.params.mousewheel.enabled&&e.params.cssMode&&y(),e.params.mousewheel.enabled&&v()}),r("destroy",()=>{e.params.cssMode&&v(),e.mousewheel.enabled&&y()}),Object.assign(e.mousewheel,{enable:v,disable:y})}function rM(n,e,t,r){return n.params.createElements&&Object.keys(r).forEach(s=>{if(!t[s]&&t.auto===!0){let i=Vi(n.el,`.${r[s]}`)[0];i||(i=Wh("div",r[s]),i.className=r[s],n.el.append(i)),t[s]=i,e[s]=i}}),t}function $H(n){let{swiper:e,extendParams:t,on:r,emit:s}=n;t({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock",navigationDisabledClass:"swiper-navigation-disabled"}}),e.navigation={nextEl:null,prevEl:null};const i=g=>(Array.isArray(g)||(g=[g].filter(v=>!!v)),g);function o(g){let v;return g&&typeof g=="string"&&e.isElement&&(v=e.el.querySelector(g),v)?v:(g&&(typeof g=="string"&&(v=[...document.querySelectorAll(g)]),e.params.uniqueNavElements&&typeof g=="string"&&v.length>1&&e.el.querySelectorAll(g).length===1&&(v=e.el.querySelector(g))),g&&!v?g:v)}function a(g,v){const y=e.params.navigation;(g=i(g)).forEach(b=>{b&&(b.classList[v?"add":"remove"](...y.disabledClass.split(" ")),b.tagName==="BUTTON"&&(b.disabled=v),e.params.watchOverflow&&e.enabled&&b.classList[e.isLocked?"add":"remove"](y.lockClass))})}function l(){const{nextEl:g,prevEl:v}=e.navigation;if(e.params.loop)return a(v,!1),void a(g,!1);a(v,e.isBeginning&&!e.params.rewind),a(g,e.isEnd&&!e.params.rewind)}function c(g){g.preventDefault(),(!e.isBeginning||e.params.loop||e.params.rewind)&&(e.slidePrev(),s("navigationPrev"))}function d(g){g.preventDefault(),(!e.isEnd||e.params.loop||e.params.rewind)&&(e.slideNext(),s("navigationNext"))}function f(){const g=e.params.navigation;if(e.params.navigation=rM(e,e.originalParams.navigation,e.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!g.nextEl&&!g.prevEl)return;let v=o(g.nextEl),y=o(g.prevEl);Object.assign(e.navigation,{nextEl:v,prevEl:y}),v=i(v),y=i(y);const b=(S,E)=>{S&&S.addEventListener("click",E==="next"?d:c),!e.enabled&&S&&S.classList.add(...g.lockClass.split(" "))};v.forEach(S=>b(S,"next")),y.forEach(S=>b(S,"prev"))}function p(){let{nextEl:g,prevEl:v}=e.navigation;g=i(g),v=i(v);const y=(b,S)=>{b.removeEventListener("click",S==="next"?d:c),b.classList.remove(...e.params.navigation.disabledClass.split(" "))};g.forEach(b=>y(b,"next")),v.forEach(b=>y(b,"prev"))}r("init",()=>{e.params.navigation.enabled===!1?m():(f(),l())}),r("toEdge fromEdge lock unlock",()=>{l()}),r("destroy",()=>{p()}),r("enable disable",()=>{let{nextEl:g,prevEl:v}=e.navigation;g=i(g),v=i(v),[...g,...v].filter(y=>!!y).forEach(y=>y.classList[e.enabled?"remove":"add"](e.params.navigation.lockClass))}),r("click",(g,v)=>{let{nextEl:y,prevEl:b}=e.navigation;y=i(y),b=i(b);const S=v.target;if(e.params.navigation.hideOnClick&&!b.includes(S)&&!y.includes(S)){if(e.pagination&&e.params.pagination&&e.params.pagination.clickable&&(e.pagination.el===S||e.pagination.el.contains(S)))return;let E;y.length?E=y[0].classList.contains(e.params.navigation.hiddenClass):b.length&&(E=b[0].classList.contains(e.params.navigation.hiddenClass)),s(E===!0?"navigationShow":"navigationHide"),[...y,...b].filter(C=>!!C).forEach(C=>C.classList.toggle(e.params.navigation.hiddenClass))}});const m=()=>{e.el.classList.add(...e.params.navigation.navigationDisabledClass.split(" ")),p()};Object.assign(e.navigation,{enable:()=>{e.el.classList.remove(...e.params.navigation.navigationDisabledClass.split(" ")),f(),l()},disable:m,update:l,init:f,destroy:p})}function Ld(n){return n===void 0&&(n=""),`.${n.trim().replace(/([\.:!+\/])/g,"\\$1").replace(/ /g,".")}`}function zH(n){let{swiper:e,extendParams:t,on:r,emit:s}=n;const i="swiper-pagination";let o;t({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:b=>b,formatFractionTotal:b=>b,bulletClass:`${i}-bullet`,bulletActiveClass:`${i}-bullet-active`,modifierClass:`${i}-`,currentClass:`${i}-current`,totalClass:`${i}-total`,hiddenClass:`${i}-hidden`,progressbarFillClass:`${i}-progressbar-fill`,progressbarOppositeClass:`${i}-progressbar-opposite`,clickableClass:`${i}-clickable`,lockClass:`${i}-lock`,horizontalClass:`${i}-horizontal`,verticalClass:`${i}-vertical`,paginationDisabledClass:`${i}-disabled`}}),e.pagination={el:null,bullets:[]};let a=0;const l=b=>(Array.isArray(b)||(b=[b].filter(S=>!!S)),b);function c(){return!e.params.pagination.el||!e.pagination.el||Array.isArray(e.pagination.el)&&e.pagination.el.length===0}function d(b,S){const{bulletActiveClass:E}=e.params.pagination;b&&(b=b[(S==="prev"?"previous":"next")+"ElementSibling"])&&(b.classList.add(`${E}-${S}`),(b=b[(S==="prev"?"previous":"next")+"ElementSibling"])&&b.classList.add(`${E}-${S}-${S}`))}function f(b){const S=b.target.closest(Ld(e.params.pagination.bulletClass));if(!S)return;b.preventDefault();const E=Kh(S)*e.params.slidesPerGroup;if(e.params.loop){if(e.realIndex===E)return;const C=e.getSlideIndexByData(E),R=e.getSlideIndexByData(e.realIndex);C>e.slides.length-e.loopedSlides&&e.loopFix({direction:C>R?"next":"prev",activeSlideIndex:C,slideTo:!1}),e.slideToLoop(E)}else e.slideTo(E)}function p(){const b=e.rtl,S=e.params.pagination;if(c())return;let E,C,R=e.pagination.el;R=l(R);const I=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length,A=e.params.loop?Math.ceil(I/e.params.slidesPerGroup):e.snapGrid.length;if(e.params.loop?(C=e.previousRealIndex||0,E=e.params.slidesPerGroup>1?Math.floor(e.realIndex/e.params.slidesPerGroup):e.realIndex):e.snapIndex!==void 0?(E=e.snapIndex,C=e.previousSnapIndex):(C=e.previousIndex||0,E=e.activeIndex||0),S.type==="bullets"&&e.pagination.bullets&&e.pagination.bullets.length>0){const k=e.pagination.bullets;let N,D,M;if(S.dynamicBullets&&(o=W0(k[0],e.isHorizontal()?"width":"height",!0),R.forEach(F=>{F.style[e.isHorizontal()?"width":"height"]=o*(S.dynamicMainBullets+4)+"px"}),S.dynamicMainBullets>1&&C!==void 0&&(a+=E-(C||0),a>S.dynamicMainBullets-1?a=S.dynamicMainBullets-1:a<0&&(a=0)),N=Math.max(E-a,0),D=N+(Math.min(k.length,S.dynamicMainBullets)-1),M=(D+N)/2),k.forEach(F=>{const U=[...["","-next","-next-next","-prev","-prev-prev","-main"].map($=>`${S.bulletActiveClass}${$}`)].map($=>typeof $=="string"&&$.includes(" ")?$.split(" "):$).flat();F.classList.remove(...U)}),R.length>1)k.forEach(F=>{const U=Kh(F);U===E?F.classList.add(...S.bulletActiveClass.split(" ")):e.isElement&&F.setAttribute("part","bullet"),S.dynamicBullets&&(U>=N&&U<=D&&F.classList.add(...`${S.bulletActiveClass}-main`.split(" ")),U===N&&d(F,"prev"),U===D&&d(F,"next"))});else{const F=k[E];if(F&&F.classList.add(...S.bulletActiveClass.split(" ")),e.isElement&&k.forEach((U,$)=>{U.setAttribute("part",$===E?"bullet-active":"bullet")}),S.dynamicBullets){const U=k[N],$=k[D];for(let q=N;q<=D;q+=1)k[q]&&k[q].classList.add(...`${S.bulletActiveClass}-main`.split(" "));d(U,"prev"),d($,"next")}}if(S.dynamicBullets){const F=Math.min(k.length,S.dynamicMainBullets+4),U=(o*F-o)/2-M*o,$=b?"right":"left";k.forEach(q=>{q.style[e.isHorizontal()?$:"top"]=`${U}px`})}}R.forEach((k,N)=>{if(S.type==="fraction"&&(k.querySelectorAll(Ld(S.currentClass)).forEach(D=>{D.textContent=S.formatFractionCurrent(E+1)}),k.querySelectorAll(Ld(S.totalClass)).forEach(D=>{D.textContent=S.formatFractionTotal(A)})),S.type==="progressbar"){let D;D=S.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";const M=(E+1)/A;let F=1,U=1;D==="horizontal"?F=M:U=M,k.querySelectorAll(Ld(S.progressbarFillClass)).forEach($=>{$.style.transform=`translate3d(0,0,0) scaleX(${F}) scaleY(${U})`,$.style.transitionDuration=`${e.params.speed}ms`})}S.type==="custom"&&S.renderCustom?(k.innerHTML=S.renderCustom(e,E+1,A),N===0&&s("paginationRender",k)):(N===0&&s("paginationRender",k),s("paginationUpdate",k)),e.params.watchOverflow&&e.enabled&&k.classList[e.isLocked?"add":"remove"](S.lockClass)})}function m(){const b=e.params.pagination;if(c())return;const S=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length;let E=e.pagination.el;E=l(E);let C="";if(b.type==="bullets"){let R=e.params.loop?Math.ceil(S/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&R>S&&(R=S);for(let I=0;I<R;I+=1)b.renderBullet?C+=b.renderBullet.call(e,I,b.bulletClass):C+=`<${b.bulletElement} ${e.isElement?'part="bullet"':""} class="${b.bulletClass}"></${b.bulletElement}>`}b.type==="fraction"&&(C=b.renderFraction?b.renderFraction.call(e,b.currentClass,b.totalClass):`<span class="${b.currentClass}"></span> / <span class="${b.totalClass}"></span>`),b.type==="progressbar"&&(C=b.renderProgressbar?b.renderProgressbar.call(e,b.progressbarFillClass):`<span class="${b.progressbarFillClass}"></span>`),e.pagination.bullets=[],E.forEach(R=>{b.type!=="custom"&&(R.innerHTML=C||""),b.type==="bullets"&&e.pagination.bullets.push(...R.querySelectorAll(Ld(b.bulletClass)))}),b.type!=="custom"&&s("paginationRender",E[0])}function g(){e.params.pagination=rM(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});const b=e.params.pagination;if(!b.el)return;let S;typeof b.el=="string"&&e.isElement&&(S=e.el.querySelector(b.el)),S||typeof b.el!="string"||(S=[...document.querySelectorAll(b.el)]),S||(S=b.el),S&&S.length!==0&&(e.params.uniqueNavElements&&typeof b.el=="string"&&Array.isArray(S)&&S.length>1&&(S=[...e.el.querySelectorAll(b.el)],S.length>1&&(S=S.filter(E=>Yh(E,".swiper")[0]===e.el)[0])),Array.isArray(S)&&S.length===1&&(S=S[0]),Object.assign(e.pagination,{el:S}),S=l(S),S.forEach(E=>{b.type==="bullets"&&b.clickable&&E.classList.add(b.clickableClass),E.classList.add(b.modifierClass+b.type),E.classList.add(e.isHorizontal()?b.horizontalClass:b.verticalClass),b.type==="bullets"&&b.dynamicBullets&&(E.classList.add(`${b.modifierClass}${b.type}-dynamic`),a=0,b.dynamicMainBullets<1&&(b.dynamicMainBullets=1)),b.type==="progressbar"&&b.progressbarOpposite&&E.classList.add(b.progressbarOppositeClass),b.clickable&&E.addEventListener("click",f),e.enabled||E.classList.add(b.lockClass)}))}function v(){const b=e.params.pagination;if(c())return;let S=e.pagination.el;S&&(S=l(S),S.forEach(E=>{E.classList.remove(b.hiddenClass),E.classList.remove(b.modifierClass+b.type),E.classList.remove(e.isHorizontal()?b.horizontalClass:b.verticalClass),b.clickable&&E.removeEventListener("click",f)})),e.pagination.bullets&&e.pagination.bullets.forEach(E=>E.classList.remove(...b.bulletActiveClass.split(" ")))}r("changeDirection",()=>{if(!e.pagination||!e.pagination.el)return;const b=e.params.pagination;let{el:S}=e.pagination;S=l(S),S.forEach(E=>{E.classList.remove(b.horizontalClass,b.verticalClass),E.classList.add(e.isHorizontal()?b.horizontalClass:b.verticalClass)})}),r("init",()=>{e.params.pagination.enabled===!1?y():(g(),m(),p())}),r("activeIndexChange",()=>{e.snapIndex===void 0&&p()}),r("snapIndexChange",()=>{p()}),r("snapGridLengthChange",()=>{m(),p()}),r("destroy",()=>{v()}),r("enable disable",()=>{let{el:b}=e.pagination;b&&(b=l(b),b.forEach(S=>S.classList[e.enabled?"remove":"add"](e.params.pagination.lockClass)))}),r("lock unlock",()=>{p()}),r("click",(b,S)=>{const E=S.target,C=l(e.pagination.el);if(e.params.pagination.el&&e.params.pagination.hideOnClick&&C&&C.length>0&&!E.classList.contains(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&E===e.navigation.nextEl||e.navigation.prevEl&&E===e.navigation.prevEl))return;const R=C[0].classList.contains(e.params.pagination.hiddenClass);s(R===!0?"paginationShow":"paginationHide"),C.forEach(I=>I.classList.toggle(e.params.pagination.hiddenClass))}});const y=()=>{e.el.classList.add(e.params.pagination.paginationDisabledClass);let{el:b}=e.pagination;b&&(b=l(b),b.forEach(S=>S.classList.add(e.params.pagination.paginationDisabledClass))),v()};Object.assign(e.pagination,{enable:()=>{e.el.classList.remove(e.params.pagination.paginationDisabledClass);let{el:b}=e.pagination;b&&(b=l(b),b.forEach(S=>S.classList.remove(e.params.pagination.paginationDisabledClass))),g(),m(),p()},disable:y,render:m,update:p,init:g,destroy:v})}function qH(n){let e,t,{swiper:r,extendParams:s,on:i,emit:o,params:a}=n;r.autoplay={running:!1,paused:!1,timeLeft:0},s({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!0,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let l,c,d,f,p,m,g,v=a&&a.autoplay?a.autoplay.delay:3e3,y=a&&a.autoplay?a.autoplay.delay:3e3,b=new Date().getTime;function S(F){r&&!r.destroyed&&r.wrapperEl&&F.target===r.wrapperEl&&(r.wrapperEl.removeEventListener("transitionend",S),k())}const E=()=>{if(r.destroyed||!r.autoplay.running)return;r.autoplay.paused?c=!0:c&&(y=l,c=!1);const F=r.autoplay.paused?l:b+y-new Date().getTime();r.autoplay.timeLeft=F,o("autoplayTimeLeft",F,F/v),t=requestAnimationFrame(()=>{E()})},C=F=>{if(r.destroyed||!r.autoplay.running)return;cancelAnimationFrame(t),E();let U=F===void 0?r.params.autoplay.delay:F;v=r.params.autoplay.delay,y=r.params.autoplay.delay;const $=(()=>{let V;if(V=r.virtual&&r.params.virtual.enabled?r.slides.filter(z=>z.classList.contains("swiper-slide-active"))[0]:r.slides[r.activeIndex],!!V)return parseInt(V.getAttribute("data-swiper-autoplay"),10)})();!Number.isNaN($)&&$>0&&F===void 0&&(U=$,v=$,y=$),l=U;const q=r.params.speed,G=()=>{r&&!r.destroyed&&(r.params.autoplay.reverseDirection?!r.isBeginning||r.params.loop||r.params.rewind?(r.slidePrev(q,!0,!0),o("autoplay")):r.params.autoplay.stopOnLastSlide||(r.slideTo(r.slides.length-1,q,!0,!0),o("autoplay")):!r.isEnd||r.params.loop||r.params.rewind?(r.slideNext(q,!0,!0),o("autoplay")):r.params.autoplay.stopOnLastSlide||(r.slideTo(0,q,!0,!0),o("autoplay")),r.params.cssMode&&(b=new Date().getTime(),requestAnimationFrame(()=>{C()})))};return U>0?(clearTimeout(e),e=setTimeout(()=>{G()},U)):requestAnimationFrame(()=>{G()}),U},R=()=>{r.autoplay.running=!0,C(),o("autoplayStart")},I=()=>{r.autoplay.running=!1,clearTimeout(e),cancelAnimationFrame(t),o("autoplayStop")},A=(F,U)=>{if(r.destroyed||!r.autoplay.running)return;clearTimeout(e),F||(g=!0);const $=()=>{o("autoplayPause"),r.params.autoplay.waitForTransition?r.wrapperEl.addEventListener("transitionend",S):k()};if(r.autoplay.paused=!0,U)return m&&(l=r.params.autoplay.delay),m=!1,void $();l=(l||r.params.autoplay.delay)-(new Date().getTime()-b),r.isEnd&&l<0&&!r.params.loop||(l<0&&(l=0),$())},k=()=>{r.isEnd&&l<0&&!r.params.loop||r.destroyed||!r.autoplay.running||(b=new Date().getTime(),g?(g=!1,C(l)):C(),r.autoplay.paused=!1,o("autoplayResume"))},N=()=>{if(r.destroyed||!r.autoplay.running)return;const F=ri();F.visibilityState==="hidden"&&(g=!0,A(!0)),F.visibilityState==="visible"&&k()},D=F=>{F.pointerType==="mouse"&&(g=!0,A(!0))},M=F=>{F.pointerType==="mouse"&&r.autoplay.paused&&k()};i("init",()=>{r.params.autoplay.enabled&&(r.params.autoplay.pauseOnMouseEnter&&(r.el.addEventListener("pointerenter",D),r.el.addEventListener("pointerleave",M)),ri().addEventListener("visibilitychange",N),b=new Date().getTime(),R())}),i("destroy",()=>{r.el.removeEventListener("pointerenter",D),r.el.removeEventListener("pointerleave",M),ri().removeEventListener("visibilitychange",N),r.autoplay.running&&I()}),i("beforeTransitionStart",(F,U,$)=>{!r.destroyed&&r.autoplay.running&&($||!r.params.autoplay.disableOnInteraction?A(!0,!0):I())}),i("sliderFirstMove",()=>{!r.destroyed&&r.autoplay.running&&(r.params.autoplay.disableOnInteraction?I():(d=!0,f=!1,g=!1,p=setTimeout(()=>{g=!0,f=!0,A(!0)},200)))}),i("touchEnd",()=>{if(!r.destroyed&&r.autoplay.running&&d){if(clearTimeout(p),clearTimeout(e),r.params.autoplay.disableOnInteraction)return f=!1,void(d=!1);f&&r.params.cssMode&&k(),f=!1,d=!1}}),i("slideChange",()=>{!r.destroyed&&r.autoplay.running&&(m=!0)}),Object.assign(r.autoplay,{start:R,stop:I,pause:A,resume:k})}function HH(n){let{swiper:e,extendParams:t,emit:r,once:s}=n;t({freeMode:{enabled:!1,momentum:!0,momentumRatio:1,momentumBounce:!0,momentumBounceRatio:1,momentumVelocityRatio:1,sticky:!1,minimumVelocity:.02}}),Object.assign(e,{freeMode:{onTouchStart:function(){if(e.params.cssMode)return;const i=e.getTranslate();e.setTranslate(i),e.setTransition(0),e.touchEventsData.velocities.length=0,e.freeMode.onTouchEnd({currentPos:e.rtl?e.translate:-e.translate})},onTouchMove:function(){if(e.params.cssMode)return;const{touchEventsData:i,touches:o}=e;i.velocities.length===0&&i.velocities.push({position:o[e.isHorizontal()?"startX":"startY"],time:i.touchStartTime}),i.velocities.push({position:o[e.isHorizontal()?"currentX":"currentY"],time:yi()})},onTouchEnd:function(i){let{currentPos:o}=i;if(e.params.cssMode)return;const{params:a,wrapperEl:l,rtlTranslate:c,snapGrid:d,touchEventsData:f}=e,p=yi()-f.touchStartTime;if(o<-e.minTranslate())e.slideTo(e.activeIndex);else if(o>-e.maxTranslate())e.slides.length<d.length?e.slideTo(d.length-1):e.slideTo(e.slides.length-1);else{if(a.freeMode.momentum){if(f.velocities.length>1){const C=f.velocities.pop(),R=f.velocities.pop(),I=C.position-R.position,A=C.time-R.time;e.velocity=I/A,e.velocity/=2,Math.abs(e.velocity)<a.freeMode.minimumVelocity&&(e.velocity=0),(A>150||yi()-C.time>300)&&(e.velocity=0)}else e.velocity=0;e.velocity*=a.freeMode.momentumVelocityRatio,f.velocities.length=0;let m=1e3*a.freeMode.momentumRatio;const g=e.velocity*m;let v=e.translate+g;c&&(v=-v);let y,b=!1;const S=20*Math.abs(e.velocity)*a.freeMode.momentumBounceRatio;let E;if(v<e.maxTranslate())a.freeMode.momentumBounce?(v+e.maxTranslate()<-S&&(v=e.maxTranslate()-S),y=e.maxTranslate(),b=!0,f.allowMomentumBounce=!0):v=e.maxTranslate(),a.loop&&a.centeredSlides&&(E=!0);else if(v>e.minTranslate())a.freeMode.momentumBounce?(v-e.minTranslate()>S&&(v=e.minTranslate()+S),y=e.minTranslate(),b=!0,f.allowMomentumBounce=!0):v=e.minTranslate(),a.loop&&a.centeredSlides&&(E=!0);else if(a.freeMode.sticky){let C;for(let R=0;R<d.length;R+=1)if(d[R]>-v){C=R;break}v=Math.abs(d[C]-v)<Math.abs(d[C-1]-v)||e.swipeDirection==="next"?d[C]:d[C-1],v=-v}if(E&&s("transitionEnd",()=>{e.loopFix()}),e.velocity!==0){if(m=Math.abs(c?(-v-e.translate)/e.velocity:(v-e.translate)/e.velocity),a.freeMode.sticky){const C=Math.abs((c?-v:v)-e.translate),R=e.slidesSizesGrid[e.activeIndex];m=C<R?a.speed:C<2*R?1.5*a.speed:2.5*a.speed}}else if(a.freeMode.sticky)return void e.slideToClosest();a.freeMode.momentumBounce&&b?(e.updateProgress(y),e.setTransition(m),e.setTranslate(v),e.transitionStart(!0,e.swipeDirection),e.animating=!0,V0(l,()=>{e&&!e.destroyed&&f.allowMomentumBounce&&(r("momentumBounce"),e.setTransition(a.speed),setTimeout(()=>{e.setTranslate(y),V0(l,()=>{e&&!e.destroyed&&e.transitionEnd()})},0))})):e.velocity?(r("_freeModeNoMomentumRelease"),e.updateProgress(v),e.setTransition(m),e.setTranslate(v),e.transitionStart(!0,e.swipeDirection),e.animating||(e.animating=!0,V0(l,()=>{e&&!e.destroyed&&e.transitionEnd()}))):e.updateProgress(v),e.updateActiveIndex(),e.updateSlidesClasses()}else{if(a.freeMode.sticky)return void e.slideToClosest();a.freeMode&&r("_freeModeNoMomentumRelease")}(!a.freeMode.momentum||p>=a.longSwipesMs)&&(e.updateProgress(),e.updateActiveIndex(),e.updateSlidesClasses())}}}})}function GH(n){let e,t,r,{swiper:s,extendParams:i}=n;i({grid:{rows:1,fill:"column"}});const o=()=>{let a=s.params.spaceBetween;return typeof a=="string"&&a.indexOf("%")>=0?a=parseFloat(a.replace("%",""))/100*s.size:typeof a=="string"&&(a=parseFloat(a)),a};s.grid={initSlides:a=>{const{slidesPerView:l}=s.params,{rows:c,fill:d}=s.params.grid;r=Math.floor(a/c),e=Math.floor(a/c)===a/c?a:Math.ceil(a/c)*c,l!=="auto"&&d==="row"&&(e=Math.max(e,l*c)),t=e/c},updateSlide:(a,l,c,d)=>{const{slidesPerGroup:f}=s.params,p=o(),{rows:m,fill:g}=s.params.grid;let v,y,b;if(g==="row"&&f>1){const S=Math.floor(a/(f*m)),E=a-m*f*S,C=S===0?f:Math.min(Math.ceil((c-S*m*f)/m),f);b=Math.floor(E/C),y=E-b*C+S*f,v=y+b*e/m,l.style.order=v}else g==="column"?(y=Math.floor(a/m),b=a-y*m,(y>r||y===r&&b===m-1)&&(b+=1,b>=m&&(b=0,y+=1))):(b=Math.floor(a/t),y=a-b*t);l.row=b,l.column=y,l.style[d("margin-top")]=b!==0?p&&`${p}px`:""},updateWrapperSize:(a,l,c)=>{const{centeredSlides:d,roundLengths:f}=s.params,p=o(),{rows:m}=s.params.grid;if(s.virtualSize=(a+p)*e,s.virtualSize=Math.ceil(s.virtualSize/m)-p,s.wrapperEl.style[c("width")]=`${s.virtualSize+p}px`,d){const g=[];for(let v=0;v<l.length;v+=1){let y=l[v];f&&(y=Math.floor(y)),l[v]<s.virtualSize+l[0]&&g.push(y)}l.splice(0,l.length),l.push(...g)}}}}const sM=T.memo(({children:n,className:e,...t})=>_.jsx(tb,{...t,className:jt("bs-carousel__slide",e),children:n})),iM=T.forwardRef(({style:n,children:e,userAgent:t,className:r,spaceBetween:s,carouselStyle:i,isLtr:o=!1,onSlideChange:a,virtual:l=!1,freeMode:c=!1,keyboard:d=!1,autoplay:f=!1,breakpoints:p={},carouselClassName:m,otherOptions:g={},isVertical:v=!1,pagination:y=!1,navigation:b=!1,slidesPerView:S="auto"},E)=>{const C=T.useRef(null),[R,I]=T.useState(!1),A=T.useId().replace(/:/g,"_"),k=T.useMemo(()=>Object.entries(p||{}).reduce((F,[U,$])=>U in nM?{...F,[nM[U].replace("px","")]:$}:{...F,[U]:$},{}),[p]),N=T.useMemo(()=>R?null:(({isLtr:F,carouselId:U,isVertical:$,breakpoints:q,spaceBetween:G,slidesPerView:V})=>{const z=P=>`.bs-carousel[data-carousel-id=${U}]:not(.bs-carousel--is-loaded) .bs-carousel__slide { ${P} }`;let B=z(DL({isLtr:F,isVertical:$,spaceBetween:G,slidesPerView:V}));return Object.entries(q||{}).forEach(([P,H])=>{B+=`
58 @media (min-width: ${P}px) {
59 ${z(DL({isLtr:F,isVertical:$,slidesPerView:H.slidesPerView,spaceBetween:H.spaceBetween??G}))}
60 }
61 `}),B})({isLtr:o,isVertical:v,spaceBetween:s,slidesPerView:S,carouselId:A,breakpoints:k}),[R,s,S,k,o,v,A]),D=T.useCallback(F=>{I(!0),C.current=F},[]);T.useImperativeHandle(E,()=>{var F;return{swiper:C.current,next:()=>{var U;return(U=C.current)==null?void 0:U.slideNext()},prev:()=>{var U;return(U=C.current)==null?void 0:U.slidePrev()},activeSlideIndex:(F=C.current)==null?void 0:F.realIndex,slideTo:(U,$,q)=>{var G;return(G=C.current)==null?void 0:G.slideTo(U,$,q)}}},[]);const M=T.useMemo(()=>({virtual:l,autoplay:f,keyboard:d,freeMode:c,userAgent:t,navigation:b,pagination:y,spaceBetween:s,slidesPerView:S,breakpoints:k,direction:v?"vertical":"horizontal",modules:[$H,zH,qH,FH,UH,HH,BH,GH]}),[c,f,b,v,y,s,S,l,k,d,t]);return _.jsxs(_.Fragment,{children:[N&&_.jsx("style",{children:N}),_.jsx("div",{style:n,"data-carousel-id":A,className:jt("bs-carousel",{"bs-carousel--is-loaded":R},r),children:_.jsx(tM,{...M,...g,style:i,dir:o?"ltr":"rtl",className:m,onSwiper:D,onSlideChange:a,children:e})})]})});sM.displayName=tb.displayName,iM.displayName="BsCarousel";const nb=iM;nb.Item=sM,nb.propTypes=jH,nb.displayName="BsCarousel";const VH={name:O.string,onBlur:O.func,label:O.string,checked:O.bool,disabled:O.bool,onChange:O.func,children:O.node,className:O.string,defaultChecked:O.bool,size:O.oneOf(["sm","md"]),value:O.oneOfType([O.string,O.number])},WH={onChange:O.func,children:O.node,value:O.array.isRequired},oM=T.createContext({isInGroup:!1}),KH=oM.Provider,rb=({value:n,onChange:e,children:t})=>_.jsx(KH,{value:{checked:n,isInGroup:!0,onChange:(r,s)=>{e==null||e(s?[...n,r]:n.filter(i=>i!==r))}},children:t});rb.propTypes=WH,rb.displayName="BsCheckboxGroup";const Wi=T.forwardRef(({name:n,label:e,value:t,onBlur:r,checked:s,disabled:i,children:o,onChange:a,className:l,size:c="sm",indeterminate:d,defaultChecked:f},p)=>{const m=T.useId(),g=Mt.useFallbackRef(p),v=T.useContext(oM),y=T.useMemo(()=>{var b;return!!d||(s!==void 0?s:v.isInGroup&&t?(b=v.checked)==null?void 0:b.includes(t):f)},[d,s,v.isInGroup,v.checked,t,f]);return T.useEffect(()=>{f&&s===void 0&&g.current&&(g.current.checked=!0)},[]),T.useEffect(()=>{g.current&&(g.current.indeterminate=d||!1)},[d,g]),_.jsxs("label",{htmlFor:m,"aria-disabled":i,className:jt("bs-checkbox",`bs-checkbox--${c}`,"bs-checkbox--"+(i?"disabled":"enabled"),"bs-checkbox--"+(d?"indeterminate":"determinate"),l),children:[_.jsx("input",{id:m,ref:g,name:n,value:t,type:"checkbox",checked:y,disabled:i,className:"bs-checkbox__input",onBlur:r,onChange:b=>{a&&a(b),v.onChange&&v.onChange(typeof t=="number"?Number(b.target.value):b.target.value,b.target.checked)}}),_.jsxs("span",{className:"bs-checkbox__el",children:[_.jsx("i",{className:"bs-checkbox__el-icon bi-tick-single"}),d&&_.jsx("i",{className:"bs-checkbox__el-indeterminate"})]}),e&&_.jsx("span",{className:"bs-checkbox__label",children:e}),o]})});Wi.Group=rb,Wi.propTypes=VH,Wi.displayName="BsCheckbox";const YH={size:O.number,value:O.number,thickness:O.number,color:O.oneOf(["primary","black","white"])},sb=({value:n,className:e,size:t=20,thickness:r=2,color:s="primary"})=>{const i=T.useMemo(()=>(t-2*r)/2,[t,r]),o=T.useMemo(()=>2*i*Math.PI,[i]),a=o-n/100*o;return _.jsx("div",{className:jt(e,"bs-circular-progress",`bs-circular-progress--${s}`),children:_.jsx("svg",{width:t,height:t,className:"bs-circular-progress__svg",children:_.jsx("circle",{cx:t/2,cy:t/2,fill:"transparent",r:i,strokeWidth:r,style:{strokeDashoffset:a},className:"bs-circular-progress__svg-circle",strokeDasharray:`${o} ${o}`})})})};sb.propTypes=YH,sb.displayName="BsCircularProgress";const XH={name:O.string,color:O.string,className:O.string,size:O.oneOf(["16","20","24","32"])},Mn=({size:n="24",name:e="bi-close",color:t,className:r}={})=>_.jsx("i",{style:t?{color:t}:{},className:jt(e,"bs-icon",`bs-icon--size-${n}`,r)});Mn.propTypes=XH,Mn.displayName="BsIcon";const aM=T.forwardRef(({children:n,windowSize:e,style:t={},middleScroll:r,initialScroll:s,closeBreakpoint:i,wrapperComponent:o,isVisible:a=!1,partialOpen:l=!1,onClose:c=()=>null,isBottomSheet:d=!1,showSlideButton:f=!1,canBeClosed:p=g=>!0},m)=>{const g=T.useRef(null),v=T.useRef(null),y=T.useRef(0),b=T.useRef(!1),S=T.useRef(null),E=T.useRef(),C=T.useRef(!1),R=T.useRef(null),[I,A]=T.useState("UP"),k={height:d?e.height-1+"px":"",...t},N=T.useMemo(()=>e.height-32-12,[e]),D=async(B,P=300)=>{C.current=!0;const H=v.current;await de.animateValue({to:B,duration:P,from:(H==null?void 0:H.scrollTop)??B,step:Z=>{H&&(H.scrollTop=Z)}}),setTimeout(()=>{C.current=!1},50)},M=()=>{var B;return g.current||(g.current=(B=v.current)==null?void 0:B.querySelector(".bs-modal__dialog")),g.current},F=T.useCallback((B=1)=>{if(!d)return;const P=M();P&&(P.style.opacity=`${B}`)},[d]),U=T.useCallback(()=>{const B=M(),P=s??e.height/(l?3:1.2);return B&&B.offsetHeight<P?B.offsetHeight:P},[s,e,l]),$=T.useCallback(()=>{d&&D(U())},[d,U]),q=T.useCallback(()=>{var P,H;if(!d)return;S.current||(S.current=new ResizeObserver(Z=>{var J;const{height:Q}=Z[0].contentRect;y.current<Q&&(((J=v.current)==null?void 0:J.scrollTop)||0)<U()&&$(),y.current=Q}));const B=M();B&&((H=(P=S.current)==null?void 0:P.observe)==null||H.call(P,B))},[d,U,$]),G=T.useCallback(()=>{try{const B=M();S.current&&B&&S.current.unobserve(B)}catch(B){console.warn("bs-wrapper-resize-observer::",B)}},[]),V=()=>{p("backdrop")?c():(F(1),$())},z=()=>{if(I==="UP"){const B=M();B&&D(B.offsetHeight),A("DOWN")}else D(U()),A("UP")};return T.useImperativeHandle(m,()=>v.current,[a]),T.useEffect(()=>{d&&(a?(F(1),q()):G())},[a]),Mt.useEffectNoImmediate(()=>{d&&$()},[d]),Mt.useUnmount(()=>{G()}),_.jsxs("div",{ref:v,role:"dialog",style:k,onScroll:B=>{var H;R.current&&clearTimeout(R.current);const P=(H=B==null?void 0:B.currentTarget)==null?void 0:H.scrollTop;setTimeout(()=>{if(!d||!a||C.current)return;f&&(()=>{const Q=M(),J=v.current;J&&Q&&A(J.scrollTop>=Q.offsetHeight?"DOWN":"UP")})(),E.current=void 0;const Z=(()=>{const Q=M(),J=i??e.height/3;return Q?Q.offsetHeight<J?Q.offsetHeight/1.2:J:0})();F(1-(P<Z?(Z-P)/Z:0)),R.current=setTimeout(()=>{let Q=null;const J=(()=>{const ee=M(),K=r??e.height/1.4;return ee&&ee.offsetHeight<K?ee.offsetHeight:K})();P<Z?Q=V:P<J&&(Q=()=>D(J)),Q&&(b.current?E.current=Q:Q())},100)},0)},onTouchEnd:()=>{var B;b.current=!1,(B=E.current)==null||B.call(E)},onTouchStart:()=>{b.current=!0},className:"bs-modal__wrapper",children:[o,f&&d&&_.jsx("i",{role:"button",tabIndex:0,style:{top:`${N}px`},className:"bs-modal__slide "+(I==="UP"?"bi-angle-up":"bi-angle-down"),onClick:z,onKeyDown:z}),n]})});aM.displayName="BsModalWrapper";const lM=T.forwardRef(({onClose:n,children:e,isVisible:t,windowSize:r,isBottomSheet:s,style:i={}},o)=>{const a=Mt.useFallbackRef(o),l=T.useRef({x:0,y:0}),c=T.useMemo(()=>s?{paddingTop:`${r.height}px`,...i}:i,[s,r,i]),d=m=>{var y,b;if(m.target!==a.current)return;const g="clientX"in m?m.clientX:((y=m.touches[0])==null?void 0:y.clientX)||0,v="clientY"in m?m.clientY:((b=m.touches[0])==null?void 0:b.clientY)||0;l.current={x:g,y:v}},f=m=>{m.target===a.current&&(l.current={x:0,y:0})},p=m=>{var S,E;if(m.target!==a.current)return;const g="clientX"in m?m.clientX:((S=m.changedTouches[0])==null?void 0:S.clientX)||0,v="clientY"in m?m.clientY:((E=m.changedTouches[0])==null?void 0:E.clientY)||0,{x:y,y:b}=l.current;t&&y===g&&b===v&&n("backdrop")};return _.jsx("div",{role:"dialog",ref:a,style:c,className:"bs-modal__container",onMouseUp:p,onTouchEnd:p,onMouseMove:f,onTouchMove:f,onMouseDown:d,onTouchStart:d,children:e})});function cM(n){try{if(n){const e=getComputedStyle(n,null);return Number.parseFloat(e.paddingTop)+Number.parseFloat(e.paddingBottom)}return 0}catch{return 0}}lM.displayName="BsModalContainer";const ib=(n,e)=>{const t=n.current;t&&(t.style.maxHeight=e?`${e}px`:"")},uM=T.forwardRef(({title:n,onBack:e,subtitle:t,className:r,showHeader:s,size:i="md",beforeClose:o,show:a=!1,primaryButton:l,tertiaryButton:c,bodyClass:d="",isPlain:f=!1,children:p=null,noClose:m=!1,headerComponent:g,footerComponent:v,secondaryButton:y,showClose:b=!0,showBack:S=!1,wrapperComponent:E,headerClass:C="",footerClass:R="",hasPopstate:I=!0,partialOpen:A=!1,onShow:k=()=>null,onClose:N=()=>null,isFullScreen:D=!1,backIcon:M="bi-right",headerAppendComponent:F,bottomSheetMode:U=!0,closeOnBackdrop:$=!0,closeIcon:q="bi-close",headerPrependComponent:G,hideOtherModals:V=!1,showSlideButton:z=!1,isInternalScroll:B=!0,bottomSheetMiddleScroll:P,bottomSheetInitialScroll:H,bottomSheetCloseBreakpoint:Z,isFullScreenBordered:Q=!1},J)=>{var Wt;const ee=T.useId(),{windowSize:K,isPhone:W}=Mt.useWindowSize(),te=T.useMemo(()=>({uid:ee,data:{hideOtherModals:V}}),[ee,V]),[re,pe]=T.useState(!1),[Ee,le]=T.useState(!1),[Ie,be]=T.useState(de.popupManager.topElements[0]),ge=T.useRef(null),Ae=T.useRef(null),Re=T.useRef(null),tt=T.useRef(null),et=T.useRef(null),Oe=T.useRef(null),ht=T.useRef(null),Xe=T.useRef(null);T.useImperativeHandle(J,()=>({bodyRef:Oe,modalWrapperRef:Xe}),[re]);const Je=D||Q,qe=W&&U&&!Je,Ue=re&&(Ie==null?void 0:Ie.uid)===ee,it=!f&&!!(g||n||s),nt=!!l||!!y||!!c,dt=!f&&(!!v||nt),Ot=jt([r,`bs-modal--size-${i}`,{"bs-modal--plain":f,"bs-modal--is-hidden":!(!re||Ue||!((Wt=Ie==null?void 0:Ie.data)!=null&&Wt.hideOtherModals)),"bs-modal--has-header":it,"bs-modal--has-footer":dt,"bs-modal--is-visible":re,"bs-modal--full-screen":Je,"bs-modal--bottom-sheet-mode":qe,"bs-modal--internal-scroll":B,"bs-modal--full-screen-bordered":Q}]),xt=T.useMemo(()=>{const ot={maxWidth:""},nn=["bs-modal__dialog",{"bs-modal__dialog--shake":Ee}];return["xs","sm","md","lg","xl"].includes(i)?nn.push(`bs-modal__dialog--size-${i}`):ot.maxWidth=i,{style:ot,className:jt(nn)}},[i,Ee]),rt=T.useCallback(ot=>!(m||ot==="backdrop"&&!$||typeof o=="function"&&!o()),[m,$,o]),Me=T.useCallback(ot=>{rt(ot)?pe(!1):(le(!0),setTimeout(()=>le(!1),100))},[rt]),lt=T.useCallback(ot=>{ot.key==="Escape"&&Ue&&re&&Me()},[Me,Ue,re]),Vt=T.useCallback(()=>{if(re||!I||typeof window>"u")return;const ot=window.history;ot.state&&ot.state.bsModalVmId===ee&&ot.back()},[re,I,ee]),vn=T.useCallback(()=>{var ot,nn;I&&typeof window<"u"&&((nn=(ot=window.history)==null?void 0:ot.state)==null?void 0:nn.bsModalVmId)!==ee&&window.history.pushState({bsModalVmId:ee,isCustomHistory:!0},"","")},[I,ee]),pt=T.useCallback(ot=>{Ue&&(!ot.state||ot.state&&ot.state.bsModalVmId!==ee&&!ot.state.isInModalHistoryChanger)&&(Me("backdrop"),rt("backdrop")||vn())},[Me,Ue,rt,vn,ee]),mt=T.useCallback(async()=>{var ot,nn;if(B&&!Je){await de.sleep(20);try{const tn=it&&((ot=et.current)==null?void 0:ot.clientHeight)||0,En=dt&&((nn=ht.current)==null?void 0:nn.clientHeight)||0,$n=cM(Ae.current),_n=cM(Re.current),sr=window.innerHeight-_n-$n-tn-En-8;ib(Oe,sr)}catch{ib(Oe,null)}}else ib(Oe,null)},[B,Je,it,dt]),gt=T.useCallback((ot=re)=>{ot?k&&k():setTimeout(()=>{typeof N=="function"&&N()},400)},[re,k,N]);return T.useEffect(()=>{a!==re&&(a?(async ot=>{await de.waitUntil(()=>!!ge.current,{threshold:5,waitTime:2e3}),await de.sleep(10),ot()})(()=>{pe(!0),gt(!0),vn(),ge.current&&(ge.current.style.zIndex=`${de.popupManager.getNewZIndex()}`),mt(),de.popupManager.setIsOpen(te)}):pe(!1))},[a]),Mt.useEffectNoImmediate(()=>{re||(Vt(),gt(!1),de.popupManager.setIsClosed(te,400))},[re]),T.useEffect(()=>(document.addEventListener("keydown",lt),window.addEventListener("popstate",pt),()=>{document.removeEventListener("keydown",lt),window.removeEventListener("popstate",pt)}),[lt,pt]),T.useEffect(()=>{const ot=nn=>{be(nn.detail[0])};return de.popupManager.subscribe(ot),()=>{pe(!1),de.popupManager.unsubscribe(ot),de.popupManager.setIsClosed(te,400),Vt()}},[]),_.jsx(Ed,{children:_.jsxs("div",{ref:ge,className:jt(["bs-modal",Ot]),children:[_.jsx(aM,{ref:Xe,isVisible:re,windowSize:K,partialOpen:A,canBeClosed:rt,isBottomSheet:qe,showSlideButton:z,wrapperComponent:E,middleScroll:P,initialScroll:H,closeBreakpoint:Z,onClose:()=>Me("backdrop"),children:_.jsx(lM,{ref:Ae,onClose:Me,isVisible:re,windowSize:K,isBottomSheet:qe,children:_.jsx("div",{ref:Re,className:xt.className,style:{...xt.style},children:_.jsxs("div",{ref:tt,className:"bs-modal__content",children:[it&&_.jsxs("header",{ref:et,className:jt(["bs-modal__header",C]),children:[_.jsxs(je,{display:"flex",alignItems:"center",children:[G,S&&_.jsx("button",{"aria-label":"back",className:"bs-modal__back",onClick:ot=>{ot.preventDefault(),e?e():Me()},children:_.jsx(Mn,{size:"24",name:M})}),g,n&&_.jsx("span",{className:"bs-modal__title",children:n}),b&&_.jsx("button",{"aria-label":"close",className:"bs-modal__close",onClick:ot=>{ot.preventDefault(),Me()},children:_.jsx(Mn,{size:"24",name:q})}),F]}),!!t&&_.jsx("div",{className:"bs-modal__subtitle",children:t})]}),_.jsx("div",{ref:Oe,className:jt("bs-modal__body",d),children:p}),dt&&_.jsx("footer",{ref:ht,className:jt("bs-modal__footer",{"bs-modal__footer-default":nt},R),children:nt?_.jsxs(_.Fragment,{children:[!!l&&_.jsx("div",{className:jt("bs-modal__button","bs-modal__button--primary"),children:l}),!!y&&_.jsx("div",{className:jt("bs-modal__button","bs-modal__button--secondary"),children:y}),!!c&&_.jsx("div",{className:jt("bs-modal__button","bs-modal__button--tertiary"),children:c})]}):v})]})})})}),_.jsx("div",{role:"dialog",onClick:()=>Me(),className:"bs-modal__backdrop"})]})})});uM.displayName="BsModalComponent";const dM={show:O.bool,size:O.string,onBack:O.func,isPlain:O.bool,title:O.string,noClose:O.bool,zIndex:O.number,showBack:O.bool,showClose:O.bool,subtitle:O.string,backIcon:O.string,showHeader:O.bool,appendTo:O.string,lockScroll:O.bool,className:O.string,beforeClose:O.func,closeIcon:O.string,hasPopstate:O.bool,partialOpen:O.bool,keepMounted:O.bool,bodyClass:O.string,headerClass:O.string,footerClass:O.string,bottomSheetMode:O.bool,closeOnBackdrop:O.bool,hideOtherModals:O.bool,showSlideButton:O.bool,isFullScreenBordered:O.bool,bottomSheetMiddleScroll:O.number,bottomSheetInitialScroll:O.number,bottomSheetCloseBreakpoint:O.number,isFullScreen:O.oneOfType([O.bool]),isInternalScroll:O.oneOfType([O.bool])},lr=T.forwardRef(({show:n,keepMounted:e,onClose:t,...r},s)=>{const[i,o]=T.useState(!1),[a,l]=T.useState(!1),c=T.useCallback(()=>{e||o(!1),l(!1),t==null||t()},[t]);return T.useEffect(()=>{n!==a&&(n?(o(!0),l(!0)):l(!1))},[n]),i?_.jsx(uM,{...r,ref:s,show:a,keepMounted:e,onClose:c}):null});lr.propTypes=dM,lr.displayName="BsModal";const QH={loading:O.bool,title:O.string,onCancel:O.func,onConfirm:O.func,showCancel:O.bool,buttonSize:O.string,cancelIcon:O.string,modalProps:O.object,description:O.string,confirmIcon:O.string,cancelLabel:O.string,cancelColor:O.string,confirmLabel:O.string,confirmColor:O.string,show:O.bool.isRequired,cancelVariant:O.string,confirmVariant:O.string,onClose:O.func.isRequired,cancelButtonProps:O.object,confirmButtonProps:O.object},Md=({loading:n=!1,show:e=!1,title:t="",description:r="",showCancel:s=!0,buttonSize:i="lg",confirmLabel:o="بله",confirmColor:a="primary",confirmVariant:l="text",confirmIcon:c="",confirmButtonProps:d,cancelLabel:f="خیر",cancelColor:p="secondary",cancelVariant:m="text",cancelIcon:g="",cancelButtonProps:v,modalProps:y,children:b,onCancel:S,onConfirm:E,onClose:C})=>{const R=T.useCallback(()=>{C==null||C()},[C]),I=T.useCallback(()=>{E?E():R()},[E,R]),A=T.useCallback(()=>{S?S():R()},[S,R]),k={size:i,icon:g,disabled:n,label:f,color:p,variant:m,...v},N={loading:n,size:i,icon:c,label:o,color:a,variant:l,...d},D=_.jsxs("div",{className:"bs-confirm__footer",children:[s&&_.jsx(Qe,{className:"bs-confirm__cancel",...k,onClick:A}),_.jsx(Qe,{className:"bs-confirm__submit",...N,onClick:I})]});return _.jsx(lr,{size:"sm",show:e,title:t,showClose:!0,noClose:n,className:"bs-confirm",hideOtherModals:!1,footerComponent:D,...y,onClose:R,children:_.jsxs("div",{className:"bs-confirm__description",children:[r,b]})})};Md.propTypes=QH,Md.displayName="BsConfirm";const JH={fluid:O.bool,children:O.node,className:O.string},Jh=({fluid:n,children:e,className:t=""})=>_.jsx("div",{className:jt(t,"bs-container",{"bs-container--fluid":n}),children:e});Jh.propTypes=JH,Jh.displayName="BsContainer";const ZH={children:O.func.isRequired,value:O.oneOfType([O.string,O.number]).isRequired},Ic=({children:n,value:e})=>{const[t,r]=T.useState(!1);return T.useEffect(()=>{let s;return t&&(s=setTimeout(()=>r(!1),2e3)),()=>{clearTimeout(s)}}),n({copy:s=>{de.copy(typeof s=="string"?s:e??""),r(!0)},copied:t})};Ic.propTypes=ZH,Ic.displayName="BsCopy";const e5={id:O.string,min:O.number,max:O.number,title:O.node,label:O.node,suffix:O.node,name:O.string,type:O.string,rows:O.number,onBlur:O.func,error:O.string,onFocus:O.func,disabled:O.bool,readonly:O.bool,autoSize:O.bool,ltrInput:O.bool,onChange:O.func,autoFocus:O.bool,isNumeric:O.bool,caption:O.string,tabIndex:O.number,isRequired:O.bool,maxLength:O.number,isMultiline:O.bool,suffixIcon:O.string,isErrorFloat:O.bool,placeholder:O.string,captionIcon:O.string,convertNumbers:O.bool,autoComplete:O.string,indentFirstLine:O.bool,scrollAfterFocus:O.bool,wrapperClassName:O.string,showMaxLengthCounter:O.bool,value:O.oneOfType([O.string,O.number]),defaultValue:O.oneOfType([O.string,O.number])},Nd=T.forwardRef(({id:n,min:e,max:t,name:r,value:s,title:i,label:o,error:a,suffix:l,onBlur:c,caption:d,onFocus:f,onChange:p,rows:m=2,maxLength:g,autoFocus:v,suffixIcon:y,isMultiline:b,placeholder:S,captionIcon:E,size:C="md",defaultValue:R,autoComplete:I,tabIndex:A=0,type:k="text",align:N="right",autoSize:D=!0,ltrInput:M=!1,wrapperClassName:F,disabled:U=!1,readonly:$=!1,isNumeric:q=!1,isRequired:G=!1,isErrorFloat:V=!1,convertNumbers:z=!0,indentFirstLine:B=!0,showMaxLengthCounter:P=!0},H)=>{const Z=T.useId(),Q=Mt.useFallbackRef(H),J=T.useRef(null),ee=T.useRef(null),K=a||d,W=n||`bs_input__${Z}`,[te,re]=T.useState(!1),pe=b&&B&&!!o&&!M&&N!=="center",Ee=ge=>{z&&(ge.target.value=de.toEnglishDigits(ge.target.value)),q&&(ge.target.value=ge.target.value.replace(/[^\d,.]/g,"")),b&&D&&Q.current&&(Q.current.style.height="auto",Q.current.style.height=`${Q.current.scrollHeight}px`),g&&P&&ee.current&&(ge.target.value.length>g?ee.current.classList.add("bs-input__counter--error"):ee.current.classList.remove("bs-input__counter--error"),ee.current.textContent=g-ge.target.value.length+" کاراکتر"),p==null||p(ge)},le=ge=>{re(!0),f==null||f(ge)},Ie=ge=>{re(!1);const Ae=ge.target.value;e!==void 0&&Number(Ae)<Number(e)&&(ge.target.value=`${e}`,Ee(ge)),t!==void 0&&Number(Ae)>Number(t)&&(ge.target.value=`${t}`,Ee(ge)),c==null||c(ge)},be=jt("bs-input",F,`bs-input--size-${C}`,`bs-input--type-${k}`,`bs-input--align-${N}`,{"bs-input--dir-ltr":M,"bs-input--focused":te,"bs-input--readonly":$,"bs-input--disabled":U,"bs-input--has-title":!!i,"bs-input--has-error":!!a,"bs-input--has-indent":pe,"bs-input--is-required":G,"bs-input--is-multiline":b,"bs-input--is-error-float":V});return T.useEffect(()=>{if(!pe)return;const ge=J.current?J.current.offsetWidth+10:0;Q.current&&(Q.current.style.textIndent=ge?`${ge}px`:"")},[pe,Q]),T.useEffect(()=>{R&&Q.current&&(Q.current.value=String(R))},[R,Q]),_.jsxs("div",{className:be,"data-type":k,children:[_.jsxs("div",{className:"bs-input__head",children:[i&&_.jsx("p",{className:"bs-input__title",children:i}),g&&P&&_.jsx("p",{ref:ee,className:"bs-input__counter"})]}),_.jsxs("div",{className:"bs-input__container",children:[o&&_.jsx("label",{className:"bs-input__label",htmlFor:W,ref:J,children:o}),b?_.jsx("textarea",{ref:Q,name:r,rows:m,id:W,value:s,tabIndex:A,onBlur:Ie,readOnly:$,disabled:U,onFocus:le,maxLength:g,autoFocus:v,onChange:Ee,placeholder:S,autoComplete:I,className:"bs-input__input"}):_.jsx("input",{min:e,max:t,ref:Q,name:r,type:k,id:W,value:s,tabIndex:A,onBlur:Ie,readOnly:$,disabled:U,autoFocus:v,maxLength:g,onFocus:le,onChange:Ee,placeholder:S,autoComplete:I,className:"bs-input__input"}),(y||l)&&_.jsxs("div",{className:"bs-input__suffix",children:[l&&_.jsx("span",{children:l}),y&&_.jsx("i",{className:y})]}),K&&_.jsxs("p",{className:"bs-input__caption",children:[E&&_.jsx("i",{className:E}),_.jsx("span",{children:K})]})]})]})});Nd.propTypes=e5,Nd.displayName="BsInput";const fM=async n=>{await de.sleep(10),n()},t5=({show:n,coords:e,onClose:t,children:r,anchorEl:s,className:i="",transition:o="fade",getAwayThreshold:a=100,animationDuration:l=250,position:c="bottom-right"})=>{const d=T.useId(),f=T.useRef({uid:d}),p=T.useRef(null),m=T.useRef(null),[g,v]=T.useState(!1),y=T.useCallback(b=>{var I,A;if(typeof(e==null?void 0:e.top)!="number"||typeof(e==null?void 0:e.left)!="number"||!t)return;const S=a+(((I=m.current)==null?void 0:I.clientHeight)||0),E=a+(((A=m.current)==null?void 0:A.clientWidth)||0),C=b.pageY-e.top,R=b.pageX-e.left;(C>S||C<-1*S)&&t(),(R>E||R<-1*E)&&t()},[e==null?void 0:e.top,e==null?void 0:e.left,a,t]);return Mt.useIsomorphicEffect(()=>(n?(de.popupManager.setIsOpen(f.current),fM(()=>{typeof(e==null?void 0:e.top)=="number"&&typeof(e==null?void 0:e.left)=="number"&&document.addEventListener("mousemove",y),p.current&&(p.current.style.zIndex=`${de.popupManager.getNewZIndex()}`)})):de.popupManager.setIsClosed(f.current,l),()=>{document.removeEventListener("mousemove",y),de.popupManager.setIsClosed(f.current,l)}),[n]),T.useEffect(()=>{n?fM(()=>v(!0)):v(!1)},[n]),T.useEffect(()=>{const b=E=>{var C;E.key==="Escape"&&((C=de.popupManager.topElements[0])==null?void 0:C.uid)===d&&(t==null||t())};document.addEventListener("keydown",b);const S=f.current;return()=>{document.removeEventListener("keydown",b),de.popupManager.setIsClosed(S,l)}},[]),_.jsx(Ed,{children:_.jsx(Mr,{keepMounted:!0,mounted:g,transition:o,duration:l,onEnter:()=>{const b=m.current;if(e){if(typeof(e==null?void 0:e.top)=="number"&&typeof(e==null?void 0:e.left)=="number"&&b){const S=b.offsetWidth,E=b.offsetHeight;e.left-S<0?b.style.right=window.innerWidth-e.left-S+"px":b.style.left=e.left-S+"px",e.top+E>window.innerHeight?b.style.bottom=window.innerHeight-e.top+"px":b.style.top=`${e.top}px`}}else{const S=s==null?void 0:s.getBoundingClientRect(),[E,C]=c.split("-"),R=(S==null?void 0:S.bottom)||0,I=window.innerWidth-((S==null?void 0:S.right)||0),A=(S==null?void 0:S.x)||0,k=(S==null?void 0:S.y)||0;if(!(b!=null&&b.style))return;const N=b.clientWidth,D=b.clientHeight;C==="right"&&I+N<window.innerWidth||((S==null?void 0:S.right)||0)+N>window.innerWidth?b.style.right=`${I}px`:b.style.left=`${A}px`,E==="bottom"&&R+D<window.innerHeight||k<D?b.style.top=`${R}px`:b.style.bottom=window.innerHeight-k+"px"}},children:b=>_.jsxs("div",{className:jt("bs-popover",{"bs-popover--visible":g}),ref:p,children:[_.jsx("div",{onClick:t,className:"bs-popover__wrapper"}),_.jsx("div",{style:b,ref:m,className:jt(["bs-popover__content",{[i]:!!i}]),children:r})]})})})},n5={onClose:O.func,children:O.node,className:O.string,transition:NL,show:O.bool.isRequired,getAwayThreshold:O.number,animationDuration:O.number,position:O.oneOf(["top-left","top-right","bottom-left","bottom-right"]),anchorEl:O.oneOfType([O.element,O.object,O.func]),coords:O.shape({top:O.number.isRequired,left:O.number.isRequired})},ob=({show:n,keepMounted:e=!1,onClose:t,...r})=>{const[s,i]=T.useState(!1),[o,a]=T.useState(!1),l=T.useCallback(()=>{e||i(!1),a(!1),t==null||t()},[e,t]);return T.useEffect(()=>{n!==o&&(n?(i(!0),a(!0)):(a(!1),l()))},[n]),s?_.jsx(t5,{...r,show:o,keepMounted:e,onClose:l}):null};ob.propTypes=n5,ob.displayName="BsPopover",O.bool,O.string,O.func,O.string,O.bool,O.string,O.object,O.object,O.string,O.shape(dM),O.oneOf(["start","end"]),O.oneOf(["top-left","top-right","bottom-left","bottom-right"]);const r5={onClick:O.func,children:O.node,className:O.string},hM=({children:n,onClick:e,className:t=""})=>{const r=s=>{e==null||e(s)};return _.jsx("li",{tabIndex:0,role:"menuitem",onClick:r,onKeyDown:r,className:jt(["bs-dropdown--item",{[t]:t}]),children:n})};hM.propTypes=r5,hM.displayName="BsDropdownItem",O.string,O.func,O.object,O.object,O.string,O.string,O.bool,O.bool,Number(de.jalaliDate().format("D")),Number(de.jalaliDate().format("M")),Number(de.jalaliDate().format("YYYY")),O.func,O.bool,O.bool,O.string,O.string,O.func,O.func,O.string.isRequired,O.string.isRequired,O.oneOf(["sm","md"]).isRequired,O.oneOfType([O.string,O.number]),O.oneOfType([O.string,O.number]).isRequired;const s5={children:O.node,className:O.string,sm:O.oneOfType([O.number,O.object]),xs:O.oneOfType([O.number,O.object]),md:O.oneOfType([O.number,O.object]),lg:O.oneOfType([O.number,O.object]),xl:O.oneOfType([O.number,O.object]),xx:O.oneOfType([O.number,O.object])},ab=({className:n,children:e,xs:t,sm:r,md:s,lg:i,xl:o,xx:a})=>_.jsx("div",{className:jt(n,(()=>{const l={xs:t,sm:r,md:s,lg:i,xl:o,xx:a},c=[];for(const d in l){const f=l[d],p=d==="xs"?"":`-${d}`;let m={};typeof f=="number"?m.size=Number(f):typeof f=="object"&&(m={...m,...f}),m.size===0?c.push(`d-${d}-none`):m.size!==void 0&&m.size>0&&c.push(`bs-col${p}-${m.size}`),m.order&&c.push(`bs-order${p}-${m.order}`),m.offset&&c.push(`bs-offset${p}-${m.offset}`)}return c.length>0?c:["bs-col"]})()),children:e});ab.propTypes=s5,ab.displayName="BsCol";const i5={noGutter:O.bool,children:O.node,className:O.string},Rc=({noGutter:n,children:e,className:t})=>_.jsx("div",{className:jt("bs-row",{"bs-row--no-gutter":n},t),children:e});Rc.propTypes=i5,Rc.displayName="BsGrid",Rc.Col=ab;const o5={lazy:O.bool,alt:O.string,src:O.string,ratio:O.number,className:O.string,imageClass:O.string,withPlaceHolder:O.bool,emptyPlaceholder:O.string,errorPlaceholder:O.string},pM="https://statics.basalam.com/public-9/admin/ylMQL/06-25/sfjTC3xTzq79SYAdqmmy5pJBXNuw2XG1P3Ymqno4BCc8heDcAH.webp",lb=T.forwardRef(({src:n,ratio:e,className:t,imageClass:r,lazy:s=!1,alt:i="توضیحات تصویر",withPlaceHolder:o=!0,emptyPlaceholder:a=pM,errorPlaceholder:l=pM},c)=>{const d=Mt.useFallbackRef(c);return T.useEffect(()=>{const f=d.current;if(!f)return;const{complete:p,naturalHeight:m}=f;p&&!m&&(f.src=l)},[l,d]),_.jsxs("div",{className:jt(["bs-image",t]),children:[_.jsx("img",{ref:d,alt:i,loading:s?"lazy":void 0,className:jt("bs-image__img",r),src:!n&&o?a:n,onError:f=>{f.currentTarget.src!==l&&(f.currentTarget.src=l)}}),e&&_.jsx("div",{style:{paddingBottom:100*e+"%"}})]})});lb.propTypes=o5,lb.displayName="BsImage";var mM=T.memo(lb);const Zh={x:0,y:0,width:0,height:0,unit:"px"},Ac=(n,e,t)=>Math.min(Math.max(n,e),t),a5=(...n)=>n.filter(e=>e&&typeof e=="string").join(" "),gM=(n,e)=>n===e||n.width===e.width&&n.height===e.height&&n.x===e.x&&n.y===e.y&&n.unit===e.unit;function l5(n,e,t,r){const s=bo(n,t,r);return n.width&&(s.height=s.width/e),n.height&&(s.width=s.height*e),s.y+s.height>r&&(s.height=r-s.y,s.width=s.height*e),s.x+s.width>t&&(s.width=t-s.x,s.height=s.width/e),n.unit==="%"?Ia(s,t,r):s}function c5(n,e,t){const r=bo(n,e,t);return r.x=(e-r.width)/2,r.y=(t-r.height)/2,n.unit==="%"?Ia(r,e,t):r}function Ia(n,e,t){return n.unit==="%"?{...Zh,...n,unit:"%"}:{unit:"%",x:n.x?n.x/e*100:0,y:n.y?n.y/t*100:0,width:n.width?n.width/e*100:0,height:n.height?n.height/t*100:0}}function bo(n,e,t){return n.unit?n.unit==="px"?{...Zh,...n,unit:"px"}:{unit:"px",x:n.x?n.x*e/100:0,y:n.y?n.y*t/100:0,width:n.width?n.width*e/100:0,height:n.height?n.height*t/100:0}:{...Zh,...n,unit:"px"}}function _M(n,e,t,r,s,i=0,o=0,a=r,l=s){const c={...n};let d=Math.min(i,r),f=Math.min(o,s),p=Math.min(a,r),m=Math.min(l,s);e&&(e>1?(d=o?o*e:d,f=d/e,p=a*e):(f=i?i/e:f,d=f*e,m=l/e)),c.y<0&&(c.height=Math.max(c.height+c.y,f),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,d),c.x=0);const g=r-(c.x+c.width);g<0&&(c.x=Math.min(c.x,r-d),c.width+=g);const v=s-(c.y+c.height);if(v<0&&(c.y=Math.min(c.y,s-f),c.height+=v),c.width<d&&((t==="sw"||t=="nw")&&(c.x-=d-c.width),c.width=d),c.height<f&&((t==="nw"||t=="ne")&&(c.y-=f-c.height),c.height=f),c.width>p&&((t==="sw"||t=="nw")&&(c.x-=p-c.width),c.width=p),c.height>m&&((t==="nw"||t=="ne")&&(c.y-=m-c.height),c.height=m),e){const y=c.width/c.height;if(y<e){const b=Math.max(c.width/e,f);(t==="nw"||t=="ne")&&(c.y-=b-c.height),c.height=b}else if(y>e){const b=Math.max(c.height*e,d);(t==="sw"||t=="nw")&&(c.x-=b-c.width),c.width=b}}return c}function u5(n,e,t,r){const s={...n};return e==="ArrowLeft"?r==="nw"?(s.x-=t,s.y-=t,s.width+=t,s.height+=t):r==="w"?(s.x-=t,s.width+=t):r==="sw"?(s.x-=t,s.width+=t,s.height+=t):r==="ne"?(s.y+=t,s.width-=t,s.height-=t):r==="e"?s.width-=t:r==="se"&&(s.width-=t,s.height-=t):e==="ArrowRight"&&(r==="nw"?(s.x+=t,s.y+=t,s.width-=t,s.height-=t):r==="w"?(s.x+=t,s.width-=t):r==="sw"?(s.x+=t,s.width-=t,s.height-=t):r==="ne"?(s.y-=t,s.width+=t,s.height+=t):r==="e"?s.width+=t:r==="se"&&(s.width+=t,s.height+=t)),e==="ArrowUp"?r==="nw"?(s.x-=t,s.y-=t,s.width+=t,s.height+=t):r==="n"?(s.y-=t,s.height+=t):r==="ne"?(s.y-=t,s.width+=t,s.height+=t):r==="sw"?(s.x+=t,s.width-=t,s.height-=t):r==="s"?s.height-=t:r==="se"&&(s.width-=t,s.height-=t):e==="ArrowDown"&&(r==="nw"?(s.x+=t,s.y+=t,s.width-=t,s.height-=t):r==="n"?(s.y+=t,s.height-=t):r==="ne"?(s.y+=t,s.width-=t,s.height-=t):r==="sw"?(s.x-=t,s.width+=t,s.height+=t):r==="s"?s.height+=t:r==="se"&&(s.width+=t,s.height+=t)),s}const kc={capture:!0,passive:!1};let d5=0;const Ra=class po extends T.PureComponent{constructor(){super(...arguments),this.docMoveBound=!1,this.mouseDownOnCrop=!1,this.dragStarted=!1,this.evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0},this.componentRef=T.createRef(),this.mediaRef=T.createRef(),this.initChangeCalled=!1,this.instanceId=`rc-${d5++}`,this.state={cropIsActive:!1,newCropIsBeingDrawn:!1},this.onCropPointerDown=e=>{const{crop:t,disabled:r}=this.props,s=this.getBox();if(!t)return;const i=bo(t,s.width,s.height);if(r)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=e.target.dataset.ord,a=!!o;let l=e.clientX,c=e.clientY,d=i.x,f=i.y;if(o){const p=e.clientX-s.x,m=e.clientY-s.y;let g=0,v=0;o==="ne"||o=="e"?(g=p-(i.x+i.width),v=m-i.y,d=i.x,f=i.y+i.height):o==="se"||o==="s"?(g=p-(i.x+i.width),v=m-(i.y+i.height),d=i.x,f=i.y):o==="sw"||o=="w"?(g=p-i.x,v=m-(i.y+i.height),d=i.x+i.width,f=i.y):(o==="nw"||o=="n")&&(g=p-i.x,v=m-i.y,d=i.x+i.width,f=i.y+i.height),l=d+s.x+g,c=f+s.y+v}this.evData={startClientX:l,startClientY:c,startCropX:d,startCropY:f,clientX:e.clientX,clientY:e.clientY,isResize:a,ord:o},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})},this.onComponentPointerDown=e=>{const{crop:t,disabled:r,locked:s,keepSelection:i,onChange:o}=this.props,a=this.getBox();if(r||s||i&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=e.clientX-a.x,c=e.clientY-a.y,d={unit:"px",x:l,y:c,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:l,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,o(bo(d,a.width,a.height),Ia(d,a.width,a.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})},this.onDocPointerMove=e=>{const{crop:t,disabled:r,onChange:s,onDragStart:i}=this.props,o=this.getBox();if(r||!t||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,i&&i(e));const{evData:a}=this;a.clientX=e.clientX,a.clientY=e.clientY;let l;a.isResize?l=this.resizeCrop():l=this.dragCrop(),gM(t,l)||s(bo(l,o.width,o.height),Ia(l,o.width,o.height))},this.onComponentKeyDown=e=>{const{crop:t,disabled:r,onChange:s,onComplete:i}=this.props;if(r)return;const o=e.key;let a=!1;if(!t)return;const l=this.getBox(),c=this.makePixelCrop(l),d=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?po.nudgeStepLarge:e.shiftKey?po.nudgeStepMedium:po.nudgeStep;if(o==="ArrowLeft"?(c.x-=d,a=!0):o==="ArrowRight"?(c.x+=d,a=!0):o==="ArrowUp"?(c.y-=d,a=!0):o==="ArrowDown"&&(c.y+=d,a=!0),a){e.cancelable&&e.preventDefault(),c.x=Ac(c.x,0,l.width-c.width),c.y=Ac(c.y,0,l.height-c.height);const f=bo(c,l.width,l.height),p=Ia(c,l.width,l.height);s(f,p),i&&i(f,p)}},this.onHandlerKeyDown=(e,t)=>{const{aspect:r=0,crop:s,disabled:i,minWidth:o=0,minHeight:a=0,maxWidth:l,maxHeight:c,onChange:d,onComplete:f}=this.props,p=this.getBox();if(i||!s)return;if(e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight")e.stopPropagation(),e.preventDefault();else return;const m=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?po.nudgeStepLarge:e.shiftKey?po.nudgeStepMedium:po.nudgeStep,g=bo(s,p.width,p.height),v=u5(g,e.key,m,t),y=_M(v,r,t,p.width,p.height,o,a,l,c);if(!gM(s,y)){const b=Ia(y,p.width,p.height);d(y,b),f&&f(y,b)}},this.onDocPointerDone=e=>{const{crop:t,disabled:r,onComplete:s,onDragEnd:i}=this.props,o=this.getBox();this.unbindDocMove(),!(r||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,i&&i(e),s&&s(bo(t,o.width,o.height),Ia(t,o.width,o.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))},this.onDragFocus=()=>{var e;(e=this.componentRef.current)==null||e.scrollTo(0,0)}}get document(){return document}getBox(){const e=this.mediaRef.current;if(!e)return{x:0,y:0,width:0,height:0};const{x:t,y:r,width:s,height:i}=e.getBoundingClientRect();return{x:t,y:r,width:s,height:i}}componentDidUpdate(e){const{crop:t,onComplete:r}=this.props;if(r&&!e.crop&&t){const{width:s,height:i}=this.getBox();s&&i&&r(bo(t,s,i),Ia(t,s,i))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,kc),this.document.addEventListener("pointerup",this.onDocPointerDone,kc),this.document.addEventListener("pointercancel",this.onDocPointerDone,kc),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,kc),this.document.removeEventListener("pointerup",this.onDocPointerDone,kc),this.document.removeEventListener("pointercancel",this.onDocPointerDone,kc),this.docMoveBound=!1)}getCropStyle(){const{crop:e}=this.props;if(e)return{top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){const{evData:e}=this,t=this.getBox(),r=this.makePixelCrop(t),s=e.clientX-e.startClientX,i=e.clientY-e.startClientY;return r.x=Ac(e.startCropX+s,0,t.width-r.width),r.y=Ac(e.startCropY+i,0,t.height-r.height),r}getPointRegion(e,t,r,s){const{evData:i}=this,o=i.clientX-e.x,a=i.clientY-e.y;let l;s&&t?l=t==="nw"||t==="n"||t==="ne":l=a<i.startCropY;let c;return r&&t?c=t==="nw"||t==="w"||t==="sw":c=o<i.startCropX,c?l?"nw":"sw":l?"ne":"se"}resolveMinDimensions(e,t,r=0,s=0){const i=Math.min(r,e.width),o=Math.min(s,e.height);return!t||!i&&!o?[i,o]:t>1?i?[i,i/t]:[o*t,o]:o?[o*t,o]:[i,i/t]}resizeCrop(){const{evData:e}=this,{aspect:t=0,maxWidth:r,maxHeight:s}=this.props,i=this.getBox(),[o,a]=this.resolveMinDimensions(i,t,this.props.minWidth,this.props.minHeight);let l=this.makePixelCrop(i);const c=this.getPointRegion(i,e.ord,o,a),d=e.ord||c;let f=e.clientX-e.startClientX,p=e.clientY-e.startClientY;(o&&d==="nw"||d==="w"||d==="sw")&&(f=Math.min(f,-o)),(a&&d==="nw"||d==="n"||d==="ne")&&(p=Math.min(p,-a));const m={unit:"px",x:0,y:0,width:0,height:0};c==="ne"?(m.x=e.startCropX,m.width=f,t?(m.height=m.width/t,m.y=e.startCropY-m.height):(m.height=Math.abs(p),m.y=e.startCropY-m.height)):c==="se"?(m.x=e.startCropX,m.y=e.startCropY,m.width=f,t?m.height=m.width/t:m.height=p):c==="sw"?(m.x=e.startCropX+f,m.y=e.startCropY,m.width=Math.abs(f),t?m.height=m.width/t:m.height=p):c==="nw"&&(m.x=e.startCropX+f,m.width=Math.abs(f),t?(m.height=m.width/t,m.y=e.startCropY-m.height):(m.height=Math.abs(p),m.y=e.startCropY+p));const g=_M(m,t,c,i.width,i.height,o,a,r,s);return t||po.xyOrds.indexOf(d)>-1?l=g:po.xOrds.indexOf(d)>-1?(l.x=g.x,l.width=g.width):po.yOrds.indexOf(d)>-1&&(l.y=g.y,l.height=g.height),l.x=Ac(l.x,0,i.width-l.width),l.y=Ac(l.y,0,i.height-l.height),l}renderCropSelection(){const{ariaLabels:e=po.defaultProps.ariaLabels,disabled:t,locked:r,renderSelectionAddon:s,ruleOfThirds:i,crop:o}=this.props,a=this.getCropStyle();if(o)return Ne.createElement("div",{style:a,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":e.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!t&&!r&&Ne.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},Ne.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),Ne.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),Ne.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),Ne.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":e.nwDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"nw"),role:"button"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":e.nDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"n"),role:"button"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":e.neDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"ne"),role:"button"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":e.eDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"e"),role:"button"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":e.seDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"se"),role:"button"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":e.sDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"s"),role:"button"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":e.swDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"sw"),role:"button"}),Ne.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":e.wDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"w"),role:"button"})),s&&Ne.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:l=>l.stopPropagation()},s(this.state)),i&&Ne.createElement(Ne.Fragment,null,Ne.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),Ne.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(e){const t={...Zh,...this.props.crop||{}};return bo(t,e.width,e.height)}render(){const{aspect:e,children:t,circularCrop:r,className:s,crop:i,disabled:o,locked:a,style:l,ruleOfThirds:c}=this.props,{cropIsActive:d,newCropIsBeingDrawn:f}=this.state,p=i?this.renderCropSelection():null,m=a5("ReactCrop",s,d&&"ReactCrop--active",o&&"ReactCrop--disabled",a&&"ReactCrop--locked",f&&"ReactCrop--new-crop",i&&e&&"ReactCrop--fixed-aspect",i&&r&&"ReactCrop--circular-crop",i&&c&&"ReactCrop--rule-of-thirds",!this.dragStarted&&i&&!i.width&&!i.height&&"ReactCrop--invisible-crop",r&&"ReactCrop--no-animate");return Ne.createElement("div",{ref:this.componentRef,className:m,style:l},Ne.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},t),i?Ne.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},Ne.createElement("defs",null,Ne.createElement("mask",{id:`hole-${this.instanceId}`},Ne.createElement("rect",{width:"100%",height:"100%",fill:"white"}),r?Ne.createElement("ellipse",{cx:`${i.x+i.width/2}${i.unit}`,cy:`${i.y+i.height/2}${i.unit}`,rx:`${i.width/2}${i.unit}`,ry:`${i.height/2}${i.unit}`,fill:"black"}):Ne.createElement("rect",{x:`${i.x}${i.unit}`,y:`${i.y}${i.unit}`,width:`${i.width}${i.unit}`,height:`${i.height}${i.unit}`,fill:"black"}))),Ne.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,p)}};Ra.xOrds=["e","w"],Ra.yOrds=["n","s"],Ra.xyOrds=["nw","ne","se","sw"],Ra.nudgeStep=1,Ra.nudgeStepMedium=10,Ra.nudgeStepLarge=100,Ra.defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};let f5=Ra;const h5={aspect:O.number,disabled:O.bool,memeType:O.string,onComplete:O.func,className:O.string,blurBackground:O.bool,image:O.string.isRequired},cb=T.forwardRef(({image:n,aspect:e,className:t,onComplete:r,defaultCrop:s,disabled:i=!1,memeType:o="image/png",blurBackground:a=!1},l)=>{const[c,d]=T.useState(!0),f=T.useRef(null),p=T.useRef(null),m=T.useRef(null),[g,v]=T.useState({width:0,height:0}),[y,b]=T.useState({width:0,height:0}),[S,E]=T.useState(s),[C,R]=T.useState(),I=T.useCallback(()=>{var $;const D=($=m.current)==null?void 0:$.getContext("2d"),M=p.current;if(!m.current||!D||!M)throw new Error("context or image dose not exist");if(!C)throw new Error("please crop image");const F=M.naturalWidth/M.width,U=M.naturalHeight/M.height;m.current.width=Math.floor(C.width*F),m.current.height=Math.floor(C.height*U),D.drawImage(M,Math.floor(C.x*F),Math.floor(C.y*F),m.current.width,m.current.height,0,0,m.current.width,m.current.height)},[C,n]),A=T.useCallback((D=1)=>new Promise((M,F)=>{var U;try{I(),(U=m.current)==null||U.toBlob($=>{M($)},o,D)}catch($){F($)}}),[I,o]),k=T.useCallback(()=>new Promise((D,M)=>{var F;try{I(),D((F=m.current)==null?void 0:F.toDataURL())}catch(U){M(U)}}),[I]),N=T.useCallback(()=>S,[S]);return T.useImperativeHandle(l,()=>({getCropDimensions:N,getResultAsBlob:A,getResultAsDataURL:k}),[N,A,k]),T.useLayoutEffect(()=>{f.current&&v({width:f.current.clientWidth,height:f.current.clientHeight})},[]),T.useEffect(()=>{!s||y.width<=0||y.height<=0||(E(s),R(s))},[s]),T.useEffect(()=>{d(!0),E(void 0),R(void 0)},[n]),_.jsxs("div",{ref:f,className:jt("bs-image-crop__container",t),children:[_.jsx("canvas",{ref:m,style:{display:"none"}}),a&&_.jsx("img",{src:n,alt:"bg",className:"bs-image-crop__bg-image"}),c&&_.jsx(Cr,{size:"xl",className:"bs-image-crop__loading"}),_.jsx(f5,{crop:S,ruleOfThirds:!0,keepSelection:!0,minWidth:100,minHeight:100,aspect:e,disabled:i,onChange:D=>E(D),onComplete:D=>{R(D),r==null||r()},className:"ReactCrop--no-animate bs-image-crop__cropper",style:{width:y.width,height:y.height},children:_.jsx("img",{alt:"crop",src:n,ref:p,onLoad:D=>{let M=D.currentTarget.naturalWidth,F=D.currentTarget.naturalHeight;const U=M/F,$=g.width/g.height;(M>=g.width||F>=g.height)&&($>U?(M=Math.floor(g.height*U),F=g.height):(M=g.width,F=Math.floor(g.width/U)));const q=s||function(G,V,z){return c5(l5({unit:"%",width:90},z,G,V),G,V)}(M,F,e||M/F);E(q),b({width:M,height:F}),d(!1)},className:"bs-image-crop__image"},n)})]})});cb.propTypes=h5,cb.displayName="BsImageCrop";class ep extends T.Component{constructor(e){super(e),this.scrollListener=this.scrollListener.bind(this),this.eventListenerOptions=this.eventListenerOptions.bind(this),this.mousewheelListener=this.mousewheelListener.bind(this)}componentDidMount(){this.pageLoaded=this.props.pageStart,this.options=this.eventListenerOptions(),this.attachScrollListener()}componentDidUpdate(){if(this.props.isReverse&&this.loadMore){const e=this.getParentElement(this.scrollComponent);e.scrollTop=e.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}componentWillUnmount(){this.detachScrollListener(),this.detachMousewheelListener()}isPassiveSupported(){let e=!1;const t={get passive(){e=!0}};try{document.addEventListener("test",null,t),document.removeEventListener("test",null,t)}catch{}return e}eventListenerOptions(){let e=this.props.useCapture;return this.isPassiveSupported()?e={useCapture:this.props.useCapture,passive:!0}:e={passive:!1},e}setDefaultLoader(e){this.defaultLoader=e}detachMousewheelListener(){let e=window;this.props.useWindow===!1&&(e=this.scrollComponent.parentNode),e.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}detachScrollListener(){let e=window;this.props.useWindow===!1&&(e=this.getParentElement(this.scrollComponent)),e.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),e.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}getParentElement(e){const t=this.props.getScrollParent&&this.props.getScrollParent();return t??(e&&e.parentNode)}filterProps(e){return e}attachScrollListener(){const e=this.getParentElement(this.scrollComponent);if(!this.props.hasMore||!e)return;let t=window;this.props.useWindow===!1&&(t=e),t.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),t.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),t.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}mousewheelListener(e){e.deltaY===1&&!this.isPassiveSupported()&&e.preventDefault()}scrollListener(){const e=this.scrollComponent,t=window,r=this.getParentElement(e);let s;if(this.props.useWindow){const i=document.documentElement||document.body.parentNode||document.body,o=t.pageYOffset!==void 0?t.pageYOffset:i.scrollTop;this.props.isReverse?s=o:s=this.calculateOffset(e,o)}else this.props.isReverse?s=r.scrollTop:s=e.scrollHeight-r.scrollTop-r.clientHeight;s<Number(this.props.threshold)&&e&&e.offsetParent!==null&&(this.detachScrollListener(),this.beforeScrollHeight=r.scrollHeight,this.beforeScrollTop=r.scrollTop,typeof this.props.loadMore=="function"&&(this.props.loadMore(this.pageLoaded+=1),this.loadMore=!0))}calculateOffset(e,t){return e?this.calculateTopPosition(e)+(e.offsetHeight-t-window.innerHeight):0}calculateTopPosition(e){return e?e.offsetTop+this.calculateTopPosition(e.offsetParent):0}render(){const e=this.filterProps(this.props),{children:t,element:r,hasMore:s,initialLoad:i,isReverse:o,loader:a,loadMore:l,pageStart:c,ref:d,threshold:f,useCapture:p,useWindow:m,getScrollParent:g,...v}=e;v.ref=b=>{this.scrollComponent=b,d&&d(b)};const y=[t];return s&&(a?o?y.unshift(a):y.push(a):this.defaultLoader&&(o?y.unshift(this.defaultLoader):y.push(this.defaultLoader))),Ne.createElement(r,v,y)}}UC(ep,"propTypes",{children:O.node.isRequired,element:O.node,hasMore:O.bool,initialLoad:O.bool,isReverse:O.bool,loader:O.node,loadMore:O.func.isRequired,pageStart:O.number,ref:O.func,getScrollParent:O.func,threshold:O.number,useCapture:O.bool,useWindow:O.bool}),UC(ep,"defaultProps",{element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null});const p5={useWindow:O.bool,isReverse:O.bool,component:O.string,initialLoad:O.bool,threshold:O.number,errorComponent:O.func,getScrollParent:O.func,loadingComponent:O.func,hasMore:O.bool.isRequired,hasError:O.bool.isRequired,fetchMore:O.func.isRequired};function ub({hasMore:n,children:e,fetchMore:t,getScrollParent:r,threshold:s=200,useWindow:i=!0,hasError:o=!1,component:a="div",isReverse:l=!1,initialLoad:c=!0,errorComponent:d,loadingComponent:f}){const p=T.useMemo(()=>f===null?void 0:f?_.jsx(f,{},`${Date.now()}-${Math.random()}`):_.jsx(Cr,{className:"bs-infinite-scroll__loading"},`${Date.now()}-${Math.random()}`),[f]);return _.jsxs(_.Fragment,{children:[_.jsx(ep,{loader:p,element:a,loadMore:t,useWindow:i,isReverse:l,initialLoad:c,hasMore:!o&&n,threshold:s,getScrollParent:r,children:e}),o&&d]})}ub.propTypes=p5,ub.displayName="BsInfiniteScroll";const m5={icon:O.string,disabled:O.bool,className:O.string,size:O.oneOf(["sm","md","lg"]),variant:O.oneOf(["fill","text"]),label:O.oneOfType([O.string,O.number]).isRequired,color:O.oneOf(["primary","black","green","blue","dark-blue","red","yellow"])},Xo=({icon:n,label:e,className:t,size:r="md",disabled:s=!1,variant:i="text",color:o="primary"})=>_.jsxs("span",{className:jt(t,"bs-label",`bs-label--${o}-${i}`,`bs-label--${r}`,{"bs-label--disabled":s}),children:[n&&_.jsx("i",{className:`${n} bs-label__icon`}),e]});Xo.propTypes=m5,Xo.displayName="BsLabel";function g5(n){return Object.prototype.toString.call(n)==="[object Object]"}function vM(n){return g5(n)||Array.isArray(n)}function _5(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function db(n,e){const t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;const s=JSON.stringify(Object.keys(n.breakpoints||{})),i=JSON.stringify(Object.keys(e.breakpoints||{}));return s!==i?!1:t.every(o=>{const a=n[o],l=e[o];return typeof a=="function"?`${a}`==`${l}`:!vM(a)||!vM(l)?a===l:db(a,l)})}function yM(n){return n.concat().sort((e,t)=>e.name>t.name?1:-1).map(e=>e.options)}function v5(n,e){if(n.length!==e.length)return!1;const t=yM(n),r=yM(e);return t.every((s,i)=>{const o=r[i];return db(s,o)})}function fb(n){return typeof n=="number"}function hb(n){return typeof n=="string"}function tp(n){return typeof n=="boolean"}function bM(n){return Object.prototype.toString.call(n)==="[object Object]"}function dr(n){return Math.abs(n)}function pb(n){return Math.sign(n)}function Od(n,e){return dr(n-e)}function y5(n,e){if(n===0||e===0||dr(n)<=dr(e))return 0;const t=Od(dr(n),dr(e));return dr(t/n)}function b5(n){return Math.round(n*100)/100}function Pd(n){return jd(n).map(Number)}function Ki(n){return n[Dd(n)]}function Dd(n){return Math.max(0,n.length-1)}function mb(n,e){return e===Dd(n)}function xM(n,e=0){return Array.from(Array(n),(t,r)=>e+r)}function jd(n){return Object.keys(n)}function SM(n,e){return[n,e].reduce((t,r)=>(jd(r).forEach(s=>{const i=t[s],o=r[s],a=bM(i)&&bM(o);t[s]=a?SM(i,o):o}),t),{})}function gb(n,e){return typeof e.MouseEvent<"u"&&n instanceof e.MouseEvent}function x5(n,e){const t={start:r,center:s,end:i};function r(){return 0}function s(l){return i(l)/2}function i(l){return e-l}function o(l,c){return hb(n)?t[n](l):n(e,l,c)}return{measure:o}}function Fd(){let n=[];function e(s,i,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(i,o,a),l=()=>s.removeEventListener(i,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return n.push(l),r}function t(){n=n.filter(s=>s())}const r={add:e,clear:t};return r}function S5(n,e,t,r){const s=Fd(),i=1e3/60;let o=null,a=0,l=0;function c(){s.add(n,"visibilitychange",()=>{n.hidden&&g()})}function d(){m(),s.clear()}function f(y){if(!l)return;o||(o=y,t(),t());const b=y-o;for(o=y,a+=b;a>=i;)t(),a-=i;const S=a/i;r(S),l&&(l=e.requestAnimationFrame(f))}function p(){l||(l=e.requestAnimationFrame(f))}function m(){e.cancelAnimationFrame(l),o=null,a=0,l=0}function g(){o=null,a=0}return{init:c,destroy:d,start:p,stop:m,update:t,render:r}}function E5(n,e){const t=e==="rtl",r=n==="y",s=r?"y":"x",i=r?"x":"y",o=!r&&t?-1:1,a=d(),l=f();function c(g){const{height:v,width:y}=g;return r?v:y}function d(){return r?"top":t?"right":"left"}function f(){return r?"bottom":t?"left":"right"}function p(g){return g*o}return{scroll:s,cross:i,startEdge:a,endEdge:l,measureSize:c,direction:p}}function Il(n=0,e=0){const t=dr(n-e);function r(c){return c<n}function s(c){return c>e}function i(c){return r(c)||s(c)}function o(c){return i(c)?r(c)?n:e:c}function a(c){return t?c-t*Math.ceil((c-e)/t):c}return{length:t,max:e,min:n,constrain:o,reachedAny:i,reachedMax:s,reachedMin:r,removeOffset:a}}function EM(n,e,t){const{constrain:r}=Il(0,n),s=n+1;let i=o(e);function o(p){return t?dr((s+p)%s):r(p)}function a(){return i}function l(p){return i=o(p),f}function c(p){return d().set(a()+p)}function d(){return EM(n,a(),t)}const f={get:a,set:l,add:c,clone:d};return f}function w5(n,e,t,r,s,i,o,a,l,c,d,f,p,m,g,v,y,b,S){const{cross:E,direction:C}=n,R=["INPUT","SELECT","TEXTAREA"],I={passive:!1},A=Fd(),k=Fd(),N=Il(50,225).constrain(m.measure(20)),D={mouse:300,touch:400},M={mouse:500,touch:600},F=g?43:25;let U=!1,$=0,q=0,G=!1,V=!1,z=!1,B=!1;function P(le){if(!S)return;function Ie(ge){(tp(S)||S(le,ge))&&K(ge)}const be=e;A.add(be,"dragstart",ge=>ge.preventDefault(),I).add(be,"touchmove",()=>{},I).add(be,"touchend",()=>{}).add(be,"touchstart",Ie).add(be,"mousedown",Ie).add(be,"touchcancel",te).add(be,"contextmenu",te).add(be,"click",re,!0)}function H(){A.clear(),k.clear()}function Z(){const le=B?t:e;k.add(le,"touchmove",W,I).add(le,"touchend",te).add(le,"mousemove",W,I).add(le,"mouseup",te)}function Q(le){const Ie=le.nodeName||"";return R.includes(Ie)}function J(){return(g?M:D)[B?"mouse":"touch"]}function ee(le,Ie){const be=f.add(pb(le)*-1),ge=d.byDistance(le,!g).distance;return g||dr(le)<N?ge:y&&Ie?ge*.5:d.byIndex(be.get(),0).distance}function K(le){const Ie=gb(le,r);B=Ie,z=g&&Ie&&!le.buttons&&U,U=Od(s.get(),o.get())>=2,!(Ie&&le.button!==0)&&(Q(le.target)||(G=!0,i.pointerDown(le),c.useFriction(0).useDuration(0),s.set(o),Z(),$=i.readPoint(le),q=i.readPoint(le,E),p.emit("pointerDown")))}function W(le){if(!gb(le,r)&&le.touches.length>=2)return te(le);const be=i.readPoint(le),ge=i.readPoint(le,E),Ae=Od(be,$),Re=Od(ge,q);if(!V&&!B&&(!le.cancelable||(V=Ae>Re,!V)))return te(le);const tt=i.pointerMove(le);Ae>v&&(z=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(C(tt)),le.preventDefault()}function te(le){const be=d.byDistance(0,!1).index!==f.get(),ge=i.pointerUp(le)*J(),Ae=ee(C(ge),be),Re=y5(ge,Ae),tt=F-10*Re,et=b+Re/50;V=!1,G=!1,k.clear(),c.useDuration(tt).useFriction(et),l.distance(Ae,!g),B=!1,p.emit("pointerUp")}function re(le){z&&(le.stopPropagation(),le.preventDefault(),z=!1)}function pe(){return G}return{init:P,destroy:H,pointerDown:pe}}function T5(n,e){let r,s;function i(f){return f.timeStamp}function o(f,p){const g=`client${(p||n.scroll)==="x"?"X":"Y"}`;return(gb(f,e)?f:f.touches[0])[g]}function a(f){return r=f,s=f,o(f)}function l(f){const p=o(f)-o(s),m=i(f)-i(r)>170;return s=f,m&&(r=f),p}function c(f){if(!r||!s)return 0;const p=o(s)-o(r),m=i(f)-i(r),g=i(f)-i(s)>170,v=p/m;return m&&!g&&dr(v)>.1?v:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function C5(){function n(t){const{offsetTop:r,offsetLeft:s,offsetWidth:i,offsetHeight:o}=t;return{top:r,right:s+i,bottom:r+o,left:s,width:i,height:o}}return{measure:n}}function I5(n){function e(r){return n*(r/100)}return{measure:e}}function R5(n,e,t,r,s,i,o){const a=[n].concat(r);let l,c,d=[],f=!1;function p(y){return s.measureSize(o.measure(y))}function m(y){if(!i)return;c=p(n),d=r.map(p);function b(S){for(const E of S){if(f)return;const C=E.target===n,R=r.indexOf(E.target),I=C?c:d[R],A=p(C?n:r[R]);if(dr(A-I)>=.5){y.reInit(),e.emit("resize");break}}}l=new ResizeObserver(S=>{(tp(i)||i(y,S))&&b(S)}),t.requestAnimationFrame(()=>{a.forEach(S=>l.observe(S))})}function g(){f=!0,l&&l.disconnect()}return{init:m,destroy:g}}function A5(n,e,t,r,s,i){let o=0,a=0,l=s,c=i,d=n.get(),f=0;function p(){const I=r.get()-n.get(),A=!l;let k=0;return A?(o=0,t.set(r),n.set(r),k=I):(t.set(n),o+=I/l,o*=c,d+=o,n.add(o),k=d-f),a=pb(k),f=d,R}function m(){const I=r.get()-e.get();return dr(I)<.001}function g(){return l}function v(){return a}function y(){return o}function b(){return E(s)}function S(){return C(i)}function E(I){return l=I,R}function C(I){return c=I,R}const R={direction:v,duration:g,velocity:y,seek:p,settled:m,useBaseFriction:S,useBaseDuration:b,useFriction:C,useDuration:E};return R}function k5(n,e,t,r,s){const i=s.measure(10),o=s.measure(50),a=Il(.1,.99);let l=!1;function c(){return!(l||!n.reachedAny(t.get())||!n.reachedAny(e.get()))}function d(m){if(!c())return;const g=n.reachedMin(e.get())?"min":"max",v=dr(n[g]-e.get()),y=t.get()-e.get(),b=a.constrain(v/o);t.subtract(y*b),!m&&dr(y)<i&&(t.set(n.constrain(t.get())),r.useDuration(25).useBaseFriction())}function f(m){l=!m}return{shouldConstrain:c,constrain:d,toggleActive:f}}function L5(n,e,t,r,s){const i=Il(-e+n,0),o=f(),a=d(),l=p();function c(g,v){return Od(g,v)<=1}function d(){const g=o[0],v=Ki(o),y=o.lastIndexOf(g),b=o.indexOf(v)+1;return Il(y,b)}function f(){return t.map((g,v)=>{const{min:y,max:b}=i,S=i.constrain(g),E=!v,C=mb(t,v);return E?b:C||c(y,S)?y:c(b,S)?b:S}).map(g=>parseFloat(g.toFixed(3)))}function p(){if(e<=n+s)return[i.max];if(r==="keepSnaps")return o;const{min:g,max:v}=a;return o.slice(g,v)}return{snapsContained:l,scrollContainLimit:a}}function M5(n,e,t){const r=e[0],s=t?r-n:Ki(e);return{limit:Il(s,r)}}function N5(n,e,t,r){const i=e.min+.1,o=e.max+.1,{reachedMin:a,reachedMax:l}=Il(i,o);function c(p){return p===1?l(t.get()):p===-1?a(t.get()):!1}function d(p){if(!c(p))return;const m=n*(p*-1);r.forEach(g=>g.add(m))}return{loop:d}}function O5(n){const{max:e,length:t}=n;function r(i){const o=i-e;return t?o/-t:0}return{get:r}}function P5(n,e,t,r,s){const{startEdge:i,endEdge:o}=n,{groupSlides:a}=s,l=f().map(e.measure),c=p(),d=m();function f(){return a(r).map(v=>Ki(v)[o]-v[0][i]).map(dr)}function p(){return r.map(v=>t[i]-v[i]).map(v=>-dr(v))}function m(){return a(c).map(v=>v[0]).map((v,y)=>v+l[y])}return{snaps:c,snapsAligned:d}}function D5(n,e,t,r,s,i){const{groupSlides:o}=s,{min:a,max:l}=r,c=d();function d(){const p=o(i),m=!n||e==="keepSnaps";return t.length===1?[i]:m?p:p.slice(a,l).map((g,v,y)=>{const b=!v,S=mb(y,v);if(b){const E=Ki(y[0])+1;return xM(E)}if(S){const E=Dd(i)-Ki(y)[0]+1;return xM(E,Ki(y)[0])}return g})}return{slideRegistry:c}}function j5(n,e,t,r,s){const{reachedAny:i,removeOffset:o,constrain:a}=r;function l(g){return g.concat().sort((v,y)=>dr(v)-dr(y))[0]}function c(g){const v=n?o(g):a(g),y=e.map((S,E)=>({diff:d(S-v,0),index:E})).sort((S,E)=>dr(S.diff)-dr(E.diff)),{index:b}=y[0];return{index:b,distance:v}}function d(g,v){const y=[g,g+t,g-t];if(!n)return g;if(!v)return l(y);const b=y.filter(S=>pb(S)===v);return b.length?l(b):Ki(y)-t}function f(g,v){const y=e[g]-s.get(),b=d(y,v);return{index:g,distance:b}}function p(g,v){const y=s.get()+g,{index:b,distance:S}=c(y),E=!n&&i(y);if(!v||E)return{index:b,distance:g};const C=e[b]-S,R=g+d(C,0);return{index:b,distance:R}}return{byDistance:p,byIndex:f,shortcut:d}}function F5(n,e,t,r,s,i,o){function a(f){const p=f.distance,m=f.index!==e.get();i.add(p),p&&(r.duration()?n.start():(n.update(),n.render(1),n.update())),m&&(t.set(e.get()),e.set(f.index),o.emit("select"))}function l(f,p){const m=s.byDistance(f,p);a(m)}function c(f,p){const m=e.clone().set(f),g=s.byIndex(m.get(),p);a(g)}return{distance:l,index:c}}function U5(n,e,t,r,s,i,o,a){const l={passive:!0,capture:!0};let c=0;function d(m){if(!a)return;function g(v){if(new Date().getTime()-c>10)return;o.emit("slideFocusStart"),n.scrollLeft=0;const S=t.findIndex(E=>E.includes(v));fb(S)&&(s.useDuration(0),r.index(S,0),o.emit("slideFocus"))}i.add(document,"keydown",f,!1),e.forEach((v,y)=>{i.add(v,"focus",b=>{(tp(a)||a(m,b))&&g(y)},l)})}function f(m){m.code==="Tab"&&(c=new Date().getTime())}return{init:d}}function Ud(n){let e=n;function t(){return e}function r(l){e=o(l)}function s(l){e+=o(l)}function i(l){e-=o(l)}function o(l){return fb(l)?l:l.get()}return{get:t,set:r,add:s,subtract:i}}function wM(n,e){const t=n.scroll==="x"?o:a,r=e.style;let s=null,i=!1;function o(p){return`translate3d(${p}px,0px,0px)`}function a(p){return`translate3d(0px,${p}px,0px)`}function l(p){if(i)return;const m=b5(n.direction(p));m!==s&&(r.transform=t(m),s=m)}function c(p){i=!p}function d(){i||(r.transform="",e.getAttribute("style")||e.removeAttribute("style"))}return{clear:d,to:l,toggleActive:c}}function B5(n,e,t,r,s,i,o,a,l){const d=Pd(s),f=Pd(s).reverse(),p=b().concat(S());function m(A,k){return A.reduce((N,D)=>N-s[D],k)}function g(A,k){return A.reduce((N,D)=>m(N,k)>0?N.concat([D]):N,[])}function v(A){return i.map((k,N)=>({start:k-r[N]+.5+A,end:k+e-.5+A}))}function y(A,k,N){const D=v(k);return A.map(M=>{const F=N?0:-t,U=N?t:0,$=N?"end":"start",q=D[M][$];return{index:M,loopPoint:q,slideLocation:Ud(-1),translate:wM(n,l[M]),target:()=>a.get()>q?F:U}})}function b(){const A=o[0],k=g(f,A);return y(k,t,!1)}function S(){const A=e-o[0]-1,k=g(d,A);return y(k,-t,!0)}function E(){return p.every(({index:A})=>{const k=d.filter(N=>N!==A);return m(k,e)<=.1})}function C(){p.forEach(A=>{const{target:k,translate:N,slideLocation:D}=A,M=k();M!==D.get()&&(N.to(M),D.set(M))})}function R(){p.forEach(A=>A.translate.clear())}return{canLoop:E,clear:R,loop:C,loopPoints:p}}function $5(n,e,t){let r,s=!1;function i(l){if(!t)return;function c(d){for(const f of d)if(f.type==="childList"){l.reInit(),e.emit("slidesChanged");break}}r=new MutationObserver(d=>{s||(tp(t)||t(l,d))&&c(d)}),r.observe(n,{childList:!0})}function o(){r&&r.disconnect(),s=!0}return{init:i,destroy:o}}function z5(n,e,t,r){const s={};let i=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(g=>{l||(g.forEach(v=>{const y=e.indexOf(v.target);s[y]=v}),i=null,o=null,t.emit("slidesInView"))},{root:n.parentElement,threshold:r}),e.forEach(g=>a.observe(g))}function d(){a&&a.disconnect(),l=!0}function f(g){return jd(s).reduce((v,y)=>{const b=parseInt(y),{isIntersecting:S}=s[b];return(g&&S||!g&&!S)&&v.push(b),v},[])}function p(g=!0){if(g&&i)return i;if(!g&&o)return o;const v=f(g);return g&&(i=v),g||(o=v),v}return{init:c,destroy:d,get:p}}function q5(n,e,t,r,s,i){const{measureSize:o,startEdge:a,endEdge:l}=n,c=t[0]&&s,d=g(),f=v(),p=t.map(o),m=y();function g(){if(!c)return 0;const S=t[0];return dr(e[a]-S[a])}function v(){if(!c)return 0;const S=i.getComputedStyle(Ki(r));return parseFloat(S.getPropertyValue(`margin-${l}`))}function y(){return t.map((S,E,C)=>{const R=!E,I=mb(C,E);return R?p[E]+d:I?p[E]+f:C[E+1][a]-S[a]}).map(dr)}return{slideSizes:p,slideSizesWithGaps:m,startGap:d,endGap:f}}function H5(n,e,t,r,s,i,o,a,l){const{startEdge:c,endEdge:d,direction:f}=n,p=fb(t);function m(b,S){return Pd(b).filter(E=>E%S===0).map(E=>b.slice(E,E+S))}function g(b){return b.length?Pd(b).reduce((S,E,C)=>{const R=Ki(S)||0,I=R===0,A=E===Dd(b),k=s[c]-i[R][c],N=s[c]-i[E][d],D=!r&&I?f(o):0,M=!r&&A?f(a):0,F=dr(N-M-(k+D));return C&&F>e+l&&S.push(E),A&&S.push(b.length),S},[]).map((S,E,C)=>{const R=Math.max(C[E-1]||0);return b.slice(R,S)}):[]}function v(b){return p?m(b,t):g(b)}return{groupSlides:v}}function G5(n,e,t,r,s,i,o){const{align:a,axis:l,direction:c,startIndex:d,loop:f,duration:p,dragFree:m,dragThreshold:g,inViewThreshold:v,slidesToScroll:y,skipSnaps:b,containScroll:S,watchResize:E,watchSlides:C,watchDrag:R,watchFocus:I}=i,A=2,k=C5(),N=k.measure(e),D=t.map(k.measure),M=E5(l,c),F=M.measureSize(N),U=I5(F),$=x5(a,F),q=!f&&!!S,G=f||!!S,{slideSizes:V,slideSizesWithGaps:z,startGap:B,endGap:P}=q5(M,N,D,t,G,s),H=H5(M,F,y,f,N,D,B,P,A),{snaps:Z,snapsAligned:Q}=P5(M,$,N,D,H),J=-Ki(Z)+Ki(z),{snapsContained:ee,scrollContainLimit:K}=L5(F,J,Q,S,A),W=q?ee:Q,{limit:te}=M5(J,W,f),re=EM(Dd(W),d,f),pe=re.clone(),Ee=Pd(t),le=({dragHandler:xt,scrollBody:rt,scrollBounds:Me,options:{loop:lt}})=>{lt||Me.constrain(xt.pointerDown()),rt.seek()},Ie=({scrollBody:xt,translate:rt,location:Me,offsetLocation:lt,previousLocation:Vt,scrollLooper:vn,slideLooper:pt,dragHandler:mt,animation:gt,eventHandler:Wt,scrollBounds:ot,options:{loop:nn}},tn)=>{const En=xt.settled(),$n=!ot.shouldConstrain(),_n=nn?En:En&&$n,sr=_n&&!mt.pointerDown();sr&&gt.stop();const wr=Me.get()*tn+Vt.get()*(1-tn);lt.set(wr),nn&&(vn.loop(xt.direction()),pt.loop()),rt.to(lt.get()),sr&&Wt.emit("settle"),_n||Wt.emit("scroll")},be=S5(r,s,()=>le(Ot),xt=>Ie(Ot,xt)),ge=.68,Ae=W[re.get()],Re=Ud(Ae),tt=Ud(Ae),et=Ud(Ae),Oe=Ud(Ae),ht=A5(Re,et,tt,Oe,p,ge),Xe=j5(f,W,J,te,Oe),Je=F5(be,re,pe,ht,Xe,Oe,o),qe=O5(te),Ue=Fd(),it=z5(e,t,o,v),{slideRegistry:nt}=D5(q,S,W,K,H,Ee),dt=U5(n,t,nt,Je,ht,Ue,o,I),Ot={ownerDocument:r,ownerWindow:s,eventHandler:o,containerRect:N,slideRects:D,animation:be,axis:M,dragHandler:w5(M,n,r,s,Oe,T5(M,s),Re,be,Je,ht,Xe,re,o,U,m,g,b,ge,R),eventStore:Ue,percentOfView:U,index:re,indexPrevious:pe,limit:te,location:Re,offsetLocation:et,previousLocation:tt,options:i,resizeHandler:R5(e,o,s,t,M,E,k),scrollBody:ht,scrollBounds:k5(te,et,Oe,ht,U),scrollLooper:N5(J,te,et,[Re,et,tt,Oe]),scrollProgress:qe,scrollSnapList:W.map(qe.get),scrollSnaps:W,scrollTarget:Xe,scrollTo:Je,slideLooper:B5(M,F,J,V,z,Z,W,et,t),slideFocus:dt,slidesHandler:$5(e,o,C),slidesInView:it,slideIndexes:Ee,slideRegistry:nt,slidesToScroll:H,target:Oe,translate:wM(M,e)};return Ot}function V5(){let n={},e;function t(c){e=c}function r(c){return n[c]||[]}function s(c){return r(c).forEach(d=>d(e,c)),l}function i(c,d){return n[c]=r(c).concat([d]),l}function o(c,d){return n[c]=r(c).filter(f=>f!==d),l}function a(){n={}}const l={init:t,emit:s,off:o,on:i,clear:a};return l}const W5={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function K5(n){function e(i,o){return SM(i,o||{})}function t(i){const o=i.breakpoints||{},a=jd(o).filter(l=>n.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>e(l,c),{});return e(i,a)}function r(i){return i.map(o=>jd(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(n.matchMedia)}return{mergeOptions:e,optionsAtMedia:t,optionsMediaQueries:r}}function Y5(n){let e=[];function t(i,o){return e=o.filter(({options:a})=>n.optionsAtMedia(a).active!==!1),e.forEach(a=>a.init(i,n)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function r(){e=e.filter(i=>i.destroy())}return{init:t,destroy:r}}function np(n,e,t){const r=n.ownerDocument,s=r.defaultView,i=K5(s),o=Y5(i),a=Fd(),l=V5(),{mergeOptions:c,optionsAtMedia:d,optionsMediaQueries:f}=i,{on:p,off:m,emit:g}=l,v=M;let y=!1,b,S=c(W5,np.globalOptions),E=c(S),C=[],R,I,A;function k(){const{container:Ee,slides:le}=E;I=(hb(Ee)?n.querySelector(Ee):Ee)||n.children[0];const be=hb(le)?I.querySelectorAll(le):le;A=[].slice.call(be||I.children)}function N(Ee){const le=G5(n,I,A,r,s,Ee,l);if(Ee.loop&&!le.slideLooper.canLoop()){const Ie=Object.assign({},Ee,{loop:!1});return N(Ie)}return le}function D(Ee,le){y||(S=c(S,Ee),E=d(S),C=le||C,k(),b=N(E),f([S,...C.map(({options:Ie})=>Ie)]).forEach(Ie=>a.add(Ie,"change",M)),E.active&&(b.translate.to(b.location.get()),b.animation.init(),b.slidesInView.init(),b.slideFocus.init(pe),b.eventHandler.init(pe),b.resizeHandler.init(pe),b.slidesHandler.init(pe),b.options.loop&&b.slideLooper.loop(),I.offsetParent&&A.length&&b.dragHandler.init(pe),R=o.init(pe,C)))}function M(Ee,le){const Ie=H();F(),D(c({startIndex:Ie},Ee),le),l.emit("reInit")}function F(){b.dragHandler.destroy(),b.eventStore.clear(),b.translate.clear(),b.slideLooper.clear(),b.resizeHandler.destroy(),b.slidesHandler.destroy(),b.slidesInView.destroy(),b.animation.destroy(),o.destroy(),a.clear()}function U(){y||(y=!0,a.clear(),F(),l.emit("destroy"),l.clear())}function $(Ee,le,Ie){!E.active||y||(b.scrollBody.useBaseFriction().useDuration(le===!0?0:E.duration),b.scrollTo.index(Ee,Ie||0))}function q(Ee){const le=b.index.add(1).get();$(le,Ee,-1)}function G(Ee){const le=b.index.add(-1).get();$(le,Ee,1)}function V(){return b.index.add(1).get()!==H()}function z(){return b.index.add(-1).get()!==H()}function B(){return b.scrollSnapList}function P(){return b.scrollProgress.get(b.offsetLocation.get())}function H(){return b.index.get()}function Z(){return b.indexPrevious.get()}function Q(){return b.slidesInView.get()}function J(){return b.slidesInView.get(!1)}function ee(){return R}function K(){return b}function W(){return n}function te(){return I}function re(){return A}const pe={canScrollNext:V,canScrollPrev:z,containerNode:te,internalEngine:K,destroy:U,off:m,on:p,emit:g,plugins:ee,previousScrollSnap:Z,reInit:v,rootNode:W,scrollNext:q,scrollPrev:G,scrollProgress:P,scrollSnapList:B,scrollTo:$,selectedScrollSnap:H,slideNodes:re,slidesInView:Q,slidesNotInView:J};return D(e,t),setTimeout(()=>l.emit("init"),0),pe}np.globalOptions=void 0;function _b(n={},e=[]){const t=T.useRef(n),r=T.useRef(e),[s,i]=T.useState(),[o,a]=T.useState(),l=T.useCallback(()=>{s&&s.reInit(t.current,r.current)},[s]);return T.useEffect(()=>{db(t.current,n)||(t.current=n,l())},[n,l]),T.useEffect(()=>{v5(r.current,e)||(r.current=e,l())},[e,l]),T.useEffect(()=>{if(_5()&&o){np.globalOptions=_b.globalOptions;const c=np(o,t.current,r.current);return i(c),()=>c.destroy()}else i(void 0)},[o,i]),[a,s]}_b.globalOptions=void 0;const X5={onInit:O.func,children:O.node,plugins:O.array,onReInit:O.func,onSelect:O.func,onScroll:O.func,onSettle:O.func,onResize:O.func,onDestroy:O.func,className:O.string,onPointerUp:O.func,onSlideFocus:O.func,onPointerDown:O.func,onSlidesInView:O.func,onSlidesChanged:O.func,navigation:O.oneOfType([O.bool,O.object])},vb=T.forwardRef(({onInit:n,plugins:e,children:t,onReInit:r,onSelect:s,onScroll:i,onSettle:o,onResize:a,className:l,onDestroy:c,navigation:d,onPointerUp:f,onSlideFocus:p,onPointerDown:m,onSlidesInView:g,onSlidesChanged:v,...y},b)=>{const[S,E]=_b({direction:"rtl",...y},e),[C,R]=T.useState(!0),[I,A]=T.useState(!1),k=d&&typeof d=="object",N=T.useCallback(()=>{var F,U;E==null||E.scrollNext(),(U=(F=E==null?void 0:E.plugins())==null?void 0:F.autoplay)==null||U.reset()},[E]),D=T.useCallback(()=>{var F,U;E==null||E.scrollPrev(),(U=(F=E==null?void 0:E.plugins())==null?void 0:F.autoplay)==null||U.reset()},[E]),M=T.useCallback(F=>{d&&(R(()=>F.canScrollNext()),A(()=>F.canScrollPrev())),s&&s(F,"select")},[d,s]);return T.useEffect(()=>(E&&(n&&(E.on("init",n),n(E,"init")),r&&E.on("reInit",r),i&&E.on("scroll",i),o&&E.on("settle",o),a&&E.on("resize",a),c&&E.on("destroy",c),f&&E.on("pointerUp",f),p&&E.on("slideFocus",p),m&&E.on("pointerDown",m),g&&E.on("slidesInView",g),v&&E.on("slidesChanged",v),M&&E.on("select",M)),()=>{E&&(n&&E.off("init",n),r&&E.off("reInit",r),i&&E.off("scroll",i),o&&E.off("settle",o),a&&E.off("resize",a),c&&E.off("destroy",c),f&&E.off("pointerUp",f),p&&E.off("slideFocus",p),m&&E.off("pointerDown",m),g&&E.off("slidesInView",g),v&&E.off("slidesChanged",v),M&&E.off("select",M))}),[n,E,r,a,i,o,c,f,p,m,g,v,M]),T.useImperativeHandle(b,()=>({api:E}),[E]),_.jsxs("div",{ref:S,className:jt("bs-light-carousel",l),children:[_.jsx("div",{className:"bs-light-carousel__container",children:t}),d&&_.jsxs(_.Fragment,{children:[_.jsx(Qe,{square:!0,size:"md",variant:"outline",color:"secondary",icon:"bi-angle-left",...k?d:{},className:jt("bs-light-carousel__next",{"bs-light-carousel__next--active":C},k?d.className:""),onClick:N}),_.jsx(Qe,{square:!0,size:"md",color:"secondary",variant:"outline",icon:"bi-angle-right",...k?d:{},className:jt("bs-light-carousel__prev",{"bs-light-carousel__prev--active":I},k?d.className:""),onClick:D})]})]})});vb.Item=({className:n,children:e})=>_.jsx("div",{className:jt("bs-light-carousel__container-item",n),children:e}),vb.displayName="BsLightCarousel",vb.propTypes=X5;function TM(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Lc=TM();function Q5(n){Lc=n}const CM=/[&<>"']/,J5=new RegExp(CM.source,"g"),IM=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Z5=new RegExp(IM.source,"g"),eG={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},RM=n=>eG[n];function os(n,e){if(e){if(CM.test(n))return n.replace(J5,RM)}else if(IM.test(n))return n.replace(Z5,RM);return n}const tG=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function AM(n){return n.replace(tG,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const nG=/(^|[^\[])\^/g;function qn(n,e){n=typeof n=="string"?n:n.source,e=e||"";const t={replace:(r,s)=>(s=s.source||s,s=s.replace(nG,"$1"),n=n.replace(r,s),t),getRegex:()=>new RegExp(n,e)};return t}const rG=/[^\w:]/g,sG=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function kM(n,e,t){if(n){let r;try{r=decodeURIComponent(AM(t)).replace(rG,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!sG.test(t)&&(t=lG(e,t));try{t=encodeURI(t).replace(/%25/g,"%")}catch{return null}return t}const rp={},iG=/^[^:]+:\/*[^/]*$/,oG=/^([^:]+:)[\s\S]*$/,aG=/^([^:]+:\/*[^/]*)[\s\S]*$/;function lG(n,e){rp[" "+n]||(iG.test(n)?rp[" "+n]=n+"/":rp[" "+n]=ip(n,"/",!0)),n=rp[" "+n];const t=n.indexOf(":")===-1;return e.substring(0,2)==="//"?t?e:n.replace(oG,"$1")+e:e.charAt(0)==="/"?t?e:n.replace(aG,"$1")+e:n+e}const sp={exec:function(){}};function Yi(n){let e=1,t,r;for(;e<arguments.length;e++){t=arguments[e];for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n}function LM(n,e){const t=n.replace(/\|/g,(i,o,a)=>{let l=!1,c=o;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=t.split(/ \|/);let s=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(/\\\|/g,"|");return r}function ip(n,e,t){const r=n.length;if(r===0)return"";let s=0;for(;s<r;){const i=n.charAt(r-s-1);if(i===e&&!t)s++;else if(i!==e&&t)s++;else break}return n.slice(0,r-s)}function cG(n,e){if(n.indexOf(e[1])===-1)return-1;const t=n.length;let r=0,s=0;for(;s<t;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])r++;else if(n[s]===e[1]&&(r--,r<0))return s;return-1}function MM(n){n&&n.sanitize&&!n.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function NM(n,e){if(e<1)return"";let t="";for(;e>1;)e&1&&(t+=n),e>>=1,n+=n;return t+n}function OM(n,e,t,r){const s=e.href,i=e.title?os(e.title):null,o=n[1].replace(/\\([\[\]])/g,"$1");if(n[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:t,href:s,title:i,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,a}return{type:"image",raw:t,href:s,title:i,text:os(o)}}function uG(n,e){const t=n.match(/^(\s+)(?:```)/);if(t===null)return e;const r=t[1];return e.split(`
62 `).map(s=>{const i=s.match(/^\s+/);if(i===null)return s;const[o]=i;return o.length>=r.length?s.slice(r.length):s}).join(`
63 `)}class yb{constructor(e){this.options=e||Lc}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const r=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?r:ip(r,`
64 `)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const r=t[0],s=uG(r,t[3]||"");return{type:"code",raw:r,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:s}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let r=t[2].trim();if(/#$/.test(r)){const s=ip(r,"#");(this.options.pedantic||!s||/ $/.test(s))&&(r=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const r=t[0].replace(/^ *>[ \t]?/gm,"");return{type:"blockquote",raw:t[0],tokens:this.lexer.blockTokens(r,[]),text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let r,s,i,o,a,l,c,d,f,p,m,g,v=t[1].trim();const y=v.length>1,b={type:"list",raw:"",ordered:y,start:y?+v.slice(0,-1):"",loose:!1,items:[]};v=y?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=y?v:"[*+-]");const S=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(g=!1,!(!(t=S.exec(e))||this.rules.block.hr.test(e)));){if(r=t[0],e=e.substring(r.length),d=t[2].split(`
65 `,1)[0],f=e.split(`
66 `,1)[0],this.options.pedantic?(o=2,m=d.trimLeft()):(o=t[2].search(/[^ ]/),o=o>4?1:o,m=d.slice(o),o+=t[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
67 `,e=e.substring(f.length+1),g=!0),!g){const C=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`),R=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),I=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),A=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(p=e.split(`
68 `,1)[0],d=p,this.options.pedantic&&(d=d.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(I.test(d)||A.test(d)||C.test(d)||R.test(e)));){if(d.search(/[^ ]/)>=o||!d.trim())m+=`
69 `+d.slice(o);else if(!l)m+=`
70 `+d;else break;!l&&!d.trim()&&(l=!0),r+=p+`
71 `,e=e.substring(p.length+1)}}b.loose||(c?b.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(s=/^\[[ xX]\] /.exec(m),s&&(i=s[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),b.items.push({type:"list_item",raw:r,task:!!s,checked:i,loose:!1,text:m}),b.raw+=r}b.items[b.items.length-1].raw=r.trimRight(),b.items[b.items.length-1].text=m.trimRight(),b.raw=b.raw.trimRight();const E=b.items.length;for(a=0;a<E;a++){this.lexer.state.top=!1,b.items[a].tokens=this.lexer.blockTokens(b.items[a].text,[]);const C=b.items[a].tokens.filter(I=>I.type==="space"),R=C.every(I=>{const A=I.raw.split("");let k=0;for(const N of A)if(N===`
72 `&&(k+=1),k>1)return!0;return!1});!b.loose&&C.length&&R&&(b.loose=!0,b.items[a].loose=!0)}return b}}html(e){const t=this.rules.block.html.exec(e);if(t){const r={type:"html",raw:t[0],pre:!this.options.sanitizer&&(t[1]==="pre"||t[1]==="script"||t[1]==="style"),text:t[0]};if(this.options.sanitize){const s=this.options.sanitizer?this.options.sanitizer(t[0]):os(t[0]);r.type="paragraph",r.text=s,r.tokens=this.lexer.inline(s)}return r}}def(e){const t=this.rules.block.def.exec(e);if(t){const r=t[1].toLowerCase().replace(/\s+/g," "),s=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:r,raw:t[0],href:s,title:i}}}table(e){const t=this.rules.block.table.exec(e);if(t){const r={type:"table",header:LM(t[1]).map(s=>({text:s})),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
73 `):[]};if(r.header.length===r.align.length){r.raw=t[0];let s=r.align.length,i,o,a,l;for(i=0;i<s;i++)/^ *-+: *$/.test(r.align[i])?r.align[i]="right":/^ *:-+: *$/.test(r.align[i])?r.align[i]="center":/^ *:-+ *$/.test(r.align[i])?r.align[i]="left":r.align[i]=null;for(s=r.rows.length,i=0;i<s;i++)r.rows[i]=LM(r.rows[i],r.header.length).map(c=>({text:c}));for(s=r.header.length,o=0;o<s;o++)r.header[o].tokens=this.lexer.inline(r.header[o].text);for(s=r.rows.length,o=0;o<s;o++)for(l=r.rows[o],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const r=t[1].charAt(t[1].length-1)===`
74 `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:r,tokens:this.lexer.inline(r)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:os(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):os(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const r=t[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const o=ip(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=cG(t[2],"()");if(o>-1){const l=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);o&&(s=o[1],i=o[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(r)?s=s.slice(1):s=s.slice(1,-1)),OM(t,{href:s&&s.replace(this.rules.inline._escapes,"$1"),title:i&&i.replace(this.rules.inline._escapes,"$1")},t[0],this.lexer)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let s=(r[2]||r[1]).replace(/\s+/g," ");if(s=t[s.toLowerCase()],!s){const i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return OM(r,s,r[0],this.lexer)}}emStrong(e,t,r=""){let s=this.rules.inline.emStrong.lDelim.exec(e);if(!s||s[3]&&r.match(/[\p{L}\p{N}]/u))return;const i=s[1]||s[2]||"";if(!i||i&&(r===""||this.rules.inline.punctuation.exec(r))){const o=s[0].length-1;let a,l,c=o,d=0;const f=s[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,t=t.slice(-1*e.length+o);(s=f.exec(t))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(l=a.length,s[3]||s[4]){c+=l;continue}else if((s[5]||s[6])&&o%3&&!((o+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const p=e.slice(0,o+s.index+(s[0].length-a.length)+l);if(Math.min(o,l)%2){const g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}const m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let r=t[2].replace(/\n/g," ");const s=/[^ ]/.test(r),i=/^ /.test(r)&&/ $/.test(r);return s&&i&&(r=r.substring(1,r.length-1)),r=os(r,!0),{type:"codespan",raw:t[0],text:r}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){const r=this.rules.inline.autolink.exec(e);if(r){let s,i;return r[2]==="@"?(s=os(this.options.mangle?t(r[1]):r[1]),i="mailto:"+s):(s=os(r[1]),i=s),{type:"link",raw:r[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}url(e,t){let r;if(r=this.rules.inline.url.exec(e)){let s,i;if(r[2]==="@")s=os(this.options.mangle?t(r[0]):r[0]),i="mailto:"+s;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);s=os(r[0]),r[1]==="www."?i="http://"+s:i=s}return{type:"link",raw:r[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e,t){const r=this.rules.inline.text.exec(e);if(r){let s;return this.lexer.state.inRawBlock?s=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):os(r[0]):r[0]:s=os(this.options.smartypants?t(r[0]):r[0]),{type:"text",raw:r[0],text:s}}}}const Ut={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:sp,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ut._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ut._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Ut.def=qn(Ut.def).replace("label",Ut._label).replace("title",Ut._title).getRegex(),Ut.bullet=/(?:[*+-]|\d{1,9}[.)])/,Ut.listItemStart=qn(/^( *)(bull) */).replace("bull",Ut.bullet).getRegex(),Ut.list=qn(Ut.list).replace(/bull/g,Ut.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ut.def.source+")").getRegex(),Ut._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ut._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Ut.html=qn(Ut.html,"i").replace("comment",Ut._comment).replace("tag",Ut._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ut.paragraph=qn(Ut._paragraph).replace("hr",Ut.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ut._tag).getRegex(),Ut.blockquote=qn(Ut.blockquote).replace("paragraph",Ut.paragraph).getRegex(),Ut.normal=Yi({},Ut),Ut.gfm=Yi({},Ut.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),Ut.gfm.table=qn(Ut.gfm.table).replace("hr",Ut.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ut._tag).getRegex(),Ut.gfm.paragraph=qn(Ut._paragraph).replace("hr",Ut.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ut.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ut._tag).getRegex(),Ut.pedantic=Yi({},Ut.normal,{html:qn(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ut._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:sp,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:qn(Ut.normal._paragraph).replace("hr",Ut.hr).replace("heading",` *#{1,6} *[^
75 ]`).replace("lheading",Ut.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const yt={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:sp,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:sp,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};yt._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",yt.punctuation=qn(yt.punctuation).replace(/punctuation/g,yt._punctuation).getRegex(),yt.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,yt.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,yt._comment=qn(Ut._comment).replace("(?:-->|$)","-->").getRegex(),yt.emStrong.lDelim=qn(yt.emStrong.lDelim).replace(/punct/g,yt._punctuation).getRegex(),yt.emStrong.rDelimAst=qn(yt.emStrong.rDelimAst,"g").replace(/punct/g,yt._punctuation).getRegex(),yt.emStrong.rDelimUnd=qn(yt.emStrong.rDelimUnd,"g").replace(/punct/g,yt._punctuation).getRegex(),yt._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,yt._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,yt._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,yt.autolink=qn(yt.autolink).replace("scheme",yt._scheme).replace("email",yt._email).getRegex(),yt._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,yt.tag=qn(yt.tag).replace("comment",yt._comment).replace("attribute",yt._attribute).getRegex(),yt._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,yt._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,yt._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,yt.link=qn(yt.link).replace("label",yt._label).replace("href",yt._href).replace("title",yt._title).getRegex(),yt.reflink=qn(yt.reflink).replace("label",yt._label).replace("ref",Ut._label).getRegex(),yt.nolink=qn(yt.nolink).replace("ref",Ut._label).getRegex(),yt.reflinkSearch=qn(yt.reflinkSearch,"g").replace("reflink",yt.reflink).replace("nolink",yt.nolink).getRegex(),yt.normal=Yi({},yt),yt.pedantic=Yi({},yt.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:qn(/^!?\[(label)\]\((.*?)\)/).replace("label",yt._label).getRegex(),reflink:qn(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yt._label).getRegex()}),yt.gfm=Yi({},yt.normal,{escape:qn(yt.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),yt.gfm.url=qn(yt.gfm.url,"i").replace("email",yt.gfm._extended_email).getRegex(),yt.breaks=Yi({},yt.gfm,{br:qn(yt.br).replace("{2,}","*").getRegex(),text:qn(yt.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});function dG(n){return n.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function PM(n){let e="",t,r;const s=n.length;for(t=0;t<s;t++)r=n.charCodeAt(t),Math.random()>.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class Qo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Lc,this.options.tokenizer=this.options.tokenizer||new yb,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Ut.normal,inline:yt.normal};this.options.pedantic?(t.block=Ut.pedantic,t.inline=yt.pedantic):this.options.gfm&&(t.block=Ut.gfm,this.options.breaks?t.inline=yt.breaks:t.inline=yt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ut,inline:yt}}static lex(e,t){return new Qo(t).lex(e)}static lexInline(e,t){return new Qo(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
76 `),this.blockTokens(e,this.tokens);let t;for(;t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,s,i,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&t.length>0?t[t.length-1].raw+=`
77 `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=`
78 `+r.raw,s.text+=`
79 `+r.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=`
80 `+r.raw,s.text+=`
81 `+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(i=e,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=e.slice(1);let c;this.options.extensions.startBlock.forEach(function(d){c=d.call({lexer:this},l),typeof c=="number"&&c>=0&&(a=Math.min(a,c))}),a<1/0&&a>=0&&(i=e.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){s=t[t.length-1],o&&s.type==="paragraph"?(s.raw+=`
82 `+r.raw,s.text+=`
83 `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(r),o=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),s=t[t.length-1],s&&s.type==="text"?(s.raw+=`
84 `+r.raw,s.text+=`
85 `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(r);continue}if(e){const a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let r,s,i,o=e,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,a.index)+"["+NM("a",a[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,a.index)+"["+NM("a",a[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,a.index+a[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),s=t[t.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),s=t[t.length-1],s&&r.type==="text"&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,o,c)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e,PM)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,PM))){e=e.substring(r.raw.length),t.push(r);continue}if(i=e,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=e.slice(1);let p;this.options.extensions.startInline.forEach(function(m){p=m.call({lexer:this},f),typeof p=="number"&&p>=0&&(d=Math.min(d,p))}),d<1/0&&d>=0&&(i=e.substring(0,d+1))}if(r=this.tokenizer.inlineText(i,dG)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,s=t[t.length-1],s&&s.type==="text"?(s.raw+=r.raw,s.text+=r.text):t.push(r);continue}if(e){const d="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return t}}class bb{constructor(e){this.options=e||Lc}code(e,t,r){const s=(t||"").match(/\S*/)[0];if(this.options.highlight){const i=this.options.highlight(e,s);i!=null&&i!==e&&(r=!0,e=i)}return e=e.replace(/\n$/,"")+`
86 `,s?'<pre><code class="'+this.options.langPrefix+os(s)+'">'+(r?e:os(e,!0))+`</code></pre>
87 `:"<pre><code>"+(r?e:os(e,!0))+`</code></pre>
88 `}blockquote(e){return`<blockquote>
89 ${e}</blockquote>
90 `}html(e){return e}heading(e,t,r,s){if(this.options.headerIds){const i=this.options.headerPrefix+s.slug(r);return`<h${t} id="${i}">${e}</h${t}>
91 `}return`<h${t}>${e}</h${t}>
92 `}hr(){return this.options.xhtml?`<hr/>
93 `:`<hr>
94 `}list(e,t,r){const s=t?"ol":"ul",i=t&&r!==1?' start="'+r+'"':"";return"<"+s+i+`>
95 `+e+"</"+s+`>
96 `}listitem(e){return`<li>${e}</li>
97 `}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return`<p>${e}</p>
98 `}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
99 <thead>
100 `+e+`</thead>
101 `+t+`</table>
102 `}tablerow(e){return`<tr>
103 ${e}</tr>
104 `}tablecell(e,t){const r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>
105 `}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(e){return`<del>${e}</del>`}link(e,t,r){if(e=kM(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let s='<a href="'+e+'"';return t&&(s+=' title="'+t+'"'),s+=">"+r+"</a>",s}image(e,t,r){if(e=kM(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let s=`<img src="${e}" alt="${r}"`;return t&&(s+=` title="${t}"`),s+=this.options.xhtml?"/>":">",s}text(e){return e}}class DM{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,r){return""+r}image(e,t,r){return""+r}br(){return""}}class jM{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let r=e,s=0;if(this.seen.hasOwnProperty(r)){s=this.seen[e];do s++,r=e+"-"+s;while(this.seen.hasOwnProperty(r))}return t||(this.seen[e]=s,this.seen[r]=0),r}slug(e,t={}){const r=this.serialize(e);return this.getNextSafeSlug(r,t.dryrun)}}class xo{constructor(e){this.options=e||Lc,this.options.renderer=this.options.renderer||new bb,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new DM,this.slugger=new jM}static parse(e,t){return new xo(t).parse(e)}static parseInline(e,t){return new xo(t).parseInline(e)}parse(e,t=!0){let r="",s,i,o,a,l,c,d,f,p,m,g,v,y,b,S,E,C,R,I;const A=e.length;for(s=0;s<A;s++){if(m=e[s],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[m.type]&&(I=this.options.extensions.renderers[m.type].call({parser:this},m),I!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(m.type))){r+=I||"";continue}switch(m.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(m.tokens),m.depth,AM(this.parseInline(m.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(m.text,m.lang,m.escaped);continue}case"table":{for(f="",d="",a=m.header.length,i=0;i<a;i++)d+=this.renderer.tablecell(this.parseInline(m.header[i].tokens),{header:!0,align:m.align[i]});for(f+=this.renderer.tablerow(d),p="",a=m.rows.length,i=0;i<a;i++){for(c=m.rows[i],d="",l=c.length,o=0;o<l;o++)d+=this.renderer.tablecell(this.parseInline(c[o].tokens),{header:!1,align:m.align[o]});p+=this.renderer.tablerow(d)}r+=this.renderer.table(f,p);continue}case"blockquote":{p=this.parse(m.tokens),r+=this.renderer.blockquote(p);continue}case"list":{for(g=m.ordered,v=m.start,y=m.loose,a=m.items.length,p="",i=0;i<a;i++)S=m.items[i],E=S.checked,C=S.task,b="",S.task&&(R=this.renderer.checkbox(E),y?S.tokens.length>0&&S.tokens[0].type==="paragraph"?(S.tokens[0].text=R+" "+S.tokens[0].text,S.tokens[0].tokens&&S.tokens[0].tokens.length>0&&S.tokens[0].tokens[0].type==="text"&&(S.tokens[0].tokens[0].text=R+" "+S.tokens[0].tokens[0].text)):S.tokens.unshift({type:"text",text:R}):b+=R),b+=this.parse(S.tokens,y),p+=this.renderer.listitem(b,C,E);r+=this.renderer.list(p,g,v);continue}case"html":{r+=this.renderer.html(m.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(m.tokens));continue}case"text":{for(p=m.tokens?this.parseInline(m.tokens):m.text;s+1<A&&e[s+1].type==="text";)m=e[++s],p+=`
106 `+(m.tokens?this.parseInline(m.tokens):m.text);r+=t?this.renderer.paragraph(p):p;continue}default:{const k='Token with "'+m.type+'" type was not found.';if(this.options.silent){console.error(k);return}else throw new Error(k)}}}return r}parseInline(e,t){t=t||this.renderer;let r="",s,i,o;const a=e.length;for(s=0;s<a;s++){if(i=e[s],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]&&(o=this.options.extensions.renderers[i.type].call({parser:this},i),o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type))){r+=o||"";continue}switch(i.type){case"escape":{r+=t.text(i.text);break}case"html":{r+=t.html(i.text);break}case"link":{r+=t.link(i.href,i.title,this.parseInline(i.tokens,t));break}case"image":{r+=t.image(i.href,i.title,i.text);break}case"strong":{r+=t.strong(this.parseInline(i.tokens,t));break}case"em":{r+=t.em(this.parseInline(i.tokens,t));break}case"codespan":{r+=t.codespan(i.text);break}case"br":{r+=t.br();break}case"del":{r+=t.del(this.parseInline(i.tokens,t));break}case"text":{r+=t.text(i.text);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}function Xt(n,e,t){if(typeof n>"u"||n===null)throw new Error("marked(): input parameter is undefined or null");if(typeof n!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected");if(typeof e=="function"&&(t=e,e=null),e=Yi({},Xt.defaults,e||{}),MM(e),t){const s=e.highlight;let i;try{i=Qo.lex(n,e)}catch(l){return t(l)}const o=function(l){let c;if(!l)try{e.walkTokens&&Xt.walkTokens(i,e.walkTokens),c=xo.parse(i,e)}catch(d){l=d}return e.highlight=s,l?t(l):t(null,c)};if(!s||s.length<3||(delete e.highlight,!i.length))return o();let a=0;Xt.walkTokens(i,function(l){l.type==="code"&&(a++,setTimeout(()=>{s(l.text,l.lang,function(c,d){if(c)return o(c);d!=null&&d!==l.text&&(l.text=d,l.escaped=!0),a--,a===0&&o()})},0))}),a===0&&o();return}function r(s){if(s.message+=`
107 Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+os(s.message+"",!0)+"</pre>";throw s}try{const s=Qo.lex(n,e);if(e.walkTokens){if(e.async)return Promise.all(Xt.walkTokens(s,e.walkTokens)).then(()=>xo.parse(s,e)).catch(r);Xt.walkTokens(s,e.walkTokens)}return xo.parse(s,e)}catch(s){r(s)}}Xt.options=Xt.setOptions=function(n){return Yi(Xt.defaults,n),Q5(Xt.defaults),Xt},Xt.getDefaults=TM,Xt.defaults=Lc,Xt.use=function(...n){const e=Xt.defaults.extensions||{renderers:{},childTokens:{}};n.forEach(t=>{const r=Yi({},t);if(r.async=Xt.defaults.async||r.async,t.extensions&&(t.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if(s.renderer){const i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=i.apply(this,o)),a}:e.renderers[s.name]=s.renderer}if(s.tokenizer){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[s.level]?e[s.level].unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),t.renderer){const s=Xt.defaults.renderer||new bb;for(const i in t.renderer){const o=s[i];s[i]=(...a)=>{let l=t.renderer[i].apply(s,a);return l===!1&&(l=o.apply(s,a)),l}}r.renderer=s}if(t.tokenizer){const s=Xt.defaults.tokenizer||new yb;for(const i in t.tokenizer){const o=s[i];s[i]=(...a)=>{let l=t.tokenizer[i].apply(s,a);return l===!1&&(l=o.apply(s,a)),l}}r.tokenizer=s}if(t.walkTokens){const s=Xt.defaults.walkTokens;r.walkTokens=function(i){let o=[];return o.push(t.walkTokens.call(this,i)),s&&(o=o.concat(s.call(this,i))),o}}Xt.setOptions(r)})},Xt.walkTokens=function(n,e){let t=[];for(const r of n)switch(t=t.concat(e.call(Xt,r)),r.type){case"table":{for(const s of r.header)t=t.concat(Xt.walkTokens(s.tokens,e));for(const s of r.rows)for(const i of s)t=t.concat(Xt.walkTokens(i.tokens,e));break}case"list":{t=t.concat(Xt.walkTokens(r.items,e));break}default:Xt.defaults.extensions&&Xt.defaults.extensions.childTokens&&Xt.defaults.extensions.childTokens[r.type]?Xt.defaults.extensions.childTokens[r.type].forEach(function(s){t=t.concat(Xt.walkTokens(r[s],e))}):r.tokens&&(t=t.concat(Xt.walkTokens(r.tokens,e)))}return t},Xt.parseInline=function(n,e){if(typeof n>"u"||n===null)throw new Error("marked.parseInline(): input parameter is undefined or null");if(typeof n!="string")throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected");e=Yi({},Xt.defaults,e||{}),MM(e);try{const t=Qo.lexInline(n,e);return e.walkTokens&&Xt.walkTokens(t,e.walkTokens),xo.parseInline(t,e)}catch(t){if(t.message+=`
108 Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+os(t.message+"",!0)+"</pre>";throw t}},Xt.Parser=xo,Xt.parser=xo.parse,Xt.Renderer=bb,Xt.TextRenderer=DM,Xt.Lexer=Qo,Xt.lexer=Qo.lex,Xt.Tokenizer=yb,Xt.Slugger=jM,Xt.parse=Xt,Xt.options,Xt.setOptions,Xt.use,Xt.walkTokens,Xt.parseInline,xo.parse,Qo.lex,O.string,O.string.isRequired;const fG={id:O.string,loop:O.bool,muted:O.bool,poster:O.string,autoplay:O.bool,children:O.node,controls:O.bool,observer:O.bool,preload:O.string,className:O.string,playsInline:O.bool,src:O.string.isRequired};let xb=null;const Bd=T.forwardRef(({id:n,src:e,loop:t,muted:r,poster:s,preload:i,autoplay:o,children:a,className:l,playsInline:c,controls:d=!0,observer:f=!1},p)=>{const m=Mt.useFallbackRef(p),g=T.useRef(),[v,y]=T.useState(!1),[b,S]=T.useState(!1);T.useEffect(()=>{S(!1)},[e]);const E=T.useMemo(()=>de.isClientSide()&&"IntersectionObserver"in window?new IntersectionObserver(N=>{var D;N[0].isIntersecting||((D=m.current)==null||D.pause())}):null,[m]),C=T.useCallback(async()=>{try{let N=xb;N||(N=(await Promise.resolve().then(()=>xce)).default,xb||(xb=N)),N&&N.isSupported()&&m.current?(g.current=new N({startLevel:3}),g.current.loadSource(e),g.current.attachMedia(m.current)):m.current&&m.current.canPlayType("application/vnd.apple.mpegurl")&&(m.current.src=e)}catch(N){console.error(N)}},[e,m]),R=T.useCallback(()=>{try{m.current&&(m.current.src=e)}catch(N){console.error(N)}},[e,m]),I=T.useCallback(()=>{y(!0)},[]),A=T.useCallback(()=>{y(!1)},[]),k=T.useCallback(()=>{S(!0)},[]);return T.useEffect(()=>{const N=m.current;return f&&N&&E&&E.observe(N),()=>{f&&N&&E&&E.unobserve(N)}},[f,E,m]),T.useEffect(()=>(e.endsWith(".m3u8")?C():R(),()=>{var N;(N=g.current)==null||N.destroy()}),[e,C,R]),T.useEffect(()=>{m.current&&(m.current.addEventListener("play",I),m.current.addEventListener("pause",A),m.current.addEventListener("ended",A),m.current.addEventListener("canplay",k));const N=m.current;return()=>{var D;(D=g.current)==null||D.destroy(),N==null||N.removeEventListener("play",I),N==null||N.removeEventListener("pause",A),N==null||N.removeEventListener("ended",A),N==null||N.removeEventListener("canplay",k)}},[o,k,A,I,m]),_.jsxs("div",{className:jt("bs-video",l),children:[_.jsxs("video",{id:n,loop:t,muted:r,ref:m,poster:s,preload:i,controls:d,autoPlay:o,playsInline:c,className:"bs-video__player",children:[a,"مرورگر شما از ویدیو پشتیبانی نمی‌کند."]}),_.jsx(Mr,{mounted:!v&&b,transition:"fade",duration:400,children:N=>_.jsx("button",{"aria-label":"play",className:"bs-video__play",style:N,onClick:()=>{var D;return(D=m.current)==null?void 0:D.play()},children:_.jsx("i",{className:"bi-play"})})})]})});Bd.propTypes=fG,Bd.displayName="BsVideo";const hG=[];for(let n=0;n<256;++n)hG.push((n+256).toString(16).slice(1));typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const pG={href:O.string,onClick:O.func,children:O.node,className:O.string,size:O.oneOf(["sm","md","lg"]),target:O.oneOf(["_self","_blank"]),label:O.oneOfType([O.string,O.number]),component:O.oneOfType([O.string,O.element,O.func])},$d=({href:n,target:e,onClick:t,children:r,className:s,label:i="",size:o="md",component:a="a"})=>_.jsx(a,{to:n,href:n,tabIndex:0,role:"button",target:e,onClick:t,onKeyDown:t,className:jt("bs-more-link",`bs-more-link--${o}`,s),children:r||i});$d.propTypes=pG,$d.displayName="BsMoreLink",O.string,O.number,O.number,O.number,O.string,O.string,O.oneOfType([O.string,O.element,O.func]);const mG={label:O.node,name:O.string,onBlur:O.func,checked:O.bool,disabled:O.bool,onChange:O.func,className:O.string,defaultChecked:O.bool,size:O.oneOf(["md","lg"]),value:O.oneOfType([O.string,O.number]).isRequired},gG={onChange:O.func,children:O.node,value:O.oneOfType([O.string,O.number]).isRequired},FM=T.createContext({isInGroup:!1}),_G=FM.Provider,gs=T.forwardRef(({value:n,label:e,onChange:t,className:r,size:s="md",defaultChecked:i,checked:o,disabled:a},l)=>{const c=T.useId(),d=Mt.useFallbackRef(l),f=T.useContext(FM),p=o===void 0?f.isInGroup&&n?f.value===n:void 0:o;return T.useEffect(()=>{i&&o===void 0&&d.current&&(d.current.checked=!0)},[]),_.jsxs("label",{htmlFor:c,className:jt("bs-radio",`bs-radio--${s}`,"bs-radio--"+(a?"disabled":"enabled"),r),children:[_.jsx("input",{id:c,ref:d,type:"radio",value:n,disabled:a,checked:p,className:"bs-radio__input",onChange:m=>{t&&t(m),f.onChange&&f.onChange(typeof n=="number"?Number(m.target.value):m.target.value)}}),_.jsx("span",{className:"bs-radio__el"}),e]})}),Sb=({children:n,value:e,onChange:t})=>_.jsx(_G,{value:{isInGroup:!0,value:e,onChange:t},children:n});gs.propTypes=mG,gs.displayName="BsRadio",Sb.propTypes=gG,Sb.displayName="BsRadioGroup",gs.Group=Sb;const vG={min:O.number,mid:O.number,max:O.number,value:O.number,isButton:O.bool,onChange:O.func,readOnly:O.bool,showIndex:O.bool,className:O.string,indexColor:O.string,onHoverChange:O.func,defaultValue:O.number,size:O.oneOf(["sm","md","lg"]),color:O.oneOf(["black","auto","danger","warning","primary"])},Eb=({value:n,min:e=0,mid:t=3,max:r=5,readOnly:s,isButton:i,onChange:o,showIndex:a,className:l,indexColor:c,size:d="lg",defaultValue:f,onHoverChange:p,color:m="warning"})=>{const g=T.useId(),v=T.useRef(null),[y,b]=Mt.useUncontrolled({value:n,onChange:o,defaultValue:f,finalValue:0}),[S,E]=T.useState(-1),[C,R]=T.useState(!0),I=z=>{const B=z+1;s||B<e||b(B)},A=z=>{const B=z+1;return C||s?B<=Math.round(y):B<=Math.max(e,S)},k=T.useMemo(()=>s?{index:Math.ceil(y)-1,fillPercent:y%1==0?100:10*Number(y.toFixed(1).toString().split(".")[1])}:null,[s,y]),N=T.useMemo(()=>jt("bs-rating",`bs-rating--${d}`,{"bs-rating--is-button":i},l),[d,i,l]),D=jt("bs-rating__wrapper",{"bs-rating__wrapper--button":i}),M=z=>jt("bs-rating__star",{"bs-rating__star--active":A(z)},{"bs-rating__star--readonly":s}),F=z=>jt("bs-rating__button",{"bs-rating__button--active":A(z),"bs-rating__button--disabled":s&&!f}),U=z=>jt("bs-rating__button-icon","bi-star"+(A(z)?"-fill":"")),$=z=>(k==null?void 0:k.index)===z?{fill:`url('#${g}')`}:{},q={bg:"var(--gray-100)",danger:"var(--danger)",black:"var(--gray-600)",warning:"var(--warning)",primary:"var(--primary)",auto:(G=S,V=y,(G>-1?t<=G:t<=V)?"var(--warning)":"var(--danger)")};var G,V;return _.jsx("div",{className:N,children:_.jsx("div",{ref:v,className:D,onMouseEnter:()=>{s||R(!1)},onMouseMove:z=>{if(s||!v.current)return;const{left:B,width:P}=v.current.getBoundingClientRect(),H=P/r,Z=(z.clientX-B)/H,Q=Math.round(Z+.5);E(Q),p==null||p(Q)},onMouseLeave:()=>{s||(E(-1),R(!0),p==null||p(-1))},children:Array.from({length:r}).map((z,B)=>_.jsxs("div",i?{className:M(B),children:[_.jsx("div",{className:F(B),onClick:()=>I(B),children:_.jsx("i",{className:U(B)})},B),a&&_.jsx("span",{className:"bs-rating__star-index",children:B+1})]}:{className:M(B),role:"button",tabIndex:0,onClick:()=>I(B),onKeyDown:()=>I(B),children:[_.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(k==null?void 0:k.index)===B&&_.jsxs("linearGradient",{id:g,children:[_.jsx("stop",{offset:`${k.fillPercent}%`,stopColor:q[m]}),_.jsx("stop",{offset:`${k.fillPercent}%`,stopColor:q.bg})]}),_.jsx("path",{fill:A(B)?q[m]:q.bg,d:"M12.9279 4.79202L14.2024 8.96053H18.3093C19.7255 8.96053 20.292 10.747 19.159 11.6403L15.7602 14.1712L17.0348 18.3397C17.4596 19.6796 15.9018 20.8706 14.9105 19.9774L11.5117 17.4465L8.11291 19.9774C6.97998 20.8706 5.56381 19.6796 5.98866 18.3397L7.26321 14.1712L3.86441 11.6403C2.73147 10.747 3.29794 8.96053 4.71411 8.96053H8.821L10.0956 4.79202C10.5204 3.45214 12.503 3.45214 12.9279 4.79202Z",style:$(B)})]}),a&&_.jsx("span",{className:"bs-rating__star-index",style:{color:c||q[m]},children:B+1})]},B))})})};Eb.propTypes=vG,Eb.displayName="BsRating",O.number,O.number,O.bool,O.string,O.number,O.string,O.string,O.func,O.func,O.string,O.oneOf(["sm","md","lg"]),O.oneOfType([O.string,O.number]);const yG={waveColor:O.string,className:O.string,backgroundColor:O.string,width:O.oneOfType([O.string,O.number]),radius:O.oneOfType([O.string,O.number]),height:O.oneOfType([O.string,O.number])},wb=n=>typeof n=="number"?`${n}px`:n,Tb=({width:n,height:e,className:t,radius:r=4,waveColor:s="var(--gray-100)",backgroundColor:i="var(--gray-050)"})=>{const o=T.useRef(null),{observe:a,unobserve:l,isInViewport:c}=Mt.useIntersectionObserver(),d={backgroundColor:i,borderRadius:wb(r),"--skeleton-gradient-color":s,width:n?wb(n):void 0,height:e?wb(e):void 0};return T.useEffect(()=>{const f=o.current;return f&&a(f),()=>{f&&l(f)}},[]),_.jsx("div",{ref:o,className:jt("bs-skeleton",t,{"bs-skeleton--animate":c}),style:d})};Tb.propTypes=yG,Tb.displayName="BsSkeleton";var vt=T.memo(Tb);let bG={data:""},xG=n=>typeof window=="object"?((n?n.querySelector("#_goober"):window._goober)||Object.assign((n||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:n||bG,SG=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,EG=/\/\*[^]*?\*\/| +/g,UM=/\n+/g,Aa=(n,e)=>{let t="",r="",s="";for(let i in n){let o=n[i];i[0]=="@"?i[1]=="i"?t=i+" "+o+";":r+=i[1]=="f"?Aa(o,i):i+"{"+Aa(o,i[1]=="k"?"":e)+"}":typeof o=="object"?r+=Aa(o,e?e.replace(/([^,])+/g,a=>i.replace(/(^:.*)|([^,])+/g,l=>/&/.test(l)?l.replace(/&/g,a):a?a+" "+l:l)):i):o!=null&&(i=/^--/.test(i)?i:i.replace(/[A-Z]/g,"-$&").toLowerCase(),s+=Aa.p?Aa.p(i,o):i+":"+o+";")}return t+(e&&s?e+"{"+s+"}":s)+r},Jo={},BM=n=>{if(typeof n=="object"){let e="";for(let t in n)e+=t+BM(n[t]);return e}return n},wG=(n,e,t,r,s)=>{let i=BM(n),o=Jo[i]||(Jo[i]=(l=>{let c=0,d=11;for(;c<l.length;)d=101*d+l.charCodeAt(c++)>>>0;return"go"+d})(i));if(!Jo[o]){let l=i!==n?n:(c=>{let d,f,p=[{}];for(;d=SG.exec(c.replace(EG,""));)d[4]?p.shift():d[3]?(f=d[3].replace(UM," ").trim(),p.unshift(p[0][f]=p[0][f]||{})):p[0][d[1]]=d[2].replace(UM," ").trim();return p[0]})(n);Jo[o]=Aa(s?{["@keyframes "+o]:l}:l,t?"":"."+o)}let a=t&&Jo.g?Jo.g:null;return t&&(Jo.g=Jo[o]),((l,c,d,f)=>{f?c.data=c.data.replace(f,l):c.data.indexOf(l)===-1&&(c.data=d?l+c.data:c.data+l)})(Jo[o],e,r,a),o},TG=(n,e,t)=>n.reduce((r,s,i)=>{let o=e[i];if(o&&o.call){let a=o(t),l=a&&a.props&&a.props.className||/^go/.test(a)&&a;o=l?"."+l:a&&typeof a=="object"?a.props?"":Aa(a,""):a===!1?"":a}return r+s+(o??"")},"");function op(n){let e=this||{},t=n.call?n(e.p):n;return wG(t.unshift?t.raw?TG(t,[].slice.call(arguments,1),e.p):t.reduce((r,s)=>Object.assign(r,s&&s.call?s(e.p):s),{}):t,xG(e.target),e.g,e.o,e.k)}let $M,Cb,Ib;op.bind({g:1});let Zo=op.bind({k:1});function CG(n,e,t,r){Aa.p=e,$M=n,Cb=t,Ib=r}function ka(n,e){let t=this||{};return function(){let r=arguments;function s(i,o){let a=Object.assign({},i),l=a.className||s.className;t.p=Object.assign({theme:Cb&&Cb()},a),t.o=/ *go\d+/.test(l),a.className=op.apply(t,r)+(l?" "+l:"");let c=n;return n[0]&&(c=a.as||n,delete a.as),Ib&&c[0]&&Ib(a),$M(c,a)}return s}}var IG=n=>typeof n=="function",ap=(n,e)=>IG(n)?n(e):n,RG=(()=>{let n=0;return()=>(++n).toString()})(),zM=(()=>{let n;return()=>{if(n===void 0&&typeof window<"u"){let e=matchMedia("(prefers-reduced-motion: reduce)");n=!e||e.matches}return n}})(),AG=20,lp=new Map,kG=1e3,qM=n=>{if(lp.has(n))return;let e=setTimeout(()=>{lp.delete(n),Rl({type:4,toastId:n})},kG);lp.set(n,e)},LG=n=>{let e=lp.get(n);e&&clearTimeout(e)},Rb=(n,e)=>{switch(e.type){case 0:return{...n,toasts:[e.toast,...n.toasts].slice(0,AG)};case 1:return e.toast.id&&LG(e.toast.id),{...n,toasts:n.toasts.map(i=>i.id===e.toast.id?{...i,...e.toast}:i)};case 2:let{toast:t}=e;return n.toasts.find(i=>i.id===t.id)?Rb(n,{type:1,toast:t}):Rb(n,{type:0,toast:t});case 3:let{toastId:r}=e;return r?qM(r):n.toasts.forEach(i=>{qM(i.id)}),{...n,toasts:n.toasts.map(i=>i.id===r||r===void 0?{...i,visible:!1}:i)};case 4:return e.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(i=>i.id!==e.toastId)};case 5:return{...n,pausedAt:e.time};case 6:let s=e.time-(n.pausedAt||0);return{...n,pausedAt:void 0,toasts:n.toasts.map(i=>({...i,pauseDuration:i.pauseDuration+s}))}}},cp=[],up={toasts:[],pausedAt:void 0},Rl=n=>{up=Rb(up,n),cp.forEach(e=>{e(up)})},MG={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},NG=(n={})=>{let[e,t]=T.useState(up);T.useEffect(()=>(cp.push(t),()=>{let s=cp.indexOf(t);s>-1&&cp.splice(s,1)}),[e]);let r=e.toasts.map(s=>{var i,o;return{...n,...n[s.type],...s,duration:s.duration||((i=n[s.type])==null?void 0:i.duration)||(n==null?void 0:n.duration)||MG[s.type],style:{...n.style,...(o=n[s.type])==null?void 0:o.style,...s.style}}});return{...e,toasts:r}},OG=(n,e="blank",t)=>({createdAt:Date.now(),visible:!0,type:e,ariaProps:{role:"status","aria-live":"polite"},message:n,pauseDuration:0,...t,id:(t==null?void 0:t.id)||RG()}),zd=n=>(e,t)=>{let r=OG(e,n,t);return Rl({type:2,toast:r}),r.id},_s=(n,e)=>zd("blank")(n,e);_s.error=zd("error"),_s.success=zd("success"),_s.loading=zd("loading"),_s.custom=zd("custom"),_s.dismiss=n=>{Rl({type:3,toastId:n})},_s.remove=n=>Rl({type:4,toastId:n}),_s.promise=(n,e,t)=>{let r=_s.loading(e.loading,{...t,...t==null?void 0:t.loading});return n.then(s=>(_s.success(ap(e.success,s),{id:r,...t,...t==null?void 0:t.success}),s)).catch(s=>{_s.error(ap(e.error,s),{id:r,...t,...t==null?void 0:t.error})}),n};var PG=(n,e)=>{Rl({type:1,toast:{id:n,height:e}})},DG=()=>{Rl({type:5,time:Date.now()})},jG=n=>{let{toasts:e,pausedAt:t}=NG(n);T.useEffect(()=>{if(t)return;let i=Date.now(),o=e.map(a=>{if(a.duration===1/0)return;let l=(a.duration||0)+a.pauseDuration-(i-a.createdAt);if(l<0){a.visible&&_s.dismiss(a.id);return}return setTimeout(()=>_s.dismiss(a.id),l)});return()=>{o.forEach(a=>a&&clearTimeout(a))}},[e,t]);let r=T.useCallback(()=>{t&&Rl({type:6,time:Date.now()})},[t]),s=T.useCallback((i,o)=>{let{reverseOrder:a=!1,gutter:l=8,defaultPosition:c}=o||{},d=e.filter(m=>(m.position||c)===(i.position||c)&&m.height),f=d.findIndex(m=>m.id===i.id),p=d.filter((m,g)=>g<f&&m.visible).length;return d.filter(m=>m.visible).slice(...a?[p+1]:[0,p]).reduce((m,g)=>m+(g.height||0)+l,0)},[e]);return{toasts:e,handlers:{updateHeight:PG,startPause:DG,endPause:r,calculateOffset:s}}},FG=Zo`
109 from {
110 transform: scale(0) rotate(45deg);
111 opacity: 0;
112 }
113 to {
114 transform: scale(1) rotate(45deg);
115 opacity: 1;
116 }`,UG=Zo`
117 from {
118 transform: scale(0);
119 opacity: 0;
120 }
121 to {
122 transform: scale(1);
123 opacity: 1;
124 }`,BG=Zo`
125 from {
126 transform: scale(0) rotate(90deg);
127 opacity: 0;
128 }
129 to {
130 transform: scale(1) rotate(90deg);
131 opacity: 1;
132 }`,$G=ka("div")`
133 width: 20px;
134 opacity: 0;
135 height: 20px;
136 border-radius: 10px;
137 background: ${n=>n.primary||"#ff4b4b"};
138 position: relative;
139 transform: rotate(45deg);
140
141 animation: ${FG} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
142 forwards;
143 animation-delay: 100ms;
144
145 &:after,
146 &:before {
147 content: '';
148 animation: ${UG} 0.15s ease-out forwards;
149 animation-delay: 150ms;
150 position: absolute;
151 border-radius: 3px;
152 opacity: 0;
153 background: ${n=>n.secondary||"#fff"};
154 bottom: 9px;
155 left: 4px;
156 height: 2px;
157 width: 12px;
158 }
159
160 &:before {
161 animation: ${BG} 0.15s ease-out forwards;
162 animation-delay: 180ms;
163 transform: rotate(90deg);
164 }
165 `,zG=Zo`
166 from {
167 transform: rotate(0deg);
168 }
169 to {
170 transform: rotate(360deg);
171 }
172 `,qG=ka("div")`
173 width: 12px;
174 height: 12px;
175 box-sizing: border-box;
176 border: 2px solid;
177 border-radius: 100%;
178 border-color: ${n=>n.secondary||"#e0e0e0"};
179 border-right-color: ${n=>n.primary||"#616161"};
180 animation: ${zG} 1s linear infinite;
181 `,HG=Zo`
182 from {
183 transform: scale(0) rotate(45deg);
184 opacity: 0;
185 }
186 to {
187 transform: scale(1) rotate(45deg);
188 opacity: 1;
189 }`,GG=Zo`
190 0% {
191 height: 0;
192 width: 0;
193 opacity: 0;
194 }
195 40% {
196 height: 0;
197 width: 6px;
198 opacity: 1;
199 }
200 100% {
201 opacity: 1;
202 height: 10px;
203 }`,VG=ka("div")`
204 width: 20px;
205 opacity: 0;
206 height: 20px;
207 border-radius: 10px;
208 background: ${n=>n.primary||"#61d345"};
209 position: relative;
210 transform: rotate(45deg);
211
212 animation: ${HG} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
213 forwards;
214 animation-delay: 100ms;
215 &:after {
216 content: '';
217 box-sizing: border-box;
218 animation: ${GG} 0.2s ease-out forwards;
219 opacity: 0;
220 animation-delay: 200ms;
221 position: absolute;
222 border-right: 2px solid;
223 border-bottom: 2px solid;
224 border-color: ${n=>n.secondary||"#fff"};
225 bottom: 6px;
226 left: 6px;
227 height: 10px;
228 width: 6px;
229 }
230 `,WG=ka("div")`
231 position: absolute;
232 `,KG=ka("div")`
233 position: relative;
234 display: flex;
235 justify-content: center;
236 align-items: center;
237 min-width: 20px;
238 min-height: 20px;
239 `,YG=Zo`
240 from {
241 transform: scale(0.6);
242 opacity: 0.4;
243 }
244 to {
245 transform: scale(1);
246 opacity: 1;
247 }`,XG=ka("div")`
248 position: relative;
249 transform: scale(0.6);
250 opacity: 0.4;
251 min-width: 20px;
252 animation: ${YG} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
253 forwards;
254 `,QG=({toast:n})=>{let{icon:e,type:t,iconTheme:r}=n;return e!==void 0?typeof e=="string"?T.createElement(XG,null,e):e:t==="blank"?null:T.createElement(KG,null,T.createElement(qG,{...r}),t!=="loading"&&T.createElement(WG,null,t==="error"?T.createElement($G,{...r}):T.createElement(VG,{...r})))},JG=n=>`
255 0% {transform: translate3d(0,${n*-200}%,0) scale(.6); opacity:.5;}
256 100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
257 `,ZG=n=>`
258 0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
259 100% {transform: translate3d(0,${n*-150}%,-1px) scale(.6); opacity:0;}
260 `,eV="0%{opacity:0;} 100%{opacity:1;}",tV="0%{opacity:1;} 100%{opacity:0;}",nV=ka("div")`
261 display: flex;
262 align-items: center;
263 background: #fff;
264 color: #363636;
265 line-height: 1.3;
266 will-change: transform;
267 box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05);
268 max-width: 350px;
269 pointer-events: auto;
270 padding: 8px 10px;
271 border-radius: 8px;
272 `,rV=ka("div")`
273 display: flex;
274 justify-content: center;
275 margin: 4px 10px;
276 color: inherit;
277 flex: 1 1 auto;
278 white-space: pre-line;
279 `,sV=(n,e)=>{let t=n.includes("top")?1:-1,[r,s]=zM()?[eV,tV]:[JG(t),ZG(t)];return{animation:e?`${Zo(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${Zo(s)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},iV=T.memo(({toast:n,position:e,style:t,children:r})=>{let s=n.height?sV(n.position||e||"top-center",n.visible):{opacity:0},i=T.createElement(QG,{toast:n}),o=T.createElement(rV,{...n.ariaProps},ap(n.message,n));return T.createElement(nV,{className:n.className,style:{...s,...t,...n.style}},typeof r=="function"?r({icon:i,message:o}):T.createElement(T.Fragment,null,i,o))});CG(T.createElement);var oV=({id:n,className:e,style:t,onHeightUpdate:r,children:s})=>{let i=T.useCallback(o=>{if(o){let a=()=>{let l=o.getBoundingClientRect().height;r(n,l)};a(),new MutationObserver(a).observe(o,{subtree:!0,childList:!0,characterData:!0})}},[n,r]);return T.createElement("div",{ref:i,className:e,style:t},s)},aV=(n,e)=>{let t=n.includes("top"),r=t?{top:0}:{bottom:0},s=n.includes("center")?{justifyContent:"center"}:n.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:zM()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${e*(t?1:-1)}px)`,...r,...s}},lV=op`
280 z-index: 9999;
281 > * {
282 pointer-events: auto;
283 }
284 `,dp=16,cV=({reverseOrder:n,position:e="top-center",toastOptions:t,gutter:r,children:s,containerStyle:i,containerClassName:o})=>{let{toasts:a,handlers:l}=jG(t);return T.createElement("div",{style:{position:"fixed",zIndex:9999,top:dp,left:dp,right:dp,bottom:dp,pointerEvents:"none",...i},className:o,onMouseEnter:l.startPause,onMouseLeave:l.endPause},a.map(c=>{let d=c.position||e,f=l.calculateOffset(c,{reverseOrder:n,gutter:r,defaultPosition:e}),p=aV(d,f);return T.createElement(oV,{id:c.id,key:c.id,onHeightUpdate:l.updateHeight,className:c.visible?lV:"",style:p},c.type==="custom"?ap(c.message,c):s?s(c):T.createElement(iV,{toast:c,position:d}))}))};const uV={duration:O.string,snackbarClassName:O.string,containerClassName:O.string,position:O.oneOf(["bottom-left","bottom-center","bottom-right","top-left","top-center","top-right"])},Ab=({duration:n=4e3,snackbarClassName:e,containerClassName:t,position:r="top-left"})=>{const{subEvent:s,offEvent:i}=Mt.useEmitter(),o=T.useCallback(({id:d,type:f,text:p,title:m,showProgressBar:g=!1,action:v={type:"icon",label:"bi-close",onClick:y=>_s.dismiss(y)}})=>{let y="";switch(f){case"success":y="bi-tick-circle-fill";break;case"warning":y="bi-warning-fill";break;case"error":y="bi-close-circle-fill";break;case"info":y="bi-info-fill"}return _.jsxs("div",{className:jt("bs-snackbar",`bs-snackbar--${f}`),children:[g&&_.jsx("div",{className:"bs-snackbar__progress",children:_.jsx("div",{className:"bs-snackbar__progress-inner",style:{animationDuration:`${n}ms`}})}),_.jsx("i",{className:jt("bs-snackbar__icon",y)}),_.jsxs("div",{children:[m&&_.jsx("span",{className:"bs-snackbar__title",children:m}),_.jsx("span",{className:"bs-snackbar__text",children:p})]}),_.jsxs("button",{className:"bs-snackbar__action",onClick:()=>v.onClick(d),children:[v.type==="icon"&&_.jsx("i",{className:v.label}),v.type==="text"&&_.jsx("span",{children:v.label})]})]})},[n]),a=T.useCallback(()=>{const d=document.querySelector(".bs-snackbar-container");d&&(d.style.zIndex=de.popupManager.getNewZIndex().toString())},[]),l=T.useCallback(d=>{if(a(),d.type==="custom"&&d.customComponentCallback){const f=d.customComponentCallback;_s.custom(p=>f(p),{duration:d==null?void 0:d.duration,position:d==null?void 0:d.position})}else _s(({id:f})=>o({id:f,...d}))},[o,a]),c=T.useCallback(d=>{_s.dismiss(d.id)},[]);return T.useEffect(()=>(s("bs-snackbar-show",l,{autoOff:!1}),s("bs-snackbar-hide",c,{autoOff:!1}),()=>{i("bs-snackbar-show",l),i("bs-snackbar-hide",c)}),[l,c]),_.jsx(cV,{position:r,containerClassName:jt("bs-snackbar-container",t),toastOptions:{duration:n,className:jt("bs-snackbar-wrapper",e)}})};Ab.propTypes=uV,Ab.displayName="BsSnackbar",O.number,O.number,O.bool,O.number,O.func,O.bool,O.bool,O.bool,O.func,O.func,O.func,O.func,O.string,O.bool,O.number,O.string,O.string,O.string,O.number,O.bool,O.bool,O.bool,O.oneOfType([O.number,O.string]),O.oneOf(["32","36","40","44","48","52","56"]),O.node,O.number,O.string,O.string,O.string;const dV=O.oneOfType([O.string,O.number]),fV=O.shape({icon:O.string,hasDot:O.bool,count:O.number,value:dV.isRequired,title:O.oneOfType([O.string,O.number,O.node]).isRequired});O.func,O.bool,O.string,O.arrayOf(fV).isRequired,O.oneOf(["primary","success","danger"]),O.oneOf(["p","h1","h2","h3","h4","h5","h6","em","span","strong"]),O.string,O.oneOf(["bold","medium","regular"]),O.node.isRequired,O.oneOf(["body-lg","body-sm","heading-1","heading-2","heading-3","heading-4","caption-lg","caption-sm","subtitle-lg","subtitle-sm"]).isRequired,O.oneOfType([O.oneOf(["10","12","14","16","18","22"]),O.number]);const hV={onBlur:O.func,value:O.string,checked:O.bool,disabled:O.bool,onChange:O.func,children:O.node,className:O.string,labelClass:O.string,defaultChecked:O.bool,toggleClassName:O.string,label:O.oneOfType([O.string,O.number])},HM=T.forwardRef(({name:n,label:e,value:t,onBlur:r,checked:s,disabled:i,onChange:o,children:a,className:l,labelClass:c,defaultChecked:d},f)=>{const p=T.useId(),m=Mt.useFallbackRef(f);return T.useEffect(()=>{d&&s===void 0&&m.current&&(m.current.checked=!0)},[]),_.jsxs("label",{htmlFor:p,className:jt(l,"bs-toggle","bs-toggle--"+(i?"disabled":"enabled")),children:[_.jsx("input",{id:p,ref:m,name:n,value:t,type:"checkbox",checked:s,disabled:i,className:"bs-toggle__input",onBlur:r,onChange:o}),_.jsx("div",{className:"bs-toggle__el",children:_.jsx("span",{className:"bs-toggle__el-circle"})}),e&&_.jsx("span",{className:jt(c,"bs-toggle-label"),children:e}),a]})});HM.propTypes=hV,HM.displayName="BsToggle",O.bool,O.func,O.func,O.object,O.bool,O.bool,O.string,O.arrayOf(O.shape({title:O.string,placement:O.string,disableBeacon:O.bool,content:O.node.isRequired,target:O.string.isRequired})).isRequired;const fp=0,La=1,Mc=2,GM=4;function qd(n,e){return t=>n(e(t))}function pV(n,e){return e(n)}function VM(n,e){return t=>n(e,t)}function WM(n,e){return()=>n(e)}function hp(n,e){return e(n),n}function er(...n){return n}function mV(n){n()}function KM(n){return()=>n}function gV(...n){return()=>{n.map(mV)}}function kb(n){return n!==void 0}function Al(){}function Pn(n,e){return n(La,e)}function un(n,e){n(fp,e)}function Lb(n){n(Mc)}function vs(n){return n(GM)}function Nt(n,e){return Pn(n,VM(e,fp))}function So(n,e){const t=n(La,r=>{t(),e(r)});return t}function bn(){const n=[];return(e,t)=>{switch(e){case Mc:n.splice(0,n.length);return;case La:return n.push(t),()=>{const r=n.indexOf(t);r>-1&&n.splice(r,1)};case fp:n.slice().forEach(r=>{r(t)});return;default:throw new Error(`unrecognized action ${e}`)}}}function st(n){let e=n;const t=bn();return(r,s)=>{switch(r){case La:s(e);break;case fp:e=s;break;case GM:return e}return t(r,s)}}function _V(n){let e,t;const r=()=>e&&e();return function(s,i){switch(s){case La:return i?t===i?void 0:(r(),t=i,e=Pn(n,i),e):(r(),Al);case Mc:r(),t=null;return;default:throw new Error(`unrecognized action ${s}`)}}}function ii(n){return hp(bn(),e=>Nt(n,e))}function ys(n,e){return hp(st(e),t=>Nt(n,t))}function vV(...n){return e=>n.reduceRight(pV,e)}function Ye(n,...e){const t=vV(...e);return(r,s)=>{switch(r){case La:return Pn(n,t(s));case Mc:Lb(n);return}}}function YM(n,e){return n===e}function tr(n=YM){let e;return t=>r=>{n(e,r)||(e=r,t(r))}}function Zt(n){return e=>t=>{n(t)&&e(t)}}function wt(n){return e=>qd(e,n)}function Eo(n){return e=>()=>e(n)}function wo(n,e){return t=>r=>t(e=n(e,r))}function Nc(n){return e=>t=>{n>0?n--:e(t)}}function Ma(n){let e=null,t;return r=>s=>{e=s,!t&&(t=setTimeout(()=>{t=void 0,r(e)},n))}}function XM(n){let e,t;return r=>s=>{e=s,t&&clearTimeout(t),t=setTimeout(()=>{r(e)},n)}}function fn(...n){const e=new Array(n.length);let t=0,r=null;const s=Math.pow(2,n.length)-1;return n.forEach((i,o)=>{const a=Math.pow(2,o);Pn(i,l=>{const c=t;t=t|a,e[o]=l,c!==s&&t===s&&r&&(r(),r=null)})}),i=>o=>{const a=()=>i([o].concat(e));t===s?a():r=a}}function QM(...n){return function(e,t){switch(e){case La:return gV(...n.map(r=>Pn(r,t)));case Mc:return;default:throw new Error(`unrecognized action ${e}`)}}}function en(n,e=YM){return Ye(n,tr(e))}function Vr(...n){const e=bn(),t=new Array(n.length);let r=0;const s=Math.pow(2,n.length)-1;return n.forEach((i,o)=>{const a=Math.pow(2,o);Pn(i,l=>{t[o]=l,r=r|a,r===s&&un(e,t)})}),function(i,o){switch(i){case La:return r===s&&o(t),Pn(e,o);case Mc:return Lb(e);default:throw new Error(`unrecognized action ${i}`)}}}function An(n,e=[],{singleton:t}={singleton:!0}){return{id:yV(),constructor:n,dependencies:e,singleton:t}}const yV=()=>Symbol();function bV(n){const e=new Map,t=({id:r,constructor:s,dependencies:i,singleton:o})=>{if(o&&e.has(r))return e.get(r);const a=s(i.map(l=>t(l)));return o&&e.set(r,a),a};return t(n)}function xV(n,e){const t={},r={};let s=0;const i=n.length;for(;s<i;)r[n[s]]=1,s+=1;for(const o in e)r.hasOwnProperty(o)||(t[o]=e[o]);return t}const pp=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Mb(n,e,t){const r=Object.keys(e.required||{}),s=Object.keys(e.optional||{}),i=Object.keys(e.methods||{}),o=Object.keys(e.events||{}),a=Ne.createContext({});function l(b,S){b.propsReady&&un(b.propsReady,!1);for(const E of r){const C=b[e.required[E]];un(C,S[E])}for(const E of s)if(E in S){const C=b[e.optional[E]];un(C,S[E])}b.propsReady&&un(b.propsReady,!0)}function c(b){return i.reduce((S,E)=>(S[E]=C=>{const R=b[e.methods[E]];un(R,C)},S),{})}function d(b){return o.reduce((S,E)=>(S[E]=_V(b[e.events[E]]),S),{})}const f=Ne.forwardRef((b,S)=>{const{children:E,...C}=b,[R]=Ne.useState(()=>hp(bV(n),k=>l(k,C))),[I]=Ne.useState(WM(d,R));pp(()=>{for(const k of o)k in C&&Pn(I[k],C[k]);return()=>{Object.values(I).map(Lb)}},[C,I,R]),pp(()=>{l(R,C)}),Ne.useImperativeHandle(S,KM(c(R)));const A=t;return _.jsx(a.Provider,{value:R,children:t?_.jsx(A,{...xV([...r,...s,...o],C),children:E}):E})}),p=b=>Ne.useCallback(VM(un,Ne.useContext(a)[b]),[b]),m=b=>{const E=Ne.useContext(a)[b],C=Ne.useCallback(R=>Pn(E,R),[E]);return Ne.useSyncExternalStore(C,()=>vs(E),()=>vs(E))},g=b=>{const E=Ne.useContext(a)[b],[C,R]=Ne.useState(WM(vs,E));return pp(()=>Pn(E,I=>{I!==C&&R(KM(I))}),[E,C]),C},v=Ne.version.startsWith("18")?m:g;return{Component:f,usePublisher:p,useEmitterValue:v,useEmitter:(b,S)=>{const C=Ne.useContext(a)[b];pp(()=>Pn(C,S),[S,C])}}}const JM=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;var qs=(n=>(n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR",n))(qs||{});const SV={0:"debug",1:"log",2:"warn",3:"error"},EV=()=>typeof globalThis>"u"?window:globalThis,Na=An(()=>{const n=st(3);return{log:st((t,r,s=1)=>{var i;const o=(i=EV().VIRTUOSO_LOG_LEVEL)!=null?i:vs(n);s>=o&&console[SV[s]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:n}},[],{singleton:!0});function Nb(n,e,t){const r=Ne.useRef(null);let s=i=>{};if(typeof ResizeObserver<"u"){const i=Ne.useMemo(()=>new ResizeObserver(o=>{const a=()=>{const l=o[0].target;l.offsetParent!==null&&n(l)};t?a():requestAnimationFrame(a)}),[n]);s=o=>{o&&e?(i.observe(o),r.current=o):(r.current&&i.unobserve(r.current),r.current=null)}}return{ref:r,callbackRef:s}}function To(n,e,t){return Nb(n,e,t).callbackRef}function ZM(n,e,t,r,s,i,o,a,l){const c=Ne.useCallback(d=>{const f=wV(d.children,e,a?"offsetWidth":"offsetHeight",s);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const m=p.lastElementChild.dataset.viewportType==="window",g=o?a?o.scrollLeft:o.scrollTop:m?a?window.pageXOffset||document.documentElement.scrollLeft:window.pageYOffset||document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,v=o?a?o.scrollWidth:o.scrollHeight:m?a?document.documentElement.scrollWidth:document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,y=o?a?o.offsetWidth:o.offsetHeight:m?a?window.innerWidth:window.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollTop:Math.max(g,0),scrollHeight:v,viewportHeight:y}),i==null||i(a?eN("column-gap",getComputedStyle(d).columnGap,s):eN("row-gap",getComputedStyle(d).rowGap,s)),f!==null&&n(f)},[n,e,s,i,o,r]);return Nb(c,t,l)}function wV(n,e,t,r){const s=n.length;if(s===0)return null;const i=[];for(let o=0;o<s;o++){const a=n.item(o);if(!a||a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=e(a,t);if(d===0&&r("Zero-sized element, this should not happen",{child:a},qs.ERROR),d===c)continue;const f=i[i.length-1];i.length===0||f.size!==d||f.endIndex!==l-1?i.push({startIndex:l,endIndex:l,size:d}):i[i.length-1].endIndex++}return i}function eN(n,e,t){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&t(`${n} was not resolved to pixel value correctly`,e,qs.WARN),e==="normal"?0:parseInt(e??"0",10)}function Xi(n,e){return Math.round(n.getBoundingClientRect()[e])}function tN(n,e){return Math.abs(n-e)<1.01}function nN(n,e,t,r=Al,s,i){const o=Ne.useRef(null),a=Ne.useRef(null),l=Ne.useRef(null),c=Ne.useCallback(p=>{const m=p.target,g=m===window||m===document,v=i?g?window.pageXOffset||document.documentElement.scrollLeft:m.scrollLeft:g?window.pageYOffset||document.documentElement.scrollTop:m.scrollTop,y=i?g?document.documentElement.scrollWidth:m.scrollWidth:g?document.documentElement.scrollHeight:m.scrollHeight,b=i?g?window.innerWidth:m.offsetWidth:g?window.innerHeight:m.offsetHeight,S=()=>{n({scrollTop:Math.max(v,0),scrollHeight:y,viewportHeight:b})};p.suppressFlushSync?S():ML.flushSync(S),a.current!==null&&(v===a.current||v<=0||v===y-b)&&(a.current=null,e(!0),l.current&&(clearTimeout(l.current),l.current=null))},[n,e]);Ne.useEffect(()=>{const p=s||o.current;return r(s||o.current),c({target:p,suppressFlushSync:!0}),p.addEventListener("scroll",c,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",c)}},[o,c,t,r,s]);function d(p){const m=o.current;if(!m||(i?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const g=p.behavior==="smooth";let v,y,b;m===window?(y=Math.max(Xi(document.documentElement,i?"width":"height"),i?document.documentElement.scrollWidth:document.documentElement.scrollHeight),v=i?window.innerWidth:window.innerHeight,b=i?document.documentElement.scrollLeft:document.documentElement.scrollTop):(y=m[i?"scrollWidth":"scrollHeight"],v=Xi(m,i?"width":"height"),b=m[i?"scrollLeft":"scrollTop"]);const S=y-v;if(p.top=Math.ceil(Math.max(Math.min(S,p.top),0)),tN(v,y)||p.top===b){n({scrollTop:b,scrollHeight:y,viewportHeight:v}),g&&e(!0);return}g?(a.current=p.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,e(!0)},1e3)):a.current=null,i&&(p={left:p.top,behavior:p.behavior}),m.scrollTo(p)}function f(p){i&&(p={left:p.top,behavior:p.behavior}),o.current.scrollBy(p)}return{scrollerRef:o,scrollByCallback:f,scrollToCallback:d}}const Ls=An(()=>{const n=bn(),e=bn(),t=st(0),r=bn(),s=st(0),i=bn(),o=bn(),a=st(0),l=st(0),c=st(0),d=st(0),f=bn(),p=bn(),m=st(!1),g=st(!1),v=st(!1);return Nt(Ye(n,wt(({scrollTop:y})=>y)),e),Nt(Ye(n,wt(({scrollHeight:y})=>y)),o),Nt(e,s),{scrollContainerState:n,scrollTop:e,viewportHeight:i,headerHeight:a,fixedHeaderHeight:l,fixedFooterHeight:c,footerHeight:d,scrollHeight:o,smoothScrollTargetReached:r,horizontalDirection:g,skipAnimationFrameInResizeObserver:v,scrollTo:f,scrollBy:p,statefulScrollTop:s,deviation:t,scrollingInProgress:m}},[],{singleton:!0}),Hd={lvl:0};function rN(n,e,t,r=Hd,s=Hd){return{k:n,v:e,lvl:t,l:r,r:s}}function Hn(n){return n===Hd}function Oc(){return Hd}function Ob(n,e){if(Hn(n))return Hd;const{k:t,l:r,r:s}=n;if(e===t){if(Hn(r))return s;if(Hn(s))return r;{const[i,o]=sN(r);return mp(jr(n,{k:i,v:o,l:iN(r)}))}}else return e<t?mp(jr(n,{l:Ob(r,e)})):mp(jr(n,{r:Ob(s,e)}))}function Gd(n,e){if(!Hn(n))return e===n.k?n.v:e<n.k?Gd(n.l,e):Gd(n.r,e)}function Qi(n,e,t="k"){if(Hn(n))return[-1/0,void 0];if(Number(n[t])===e)return[n.k,n.v];if(Number(n[t])<e){const r=Qi(n.r,e,t);return r[0]===-1/0?[n.k,n.v]:r}return Qi(n.l,e,t)}function oi(n,e,t){return Hn(n)?rN(e,t,1):e===n.k?jr(n,{k:e,v:t}):e<n.k?oN(jr(n,{l:oi(n.l,e,t)})):oN(jr(n,{r:oi(n.r,e,t)}))}function Pb(n,e,t){if(Hn(n))return[];const{k:r,v:s,l:i,r:o}=n;let a=[];return r>e&&(a=a.concat(Pb(i,e,t))),r>=e&&r<=t&&a.push({k:r,v:s}),r<=t&&(a=a.concat(Pb(o,e,t))),a}function kl(n){return Hn(n)?[]:[...kl(n.l),{k:n.k,v:n.v},...kl(n.r)]}function sN(n){return Hn(n.r)?[n.k,n.v]:sN(n.r)}function iN(n){return Hn(n.r)?n.l:mp(jr(n,{r:iN(n.r)}))}function jr(n,e){return rN(e.k!==void 0?e.k:n.k,e.v!==void 0?e.v:n.v,e.lvl!==void 0?e.lvl:n.lvl,e.l!==void 0?e.l:n.l,e.r!==void 0?e.r:n.r)}function Db(n){return Hn(n)||n.lvl>n.r.lvl}function oN(n){return jb(lN(n))}function mp(n){const{l:e,r:t,lvl:r}=n;if(t.lvl>=r-1&&e.lvl>=r-1)return n;if(r>t.lvl+1){if(Db(e))return lN(jr(n,{lvl:r-1}));if(!Hn(e)&&!Hn(e.r))return jr(e.r,{l:jr(e,{r:e.r.l}),r:jr(n,{l:e.r.r,lvl:r-1}),lvl:r});throw new Error("Unexpected empty nodes")}else{if(Db(n))return jb(jr(n,{lvl:r-1}));if(!Hn(t)&&!Hn(t.l)){const s=t.l,i=Db(s)?t.lvl-1:t.lvl;return jr(s,{l:jr(n,{r:s.l,lvl:r-1}),r:jb(jr(t,{l:s.r,lvl:i})),lvl:s.lvl+1})}else throw new Error("Unexpected empty nodes")}}function gp(n,e,t){if(Hn(n))return[];const r=Qi(n,e)[0];return TV(Pb(n,r,t))}function aN(n,e){const t=n.length;if(t===0)return[];let{index:r,value:s}=e(n[0]);const i=[];for(let o=1;o<t;o++){const{index:a,value:l}=e(n[o]);i.push({start:r,end:a-1,value:s}),r=a,s=l}return i.push({start:r,end:1/0,value:s}),i}function TV(n){return aN(n,({k:e,v:t})=>({index:e,value:t}))}function jb(n){const{r:e,lvl:t}=n;return!Hn(e)&&!Hn(e.r)&&e.lvl===t&&e.r.lvl===t?jr(e,{l:jr(n,{r:e.l}),lvl:t+1}):n}function lN(n){const{l:e}=n;return!Hn(e)&&e.lvl===n.lvl?jr(e,{r:jr(n,{l:e.r})}):n}function _p(n,e,t,r=0){let s=n.length-1;for(;r<=s;){const i=Math.floor((r+s)/2),o=n[i],a=t(o,e);if(a===0)return i;if(a===-1){if(s-r<2)return i-1;s=i-1}else{if(s===r)return i;r=i+1}}throw new Error(`Failed binary finding record in array - ${n.join(",")}, searched for ${e}`)}function cN(n,e,t){return n[_p(n,e,t)]}function CV(n,e,t,r){const s=_p(n,e,r),i=_p(n,t,r,s);return n.slice(s,i+1)}const Fb=An(()=>({recalcInProgress:st(!1)}),[],{singleton:!0});function IV(n){const{size:e,startIndex:t,endIndex:r}=n;return s=>s.start===t&&(s.end===r||s.end===1/0)&&s.value===e}function uN(n,e){let t=0,r=0;for(;t<n;)t+=e[r+1]-e[r]-1,r++;return r-(t===n?0:1)}function RV(n,e){let t=Hn(n)?0:1/0;for(const r of e){const{size:s,startIndex:i,endIndex:o}=r;if(t=Math.min(t,i),Hn(n)){n=oi(n,0,s);continue}const a=gp(n,i-1,o+1);if(a.some(IV(r)))continue;let l=!1,c=!1;for(const{start:d,end:f,value:p}of a)l?(o>=d||s===p)&&(n=Ob(n,d)):(c=p!==s,l=!0),f>o&&o>=d&&p!==s&&(n=oi(n,o+1,p));c&&(n=oi(n,i,s))}return[n,t]}function AV(){return{offsetTree:[],sizeTree:Oc(),groupOffsetTree:Oc(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]}}function Ub({index:n},e){return e===n?0:e<n?-1:1}function kV({offset:n},e){return e===n?0:e<n?-1:1}function LV(n){return{index:n.index,value:n}}function MV(n,e,t,r=0){return r>0&&(e=Math.max(e,cN(n,r,Ub).offset)),aN(CV(n,e,t,kV),LV)}function Bb(n,e,t,r){let s=n,i=0,o=0,a=0,l=0;if(e!==0){l=_p(s,e-1,Ub),a=s[l].offset;const d=Qi(t,e-1);i=d[0],o=d[1],s.length&&s[l].size===Qi(t,e)[1]&&(l-=1),s=s.slice(0,l+1)}else s=[];for(const{start:c,value:d}of gp(t,e,1/0)){const f=c-i,p=f*o+a+f*r;s.push({offset:p,size:d,index:c}),i=c,a=p,o=d}return{offsetTree:s,lastIndex:i,lastOffset:a,lastSize:o}}function NV(n,[e,t,r,s]){e.length>0&&r("received item sizes",e,qs.DEBUG);const i=n.sizeTree;let o=i,a=0;if(t.length>0&&Hn(i)&&e.length===2){const p=e[0].size,m=e[1].size;o=t.reduce((g,v)=>oi(oi(g,v,p),v+1,m),o)}else[o,a]=RV(o,e);if(o===i)return n;const{offsetTree:l,lastIndex:c,lastSize:d,lastOffset:f}=Bb(n.offsetTree,a,o,s);return{sizeTree:o,offsetTree:l,lastIndex:c,lastOffset:f,lastSize:d,groupOffsetTree:t.reduce((p,m)=>oi(p,m,Vd(m,l,s)),Oc()),groupIndices:t}}function Vd(n,e,t){if(e.length===0)return 0;const{offset:r,index:s,size:i}=cN(e,n,Ub),o=n-s,a=i*o+(o-1)*t+r;return a>0?a+t:a}function OV(n){return typeof n.groupIndex<"u"}function dN(n,e,t){if(OV(n))return e.groupIndices[n.groupIndex]+1;{const r=n.index==="LAST"?t:n.index;let s=fN(r,e);return s=Math.max(0,s,Math.min(t,s)),s}}function fN(n,e){if(!vp(e))return n;let t=0;for(;e.groupIndices[t]<=n+t;)t++;return n+t}function vp(n){return!Hn(n.groupOffsetTree)}function PV(n){return kl(n).map(({k:e,v:t},r,s)=>{const i=s[r+1],o=i?i.k-1:1/0;return{startIndex:e,endIndex:o,size:t}})}const DV={offsetHeight:"height",offsetWidth:"width"},Co=An(([{log:n},{recalcInProgress:e}])=>{const t=bn(),r=bn(),s=ys(r,0),i=bn(),o=bn(),a=st(0),l=st([]),c=st(void 0),d=st(void 0),f=st((R,I)=>Xi(R,DV[I])),p=st(void 0),m=st(0),g=AV(),v=ys(Ye(t,fn(l,n,m),wo(NV,g),tr()),g),y=ys(Ye(l,tr(),wo((R,I)=>({prev:R.current,current:I}),{prev:[],current:[]}),wt(({prev:R})=>R)),[]);Nt(Ye(l,Zt(R=>R.length>0),fn(v,m),wt(([R,I,A])=>{const k=R.reduce((N,D,M)=>oi(N,D,Vd(D,I.offsetTree,A)||M),Oc());return{...I,groupIndices:R,groupOffsetTree:k}})),v),Nt(Ye(r,fn(v),Zt(([R,{lastIndex:I}])=>R<I),wt(([R,{lastIndex:I,lastSize:A}])=>[{startIndex:R,endIndex:I,size:A}])),t),Nt(c,d);const b=ys(Ye(c,wt(R=>R===void 0)),!0);Nt(Ye(d,Zt(R=>R!==void 0&&Hn(vs(v).sizeTree)),wt(R=>[{startIndex:0,endIndex:0,size:R}])),t);const S=ii(Ye(t,fn(v),wo(({sizes:R},[I,A])=>({changed:A!==R,sizes:A}),{changed:!1,sizes:g}),wt(R=>R.changed)));Pn(Ye(a,wo((R,I)=>({diff:R.prev-I,prev:I}),{diff:0,prev:0}),wt(R=>R.diff)),R=>{const{groupIndices:I}=vs(v);if(R>0)un(e,!0),un(i,R+uN(R,I));else if(R<0){const A=vs(y);A.length>0&&(R-=uN(-R,A)),un(o,R)}}),Pn(Ye(a,fn(n)),([R,I])=>{R<0&&I("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},qs.ERROR)});const E=ii(i);Nt(Ye(i,fn(v),wt(([R,I])=>{const A=I.groupIndices.length>0,k=[],N=I.lastSize;if(A){const D=Gd(I.sizeTree,0);let M=0,F=0;for(;M<R;){const q=I.groupIndices[F],G=I.groupIndices.length===F+1?1/0:I.groupIndices[F+1]-q-1;k.push({startIndex:q,endIndex:q,size:D}),k.push({startIndex:q+1,endIndex:q+1+G-1,size:N}),F++,M+=G+1}const U=kl(I.sizeTree);return M!==R&&U.shift(),U.reduce((q,{k:G,v:V})=>{let z=q.ranges;return q.prevSize!==0&&(z=[...q.ranges,{startIndex:q.prevIndex,endIndex:G+R-1,size:q.prevSize}]),{ranges:z,prevIndex:G+R,prevSize:V}},{ranges:k,prevIndex:R,prevSize:0}).ranges}return kl(I.sizeTree).reduce((D,{k:M,v:F})=>({ranges:[...D.ranges,{startIndex:D.prevIndex,endIndex:M+R-1,size:D.prevSize}],prevIndex:M+R,prevSize:F}),{ranges:[],prevIndex:0,prevSize:N}).ranges})),t);const C=ii(Ye(o,fn(v,m),wt(([R,{offsetTree:I},A])=>{const k=-R;return Vd(k,I,A)})));return Nt(Ye(o,fn(v,m),wt(([R,I,A])=>{if(I.groupIndices.length>0){if(Hn(I.sizeTree))return I;let N=Oc();const D=vs(y);let M=0,F=0,U=0;for(;M<-R;){U=D[F];const q=D[F+1]-U-1;F++,M+=q+1}if(N=kl(I.sizeTree).reduce((q,{k:G,v:V})=>oi(q,Math.max(0,G+R),V),N),M!==-R){const q=Gd(I.sizeTree,U);N=oi(N,0,q);const G=Qi(I.sizeTree,-R+1)[1];N=oi(N,1,G)}return{...I,sizeTree:N,...Bb(I.offsetTree,0,N,A)}}else{const N=kl(I.sizeTree).reduce((D,{k:M,v:F})=>oi(D,Math.max(0,M+R),F),Oc());return{...I,sizeTree:N,...Bb(I.offsetTree,0,N,A)}}})),v),{data:p,totalCount:r,sizeRanges:t,groupIndices:l,defaultItemSize:d,fixedItemSize:c,unshiftWith:i,shiftWith:o,shiftWithOffset:C,beforeUnshiftWith:E,firstItemIndex:a,gap:m,sizes:v,listRefresh:S,statefulTotalCount:s,trackItemSizes:b,itemSize:f}},er(Na,Fb),{singleton:!0}),jV=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function hN(n){const e=typeof n=="number"?{index:n}:n;return e.align||(e.align="start"),(!e.behavior||!jV)&&(e.behavior="auto"),e.offset||(e.offset=0),e}const Wd=An(([{sizes:n,totalCount:e,listRefresh:t,gap:r},{scrollingInProgress:s,viewportHeight:i,scrollTo:o,smoothScrollTargetReached:a,headerHeight:l,footerHeight:c,fixedHeaderHeight:d,fixedFooterHeight:f},{log:p}])=>{const m=bn(),g=bn(),v=st(0);let y=null,b=null,S=null;function E(){y&&(y(),y=null),S&&(S(),S=null),b&&(clearTimeout(b),b=null),un(s,!1)}return Nt(Ye(m,fn(n,i,e,v,l,c,p),fn(r,d,f),wt(([[C,R,I,A,k,N,D,M],F,U,$])=>{const q=hN(C),{align:G,behavior:V,offset:z}=q,B=A-1,P=dN(q,R,B);let H=Vd(P,R.offsetTree,F)+N;G==="end"?(H+=U+Qi(R.sizeTree,P)[1]-I+$,P===B&&(H+=D)):G==="center"?H+=(U+Qi(R.sizeTree,P)[1]-I+$)/2:H-=k,z&&(H+=z);const Z=Q=>{E(),Q?(M("retrying to scroll to",{location:C},qs.DEBUG),un(m,C)):(un(g,!0),M("list did not change, scroll successful",{},qs.DEBUG))};if(E(),V==="smooth"){let Q=!1;S=Pn(t,J=>{Q=Q||J}),y=So(a,()=>{Z(Q)})}else y=So(Ye(t,FV(150)),Z);return b=setTimeout(()=>{E()},1200),un(s,!0),M("scrolling from index to",{index:P,top:H,behavior:V},qs.DEBUG),{top:H,behavior:V}})),o),{scrollToIndex:m,scrollTargetReached:g,topListHeight:v}},er(Co,Ls,Na),{singleton:!0});function FV(n){return e=>{const t=setTimeout(()=>{e(!1)},n);return r=>{r&&(e(!0),clearTimeout(t))}}}const Kd="up",Yd="down",UV="none",BV={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollTop:0,viewportHeight:0,scrollHeight:0}},$V=0,Xd=An(([{scrollContainerState:n,scrollTop:e,viewportHeight:t,headerHeight:r,footerHeight:s,scrollBy:i}])=>{const o=st(!1),a=st(!0),l=bn(),c=bn(),d=st(4),f=st($V),p=ys(Ye(QM(Ye(en(e),Nc(1),Eo(!0)),Ye(en(e),Nc(1),Eo(!1),XM(100))),tr()),!1),m=ys(Ye(QM(Ye(i,Eo(!0)),Ye(i,Eo(!1),XM(200))),tr()),!1);Nt(Ye(Vr(en(e),en(f)),wt(([S,E])=>S<=E),tr()),a),Nt(Ye(a,Ma(50)),c);const g=ii(Ye(Vr(n,en(t),en(r),en(s),en(d)),wo((S,[{scrollTop:E,scrollHeight:C},R,I,A,k])=>{const N=E+R-C>-k,D={viewportHeight:R,scrollTop:E,scrollHeight:C};if(N){let F,U;return E>S.state.scrollTop?(F="SCROLLED_DOWN",U=S.state.scrollTop-E):(F="SIZE_DECREASED",U=S.state.scrollTop-E||S.scrollTopDelta),{atBottom:!0,state:D,atBottomBecause:F,scrollTopDelta:U}}let M;return D.scrollHeight>S.state.scrollHeight?M="SIZE_INCREASED":R<S.state.viewportHeight?M="VIEWPORT_HEIGHT_DECREASING":E<S.state.scrollTop?M="SCROLLING_UPWARDS":M="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:M,state:D}},BV),tr((S,E)=>S&&S.atBottom===E.atBottom))),v=ys(Ye(n,wo((S,{scrollTop:E,scrollHeight:C,viewportHeight:R})=>{if(tN(S.scrollHeight,C))return{scrollTop:E,scrollHeight:C,jump:0,changed:!1};{const I=C-(E+R)<1;return S.scrollTop!==E&&I?{scrollHeight:C,scrollTop:E,jump:S.scrollTop-E,changed:!0}:{scrollHeight:C,scrollTop:E,jump:0,changed:!0}}},{scrollHeight:0,jump:0,scrollTop:0,changed:!1}),Zt(S=>S.changed),wt(S=>S.jump)),0);Nt(Ye(g,wt(S=>S.atBottom)),o),Nt(Ye(o,Ma(50)),l);const y=st(Yd);Nt(Ye(n,wt(({scrollTop:S})=>S),tr(),wo((S,E)=>vs(m)?{direction:S.direction,prevScrollTop:E}:{direction:E<S.prevScrollTop?Kd:Yd,prevScrollTop:E},{direction:Yd,prevScrollTop:0}),wt(S=>S.direction)),y),Nt(Ye(n,Ma(50),Eo(UV)),y);const b=st(0);return Nt(Ye(p,Zt(S=>!S),Eo(0)),b),Nt(Ye(e,Ma(100),fn(p),Zt(([S,E])=>!!E),wo(([S,E],[C])=>[E,C],[0,0]),wt(([S,E])=>E-S)),b),{isScrolling:p,isAtTop:a,isAtBottom:o,atBottomState:g,atTopStateChange:c,atBottomStateChange:l,scrollDirection:y,atBottomThreshold:d,atTopThreshold:f,scrollVelocity:b,lastJumpDueToItemResize:v}},er(Ls)),Oa=An(([{log:n}])=>{const e=st(!1),t=ii(Ye(e,Zt(r=>r),tr()));return Pn(e,r=>{r&&vs(n)("props updated",{},qs.DEBUG)}),{propsReady:e,didMount:t}},er(Na),{singleton:!0});function $b(n,e){n==0?e():requestAnimationFrame(()=>$b(n-1,e))}function zb(n,e){const t=e-1;return typeof n=="number"?n:n.index==="LAST"?t:n.index}const Qd=An(([{sizes:n,listRefresh:e,defaultItemSize:t},{scrollTop:r},{scrollToIndex:s,scrollTargetReached:i},{didMount:o}])=>{const a=st(!0),l=st(0),c=st(!0);return Nt(Ye(o,fn(l),Zt(([d,f])=>!!f),Eo(!1)),a),Nt(Ye(o,fn(l),Zt(([d,f])=>!!f),Eo(!1)),c),Pn(Ye(Vr(e,o),fn(a,n,t,c),Zt(([[,d],f,{sizeTree:p},m,g])=>d&&(!Hn(p)||kb(m))&&!f&&!g),fn(l)),([,d])=>{So(i,()=>{un(c,!0)}),$b(4,()=>{So(r,()=>{un(a,!0)}),un(s,d)})}),{scrolledToInitialItem:a,initialTopMostItemIndex:l,initialItemFinalLocationReached:c}},er(Co,Ls,Wd,Oa),{singleton:!0});function pN(n){return n?n==="smooth"?"smooth":"auto":!1}const zV=(n,e)=>typeof n=="function"?pN(n(e)):e&&pN(n),qV=An(([{totalCount:n,listRefresh:e},{isAtBottom:t,atBottomState:r},{scrollToIndex:s},{scrolledToInitialItem:i},{propsReady:o,didMount:a},{log:l},{scrollingInProgress:c}])=>{const d=st(!1),f=bn();let p=null;function m(v){un(s,{index:"LAST",align:"end",behavior:v})}Pn(Ye(Vr(Ye(en(n),Nc(1)),a),fn(en(d),t,i,c),wt(([[v,y],b,S,E,C])=>{let R=y&&E,I="auto";return R&&(I=zV(b,S||C),R=R&&!!I),{totalCount:v,shouldFollow:R,followOutputBehavior:I}}),Zt(({shouldFollow:v})=>v)),({totalCount:v,followOutputBehavior:y})=>{p&&(p(),p=null),p=So(e,()=>{vs(l)("following output to ",{totalCount:v},qs.DEBUG),m(y),p=null})});function g(v){const y=So(r,b=>{v&&!b.atBottom&&b.notAtBottomBecause==="SIZE_INCREASED"&&!p&&(vs(l)("scrolling to bottom due to increased size",{},qs.DEBUG),m("auto"))});setTimeout(y,100)}return Pn(Ye(Vr(en(d),n,o),Zt(([v,,y])=>v&&y),wo(({value:v},[,y])=>({refreshed:v===y,value:y}),{refreshed:!1,value:0}),Zt(({refreshed:v})=>v),fn(d,n)),([,v])=>{vs(i)&&g(v!==!1)}),Pn(f,()=>{g(vs(d)!==!1)}),Pn(Vr(en(d),r),([v,y])=>{v&&!y.atBottom&&y.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&m("auto")}),{followOutput:d,autoscrollToBottom:f}},er(Co,Xd,Wd,Qd,Oa,Na,Ls));function HV(n){return n.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{totalCount:0,groupIndices:[]})}const mN=An(([{totalCount:n,groupIndices:e,sizes:t},{scrollTop:r,headerHeight:s}])=>{const i=bn(),o=bn(),a=ii(Ye(i,wt(HV)));return Nt(Ye(a,wt(l=>l.totalCount)),n),Nt(Ye(a,wt(l=>l.groupIndices)),e),Nt(Ye(Vr(r,t,s),Zt(([l,c])=>vp(c)),wt(([l,c,d])=>Qi(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),tr(),wt(l=>[l])),o),{groupCounts:i,topItemsIndexes:o}},er(Co,Ls));function Jd(n,e){return!!(n&&n[0]===e[0]&&n[1]===e[1])}function gN(n,e){return!!(n&&n.startIndex===e.startIndex&&n.endIndex===e.endIndex)}const yp="top",bp="bottom",_N="none";function vN(n,e,t){return typeof n=="number"?t===Kd&&e===yp||t===Yd&&e===bp?n:0:t===Kd?e===yp?n.main:n.reverse:e===bp?n.main:n.reverse}function yN(n,e){return typeof n=="number"?n:n[e]||0}const qb=An(([{scrollTop:n,viewportHeight:e,deviation:t,headerHeight:r,fixedHeaderHeight:s}])=>{const i=bn(),o=st(0),a=st(0),l=st(0),c=ys(Ye(Vr(en(n),en(e),en(r),en(i,Jd),en(l),en(o),en(s),en(t),en(a)),wt(([d,f,p,[m,g],v,y,b,S,E])=>{const C=d-S,R=y+b,I=Math.max(p-C,0);let A=_N;const k=yN(E,yp),N=yN(E,bp);return m-=S,m+=p+b,g+=p+b,g-=S,m>d+R-k&&(A=Kd),g<d-I+f+N&&(A=Yd),A!==_N?[Math.max(C-p-vN(v,yp,A)-k,0),C-I-b+f+vN(v,bp,A)+N]:null}),Zt(d=>d!=null),tr(Jd)),[0,0]);return{listBoundary:i,overscan:l,topListHeight:o,increaseViewportBy:a,visibleRange:c}},er(Ls),{singleton:!0});function GV(n,e,t){if(vp(e)){const r=fN(n,e);return[{index:Qi(e.groupOffsetTree,r)[0],size:0,offset:0},{index:r,size:0,offset:0,data:t&&t[0]}]}return[{index:n,size:0,offset:0,data:t&&t[0]}]}const Hb={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0,totalCount:0,firstItemIndex:0};function bN(n,e,t){if(n.length===0)return[];if(!vp(e))return n.map(c=>({...c,index:c.index+t,originalIndex:c.index}));const r=n[0].index,s=n[n.length-1].index,i=[],o=gp(e.groupOffsetTree,r,s);let a,l=0;for(const c of n){(!a||a.end<c.index)&&(a=o.shift(),l=e.groupIndices.indexOf(a.start));let d;c.index===a.start?d={type:"group",index:l}:d={index:c.index-(l+1)+t,groupIndex:l},i.push({...d,size:c.size,offset:c.offset,originalIndex:c.index,data:c.data})}return i}function xp(n,e,t,r,s,i){const{lastSize:o,lastOffset:a,lastIndex:l}=s;let c=0,d=0;if(n.length>0){c=n[0].offset;const v=n[n.length-1];d=v.offset+v.size}const f=t-l,p=a+f*o+(f-1)*r,m=c,g=p-d;return{items:bN(n,s,i),topItems:bN(e,s,i),topListHeight:e.reduce((v,y)=>y.size+v,0),offsetTop:c,offsetBottom:g,top:m,bottom:d,totalCount:t,firstItemIndex:i}}function xN(n,e,t,r,s,i){let o=0;if(t.groupIndices.length>0)for(const d of t.groupIndices){if(d-o>=n)break;o++}const a=n+o,l=zb(e,a),c=Array.from({length:a}).map((d,f)=>({index:f+l,size:0,offset:0,data:i[f+l]}));return xp(c,[],a,s,t,r)}const Ll=An(([{sizes:n,totalCount:e,data:t,firstItemIndex:r,gap:s},i,{visibleRange:o,listBoundary:a,topListHeight:l},{scrolledToInitialItem:c,initialTopMostItemIndex:d},{topListHeight:f},p,{didMount:m},{recalcInProgress:g}])=>{const v=st([]),y=st(0),b=bn();Nt(i.topItemsIndexes,v);const S=ys(Ye(Vr(m,g,en(o,Jd),en(e),en(n),en(d),c,en(v),en(r),en(s),t),Zt(([I,A,,k,,,,,,,N])=>{const D=N&&N.length!==k;return I&&!A&&!D}),wt(([,,[I,A],k,N,D,M,F,U,$,q])=>{const G=N,{sizeTree:V,offsetTree:z}=G,B=vs(y);if(k===0)return{...Hb,totalCount:k};if(I===0&&A===0)return B===0?{...Hb,totalCount:k}:xN(B,D,N,U,$,q||[]);if(Hn(V))return B>0?null:xp(GV(zb(D,k),G,q),[],k,$,G,U);const P=[];if(F.length>0){const ee=F[0],K=F[F.length-1];let W=0;for(const te of gp(V,ee,K)){const re=te.value,pe=Math.max(te.start,ee),Ee=Math.min(te.end,K);for(let le=pe;le<=Ee;le++)P.push({index:le,size:re,offset:W,data:q&&q[le]}),W+=re}}if(!M)return xp([],P,k,$,G,U);const H=F.length>0?F[F.length-1]+1:0,Z=MV(z,I,A,H);if(Z.length===0)return null;const Q=k-1,J=hp([],ee=>{for(const K of Z){const W=K.value;let te=W.offset,re=K.start;const pe=W.size;if(W.offset<I){re+=Math.floor((I-W.offset+$)/(pe+$));const le=re-K.start;te+=le*pe+le*$}re<H&&(te+=(H-re)*pe,re=H);const Ee=Math.min(K.end,Q);for(let le=re;le<=Ee&&!(te>=A);le++)ee.push({index:le,size:pe,offset:te,data:q&&q[le]}),te+=pe+$}});return xp(J,P,k,$,G,U)}),Zt(I=>I!==null),tr()),Hb);Nt(Ye(t,Zt(kb),wt(I=>I==null?void 0:I.length)),e),Nt(Ye(S,wt(I=>I.topListHeight)),f),Nt(f,l),Nt(Ye(S,wt(I=>[I.top,I.bottom])),a),Nt(Ye(S,wt(I=>I.items)),b);const E=ii(Ye(S,Zt(({items:I})=>I.length>0),fn(e,t),Zt(([{items:I},A])=>I[I.length-1].originalIndex===A-1),wt(([,I,A])=>[I-1,A]),tr(Jd),wt(([I])=>I))),C=ii(Ye(S,Ma(200),Zt(({items:I,topItems:A})=>I.length>0&&I[0].originalIndex===A.length),wt(({items:I})=>I[0].index),tr())),R=ii(Ye(S,Zt(({items:I})=>I.length>0),wt(({items:I})=>{let A=0,k=I.length-1;for(;I[A].type==="group"&&A<k;)A++;for(;I[k].type==="group"&&k>A;)k--;return{startIndex:I[A].index,endIndex:I[k].index}}),tr(gN)));return{listState:S,topItemsIndexes:v,endReached:E,startReached:C,rangeChanged:R,itemsRendered:b,initialItemCount:y,...p}},er(Co,mN,qb,Qd,Wd,Xd,Oa,Fb),{singleton:!0}),VV=An(([{sizes:n,firstItemIndex:e,data:t,gap:r},{initialTopMostItemIndex:s},{initialItemCount:i,listState:o},{didMount:a}])=>(Nt(Ye(a,fn(i),Zt(([,l])=>l!==0),fn(s,n,e,r,t),wt(([[,l],c,d,f,p,m=[]])=>xN(l,c,d,f,p,m))),o),{}),er(Co,Qd,Ll,Oa),{singleton:!0}),SN=An(([{scrollVelocity:n}])=>{const e=st(!1),t=bn(),r=st(!1);return Nt(Ye(n,fn(r,e,t),Zt(([s,i])=>!!i),wt(([s,i,o,a])=>{const{exit:l,enter:c}=i;if(o){if(l(s,a))return!1}else if(c(s,a))return!0;return o}),tr()),e),Pn(Ye(Vr(e,n,t),fn(r)),([[s,i,o],a])=>s&&a&&a.change&&a.change(i,o)),{isSeeking:e,scrollSeekConfiguration:r,scrollVelocity:n,scrollSeekRangeChanged:t}},er(Xd),{singleton:!0}),WV=An(([{topItemsIndexes:n}])=>{const e=st(0);return Nt(Ye(e,Zt(t=>t>0),wt(t=>Array.from({length:t}).map((r,s)=>s))),n),{topItemCount:e}},er(Ll)),EN=An(([{footerHeight:n,headerHeight:e,fixedHeaderHeight:t,fixedFooterHeight:r},{listState:s}])=>{const i=bn(),o=ys(Ye(Vr(n,r,e,t,s),wt(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return Nt(en(o),i),{totalListHeight:o,totalListHeightChanged:i}},er(Ls,Ll),{singleton:!0});function wN(n){let e=!1,t;return()=>(e||(e=!0,t=n()),t)}const KV=wN(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),YV=An(([{scrollBy:n,scrollTop:e,deviation:t,scrollingInProgress:r},{isScrolling:s,isAtBottom:i,scrollDirection:o,lastJumpDueToItemResize:a},{listState:l},{beforeUnshiftWith:c,shiftWithOffset:d,sizes:f,gap:p},{log:m},{recalcInProgress:g}])=>{const v=ii(Ye(l,fn(a),wo(([,b,S,E],[{items:C,totalCount:R,bottom:I,offsetBottom:A},k])=>{const N=I+A;let D=0;return S===R&&b.length>0&&C.length>0&&(C[0].originalIndex===0&&b[0].originalIndex===0||(D=N-E,D!==0&&(D+=k))),[D,C,R,N]},[0,[],0,0]),Zt(([b])=>b!==0),fn(e,o,r,i,m,g),Zt(([,b,S,E,,,C])=>!C&&!E&&b!==0&&S===Kd),wt(([[b],,,,,S])=>(S("Upward scrolling compensation",{amount:b},qs.DEBUG),b))));function y(b){b>0?(un(n,{top:-b,behavior:"auto"}),un(t,0)):(un(t,0),un(n,{top:-b,behavior:"auto"}))}return Pn(Ye(v,fn(t,s)),([b,S,E])=>{E&&KV()?un(t,S-b):y(-b)}),Pn(Ye(Vr(ys(s,!1),t,g),Zt(([b,S,E])=>!b&&!E&&S!==0),wt(([b,S])=>S),Ma(1)),y),Nt(Ye(d,wt(b=>({top:-b}))),n),Pn(Ye(c,fn(f,p),wt(([b,{lastSize:S,groupIndices:E,sizeTree:C},R])=>{function I(A){return A*(S+R)}if(E.length===0)return I(b);{let A=0;const k=Gd(C,0);let N=0,D=0;for(;N<b;){N++,A+=k;let M=E.length===D+1?1/0:E[D+1]-E[D]-1;N+M>b&&(A-=k,M=b-N+1),N+=M,A+=I(M),D++}return A}})),b=>{un(t,b),requestAnimationFrame(()=>{un(n,{top:b}),requestAnimationFrame(()=>{un(t,0),un(g,!1)})})}),{deviation:t}},er(Ls,Xd,Ll,Co,Na,Fb)),XV=An(([{didMount:n},{scrollTo:e},{listState:t}])=>{const r=st(0);return Pn(Ye(n,fn(r),Zt(([,s])=>s!==0),wt(([,s])=>({top:s}))),s=>{So(Ye(t,Nc(1),Zt(i=>i.items.length>1)),()=>{requestAnimationFrame(()=>{un(e,s)})})}),{initialScrollTop:r}},er(Oa,Ls,Ll),{singleton:!0}),QV=An(([{viewportHeight:n},{totalListHeight:e}])=>{const t=st(!1),r=ys(Ye(Vr(t,n,e),Zt(([s])=>s),wt(([,s,i])=>Math.max(0,s-i)),Ma(0),tr()),0);return{alignToBottom:t,paddingTopAddition:r}},er(Ls,EN),{singleton:!0}),Gb=An(([{scrollTo:n,scrollContainerState:e}])=>{const t=bn(),r=bn(),s=bn(),i=st(!1),o=st(void 0);return Nt(Ye(Vr(t,r),wt(([{viewportHeight:a,scrollTop:l,scrollHeight:c},{offsetTop:d}])=>({scrollTop:Math.max(0,l-d),scrollHeight:c,viewportHeight:a}))),e),Nt(Ye(n,fn(r),wt(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),s),{useWindowScroll:i,customScrollParent:o,windowScrollContainerState:t,windowViewportRect:r,windowScrollTo:s}},er(Ls)),JV=({itemTop:n,itemBottom:e,viewportTop:t,viewportBottom:r,locationParams:{behavior:s,align:i,...o}})=>n<t?{...o,behavior:s,align:i??"start"}:e>r?{...o,behavior:s,align:i??"end"}:null,ZV=An(([{sizes:n,totalCount:e,gap:t},{scrollTop:r,viewportHeight:s,headerHeight:i,fixedHeaderHeight:o,fixedFooterHeight:a,scrollingInProgress:l},{scrollToIndex:c}])=>{const d=bn();return Nt(Ye(d,fn(n,s,e,i,o,a,r),fn(t),wt(([[f,p,m,g,v,y,b,S],E])=>{const{done:C,behavior:R,align:I,calculateViewLocation:A=JV,...k}=f,N=dN(f,p,g-1),D=Vd(N,p.offsetTree,E)+v+y,M=D+Qi(p.sizeTree,N)[1],F=S+y,U=S+m-b,$=A({itemTop:D,itemBottom:M,viewportTop:F,viewportBottom:U,locationParams:{behavior:R,align:I,...k}});return $?C&&So(Ye(l,Zt(q=>q===!1),Nc(vs(l)?1:2)),C):C&&C(),$}),Zt(f=>f!==null)),c),{scrollIntoView:d}},er(Co,Ls,Wd,Ll,Na),{singleton:!0}),e9=An(([{sizes:n,sizeRanges:e},{scrollTop:t,headerHeight:r},{initialTopMostItemIndex:s},{didMount:i},{useWindowScroll:o,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=bn(),d=st(void 0),f=st(null),p=st(null);return Nt(a,f),Nt(l,p),Pn(Ye(c,fn(n,t,o,f,p,r)),([m,g,v,y,b,S,E])=>{const C=PV(g.sizeTree);y&&b!==null&&S!==null&&(v=b.scrollTop-S.offsetTop),v-=E,m({ranges:C,scrollTop:v})}),Nt(Ye(d,Zt(kb),wt(t9)),s),Nt(Ye(i,fn(d),Zt(([,m])=>m!==void 0),tr(),wt(([,m])=>m.ranges)),e),{getState:c,restoreStateFrom:d}},er(Co,Ls,Qd,Oa,Gb));function t9(n){return{offset:n.scrollTop,index:0,align:"start"}}const n9=An(([n,e,t,r,s,i,o,a,l,c])=>({...n,...e,...t,...r,...s,...i,...o,...a,...l,...c}),er(qb,VV,Oa,SN,EN,XV,QV,Gb,ZV,Na)),TN=An(([{totalCount:n,sizeRanges:e,fixedItemSize:t,defaultItemSize:r,trackItemSizes:s,itemSize:i,data:o,firstItemIndex:a,groupIndices:l,statefulTotalCount:c,gap:d,sizes:f},{initialTopMostItemIndex:p,scrolledToInitialItem:m,initialItemFinalLocationReached:g},v,y,b,{listState:S,topItemsIndexes:E,...C},{scrollToIndex:R},I,{topItemCount:A},{groupCounts:k},N])=>(Nt(C.rangeChanged,N.scrollSeekRangeChanged),Nt(Ye(N.windowViewportRect,wt(D=>D.visibleHeight)),v.viewportHeight),{totalCount:n,data:o,firstItemIndex:a,sizeRanges:e,initialTopMostItemIndex:p,scrolledToInitialItem:m,initialItemFinalLocationReached:g,topItemsIndexes:E,topItemCount:A,groupCounts:k,fixedItemHeight:t,defaultItemHeight:r,gap:d,...b,statefulTotalCount:c,listState:S,scrollToIndex:R,trackItemSizes:s,itemSize:i,groupIndices:l,...C,...N,...v,sizes:f,...y}),er(Co,Qd,Ls,e9,qV,Ll,Wd,YV,WV,mN,n9)),Vb="-webkit-sticky",CN="sticky",IN=wN(()=>{if(typeof document>"u")return CN;const n=document.createElement("div");return n.style.position=Vb,n.style.position===Vb?Vb:CN});function Wb(n,e,t){const r=Ne.useRef(null),s=Ne.useCallback(l=>{if(l===null||!l.offsetParent)return;const c=l.getBoundingClientRect(),d=c.width;let f,p;if(e){const m=e.getBoundingClientRect(),g=c.top-m.top;f=m.height-Math.max(0,g),p=g+e.scrollTop}else f=window.innerHeight-Math.max(0,c.top),p=c.top+window.pageYOffset;r.current={offsetTop:p,visibleHeight:f,visibleWidth:d},n(r.current)},[n,e]),{callbackRef:i,ref:o}=Nb(s,!0,t),a=Ne.useCallback(()=>{s(o.current)},[s,o]);return Ne.useEffect(()=>{if(e){e.addEventListener("scroll",a);const l=new ResizeObserver(()=>{requestAnimationFrame(a)});return l.observe(e),()=>{e.removeEventListener("scroll",a),l.unobserve(e)}}else return window.addEventListener("scroll",a),window.addEventListener("resize",a),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a)}},[a,e]),i}const Sp=Ne.createContext(void 0),RN=Ne.createContext(void 0);function Kb(n){return n}const r9=An(([n,e])=>({...n,...e}),er(TN,An(()=>{const n=st(l=>`Item ${l}`),e=st(null),t=st(l=>`Group ${l}`),r=st({}),s=st(Kb),i=st("div"),o=st(Al),a=(l,c=null)=>ys(Ye(r,wt(d=>d[l]),tr()),c);return{context:e,itemContent:n,groupContent:t,components:r,computeItemKey:s,HeaderFooterTag:i,scrollerRef:o,FooterComponent:a("Footer"),HeaderComponent:a("Header"),TopItemListComponent:a("TopItemList"),ListComponent:a("List","div"),ItemComponent:a("Item","div"),GroupComponent:a("Group","div"),ScrollerComponent:a("Scroller","div"),EmptyPlaceholder:a("EmptyPlaceholder"),ScrollSeekPlaceholder:a("ScrollSeekPlaceholder")}}))),s9=({height:n})=>_.jsx("div",{style:{height:n}}),i9={position:IN(),zIndex:1,overflowAnchor:"none"},AN={overflowAnchor:"none"},o9={...AN,display:"inline-block",height:"100%"},kN=Ne.memo(function({showTopList:e=!1}){const t=sn("listState"),r=bi("sizeRanges"),s=sn("useWindowScroll"),i=sn("customScrollParent"),o=bi("windowScrollContainerState"),a=bi("scrollContainerState"),l=i||s?o:a,c=sn("itemContent"),d=sn("context"),f=sn("groupContent"),p=sn("trackItemSizes"),m=sn("itemSize"),g=sn("log"),v=bi("gap"),y=sn("horizontalDirection"),{callbackRef:b}=ZM(r,m,p,e?Al:l,g,v,i,y,sn("skipAnimationFrameInResizeObserver")),[S,E]=Ne.useState(0);Qb("deviation",q=>{S!==q&&E(q)});const C=sn("EmptyPlaceholder"),R=sn("ScrollSeekPlaceholder")||s9,I=sn("ListComponent"),A=sn("ItemComponent"),k=sn("GroupComponent"),N=sn("computeItemKey"),D=sn("isSeeking"),M=sn("groupIndices").length>0,F=sn("alignToBottom"),U=sn("initialItemFinalLocationReached"),$=e?{}:{boxSizing:"border-box",...y?{whiteSpace:"nowrap",display:"inline-block",height:"100%",paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,marginLeft:S!==0?S:F?"auto":0}:{marginTop:S!==0?S:F?"auto":0,paddingTop:t.offsetTop,paddingBottom:t.offsetBottom},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?_.jsx(C,{...yr(C,d)}):_.jsx(I,{...yr(I,d),ref:b,style:$,"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",children:(e?t.topItems:t.items).map(q=>{const G=q.originalIndex,V=N(G+t.firstItemIndex,q.data,d);return D?T.createElement(R,{...yr(R,d),key:V,index:q.index,height:q.size,type:q.type||"item",...q.type==="group"?{}:{groupIndex:q.groupIndex}}):q.type==="group"?T.createElement(k,{...yr(k,d),key:V,"data-index":G,"data-known-size":q.size,"data-item-index":q.index,style:i9},f(q.index,d)):T.createElement(A,{...yr(A,d),...LN(A,q.data),key:V,"data-index":G,"data-known-size":q.size,"data-item-index":q.index,"data-item-group-index":q.groupIndex,style:y?o9:AN},M?c(q.index,q.groupIndex,q.data,d):c(q.index,q.data,d))})})}),a9={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},l9={outline:"none",overflowX:"auto",position:"relative"},Pc=n=>({width:"100%",height:"100%",position:"absolute",top:0,...n?{display:"flex",flexDirection:"column"}:{}}),c9={width:"100%",position:IN(),top:0,zIndex:1};function yr(n,e){if(typeof n!="string")return{context:e}}function LN(n,e){return{item:typeof n=="string"?void 0:e}}const u9=Ne.memo(function(){const e=sn("HeaderComponent"),t=bi("headerHeight"),r=sn("HeaderFooterTag"),s=To(Ne.useMemo(()=>o=>t(Xi(o,"height")),[t]),!0,sn("skipAnimationFrameInResizeObserver")),i=sn("context");return e?_.jsx(r,{ref:s,children:_.jsx(e,{...yr(e,i)})}):null}),d9=Ne.memo(function(){const e=sn("FooterComponent"),t=bi("footerHeight"),r=sn("HeaderFooterTag"),s=To(Ne.useMemo(()=>o=>t(Xi(o,"height")),[t]),!0,sn("skipAnimationFrameInResizeObserver")),i=sn("context");return e?_.jsx(r,{ref:s,children:_.jsx(e,{...yr(e,i)})}):null});function Yb({usePublisher:n,useEmitter:e,useEmitterValue:t}){return Ne.memo(function({style:i,children:o,...a}){const l=n("scrollContainerState"),c=t("ScrollerComponent"),d=n("smoothScrollTargetReached"),f=t("scrollerRef"),p=t("context"),m=t("horizontalDirection")||!1,{scrollerRef:g,scrollByCallback:v,scrollToCallback:y}=nN(l,d,c,f,void 0,m);e("scrollTo",y),e("scrollBy",v);const b=m?l9:a9;return _.jsx(c,{ref:g,style:{...b,...i},"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,tabIndex:0,...a,...yr(c,p),children:o})})}function Xb({usePublisher:n,useEmitter:e,useEmitterValue:t}){return Ne.memo(function({style:i,children:o,...a}){const l=n("windowScrollContainerState"),c=t("ScrollerComponent"),d=n("smoothScrollTargetReached"),f=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),g=t("context"),{scrollerRef:v,scrollByCallback:y,scrollToCallback:b}=nN(l,d,c,Al,m);return JM(()=>(v.current=m||window,()=>{v.current=null}),[v,m]),e("windowScrollTo",b),e("scrollBy",y),_.jsx(c,{style:{position:"relative",...i,...f!==0?{height:f+p}:{}},"data-virtuoso-scroller":!0,...a,...yr(c,g),children:o})})}const f9=({children:n})=>{const e=Ne.useContext(Sp),t=bi("viewportHeight"),r=bi("fixedItemHeight"),s=sn("alignToBottom"),i=sn("horizontalDirection"),o=Ne.useMemo(()=>qd(t,l=>Xi(l,i?"width":"height")),[t,i]),a=To(o,!0,sn("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{e&&(t(e.viewportHeight),r(e.itemHeight))},[e,t,r]),_.jsx("div",{style:Pc(s),ref:a,"data-viewport-type":"element",children:n})},h9=({children:n})=>{const e=Ne.useContext(Sp),t=bi("windowViewportRect"),r=bi("fixedItemHeight"),s=sn("customScrollParent"),i=Wb(t,s,sn("skipAnimationFrameInResizeObserver")),o=sn("alignToBottom");return Ne.useEffect(()=>{e&&(r(e.itemHeight),t({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,t,r]),_.jsx("div",{ref:i,style:Pc(o),"data-viewport-type":"window",children:n})},p9=({children:n})=>{const e=sn("TopItemListComponent")||"div",t=sn("headerHeight"),r={...c9,marginTop:`${t}px`},s=sn("context");return _.jsx(e,{style:r,...yr(e,s),children:n})},m9=Ne.memo(function(e){const t=sn("useWindowScroll"),r=sn("topItemsIndexes").length>0,s=sn("customScrollParent"),i=s||t?_9:g9,o=s||t?h9:f9;return _.jsxs(i,{...e,children:[r&&_.jsx(p9,{children:_.jsx(kN,{showTopList:!0})}),_.jsxs(o,{children:[_.jsx(u9,{}),_.jsx(kN,{}),_.jsx(d9,{})]})]})}),{Component:MN,usePublisher:bi,useEmitterValue:sn,useEmitter:Qb}=Mb(r9,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},m9),g9=Yb({usePublisher:bi,useEmitterValue:sn,useEmitter:Qb}),_9=Xb({usePublisher:bi,useEmitterValue:sn,useEmitter:Qb}),Zd=MN,v9=MN,NN={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},y9={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},{round:ON,ceil:PN,floor:Ep,min:Jb,max:ef}=Math;function b9(n){return{...y9,items:n}}function DN(n,e,t){return Array.from({length:e-n+1}).map((r,s)=>{const i=t===null?null:t[s+n];return{index:s+n,data:i}})}function x9(n,e){return n&&n.column===e.column&&n.row===e.row}function wp(n,e){return n&&n.width===e.width&&n.height===e.height}const S9=An(([{overscan:n,visibleRange:e,listBoundary:t},{scrollTop:r,viewportHeight:s,scrollBy:i,scrollTo:o,smoothScrollTargetReached:a,scrollContainerState:l,footerHeight:c,headerHeight:d},f,p,{propsReady:m,didMount:g},{windowViewportRect:v,useWindowScroll:y,customScrollParent:b,windowScrollContainerState:S,windowScrollTo:E},C])=>{const R=st(0),I=st(0),A=st(NN),k=st({height:0,width:0}),N=st({height:0,width:0}),D=bn(),M=bn(),F=st(0),U=st(null),$=st({row:0,column:0}),q=bn(),G=bn(),V=st(!1),z=st(0),B=st(!0),P=st(!1),H=st(!1);Pn(Ye(g,fn(z),Zt(([W,te])=>!!te)),()=>{un(B,!1),un(I,0)}),Pn(Ye(Vr(g,B,N,k,z,P),Zt(([W,te,re,pe,,Ee])=>W&&!te&&re.height!==0&&pe.height!==0&&!Ee)),([,,,,W])=>{un(P,!0),$b(1,()=>{un(D,W)}),So(Ye(r),()=>{un(t,[0,0]),un(B,!0)})}),Nt(Ye(G,Zt(W=>W!=null&&W.scrollTop>0),Eo(0)),I),Pn(Ye(g,fn(G),Zt(([,W])=>W!=null)),([,W])=>{W&&(un(k,W.viewport),un(N,W==null?void 0:W.item),un($,W.gap),W.scrollTop>0&&(un(V,!0),So(Ye(r,Nc(1)),te=>{un(V,!1)}),un(o,{top:W.scrollTop})))}),Nt(Ye(k,wt(({height:W})=>W)),s),Nt(Ye(Vr(en(k,wp),en(N,wp),en($,(W,te)=>W&&W.column===te.column&&W.row===te.row),en(r)),wt(([W,te,re,pe])=>({viewport:W,item:te,gap:re,scrollTop:pe}))),q),Nt(Ye(Vr(en(R),e,en($,x9),en(N,wp),en(k,wp),en(U),en(I),en(V),en(B),en(z)),Zt(([,,,,,,,W])=>!W),wt(([W,[te,re],pe,Ee,le,Ie,be,,ge,Ae])=>{const{row:Re,column:tt}=pe,{height:et,width:Oe}=Ee,{width:ht}=le;if(be===0&&(W===0||ht===0))return NN;if(Oe===0){const rt=zb(Ae,W),Me=rt===0?Math.max(be-1,0):rt;return b9(DN(rt,Me,Ie))}const Xe=FN(ht,Oe,tt);let Je,qe;ge?te===0&&re===0&&be>0?(Je=0,qe=be-1):(Je=Xe*Ep((te+Re)/(et+Re)),qe=Xe*PN((re+Re)/(et+Re))-1,qe=Jb(W-1,ef(qe,Xe-1)),Je=Jb(qe,ef(0,Je))):(Je=0,qe=-1);const Ue=DN(Je,qe,Ie),{top:it,bottom:nt}=jN(le,pe,Ee,Ue),dt=PN(W/Xe),xt=dt*et+(dt-1)*Re-nt;return{items:Ue,offsetTop:it,offsetBottom:xt,top:it,bottom:nt,itemHeight:et,itemWidth:Oe}})),A),Nt(Ye(U,Zt(W=>W!==null),wt(W=>W.length)),R),Nt(Ye(Vr(k,N,A,$),Zt(([W,te,{items:re}])=>re.length>0&&te.height!==0&&W.height!==0),wt(([W,te,{items:re},pe])=>{const{top:Ee,bottom:le}=jN(W,pe,te,re);return[Ee,le]}),tr(Jd)),t);const Z=st(!1);Nt(Ye(r,fn(Z),wt(([W,te])=>te||W!==0)),Z);const Q=ii(Ye(en(A),Zt(({items:W})=>W.length>0),fn(R,Z),Zt(([{items:W},te,re])=>re&&W[W.length-1].index===te-1),wt(([,W])=>W-1),tr())),J=ii(Ye(en(A),Zt(({items:W})=>W.length>0&&W[0].index===0),Eo(0),tr())),ee=ii(Ye(en(A),fn(V),Zt(([{items:W},te])=>W.length>0&&!te),wt(([{items:W}])=>({startIndex:W[0].index,endIndex:W[W.length-1].index})),tr(gN),Ma(0)));Nt(ee,p.scrollSeekRangeChanged),Nt(Ye(D,fn(k,N,R,$),wt(([W,te,re,pe,Ee])=>{const le=hN(W),{align:Ie,behavior:be,offset:ge}=le;let Ae=le.index;Ae==="LAST"&&(Ae=pe-1),Ae=ef(0,Ae,Jb(pe-1,Ae));let Re=Zb(te,Ee,re,Ae);return Ie==="end"?Re=ON(Re-te.height+re.height):Ie==="center"&&(Re=ON(Re-te.height/2+re.height/2)),ge&&(Re+=ge),{top:Re,behavior:be}})),o);const K=ys(Ye(A,wt(W=>W.offsetBottom+W.bottom)),0);return Nt(Ye(v,wt(W=>({width:W.visibleWidth,height:W.visibleHeight}))),k),{data:U,totalCount:R,viewportDimensions:k,itemDimensions:N,scrollTop:r,scrollHeight:M,overscan:n,scrollBy:i,scrollTo:o,scrollToIndex:D,smoothScrollTargetReached:a,windowViewportRect:v,windowScrollTo:E,useWindowScroll:y,customScrollParent:b,windowScrollContainerState:S,deviation:F,scrollContainerState:l,footerHeight:c,headerHeight:d,initialItemCount:I,gap:$,restoreStateFrom:G,...p,initialTopMostItemIndex:z,horizontalDirection:H,gridState:A,totalListHeight:K,...f,startReached:J,endReached:Q,rangeChanged:ee,stateChanged:q,propsReady:m,stateRestoreInProgress:V,...C}},er(qb,Ls,Xd,SN,Oa,Gb,Na));function jN(n,e,t,r){const{height:s}=t;if(s===void 0||r.length===0)return{top:0,bottom:0};const i=Zb(n,e,t,r[0].index),o=Zb(n,e,t,r[r.length-1].index)+s;return{top:i,bottom:o}}function Zb(n,e,t,r){const s=FN(n.width,t.width,e.column),i=Ep(r/s),o=i*t.height+ef(0,i-1)*e.row;return o>0?o+e.row:o}function FN(n,e,t){return ef(1,Ep((n+t)/(Ep(e)+t)))}const E9=An(([n,e])=>({...n,...e}),er(S9,An(()=>{const n=st(f=>`Item ${f}`),e=st({}),t=st(null),r=st("virtuoso-grid-item"),s=st("virtuoso-grid-list"),i=st(Kb),o=st("div"),a=st(Al),l=(f,p=null)=>ys(Ye(e,wt(m=>m[f]),tr()),p),c=st(!1),d=st(!1);return Nt(en(d),c),{readyStateChanged:c,reportReadyState:d,context:t,itemContent:n,components:e,computeItemKey:i,itemClassName:r,listClassName:s,headerFooterTag:o,scrollerRef:a,FooterComponent:l("Footer"),HeaderComponent:l("Header"),ListComponent:l("List","div"),ItemComponent:l("Item","div"),ScrollerComponent:l("Scroller","div"),ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}))),w9=Ne.memo(function(){const e=fr("gridState"),t=fr("listClassName"),r=fr("itemClassName"),s=fr("itemContent"),i=fr("computeItemKey"),o=fr("isSeeking"),a=xi("scrollHeight"),l=fr("ItemComponent"),c=fr("ListComponent"),d=fr("ScrollSeekPlaceholder"),f=fr("context"),p=xi("itemDimensions"),m=xi("gap"),g=fr("log"),v=fr("stateRestoreInProgress"),y=xi("reportReadyState"),b=To(Ne.useMemo(()=>S=>{const E=S.parentElement.parentElement.scrollHeight;a(E);const C=S.firstChild;if(C){const{width:R,height:I}=C.getBoundingClientRect();p({width:R,height:I})}m({row:BN("row-gap",getComputedStyle(S).rowGap,g),column:BN("column-gap",getComputedStyle(S).columnGap,g)})},[a,p,m,g]),!0,!1);return v?null:(JM(()=>{e.itemHeight>0&&e.itemWidth>0&&y(!0)},[e]),_.jsx(c,{ref:b,className:t,...yr(c,f),style:{paddingTop:e.offsetTop,paddingBottom:e.offsetBottom},"data-testid":"virtuoso-item-list",children:e.items.map(S=>{const E=i(S.index,S.data,f);return o?_.jsx(d,{...yr(d,f),index:S.index,height:e.itemHeight,width:e.itemWidth},E):T.createElement(l,{...yr(l,f),className:r,"data-index":S.index,key:E},s(S.index,S.data,f))})}))}),T9=Ne.memo(function(){const e=fr("HeaderComponent"),t=xi("headerHeight"),r=fr("headerFooterTag"),s=To(Ne.useMemo(()=>o=>t(Xi(o,"height")),[t]),!0,!1),i=fr("context");return e?_.jsx(r,{ref:s,children:_.jsx(e,{...yr(e,i)})}):null}),C9=Ne.memo(function(){const e=fr("FooterComponent"),t=xi("footerHeight"),r=fr("headerFooterTag"),s=To(Ne.useMemo(()=>o=>t(Xi(o,"height")),[t]),!0,!1),i=fr("context");return e?_.jsx(r,{ref:s,children:_.jsx(e,{...yr(e,i)})}):null}),I9=({children:n})=>{const e=Ne.useContext(RN),t=xi("itemDimensions"),r=xi("viewportDimensions"),s=To(Ne.useMemo(()=>i=>{r(i.getBoundingClientRect())},[r]),!0,!1);return Ne.useEffect(()=>{e&&(r({height:e.viewportHeight,width:e.viewportWidth}),t({height:e.itemHeight,width:e.itemWidth}))},[e,r,t]),_.jsx("div",{style:Pc(!1),ref:s,children:n})},R9=({children:n})=>{const e=Ne.useContext(RN),t=xi("windowViewportRect"),r=xi("itemDimensions"),s=fr("customScrollParent"),i=Wb(t,s,!1);return Ne.useEffect(()=>{e&&(r({height:e.itemHeight,width:e.itemWidth}),t({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:e.viewportWidth}))},[e,t,r]),_.jsx("div",{ref:i,style:Pc(!1),children:n})},A9=Ne.memo(function({...e}){const t=fr("useWindowScroll"),r=fr("customScrollParent"),s=r||t?M9:L9,i=r||t?R9:I9;return _.jsx(s,{...e,children:_.jsxs(i,{children:[_.jsx(T9,{}),_.jsx(w9,{}),_.jsx(C9,{})]})})}),{Component:k9,usePublisher:xi,useEmitterValue:fr,useEmitter:UN}=Mb(E9,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},A9),L9=Yb({usePublisher:xi,useEmitterValue:fr,useEmitter:UN}),M9=Xb({usePublisher:xi,useEmitterValue:fr,useEmitter:UN});function BN(n,e,t){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&t(`${n} was not resolved to pixel value correctly`,e,qs.WARN),e==="normal"?0:parseInt(e??"0",10)}const N9=k9,O9=An(([n,e])=>({...n,...e}),er(TN,An(()=>{const n=st(l=>_.jsxs("td",{children:["Item $",l]})),e=st(null),t=st(null),r=st(null),s=st({}),i=st(Kb),o=st(Al),a=(l,c=null)=>ys(Ye(s,wt(d=>d[l]),tr()),c);return{context:e,itemContent:n,fixedHeaderContent:t,fixedFooterContent:r,components:s,computeItemKey:i,scrollerRef:o,TableComponent:a("Table","table"),TableHeadComponent:a("TableHead","thead"),TableFooterComponent:a("TableFoot","tfoot"),TableBodyComponent:a("TableBody","tbody"),TableRowComponent:a("TableRow","tr"),ScrollerComponent:a("Scroller","div"),EmptyPlaceholder:a("EmptyPlaceholder"),ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),FillerRow:a("FillerRow")}}))),P9=({height:n})=>_.jsx("tr",{children:_.jsx("td",{style:{height:n}})}),D9=({height:n})=>_.jsx("tr",{children:_.jsx("td",{style:{height:n,padding:0,border:0}})}),j9={overflowAnchor:"none"},F9=Ne.memo(function(){const e=xn("listState"),t=Ji("sizeRanges"),r=xn("useWindowScroll"),s=xn("customScrollParent"),i=Ji("windowScrollContainerState"),o=Ji("scrollContainerState"),a=s||r?i:o,l=xn("itemContent"),c=xn("trackItemSizes"),d=xn("itemSize"),f=xn("log"),{callbackRef:p,ref:m}=ZM(t,d,c,a,f,void 0,s,!1,xn("skipAnimationFrameInResizeObserver")),[g,v]=Ne.useState(0);ex("deviation",G=>{g!==G&&(m.current.style.marginTop=`${G}px`,v(G))});const y=xn("EmptyPlaceholder"),b=xn("ScrollSeekPlaceholder")||P9,S=xn("FillerRow")||D9,E=xn("TableBodyComponent"),C=xn("TableRowComponent"),R=xn("computeItemKey"),I=xn("isSeeking"),A=xn("paddingTopAddition"),k=xn("firstItemIndex"),N=xn("statefulTotalCount"),D=xn("context");if(N===0&&y)return _.jsx(y,{...yr(y,D)});const M=e.offsetTop+A+g,F=e.offsetBottom,U=M>0?_.jsx(S,{height:M,context:D},"padding-top"):null,$=F>0?_.jsx(S,{height:F,context:D},"padding-bottom"):null,q=e.items.map(G=>{const V=G.originalIndex,z=R(V+k,G.data,D);return I?T.createElement(b,{...yr(b,D),key:z,index:G.index,height:G.size,type:G.type||"item"}):T.createElement(C,{...yr(C,D),...LN(C,G.data),key:z,"data-index":V,"data-known-size":G.size,"data-item-index":G.index,style:j9},l(G.index,G.data,D))});return _.jsxs(E,{ref:p,"data-testid":"virtuoso-item-list",...yr(E,D),children:[U,q,$]})}),U9=({children:n})=>{const e=Ne.useContext(Sp),t=Ji("viewportHeight"),r=Ji("fixedItemHeight"),s=To(Ne.useMemo(()=>qd(t,i=>Xi(i,"height")),[t]),!0,xn("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{e&&(t(e.viewportHeight),r(e.itemHeight))},[e,t,r]),_.jsx("div",{style:Pc(!1),ref:s,"data-viewport-type":"element",children:n})},B9=({children:n})=>{const e=Ne.useContext(Sp),t=Ji("windowViewportRect"),r=Ji("fixedItemHeight"),s=xn("customScrollParent"),i=Wb(t,s,xn("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{e&&(r(e.itemHeight),t({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,t,r]),_.jsx("div",{ref:i,style:Pc(!1),"data-viewport-type":"window",children:n})},$9=Ne.memo(function(e){const t=xn("useWindowScroll"),r=xn("customScrollParent"),s=Ji("fixedHeaderHeight"),i=Ji("fixedFooterHeight"),o=xn("fixedHeaderContent"),a=xn("fixedFooterContent"),l=xn("context"),c=To(Ne.useMemo(()=>qd(s,S=>Xi(S,"height")),[s]),!0,xn("skipAnimationFrameInResizeObserver")),d=To(Ne.useMemo(()=>qd(i,S=>Xi(S,"height")),[i]),!0,xn("skipAnimationFrameInResizeObserver")),f=r||t?H9:q9,p=r||t?B9:U9,m=xn("TableComponent"),g=xn("TableHeadComponent"),v=xn("TableFooterComponent"),y=o?_.jsx(g,{style:{zIndex:2,position:"sticky",top:0},ref:c,...yr(g,l),children:o()},"TableHead"):null,b=a?_.jsx(v,{style:{zIndex:1,position:"sticky",bottom:0},ref:d,...yr(v,l),children:a()},"TableFoot"):null;return _.jsx(f,{...e,children:_.jsx(p,{children:_.jsxs(m,{style:{borderSpacing:0,overflowAnchor:"none"},...yr(m,l),children:[y,_.jsx(F9,{},"TableBody"),b]})})})}),{Component:z9,usePublisher:Ji,useEmitterValue:xn,useEmitter:ex}=Mb(O9,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},$9),q9=Yb({usePublisher:Ji,useEmitterValue:xn,useEmitter:ex}),H9=Xb({usePublisher:Ji,useEmitterValue:xn,useEmitter:ex}),G9=z9,$N=T.forwardRef((n,e)=>_.jsx(Zd,{ref:e,...n})),zN=T.forwardRef((n,e)=>_.jsx(v9,{ref:e,...n})),qN=T.forwardRef((n,e)=>_.jsx(G9,{ref:e,...n})),HN=T.forwardRef((n,e)=>_.jsx(N9,{ref:e,...n}));$N.displayName="BsVirtualScroll",zN.displayName="BsVirtualScrollGrouped",qN.displayName="BsVirtualScrollTable",HN.displayName="BsVirtualScrollGrid",Object.assign($N,{Grid:HN,Table:qN,Grouped:zN});const GN=T.createContext(null);function tx({children:n}){const e=T.useRef([]),t=T.useCallback(o=>(e.current.push(o),()=>{e.current=e.current.filter(a=>a!==o)}),[]),r=T.useCallback(o=>{const a=()=>{o(),e.current=e.current.filter(l=>l!==a)};return e.current.push(a),()=>{e.current=e.current.filter(l=>l!==a)}},[]),s=T.useCallback(o=>{if(o.key==="Escape"){const a=e.current.at(-1);a&&a()}},[]);T.useEffect(()=>(document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)),[s]);const i=T.useMemo(()=>({push:t,pushOnce:r}),[t,r]);return _.jsx(GN.Provider,{value:i,children:n})}const Si=()=>{const n=T.useContext(GN);if(!n)throw new Error("useEscapeContext must be used within an EscapeStackProvider");return n};function tf({show:n,className:e,children:t,onClose:r,...s}){const{push:i}=Si();return T.useEffect(()=>{if(n)return i(a=>{r(a)})},[i,n]),_.jsx(ob,{show:n,className:e,onClose:r,...s,children:t})}const Pa={"options-modal__item":"_options-modal__item_19kqs_6","options-modal__item-icon":"_options-modal__item-icon_19kqs_32","options-modal__item-title":"_options-modal__item-title_19kqs_41","options-popover":"_options-popover_19kqs_53","options-popover__item":"_options-popover__item_19kqs_73","options-popover__item-icon":"_options-popover__item-icon_19kqs_117"},VN={"delete-confirm__btn":"_delete-confirm__btn_1o4au_6"};function V9({show:n,onConfirm:e,onClose:t,title:r,isGroup:s}){const i=()=>{e(),t()};return _.jsx(Md,{show:n,onClose:t,title:r,modalProps:{hasPopstate:!0},cancelColor:"secondary",description:`مطمئنی می‌خوای این ${s?"گروه":"کانال"} را ترک کنی؟`,confirmLabel:`ترک ${s?"گروه":"کانال"}`,cancelLabel:"انصراف",cancelVariant:"outline",confirmVariant:"fill",confirmButtonProps:{icon:"bi-logout",className:VN["delete-confirm__btn"]},cancelButtonProps:{className:VN["delete-confirm__btn"]},onConfirm:i})}function W9(n){const[e,t]=T.useState(n);return T.useEffect(()=>{t(n)},[n]),[e,t]}const WN={"delete-confirm__btn":"_delete-confirm__btn_1o4au_6"};function K9({show:n,onDelete:e,onClose:t,title:r}){const s=()=>{e(),t()};return _.jsx(Md,{show:n,onClose:t,title:r,modalProps:{hasPopstate:!0},cancelColor:"secondary",description:"مطمئنی می‌خوای این گفت‌وگو را حذف کنی؟",confirmLabel:"حذف",cancelLabel:"انصراف",cancelVariant:"outline",confirmVariant:"fill",confirmButtonProps:{icon:"bi-delete",className:WN["delete-confirm__btn"]},cancelButtonProps:{className:WN["delete-confirm__btn"]},onConfirm:s})}const Kn=R_(n=>({messages:[],isError:!1,chat:void 0,isEditing:!1,isLoading:!1,isFetching:!1,contact:void 0,hasNextPage:!1,pendingMessages:[],hasChatUpdate:!1,identifier:void 0,shouldLabelShow:!0,hasUnseenLabel:!1,forwardModalData:null,toMessageId:void 0,hasPreviousPage:!1,hasNextMessages:!1,editingMessage:void 0,hasPreviousMessages:!1,replyingMessage:void 0,isLoadingNextMessages:!1,messageIdToSearch:void 0,selectedMessageIds:new Set,scrollToRepliedMessage:void 0,scrollToReplierMessage:void 0,actions:{setIsError:e=>n(()=>({isError:e})),setContact:e=>n(()=>({contact:e})),setIsLoading:e=>n(()=>({isLoading:e})),setIsEditing:e=>n(()=>({isEditing:e})),setIdentifier:e=>n(()=>({identifier:e})),setIsFetching:e=>n(()=>({isFetching:e})),setHasNextPage:e=>n(()=>({hasNextPage:e})),setForwardModalData:e=>n(()=>({forwardModalData:e})),setToMessageId:e=>n(()=>({toMessageId:e})),setHasPreviousPage:e=>n(()=>({hasPreviousPage:e})),setHasNextMessages:e=>n(()=>({hasNextMessages:e})),setReplyingMessage:e=>n(()=>({replyingMessage:e})),setHasChatUpdate:e=>n(()=>({hasChatUpdate:e})),setHasUnseenLabel:e=>n(()=>({hasUnseenLabel:e})),setPendingMessages:e=>n(()=>({pendingMessages:e})),setShouldLabelShow:e=>n(()=>({shouldLabelShow:e})),setMessageIdToSearch:e=>n(()=>({messageIdToSearch:e})),setHasPreviousMessages:e=>n(()=>({hasPreviousMessages:e})),setIsLoadingNextMessages:e=>n(()=>({isLoadingNextMessages:e})),setScrollToRepliedMessage:e=>n(()=>({scrollToRepliedMessage:e})),setScrollToReplierMessage:e=>n(()=>({scrollToReplierMessage:e})),setEditingMessage:e=>n(()=>({isEditing:!!e,editingMessage:e})),resetChat:()=>n(()=>({chat:void 0,contact:void 0,identifier:void 0})),setChat:e=>n(t=>({chat:typeof e=="function"?e(t.chat):e})),setMessages:e=>n(t=>({messages:typeof e=="function"?e(t.messages):e})),setSelectedMessageIds:e=>n(t=>({selectedMessageIds:new Set(typeof e=="function"?e(t.selectedMessageIds):e)})),resetMessages:()=>n(()=>({messages:[],isEditing:!1,pendingMessages:[],hasChatUpdate:!1,shouldLabelShow:!0,hasUnseenLabel:!1,toMessageId:void 0,editingMessage:void 0,replyingMessage:void 0,isLoadingNextMessages:!1,messageIdToSearch:void 0,selectedMessageIds:new Set,scrollToRepliedMessage:void 0,scrollToReplierMessage:void 0})),resetAll:()=>n(()=>({messages:[],isError:!1,chat:void 0,isEditing:!1,isLoading:!1,isFetching:!1,contact:void 0,hasNextPage:!1,pendingMessages:[],hasChatUpdate:!1,identifier:void 0,shouldLabelShow:!0,hasUnseenLabel:!1,forwardModalData:null,toMessageId:void 0,hasPreviousPage:!1,hasNextMessages:!1,editingMessage:void 0,hasPreviousMessages:!1,replyingMessage:void 0,isLoadingNextMessages:!1,messageIdToSearch:void 0,selectedMessageIds:new Set,scrollToRepliedMessage:void 0,scrollToReplierMessage:void 0}))}})),Y9=()=>Kn(n=>n.chat),X9=()=>Kn(n=>n.contact),Q9=()=>Kn(n=>n.identifier),J9=()=>Kn(n=>n.forwardModalData),Z9=()=>Kn(n=>n.messages),eW=()=>Kn(n=>n.selectedMessageIds),tW=()=>Kn(n=>n.editingMessage),nW=()=>Kn(n=>n.replyingMessage),rW=()=>Kn(n=>n.isLoadingNextMessages),sW=()=>Kn(n=>n.hasChatUpdate),iW=()=>Kn(n=>n.isEditing),oW=()=>Kn(n=>n.messageIdToSearch),aW=()=>Kn(n=>n.pendingMessages),lW=()=>Kn(n=>n.shouldLabelShow),cW=()=>Kn(n=>n.hasUnseenLabel),uW=()=>Kn(n=>n.toMessageId),dW=()=>Kn(n=>n.scrollToRepliedMessage),fW=()=>Kn(n=>n.scrollToReplierMessage),hW=()=>Kn(n=>n.isLoading),pW=()=>Kn(n=>n.isFetching),mW=()=>Kn(n=>n.isError),gW=()=>Kn(n=>n.hasNextPage),_W=()=>Kn(n=>n.hasPreviousPage),vW=()=>Kn(n=>n.hasNextMessages),yW=()=>Kn(n=>n.hasPreviousMessages),ai=()=>Kn(n=>n.actions),Tn=A_({useChat:Y9,useContact:X9,useIsError:mW,useMessages:Z9,useIsEditing:iW,useIsLoading:hW,useIdentifier:Q9,useIsFetching:pW,useHasNextPage:gW,useToMessageId:uW,useHasChatUpdate:sW,useEditingMessage:tW,useHasUnseenLabel:cW,useReplyingMessage:nW,useHasPreviousPage:_W,useHasNextMessages:vW,usePendingMessages:aW,useShouldLabelShow:lW,useForwardModalData:J9,useMessageIdToSearch:oW,useSelectedMessageIds:eW,useChatMessagesActions:ai,useHasPreviousMessages:yW,useIsLoadingNextMessages:rW,useScrollToRepliedMessage:dW,useScrollToReplierMessage:fW});class Dc{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.push(e),this.onSubscribe(),()=>{this.listeners=this.listeners.filter(t=>t!==e),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const nf=typeof window>"u"||"Deno"in window;function Ei(){}function bW(n,e){return typeof n=="function"?n(e):n}function nx(n){return typeof n=="number"&&n>=0&&n!==1/0}function KN(n,e){return Math.max(n+(e||0)-Date.now(),0)}function jc(n,e,t){return rf(n)?typeof e=="function"?{...t,queryKey:n,queryFn:e}:{...e,queryKey:n}:n}function xW(n,e,t){return rf(n)?typeof e=="function"?{...t,mutationKey:n,mutationFn:e}:{...e,mutationKey:n}:typeof n=="function"?{...e,mutationFn:n}:{...n}}function Da(n,e,t){return rf(n)?[{...e,queryKey:n},t]:[n||{},e]}function YN(n,e){const{type:t="all",exact:r,fetchStatus:s,predicate:i,queryKey:o,stale:a}=n;if(rf(o)){if(r){if(e.queryHash!==rx(o,e.options))return!1}else if(!Tp(e.queryKey,o))return!1}if(t!=="all"){const l=e.isActive();if(t==="active"&&!l||t==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||typeof s<"u"&&s!==e.state.fetchStatus||i&&!i(e))}function XN(n,e){const{exact:t,fetching:r,predicate:s,mutationKey:i}=n;if(rf(i)){if(!e.options.mutationKey)return!1;if(t){if(Ml(e.options.mutationKey)!==Ml(i))return!1}else if(!Tp(e.options.mutationKey,i))return!1}return!(typeof r=="boolean"&&e.state.status==="loading"!==r||s&&!s(e))}function rx(n,e){return((e==null?void 0:e.queryKeyHashFn)||Ml)(n)}function Ml(n){return JSON.stringify(n,(e,t)=>ix(t)?Object.keys(t).sort().reduce((r,s)=>(r[s]=t[s],r),{}):t)}function Tp(n,e){return QN(n,e)}function QN(n,e){return n===e?!0:typeof n!=typeof e?!1:n&&e&&typeof n=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!QN(n[t],e[t])):!1}function JN(n,e){if(n===e)return n;const t=ZN(n)&&ZN(e);if(t||ix(n)&&ix(e)){const r=t?n.length:Object.keys(n).length,s=t?e:Object.keys(e),i=s.length,o=t?[]:{};let a=0;for(let l=0;l<i;l++){const c=t?l:s[l];o[c]=JN(n[c],e[c]),o[c]===n[c]&&a++}return r===i&&a===r?n:o}return e}function sx(n,e){if(n&&!e||e&&!n)return!1;for(const t in n)if(n[t]!==e[t])return!1;return!0}function ZN(n){return Array.isArray(n)&&n.length===Object.keys(n).length}function ix(n){if(!eO(n))return!1;const e=n.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!eO(t)||!t.hasOwnProperty("isPrototypeOf"))}function eO(n){return Object.prototype.toString.call(n)==="[object Object]"}function rf(n){return Array.isArray(n)}function tO(n){return new Promise(e=>{setTimeout(e,n)})}function nO(n){tO(0).then(n)}function SW(){if(typeof AbortController=="function")return new AbortController}function ox(n,e,t){return t.isDataEqual!=null&&t.isDataEqual(n,e)?n:typeof t.structuralSharing=="function"?t.structuralSharing(n,e):t.structuralSharing!==!1?JN(n,e):e}class EW extends Dc{constructor(){super(),this.setup=e=>{if(!nf&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),window.addEventListener("focus",t,!1),()=>{window.removeEventListener("visibilitychange",t),window.removeEventListener("focus",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.cleanup)==null||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,(t=this.cleanup)==null||t.call(this),this.cleanup=e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()})}setFocused(e){this.focused=e,e&&this.onFocus()}onFocus(){this.listeners.forEach(e=>{e()})}isFocused(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)}}const Cp=new EW;class wW extends Dc{constructor(){super(),this.setup=e=>{if(!nf&&window.addEventListener){const t=()=>e();return window.addEventListener("online",t,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var e;(e=this.cleanup)==null||e.call(this),this.cleanup=void 0}}setEventListener(e){var t;this.setup=e,(t=this.cleanup)==null||t.call(this),this.cleanup=e(r=>{typeof r=="boolean"?this.setOnline(r):this.onOnline()})}setOnline(e){this.online=e,e&&this.onOnline()}onOnline(){this.listeners.forEach(e=>{e()})}isOnline(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine}}const Ip=new wW;function TW(n){return Math.min(1e3*2**n,3e4)}function Rp(n){return(n??"online")==="online"?Ip.isOnline():!0}class rO{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}function Ap(n){return n instanceof rO}function sO(n){let e=!1,t=0,r=!1,s,i,o;const a=new Promise((y,b)=>{i=y,o=b}),l=y=>{r||(m(new rO(y)),n.abort==null||n.abort())},c=()=>{e=!0},d=()=>{e=!1},f=()=>!Cp.isFocused()||n.networkMode!=="always"&&!Ip.isOnline(),p=y=>{r||(r=!0,n.onSuccess==null||n.onSuccess(y),s==null||s(),i(y))},m=y=>{r||(r=!0,n.onError==null||n.onError(y),s==null||s(),o(y))},g=()=>new Promise(y=>{s=b=>{const S=r||!f();return S&&y(b),S},n.onPause==null||n.onPause()}).then(()=>{s=void 0,r||n.onContinue==null||n.onContinue()}),v=()=>{if(r)return;let y;try{y=n.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(p).catch(b=>{var S,E;if(r)return;const C=(S=n.retry)!=null?S:3,R=(E=n.retryDelay)!=null?E:TW,I=typeof R=="function"?R(t,b):R,A=C===!0||typeof C=="number"&&t<C||typeof C=="function"&&C(t,b);if(e||!A){m(b);return}t++,n.onFail==null||n.onFail(t,b),tO(I).then(()=>{if(f())return g()}).then(()=>{e?m(b):v()})})};return Rp(n.networkMode)?v():g().then(v),{promise:a,cancel:l,continue:()=>(s==null?void 0:s())?a:Promise.resolve(),cancelRetry:c,continueRetry:d}}const ax=console;function CW(){let n=[],e=0,t=d=>{d()},r=d=>{d()};const s=d=>{let f;e++;try{f=d()}finally{e--,e||a()}return f},i=d=>{e?n.push(d):nO(()=>{t(d)})},o=d=>(...f)=>{i(()=>{d(...f)})},a=()=>{const d=n;n=[],d.length&&nO(()=>{r(()=>{d.forEach(f=>{t(f)})})})};return{batch:s,batchCalls:o,schedule:i,setNotifyFunction:d=>{t=d},setBatchNotifyFunction:d=>{r=d}}}const br=CW();class iO{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),nx(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(e){this.cacheTime=Math.max(this.cacheTime||0,e??(nf?1/0:3e5))}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class IW extends iO{constructor(e){super(),this.abortSignalConsumed=!1,this.defaultOptions=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.cache=e.cache,this.logger=e.logger||ax,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.initialState=e.state||RW(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(e){this.options={...this.defaultOptions,...e},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.cache.remove(this)}setData(e,t){const r=ox(this.state.data,e,this.options);return this.dispatch({data:r,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),r}setState(e,t){this.dispatch({type:"setState",state:e,setStateOptions:t})}cancel(e){var t;const r=this.promise;return(t=this.retryer)==null||t.cancel(e),r?r.then(Ei).catch(Ei):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!KN(this.state.dataUpdatedAt,e)}onFocus(){var e;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t&&t.refetch({cancelRefetch:!1}),(e=this.retryer)==null||e.continue()}onOnline(){var e;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t&&t.refetch({cancelRefetch:!1}),(e=this.retryer)==null||e.continue()}addObserver(e){this.observers.indexOf(e)===-1&&(this.observers.push(e),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.indexOf(e)!==-1&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(e,t){var r,s;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&t!=null&&t.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var i;return(i=this.retryer)==null||i.continueRetry(),this.promise}}if(e&&this.setOptions(e),!this.options.queryFn){const m=this.observers.find(g=>g.options.queryFn);m&&this.setOptions(m.options)}Array.isArray(this.options.queryKey);const o=SW(),a={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},l=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>{if(o)return this.abortSignalConsumed=!0,o.signal}})};l(a);const c=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(a)):Promise.reject("Missing queryFn"),d={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:c};if(l(d),(r=this.options.behavior)==null||r.onFetch(d),this.revertState=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==((s=d.fetchOptions)==null?void 0:s.meta)){var f;this.dispatch({type:"fetch",meta:(f=d.fetchOptions)==null?void 0:f.meta})}const p=m=>{if(Ap(m)&&m.silent||this.dispatch({type:"error",error:m}),!Ap(m)){var g,v;(g=(v=this.cache.config).onError)==null||g.call(v,m,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=sO({fn:d.fetchFn,abort:o==null?void 0:o.abort.bind(o),onSuccess:m=>{var g,v;if(typeof m>"u"){p(new Error("undefined"));return}this.setData(m),(g=(v=this.cache.config).onSuccess)==null||g.call(v,m,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:p,onFail:(m,g)=>{this.dispatch({type:"failed",failureCount:m,error:g})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(e){const t=r=>{var s,i;switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:(s=e.meta)!=null?s:null,fetchStatus:Rp(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:(i=e.dataUpdatedAt)!=null?i:Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=e.error;return Ap(o)&&o.revert&&this.revertState?{...this.revertState}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),br.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate(e)}),this.cache.notify({query:this,type:"updated",action:e})})}}function RW(n){const e=typeof n.initialData=="function"?n.initialData():n.initialData,t=typeof e<"u",r=t?typeof n.initialDataUpdatedAt=="function"?n.initialDataUpdatedAt():n.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"loading",fetchStatus:"idle"}}class AW extends Dc{constructor(e){super(),this.config=e||{},this.queries=[],this.queriesMap={}}build(e,t,r){var s;const i=t.queryKey,o=(s=t.queryHash)!=null?s:rx(i,t);let a=this.get(o);return a||(a=new IW({cache:this,logger:e.getLogger(),queryKey:i,queryHash:o,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(a)),a}add(e){this.queriesMap[e.queryHash]||(this.queriesMap[e.queryHash]=e,this.queries.push(e),this.notify({type:"added",query:e}))}remove(e){const t=this.queriesMap[e.queryHash];t&&(e.destroy(),this.queries=this.queries.filter(r=>r!==e),t===e&&delete this.queriesMap[e.queryHash],this.notify({type:"removed",query:e}))}clear(){br.batch(()=>{this.queries.forEach(e=>{this.remove(e)})})}get(e){return this.queriesMap[e]}getAll(){return this.queries}find(e,t){const[r]=Da(e,t);return typeof r.exact>"u"&&(r.exact=!0),this.queries.find(s=>YN(r,s))}findAll(e,t){const[r]=Da(e,t);return Object.keys(r).length>0?this.queries.filter(s=>YN(r,s)):this.queries}notify(e){br.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){br.batch(()=>{this.queries.forEach(e=>{e.onFocus()})})}onOnline(){br.batch(()=>{this.queries.forEach(e=>{e.onOnline()})})}}var kW={NODE_ENV:"production"};class LW extends iO{constructor(e){super(),this.options={...e.defaultOptions,...e.options},this.mutationId=e.mutationId,this.mutationCache=e.mutationCache,this.logger=e.logger||ax,this.observers=[],this.state=e.state||oO(),this.updateCacheTime(this.options.cacheTime),this.scheduleGc()}get meta(){return this.options.meta}setState(e){this.dispatch({type:"setState",state:e})}addObserver(e){this.observers.indexOf(e)===-1&&(this.observers.push(e),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.observers=this.observers.filter(t=>t!==e),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.observers.length||(this.state.status==="loading"?this.scheduleGc():this.mutationCache.remove(this))}continue(){var e,t;return(e=(t=this.retryer)==null?void 0:t.continue())!=null?e:this.execute()}async execute(){const e=()=>{var E;return this.retryer=sO({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(C,R)=>{this.dispatch({type:"failed",failureCount:C,error:R})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:(E=this.options.retry)!=null?E:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},t=this.state.status==="loading";try{var r,s,i,o,a,l;if(!t){var c,d,f,p;this.dispatch({type:"loading",variables:this.options.variables}),await((c=(d=this.mutationCache.config).onMutate)==null?void 0:c.call(d,this.state.variables,this));const C=await((f=(p=this.options).onMutate)==null?void 0:f.call(p,this.state.variables));C!==this.state.context&&this.dispatch({type:"loading",context:C,variables:this.state.variables})}const E=await e();return await((r=(s=this.mutationCache.config).onSuccess)==null?void 0:r.call(s,E,this.state.variables,this.state.context,this)),await((i=(o=this.options).onSuccess)==null?void 0:i.call(o,E,this.state.variables,this.state.context)),await((a=(l=this.options).onSettled)==null?void 0:a.call(l,E,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:E}),E}catch(E){try{var m,g,v,y,b,S;throw await((m=(g=this.mutationCache.config).onError)==null?void 0:m.call(g,E,this.state.variables,this.state.context,this)),kW.NODE_ENV,await((v=(y=this.options).onError)==null?void 0:v.call(y,E,this.state.variables,this.state.context)),await((b=(S=this.options).onSettled)==null?void 0:b.call(S,void 0,E,this.state.variables,this.state.context)),E}finally{this.dispatch({type:"error",error:E})}}}dispatch(e){const t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"loading":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!Rp(this.options.networkMode),status:"loading",variables:e.variables};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"};case"setState":return{...r,...e.state}}};this.state=t(this.state),br.batch(()=>{this.observers.forEach(r=>{r.onMutationUpdate(e)}),this.mutationCache.notify({mutation:this,type:"updated",action:e})})}}function oO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class MW extends Dc{constructor(e){super(),this.config=e||{},this.mutations=[],this.mutationId=0}build(e,t,r){const s=new LW({mutationCache:this,logger:e.getLogger(),mutationId:++this.mutationId,options:e.defaultMutationOptions(t),state:r,defaultOptions:t.mutationKey?e.getMutationDefaults(t.mutationKey):void 0});return this.add(s),s}add(e){this.mutations.push(e),this.notify({type:"added",mutation:e})}remove(e){this.mutations=this.mutations.filter(t=>t!==e),this.notify({type:"removed",mutation:e})}clear(){br.batch(()=>{this.mutations.forEach(e=>{this.remove(e)})})}getAll(){return this.mutations}find(e){return typeof e.exact>"u"&&(e.exact=!0),this.mutations.find(t=>XN(e,t))}findAll(e){return this.mutations.filter(t=>XN(e,t))}notify(e){br.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){var e;return this.resuming=((e=this.resuming)!=null?e:Promise.resolve()).then(()=>{const t=this.mutations.filter(r=>r.state.isPaused);return br.batch(()=>t.reduce((r,s)=>r.then(()=>s.continue().catch(Ei)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function lx(){return{onFetch:n=>{n.fetchFn=()=>{var e,t,r,s,i,o;const a=(e=n.fetchOptions)==null||(t=e.meta)==null?void 0:t.refetchPage,l=(r=n.fetchOptions)==null||(s=r.meta)==null?void 0:s.fetchMore,c=l==null?void 0:l.pageParam,d=(l==null?void 0:l.direction)==="forward",f=(l==null?void 0:l.direction)==="backward",p=((i=n.state.data)==null?void 0:i.pages)||[],m=((o=n.state.data)==null?void 0:o.pageParams)||[];let g=m,v=!1;const y=I=>{Object.defineProperty(I,"signal",{enumerable:!0,get:()=>{var A;if((A=n.signal)!=null&&A.aborted)v=!0;else{var k;(k=n.signal)==null||k.addEventListener("abort",()=>{v=!0})}return n.signal}})},b=n.options.queryFn||(()=>Promise.reject("Missing queryFn")),S=(I,A,k,N)=>(g=N?[A,...g]:[...g,A],N?[k,...I]:[...I,k]),E=(I,A,k,N)=>{if(v)return Promise.reject("Cancelled");if(typeof k>"u"&&!A&&I.length)return Promise.resolve(I);const D={queryKey:n.queryKey,pageParam:k,meta:n.options.meta};y(D);const M=b(D);return Promise.resolve(M).then(U=>S(I,k,U,N))};let C;if(!p.length)C=E([]);else if(d){const I=typeof c<"u",A=I?c:cx(n.options,p);C=E(p,I,A)}else if(f){const I=typeof c<"u",A=I?c:aO(n.options,p);C=E(p,I,A,!0)}else{g=[];const I=typeof n.options.getNextPageParam>"u";C=(a&&p[0]?a(p[0],0,p):!0)?E([],I,m[0]):Promise.resolve(S([],m[0],p[0]));for(let k=1;k<p.length;k++)C=C.then(N=>{if(a&&p[k]?a(p[k],k,p):!0){const M=I?m[k]:cx(n.options,N);return E(N,I,M)}return Promise.resolve(S(N,m[k],p[k]))})}return C.then(I=>({pages:I,pageParams:g}))}}}}function cx(n,e){return n.getNextPageParam==null?void 0:n.getNextPageParam(e[e.length-1],e)}function aO(n,e){return n.getPreviousPageParam==null?void 0:n.getPreviousPageParam(e[0],e)}function NW(n,e){if(n.getNextPageParam&&Array.isArray(e)){const t=cx(n,e);return typeof t<"u"&&t!==null&&t!==!1}}function OW(n,e){if(n.getPreviousPageParam&&Array.isArray(e)){const t=aO(n,e);return typeof t<"u"&&t!==null&&t!==!1}}class PW{constructor(e={}){this.queryCache=e.queryCache||new AW,this.mutationCache=e.mutationCache||new MW,this.logger=e.logger||ax,this.defaultOptions=e.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,this.mountCount===1&&(this.unsubscribeFocus=Cp.subscribe(()=>{Cp.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=Ip.subscribe(()=>{Ip.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var e,t;this.mountCount--,this.mountCount===0&&((e=this.unsubscribeFocus)==null||e.call(this),this.unsubscribeFocus=void 0,(t=this.unsubscribeOnline)==null||t.call(this),this.unsubscribeOnline=void 0)}isFetching(e,t){const[r]=Da(e,t);return r.fetchStatus="fetching",this.queryCache.findAll(r).length}isMutating(e){return this.mutationCache.findAll({...e,fetching:!0}).length}getQueryData(e,t){var r;return(r=this.queryCache.find(e,t))==null?void 0:r.state.data}ensureQueryData(e,t,r){const s=jc(e,t,r),i=this.getQueryData(s.queryKey);return i?Promise.resolve(i):this.fetchQuery(s)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:r})=>{const s=r.data;return[t,s]})}setQueryData(e,t,r){const s=this.queryCache.find(e),i=s==null?void 0:s.state.data,o=bW(t,i);if(typeof o>"u")return;const a=jc(e),l=this.defaultQueryOptions(a);return this.queryCache.build(this,l).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return br.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,r)]))}getQueryState(e,t){var r;return(r=this.queryCache.find(e,t))==null?void 0:r.state}removeQueries(e,t){const[r]=Da(e,t),s=this.queryCache;br.batch(()=>{s.findAll(r).forEach(i=>{s.remove(i)})})}resetQueries(e,t,r){const[s,i]=Da(e,t,r),o=this.queryCache,a={type:"active",...s};return br.batch(()=>(o.findAll(s).forEach(l=>{l.reset()}),this.refetchQueries(a,i)))}cancelQueries(e,t,r){const[s,i={}]=Da(e,t,r);typeof i.revert>"u"&&(i.revert=!0);const o=br.batch(()=>this.queryCache.findAll(s).map(a=>a.cancel(i)));return Promise.all(o).then(Ei).catch(Ei)}invalidateQueries(e,t,r){const[s,i]=Da(e,t,r);return br.batch(()=>{var o,a;if(this.queryCache.findAll(s).forEach(c=>{c.invalidate()}),s.refetchType==="none")return Promise.resolve();const l={...s,type:(o=(a=s.refetchType)!=null?a:s.type)!=null?o:"active"};return this.refetchQueries(l,i)})}refetchQueries(e,t,r){const[s,i]=Da(e,t,r),o=br.batch(()=>this.queryCache.findAll(s).filter(l=>!l.isDisabled()).map(l=>{var c;return l.fetch(void 0,{...i,cancelRefetch:(c=i==null?void 0:i.cancelRefetch)!=null?c:!0,meta:{refetchPage:s.refetchPage}})}));let a=Promise.all(o).then(Ei);return i!=null&&i.throwOnError||(a=a.catch(Ei)),a}fetchQuery(e,t,r){const s=jc(e,t,r),i=this.defaultQueryOptions(s);typeof i.retry>"u"&&(i.retry=!1);const o=this.queryCache.build(this,i);return o.isStaleByTime(i.staleTime)?o.fetch(i):Promise.resolve(o.state.data)}prefetchQuery(e,t,r){return this.fetchQuery(e,t,r).then(Ei).catch(Ei)}fetchInfiniteQuery(e,t,r){const s=jc(e,t,r);return s.behavior=lx(),this.fetchQuery(s)}prefetchInfiniteQuery(e,t,r){return this.fetchInfiniteQuery(e,t,r).then(Ei).catch(Ei)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(e){this.defaultOptions=e}setQueryDefaults(e,t){const r=this.queryDefaults.find(s=>Ml(e)===Ml(s.queryKey));r?r.defaultOptions=t:this.queryDefaults.push({queryKey:e,defaultOptions:t})}getQueryDefaults(e){if(!e)return;const t=this.queryDefaults.find(r=>Tp(e,r.queryKey));return t==null?void 0:t.defaultOptions}setMutationDefaults(e,t){const r=this.mutationDefaults.find(s=>Ml(e)===Ml(s.mutationKey));r?r.defaultOptions=t:this.mutationDefaults.push({mutationKey:e,defaultOptions:t})}getMutationDefaults(e){if(!e)return;const t=this.mutationDefaults.find(r=>Tp(e,r.mutationKey));return t==null?void 0:t.defaultOptions}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...this.defaultOptions.queries,...this.getQueryDefaults(e==null?void 0:e.queryKey),...e,_defaulted:!0};return!t.queryHash&&t.queryKey&&(t.queryHash=rx(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.useErrorBoundary>"u"&&(t.useErrorBoundary=!!t.suspense),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...this.defaultOptions.mutations,...this.getMutationDefaults(e==null?void 0:e.mutationKey),...e,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}class lO extends Dc{constructor(e,t){super(),this.client=e,this.options=t,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.length===1&&(this.currentQuery.addObserver(this),cO(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.listeners.length||this.destroy()}shouldFetchOnReconnect(){return ux(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ux(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=[],this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(e,t){const r=this.options,s=this.currentQuery;if(this.options=this.client.defaultQueryOptions(e),sx(r,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),this.updateQuery();const i=this.hasListeners();i&&uO(this.currentQuery,s,this.options,r)&&this.executeFetch(),this.updateResult(t),i&&(this.currentQuery!==s||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&this.updateStaleTimeout();const o=this.computeRefetchInterval();i&&(this.currentQuery!==s||this.options.enabled!==r.enabled||o!==this.currentRefetchInterval)&&this.updateRefetchInterval(o)}getOptimisticResult(e){const t=this.client.getQueryCache().build(this.client,e);return this.createResult(t,e)}getCurrentResult(){return this.currentResult}trackResult(e){const t={};return Object.keys(e).forEach(r=>{Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(r),e[r])})}),t}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:e,...t}={}){return this.fetch({...t,meta:{refetchPage:e}})}fetchOptimistic(e){const t=this.client.defaultQueryOptions(e),r=this.client.getQueryCache().build(this.client,t);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,t))}fetch(e){var t;return this.executeFetch({...e,cancelRefetch:(t=e.cancelRefetch)!=null?t:!0}).then(()=>(this.updateResult(),this.currentResult))}executeFetch(e){this.updateQuery();let t=this.currentQuery.fetch(this.options,e);return e!=null&&e.throwOnError||(t=t.catch(Ei)),t}updateStaleTimeout(){if(this.clearStaleTimeout(),nf||this.currentResult.isStale||!nx(this.options.staleTime))return;const t=KN(this.currentResult.dataUpdatedAt,this.options.staleTime)+1;this.staleTimeoutId=setTimeout(()=>{this.currentResult.isStale||this.updateResult()},t)}computeRefetchInterval(){var e;return typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.currentResult.data,this.currentQuery):(e=this.options.refetchInterval)!=null?e:!1}updateRefetchInterval(e){this.clearRefetchInterval(),this.currentRefetchInterval=e,!(nf||this.options.enabled===!1||!nx(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(()=>{(this.options.refetchIntervalInBackground||Cp.isFocused())&&this.executeFetch()},this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(e,t){const r=this.currentQuery,s=this.options,i=this.currentResult,o=this.currentResultState,a=this.currentResultOptions,l=e!==r,c=l?e.state:this.currentQueryInitialState,d=l?this.currentResult:this.previousQueryResult,{state:f}=e;let{dataUpdatedAt:p,error:m,errorUpdatedAt:g,fetchStatus:v,status:y}=f,b=!1,S=!1,E;if(t._optimisticResults){const k=this.hasListeners(),N=!k&&cO(e,t),D=k&&uO(e,r,t,s);(N||D)&&(v=Rp(e.options.networkMode)?"fetching":"paused",p||(y="loading")),t._optimisticResults==="isRestoring"&&(v="idle")}if(t.keepPreviousData&&!f.dataUpdatedAt&&d!=null&&d.isSuccess&&y!=="error")E=d.data,p=d.dataUpdatedAt,y=d.status,b=!0;else if(t.select&&typeof f.data<"u")if(i&&f.data===(o==null?void 0:o.data)&&t.select===this.selectFn)E=this.selectResult;else try{this.selectFn=t.select,E=t.select(f.data),E=ox(i==null?void 0:i.data,E,t),this.selectResult=E,this.selectError=null}catch(k){this.selectError=k}else E=f.data;if(typeof t.placeholderData<"u"&&typeof E>"u"&&y==="loading"){let k;if(i!=null&&i.isPlaceholderData&&t.placeholderData===(a==null?void 0:a.placeholderData))k=i.data;else if(k=typeof t.placeholderData=="function"?t.placeholderData():t.placeholderData,t.select&&typeof k<"u")try{k=t.select(k),this.selectError=null}catch(N){this.selectError=N}typeof k<"u"&&(y="success",E=ox(i==null?void 0:i.data,k,t),S=!0)}this.selectError&&(m=this.selectError,E=this.selectResult,g=Date.now(),y="error");const C=v==="fetching",R=y==="loading",I=y==="error";return{status:y,fetchStatus:v,isLoading:R,isSuccess:y==="success",isError:I,isInitialLoading:R&&C,data:E,dataUpdatedAt:p,error:m,errorUpdatedAt:g,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>c.dataUpdateCount||f.errorUpdateCount>c.errorUpdateCount,isFetching:C,isRefetching:C&&!R,isLoadingError:I&&f.dataUpdatedAt===0,isPaused:v==="paused",isPlaceholderData:S,isPreviousData:b,isRefetchError:I&&f.dataUpdatedAt!==0,isStale:dx(e,t),refetch:this.refetch,remove:this.remove}}updateResult(e){const t=this.currentResult,r=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,sx(r,t))return;this.currentResult=r;const s={cache:!0},i=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options;if(o==="all"||!o&&!this.trackedProps.size)return!0;const a=new Set(o??this.trackedProps);return this.options.useErrorBoundary&&a.add("error"),Object.keys(this.currentResult).some(l=>{const c=l;return this.currentResult[c]!==t[c]&&a.has(c)})};(e==null?void 0:e.listeners)!==!1&&i()&&(s.listeners=!0),this.notify({...s,...e})}updateQuery(){const e=this.client.getQueryCache().build(this.client,this.options);if(e===this.currentQuery)return;const t=this.currentQuery;this.currentQuery=e,this.currentQueryInitialState=e.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(t==null||t.removeObserver(this),e.addObserver(this))}onQueryUpdate(e){const t={};e.type==="success"?t.onSuccess=!e.manual:e.type==="error"&&!Ap(e.error)&&(t.onError=!0),this.updateResult(t),this.hasListeners()&&this.updateTimers()}notify(e){br.batch(()=>{if(e.onSuccess){var t,r,s,i;(t=(r=this.options).onSuccess)==null||t.call(r,this.currentResult.data),(s=(i=this.options).onSettled)==null||s.call(i,this.currentResult.data,null)}else if(e.onError){var o,a,l,c;(o=(a=this.options).onError)==null||o.call(a,this.currentResult.error),(l=(c=this.options).onSettled)==null||l.call(c,void 0,this.currentResult.error)}e.listeners&&this.listeners.forEach(d=>{d(this.currentResult)}),e.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})})}}function DW(n,e){return e.enabled!==!1&&!n.state.dataUpdatedAt&&!(n.state.status==="error"&&e.retryOnMount===!1)}function cO(n,e){return DW(n,e)||n.state.dataUpdatedAt>0&&ux(n,e,e.refetchOnMount)}function ux(n,e,t){if(e.enabled!==!1){const r=typeof t=="function"?t(n):t;return r==="always"||r!==!1&&dx(n,e)}return!1}function uO(n,e,t,r){return t.enabled!==!1&&(n!==e||r.enabled===!1)&&(!t.suspense||n.state.status!=="error")&&dx(n,t)}function dx(n,e){return n.isStaleByTime(e.staleTime)}class jW extends lO{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,t){super.setOptions({...e,behavior:lx()},t)}getOptimisticResult(e){return e.behavior=lx(),super.getOptimisticResult(e)}fetchNextPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"forward",pageParam:e}}})}fetchPreviousPage({pageParam:e,...t}={}){return this.fetch({...t,meta:{fetchMore:{direction:"backward",pageParam:e}}})}createResult(e,t){var r,s,i,o,a,l;const{state:c}=e,d=super.createResult(e,t),{isFetching:f,isRefetching:p}=d,m=f&&((r=c.fetchMeta)==null||(s=r.fetchMore)==null?void 0:s.direction)==="forward",g=f&&((i=c.fetchMeta)==null||(o=i.fetchMore)==null?void 0:o.direction)==="backward";return{...d,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:NW(t,(a=c.data)==null?void 0:a.pages),hasPreviousPage:OW(t,(l=c.data)==null?void 0:l.pages),isFetchingNextPage:m,isFetchingPreviousPage:g,isRefetching:p&&!m&&!g}}}let FW=class extends Dc{constructor(e,t){super(),this.client=e,this.setOptions(t),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.client.defaultMutationOptions(e),sx(t,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this})}onUnsubscribe(){if(!this.listeners.length){var e;(e=this.currentMutation)==null||e.removeObserver(this)}}onMutationUpdate(e){this.updateResult();const t={listeners:!0};e.type==="success"?t.onSuccess=!0:e.type==="error"&&(t.onError=!0),this.notify(t)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(e,t){return this.mutateOptions=t,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:typeof e<"u"?e:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const e=this.currentMutation?this.currentMutation.state:oO(),t={...e,isLoading:e.status==="loading",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset};this.currentResult=t}notify(e){br.batch(()=>{if(this.mutateOptions&&this.hasListeners()){if(e.onSuccess){var t,r,s,i;(t=(r=this.mutateOptions).onSuccess)==null||t.call(r,this.currentResult.data,this.currentResult.variables,this.currentResult.context),(s=(i=this.mutateOptions).onSettled)==null||s.call(i,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)}else if(e.onError){var o,a,l,c;(o=(a=this.mutateOptions).onError)==null||o.call(a,this.currentResult.error,this.currentResult.variables,this.currentResult.context),(l=(c=this.mutateOptions).onSettled)==null||l.call(c,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}}e.listeners&&this.listeners.forEach(d=>{d(this.currentResult)})})}};var UW=XC();const dO=UW.useSyncExternalStore,fO=T.createContext(void 0),hO=T.createContext(!1);function pO(n,e){return n||(e&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=fO),window.ReactQueryClientContext):fO)}const Nl=({context:n}={})=>{const e=T.useContext(pO(n,T.useContext(hO)));if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},BW=({client:n,children:e,context:t,contextSharing:r=!1})=>{T.useEffect(()=>(n.mount(),()=>{n.unmount()}),[n]);const s=pO(t,r);return T.createElement(hO.Provider,{value:!t&&r},T.createElement(s.Provider,{value:n},e))},mO=T.createContext(!1),$W=()=>T.useContext(mO);mO.Provider;function zW(){let n=!1;return{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n}}const qW=T.createContext(zW()),HW=()=>T.useContext(qW);function gO(n,e){return typeof n=="function"?n(...e):!!n}const GW=(n,e)=>{(n.suspense||n.useErrorBoundary)&&(e.isReset()||(n.retryOnMount=!1))},VW=n=>{T.useEffect(()=>{n.clearReset()},[n])},WW=({result:n,errorResetBoundary:e,useErrorBoundary:t,query:r})=>n.isError&&!e.isReset()&&!n.isFetching&&gO(t,[n.error,r]),KW=n=>{n.suspense&&typeof n.staleTime!="number"&&(n.staleTime=1e3)},YW=(n,e)=>n.isLoading&&n.isFetching&&!e,XW=(n,e,t)=>(n==null?void 0:n.suspense)&&YW(e,t),QW=(n,e,t)=>e.fetchOptimistic(n).then(({data:r})=>{n.onSuccess==null||n.onSuccess(r),n.onSettled==null||n.onSettled(r,null)}).catch(r=>{t.clearReset(),n.onError==null||n.onError(r),n.onSettled==null||n.onSettled(void 0,r)});function _O(n,e){const t=Nl({context:n.context}),r=$W(),s=HW(),i=t.defaultQueryOptions(n);i._optimisticResults=r?"isRestoring":"optimistic",i.onError&&(i.onError=br.batchCalls(i.onError)),i.onSuccess&&(i.onSuccess=br.batchCalls(i.onSuccess)),i.onSettled&&(i.onSettled=br.batchCalls(i.onSettled)),KW(i),GW(i,s),VW(s);const[o]=T.useState(()=>new e(t,i)),a=o.getOptimisticResult(i);if(dO(T.useCallback(l=>r?()=>{}:o.subscribe(br.batchCalls(l)),[o,r]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),T.useEffect(()=>{o.setOptions(i,{listeners:!1})},[i,o]),XW(i,a,r))throw QW(i,o,s);if(WW({result:a,errorResetBoundary:s,useErrorBoundary:i.useErrorBoundary,query:o.getCurrentQuery()}))throw a.error;return i.notifyOnChangeProps?a:o.trackResult(a)}function JW(n,e,t){const r=jc(n,e,t);return _O(r,lO)}function ZW(n,e,t){const r=xW(n,e,t),s=Nl({context:r.context}),[i]=T.useState(()=>new FW(s,r));T.useEffect(()=>{i.setOptions(r)},[i,r]);const o=dO(T.useCallback(l=>i.subscribe(br.batchCalls(l)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),a=T.useCallback((l,c)=>{i.mutate(l,c).catch(e7)},[i]);if(o.error&&gO(i.options.useErrorBoundary,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}function e7(){}function vO(n,e,t){const r=jc(n,e,t);return _O(r,jW)}const Gn=(n,e,t={})=>JW(n,e,t),Yn=(n,e={})=>ZW(n,e),kp=n=>vO(n),Dt={SENT:"SENT",ERROR:"ERROR",DELETED:"DELETED",SENDING:"SENDING"},Lp={POSTED:3238,REFUND:3233,PROBLEM:5056,SATISFIED:3195},yO={ACCEPTED:"accepted",REJECTED:"rejected"},t7={AVAILABLE:2976},n7={ACTIVE:2987},fx={CONVERSATION_USER:5798},r7={SPAM:5},Ol={CONNECTED:"connected",DISCONNECTED:"disconnected"},Zi={CHANNEL:"CHANNEL",NOTIFICATION:"NOTIFICATION",SUPPORT:"BASALAM_SUPPORT_CHANNEL"},Bt={BOT:"bot",GROUP:"group",PRIVATE:"private",CHANNEL:"channel"},Fc={BLOCK:"block",UNBLOCK:"unblock",MARK_READ:"mark_read",MARK_UNREAD:"mark_unread"},Fe={TEXT:"text",FILE:"file",USER:"user",VOICE:"voice",ORDER:"order",VIDEO:"video",STORY:"story",REVIEW:"review",VENDOR:"vendor",COUPON:"coupon",FACTOR:"factor",PRODUCT:"product",STICKER:"sticker",PICTURE:"picture",AGREEMENT:"agreement",CALL:"voice_call_phone",SOCIAL_POST:"social_post",NOTIFICATION:"notification",ORDER_PROCESS:"order_process"},Mp={URL:"url",CALLBACK:"cb",MESSAGE:"msg"},hx={CHAT_FILE:"chat.file",CHAT_PHOTO:"chat.photo",CHAT_VIDEO:"chat.video",CHAT_VOICE:"chat.voice"},ja={LESS_THAN:"lt",GREATER_THAN:"gt",LESS_THAN_OR_EQUAL:"lte"},px={DESC:"desc"},Ct={NEW_MESSAGE:"new-message",SENDER_SEEN:"sender-seen",MESSAGE_SEEN:"message-seen",MESSAGE_EDITED:"message-edited",MESSAGE_DELETED:"message-deleted",UPDATE_CHAT_INFO:"update-chat-info",UPDATE_CHAT_LIST:"update-chat-list",BROADCAST_TO_ALL:"broadcast-to-all",NEW_MESSAGE_TOAST:"new-message-toast",PUBLISH_TO_SOCKET:"publish-to-socket",ADD_EVENT_LISTENER:"add-event-listener",SENDER_CHAT_SEEN_ALL:"sender-chat-seen-all",RECEIVER_CHAT_SEEN_ALL:"receiver-chat-seen-all",UPDATE_CHAT_LIST_BY_ID:"update-chat-list-by-id",UPDATE_LAST_SEEN_MESSAGE:"update-last-seen-message",UPDATE_CHAT_LIST_BY_SOCKET:"update-chat-list-by-socket",UPDATE_CHAT_LIST_LAST_MESSAGE:"update-chat-list-last-message"},Fa={SHOW_CES_MODAL:"show-ces-modal",OPEN_SHOW_FOLLOWERS:"open-show-followers",SHOW_REPORT_CONTENT_MODAL:"show-report-content-modal",SHOW_ADD_OR_EDIT_REVIEW_MODAL:"show-add-or-edit-review-modal"},Uc={CHAT_SEEN:"chat.seen",MESSAGE_SEEN:"message.seen",MESSAGE_NEW:"message.new.notify",CHAT_SEEN_NOTIFY:"chat.seen.notify",MESSAGE_SEEN_NOTIFY:"message.seen.notify",CHAT_LAST_SEEN_NOTIFY:"chat.last_seen.notify"},Bc={INFO:"info",REVIEW:"review",SUCCESS:"success"},s7={PRIMARY:"primary"},Wr={REVIEW:"review",OPEN_LINK:"open-link",ACCEPT_REQUEST:"accept-request",REJECT_REQUEST:"reject-request"},i7={SATISFACTION:4228},bO={PAID:2,PAYMENT_WAITING:3};function xO(n,e){return function(){return n.apply(e,arguments)}}const{toString:o7}=Object.prototype,{getPrototypeOf:mx}=Object,{iterator:Np,toStringTag:SO}=Symbol,Op=(n=>e=>{const t=o7.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),eo=n=>(n=n.toLowerCase(),e=>Op(e)===n),Pp=n=>e=>typeof e===n,{isArray:$c}=Array,sf=Pp("undefined");function a7(n){return n!==null&&!sf(n)&&n.constructor!==null&&!sf(n.constructor)&&Hs(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const EO=eo("ArrayBuffer");function l7(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&EO(n.buffer),e}const c7=Pp("string"),Hs=Pp("function"),wO=Pp("number"),Dp=n=>n!==null&&typeof n=="object",u7=n=>n===!0||n===!1,jp=n=>{if(Op(n)!=="object")return!1;const e=mx(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(SO in n)&&!(Np in n)},d7=eo("Date"),f7=eo("File"),h7=eo("Blob"),p7=eo("FileList"),m7=n=>Dp(n)&&Hs(n.pipe),g7=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||Hs(n.append)&&((e=Op(n))==="formdata"||e==="object"&&Hs(n.toString)&&n.toString()==="[object FormData]"))},_7=eo("URLSearchParams"),[v7,y7,b7,x7]=["ReadableStream","Request","Response","Headers"].map(eo),S7=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function of(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let r,s;if(typeof n!="object"&&(n=[n]),$c(n))for(r=0,s=n.length;r<s;r++)e.call(null,n[r],r,n);else{const i=t?Object.getOwnPropertyNames(n):Object.keys(n),o=i.length;let a;for(r=0;r<o;r++)a=i[r],e.call(null,n[a],a,n)}}function TO(n,e){e=e.toLowerCase();const t=Object.keys(n);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const Pl=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,CO=n=>!sf(n)&&n!==Pl;function gx(){const{caseless:n}=CO(this)&&this||{},e={},t=(r,s)=>{const i=n&&TO(e,s)||s;jp(e[i])&&jp(r)?e[i]=gx(e[i],r):jp(r)?e[i]=gx({},r):$c(r)?e[i]=r.slice():e[i]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&of(arguments[r],t);return e}const E7=(n,e,t,{allOwnKeys:r}={})=>(of(e,(s,i)=>{t&&Hs(s)?n[i]=xO(s,t):n[i]=s},{allOwnKeys:r}),n),w7=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),T7=(n,e,t,r)=>{n.prototype=Object.create(e.prototype,r),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},C7=(n,e,t,r)=>{let s,i,o;const a={};if(e=e||{},n==null)return e;do{for(s=Object.getOwnPropertyNames(n),i=s.length;i-- >0;)o=s[i],(!r||r(o,n,e))&&!a[o]&&(e[o]=n[o],a[o]=!0);n=t!==!1&&mx(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},I7=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const r=n.indexOf(e,t);return r!==-1&&r===t},R7=n=>{if(!n)return null;if($c(n))return n;let e=n.length;if(!wO(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},A7=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&mx(Uint8Array)),k7=(n,e)=>{const r=(n&&n[Np]).call(n);let s;for(;(s=r.next())&&!s.done;){const i=s.value;e.call(n,i[0],i[1])}},L7=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},M7=eo("HTMLFormElement"),N7=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),IO=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),O7=eo("RegExp"),RO=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),r={};of(t,(s,i)=>{let o;(o=e(s,i,n))!==!1&&(r[i]=o||s)}),Object.defineProperties(n,r)},P7=n=>{RO(n,(e,t)=>{if(Hs(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=n[t];if(Hs(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},D7=(n,e)=>{const t={},r=s=>{s.forEach(i=>{t[i]=!0})};return $c(n)?r(n):r(String(n).split(e)),t},j7=()=>{},F7=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function U7(n){return!!(n&&Hs(n.append)&&n[SO]==="FormData"&&n[Np])}const B7=n=>{const e=new Array(10),t=(r,s)=>{if(Dp(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[s]=r;const i=$c(r)?[]:{};return of(r,(o,a)=>{const l=t(o,s+1);!sf(l)&&(i[a]=l)}),e[s]=void 0,i}}return r};return t(n,0)},$7=eo("AsyncFunction"),z7=n=>n&&(Dp(n)||Hs(n))&&Hs(n.then)&&Hs(n.catch),AO=((n,e)=>n?setImmediate:e?((t,r)=>(Pl.addEventListener("message",({source:s,data:i})=>{s===Pl&&i===t&&r.length&&r.shift()()},!1),s=>{r.push(s),Pl.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Hs(Pl.postMessage)),q7=typeof queueMicrotask<"u"?queueMicrotask.bind(Pl):typeof process<"u"&&process.nextTick||AO,ke={isArray:$c,isArrayBuffer:EO,isBuffer:a7,isFormData:g7,isArrayBufferView:l7,isString:c7,isNumber:wO,isBoolean:u7,isObject:Dp,isPlainObject:jp,isReadableStream:v7,isRequest:y7,isResponse:b7,isHeaders:x7,isUndefined:sf,isDate:d7,isFile:f7,isBlob:h7,isRegExp:O7,isFunction:Hs,isStream:m7,isURLSearchParams:_7,isTypedArray:A7,isFileList:p7,forEach:of,merge:gx,extend:E7,trim:S7,stripBOM:w7,inherits:T7,toFlatObject:C7,kindOf:Op,kindOfTest:eo,endsWith:I7,toArray:R7,forEachEntry:k7,matchAll:L7,isHTMLForm:M7,hasOwnProperty:IO,hasOwnProp:IO,reduceDescriptors:RO,freezeMethods:P7,toObjectSet:D7,toCamelCase:N7,noop:j7,toFiniteNumber:F7,findKey:TO,global:Pl,isContextDefined:CO,isSpecCompliantForm:U7,toJSONObject:B7,isAsyncFn:$7,isThenable:z7,setImmediate:AO,asap:q7,isIterable:n=>n!=null&&Hs(n[Np])};function ln(n,e,t,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}ke.inherits(ln,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ke.toJSONObject(this.config),code:this.code,status:this.status}}});const kO=ln.prototype,LO={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{LO[n]={value:n}}),Object.defineProperties(ln,LO),Object.defineProperty(kO,"isAxiosError",{value:!0}),ln.from=(n,e,t,r,s,i)=>{const o=Object.create(kO);return ke.toFlatObject(n,o,function(l){return l!==Error.prototype},a=>a!=="isAxiosError"),ln.call(o,n.message,e,t,r,s),o.cause=n,o.name=n.name,i&&Object.assign(o,i),o};const H7=null;function _x(n){return ke.isPlainObject(n)||ke.isArray(n)}function MO(n){return ke.endsWith(n,"[]")?n.slice(0,-2):n}function NO(n,e,t){return n?n.concat(e).map(function(s,i){return s=MO(s),!t&&i?"["+s+"]":s}).join(t?".":""):e}function G7(n){return ke.isArray(n)&&!n.some(_x)}const V7=ke.toFlatObject(ke,{},null,function(e){return/^is[A-Z]/.test(e)});function Fp(n,e,t){if(!ke.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=ke.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,y){return!ke.isUndefined(y[v])});const r=t.metaTokens,s=t.visitor||d,i=t.dots,o=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&ke.isSpecCompliantForm(e);if(!ke.isFunction(s))throw new TypeError("visitor must be a function");function c(g){if(g===null)return"";if(ke.isDate(g))return g.toISOString();if(!l&&ke.isBlob(g))throw new ln("Blob is not supported. Use a Buffer instead.");return ke.isArrayBuffer(g)||ke.isTypedArray(g)?l&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function d(g,v,y){let b=g;if(g&&!y&&typeof g=="object"){if(ke.endsWith(v,"{}"))v=r?v:v.slice(0,-2),g=JSON.stringify(g);else if(ke.isArray(g)&&G7(g)||(ke.isFileList(g)||ke.endsWith(v,"[]"))&&(b=ke.toArray(g)))return v=MO(v),b.forEach(function(E,C){!(ke.isUndefined(E)||E===null)&&e.append(o===!0?NO([v],C,i):o===null?v:v+"[]",c(E))}),!1}return _x(g)?!0:(e.append(NO(y,v,i),c(g)),!1)}const f=[],p=Object.assign(V7,{defaultVisitor:d,convertValue:c,isVisitable:_x});function m(g,v){if(!ke.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(g),ke.forEach(g,function(b,S){(!(ke.isUndefined(b)||b===null)&&s.call(e,b,ke.isString(S)?S.trim():S,v,p))===!0&&m(b,v?v.concat(S):[S])}),f.pop()}}if(!ke.isObject(n))throw new TypeError("data must be an object");return m(n),e}function OO(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function vx(n,e){this._pairs=[],n&&Fp(n,this,e)}const PO=vx.prototype;PO.append=function(e,t){this._pairs.push([e,t])},PO.toString=function(e){const t=e?function(r){return e.call(this,r,OO)}:OO;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function W7(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function DO(n,e,t){if(!e)return n;const r=t&&t.encode||W7;ke.isFunction(t)&&(t={serialize:t});const s=t&&t.serialize;let i;if(s?i=s(e,t):i=ke.isURLSearchParams(e)?e.toString():new vx(e,t).toString(r),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class jO{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ke.forEach(this.handlers,function(r){r!==null&&e(r)})}}const FO={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},K7={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:vx,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yx=typeof window<"u"&&typeof document<"u",bx=typeof navigator=="object"&&navigator||void 0,Y7=yx&&(!bx||["ReactNative","NativeScript","NS"].indexOf(bx.product)<0),X7=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Q7=yx&&window.location.href||"http://localhost",bs={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yx,hasStandardBrowserEnv:Y7,hasStandardBrowserWebWorkerEnv:X7,navigator:bx,origin:Q7},Symbol.toStringTag,{value:"Module"})),...K7};function J7(n,e){return Fp(n,new bs.classes.URLSearchParams,Object.assign({visitor:function(t,r,s,i){return bs.isNode&&ke.isBuffer(t)?(this.append(r,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function Z7(n){return ke.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function eK(n){const e={},t=Object.keys(n);let r;const s=t.length;let i;for(r=0;r<s;r++)i=t[r],e[i]=n[i];return e}function UO(n){function e(t,r,s,i){let o=t[i++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),l=i>=t.length;return o=!o&&ke.isArray(s)?s.length:o,l?(ke.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!a):((!s[o]||!ke.isObject(s[o]))&&(s[o]=[]),e(t,r,s[o],i)&&ke.isArray(s[o])&&(s[o]=eK(s[o])),!a)}if(ke.isFormData(n)&&ke.isFunction(n.entries)){const t={};return ke.forEachEntry(n,(r,s)=>{e(Z7(r),s,t,0)}),t}return null}function tK(n,e,t){if(ke.isString(n))try{return(e||JSON.parse)(n),ke.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(n)}const af={transitional:FO,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,i=ke.isObject(e);if(i&&ke.isHTMLForm(e)&&(e=new FormData(e)),ke.isFormData(e))return s?JSON.stringify(UO(e)):e;if(ke.isArrayBuffer(e)||ke.isBuffer(e)||ke.isStream(e)||ke.isFile(e)||ke.isBlob(e)||ke.isReadableStream(e))return e;if(ke.isArrayBufferView(e))return e.buffer;if(ke.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return J7(e,this.formSerializer).toString();if((a=ke.isFileList(e))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fp(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return i||s?(t.setContentType("application/json",!1),tK(e)):e}],transformResponse:[function(e){const t=this.transitional||af.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(ke.isResponse(e)||ke.isReadableStream(e))return e;if(e&&ke.isString(e)&&(r&&!this.responseType||s)){const o=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?ln.from(a,ln.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:bs.classes.FormData,Blob:bs.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ke.forEach(["delete","get","head","post","put","patch"],n=>{af.headers[n]={}});const nK=ke.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),rK=n=>{const e={};let t,r,s;return n&&n.split(`
285 `).forEach(function(o){s=o.indexOf(":"),t=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!t||e[t]&&nK[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},BO=Symbol("internals");function lf(n){return n&&String(n).trim().toLowerCase()}function Up(n){return n===!1||n==null?n:ke.isArray(n)?n.map(Up):String(n)}function sK(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(n);)e[r[1]]=r[2];return e}const iK=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function xx(n,e,t,r,s){if(ke.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!ke.isString(e)){if(ke.isString(r))return e.indexOf(r)!==-1;if(ke.isRegExp(r))return r.test(e)}}function oK(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function aK(n,e){const t=ke.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(n,r+t,{value:function(s,i,o){return this[r].call(this,e,s,i,o)},configurable:!0})})}let Gs=class{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function i(a,l,c){const d=lf(l);if(!d)throw new Error("header name must be a non-empty string");const f=ke.findKey(s,d);(!f||s[f]===void 0||c===!0||c===void 0&&s[f]!==!1)&&(s[f||l]=Up(a))}const o=(a,l)=>ke.forEach(a,(c,d)=>i(c,d,l));if(ke.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(ke.isString(e)&&(e=e.trim())&&!iK(e))o(rK(e),t);else if(ke.isObject(e)&&ke.isIterable(e)){let a={},l,c;for(const d of e){if(!ke.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?ke.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}o(a,t)}else e!=null&&i(t,e,r);return this}get(e,t){if(e=lf(e),e){const r=ke.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return sK(s);if(ke.isFunction(t))return t.call(this,s,r);if(ke.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=lf(e),e){const r=ke.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||xx(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function i(o){if(o=lf(o),o){const a=ke.findKey(r,o);a&&(!t||xx(r,r[a],a,t))&&(delete r[a],s=!0)}}return ke.isArray(e)?e.forEach(i):i(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const i=t[r];(!e||xx(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){const t=this,r={};return ke.forEach(this,(s,i)=>{const o=ke.findKey(r,i);if(o){t[o]=Up(s),delete t[i];return}const a=e?oK(i):String(i).trim();a!==i&&delete t[i],t[a]=Up(s),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ke.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&ke.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
286 `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[BO]=this[BO]={accessors:{}}).accessors,s=this.prototype;function i(o){const a=lf(o);r[a]||(aK(s,o),r[a]=!0)}return ke.isArray(e)?e.forEach(i):i(e),this}};Gs.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ke.reduceDescriptors(Gs.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(r){this[t]=r}}}),ke.freezeMethods(Gs);function Sx(n,e){const t=this||af,r=e||t,s=Gs.from(r.headers);let i=r.data;return ke.forEach(n,function(a){i=a.call(t,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function $O(n){return!!(n&&n.__CANCEL__)}function zc(n,e,t){ln.call(this,n??"canceled",ln.ERR_CANCELED,e,t),this.name="CanceledError"}ke.inherits(zc,ln,{__CANCEL__:!0});function zO(n,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?n(t):e(new ln("Request failed with status code "+t.status,[ln.ERR_BAD_REQUEST,ln.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function lK(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function cK(n,e){n=n||10;const t=new Array(n),r=new Array(n);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),d=r[i];o||(o=c),t[s]=l,r[s]=c;let f=i,p=0;for(;f!==s;)p+=t[f++],f=f%n;if(s=(s+1)%n,s===i&&(i=(i+1)%n),c-o<e)return;const m=d&&c-d;return m?Math.round(p*1e3/m):void 0}}function uK(n,e){let t=0,r=1e3/e,s,i;const o=(c,d=Date.now())=>{t=d,s=null,i&&(clearTimeout(i),i=null),n.apply(null,c)};return[(...c)=>{const d=Date.now(),f=d-t;f>=r?o(c,d):(s=c,i||(i=setTimeout(()=>{i=null,o(s)},r-f)))},()=>s&&o(s)]}const Bp=(n,e,t=3)=>{let r=0;const s=cK(50,250);return uK(i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,l=o-r,c=s(l),d=o<=a;r=o;const f={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-o)/c:void 0,event:i,lengthComputable:a!=null,[e?"download":"upload"]:!0};n(f)},t)},qO=(n,e)=>{const t=n!=null;return[r=>e[0]({lengthComputable:t,total:n,loaded:r}),e[1]]},HO=n=>(...e)=>ke.asap(()=>n(...e)),dK=bs.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,bs.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(bs.origin),bs.navigator&&/(msie|trident)/i.test(bs.navigator.userAgent)):()=>!0,fK=bs.hasStandardBrowserEnv?{write(n,e,t,r,s,i){const o=[n+"="+encodeURIComponent(e)];ke.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),ke.isString(r)&&o.push("path="+r),ke.isString(s)&&o.push("domain="+s),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(n){const e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function hK(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function pK(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function GO(n,e,t){let r=!hK(e);return n&&(r||t==!1)?pK(n,e):e}const VO=n=>n instanceof Gs?{...n}:n;function Dl(n,e){e=e||{};const t={};function r(c,d,f,p){return ke.isPlainObject(c)&&ke.isPlainObject(d)?ke.merge.call({caseless:p},c,d):ke.isPlainObject(d)?ke.merge({},d):ke.isArray(d)?d.slice():d}function s(c,d,f,p){if(ke.isUndefined(d)){if(!ke.isUndefined(c))return r(void 0,c,f,p)}else return r(c,d,f,p)}function i(c,d){if(!ke.isUndefined(d))return r(void 0,d)}function o(c,d){if(ke.isUndefined(d)){if(!ke.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in e)return r(c,d);if(f in n)return r(void 0,c)}const l={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,d,f)=>s(VO(c),VO(d),f,!0)};return ke.forEach(Object.keys(Object.assign({},n,e)),function(d){const f=l[d]||s,p=f(n[d],e[d],d);ke.isUndefined(p)&&f!==a||(t[d]=p)}),t}const WO=n=>{const e=Dl({},n);let{data:t,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:a}=e;e.headers=o=Gs.from(o),e.url=DO(GO(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let l;if(ke.isFormData(t)){if(bs.hasStandardBrowserEnv||bs.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((l=o.getContentType())!==!1){const[c,...d]=l?l.split(";").map(f=>f.trim()).filter(Boolean):[];o.setContentType([c||"multipart/form-data",...d].join("; "))}}if(bs.hasStandardBrowserEnv&&(r&&ke.isFunction(r)&&(r=r(e)),r||r!==!1&&dK(e.url))){const c=s&&i&&fK.read(i);c&&o.set(s,c)}return e},mK=typeof XMLHttpRequest<"u"&&function(n){return new Promise(function(t,r){const s=WO(n);let i=s.data;const o=Gs.from(s.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=s,d,f,p,m,g;function v(){m&&m(),g&&g(),s.cancelToken&&s.cancelToken.unsubscribe(d),s.signal&&s.signal.removeEventListener("abort",d)}let y=new XMLHttpRequest;y.open(s.method.toUpperCase(),s.url,!0),y.timeout=s.timeout;function b(){if(!y)return;const E=Gs.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),R={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:E,config:n,request:y};zO(function(A){t(A),v()},function(A){r(A),v()},R),y=null}"onloadend"in y?y.onloadend=b:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(b)},y.onabort=function(){y&&(r(new ln("Request aborted",ln.ECONNABORTED,n,y)),y=null)},y.onerror=function(){r(new ln("Network Error",ln.ERR_NETWORK,n,y)),y=null},y.ontimeout=function(){let C=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const R=s.transitional||FO;s.timeoutErrorMessage&&(C=s.timeoutErrorMessage),r(new ln(C,R.clarifyTimeoutError?ln.ETIMEDOUT:ln.ECONNABORTED,n,y)),y=null},i===void 0&&o.setContentType(null),"setRequestHeader"in y&&ke.forEach(o.toJSON(),function(C,R){y.setRequestHeader(R,C)}),ke.isUndefined(s.withCredentials)||(y.withCredentials=!!s.withCredentials),a&&a!=="json"&&(y.responseType=s.responseType),c&&([p,g]=Bp(c,!0),y.addEventListener("progress",p)),l&&y.upload&&([f,m]=Bp(l),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(s.cancelToken||s.signal)&&(d=E=>{y&&(r(!E||E.type?new zc(null,n,y):E),y.abort(),y=null)},s.cancelToken&&s.cancelToken.subscribe(d),s.signal&&(s.signal.aborted?d():s.signal.addEventListener("abort",d)));const S=lK(s.url);if(S&&bs.protocols.indexOf(S)===-1){r(new ln("Unsupported protocol "+S+":",ln.ERR_BAD_REQUEST,n));return}y.send(i||null)})},gK=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let r=new AbortController,s;const i=function(c){if(!s){s=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof ln?d:new zc(d instanceof Error?d.message:d))}};let o=e&&setTimeout(()=>{o=null,i(new ln(`timeout ${e} of ms exceeded`,ln.ETIMEDOUT))},e);const a=()=>{n&&(o&&clearTimeout(o),o=null,n.forEach(c=>{c.unsubscribe?c.unsubscribe(i):c.removeEventListener("abort",i)}),n=null)};n.forEach(c=>c.addEventListener("abort",i));const{signal:l}=r;return l.unsubscribe=()=>ke.asap(a),l}},_K=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let r=0,s;for(;r<t;)s=r+e,yield n.slice(r,s),r=s},vK=async function*(n,e){for await(const t of yK(n))yield*_K(t,e)},yK=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)break;yield r}}finally{await e.cancel()}},KO=(n,e,t,r)=>{const s=vK(n,e);let i=0,o,a=l=>{o||(o=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await s.next();if(c){a(),l.close();return}let f=d.byteLength;if(t){let p=i+=f;t(p)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),s.return()}},{highWaterMark:2})},$p=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",YO=$p&&typeof ReadableStream=="function",bK=$p&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),XO=(n,...e)=>{try{return!!n(...e)}catch{return!1}},xK=YO&&XO(()=>{let n=!1;const e=new Request(bs.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),QO=64*1024,Ex=YO&&XO(()=>ke.isReadableStream(new Response("").body)),zp={stream:Ex&&(n=>n.body)};$p&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!zp[e]&&(zp[e]=ke.isFunction(n[e])?t=>t[e]():(t,r)=>{throw new ln(`Response type '${e}' is not supported`,ln.ERR_NOT_SUPPORT,r)})})})(new Response);const SK=async n=>{if(n==null)return 0;if(ke.isBlob(n))return n.size;if(ke.isSpecCompliantForm(n))return(await new Request(bs.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(ke.isArrayBufferView(n)||ke.isArrayBuffer(n))return n.byteLength;if(ke.isURLSearchParams(n)&&(n=n+""),ke.isString(n))return(await bK(n)).byteLength},EK=async(n,e)=>{const t=ke.toFiniteNumber(n.getContentLength());return t??SK(e)},wx={http:H7,xhr:mK,fetch:$p&&(async n=>{let{url:e,method:t,data:r,signal:s,cancelToken:i,timeout:o,onDownloadProgress:a,onUploadProgress:l,responseType:c,headers:d,withCredentials:f="same-origin",fetchOptions:p}=WO(n);c=c?(c+"").toLowerCase():"text";let m=gK([s,i&&i.toAbortSignal()],o),g;const v=m&&m.unsubscribe&&(()=>{m.unsubscribe()});let y;try{if(l&&xK&&t!=="get"&&t!=="head"&&(y=await EK(d,r))!==0){let R=new Request(e,{method:"POST",body:r,duplex:"half"}),I;if(ke.isFormData(r)&&(I=R.headers.get("content-type"))&&d.setContentType(I),R.body){const[A,k]=qO(y,Bp(HO(l)));r=KO(R.body,QO,A,k)}}ke.isString(f)||(f=f?"include":"omit");const b="credentials"in Request.prototype;g=new Request(e,{...p,signal:m,method:t.toUpperCase(),headers:d.normalize().toJSON(),body:r,duplex:"half",credentials:b?f:void 0});let S=await fetch(g);const E=Ex&&(c==="stream"||c==="response");if(Ex&&(a||E&&v)){const R={};["status","statusText","headers"].forEach(N=>{R[N]=S[N]});const I=ke.toFiniteNumber(S.headers.get("content-length")),[A,k]=a&&qO(I,Bp(HO(a),!0))||[];S=new Response(KO(S.body,QO,A,()=>{k&&k(),v&&v()}),R)}c=c||"text";let C=await zp[ke.findKey(zp,c)||"text"](S,n);return!E&&v&&v(),await new Promise((R,I)=>{zO(R,I,{data:C,headers:Gs.from(S.headers),status:S.status,statusText:S.statusText,config:n,request:g})})}catch(b){throw v&&v(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new ln("Network Error",ln.ERR_NETWORK,n,g),{cause:b.cause||b}):ln.from(b,b&&b.code,n,g)}})};ke.forEach(wx,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const JO=n=>`- ${n}`,wK=n=>ke.isFunction(n)||n===null||n===!1,ZO={getAdapter:n=>{n=ke.isArray(n)?n:[n];const{length:e}=n;let t,r;const s={};for(let i=0;i<e;i++){t=n[i];let o;if(r=t,!wK(t)&&(r=wx[(o=String(t)).toLowerCase()],r===void 0))throw new ln(`Unknown adapter '${o}'`);if(r)break;s[o||"#"+i]=r}if(!r){const i=Object.entries(s).map(([a,l])=>`adapter ${a} `+(l===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
287 `+i.map(JO).join(`
288 `):" "+JO(i[0]):"as no adapter specified";throw new ln("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:wx};function Tx(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new zc(null,n)}function eP(n){return Tx(n),n.headers=Gs.from(n.headers),n.data=Sx.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),ZO.getAdapter(n.adapter||af.adapter)(n).then(function(r){return Tx(n),r.data=Sx.call(n,n.transformResponse,r),r.headers=Gs.from(r.headers),r},function(r){return $O(r)||(Tx(n),r&&r.response&&(r.response.data=Sx.call(n,n.transformResponse,r.response),r.response.headers=Gs.from(r.response.headers))),Promise.reject(r)})}const tP="1.9.0",qp={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{qp[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});const nP={};qp.transitional=function(e,t,r){function s(i,o){return"[Axios v"+tP+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,a)=>{if(e===!1)throw new ln(s(o," has been removed"+(t?" in "+t:"")),ln.ERR_DEPRECATED);return t&&!nP[o]&&(nP[o]=!0,console.warn(s(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,a):!0}},qp.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function TK(n,e,t){if(typeof n!="object")throw new ln("options must be an object",ln.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const i=r[s],o=e[i];if(o){const a=n[i],l=a===void 0||o(a,i,n);if(l!==!0)throw new ln("option "+i+" must be "+l,ln.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new ln("Unknown option "+i,ln.ERR_BAD_OPTION)}}const Hp={assertOptions:TK,validators:qp},Io=Hp.validators;let jl=class{constructor(e){this.defaults=e||{},this.interceptors={request:new jO,response:new jO}}async request(e,t){try{return await this._request(e,t)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
289 `+i):r.stack=i}catch{}}throw r}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Dl(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:i}=t;r!==void 0&&Hp.assertOptions(r,{silentJSONParsing:Io.transitional(Io.boolean),forcedJSONParsing:Io.transitional(Io.boolean),clarifyTimeoutError:Io.transitional(Io.boolean)},!1),s!=null&&(ke.isFunction(s)?t.paramsSerializer={serialize:s}:Hp.assertOptions(s,{encode:Io.function,serialize:Io.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Hp.assertOptions(t,{baseUrl:Io.spelling("baseURL"),withXsrfToken:Io.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&ke.merge(i.common,i[t.method]);i&&ke.forEach(["delete","get","head","post","put","patch","common"],g=>{delete i[g]}),t.headers=Gs.concat(o,i);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(t)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const c=[];this.interceptors.response.forEach(function(v){c.push(v.fulfilled,v.rejected)});let d,f=0,p;if(!l){const g=[eP.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,c),p=g.length,d=Promise.resolve(t);f<p;)d=d.then(g[f++],g[f++]);return d}p=a.length;let m=t;for(f=0;f<p;){const g=a[f++],v=a[f++];try{m=g(m)}catch(y){v.call(this,y);break}}try{d=eP.call(this,m)}catch(g){return Promise.reject(g)}for(f=0,p=c.length;f<p;)d=d.then(c[f++],c[f++]);return d}getUri(e){e=Dl(this.defaults,e);const t=GO(e.baseURL,e.url,e.allowAbsoluteUrls);return DO(t,e.params,e.paramsSerializer)}};ke.forEach(["delete","get","head","options"],function(e){jl.prototype[e]=function(t,r){return this.request(Dl(r||{},{method:e,url:t,data:(r||{}).data}))}}),ke.forEach(["post","put","patch"],function(e){function t(r){return function(i,o,a){return this.request(Dl(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}jl.prototype[e]=t(),jl.prototype[e+"Form"]=t(!0)});let CK=class wz{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(a=>{r.subscribe(a),i=a}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,a){r.reason||(r.reason=new zc(i,o,a),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=r=>{e.abort(r)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new wz(function(s){e=s}),cancel:e}}};function IK(n){return function(t){return n.apply(null,t)}}function RK(n){return ke.isObject(n)&&n.isAxiosError===!0}const Cx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Cx).forEach(([n,e])=>{Cx[e]=n});function rP(n){const e=new jl(n),t=xO(jl.prototype.request,e);return ke.extend(t,jl.prototype,e,{allOwnKeys:!0}),ke.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return rP(Dl(n,s))},t}const hr=rP(af);hr.Axios=jl,hr.CanceledError=zc,hr.CancelToken=CK,hr.isCancel=$O,hr.VERSION=tP,hr.toFormData=Fp,hr.AxiosError=ln,hr.Cancel=hr.CanceledError,hr.all=function(e){return Promise.all(e)},hr.spread=IK,hr.isAxiosError=RK,hr.mergeConfig=Dl,hr.AxiosHeaders=Gs,hr.formToJSON=n=>UO(ke.isHTMLForm(n)?new FormData(n):n),hr.getAdapter=ZO.getAdapter,hr.HttpStatusCode=Cx,hr.default=hr;const{Axios:Mde,AxiosError:Nde,CanceledError:Ode,isCancel:Pde,CancelToken:Dde,VERSION:jde,all:Fde,Cancel:Ude,isAxiosError:Bde,spread:$de,toFormData:zde,AxiosHeaders:qde,HttpStatusCode:Hde,formToJSON:Gde,getAdapter:Vde,mergeConfig:Wde}=hr,AK={version:"3.3.2"},Ix="accessToken",kK="secondAccessToken";function LK(){var e,t;const n=Dr();return de.isStaging(window.location.href)?xa.get(kK)||xa.get(Ix):n?n.token:(t=(e=window.WebViewInterface)==null?void 0:e.fetchToken)==null?void 0:t.call(e)}function MK(n){de.isStaging(window.location.href)&&xa.set(Ix,n)}let Gp;const NK=new Uint8Array(16);function OK(){if(!Gp&&(Gp=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Gp))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Gp(NK)}const as=[];for(let n=0;n<256;++n)as.push((n+256).toString(16).slice(1));function PK(n,e=0){return as[n[e+0]]+as[n[e+1]]+as[n[e+2]]+as[n[e+3]]+"-"+as[n[e+4]]+as[n[e+5]]+"-"+as[n[e+6]]+as[n[e+7]]+"-"+as[n[e+8]]+as[n[e+9]]+"-"+as[n[e+10]]+as[n[e+11]]+as[n[e+12]]+as[n[e+13]]+as[n[e+14]]+as[n[e+15]]}const sP={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Vn(n,e,t){if(sP.randomUUID&&!n)return sP.randomUUID();n=n||{};const r=n.random||(n.rng||OK)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,PK(r)}const iP="deviceId",DK=()=>de.isProduction()?`.basalam.${de.isStaging(window.location.hostname)?"dev":"com"}`:void 0,jK=()=>{let n=xa.get(iP);return n||(n=Vn()),xa.set(iP,n,{expires:3650,domain:DK(),secure:de.isProduction()}),n},FK=n=>typeof window<"u"&&"getApiBaseUrl"in window?window.getApiBaseUrl(n):de.isProduction()?n:`/api-proxy?url=${n}`,UK=n=>{n.interceptors.request.use(e=>{const t={platform:"web",project:"dalan",name:"web.public",version:AK.version,deviceId:jK()},r=LK(),s=Dr();return{...e,headers:{...e==null?void 0:e.headers,...r&&{Authorization:`Bearer ${r}`},...s&&{Accept:"application/json","Content-Type":"application/json"},"X-Client-Info":JSON.stringify(t)}}},e=>Promise.reject(e))},BK=n=>{n.interceptors.response.use(null,e=>{var r;const t=e.config;if(((r=e.response)==null?void 0:r.status)===401&&!t._retry){t._retry=!0;const s=de.isProduction()?"/accounts":"/login",i=de.isProduction()?"/account/chats":"/chats";window.location.pathname.startsWith(i)&&window.location.replace(`${s}?prev=${encodeURIComponent(window.location.href)}`)}return Promise.reject(e)})},$K=n=>{n.interceptors.response.use(e=>e&&e.data?e.data:e)},zK=n=>{n.interceptors.response.use(e=>de.camelize(e),e=>Promise.reject(e))},qK=n=>{n.interceptors.request.use(e=>e.data instanceof FormData||e.noSnakize?e:{...e,params:e.params||{},data:e.data?de.snakize(e.data):void 0},e=>Promise.reject(e))},HK=(n,{headers:e,...t}={})=>hr.create({timeout:15e3,withCredentials:!0,baseURL:FK(n),headers:{...e},...t}),ls=(n,e={},t={})=>{const{hasCamelizeInterceptor:r=!0,hasSnakizeInterceptor:s=!1}=t,i=HK(n,e);return UK(i),$K(i),BK(i),r&&zK(i),s&&qK(i),i},xs=()=>{const n=Dr();return n?{core:n.apiBaseUrl.core,chat:n.apiBaseUrl.chat,auth:n.apiBaseUrl.auth,story:n.apiBaseUrl.story,order:n.apiBaseUrl.order,review:n.apiBaseUrl.review,search:n.apiBaseUrl.search,appsApi:n.apiBaseUrl.appsApi,uploadio:n.apiBaseUrl.uploadio,automation:n.apiBaseUrl.automation,featureFlag:n.apiBaseUrl.featureFlag,conversation:n.apiBaseUrl.conversation,orderProcess:n.apiBaseUrl.orderProcess,userActivity:n.apiBaseUrl.userActivity,notification:n.apiBaseUrl.notification,voucherService:n.apiBaseUrl.voucherService}:{core:mn.coreUrl,chat:mn.chatUrl,auth:mn.authUrl,story:mn.storyUrl,order:mn.orderUrl,review:mn.reviewUrl,search:mn.searchUrl,appsApi:mn.appsApiUrl,uploadio:mn.uploadioUrl,automation:mn.automationUrl,conversation:mn.conversation,orderProcess:mn.orderProcess,featureFlag:mn.featureFlagUrl,notification:mn.notificationUrl,userActivity:mn.userActivityUrl,voucherService:mn.voucherServiceUrl}},oP=ls(xs().auth),cf=ls(xs().core),GK=ls(xs().chat),nr=ls(xs().conversation,{},{hasSnakizeInterceptor:!0,hasCamelizeInterceptor:!0}),VK=ls(xs().story),Vp=ls(xs().review);ls(xs().search);const Fl=ls(xs().orderProcess),Rx=ls(xs().featureFlag),aP=ls(xs().userActivity),uf=ls(xs().notification),WK=ls(xs().uploadio,{timeout:6e4}),Ax=ls(xs().automation),KK=ls(xs().appsApi),YK=ls(xs().voucherService),XK=ls(xs().order,{},{hasSnakizeInterceptor:!0,hasCamelizeInterceptor:!0}),kx=()=>{var e;return(window.DALAN_NEW_SERVICE_TESTERS||[]).includes((e=window.currentUser)==null?void 0:e.id)?nr:GK};function QK({pageParam:n},e){return nr.get("/v3/chats",{params:{...de.snakize(n),filters:e}})}const JK={limit:30,chatType:Bt.CHANNEL};function ZK({limit:n,updatedFrom:e,chatType:t}=JK){return nr.get("/v3/chats",{params:de.snakize({limit:n,updatedFrom:e,chatType:t})})}const eY={limit:30,chatType:Bt.CHANNEL};function tY({limit:n,updatedFrom:e,chatType:t}=eY){return nr.get("/v3/chats/public",{params:{limit:n,updatedFrom:e,chatType:t}})}function nY(){return kx().get("/v2/user/websocket/auth/token")}function rY(n){return nr.post("/v2/broadcast",de.snakize(n))}function sY(n){return nr.post("/v3/messages/forward",de.snakize(n))}function iY(){return kx().get("/v2/stickers")}function oY(n){return kx().post("/v2/chat/confirmation",n)}function aY(n){return nr.get(`/lookup/${n}`)}function lY({payload:n,status:e}){return nr.patch(`/v3/chats/${e}`,de.snakize(n))}function cY(n){return nr.delete("/v3/chats",{data:de.snakize(n)})}function uY(n){return nr.post("/v3/messages",de.snakize(n))}function Lx(n){return nr.get("/v3/messages",{params:de.snakize(n)})}function lP(n){return nr.get("/v3/messages/public",{params:de.snakize(n)})}function dY(n){return nr.post("/v3/search/message",n)}function fY(n){return nr.post("/v3/search/contact",n)}function hY(n){return nr.patch("/v3/messages",n)}function pY(){return nr.get("/v3/messages/unseen_count")}function mY(n){return nr.delete("/v3/messages",{data:n})}function gY({channelIdentifier:n}){return nr.post(`/v3/channels/${n.replace("@","")}/left`)}function _Y({channelIdentifier:n}){return nr.post(`/v3/channels/${n.replace("@","")}/join`)}function vY({pageParam:n}){return nr.get("/v3/chats/public",{params:n})}function yY(n){return nr.post("/v3/chats",n)}function bY(n){return nr.post("/v3/messages/seen",n)}function xY(n){return nr.post("/v3/messages/seen_all",n)}function SY(n){return nr.post("/v3/users/call/phone",de.snakize(n))}function EY(n){return nr.post("/v3/messages/reply_markup/callback",n)}const wY=({limit:n,query:e,filter:t,isLoggedIn:r,searchType:s},i)=>{const o=T.useId();return kp({...i,cacheTime:0,queryKey:["chat-list",t,e,s,r,o],getNextPageParam:(a,l)=>{var c;return a.data.chats.length===n?e?{limit:n,offset:l.length*n}:{limit:n,updatedBefore:(c=a.data.chats[n-1])==null?void 0:c.updatedAt}:void 0},queryFn:({pageParam:a})=>{const c={pageParam:{...a??{limit:30}}};if(!r)return vY(c);if(e){const d={q:e,rows:c.pageParam.limit||30,start:c.pageParam.offset||0};if(s==="CONTACTS")return fY(d);if(s==="MESSAGES")return dY(d)}return QK(c,t)}})},TY=(n={},e={})=>Gn([`chat-list-${n.updatedFrom}`],()=>n.isLoggedIn?ZK(n):tY(n),e);function CY(n={}){return Yn(cY,n)}function IY(n={}){return Yn(gY,n)}function RY(n={}){return Yn(_Y,n)}function qc(n={}){return Yn(lY,n)}const AY=(n={})=>Gn(["centrifuge-token"],nY,n);function kY(n={}){return Yn({...n,mutationKey:["private-chat"],mutationFn:yY})}function LY(n={}){return Gn(["unseen-messages-count"],pY,n)}function MY(n={},e={}){const t=T.useMemo(()=>[`chat-messages-${n.chatId}`],[n.chatId]),r=Nl(),s={order:px.DESC,limit:(n==null?void 0:n.limit)||20,messageId:n.messageId||0,cmp:ja.LESS_THAN_OR_EQUAL},i=kp({...e,queryKey:t,cacheTime:0,queryFn:({pageParam:a=s})=>{const l={...s,...a};return n.isLoggedIn?Lx({...l,chatId:n.chatId}):lP({...l,chatId:n.chatId})},getPreviousPageParam:a=>{var f,p,m;const l=a.data.messages;let c=!0;c=l.length>=n.limit&&!((f=l.at(-1))!=null&&f.isManuallyAdded);const d=((m=(p=l.findLast)==null?void 0:p.call(l,g=>g.status!==Dt.SENDING&&g.status!==Dt.DELETED&&!g.unReadMessages))==null?void 0:m.id)??0;return c?{cmp:ja.LESS_THAN,messageId:d}:void 0},getNextPageParam:(a,l)=>{var p,m,g,v;const c=a.data.messages;let d=!0;d=(l.length<=1?c.length>0:c.length>=n.limit)&&!((p=c==null?void 0:c[0])!=null&&p.isManuallyAdded)&&!((m=c==null?void 0:c[0])!=null&&m.isUpdatedMessage)&&!((g=c==null?void 0:c[0])!=null&&g.unReadMessages);const f=((v=c.find(y=>y.status!==Dt.SENDING&&y.status!==Dt.DELETED))==null?void 0:v.id)??0;return d?{cmp:ja.GREATER_THAN,messageId:f}:void 0}}),o=T.useCallback(a=>{r.setQueryData(t,a)},[r,t]);return{...i,setData:o}}const NY=(n={},e={})=>Gn([`searched-message-${n.messageId}`],()=>{const{limit:t,messageId:r,chatId:s}=n;return Lx({limit:t,chatId:s,messageId:r,order:px.DESC,cmp:ja.LESS_THAN_OR_EQUAL})},e),OY=(n={},e={})=>{const{chatId:t,limit:r,lastMessageId:s}=n;return Gn([`updated-messages-${s}`],()=>{const i={limit:r,order:px.DESC,messageId:s,cmp:ja.GREATER_THAN};return n.isLoggedIn?Lx({...i,chatId:t}):lP({...i,chatId:t})},e)};function PY(n={}){return Yn(mY,n)}function Hc(n={}){return Yn(uY,n)}function DY(n={}){return Yn(rY,n)}function jY(n={}){return Yn(sY,n)}const FY=(n={})=>Gn(["sticker-packs"],iY,n);function UY(n={}){return Yn(oY,n)}function BY(n={}){return Yn(hY,n)}const $Y=(n={})=>Yn(aY,n),zY=(n={})=>Yn(bY,n),qY=(n={})=>Yn(xY,n);function HY(n={}){return Yn(SY,n)}const GY=(n={})=>Yn(EY,n);function cP({children:n,...e}){return _.jsx("button",{...e,children:n})}function uP({mode:n,show:e,chat:t,coords:r,contact:s,onBlock:i,onClose:o,anchorEl:a,onDelete:l,onMarkAsRead:c,onMarkAsUnread:d,options:f={delete:!0,report:!0,block:!0,rules:!0,mark:!0}}){const{emitEvent:p}=Mt.useEmitter(),{chat:m}=Tn(["chat"]),{setChat:g}=ai(),[v,y]=T.useState(!1),[b,S]=T.useState(!1),[E,C]=W9(t==null?void 0:t.markedAsUnread),{showSuccessSnackbar:R}=Mt.useSnackbar(),I=Dr(),A=(t==null?void 0:t.chatType)===Bt.GROUP,k=(t==null?void 0:t.chatType)===Bt.CHANNEL,N=(t==null?void 0:t.chatType)===Bt.PRIVATE,{mutate:D,isLoading:M}=qc(),{mutate:F,isLoading:U}=qc(),{mutate:$,isLoading:q}=qc(),{mutate:G,isLoading:V}=CY({onSuccess:()=>{l==null||l(),o(),R("گفت‌وگو با موفقیت حذف شد",{showProgressBar:!0})}}),{mutate:z,isLoading:B}=IY({onSuccess:()=>{l==null||l(),o(),R(`${A?"گروه":"کانال"} با موفقیت ترک شد`,{showProgressBar:!0})}}),P=()=>{D({payload:{chatIds:[t.id]},status:Fc.MARK_READ},{onSuccess:()=>{C(!1),c==null||c(),o()}})},H=()=>{$({payload:{chatIds:[t.id]},status:Fc.MARK_UNREAD},{onSuccess:()=>{C(!0),d==null||d(),o()}})},Z=W=>{W==null||W.stopPropagation(),F({payload:{chatIds:[t.id]},status:Fc.BLOCK},{onSuccess:()=>{var te;p(Ct.UPDATE_CHAT_LIST_BY_ID,{chatId:t==null?void 0:t.id,chatUpdate:{contactIsBlocked:!0}}),((te=m==null?void 0:m.contact)==null?void 0:te.identifier)===(s==null?void 0:s.identifier)&&g(re=>({...re,contactIsBlocked:!0})),i==null||i(),o(),R("کاربر با موفقیت مسدود شد",{showProgressBar:!0})}})},Q=async W=>{W==null||W.stopPropagation(),o(),n==="modal"&&await de.sleep(200),S(!0)},J=async W=>{W==null||W.stopPropagation(),o(),n==="modal"&&await de.sleep(200),y(!0)},K=t&&[{type:"BUTTON",title:"گزارش تخلف",onClick:W=>{W==null||W.stopPropagation(),p(Fa.SHOW_REPORT_CONTENT_MODAL,{source:"CHAT",entityId:s==null?void 0:s.id,entityType:"CONVERSATION_USER",reportType:fx.CONVERSATION_USER}),o()},icon:_.jsx("i",{className:"bi-report"}),show:f.report&&N&&!I},{type:"BUTTON",onClick:H,title:"علامت‌گذاری به عنوان خوانده نشده",show:f.mark&&!E&&t.unseenMessageCount===0,icon:q?_.jsx(Cr,{size:"md",color:"black"}):_.jsx("i",{className:"bi-mark-as-unread"})},{type:"BUTTON",onClick:P,title:"علامت‌گذاری به عنوان خوانده شده",show:f.mark&&(E||t.unseenMessageCount>0),icon:M?_.jsx(Cr,{size:"md",color:"black"}):_.jsx("i",{className:"bi-mark-as-read"})},{type:"BUTTON",title:"مسدود کردن",onClick:Z,show:f.block&&!t.contactIsBlocked&&N,icon:U?_.jsx(Cr,{size:"md",color:"black"}):_.jsx("i",{className:"bi-block"})},{type:"LINK",title:"قوانین",show:f.rules,icon:_.jsx("i",{className:"bi-privacy"}),target:I&&"_blank",href:I?`${mn.baseUrl}/about/messaging-terms`:"/about/messaging-terms"},{title:"حذف",type:"BUTTON",onClick:Q,show:f.delete&&N,icon:V?_.jsx(Cr,{size:"md",color:"black"}):_.jsx("i",{className:"bi-delete"})},{type:"BUTTON",onClick:J,title:`ترک ${A?"گروه":"کانال"}`,show:f.delete&&(k||A)&&(s.canLeave||A),icon:B?_.jsx(Cr,{size:"md",color:"black"}):_.jsx("i",{className:"bi-logout"})}];return _.jsxs("div",{children:[n==="modal"?_.jsx(lr,{showHeader:!0,show:e,title:s.name,className:"dataset-inp-ChatOptionsMenu",onClose:o,children:_.jsx("div",{className:Pa["options-modal"],children:K==null?void 0:K.map((W,te)=>{const re=W.type==="BUTTON"?cP:wa;return W.show&&_.jsxs(re,{to:W.href,target:W.target||"_self",className:Pa["options-modal__item"],onClick:W.onClick,children:[_.jsx("div",{className:Pa["options-modal__item-icon"],children:W.icon}),_.jsx("span",{className:Pa["options-modal__item-title"],children:W.title})]},te)})})}):_.jsx(tf,{show:e,coords:r,anchorEl:a,getAwayThreshold:75,position:"bottom-left",transition:"pop-top-right",className:"dataset-inp-ChatOptionsMenu",onClose:W=>{W==null||W.stopPropagation(),o()},children:_.jsx("div",{className:Pa["options-popover"],children:K==null?void 0:K.map((W,te)=>{const re=W.type==="BUTTON"?cP:wa;return W.show&&_.jsxs(re,{to:W.href,target:W.target||"_self",className:Pa["options-popover__item"],onClick:W.onClick,children:[_.jsx("div",{className:Pa["options-popover__item-icon"],children:W.icon}),_.jsx("span",{className:Pa["options-popover__item-title"],children:W.title})]},te)})})}),_.jsx(V9,{isGroup:A,title:s==null?void 0:s.name,show:v,onClose:()=>y(!1),onConfirm:()=>z({channelIdentifier:s==null?void 0:s.link})}),_.jsx(K9,{title:s==null?void 0:s.name,show:b,onDelete:()=>G({chatIds:[t.id]}),onClose:()=>S(!1)})]})}var Mx,dP;function VY(){if(dP)return Mx;dP=1;var n=bl(),e=function(){try{var t=n(Object,"defineProperty");return t({},"",{}),t}catch{}}();return Mx=e,Mx}var Nx,fP;function hP(){if(fP)return Nx;fP=1;var n=VY();function e(t,r,s){r=="__proto__"&&n?n(t,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[r]=s}return Nx=e,Nx}var Ox,pP;function mP(){if(pP)return Ox;pP=1;var n=hP(),e=Ev(),t=Object.prototype,r=t.hasOwnProperty;function s(i,o,a){var l=i[o];(!(r.call(i,o)&&e(l,a))||a===void 0&&!(o in i))&&n(i,o,a)}return Ox=s,Ox}var Px,gP;function Wp(){if(gP)return Px;gP=1;var n=mP(),e=hP();function t(r,s,i,o){var a=!i;i||(i={});for(var l=-1,c=s.length;++l<c;){var d=s[l],f=o?o(i[d],r[d],d,i,r):void 0;f===void 0&&(f=r[d]),a?e(i,d,f):n(i,d,f)}return i}return Px=t,Px}var Dx,_P;function WY(){if(_P)return Dx;_P=1;var n=Wp(),e=sd();function t(r,s){return r&&n(s,e(s),r)}return Dx=t,Dx}var jx,vP;function KY(){if(vP)return jx;vP=1;function n(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}return jx=n,jx}var Fx,yP;function YY(){if(yP)return Fx;yP=1;var n=Wo(),e=fv(),t=KY(),r=Object.prototype,s=r.hasOwnProperty;function i(o){if(!n(o))return t(o);var a=e(o),l=[];for(var c in o)c=="constructor"&&(a||!s.call(o,c))||l.push(c);return l}return Fx=i,Fx}var Ux,bP;function Bx(){if(bP)return Ux;bP=1;var n=oR(),e=YY(),t=pR();function r(s){return t(s)?n(s,!0):e(s)}return Ux=r,Ux}var $x,xP;function XY(){if(xP)return $x;xP=1;var n=Wp(),e=Bx();function t(r,s){return r&&n(s,e(s),r)}return $x=t,$x}var df={exports:{}};df.exports;var SP;function QY(){return SP||(SP=1,function(n,e){var t=Hi(),r=e&&!e.nodeType&&e,s=r&&!0&&n&&!n.nodeType&&n,i=s&&s.exports===r,o=i?t.Buffer:void 0,a=o?o.allocUnsafe:void 0;function l(c,d){if(d)return c.slice();var f=c.length,p=a?a(f):new c.constructor(f);return c.copy(p),p}n.exports=l}(df,df.exports)),df.exports}var zx,EP;function JY(){if(EP)return zx;EP=1;function n(e,t){var r=-1,s=e.length;for(t||(t=Array(s));++r<s;)t[r]=e[r];return t}return zx=n,zx}var qx,wP;function ZY(){if(wP)return qx;wP=1;var n=Wp(),e=Sy();function t(r,s){return n(r,e(r),s)}return qx=t,qx}var Hx,TP;function CP(){if(TP)return Hx;TP=1;var n=hA(),e=o0(),t=Sy(),r=vA(),s=Object.getOwnPropertySymbols,i=s?function(o){for(var a=[];o;)n(a,t(o)),o=e(o);return a}:r;return Hx=i,Hx}var Gx,IP;function eX(){if(IP)return Gx;IP=1;var n=Wp(),e=CP();function t(r,s){return n(r,e(r),s)}return Gx=t,Gx}var Vx,RP;function tX(){if(RP)return Vx;RP=1;var n=mA(),e=CP(),t=Bx();function r(s){return n(s,t,e)}return Vx=r,Vx}var Wx,AP;function nX(){if(AP)return Wx;AP=1;var n=Object.prototype,e=n.hasOwnProperty;function t(r){var s=r.length,i=new r.constructor(s);return s&&typeof r[0]=="string"&&e.call(r,"index")&&(i.index=r.index,i.input=r.input),i}return Wx=t,Wx}var Kx,kP;function Yx(){if(kP)return Kx;kP=1;var n=lA();function e(t){var r=new t.constructor(t.byteLength);return new n(r).set(new n(t)),r}return Kx=e,Kx}var Xx,LP;function rX(){if(LP)return Xx;LP=1;var n=Yx();function e(t,r){var s=r?n(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}return Xx=e,Xx}var Qx,MP;function sX(){if(MP)return Qx;MP=1;var n=/\w*$/;function e(t){var r=new t.constructor(t.source,n.exec(t));return r.lastIndex=t.lastIndex,r}return Qx=e,Qx}var Jx,NP;function iX(){if(NP)return Jx;NP=1;var n=ed(),e=n?n.prototype:void 0,t=e?e.valueOf:void 0;function r(s){return t?Object(t.call(s)):{}}return Jx=r,Jx}var Zx,OP;function oX(){if(OP)return Zx;OP=1;var n=Yx();function e(t,r){var s=r?n(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}return Zx=e,Zx}var eS,PP;function aX(){if(PP)return eS;PP=1;var n=Yx(),e=rX(),t=sX(),r=iX(),s=oX(),i="[object Boolean]",o="[object Date]",a="[object Map]",l="[object Number]",c="[object RegExp]",d="[object Set]",f="[object String]",p="[object Symbol]",m="[object ArrayBuffer]",g="[object DataView]",v="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",S="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",A="[object Uint32Array]";function k(N,D,M){var F=N.constructor;switch(D){case m:return n(N);case i:case o:return new F(+N);case g:return e(N,M);case v:case y:case b:case S:case E:case C:case R:case I:case A:return s(N,M);case a:return new F;case l:case f:return new F(N);case c:return t(N);case d:return new F;case p:return r(N)}}return eS=k,eS}var tS,DP;function lX(){if(DP)return tS;DP=1;var n=OI(),e=o0(),t=fv();function r(s){return typeof s.constructor=="function"&&!t(s)?n(e(s)):{}}return tS=r,tS}var nS,jP;function cX(){if(jP)return nS;jP=1;var n=jh(),e=yl(),t="[object Map]";function r(s){return e(s)&&n(s)==t}return nS=r,nS}var rS,FP;function uX(){if(FP)return rS;FP=1;var n=cX(),e=ov(),t=av(),r=t&&t.isMap,s=r?e(r):n;return rS=s,rS}var sS,UP;function dX(){if(UP)return sS;UP=1;var n=jh(),e=yl(),t="[object Set]";function r(s){return e(s)&&n(s)==t}return sS=r,sS}var iS,BP;function fX(){if(BP)return iS;BP=1;var n=dX(),e=ov(),t=av(),r=t&&t.isSet,s=r?e(r):n;return iS=s,iS}var oS,$P;function hX(){if($P)return oS;$P=1;var n=oy(),e=LI(),t=mP(),r=WY(),s=XY(),i=QY(),o=JY(),a=ZY(),l=eX(),c=xA(),d=tX(),f=jh(),p=nX(),m=aX(),g=lX(),v=vo(),y=Mh(),b=uX(),S=Wo(),E=fX(),C=sd(),R=Bx(),I=1,A=2,k=4,N="[object Arguments]",D="[object Array]",M="[object Boolean]",F="[object Date]",U="[object Error]",$="[object Function]",q="[object GeneratorFunction]",G="[object Map]",V="[object Number]",z="[object Object]",B="[object RegExp]",P="[object Set]",H="[object String]",Z="[object Symbol]",Q="[object WeakMap]",J="[object ArrayBuffer]",ee="[object DataView]",K="[object Float32Array]",W="[object Float64Array]",te="[object Int8Array]",re="[object Int16Array]",pe="[object Int32Array]",Ee="[object Uint8Array]",le="[object Uint8ClampedArray]",Ie="[object Uint16Array]",be="[object Uint32Array]",ge={};ge[N]=ge[D]=ge[J]=ge[ee]=ge[M]=ge[F]=ge[K]=ge[W]=ge[te]=ge[re]=ge[pe]=ge[G]=ge[V]=ge[z]=ge[B]=ge[P]=ge[H]=ge[Z]=ge[Ee]=ge[le]=ge[Ie]=ge[be]=!0,ge[U]=ge[$]=ge[Q]=!1;function Ae(Re,tt,et,Oe,ht,Xe){var Je,qe=tt&I,Ue=tt&A,it=tt&k;if(et&&(Je=ht?et(Re,Oe,ht,Xe):et(Re)),Je!==void 0)return Je;if(!S(Re))return Re;var nt=v(Re);if(nt){if(Je=p(Re),!qe)return o(Re,Je)}else{var dt=f(Re),Ot=dt==$||dt==q;if(y(Re))return i(Re,qe);if(dt==z||dt==N||Ot&&!ht){if(Je=Ue||Ot?{}:g(Re),!qe)return Ue?l(Re,s(Je,Re)):a(Re,r(Je,Re))}else{if(!ge[dt])return ht?Re:{};Je=m(Re,dt,qe)}}Xe||(Xe=new n);var xt=Xe.get(Re);if(xt)return xt;Xe.set(Re,Je),E(Re)?Re.forEach(function(lt){Je.add(Ae(lt,tt,et,lt,Re,Xe))}):b(Re)&&Re.forEach(function(lt,Vt){Je.set(Vt,Ae(lt,tt,et,Vt,Re,Xe))});var rt=it?Ue?d:c:Ue?R:C,Me=nt?void 0:rt(Re);return e(Me||Re,function(lt,Vt){Me&&(Vt=lt,lt=Re[Vt]),t(Je,Vt,Ae(lt,tt,et,Vt,Re,Xe))}),Je}return oS=Ae,oS}var aS,zP;function pX(){if(zP)return aS;zP=1;var n=hX(),e=1,t=4;function r(s){return n(s,e|t)}return aS=r,aS}var mX=pX();const gX=ba(mX);function Ul(n){var e,t,r;if((e=n==null?void 0:n.content)!=null&&e.text)return n.content.text;switch(n==null?void 0:n.messageType){case Fe.TEXT:return(t=n==null?void 0:n.content)==null?void 0:t.text;case Fe.PICTURE:return"تصویر";case Fe.STICKER:return"استیکر";case Fe.PRODUCT:return"محصول";case Fe.SOCIAL_POST:return"پست";case Fe.VOICE:return"پیام صوتی";case Fe.NOTIFICATION:return"اطلاع رسانی";case Fe.VENDOR:return"غرفه";case Fe.USER:return"کاربر";case Fe.ORDER_PROCESS:return"پردازش سفارش";case Fe.REVIEW:return"ثبت تجربه";case Fe.ORDER:return"ثبت رضایت";case Fe.AGREEMENT:return"ثبت رضایت";case Fe.STORY:return"استوری";case Fe.VIDEO:return"ویدئو";case Fe.FILE:return"فایل";case Fe.COUPON:return"کوپن";case Fe.FACTOR:return"فاکتور";default:return((r=n==null?void 0:n.content)==null?void 0:r.text)||""}}function qP(n){switch(n==null?void 0:n.messageType){case Fe.VOICE:return"bi-microphone";case Fe.PICTURE:return"bi-picture";case Fe.PRODUCT:return"bi-cube";case Fe.VENDOR:return"bi-vendor";case Fe.USER:return"bi-user";case Fe.SOCIAL_POST:return"bi-edit-square";case Fe.STICKER:return"bi-sticker";case Fe.REVIEW:return"bi-star";case Fe.ORDER:return"bi-cube";case Fe.AGREEMENT:return"bi-cube";case Fe.STORY:return"bi-ticket";case Fe.VIDEO:return"bi-video-square";case Fe.FILE:return"bi-file";case Fe.NOTIFICATION:return"bi-notification";case Fe.CALL:return"bi-phone";case Fe.FACTOR:return"bi-factor";default:return null}}function _X(n){const e=gX(n);return delete e.isNew,delete e.content.files,delete e.sender,delete e.status,e}function vX({chat:n,contact:e,onClick:t,onBlock:r,isActive:s,onDelete:i,onMarkAsRead:o,onMarkAsUnread:a,isCompact:l=!1,bottomBordered:c=!0,isNotification:d=!1}){var te,re,pe,Ee,le,Ie,be,ge;const p=T.useRef(),m=T.useRef(),{isMobile:g,isForceMobile:v}=At(),{isLoggedIn:y,currentUser:b,featureFlags:S}=Lt(["isLoggedIn","currentUser","featureFlags"]),[E,C]=T.useState(!1),[R,I]=T.useState(!!d),[A,k]=T.useState(!1),[N,D]=T.useState({top:0,left:0}),M=e&&b&&e.id===b.id,[F,U]=[((te=S==null?void 0:S.features)==null?void 0:te.deleteChat)&&!M,((re=S==null?void 0:S.features)==null?void 0:re.blockContact)&&(n==null?void 0:n.chatType)===Bt.PRIVATE],$=((pe=e==null?void 0:e.avatar)==null?void 0:pe.extraSmall)&&!R,q=async()=>{i==null||i(n),C(!0),await de.sleep(550)},G=()=>{y&&(clearTimeout(m.current),m.current=null,m.current=setTimeout(()=>{var Ae;(Ae=navigator==null?void 0:navigator.vibrate)==null||Ae.call(navigator,50),k(!0)},500))},V=()=>{m.current&&clearTimeout(m.current)},z=()=>{clearTimeout(m.current),m.current=null},B=()=>{setTimeout(()=>{k(!1)},0)},P=T.useMemo(()=>ad(e==null?void 0:e.lastActivity),[e==null?void 0:e.lastActivity]),H=T.useMemo(()=>{const Ae=de.jalaliDate();if(!n.updatedAt)return"";const Re=de.jalaliDate(n.updatedAt),tt=Ae.format("YYYY")===Re.format("YYYY");return Ae.isSame(Re,"day")?Re.format("HH:mm"):Ae.subtract(1,"day").isSame(Re,"day")?"دیروز":tt?Re.format("D MMMM"):Re.format("YYYY/MM/D")},[n.updatedAt]),Z=T.useMemo(()=>n.searchedMessage||E8(n.lastMessage),[n.searchedMessage,n.lastMessage]),Q=T.useMemo(()=>Ul(Z),[Z]),J=T.useMemo(()=>qP(Z),[Z]),ee=T.useCallback(()=>{var Ae;return M?_.jsx("div",{className:Te(Ln["chat-list-item__top__saved-message__avatar"],{[Ln["chat-list-item__top__saved-message__avatar--compact"]]:l}),children:_.jsx(Mn,{size:l?"32":"24",name:"bi-saved-message-fill",color:"white"})}):_.jsx("div",{className:Ln["chat-list-item__top-avatar"],children:_.jsx(zs,{src:(Ae=e==null?void 0:e.avatar)==null?void 0:Ae.extraSmall,size:l?"56":g?"40":"44",status:$?"offline":P,onLoad:()=>I(!0)})})},[M,$,P,l,g,(Ee=e==null?void 0:e.avatar)==null?void 0:Ee.extraSmall]),K=T.useCallback(Ae=>{y&&(Ae.preventDefault(),D({top:Ae.pageY,left:Ae.pageX}),k(!0))},[y]);T.useEffect(()=>{const Ae=p.current;return Ae==null||Ae.addEventListener("contextmenu",K),()=>{Ae==null||Ae.removeEventListener("contextmenu",K)}},[K]);const W=n.unseenMessageCount>0;return _.jsxs("div",{ref:p,style:{transition:"all 450ms ease"},className:Te(Ln["chat-list-item-container"],{[Ln["chat-list-item-container--active"]]:s,[Ln["chat-list-item-container--deleted"]]:E,[Ln["chat-list-item-container--notification"]]:n.chatType===Zi.NOTIFICATION}),onTouchEnd:z,onTouchMove:V,onTouchStart:G,children:[_.jsx("button",{className:Te(Ln["chat-list-item"],{[Ln["chat-list-item--compact"]]:l,[Ln["chat-list-item--active"]]:A,[Ln["chat-list-item--bottom-bordered"]]:c}),onClick:()=>t(n),children:l?_.jsxs(_.Fragment,{children:[ee(),_.jsxs("div",{className:Ln["chat-list-item__compact-indicators"],children:[W&&_.jsx("span",{className:Ln["chat-list-item__compact-unseen"],children:n.unseenMessageCount}),(n==null?void 0:n.markedAsUnread)&&_.jsx("span",{className:Ln["chat-list-item__compact-mark"]})]})]}):_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:Ln["chat-list-item__top"],children:[ee(),_.jsxs("div",{className:Ln["chat-list-item__top-sender"],children:[_.jsxs("div",{className:Ln["chat-list-item__top-sender-name"],children:[n.searchedMessage&&(e!=null&&e.snippet)?_.jsx("div",{className:Ln["chat-list-item__top-sender-name-snippet"],dangerouslySetInnerHTML:{__html:Ec.sanitize(e==null?void 0:e.snippet)}}):_.jsxs("span",{children:[(n==null?void 0:n.chatType)===Bt.CHANNEL&&_.jsx("i",{className:"bi-megaphone-fill"}),(n==null?void 0:n.chatType)===Bt.GROUP&&_.jsx("i",{className:"bi-users-fill"}),n.chatType===Bt.BOT&&_.jsx("i",{className:"bi-bot-fill"}),M?"پیام های ذخیره شده":e==null?void 0:e.name]}),(e==null?void 0:e.verified)&&!M&&_.jsx("i",{className:Te("bi-tick-single",Ln["chat-list-item__top-sender-name-official"])}),!!(e!=null&&e.badge)&&!M&&_.jsx(Xo,{className:Ln["chat-list-item__top-sender-name-basalmi-badge"],label:e==null?void 0:e.badge,size:"sm",color:"black"})]}),!!(e!=null&&e.vendor)&&!M&&_.jsxs("span",{className:Ln["chat-list-item__top-sender-vendor"],children:[_.jsx("i",{className:"bi-vendor"}),(le=e==null?void 0:e.vendor)==null?void 0:le.title]})]}),_.jsx("div",{className:Te(Ln["chat-list-item__top-time"],{[Ln["chat-list-item__top-time--unseen"]]:W}),children:H||_.jsx(vt,{width:30,height:20})})]}),_.jsxs("div",{className:Ln["chat-list-item__bottom"],children:[_.jsxs("div",{className:Ln["chat-list-item__bottom-message"],children:[J&&_.jsx("i",{className:J}),(be=(Ie=n.searchedMessage)==null?void 0:Ie.content)!=null&&be.snippet||n.chatType===Zi.NOTIFICATION?_.jsx("div",{className:Ln["chat-list-item__bottom-message-snippet"],dangerouslySetInnerHTML:{__html:Ec.sanitize(n.chatType===Zi.NOTIFICATION?Q:n.searchedMessage.content.snippet)}}):_.jsx("span",{className:Ln["chat-list-item__bottom-message-snippet"],children:Q})]}),n.unseenMessageCount===0&&!M&&((ge=Z==null?void 0:Z.sender)==null?void 0:ge.id)===String(b==null?void 0:b.id)&&_.jsx("i",{className:Te(Ln["chat-list-item__bottom-seen"],{"bi-tick-double":(n==null?void 0:n.lastSeenId)===(Z==null?void 0:Z.id)&&(Z==null?void 0:Z.seenAt),"bi-tick-single":(n==null?void 0:n.lastSeenId)!==(Z==null?void 0:Z.id)||!(Z!=null&&Z.seenAt)})}),W&&_.jsx("span",{className:Ln["chat-list-item__bottom-unseen"],children:n.unseenMessageCount}),(n==null?void 0:n.markedAsUnread)&&_.jsx("span",{className:Ln["chat-list-item__bottom-mark"]})]})]})}),!d&&_.jsx(uP,{chat:n,contact:e,show:A,coords:N,mode:g&&!v?"modal":"popover",options:{delete:F,block:U,mark:!0},onBlock:r,onDelete:q,onClose:B,onMarkAsRead:o,onMarkAsUnread:a})]})}const HP=T.memo(vX),Kr={"chat-list-search":"_chat-list-search_1w7f3_6","chat-list-search--no-border":"_chat-list-search--no-border_1w7f3_15","chat-list-search__header":"_chat-list-search__header_1w7f3_18","chat-list-search__header-title":"_chat-list-search__header-title_1w7f3_24","chat-list-search__header-search-icon":"_chat-list-search__header-search-icon_1w7f3_29","types-modal__item":"_types-modal__item_1w7f3_45","types-modal__item-label":"_types-modal__item-label_1w7f3_49","search-modal__header":"_search-modal__header_1w7f3_64","search-modal__header-back":"_search-modal__header-back_1w7f3_69","search-modal__header-box":"_search-modal__header-box_1w7f3_93","search-modal__header-box-form":"_search-modal__header-box-form_1w7f3_102","search-modal__header-box-input":"_search-modal__header-box-input_1w7f3_106","search-modal__header-box-input--isSearching":"_search-modal__header-box-input--isSearching_1w7f3_121","search-modal__header-box-select":"_search-modal__header-box-select_1w7f3_130","search-modal__header-box-clear":"_search-modal__header-box-clear_1w7f3_151","search-modal__header-box-select-icon":"_search-modal__header-box-select-icon_1w7f3_159"},Kp={"header-options__more":"_header-options__more_1tirw_6","header-options__more-icon":"_header-options__more-icon_1tirw_9","header-options__more-icon-dot":"_header-options__more-icon-dot_1tirw_24","header-options__more--compact":"_header-options__more--compact_1tirw_34"},cs={"options-modal__item":"_options-modal__item_1a3tm_6","options-modal__item-icon":"_options-modal__item-icon_1a3tm_28","options-modal__item-title":"_options-modal__item-title_1a3tm_37","options-popover":"_options-popover_1a3tm_49","options-popover__item":"_options-popover__item_1a3tm_69","options-popover__item-icon":"_options-popover__item-icon_1a3tm_104"};function GP(n){return Dr()?n!=null&&n.username?`${mn.baseUrl}/@${n==null?void 0:n.username}`:`${mn.baseUrl}/user/${n==null?void 0:n.hashId}`:n!=null&&n.username?`/@${n==null?void 0:n.username}`:`/user/${n==null?void 0:n.hashId}`}function VP(){return(window==null?void 0:window.location.host.endsWith("dev"))?"https://basalam.dev/accounts/login?prev=https%3A%2F%2Fdalan.basalam.dev":"https://basalam.com/accounts/login?prev=https%3A%2F%2Fdalan.basalam.com"}function yX(n,e=[]){try{if(!n||typeof n!="string")return!1;const t=n.trim().toLowerCase();if(["javascript:","data:","vbscript:","<script","alert(","onclick=","onload=","onerror=","onfocus=","onmouseover=","withcredentials=","settimeout=","console.","eval(","execscript(","expression(","setinterval(","settimeout(","unescape(","decodeuri(","decodeuricomponent(","decodeuricomponent("].some(m=>t.includes(m)))return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;const i=new URL(n),a=["http:","https:"].includes(i.protocol),c=["javascript:","data:","vbscript:","file:","ftp:","blob:","chrome:","chrome-extension:","moz-extension:"].includes(i.protocol.toLowerCase());let d=!0;e.length>0&&(d=e.some(m=>{if(m.startsWith("*.")){const v=m.slice(2);return i.hostname===v||i.hostname.endsWith(`.${v}`)}const g=m.replace(/^https?:\/\//,"").replace(/\/$/,"");return i.hostname===g}));const f=i.hostname,p=f.startsWith("10.")||f.startsWith("192.168.")||f.startsWith("127.")||f==="localhost"||f.startsWith("172.")&&/^172\.(1[6-9]|2\d|3[01])\./.test(f);return a&&!c&&d&&!p}catch{return!1}}const lS=()=>{let n="",t=new URLSearchParams(window.location.search).get("text")||"";return t=Ec.sanitize(t),yX(window.location.href)&&(n=t.replace(/\r?\n/g,"<br>").replace(/\\n/g,"<br>")),window.location.hash&&(n+=window.location.hash),n},Fr=()=>{const{injection:n}=Lt(["injection"]),e=T.useRef(n);return T.useEffect(()=>{e.current=n},[n]),{publishEvent:T.useCallback((r,s)=>{const i=e.current;i!=null&&i.publishEvent?i.publishEvent(r,s):console.warn("publishEvent method not provided!!!")},[])}};function WP(n){return n.startsWith("@")}class KP extends Error{constructor(e){super(e),this.name="ApiError"}}function bX(n){var t,r,s,i,o,a,l,c;if(!(n!=null&&n.response)&&!(n!=null&&n.request))return n;const e=n.response?new KP("Response error: "+((t=n==null?void 0:n.response)==null?void 0:t.statusText)):new KP("Network error: "+(n==null?void 0:n.message));if(e.statusCode=!n.response&&n.code==="ECONNABORTED"?408:!n.response&&!e.isTimeoutError?599:((r=n==null?void 0:n.response)==null?void 0:r.status)||500,e.errorType="api",e.url=((s=n==null?void 0:n.config)==null?void 0:s.baseURL)+((i=n==null?void 0:n.config)==null?void 0:i.url),e.method=(o=n==null?void 0:n.config)==null?void 0:o.method,e.headers=(a=n==null?void 0:n.config)==null?void 0:a.headers,e.data=(l=n==null?void 0:n.config)==null?void 0:l.data,e.timeout=(c=n==null?void 0:n.config)==null?void 0:c.timeout,e.url){const d=new URL(e.url);e.hostname=d.hostname,e.pathname=d.pathname,e.search=d.search}return e}var xX={NODE_ENV:"production"};const Gc=n=>{const e=window.emitter;e&&e.emit("bs-snackbar-show",{type:"error",title:n})};function SX(n){let e=null;return n!=null&&n.response||n!=null&&n.request?e=bX(n):n instanceof Error?(e=n,e.errorType="logic"):(e=new Error("something unexpected",{cause:n}),e.errorType="unknown"),e.statusCode||(e.statusCode=500),e}function EX(n){typeof process<"u"&&xX.NODE_ENV==="production"?console.warn("%c Capture Error::","color:#FF5C39;font-weight:900",n):console.error("Capture Error::",n),n.errorType}function wX(n){return n=SX(n),EX(n),n}const TX={showToast:!0};function Vc(n,e=TX){e.showToast&&Gc("مشکلی در انجام عملیات رخ داد. لطفا دوباره امتحان کنید."),wX(n)}function to(n,e){var t,r;try{if(!((t=n==null?void 0:n.response)!=null&&t.data)||((r=n==null?void 0:n.response)==null?void 0:r.status)===500)return Vc(n);const s=n.response.data;s.messages?s.messages.forEach(i=>{i.message&&Gc(de.replaceAllMatchedKeys(i.message,e))}):s.errors?s.errors.forEach(i=>{Gc(i.message)}):Array.isArray(s)?s.forEach(i=>{i.message&&Gc(de.replaceAllMatchedKeys(i.message,e))}):Vc()}catch(s){Vc(s)}}function no(n,e){var t,r;try{if(!((t=n==null?void 0:n.response)!=null&&t.data)||((r=n==null?void 0:n.response)==null?void 0:r.status)===500)return Vc(n);const s=n.response.data.error;s.messages?s.messages.forEach(i=>{i.text&&Gc(de.replaceAllMatchedKeys(i.text,e))}):Array.isArray(s)?s.forEach(i=>{i.text&&Gc(de.replaceAllMatchedKeys(i.text,e))}):Vc()}catch(s){Vc(s)}}const Yp=(n,e)=>typeof n=="function"?n(e):n,wi=R_(n=>({tabs:[],messages:[],hasMoreMessages:!0,selectedTab:void 0,containerRef:void 0,isFetchedFirstPage:!1,getNextMessages:()=>{},unseenMessageCount:void 0,refetchNotifications:void 0,isLoadingFetchNotifications:!1,actions:{setSelectedTab:e=>n({selectedTab:e}),setContainerRef:e=>n({containerRef:e}),setHasMoreMessages:e=>n({hasMoreMessages:e}),setGetNextMessages:e=>n({getNextMessages:e}),setIsFetchedFirstPage:e=>n({isFetchedFirstPage:e}),setRefetchNotifications:e=>n({refetchNotifications:e}),setIsLoadingFetchNotifications:e=>n({isLoadingFetchNotifications:e}),updateTabs:e=>n(t=>({tabs:Yp(e,t.tabs)})),updateMessages:e=>n(t=>({messages:Yp(e,t.messages)})),updateNotification:e=>n(t=>({notification:Yp(e,t.notification)})),updateUnseenMessageCount:e=>n(t=>({unseenMessageCount:Yp(e,t.unseenMessageCount)}))},notification:{id:-2,deletedAt:"",createdAt:"",updatedAt:"",showApprovals:!1,markedAsUnread:!1,isSearchResult:!1,unseenMessageCount:0,contactIsBlocked:!1,chatType:Zi.NOTIFICATION,lastMessage:{id:-20,chatId:-2,tempId:null,updatedAt:"",createdAt:"",messageSource:null,sender:{id:-3},messageType:Fe.NOTIFICATION,message:{text:"",links:[],files:[],entityId:212059117}},contact:{id:-3,bio:"",hashId:"",lastActivity:"",userFollowerCount:0,userFollowingCount:0,name:"اعلان‌های باسلام",username:"BASALAM_NOTIFICATIONS",identifier:Zi.NOTIFICATION,markedType:{id:3706,parentId:-4,description:null,title:"همکاران باسلام"},avatar:{id:-5,small:"https://statics.basalam.com/public-41/admin/Ddrd75/11-05/2KWi7NTi7XSdyz7dDu8EAGFRazYgXFk7Zy5DpyVaiz24uCmXhG.SVG",large:"https://statics.basalam.com/public-41/admin/Ddrd75/11-05/2KWi7NTi7XSdyz7dDu8EAGFRazYgXFk7Zy5DpyVaiz24uCmXhG.SVG",medium:"https://statics.basalam.com/public-41/admin/Ddrd75/11-05/2KWi7NTi7XSdyz7dDu8EAGFRazYgXFk7Zy5DpyVaiz24uCmXhG.SVG",extraSmall:"https://statics.basalam.com/public-41/admin/Ddrd75/11-05/2KWi7NTi7XSdyz7dDu8EAGFRazYgXFk7Zy5DpyVaiz24uCmXhG.SVG"}}}})),ff=()=>wi(n=>n.actions),Bl=A_({useTabs:()=>wi(n=>n.tabs),useMessages:()=>wi(n=>n.messages),useSelectedTab:()=>wi(n=>n.selectedTab),useNotification:()=>wi(n=>n.notification),useContainerRef:()=>wi(n=>n.containerRef),useHasMoreMessages:()=>wi(n=>n.hasMoreMessages),useGetNextMessages:()=>wi(n=>n.getNextMessages),useIsFetchedFirstPage:()=>wi(n=>n.isFetchedFirstPage),useUnseenMessageCount:()=>wi(n=>n.unseenMessageCount),useRefetchNotifications:()=>wi(n=>n.refetchNotifications),useIsLoadingFetchNotifications:()=>wi(n=>n.isLoadingFetchNotifications)});function hf(n){return{...n,identifier:n.hashId,avatar:typeof n.avatar=="string"?{small:n.avatar,large:n.avatar,medium:n.avatar,extraSmall:n.avatar}:n.avatar}}function Xp(n){return{...n,name:n.title,hashId:`@${n.link}`,identifier:`@${n.link}`,verified:(n==null?void 0:n.verified)||(n==null?void 0:n.blueTick),avatar:{small:n.avatar,large:n.avatar,medium:n.avatar,extraSmall:n.avatar}}}function Qp(n){return{...n,name:n.title,hashId:`@${n.link}`,identifier:`@${n.link}`,verified:(n==null?void 0:n.verified)||(n==null?void 0:n.blueTick),avatar:{small:n.avatar,large:n.avatar,medium:n.avatar,extraSmall:n.avatar}}}function Jp(n){return{...n,identifier:`@${n.hashId}`,avatar:{small:n.avatar,large:n.avatar,medium:n.avatar,extraSmall:n.avatar}}}const CX=({onChatOpen:n,onChatClose:e,onChatJoin:t})=>{const r=At(),{emitEvent:s}=Mt.useEmitter(),{chat:i,contact:o,identifier:a}=Tn(["chat","contact","identifier"]),{setChat:l,setContact:c,setIdentifier:d,resetMessages:f}=ai(),{setUnseenMessages:p}=$i(),{notification:m}=Bl(["notification"]),g=T.useCallback(N=>{(N==null?void 0:N.unseenMessageCount)>0&&N.id===-2&&N.chatType===Zi.NOTIFICATION&&p(D=>{const M={...D,notification:Math.max(D.notification-N.unseenMessageCount,0)};return s(Ct.BROADCAST_TO_ALL,{data:M,customType:"setUnseenMessages"}),M})},[p,s]),{mutate:v,reset:y}=kY({onError:to,onSuccess:({data:N})=>{g(N);const D={...N,contact:(i==null?void 0:i.chatType)===Bt.BOT&&(i==null?void 0:i.contact)||hf(N.contact)};l(D),c(D.contact)}}),{data:b,mutate:S,reset:E}=$Y(),C=T.useMemo(()=>{var N;return(N=i==null?void 0:i.contact)!=null&&N.name?i.contact:b?Jp(b):null},[i,b]),R=a===Zi.NOTIFICATION&&(m==null?void 0:m.contact);T.useEffect(()=>{(i==null?void 0:i.chatType)===Bt.PRIVATE?c(i.contact):i!=null&&i.channel&&(i==null?void 0:i.chatType)===Bt.CHANNEL?c(Xp(i.channel)):i!=null&&i.group&&(i==null?void 0:i.chatType)===Bt.GROUP?c(Qp(i.group)):R?c(R):C&&(i==null?void 0:i.chatType)===Bt.BOT?c(C):c({})},[i,C,R,c]);const I=T.useCallback(async({chat:N,identifier:D,preventOpenChat:M=!1})=>{var F,U,$,q;N?(((F=i==null?void 0:i.contact)==null?void 0:F.identifier)!==((U=N.contact)==null?void 0:U.identifier)&&f(),l(N),d(($=N.contact)==null?void 0:$.identifier),E(),n==null||n((q=N.contact)==null?void 0:q.identifier),g(N)):(d(D),WP(D)?S(D,{onError:to,onSuccess:G=>{if(G.chatType===Bt.CHANNEL){y();const V={...G,contact:Xp(G.channel)};g(V),l(V),V.hasChat||t==null||t()}else if(G.chatType===Bt.GROUP){y();const V={...G,contact:Qp(G.group)};g(V),l(V),V.hasChat||t==null||t()}else v({chatType:Bt.BOT,userId:G.id})}}):D!==Zi.NOTIFICATION&&(o==null?void 0:o.hashId)!==D&&v({chatType:Bt.PRIVATE,hashId:D}),M||n==null||n(D))},[o]),A=T.useCallback(()=>{i&&o&&v({chatType:i.chatType,userId:o.id})},[i,o,v]),k=T.useCallback(async()=>{e==null||e(),r.isPc||await de.sleep(360),l(void 0),d(void 0)},[i,a,e]);return{chat:i,contact:o,openChat:I,closeChat:k,identifier:a,updateChatInfo:A}},YP=T.createContext(null),XP=T.forwardRef(({children:n,onChatOpen:e,onChatClose:t,onChatJoin:r},s)=>{const{subEvent:i}=Mt.useEmitter(),o=CX({onChatOpen:e,onChatClose:t,onChatJoin:r});T.useImperativeHandle(s,()=>({openChat:o.openChat,closeChat:o.closeChat,identifier:o.identifier}),[o.openChat,o.closeChat,o.identifier]);const a=T.useMemo(()=>({openChat:o.openChat,closeChat:o.closeChat,updateChatInfo:o.updateChatInfo}),[o.openChat,o.closeChat,o.updateChatInfo]);return T.useEffect(()=>{i(Ct.UPDATE_CHAT_INFO,()=>{o.updateChatInfo()})},[i]),_.jsx(YP.Provider,{value:a,children:n})}),Wc=()=>{const n=T.useContext(YP);if(!n)throw new Error("useChatMessagesContext must be used within ChatMessagesProvider");return n};function IX({mode:n,show:e,coords:t,options:r,onClose:s,anchorEl:i,onOpenBotsListModal:o,onOpenMessengerModal:a,onCloseBotsListModal:l,onCloseMessengerModal:c}){const d=r.savedMessage,f=r.messenger,p=r.botsList,{openChat:m}=Wc(),{currentUser:g,pagesBasePath:v}=Lt(["currentUser","pagesBasePath"]),{pushOnce:y}=Si(),{publishEvent:b}=Fr(),S=Dr(),E=()=>{requestIdleCallback(()=>{b("chatHeaderOptionsSavedMessageItemClick",{vendorIdentifier:g==null?void 0:g.hashId})}),m({identifier:g==null?void 0:g.hashId,preventOpenChat:!0});const I=lS(),A=g==null?void 0:g.hashId;S||window.history.pushState({chat:1,__N:!0,options:{},as:`${v}/${A}`,url:`${v}/[identifier]?identifier=${A}`},"",`${v}/${A}${!A&&(I==null?void 0:I.length)>0?`?text=${I}`:""}`),s()},C=()=>{requestIdleCallback(()=>{b("chatHeaderOptionsMessengerItemClick",{vendorIdentifier:g==null?void 0:g.hashId})}),s(),y(()=>{c()}),a()},R=()=>{requestIdleCallback(()=>{b("chatHeaderOptionsBotsListClick",{vendorIdentifier:g==null?void 0:g.hashId})}),s(),y(()=>{l()}),o()};return n==="modal"?_.jsx(lr,{showHeader:!0,show:e,className:"dataset-inp-MoreOptionsMenu",onClose:s,children:_.jsxs("div",{className:cs["options-modal"],children:[d&&_.jsxs("button",{className:cs["options-modal__item"],onClick:E,children:[_.jsx("i",{className:Te("bi-saved-message",cs["options-modal__item-icon"])}),_.jsx("span",{className:cs["options-modal__item-title"],children:"پیام‌های ذخیره‌ شده"})]}),f&&_.jsxs("button",{className:cs["options-modal__item"],onClick:C,children:[_.jsx("i",{className:Te("bi-notification",cs["options-modal__item-icon"])}),_.jsx("span",{className:cs["options-modal__item-title"],children:"اعلان گفت‌وگوها در پیام‌رسان‌ها"})]}),p&&_.jsxs("button",{className:cs["options-modal__item"],onClick:R,children:[_.jsx("i",{className:Te("bi-bot",cs["options-modal__item-icon"])}),_.jsx("span",{className:cs["options-modal__item-title"],children:"لیست بات‌ها"})]})]})}):_.jsx(tf,{show:e,coords:t,anchorEl:i,getAwayThreshold:75,position:"bottom-left",transition:"pop-top-right",className:"dataset-inp-MoreOptionsMenu",onClose:I=>{I==null||I.stopPropagation(),s()},children:_.jsxs("div",{className:cs["options-popover"],children:[d&&_.jsxs("button",{className:cs["options-popover__item"],onClick:E,children:[_.jsx("div",{className:cs["options-popover__item-icon"],children:_.jsx("i",{className:"bi-saved-message"})}),_.jsx("span",{children:"پیام‌های ذخیره‌ شده"})]}),f&&_.jsxs("button",{className:cs["options-popover__item"],onClick:C,children:[_.jsx("div",{className:cs["options-popover__item-icon"],children:_.jsx("i",{className:"bi-notification"})}),_.jsx("span",{children:"اعلان گفت‌وگوها در پیام‌رسان‌ها"})]}),p&&_.jsxs("button",{className:cs["options-popover__item"],onClick:R,children:[_.jsx("div",{className:cs["options-popover__item-icon"],children:_.jsx("i",{className:"bi-bot"})}),_.jsx("span",{children:"لیست بات‌ها"})]})]})})}const cS=()=>{const{injection:n}=Lt(["injection"]);return e=>{if(n!=null&&n.runGBTest)return n.runGBTest(e);console.warn("run gb test should be injected from host project")}},Ua={messengers__hint:"_messengers__hint_12tv6_6","messengers__hint-link":"_messengers__hint-link_12tv6_21","messengers__hint-text":"_messengers__hint-text_12tv6_28","messengers__hint-icon":"_messengers__hint-icon_12tv6_31","messengers__select-title":"_messengers__select-title_12tv6_39",messengers__registered:"_messengers__registered_12tv6_39","messengers__select-option":"_messengers__select-option_12tv6_48"},QP=[{id:1,title:"واتس‌اپ",link:"https://api.whatsapp.com/send?phone=989017065636&text=%D8%B3%D9%84%D8%A7%D9%85.%20%D8%AF%D8%B1%D8%AE%D9%88%D8%A7%D8%B3%D8%AA%20%D9%81%D8%B9%D8%A7%D9%84%D8%B3%D8%A7%D8%B2%DB%8C%20%D8%AF%D8%B1%DB%8C%D8%A7%D9%81%D8%AA%20%D8%A7%D8%B9%D9%84%D8%A7%D9%86%D8%A7%D8%AA%20%DA%AF%D9%81%D8%AA%DA%AF%D9%88%DB%8C%20%D8%A8%D8%A7%D8%B3%D9%84%D8%A7%D9%85%20%D8%AF%D8%B1%20%D9%88%D8%A7%D8%AA%D8%B3%D8%A7%D9%BE%20%D8%B1%D8%A7%20%D8%AF%D8%A7%D8%B1%D9%85"},{id:2,title:"تلگرام",link:"https://t.me/basalam_notif_bot"},{id:3,title:"بله",link:"https://ble.ir/basalam_notif_bot"}];function RX(){return uf.get("/api_v1.0/user/notifications/un_read_count")}function AX(){return uf.post("/api_v1.0/user/notifications/read_all")}function kX(n={}){return uf.get("/api_v1.0/user/notifications/",{...n,params:de.snakize((n==null?void 0:n.params)||{})})}function LX(n={}){return uf.get("/api_v1.0/user/notification-setting/chat",n)}function MX(n={}){return uf.delete("/api_v1.0/user/notification-setting/chat",n)}const NX=(n={})=>Yn(AX,n),JP=(n,e,t={})=>vO({...t,queryKey:["user","notifications",n,e],queryFn:({pageParam:r})=>kX({params:{tab:n,pageSize:e,pageNumber:(r==null?void 0:r.page)||1}}),getNextPageParam:(r,s)=>{const i=s.flatMap(o=>o.notifications);return(r==null?void 0:r.count)>i.length?{page:s.length+1}:void 0}}),ZP=(n={})=>Gn(["notif-count"],()=>RX(),n),OX=(n={})=>Gn(["notif-settings"],LX,n),PX=(n={})=>Yn(MX,n),eD=n=>QP.find(e=>e.id===n),DX=n=>{window.location.href=eD(n).link};function jX({show:n,onClose:e}){const[t,r]=T.useState(!1),[s,i]=T.useState(null),o=!At().isPc,{showSuccessSnackbar:a}=Mt.useSnackbar(),{data:l,refetch:c}=OX(),{mutate:d,isLoading:f}=PX({onError:to,onSuccess:()=>{a("دریافت اعلان در پیام‌رسان غیر فعال شد"),e(),c()}}),p=Cc(),{pagesBasePath:m}=Lt(["pagesBasePath"]),g=!(l!=null&&l.length)||t,v=()=>{r(!1),i(null),e()},y=()=>{e(),setTimeout(()=>{p(`${m}/600rP2`)},200)},b=()=>{r(!0)};return _.jsxs(lr,{size:"sm",show:n,onClose:v,title:"اعلان گفت‌وگوها در پیام‌رسان‌ها",primaryButton:g?_.jsx(Qe,{label:"ثبت",disabled:!s,onClick:()=>DX(s)}):null,children:[!t&&_.jsxs("div",{className:Ua.messengers__hint,children:["فقط می‌تونی در یکی از پیام‌رسان‌ها اعلان‌ پیام جدید در گفت‌وگوها را فعال کنی، اگه سوالی داشتی یا مشکلی بود، می‌تونی از اینجا بهمون پیام بدی.",_.jsx(je,{mt:8,display:"flex",justifyContent:"flex-end",children:_.jsxs("div",{onClick:y,className:Ua["messengers__hint-link"],children:[_.jsx(Mn,{name:"bi-chats",color:"var(--blue)",className:Ua["messengers__hint-icon"]}),_.jsx($d,{className:Ua["messengers__hint-text"],size:o?"sm":"md",label:"پشتیبانی در گفت‌وگو"})]})})]}),g?_.jsxs("div",{className:Ua.messengers__select,children:[_.jsx("div",{className:Ua["messengers__select-title"],children:"برای دریافت اعلان‌ پیام جدید گفت‌وگوها در پیام‌رسان‌ها، یکی از پیام‌رسان‌های زیر را انتخاب کن."}),_.jsx(gs.Group,{value:s,onChange:S=>i(+S),children:QP.map(S=>_.jsx(gs,{value:S.id,label:S.title,className:Ua["messengers__select-option"]},S.id))})]}):_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:Ua.messengers__registered,children:["اعلان پیام جدید گفت‌وگو‌ها در ",_.jsx("b",{children:eD(l[0]).title})," فعال است."]}),_.jsxs(je,{display:"flex",alignItems:"center",gap:16,children:[_.jsx(Qe,{variant:"outline",color:"secondary",loading:f,label:"غیر فعال‌سازی",onClick:d,size:o?"xs":"lg"}),_.jsx(Qe,{fullWidth:!0,icon:"bi-edit-square",variant:"outline",color:"secondary",loading:f,onClick:b,size:o?"xs":"lg",label:"تغییر پیام‌رسان برای دریافت اعلان"})]})]})]})}const $l={"contact-list-item-container":"_contact-list-item-container_92mca_6","contact-list-item":"_contact-list-item_92mca_6","contact-list-item__top":"_contact-list-item__top_92mca_54","contact-list-item__top-avatar":"_contact-list-item__top-avatar_92mca_68","contact-list-item__top-sender":"_contact-list-item__top-sender_92mca_71","contact-list-item__top-sender-name":"_contact-list-item__top-sender-name_92mca_80","contact-list-item__top-sender-vendor":"_contact-list-item__top-sender-vendor_92mca_120"},tD={"chat-list-item-skeleton":"_chat-list-item-skeleton_1a304_6","chat-list-item-skeleton--show":"_chat-list-item-skeleton--show_1a304_16"};function uS({className:n,show:e,radius:t=4,width:r="100%"}){const[s,i]=T.useState(!0);return T.useEffect(()=>{e?i(!0):setTimeout(()=>{i(!1)},500)},[e]),s?_.jsx(vt,{width:r,height:"100%",radius:t,className:Te(n,tD["chat-list-item-skeleton"],{[tD["chat-list-item-skeleton--show"]]:e})}):null}function FX({chat:n,contact:e,onClick:t}){var c,d,f;const r=T.useRef(),s=!At().isPc,[i,o]=T.useState(!1),a=((c=e==null?void 0:e.avatar)==null?void 0:c.extraSmall)&&!i,l=T.useMemo(()=>ad(e==null?void 0:e.lastActivity),[e==null?void 0:e.lastActivity]);return _.jsx("div",{ref:r,className:$l["contact-list-item-container"],children:_.jsx("div",{className:$l["contact-list-item"],onClick:()=>t==null?void 0:t(n),children:_.jsxs("div",{className:$l["contact-list-item__top"],children:[_.jsxs("div",{className:$l["contact-list-item__top-avatar"],children:[_.jsx(zs,{src:(d=e==null?void 0:e.avatar)==null?void 0:d.extraSmall,size:s?"40":"44",status:a?"offline":l,onLoad:()=>o(!0)}),_.jsx(uS,{show:a,radius:"50%"})]}),_.jsxs("div",{className:$l["contact-list-item__top-sender"],children:[_.jsxs("div",{className:$l["contact-list-item__top-sender-name"],children:[_.jsx("span",{children:e==null?void 0:e.name}),!!(e!=null&&e.badge)&&_.jsx(Xo,{label:e==null?void 0:e.badge,size:"sm",color:"black"})]}),!!(e!=null&&e.vendor)&&_.jsxs("span",{className:$l["contact-list-item__top-sender-vendor"],children:[_.jsx("i",{className:"bi-vendor"}),(f=e.vendor)==null?void 0:f.title]})]})]})})})}const UX={"contact-list":"_contact-list_1vqxr_6"},Ir={"empty-list":"_empty-list_83deu_6","empty-list__illustration":"_empty-list__illustration_83deu_14","empty-list__title":"_empty-list__title_83deu_18","empty-list__hints":"_empty-list__hints_83deu_25","empty-list__action":"_empty-list__action_83deu_31"};function Zp({title:n="هنوز با کسی گفت‌وگو نداشتی"}){return _.jsxs("div",{className:Ir["empty-list"],children:[_.jsx("img",{className:Ir["empty-list__illustration"],src:"https://statics.basalam.com/public-63/admin/Ddrd75/02-16/0IEzG4Xzn31sjerX1YkvJJ7yFgPvnj80NB4T9xTJyMExlVsRfI.SVG",alt:n}),_.jsx("span",{className:Ir["empty-list__title"],children:n})]})}function BX({className:n,onClick:e}){var o;const{featureFlags:t}=Lt(["featureFlags"]),s=((o=t==null?void 0:t.features)==null?void 0:o.botsList).map(a=>({...a,contact:Jp(a.contact)})),i=s.length>0;return _.jsx("div",{id:"contact-list",className:Te(UX["contact-list"],n),children:i?_.jsx(_.Fragment,{children:s.map(a=>_.jsx(FX,{chat:a,contact:a.contact,onClick:e},a.id))}):_.jsx(Zp,{title:"باتی پیدا نشد"})})}const $X=T.memo(BX),dS={};function zX({show:n,onClose:e}){const{push:t}=Si(),{openChat:r}=Wc(),s=o=>{var a;r({identifier:(a=o.contact)==null?void 0:a.identifier}),e()},i=T.useCallback(()=>{e()},[e]);return T.useEffect(()=>n?t(()=>{i()}):void 0,[n,t,i]),_.jsx(lr,{size:"sm",showClose:!0,show:n,title:"لیست بات ها",bodyClass:dS["bots-list-modal-body"],onClose:i,className:"dataset-inp-ChatBotsListModal",children:_.jsx("div",{className:dS["bots-list-modal"],children:_.jsx($X,{className:dS["bots-list-modal__list"],onClick:s})})})}const xr={CHAT_WARN:"CHAT_WARN",DEVICE_ID:"DALAN_DEVICE_ID",ARCHIVE_CHATS:"ARCHIVE_CHATS",ACCESS_TOKEN:"DALAN_ACCESS_TOKEN",READY_MESSAGE_SENT:"READY_MESSAGE_SENT",CHAT_SIDEBAR_WIDTH:"CHAT_SIDEBAR_WIDTH",SECURE_CALL_TOOLTIP:"SECURE_CALL_TOOLTIP",RECENT_USED_STICKERS:"RECENT_USED_STICKERS",MICROPHONE_PERMISSION:"MICROPHONE_PERMISSION",MESSENGERS_NOTIF_SHOW:"MESSENGERS_NOTIF_SHOW"};function nD({isCompact:n}){var N,D,M,F,U;const e=T.useRef(),[t,r]=T.useState(!1),[s,i]=T.useState(!1),[o,a]=T.useState(!de.bsLocalStorage.getItem(xr.MESSENGERS_NOTIF_SHOW)),l=cS(),{isMobile:c,isForceMobile:d}=At(),{currentUser:f,featureFlags:p}=Lt(["currentUser","featureFlags"]),{publishEvent:m}=Fr(),v=!!(f!=null&&f.vendor)&&((N=l("test_messengers_notification"))==null?void 0:N.value),y=(D=p==null?void 0:p.features)==null?void 0:D.chatListMoreOptions,b=(M=p==null?void 0:p.features)==null?void 0:M.savedMessage,S=((U=(F=p==null?void 0:p.features)==null?void 0:F.botsList)==null?void 0:U.length)>0,[E,{open:C,close:R}]=Mt.useDisclosure(),I=()=>{setTimeout(()=>{r(!0),a(!1),de.bsLocalStorage.setItem(xr.MESSENGERS_NOTIF_SHOW,"true"),requestIdleCallback(()=>{m("chatHeaderOptionsClick",{})})},0)},A=()=>{setTimeout(()=>{i(!0)},0)},k=()=>{setTimeout(()=>{i(!1)},0)};return _.jsxs(_.Fragment,{children:[y&&_.jsx("div",{ref:e,className:Te(Kp["header-options__more"],{[Kp["header-options__more--compact"]]:n}),children:_.jsxs(Qe,{size:"xxs",variant:"text",onClick:I,className:Kp["header-options__more-icon"],children:[_.jsx("i",{className:Te({"bi-more-v":!n,"bi-more-options":n})}),o&&_.jsx("span",{className:Kp["header-options__more-icon-dot"]})]})}),v&&_.jsx(jX,{show:E,onClose:R}),y&&_.jsx(IX,{mode:c&&!d?"modal":"popover",show:t,anchorEl:e.current,options:{botsList:S,savedMessage:b,messenger:v},onOpenMessengerModal:C,onCloseMessengerModal:R,onOpenBotsListModal:A,onCloseBotsListModal:k,onClose:()=>r(!1)}),s&&_.jsx(zX,{show:s,onClose:k})]})}var fS,rD;function qX(){if(rD)return fS;rD=1;var n=Hi(),e=function(){return n.Date.now()};return fS=e,fS}var hS,sD;function HX(){if(sD)return hS;sD=1;var n=/\s/;function e(t){for(var r=t.length;r--&&n.test(t.charAt(r)););return r}return hS=e,hS}var pS,iD;function GX(){if(iD)return pS;iD=1;var n=HX(),e=/^\s+/;function t(r){return r&&r.slice(0,n(r)+1).replace(e,"")}return pS=t,pS}var mS,oD;function VX(){if(oD)return mS;oD=1;var n=GX(),e=Wo(),t=Fh(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;function l(c){if(typeof c=="number")return c;if(t(c))return r;if(e(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=e(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=n(c);var f=i.test(c);return f||o.test(c)?a(c.slice(2),f?2:8):s.test(c)?r:+c}return mS=l,mS}var gS,aD;function WX(){if(aD)return gS;aD=1;var n=Wo(),e=qX(),t=VX(),r="Expected a function",s=Math.max,i=Math.min;function o(a,l,c){var d,f,p,m,g,v,y=0,b=!1,S=!1,E=!0;if(typeof a!="function")throw new TypeError(r);l=t(l)||0,n(c)&&(b=!!c.leading,S="maxWait"in c,p=S?s(t(c.maxWait)||0,l):p,E="trailing"in c?!!c.trailing:E);function C(U){var $=d,q=f;return d=f=void 0,y=U,m=a.apply(q,$),m}function R(U){return y=U,g=setTimeout(k,l),b?C(U):m}function I(U){var $=U-v,q=U-y,G=l-$;return S?i(G,p-q):G}function A(U){var $=U-v,q=U-y;return v===void 0||$>=l||$<0||S&&q>=p}function k(){var U=e();if(A(U))return N(U);g=setTimeout(k,I(U))}function N(U){return g=void 0,E&&d?C(U):(d=f=void 0,m)}function D(){g!==void 0&&clearTimeout(g),y=0,d=v=f=g=void 0}function M(){return g===void 0?m:N(e())}function F(){var U=e(),$=A(U);if(d=arguments,f=this,v=U,$){if(g===void 0)return R(v);if(S)return clearTimeout(g),g=setTimeout(k,l),C(v)}return g===void 0&&(g=setTimeout(k,l)),m}return F.cancel=D,F.flush=M,F}return gS=o,gS}var KX=WX();const _S=ba(KX);function YX(n,e,t){const[r,s]=T.useState(!1),i=T.useCallback(l=>{n(l),s(!1)},[n]),o=T.useCallback(_S(i,e),[i]);return{isLoading:r,debouncedHandler:l=>{o(l),r||setTimeout(()=>{s(!0)},50)}}}function XX({disabled:n,onSearch:e,className:t,onShowSearch:r,setIsLoadingSearch:s}){const i=T.useRef(),[o,a]=T.useState(""),[l,c]=T.useState(!1),[d,f]=T.useState(!1),[p,m]=T.useState("MESSAGES"),{publishEvent:g}=Fr(),v=!At().isPc,y=T.useCallback(D=>{e({query:D,type:p})},[e,p]),{debouncedHandler:b,isLoading:S}=YX(y,1e3);T.useEffect(()=>{S&&s(S)},[S,s]);const E=D=>{D!==o&&(a(D),b(D))},C=D=>{m(D),setTimeout(()=>{e({query:o,type:D}),f(!1)},0)},R=()=>{setTimeout(()=>{m("MESSAGES"),E("")},0)},I=()=>{setTimeout(()=>{c(!0),r==null||r(!0),requestIdleCallback(()=>{var D;(D=i.current)==null||D.focus(),g("chatHeaderSearchClick",{})})},0)},A=()=>{setTimeout(()=>{m("MESSAGES"),E(""),c(!1),r==null||r(!1)},0)},k=()=>{setTimeout(()=>{f(!0)},0)},N=()=>{setTimeout(()=>{f(!1)},0)};return _.jsx("div",{className:Te(t,Kr["chat-list-search"],{[Kr["chat-list-search--no-border"]]:!v}),children:l?_.jsxs("div",{children:[_.jsxs("div",{className:Kr["search-modal__header"],children:[_.jsx(Qe,{variant:"text",size:"xxs",className:Kr["search-modal__header-back"],onClick:A,children:_.jsx("i",{className:"bi-right"})}),_.jsxs("div",{className:Kr["search-modal__header-box"],children:[_.jsxs("div",{className:Kr["search-modal__header-box-form"],children:[_.jsx("input",{ref:i,className:Te(Kr["search-modal__header-box-input"],{[Kr["search-modal__header-box-input--isSearching"]]:o.length>0}),value:o,type:"text",placeholder:"جست‌وجو در گفت‌وگوها",disabled:n,onInput:D=>E(D.target.value)}),_.jsx(Mr,{mounted:o.length>0,transition:"fade",duration:250,children:D=>_.jsx("div",{style:D,className:Kr["search-modal__header-box-clear"],children:_.jsx(Qe,{onClick:R,size:"xxs",color:"secondary",variant:"text",children:_.jsx("i",{className:"bi-close"})})})})]}),_.jsxs("button",{disabled:n,className:Kr["search-modal__header-box-select"],onClick:()=>!n&&k(),children:[_.jsx("i",{className:Te("bi-angle-down",Kr["search-modal__header-box-select-icon"])}),_.jsx("span",{children:p==="MESSAGES"?"متن گفت‌وگوها":"اسم آدم‌ها"})]})]})]}),_.jsx(lr,{hideOtherModals:!1,show:d,onClose:N,title:"جستجو بر اساس",children:_.jsxs(gs.Group,{value:p,onChange:C,children:[_.jsx("div",{className:Kr["types-modal__item"],children:_.jsx(gs,{disabled:n,value:"MESSAGES",label:_.jsx("span",{className:Kr["types-modal__item-label"],children:"متن گفت‌وگوها"})})}),_.jsx("div",{className:Kr["types-modal__item"],children:_.jsx(gs,{disabled:n,value:"CONTACTS",label:_.jsx("span",{className:Kr["types-modal__item-label"],children:"اسم آدم‌ها"})})})]})})]}):_.jsxs("div",{className:Kr["chat-list-search__header"],children:[_.jsx("div",{className:Kr["chat-list-search__header-title"],children:"گفت‌وگو‌ها"}),_.jsx(Qe,{disabled:n,size:"xxs",variant:"text",onClick:I,className:Kr["chat-list-search__header-search-icon"],children:_.jsx("i",{className:"bi-search"})}),_.jsx(nD,{})]})})}const Ro={"chat-list-filter":"_chat-list-filter_1efe3_6","chat-list-filter__item":"_chat-list-filter__item_1efe3_11","chat-list-filter__item-text":"_chat-list-filter__item-text_1efe3_17","chat-list-filter__item--active":"_chat-list-filter__item--active_1efe3_22"},QX=T.forwardRef(function({disabled:e,onChange:t,className:r},s){var d;const[i,o]=T.useState(null),{currentUser:a}=Lt(["currentUser"]),l=(d=a==null?void 0:a.vendor)==null?void 0:d.isActive,c=f=>{o(f),setTimeout(()=>{t(f)},0)};return T.useImperativeHandle(s,()=>({filter:i,updateFilter:f=>o(f)}),[i]),_.jsxs("div",{className:Te(r,Ro["chat-list-filter"]),children:[_.jsx(Qe,{disabled:e,size:"xxs",variant:"outline",color:"secondary",className:Te(Ro["chat-list-filter__item"],{[Ro["chat-list-filter__item--active"]]:i===null}),onClick:()=>c(null),children:_.jsx("span",{className:Ro["chat-list-filter__item-text"],children:"همه"})}),_.jsx(Qe,{disabled:e,size:"xxs",variant:"outline",color:"secondary",className:Te(Ro["chat-list-filter__item"],{[Ro["chat-list-filter__item--active"]]:i==="unseen"}),onClick:()=>c("unseen"),children:_.jsx("span",{className:Ro["chat-list-filter__item-text"],children:"خوانده نشده‌ها"})}),l&&_.jsx(Qe,{disabled:e,size:"xxs",variant:"outline",color:"secondary",className:Te(Ro["chat-list-filter__item"],{[Ro["chat-list-filter__item--active"]]:i==="order"}),onClick:()=>c("order"),children:_.jsx("span",{className:Ro["chat-list-filter__item-text"],children:"سفارش‌های جاری"})})]})}),zl={"chat-list":"_chat-list_6fj3l_6","chat-list__header":"_chat-list__header_6fj3l_14","chat-list__header-search":"_chat-list__header-search_6fj3l_17","chat-list__header-filters":"_chat-list__header-filters_6fj3l_20","chat-list__items":"_chat-list__items_6fj3l_23","chat-list__items--full-height":"_chat-list__items--full-height_6fj3l_54","chat-list--compact":"_chat-list--compact_6fj3l_77"},cn={message__wrapper:"_message__wrapper_1ls7w_6",message__wrapper__container:"_message__wrapper__container_1ls7w_11","message__wrapper__container--sender":"_message__wrapper__container--sender_1ls7w_21","message__wrapper__container--receiver":"_message__wrapper__container--receiver_1ls7w_33",message__wrapper__buttons:"_message__wrapper__buttons_1ls7w_28","message__wrapper__buttons-row":"_message__wrapper__buttons-row_1ls7w_53","message__wrapper__buttons-btn":"_message__wrapper__buttons-btn_1ls7w_57","message__wrapper--selected":"_message__wrapper--selected_1ls7w_62","background-fade-in":"_background-fade-in_1ls7w_1",message__wrapper__content:"_message__wrapper__content_1ls7w_88","message__wrapper--select-mode":"_message__wrapper--select-mode_1ls7w_91","message__wrapper--long-pressing":"_message__wrapper--long-pressing_1ls7w_99","message__wrapper--drag-selecting":"_message__wrapper--drag-selecting_1ls7w_107","message__wrapper-reply-swipe":"_message__wrapper-reply-swipe_1ls7w_113","message__wrapper-reply-swipe-me":"_message__wrapper-reply-swipe-me_1ls7w_119",message__wrapper__checkbox:"_message__wrapper__checkbox_1ls7w_122","fade-in":"_fade-in_1ls7w_1",message__wrapper__avatar:"_message__wrapper__avatar_1ls7w_139","message__wrapper__content--sender":"_message__wrapper__content--sender_1ls7w_164","message__wrapper__content--sticker":"_message__wrapper__content--sticker_1ls7w_167","message__wrapper__content--receiver":"_message__wrapper__content--receiver_1ls7w_170","message__wrapper__content--starter-receiver":"_message__wrapper__content--starter-receiver_1ls7w_173","message__wrapper__content--starter-sender":"_message__wrapper__content--starter-sender_1ls7w_176","message__wrapper__content--highlight":"_message__wrapper__content--highlight_1ls7w_179",fade:"_fade_1ls7w_1","message__wrapper__content--highlight-reverse":"_message__wrapper__content--highlight-reverse_1ls7w_232","message__wrapper__content--new":"_message__wrapper__content--new_1ls7w_240","new-receiver":"_new-receiver_1ls7w_1","message__wrapper__content--deleted":"_message__wrapper__content--deleted_1ls7w_256",delete:"_delete_1ls7w_1","message__wrapper__content--error":"_message__wrapper__content--error_1ls7w_275","chat-widget-mobile":"_chat-widget-mobile_1ls7w_1"};function em(n,e){n.style.scrollBehavior="smooth",n.scrollTop=e,setTimeout(()=>{n.style.scrollBehavior="initial"},0)}function lD(n,e){n.style.scrollBehavior="initial",n.scrollTop=e}function tm(n){n.current&&n.current.scrollToIndex({offset:100,align:"end",index:"LAST",behavior:"smooth"})}async function vS(n,e,t){if(!(t!=null&&t.current)||!(e!=null&&e.length))return"not-found";const r=e.findIndex(l=>String(l.id)===String(n)||String(l.uuid)===String(n));if(r===-1)return"not-found";t.current.scrollIntoView({align:"center",behavior:"smooth",calculateViewLocation:({itemTop:l,itemBottom:c,viewportTop:d,viewportBottom:f})=>l<d?{index:r,align:"start",behavior:"smooth"}:c>f?{index:r,align:"end",behavior:"smooth"}:null}),await de.sleep(300);const s=document.querySelector(`#chat-area-messages-message-${n}`);if(!s)return"not-found";const i=document.querySelector("#chat-area-messages"),o=i==null?void 0:i.getBoundingClientRect(),a=s.getBoundingClientRect();if(o){const l=o.width-a.width-32;s.style.setProperty("--highlight-right-distance-in-chat",`-${l}px`)}s.classList.add(cn["message__wrapper__content--highlight"]),s.classList.contains(cn["message__wrapper__content--sender"])&&s.classList.add(cn["message__wrapper__content--highlight-reverse"]),await de.sleep(2e3),s.classList.remove(cn["message__wrapper__content--highlight"]),s.classList.contains(cn["message__wrapper__content--sender"])&&s.classList.remove(cn["message__wrapper__content--highlight-reverse"])}async function yS(n){const e=document.querySelector("#chat-area-messages"),t=document.querySelector(`#chat-area-messages-message-${n}`);if(!t)return"not-found";const r=e.getBoundingClientRect(),s=t.getBoundingClientRect(),i=s.top-r.top+e.scrollTop-16,o=r.width-s.width-32;em(e,i),t.style.setProperty("--highlight-right-distance-in-chat",`-${o}px`),t.classList.add(cn["message__wrapper__content--highlight"]),t.classList.contains(cn["message__wrapper__content--sender"])&&t.classList.add(cn["message__wrapper__content--highlight-reverse"]),await de.sleep(2e3),t.classList.remove(cn["message__wrapper__content--highlight"]),t.classList.contains(cn["message__wrapper__content--sender"])&&t.classList.remove(cn["message__wrapper__content--highlight-reverse"])}const li={"chat-list-item":"_chat-list-item_1qxdb_6","chat-list-item__top":"_chat-list-item__top_1qxdb_11","chat-list-item__top-avatar":"_chat-list-item__top-avatar_1qxdb_16","chat-list-item__top-sender":"_chat-list-item__top-sender_1qxdb_19","chat-list-item__top-sender-name":"_chat-list-item__top-sender-name_1qxdb_35","chat-list-item__top-sender-vendor":"_chat-list-item__top-sender-vendor_1qxdb_55","chat-list-item__top-time":"_chat-list-item__top-time_1qxdb_71","chat-list-item--compact":"_chat-list-item--compact_1qxdb_87","chat-list-item__bottom":"_chat-list-item__bottom_1qxdb_103","chat-list-item__bottom-message":"_chat-list-item__bottom-message_1qxdb_116"};function JX({className:n,isCompact:e=!1}){const t=At().isMobile,r=e?56:t?40:44;return e?_.jsx("div",{className:Te(n,li["chat-list-item"],li["chat-list-item--compact"]),children:_.jsx("div",{className:li["chat-list-item__top"],children:_.jsx("div",{className:li["chat-list-item__top-avatar"],children:_.jsx(vt,{radius:"100%",width:r,height:r})})})}):_.jsxs("div",{className:Te(n,li["chat-list-item"]),children:[_.jsxs("div",{className:li["chat-list-item__top"],children:[_.jsx("div",{className:li["chat-list-item__top-avatar"],children:_.jsx(vt,{radius:"100%",width:r,height:r})}),_.jsxs("div",{className:li["chat-list-item__top-sender"],children:[_.jsx("div",{className:li["chat-list-item__top-sender-name"],children:_.jsx(vt,{radius:4,width:170,height:25})}),_.jsx("span",{className:li["chat-list-item__top-sender-vendor"],children:_.jsx(vt,{radius:4,width:120,height:18})})]}),_.jsx("div",{className:Te(li["chat-list-item__top-time"]),children:_.jsx(vt,{radius:4,width:50,height:22})})]}),_.jsx("div",{className:li["chat-list-item__bottom"],children:_.jsx("div",{className:li["chat-list-item__bottom-message"],children:_.jsx(vt,{radius:4,width:280,height:20})})})]})}function nm(n){return[Bt.CHANNEL,Zi.CHANNEL,Zi.SUPPORT].includes(n)}function bS(n){return n==null?void 0:n.isAdmin}function ZX({userIds:n,onlyMaxActionTime:e}){return aP.post("/api_v1.0/user-last-activity/get-activities",de.snakize({userIds:n,onlyMaxActionTime:e}))}function eQ({userId:n,onlyMaxActionTime:e}){return aP.get(`/api_v1.0/user-last-activity/${n}`,{params:de.snakize({onlyMaxActionTime:e})})}const tQ={limit:30,autoUpdate:!0,filterChannels:!1};function xS({limit:n,autoUpdate:e,filterChannels:t,openedChatIdentifier:r}=tQ){var le,Ie;const s=T.useRef(),{emitEvent:i}=Mt.useEmitter(),[o,a]=T.useState(null),{isLoggedIn:l,featureFlags:c}=Lt(["isLoggedIn","featureFlags"]),[d,f]=T.useState({}),[p,m]=T.useState(""),[g,v]=T.useState("CONTACTS"),[y,b]=T.useState(!0),[S,E]=T.useState([]),[C,R]=T.useState(!1),I=T.useRef(),A=!!((le=c==null?void 0:c.features)!=null&&le.chat),k=T.useMemo(()=>p.trim().length>0,[p]),N=T.useMemo(()=>o!==null,[o]),D=T.useCallback(async be=>{const ge=[];return be.forEach(Ae=>{if(Ae.chatType!==Bt.PRIVATE)return;const Re=Ae.contact.id;d[Re]===void 0&&ge.push(Re)}),ge.length>0&&ZX({onlyMaxActionTime:!0,userIds:ge}).then(Ae=>{if(Ae){const Re={...d,...Ae};f(Re),E(tt=>tt.map(et=>{var Oe,ht;return et.chatType===Bt.PRIVATE&&Ae[(Oe=et.contact)==null?void 0:Oe.id]?{...et,contact:{...et.contact,lastActivity:Ae[(ht=et.contact)==null?void 0:ht.id]}}:et}))}}).catch(Ae=>{console.error("Failed to fetch user activities:",Ae)}),d},[d]),{isError:M,isLoading:F,hasNextPage:U,fetchNextPage:$,refetch:q,isFetchingNextPage:G,error:V}=wY({limit:n,filter:o,searchType:g,isLoggedIn:l,query:p},{enabled:A,onSuccess:async({pages:be})=>{var et;const Ae=((et=be.at(-1))==null?void 0:et.data).chats.filter(Oe=>{var ht;return Oe.chatType===Bt.PRIVATE?!!((ht=Oe.contact)!=null&&ht.id):Oe.chatType===Bt.CHANNEL?t?bS(Oe.channel):!0:Oe.chatType===Bt.GROUP?!0:Oe.chatType===Bt.BOT?!!Oe.contact:!1}),Re=await D(Ae),tt=[];Ae.forEach(Oe=>{var Xe,Je;const ht={uuid:Vn(),...Oe,searchedMessage:Oe.message};if(delete ht.message,Oe.chatType===Bt.PRIVATE){const qe=Re==null?void 0:Re[(Xe=Oe.contact)==null?void 0:Xe.id];ht.contact={...hf(ht.contact),snippet:(Je=Oe.contact)==null?void 0:Je.snippet,lastActivity:qe||null}}else Oe.chatType===Bt.CHANNEL?ht.contact=Xp(Oe.channel):Oe.chatType===Bt.GROUP?ht.contact=Qp(Oe.group):Oe.chatType===Bt.BOT&&(ht.contact=Jp(ht.contact));tt.push(ht)}),be.length<=1?E(()=>[...tt]):E(Oe=>[...Oe,...tt]),f(Oe=>({...Oe,...Re})),b(!1),setTimeout(()=>{R(!1)},0)}}),{refetch:z}=TY({limit:30,updatedFrom:(Ie=S[0])==null?void 0:Ie.updatedAt,isLoggedIn:l},{enabled:!1,onSuccess:async({data:be})=>{if(be.chats.length===0)return;const ge=await D(be.chats);E(Ae=>{const Re=[...Ae];return be.chats.reverse().forEach(tt=>{var Oe,ht,Xe;const et=Re.findIndex(Je=>Je.id===tt.id);if(et===-1){const Je={uuid:Vn(),...tt};Je.chatType===Bt.PRIVATE?Je.contact={...hf(Je.contact),lastActivity:(ge==null?void 0:ge[(Oe=tt.contact)==null?void 0:Oe.id])||null}:Je.chatType===Bt.CHANNEL?Je.contact=Xp(Je.channel):Je.chatType===Bt.GROUP?Je.contact=Qp(Je.group):tt.chatType===Bt.BOT&&(Je.contact=Jp(Je.contact)),((ht=Je.contact)==null?void 0:ht.identifier)===r&&(Je.unseenMessageCount=0),Re.unshift(Je)}else{const Je=Re[et];Re.splice(et,1);let qe=tt.unseenMessageCount;((Xe=Je.contact)==null?void 0:Xe.identifier)===r&&(i(Ct.BROADCAST_TO_ALL,{customType:"markAsRead",data:{chatIndex:et}}),qe=0),Re.unshift({...tt,uuid:Je.uuid,unseenMessageCount:qe,contact:Je.contact,chatType:Je.chatType})}}),Re})}}),B=T.useCallback(()=>{!F&&U&&!G&&!y&&$()},[$,U,G,F,y]),P=()=>{b(!0),q()},H=T.useCallback(()=>{clearTimeout(s.current),s.current=setTimeout(()=>{!k&&!N&&z(),H()},1e4)},[k,N,z]),Z=be=>{be!==o&&(b(!0),E([]),a(be))},Q=T.useCallback(({query:be,type:ge})=>{be&&R(!0),(be!==p||ge!==g&&be)&&(b(!0),E([]),m(be),v(ge))},[p,g]),J=T.useCallback(({chatId:be,chatUpdate:ge})=>{E(Ae=>{const Re=Ae.findIndex(ht=>ht.id===be);if(Re===-1)return z(),Ae;const tt=Ae[Re],et=[...Ae],Oe=typeof ge=="function"?ge(tt):ge;return et[Re]={...tt,...Oe},et})},[z]),ee=T.useCallback(({message:be,chatId:ge})=>{E(Ae=>{const Re=Ae.findIndex(Oe=>Oe.id===ge);if(Re===-1)return z(),Ae;const tt=Ae[Re],et=[...Ae];return et[Re]={...tt,lastMessage:be,updatedAt:(be==null?void 0:be.createdAt)||(tt==null?void 0:tt.updatedAt)},et.sort((Oe,ht)=>Oe.updatedAt>ht.updatedAt?-1:1),et})},[E,z]),K=T.useCallback(be=>{E(ge=>{const Ae=ge.findIndex(et=>et.id===be.id);if(Ae===-1)return[be,...ge];const Re=[...ge],tt=Re[Ae];return Re[Ae]={...tt,...be,unseenMessageCount:tt.unseenMessageCount+1},Re.sort((et,Oe)=>et.updatedAt>Oe.updatedAt?-1:1),Re})},[]),W=T.useCallback(be=>{E(ge=>{const Ae=ge;return Ae[be].contactIsBlocked=!0,Ae})},[]),te=T.useCallback((be,ge=!0)=>{ge&&i(Ct.BROADCAST_TO_ALL,{customType:"markAsRead",data:{chatIndex:be}}),E(Ae=>{const Re=Ae;return Re[be].markedAsUnread=!1,Re})},[i]),re=T.useCallback(be=>{E(ge=>{const Ae=ge;return Ae[be].markedAsUnread=!0,Ae})},[]);T.useEffect(()=>{i("markAsRead",({data:be})=>{te(be.chatIndex,!1)})},[te,i]),T.useEffect(()=>()=>{I.current&&clearTimeout(I.current)},[]),T.useEffect(()=>(e?H():clearTimeout(s.current),()=>{clearTimeout(s.current)}),[e,k,N]);let pe=null;M&&(hr.isAxiosError(V)?V.response?V.response.status>=500&&V.response.status<600?pe="SERVER":pe="OTHER":pe="NETWORK":pe="UNKNOWN");const Ee=T.useMemo(()=>S,[S]);return{block:W,search:Q,errorType:pe,searchType:g,markAsRead:te,applyFilter:Z,isSearching:k,isFiltering:N,getNextChats:B,markAsUnread:re,isLoadingSearch:C,hasError:M,isLoadingChatList:F,updateChatListById:J,setIsLoadingSearch:R,chats:Ee,loadingModifyChatList:y,updateChatListBySocket:K,updateChatListLastMessage:ee,isFetchingNextPageChatList:G,hasMoreChats:!!U,updateChats:z,refetchChatList:P}}function nQ({retry:n}){return _.jsxs("div",{className:Ir["empty-list"],children:[_.jsx("img",{className:Ir["empty-list__illustration"],src:"https://statics.basalam.com/public-63/admin/Ddrd75/02-16/zzvnmML9ziihXTc10aoZFyUJsxuiMHWXwU02dS8X3clymVZhKQ.SVG",alt:"سرور پاسخ نمی‌دهد"}),_.jsx("span",{className:Ir["empty-list__title"],children:"سرور باسلام پاسخ نمی‌ده"}),_.jsx("div",{className:Ir["empty-list__hints"],children:_.jsx("div",{children:"لطفا یه نفس عمیق بکش و دوباره امتحان کن."})}),_.jsx(Qe,{size:"sm",icon:"bi-refresh-single",iconPosition:"center-start",variant:"fill",label:"دوباره امتحان کنیم",className:Ir["empty-list__action"],onClick:n})]})}function rQ({retry:n}){return _.jsxs("div",{className:Ir["empty-list"],children:[_.jsx("img",{className:Ir["empty-list__illustration"],src:"https://statics.basalam.com/public-63/admin/Ddrd75/02-16/AKrZYwzABbNG2PzWEsImSuoj90VPwZARQ2AyI9GLraJAnGgoQ2.SVG",alt:"اتصالت به اینترنت قطع شده"}),_.jsx("span",{className:Ir["empty-list__title"],children:"گویا اتصالت به اینترنت قطع شده"}),_.jsx("div",{className:Ir["empty-list__hints"],children:_.jsx("div",{children:"لطفا بعد از بررسی اینترنتت، دوباره امتحان کن."})}),_.jsx(Qe,{size:"sm",icon:"bi-refresh-single",iconPosition:"center-start",variant:"fill",label:"دوباره امتحان کنیم",className:Ir["empty-list__action"],onClick:n})]})}function SS({searchType:n}){const e=n==="MESSAGES";return _.jsxs("div",{className:Ir["empty-list"],children:[_.jsx("img",{className:Ir["empty-list__illustration"],src:"https://statics.basalam.com/public-13/admin/b28/10-09/S8xey4XNdzddRqVfcb5VlqyEwIfCdG4FirwqeELhqraLmdga0T.SVG",alt:"پیدا نشد!"}),_.jsx("span",{className:Ir["empty-list__title"],children:"نتونستیم گفت‌وگویی پیدا کنیم"}),_.jsx("div",{className:Ir["empty-list__hints"],children:_.jsxs("div",{children:["ببین ",e?"کلمه":"اسم"," رو درست نوشتی."," ",e?"در اسم آدم‌ها جستجو کن.":"در متن گفت‌وگوها جستجو کن."]})})]})}function ES({onFilterClear:n}){return _.jsxs("div",{className:Ir["empty-list"],children:[_.jsx("img",{className:Ir["empty-list__illustration"],src:"https://statics.basalam.com/public-63/admin/Ddrd75/02-16/0IEzG4Xzn31sjerX1YkvJJ7yFgPvnj80NB4T9xTJyMExlVsRfI.SVG",alt:"نتونستیم گفت‌وگویی پیدا کنیم"}),_.jsx("span",{className:Ir["empty-list__title"],children:"نتونستیم گفت‌وگویی پیدا کنیم"}),_.jsx(Qe,{size:"sm",color:"secondary",variant:"outline",label:"پاک کردن فیلتر",className:Ir["empty-list__action"],onClick:n})]})}function sQ(){var m,g,v;const{isLoggedIn:n}=Lt(["isLoggedIn"]),{unseenMessageCount:e}=Bl(["unseenMessageCount"]),{updateNotification:t,updateUnseenMessageCount:r}=ff(),{setUnseenMessages:s}=$i(),{data:i,refetch:o}=ZP({enabled:!1,onSuccess:y=>{r(y),s(b=>({...b,notification:y.count}))}});T.useEffect(()=>{n&&o()},[n]);const{data:a}=JP("all",1,{enabled:n}),l=T.useMemo(()=>(a==null?void 0:a.pages.flatMap(y=>y.notifications))||[],[a]),c=(m=l==null?void 0:l[0])==null?void 0:m.createdAt,d=(g=l==null?void 0:l[0])==null?void 0:g.readAt,f=(v=l==null?void 0:l[0])==null?void 0:v.title,p=(e==null?void 0:e.count)??(i==null?void 0:i.count);T.useEffect(()=>{t(y=>({...y,updatedAt:c,unseenMessageCount:p,lastMessage:{...y.lastMessage,seenAt:d,createdAt:c,message:{...y.lastMessage.message,text:f}}}))},[f,c,d,p])}function iQ({className:n,isCompact:e=!1,filterChannels:t=!1,onSearchStateChange:r}){var nt,dt,Ot,xt,rt;const{subEvent:s,offEvent:i,emitEvent:o}=Mt.useEmitter(),{isLoggedIn:a,socketConnected:l,featureFlags:c}=Lt(["isLoggedIn","featureFlags","socketConnected"]),{chat:d,identifier:f}=Tn(["chat","identifier"]),{setChat:p}=ai(),{openChat:m,closeChat:g}=Wc(),{setUnseenMessages:v}=$i(),{publishEvent:y}=Fr(),{chats:b,block:S,search:E,markAsRead:C,applyFilter:R,updateChats:I,isSearching:A,searchType:k,isFiltering:N,markAsUnread:D,getNextChats:M,updateChatListLastMessage:F,updateChatListById:U,updateChatListBySocket:$,refetchChatList:q,hasMoreChats:G,isLoadingChatList:V,loadingModifyChatList:z,isLoadingSearch:B,setIsLoadingSearch:P,errorType:H,hasError:Z}=xS({limit:30,filterChannels:t,autoUpdate:!l,openedChatIdentifier:f}),[Q,J]=[(nt=c==null?void 0:c.features)==null?void 0:nt.searchChatList,(dt=c==null?void 0:c.features)==null?void 0:dt.unseenChatListFilter],ee=(Q||J)&&a,W=At().isMobile,{notification:te}=Bl(["notification"]),[re,pe]=T.useState(!1),[Ee,le]=T.useState(!1),Ie=T.useRef(new Map),{mutate:be}=qc(),ge=e&&!A&&!N&&!Ee,Ae=A||N||Ee;T.useEffect(()=>{r==null||r(Ae)},[Ae,r]);const Re=T.useCallback(async(Me,lt)=>{var mt,gt;const Vt=(mt=d==null?void 0:d.searchedMessage)==null?void 0:mt.id,vn=(gt=Me==null?void 0:Me.searchedMessage)==null?void 0:gt.id;if(Vt&&vn&&Vt===vn)try{await yS(Vt)}catch{}else{const Wt={...Me};Me.markedAsUnread&&be({payload:{chatIds:[Me.id]},status:Fc.MARK_READ}),C(lt),m({chat:{...Wt}}),(d==null?void 0:d.id)===-2&&requestIdleCallback(()=>{y("customerViewNotification",{keepthis:null})})}},[(Ot=d==null?void 0:d.searchedMessage)==null?void 0:Ot.id,d==null?void 0:d.id,C,m,be,y]),tt=T.useCallback(Me=>{var lt;((lt=Me.contact)==null?void 0:lt.identifier)===f&&g()},[f,g]),et=T.useCallback((Me,lt,Vt)=>{var mt,gt,Wt;const vn=(mt=d==null?void 0:d.searchedMessage)==null?void 0:mt.id,pt=(gt=lt==null?void 0:lt.searchedMessage)==null?void 0:gt.id;return _.jsx(HP,{chat:lt,contact:lt.contact,isActive:pt?vn===pt:f===((Wt=lt.contact)==null?void 0:Wt.identifier),onDelete:tt,onBlock:()=>S(Me),onMarkAsRead:()=>C(Me),onMarkAsUnread:()=>D(Me),onClick:ot=>Re(ot,Me),bottomBordered:Me!==Vt.length-1,isCompact:ge},lt.id)},[(xt=d==null?void 0:d.searchedMessage)==null?void 0:xt.id,f,tt,S,C,D,Re,ge]),Oe=T.useRef(),ht=()=>{var Me;(Me=Oe.current)==null||Me.updateFilter(null),setTimeout(()=>{R(null)},0)};Mt.useEffectNoImmediate(()=>{a&&q()},[a]),T.useEffect(()=>{Ee&&ht()},[Ee]),T.useEffect(()=>(s(Ct.UPDATE_CHAT_LIST_LAST_MESSAGE,F,{autoOff:!1}),s(Ct.UPDATE_CHAT_LIST,I,{autoOff:!1}),s(Ct.UPDATE_CHAT_LIST_BY_ID,U,{autoOff:!1}),s(Ct.UPDATE_CHAT_LIST_BY_SOCKET,$,{autoOff:!1}),()=>{i(Ct.UPDATE_CHAT_LIST_LAST_MESSAGE,F),i(Ct.UPDATE_CHAT_LIST,I),i(Ct.UPDATE_CHAT_LIST_BY_ID,U),i(Ct.UPDATE_CHAT_LIST_BY_SOCKET,$)}),[]),T.useEffect(()=>(s(Ct.UPDATE_LAST_SEEN_MESSAGE,({chatId:Me,messageIds:lt,lastSeenMessageId:Vt})=>{const vn=b.find(gt=>String(gt.id)===String(Me));if(vn&&vn.lastSeenId===Vt)return;Ie.current.has(Me)||Ie.current.set(Me,new Set);const pt=Ie.current.get(Me),mt=(lt==null?void 0:lt.filter(gt=>!pt.has(gt)))||[];mt.length!==0&&(mt.forEach(gt=>pt.add(gt)),o(Ct.UPDATE_CHAT_LIST_BY_ID,{chatId:Me,chatUpdate:gt=>{const Wt=Math.max(gt.unseenMessageCount-mt.length,0);return Wt===0&&Ie.current.delete(Me),{...gt,lastSeenId:Vt,unseenMessageCount:Wt}}}),v(gt=>({...gt,chat:Math.max(gt.chat-mt.length,0)})),Me===(d==null?void 0:d.id)&&p(gt=>({...gt,lastSeenId:Vt,unseenMessageCount:Math.max(gt.unseenMessageCount-mt.length,0)})))},{autoOff:!1}),()=>{i(Ct.UPDATE_LAST_SEEN_MESSAGE)}),[d==null?void 0:d.id,b]);const Xe=b.length>0;T.useEffect(()=>{!f&&b.length>20&&o(Fa.SHOW_CES_MODAL)},[f,Xe]),sQ();const Je=T.useMemo(()=>{var Me;return f===((Me=te==null?void 0:te.contact)==null?void 0:Me.identifier)},[te,f]),qe=T.useCallback(()=>_.jsx(HP,{chat:te,contact:te.contact,isActive:Je,isNotification:!0,onClick:()=>m({chat:{...te}}),isCompact:e}),[te,Je,e]),Ue=()=>{const Me=(b==null?void 0:b.length)>0;if(Z){if(H==="NETWORK")return e?_.jsx(je,{display:"flex",justifyContent:"center",alignItems:"center",mt:32,children:_.jsx(Qe,{onClick:q,fullWidth:!0,icon:"bi-refresh-single"})}):_.jsx(rQ,{retry:q});if(H==="SERVER")return e?_.jsx(je,{display:"flex",justifyContent:"center",alignItems:"center",mt:32,children:_.jsx(Qe,{onClick:q,fullWidth:!0,icon:"bi-refresh-single"})}):_.jsx(nQ,{retry:q})}return!Me&&(z||V)||G||B?Array.from({length:Me&&!B?2:4}).map((lt,Vt)=>_.jsx(JX,{isCompact:ge},Vt)):Me?_.jsx(_.Fragment,{}):!A&&!N?_.jsx(Zp,{}):A?_.jsx(SS,{searchType:k}):_.jsx(ES,{onFilterClear:ht})},it=Me=>({Footer:Ue,Header:a&&!B&&!A&&!Me?qe:void 0});return _.jsxs("div",{id:"chat-list",className:Te(zl["chat-list"],n,{[zl["chat-list--compact"]]:ge}),children:[ee&&_.jsx("header",{className:zl["chat-list__header"],children:ge&&!W?_.jsx(nD,{isCompact:ge}):_.jsxs(_.Fragment,{children:[Q&&_.jsx(XX,{onShowSearch:le,setIsLoadingSearch:P,className:zl["chat-list__header-search"],onSearch:E}),J&&!B&&!A&&!Ee&&_.jsx(QX,{ref:Oe,disabled:A||B,onChange:R,className:re&&!W?zl["chat-list__header-filters"]:void 0})]})}),_.jsx(Zd,{onScroll:Me=>Me.target.scrollTop>50?pe(!0):pe(!1),components:it((rt=Oe.current)==null?void 0:rt.filter),className:Te(zl["chat-list__items"],{[zl["chat-list__items--full-height"]]:!ee}),increaseViewportBy:90,data:B?[]:b,endReached:M,totalCount:(b==null?void 0:b.length)||0,itemContent:(Me,lt)=>et(Me,lt,b)})]})}const cD=T.memo(iQ),pr={"media-modal__header-back":"_media-modal__header-back_5sc18_6","media-modal__header-crop":"_media-modal__header-crop_5sc18_10","media-modal__body":"_media-modal__body_5sc18_16","media-modal__body-preview":"_media-modal__body-preview_5sc18_24","media-modal__body-preview-backdrop":"_media-modal__body-preview-backdrop_5sc18_44","media-modal__body-preview-img":"_media-modal__body-preview-img_5sc18_53","media-modal__body-preview-cropper":"_media-modal__body-preview-cropper_5sc18_61","media-modal__body-items-wrapper":"_media-modal__body-items-wrapper_5sc18_72","media-modal__body-items-wrapper--isFullscreen":"_media-modal__body-items-wrapper--isFullscreen_5sc18_76","media-modal__body-items":"_media-modal__body-items_5sc18_72","media-modal__body-items-media":"_media-modal__body-items-media_5sc18_86","media-modal__body-items-media--active":"_media-modal__body-items-media--active_5sc18_96","media-modal__body-video":"_media-modal__body-video_5sc18_102","media-modal__footer":"_media-modal__footer_5sc18_111","media-modal__footer-input":"_media-modal__footer-input_5sc18_116","media-modal__footer-input--multiline":"_media-modal__footer-input--multiline_5sc18_156","media-modal__footer-input--ios":"_media-modal__footer-input--ios_5sc18_159","media-modal__footer-crop-actions":"_media-modal__footer-crop-actions_5sc18_162","media-modal-header":"_media-modal-header_5sc18_169","media-modal-body":"_media-modal-body_5sc18_177","media-modal-footer":"_media-modal-footer_5sc18_181"};function wS({show:n,media:e,defaultCaption:t,onClose:r,onSend:s}){var D;const{push:i}=Si(),o=T.useRef(),[a,l]=T.useState([]),[c,d]=T.useState(""),[f,p]=T.useState(!1),[m,g]=T.useState(200),[v,y]=T.useState(0),b=(D=e==null?void 0:e[0])!=null&&D.type.startsWith("video")?Fe.VIDEO:Fe.PICTURE,S=()=>{setTimeout(()=>{r(),d("")},0)},E=M=>{M==null||M.preventDefault(),setTimeout(()=>{s({files:a,caption:c,mode:b}),S()},0)},C=async()=>{var U;const M=await((U=o.current)==null?void 0:U.getResultAsBlob()),F=a[v].file;if(M){const $=new File([M],`${F.name}`,{type:F.type,lastModified:F.lastModified});p(!1),l(q=>{const G=[...q];return G[v]={file:$,src:URL.createObjectURL($)},G})}else p(!1)},R=(M,F)=>{p(!1),y(F)},I=M=>{M.key==="Enter"&&!M.shiftKey&&At().isPc&&(M.preventDefault(),E())};T.useEffect(()=>{(e==null?void 0:e.length)>0&&l(Array.from(e).map(M=>({file:M,src:URL.createObjectURL(M)})))},[e]),T.useEffect(()=>{t&&d(t)},[t]),T.useEffect(()=>{let M=window.innerHeight;const F=124,U=84;M-=F,b===Fe.PICTURE&&(M-=U),At().isPc&&(M-=48),g(M)},[b]),T.useEffect(()=>n?i(()=>{S()}):void 0,[n,i]);const A=_.jsx(Qe,{square:!0,size:"xs",variant:"text",color:"secondary",className:pr["media-modal__header-back"],onClick:S,children:_.jsx("i",{className:"bi-right"})}),k=!f&&b===Fe.PICTURE&&_.jsx(Qe,{className:pr["media-modal__header-crop"],size:"xs",square:!0,variant:"text",color:"secondary",onClick:()=>p(!0),children:_.jsx("i",{className:"bi-crop"})}),N=f?_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",className:pr["media-modal__footer-crop-actions"],children:[_.jsx(Qe,{label:"تایید",fullWidth:!0,onClick:C}),_.jsx(Qe,{label:"انصراف",variant:"outline",fullWidth:!0,onClick:()=>p(!1)})]}):_.jsxs("form",{className:pr["media-modal__footer"],onSubmit:E,children:[_.jsx(Qe,{icon:"bi-send-right",variant:"text",size:"sm",type:"submit",color:"secondary",square:!0}),_.jsx("textarea",{type:"text",className:Te(pr["media-modal__footer-input"],{[pr["media-modal__footer-input--ios"]]:At().isIOS,[pr["media-modal__footer-input--multiline"]]:c.includes(`
290 `)}),placeholder:"پیام",value:c,onKeyDown:I,onChange:M=>d(M.target.value)})]});return _.jsx(lr,{show:n,showClose:!1,footerComponent:N,isFullScreen:!At().isPc,headerAppendComponent:k,headerPrependComponent:A,bodyClass:pr["media-modal-body"],headerClass:pr["media-modal-header"],footerClass:pr["media-modal-footer"],title:b===Fe.PICTURE?"ارسال تصویر":"ارسال ویدئو",onClose:S,className:"dataset-inp-MediaModal",children:b===Fe.PICTURE?_.jsxs("div",{className:pr["media-modal__body"],children:[a.length>0&&_.jsxs("div",{className:pr["media-modal__body-preview"],style:{height:`${m}px`},children:[_.jsx("img",{className:pr["media-modal__body-preview-backdrop"],src:a[v].src,alt:""}),_.jsx("img",{className:pr["media-modal__body-preview-img"],src:a[v].src,alt:""}),_.jsx(Mr,{mounted:f,transition:"fade",duration:350,children:M=>_.jsx("div",{style:M,children:_.jsx(cb,{blurBackground:!0,ref:o,className:pr["media-modal__body-preview-cropper"],image:a[v].src})})})]}),_.jsx("div",{className:Te(pr["media-modal__body-items-wrapper"],{[pr["media-modal__body-items-wrapper--isFullscreen"]]:!At().isPc}),children:_.jsx("div",{className:pr["media-modal__body-items"],children:a==null?void 0:a.map((M,F)=>_.jsx("img",{className:Te(pr["media-modal__body-items-media"],{[pr["media-modal__body-items-media--active"]]:F===v}),src:M.src,alt:"",onClick:()=>R(M,F)},`${F}-${M.name}`))})})]}):_.jsx("div",{className:pr["media-modal__body"],children:!!a[0]&&_.jsx("div",{className:pr["media-modal__body-preview"],style:{height:`${m}px`},children:_.jsx(Bd,{src:a[0].src,className:pr["media-modal__body-video"]})})})})}const pf={reply:"_reply_1ds3g_6",reply__photo:"_reply__photo_1ds3g_15",reply__body:"_reply__body_1ds3g_24","reply__body-title":"_reply__body-title_1ds3g_31","reply__body-message":"_reply__body-message_1ds3g_42"};function uD(){const{emitEvent:n}=Mt.useEmitter(),{setUnseenMessages:e}=$i(),{currentUser:t,unseenMessages:r,toastOptions:s}=Lt(["currentUser","unseenMessages","toastOptions"]),{chat:i}=Tn(["chat"]),o=T.useRef(i),a=T.useRef(s),l=T.useRef(t);T.useEffect(()=>{o.current=i},[i]),T.useEffect(()=>{a.current=s},[s]),T.useEffect(()=>{l.current=t},[t]);const c=T.useCallback(g=>{var y;const v={...g,contact:{...hf(g.contact)}};n(Ct.UPDATE_CHAT_LIST_BY_SOCKET,v),n(Ct.NEW_MESSAGE,v),(y=a.current)!=null&&y.enabled&&n(Ct.NEW_MESSAGE_TOAST,v),e(b=>({...b,chat:b.chat+1}))},[n,r,e]),d=T.useCallback(g=>{var v;((v=o.current)==null?void 0:v.id)===g.chatId&&n(Ct.SENDER_SEEN,g)},[n]),f=T.useCallback(g=>{var E,C;const{chatId:v,seenAt:y,receiver:b,lastSeenMessageId:S}=g;String(b)===String((E=l.current)==null?void 0:E.id)?(e(R=>{var I;return{...R,chat:Math.max(R.chat-(((I=o.current)==null?void 0:I.unseenMessageCount)||0),0)}}),n(Ct.UPDATE_CHAT_LIST_BY_ID,{chatId:v,chatUpdate:R=>({...R,unseenMessageCount:0,markedAsUnread:!1,lastSeenId:S,lastMessage:{...R.lastMessage,seenAt:y}})}),((C=o.current)==null?void 0:C.id)===v&&n(Ct.RECEIVER_CHAT_SEEN_ALL,{chatId:v,seenAt:y,lastSeenId:S})):n(Ct.SENDER_CHAT_SEEN_ALL,{chatId:v,seenAt:y,lastSeenId:S})},[e,n]),p=T.useCallback(g=>{n(Ct.UPDATE_LAST_SEEN_MESSAGE,{chatId:g.chatId,messageIds:g.messageIds,lastSeenMessageId:g.lastSeenMessageId})},[n]),m=T.useCallback(g=>{if(!(g!=null&&g.type)||!(g!=null&&g.data)){console.warn("Invalid socket message format:",g);return}const{type:v,data:y}=g;switch(v){case Uc.MESSAGE_NEW:{c(y);break}case Uc.MESSAGE_SEEN_NOTIFY:{d(y);break}case Uc.CHAT_LAST_SEEN_NOTIFY:{p(y);break}case Uc.CHAT_SEEN_NOTIFY:{f(y);break}default:console.warn("Unknown socket message type:",v)}},[f,c,d,p]);return{handleChatSeen:f,handleNewMessage:c,processSocketMessage:m,handleUpdateLastSeenId:p}}const oQ=({chatId:n,limit:e=20,virtuosoRef:t,containerRef:r,messageId:s=0})=>{var ds,fs,oe,ce,_e;const i=T.useRef(),{emitEvent:o,subEvent:a,offEvent:l}=Mt.useEmitter(),c=T.useRef(!1),d=T.useRef(),f=T.useRef(),{chat:p,identifier:m,messages:g,selectedMessageIds:v,editingMessage:y,replyingMessage:b,scrollToRepliedMessage:S,scrollToReplierMessage:E,isLoadingNextMessages:C,hasChatUpdate:R,messageIdToSearch:I,shouldLabelShow:A,hasUnseenLabel:k,isEditing:N,toMessageId:D,pendingMessages:M,isLoading:F,isFetching:U,isError:$,hasNextPage:q,hasPreviousPage:G}=Tn(["chat","identifier","messages","selectedMessageIds","editingMessage","replyingMessage","scrollToRepliedMessage","scrollToReplierMessage","isLoadingNextMessages","hasChatUpdate","messageIdToSearch","shouldLabelShow","hasUnseenLabel","isEditing","toMessageId","pendingMessages","isLoading","isFetching","isError","hasNextPage","hasPreviousPage"]),{setIsError:V,setIsLoading:z,setIsFetching:B,setHasNextPage:P,setHasPreviousPage:H,setHasPreviousMessages:Z,setHasNextMessages:Q,setMessages:J,setHasUnseenLabel:ee,setMessageIdToSearch:K,setScrollToRepliedMessage:W,setScrollToReplierMessage:te,setHasChatUpdate:re,setShouldLabelShow:pe,setToMessageId:Ee,setPendingMessages:le,setIsLoadingNextMessages:Ie,setReplyingMessage:be,setEditingMessage:ge,setSelectedMessageIds:Ae,setChat:Re}=ai(),{isLoggedIn:tt,socketConnected:et,currentUser:Oe}=Lt(["isLoggedIn","socketConnected","currentUser"]),{mutate:ht}=qY({retry:2,retryDelay:2e3}),{handleChatSeen:Xe}=uD(),{isError:Je,setData:qe,data:Ue,isLoading:it,isFetching:nt,hasNextPage:dt,fetchNextPage:Ot,hasPreviousPage:xt,fetchPreviousPage:rt}=MY({limit:e,chatId:n,isLoggedIn:tt,messageId:s},{enabled:!1}),Me=T.useMemo(()=>!$&&!!G,[$,G]),lt=T.useMemo(()=>{var ie,xe,Le,Be;return!$&&!!q&&((ie=p==null?void 0:p.lastMessage)==null?void 0:ie.id)!==((xe=g.at(-1))==null?void 0:xe.id)&&((Le=g.at(-1))==null?void 0:Le.status)!==Dt.SENDING&&((Be=g.at(-1))==null?void 0:Be.status)!==Dt.ERROR},[$,q,(ds=p==null?void 0:p.lastMessage)==null?void 0:ds.id,g]);T.useEffect(()=>{V(Je),z(it),B(nt),P(dt),H(xt)},[Je,it,nt,dt,xt,V,z,B,P,H]),T.useEffect(()=>{Z(Me),Q(lt)},[Me,lt,Z,Q]);const{refetch:Vt}=NY({limit:e,chatId:n,messageId:I},{enabled:!1,onSuccess:({data:ie})=>{E||Ee(I),K(void 0),W(void 0),re(!1),qe({pages:[{data:ie}]})}}),vn=T.useMemo(()=>{var ie;return(ie=Ue==null?void 0:Ue.pages)==null?void 0:ie.some(xe=>{var Le,Be;return(Be=(Le=xe.data)==null?void 0:Le.messages)==null?void 0:Be.some(Se=>Se==null?void 0:Se.unReadMessages)})},[Ue]);T.useEffect(()=>{ee(vn)},[vn,ee]),T.useEffect(()=>{S&&K(S)},[S,K]),T.useEffect(()=>{E&&K(E)},[E,K]),T.useEffect(()=>{var ie,xe;(ie=p==null?void 0:p.searchedMessage)!=null&&ie.id&&K((xe=p==null?void 0:p.searchedMessage)==null?void 0:xe.id)},[(fs=p==null?void 0:p.searchedMessage)==null?void 0:fs.id,K]),Mt.useEffectNoImmediate(()=>{ee(!1),re(!1),pe(!0)},[n,ee,re,pe]),T.useEffect(()=>{!k&&Ue&&A&&qe(ie=>{const xe={pages:ie!=null&&ie.pages?[...ie.pages]:[{pages:[{data:{messages:[]}}]}]};let Le=!1;const Be={pages:[]};return xe.pages.forEach(Se=>{var ct,at,ut;if(Le)Be.pages.push(Se);else{const St=[...(((ct=Se.data)==null?void 0:ct.messages)||[]).slice().reverse()];let ft=-1;St.forEach((De,se)=>{var We;const Pe=Number((We=De==null?void 0:De.sender)==null?void 0:We.id)!==(Oe==null?void 0:Oe.id);!(De!=null&&De.seenAt)&&!(De!=null&&De.unReadMessages)&&ft===-1&&Pe&&A&&(ft=se)}),ft!==-1&&(Le=!0,ee(!0),pe(!1),St==null||St.splice(ft,0,{unReadMessages:!0,sender:{...(at=St==null?void 0:St[ft-1])==null?void 0:at.sender}})),(ut=Be.pages)==null||ut.push({data:{messages:St==null?void 0:St.reverse()}})}}),Be})},[Oe==null?void 0:Oe.id,Ue,qe,k]),T.useEffect(()=>{I&&(c.current=!0,qe({pages:[{data:{messages:[]}}]}),Vt())},[I]);const pt=T.useCallback(()=>{setTimeout(()=>{if(r.current){const ie=r.current.offsetHeight,xe=r.current.scrollTop,Be=r.current.scrollHeight-ie-ie;xe>Be&&tm(t)}},750)},[]),{refetch:mt}=OY({limit:e,chatId:n,isLoggedIn:tt,lastMessageId:((ce=(oe=g==null?void 0:g.findLast)==null?void 0:oe.call(g,ie=>ie.status!==Dt.SENDING))==null?void 0:ce.id)||0},{enabled:!1,onSuccess:({data:ie})=>{const xe=ie.messages.map(Le=>({...Le,isUpdatedMessage:!0}));Re(Le=>({...Le,lastMessage:xe.at(-1)})),qe(Le=>{const Be={pages:[...Le.pages]};return Be.pages[Be.pages.length-1]={data:{messages:[...xe,...Be.pages.at(-1).data.messages]}},Be}),(p==null?void 0:p.chatType)===Bt.BOT&&o(Ct.UPDATE_CHAT_INFO),pt()}});T.useEffect(()=>(window.__dalan.fetchUpdatedMessages=mt,()=>{window.__dalan.fetchUpdatedMessages===mt&&(window.onSetChatUnseenCount=void 0)}),[mt]);const gt=T.useCallback(async(ie={})=>{!U&&!c.current&&rt(ie)},[U,rt]),Wt=T.useCallback(()=>{!f.current&&!U&&!c.current&&(f.current=!0,Ot().finally(()=>{f.current=!1}))},[U,Ot]),ot=T.useCallback(()=>{clearTimeout(i.current),i.current=setTimeout(()=>{n&&!lt&&(mt(),ot())},1e4)},[mt,n,lt]),nn=T.useCallback(ie=>{var Le;if(!tt)return;const xe={lastMessageId:ie,chatId:p==null?void 0:p.id,chatType:p==null?void 0:p.chatType,receiverId:Oe==null?void 0:Oe.id,senderId:((Le=p==null?void 0:p.contact)==null?void 0:Le.id)||0};et?o(Ct.PUBLISH_TO_SOCKET,{payload:{data:xe,type:Uc.CHAT_SEEN}}):ht(xe,{onSuccess:()=>{Xe({chatId:p==null?void 0:p.id,receiver:Oe==null?void 0:Oe.id,lastSeenMessageId:ie,seenAt:new Date().toISOString()})}})},[tt,(_e=p==null?void 0:p.contact)==null?void 0:_e.id,p==null?void 0:p.id,p==null?void 0:p.chatType,Oe==null?void 0:Oe.id,o,ht,et,Xe]),tn=T.useCallback(ie=>{qe(xe=>{var Be;const Le=new Date().toISOString();return{...xe,pages:(Be=xe==null?void 0:xe.pages)==null?void 0:Be.map(Se=>{var ut,St;let ct=!1;const at=(St=(ut=Se==null?void 0:Se.data)==null?void 0:ut.messages)==null?void 0:St.map(ft=>{var De;return ie.some(se=>String(se)===String(ft.id))?(ct=!0,ft.id===((De=g.at(-1))==null?void 0:De.id)&&o(Ct.UPDATE_CHAT_LIST_BY_ID,{chatId:n,chatUpdate:se=>({...se,lastMessage:{...se.lastMessage,seenAt:Le}})}),{...ft,seenAt:Le}):ft});return ct?{...Se,data:{...Se==null?void 0:Se.data,messages:at}}:Se})}})},[g]),En=T.useCallback((ie,xe)=>{var Se,ct;const{isScrollToBottom:Le=!0,broadcast:Be=!0}=xe||{};Be&&o(Ct.BROADCAST_TO_ALL,{customType:"addMessageEvent",data:{message:ie,chatId:p==null?void 0:p.id}}),q&&((Se=g.at(-1))!=null&&Se.id)&&ie.status===Dt.SENDING&&((ct=p==null?void 0:p.lastMessage)!=null&&ct.id&&p.lastMessage.id!==g.at(-1).id||p!=null&&p.searchedMessage)?(Ie(!0),re(!1),J(M),qe({pages:[{data:{messages:M}}]}),le([...M,ie])):Le&&setTimeout(()=>{r.current&&tm(t)},50),qe(at=>{const ut={pages:[...at.pages]},St=ut.pages.at(-1);return St.data.messages=St.data.messages.filter(ft=>!Object.prototype.hasOwnProperty.call(ft,"unReadMessages")),ut.pages[ut.pages.length-1]={data:{messages:[ie,...St.data.messages]}},ut})},[q,p,g,M,Ie,re,J,le,o,qe]),$n=T.useCallback((ie,xe,Le)=>{var Se,ct,at,ut;const{broadcast:Be=!0}=Le||{};if(Be){let St=xe;if(typeof xe=="function"){const ft=(ct=(Se=Ue==null?void 0:Ue.pages)==null?void 0:Se.flatMap(De=>De.data.messages))==null?void 0:ct.find(De=>De.uuid===ie||De.id===ie);ft&&(St=xe(ft))}o(Ct.BROADCAST_TO_ALL,{customType:"replaceMessageEvent",data:{id:ie,chatId:p==null?void 0:p.id,replacer:St}})}if(q&&((at=g.at(-1))!=null&&at.id)&&((ut=p==null?void 0:p.lastMessage)!=null&&ut.id&&p.lastMessage.id!==g.at(-1).id||p!=null&&p.searchedMessage)){rt({pageParam:{messageId:0,limit:20,cmp:ja.LESS_THAN}}).then(({data:St})=>{var De,se,Pe,We;const ft=(We=(Pe=(se=(De=St==null?void 0:St.pages)==null?void 0:De[0])==null?void 0:se.data)==null?void 0:Pe.messages)==null?void 0:We[0];nn(ft==null?void 0:ft.id),o(Ct.UPDATE_CHAT_LIST_LAST_MESSAGE,{message:ft,chatId:n}),o(Ct.UPDATE_CHAT_LIST_BY_ID,{chatId:n,chatUpdate:{lastSeenId:ft==null?void 0:ft.id}}),Re(an=>({...an,lastMessage:ft,lastSeenId:ft==null?void 0:ft.id})),qe(an=>(an.pages.length>1&&an.pages.pop(),an)),Ie(!1),setTimeout(()=>{r.current&&tm(t)},50)});return}qe(St=>{var an,yn,Ft,zn;const ft={pages:St.pages.map(wn=>({...wn}))};let De,se;if(St.pages.some((wn,Wn)=>{const kn=wn.data.messages.findIndex(Fs=>Fs.uuid===ie||Fs.id===ie);return kn!==-1?(De=Wn,se=kn,!0):!1}),De===void 0||se===void 0)return St;ft.pages[De]={...ft.pages[De],data:{messages:[...ft.pages[De].data.messages]}};const Pe=typeof xe=="function"?xe(ft.pages[De].data.messages[se]):xe;ft.pages[De].data.messages[se]={...Pe};const We=[((yn=(an=ft.pages.at(-2))==null?void 0:an.data)==null?void 0:yn.messages)||[],((zn=(Ft=ft.pages.at(-1))==null?void 0:Ft.data)==null?void 0:zn.messages)||[]].flat().sort((wn,Wn)=>wn.createdAt>Wn.createdAt?-1:1).find(wn=>!wn.status||wn.status!==Dt.DELETED)||{};return o(Ct.UPDATE_CHAT_LIST_LAST_MESSAGE,{message:We,chatId:n}),o(Ct.UPDATE_CHAT_LIST_BY_ID,{chatId:n,chatUpdate:{lastSeenId:We.id}}),Re(wn=>({...wn,lastMessage:We,lastSeenId:We.id})),ft})},[q,p,g,Ue,qe,rt,o,n,Re,Oe==null?void 0:Oe.id,nn]),_n=T.useCallback(ie=>{$n(ie,xe=>({...xe,status:Dt.DELETED}))},[$n]),sr=T.useCallback(ie=>{const xe=document.querySelector("#chat-message-form-input");if(xe)if(ie){if(be(null),xe.innerHTML=ie.content.text.replace(/\n/g,"<br />"),xe.focus(),window.getSelection!==void 0&&document.createRange!==void 0){const Le=document.createRange();Le.selectNodeContents(xe),Le.collapse(!1);const Be=window.getSelection();Be.removeAllRanges(),Be.addRange(Le)}else if(document.body.createTextRange!==void 0){const Le=document.body.createTextRange();Le.moveToElementText(xe),Le.collapse(!1),Le.select()}setTimeout(()=>{xe.scrollTop=xe.scrollHeight},50)}else xe.innerHTML="";ge(ie)},[]),wr=T.useCallback(ie=>{N&&sr(null),be(ie)},[N,sr,be]),ws=T.useCallback((ie,xe)=>{g.forEach(Le=>{var Be;if(((Be=Le.repliedMessage)==null?void 0:Be.id)===ie){const Se={...Le.repliedMessage};Se.content={...Se.content,text:xe},$n(Le.id,{...Le,repliedMessage:Se})}})},[g,$n]),es=T.useCallback(()=>{re(!1),J([]),qe({pages:[{data:{messages:[]}}]}),rt({pageParam:{messageId:0,limit:20,cmp:ja.LESS_THAN}}).then(({data:ie})=>{var xe,Le,Be,Se,ct;nn((ct=(Se=(Be=(Le=(xe=ie==null?void 0:ie.pages)==null?void 0:xe[0])==null?void 0:Le.data)==null?void 0:Be.messages)==null?void 0:Se[0])==null?void 0:ct.id)})},[re,J,qe,rt,nn]);return T.useEffect(()=>{d.current=g},[g]),T.useEffect(()=>{Ae(new Set)},[m,Ae]),T.useEffect(()=>(et?clearTimeout(i.current):ot(),()=>{clearTimeout(i.current)}),[et,ot]),T.useEffect(()=>{var ie,xe,Le,Be;if(Ue!=null&&Ue.pages){if(!s){const Se=(Be=(Le=(xe=(ie=Ue==null?void 0:Ue.pages)==null?void 0:ie[0])==null?void 0:xe.data)==null?void 0:Le.messages)==null?void 0:Be[0];Se&&nn(Se.id)}J(Ue.pages.flatMap(Se=>Se.data.messages.slice().reverse()))}},[Ue,s]),T.useEffect(()=>{if(g.length>0&&E){const ie=document.querySelector(`#chat-area-messages-message-${E}`);if(ie&&r.current){const xe=r.current.getBoundingClientRect(),Le=ie.getBoundingClientRect(),Be=xe.width-Le.width-32;ie.style.setProperty("--highlight-right-distance-in-chat",`-${Be}px`),ie.classList.add(cn["message__wrapper__content--highlight"]),ie.classList.contains(cn["message__wrapper__content--sender"])&&ie.classList.add(cn["message__wrapper__content--highlight-reverse"]),setTimeout(()=>{ie.classList.remove(cn["message__wrapper__content--highlight"]),ie.classList.contains(cn["message__wrapper__content--sender"])&&ie.classList.remove(cn["message__wrapper__content--highlight-reverse"])},2e3),te(void 0)}}g.length>0&&D&&setTimeout(()=>{vS(D,g,t),setTimeout(()=>{Ee(void 0)},0)},100),setTimeout(()=>{c.current=!1},0)},[g]),T.useEffect(()=>{var ie;J([]),n&&!((ie=p==null?void 0:p.searchedMessage)!=null&&ie.id)&&rt().then(xe=>{qe(Le=>{var Be;return Le&&Le.pages.at(-1).data.messages.length>0?{...Le,pages:Le!=null&&Le.pages?[...Le.pages]:[{data:{messages:[]}}]}:{pages:(Be=xe==null?void 0:xe.data)!=null&&Be.pages?[...xe.data.pages]:[{data:{messages:[]}}]}})})},[n,p==null?void 0:p.searchedMessage,rt,J]),T.useEffect(()=>{o(Ct.ADD_EVENT_LISTENER,{event:"addMessageEvent",callback:({data:{message:ie,chatId:xe}})=>{o(Ct.UPDATE_CHAT_LIST_LAST_MESSAGE,{message:ie,chatId:p==null?void 0:p.id});const Le=!d.current.some(Be=>Be.uuid===ie.uuid);p!=null&&p.id&&xe&&String(xe)===String(p==null?void 0:p.id)&&Le&&En(ie,{isScrollToBottom:!1,broadcast:!1})}}),o(Ct.ADD_EVENT_LISTENER,{event:"replaceMessageEvent",callback:({data:{id:ie,replacer:xe,chatId:Le}})=>{const Be=!d.current.some(Se=>Se.id===ie);p!=null&&p.id&&Le&&String(Le)===String(p==null?void 0:p.id)&&Be&&$n(ie,xe,{broadcast:!1})}})},[p==null?void 0:p.id]),T.useEffect(()=>(a(Ct.NEW_MESSAGE,ie=>{(ie==null?void 0:ie.id)===n&&(Re(ie),En({...ie==null?void 0:ie.lastMessage,isManuallyAdded:!0},{isScrollToBottom:!1,broadcast:!1}),pt())},{autoOff:!1}),a(Ct.MESSAGE_SEEN,({chatId:ie,lastSeenId:xe})=>{ie===n&&xe&&tn([xe.toString()])},{autoOff:!1}),a(Ct.RECEIVER_CHAT_SEEN_ALL,({chatId:ie,lastSeenId:xe,seenAt:Le})=>{if(ie===n){Re(Se=>({...Se,lastSeenId:xe,unseenMessageCount:0,markedAsUnread:!1,lastMessage:{...Se.lastMessage,seenAt:Le}}));const Be=g.filter(Se=>{var ct;return String((ct=Se==null?void 0:Se.sender)==null?void 0:ct.id)!==String(Oe==null?void 0:Oe.id)}).map(Se=>{var ct;return(ct=Se==null?void 0:Se.id)==null?void 0:ct.toString()}).filter(Boolean);Be.length>0&&tn(Be)}},{autoOff:!1}),a(Ct.SENDER_CHAT_SEEN_ALL,({chatId:ie,lastSeenId:xe,seenAt:Le})=>{if(ie===n){Re(Se=>({...Se,lastSeenId:xe,lastMessage:{...Se.lastMessage,seenAt:Le}}));const Be=g.filter(Se=>{var ct;return String((ct=Se==null?void 0:Se.sender)==null?void 0:ct.id)===String(Oe==null?void 0:Oe.id)}).map(Se=>{var ct;return(ct=Se==null?void 0:Se.id)==null?void 0:ct.toString()}).filter(Boolean);Be.length>0&&tn(Be)}},{autoOff:!1}),a(Ct.SENDER_SEEN,({chatId:ie,messageIds:xe})=>{ie===n&&tn(xe)},{autoOff:!1}),()=>{l(Ct.NEW_MESSAGE),l(Ct.MESSAGE_SEEN),l(Ct.SENDER_SEEN),l(Ct.RECEIVER_CHAT_SEEN_ALL),l(Ct.SENDER_CHAT_SEEN_ALL)}),[n,g,Oe==null?void 0:Oe.id,a,l,Re,En,tn,pt]),{messages:g,isLoading:F,addMessage:En,editMessage:sr,hasNextPage:q,replyMessage:wr,seenMessages:tn,deleteMessage:_n,hasChatUpdate:R,editingMessage:y,replaceMessage:$n,scrollToBottom:es,getNextMessages:Wt,hasNextMessages:lt,replyingMessage:b,selectedMessageIds:v,editRepliedMessages:ws,getPreviousMessages:gt,hasPreviousMessages:Me,fetchUpdatedMessages:mt,isLoadingNextMessages:C,setIsLoadingNextMessages:Ie,setScrollToRepliedMessage:W,setScrollToReplierMessage:te}},dD=T.createContext(),ro=()=>{const n=T.useContext(dD);if(n===void 0)throw new Error("useMessagesManagerContext was used outside of its Provider");return n};function aQ({chatId:n,limit:e=20,messageId:t=0,children:r}){const s=T.useRef(),i=T.useRef(),o=T.useCallback(R=>{s.current=R},[]),a=T.useCallback(R=>{i.current=R},[]),{addMessage:l,editMessage:c,replyMessage:d,seenMessages:f,deleteMessage:p,replaceMessage:m,scrollToBottom:g,getNextMessages:v,getPreviousMessages:y,editRepliedMessages:b,fetchUpdatedMessages:S,scrollToBottomVirtuoso:E}=oQ({chatId:n,limit:e,messageId:t,containerRef:s,virtuosoRef:i}),C=T.useMemo(()=>({addMessage:l,editMessage:c,virtuosoRef:i,setVirtuoso:a,replyMessage:d,seenMessages:f,containerRef:s,setContainer:o,deleteMessage:p,replaceMessage:m,scrollToBottom:g,getNextMessages:v,getPreviousMessages:y,editRepliedMessages:b,fetchUpdatedMessages:S,scrollToBottomVirtuoso:E}),[l,E,p,c,b,S,v,y,m,d,g,f,o,a]);return _.jsx(dD.Provider,{value:C,children:r})}function lQ({className:n}){var l;const{contact:e,replyingMessage:t}=Tn(["contact","replyingMessage"]),{currentUser:r}=Lt(["currentUser"]),{replyMessage:s}=ro(),[i,o]=T.useState(null),a=()=>{setTimeout(()=>{s(null)},0)};return T.useEffect(()=>{t?o(t):setTimeout(()=>o(null),500)},[t]),T.useEffect(()=>{s(null)},[e==null?void 0:e.id]),_.jsxs("div",{className:Te(n,pf.reply),children:[(i==null?void 0:i.messageType)===Fe.PICTURE&&_.jsx("img",{alt:"",className:pf.reply__photo,src:i.content.files[0].url}),_.jsxs("div",{className:pf.reply__body,onClick:()=>yS(i==null?void 0:i.id),children:[_.jsxs("div",{className:pf["reply__body-title"],children:[_.jsx("i",{className:"bi-reply"}),_.jsx("span",{children:((l=i==null?void 0:i.sender)==null?void 0:l.id)==(r==null?void 0:r.id)?"شما:":`${e.name}:`})]}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[i&&_.jsx("i",{className:qP(i)}),_.jsx("p",{className:pf["reply__body-message"],title:Ul(i),children:Ul(i)})]})]}),_.jsx(Qe,{icon:"bi-close",size:"sm",variant:"plain",color:"secondary",onClick:a})]})}const Ba={"bulk-actions":"_bulk-actions_1w9kd_6","bulk-actions__container":"_bulk-actions__container_1w9kd_23","bulk-actions__counter":"_bulk-actions__counter_1w9kd_30","bulk-actions__counter-number":"_bulk-actions__counter-number_1w9kd_33","bulk-actions__counter-number--limited":"_bulk-actions__counter-number--limited_1w9kd_38","bulk-actions__buttons":"_bulk-actions__buttons_1w9kd_41"};function cQ(){var c;const{selectedMessageIds:n}=Tn(["selectedMessageIds"]),{setSelectedMessageIds:e,setForwardModalData:t}=ai(),{featureFlags:r}=Lt(["featureFlags"]),[s,i]=T.useState(!1),o=(c=r==null?void 0:r.features)==null?void 0:c.selectMessage,a=()=>{t([...n])},l=()=>{e(new Set)};return T.useEffect(()=>{(async()=>{n.size>0?(await de.sleep(450),i(!0)):i(!1)})()},[n.size]),_.jsx(Mr,{mounted:s&&n.size>0,duration:350,transition:"slide-up",children:d=>_.jsx("div",{className:Ba["bulk-actions"],style:d,children:_.jsxs("div",{className:Ba["bulk-actions__container"],children:[_.jsxs("div",{className:Ba["bulk-actions__counter"],children:[_.jsx("span",{className:Te(Ba["bulk-actions__counter-number"],{[Ba["bulk-actions__counter-number--limited"]]:n.size>=o}),children:n.size}),"از",_.jsx("span",{className:Te(Ba["bulk-actions__counter-number"],Ba["bulk-actions__counter-number--limited"]),children:o}),"پیام انتخاب شده"]}),_.jsxs("div",{className:Ba["bulk-actions__buttons"],children:[_.jsx(Qe,{onClick:a,color:"secondary",variant:"plain",children:_.jsxs(je,{display:"flex",alignItems:"center",gap:4,children:[_.jsx(Mn,{size:"20",name:"bi-arrow-up-right"}),_.jsx("span",{children:"ارسال به"})]})}),_.jsx(Qe,{onClick:l,variant:"plain",children:_.jsx(Mn,{size:"20",name:"bi-close"})})]})]})})})}const Kt={"form-container":"_form-container_f4edo_6",form:"_form_f4edo_6","form__attached-product":"_form__attached-product_f4edo_19","form__attached-product--show":"_form__attached-product--show_f4edo_24",form__reply:"_form__reply_f4edo_28",form__edit:"_form__edit_f4edo_28","form__reply--show":"_form__reply--show_f4edo_35","form__edit--show":"_form__edit--show_f4edo_35","form__lock-voice":"_form__lock-voice_f4edo_47","form__lock-voice-icon--lock":"_form__lock-voice-icon--lock_f4edo_73",form__body:"_form__body_f4edo_77","form__body--deleted":"_form__body--deleted_f4edo_106","form__body-actions":"_form__body-actions_f4edo_124","form__body-actions-voice-attachments":"_form__body-actions-voice-attachments_f4edo_131","form__body-actions-voice-attachments--show":"_form__body-actions-voice-attachments--show_f4edo_145","form__body-actions-voice":"_form__body-actions-voice_f4edo_131","form__body-actions-voice--recording":"_form__body-actions-voice--recording_f4edo_178","form__body-actions-voice-icon-wrapper":"_form__body-actions-voice-icon-wrapper_f4edo_187","form__body-actions-voice-icon-wrapper--show":"_form__body-actions-voice-icon-wrapper--show_f4edo_191","form__body-actions-voice-wave-wrapper":"_form__body-actions-voice-wave-wrapper_f4edo_194","form__body-actions-send":"_form__body-actions-send_f4edo_199","form__body-actions-send--show":"_form__body-actions-send--show_f4edo_232","form__body-actions-voice-wave":"_form__body-actions-voice-wave_f4edo_194","form__body-actions-voice-wave--show":"_form__body-actions-voice-wave--show_f4edo_265","form__body-form":"_form__body-form_f4edo_299","form__body-form--ios":"_form__body-form--ios_f4edo_307","form__body-form-input":"_form__body-form-input_f4edo_310","form__body-form-input--ios":"_form__body-form-input--ios_f4edo_356","form__body-form-input-placeholder":"_form__body-form-input-placeholder_f4edo_359","form__body-attachments-external":"_form__body-attachments-external_f4edo_377","form__body-bot-keyboard":"_form__body-bot-keyboard_f4edo_377","form__body-attachments-external--hidden":"_form__body-attachments-external--hidden_f4edo_385","form__body-voice-timer":"_form__body-voice-timer_f4edo_426","form__body-voice-timer-bullet":"_form__body-voice-timer-bullet_f4edo_448","form__body-voice-timer-time":"_form__body-voice-timer-time_f4edo_456","form__body-voice-cancel-btn":"_form__body-voice-cancel-btn_f4edo_461","form__voice-cancel":"_form__voice-cancel_f4edo_467","form__voice-cancel-text":"_form__voice-cancel-text_f4edo_490",form__blocked:"_form__blocked_f4edo_498","form__blocked-text":"_form__blocked-text_f4edo_520","form__glyph-picker":"_form__glyph-picker_f4edo_528","form__glyph-picker--show":"_form__glyph-picker--show_f4edo_532"};/**
291 * filesize
292 *
293 * @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
294 * @license BSD-3-Clause
295 * @version 10.1.6
296 */const uQ="array",dQ="bit",fD="bits",fQ="byte",hD="bytes",Kc="",hQ="exponent",pQ="function",pD="iec",mQ="Invalid number",gQ="Invalid rounding method",TS="jedec",_Q="object",mD=".",vQ="round",yQ="s",bQ="si",xQ="kbit",SQ="kB",EQ=" ",wQ="string",TQ="0",CS={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function gD(n,{bits:e=!1,pad:t=!1,base:r=-1,round:s=2,locale:i=Kc,localeOptions:o={},separator:a=Kc,spacer:l=EQ,symbols:c={},standard:d=Kc,output:f=wQ,fullform:p=!1,fullforms:m=[],exponent:g=-1,roundingMethod:v=vQ,precision:y=0}={}){let b=g,S=Number(n),E=[],C=0,R=Kc;d===bQ?(r=10,d=TS):d===pD||d===TS?r=2:r===2?d=pD:(r=10,d=TS);const I=r===10?1e3:1024,A=p===!0,k=S<0,N=Math[v];if(typeof n!="bigint"&&isNaN(n))throw new TypeError(mQ);if(typeof N!==pQ)throw new TypeError(gQ);if(k&&(S=-S),(b===-1||isNaN(b))&&(b=Math.floor(Math.log(S)/Math.log(I)),b<0&&(b=0)),b>8&&(y>0&&(y+=8-b),b=8),f===hQ)return b;if(S===0)E[0]=0,R=E[1]=CS.symbol[d][e?fD:hD][b];else{C=S/(r===2?Math.pow(2,b*10):Math.pow(1e3,b)),e&&(C=C*8,C>=I&&b<8&&(C=C/I,b++));const D=Math.pow(10,b>0?s:0);E[0]=N(C*D)/D,E[0]===I&&b<8&&g===-1&&(E[0]=1,b++),R=E[1]=r===10&&b===1?e?xQ:SQ:CS.symbol[d][e?fD:hD][b]}if(k&&(E[0]=-E[0]),y>0&&(E[0]=E[0].toPrecision(y)),E[1]=c[E[1]]||E[1],i===!0?E[0]=E[0].toLocaleString():i.length>0?E[0]=E[0].toLocaleString(i,o):a.length>0&&(E[0]=E[0].toString().replace(mD,a)),t&&s>0){const D=E[0].toString(),M=a||(D.match(/(\D)/g)||[]).pop()||mD,F=D.toString().split(M),U=F[1]||Kc,$=U.length,q=s-$;E[0]=`${F[0]}${M}${U.padEnd($+q,TQ)}`}return A&&(E[1]=m[b]?m[b]:CS.fullform[d][b]+(e?dQ:fQ)+(E[0]===1?Kc:yQ)),f===uQ?E:f===_Q?{value:E[0],symbol:E[1],exponent:b,unit:R}:E.join(l)}const Ao={"file-modal__file":"_file-modal__file_liymn_6","file-modal__file-info":"_file-modal__file-info_liymn_18","file-modal__file-info-name":"_file-modal__file-info-name_liymn_21","file-modal__file-info-size":"_file-modal__file-info-size_liymn_29","file-modal__file-info-type":"_file-modal__file-info-type_liymn_33","file-modal__file-icon":"_file-modal__file-icon_liymn_39","file-modal__form":"_file-modal__form_liymn_52","file-modal__form-input":"_file-modal__form-input_liymn_63","file-modal__form-input--ios":"_file-modal__form-input--ios_liymn_76"};function CQ({show:n,file:e,onSend:t,onClose:r}){const[s,i]=T.useState(""),o=T.useMemo(()=>e?{type:e.name.split(".").at(-1).toUpperCase(),size:gD(e.size,{round:0,symbols:{B:"بایت",kB:"کیلوبایت",MB:"مگابایت",GB:"گیگابایت"}})}:{},[e]),a=async()=>{r(),await de.sleep(200),i("")},l=c=>{c==null||c.preventDefault(),t({caption:s,file:{file:e,size:e.size,name:e.name,type:o.type,src:URL.createObjectURL(e)}}),a()};return _.jsx(lr,{show:n,title:"ارسال فایل",size:"sm",onClose:a,children:_.jsxs("div",{className:Ao["file-modal"],children:[_.jsxs("div",{className:Ao["file-modal__file"],children:[_.jsxs("div",{className:Ao["file-modal__file-info"],children:[_.jsx("span",{className:Ao["file-modal__file-info-name"],children:e==null?void 0:e.name}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[_.jsx("span",{className:Ao["file-modal__file-info-size"],children:o.size}),_.jsx("span",{className:Ao["file-modal__file-info-type"],children:o.type})]})]}),_.jsx("div",{className:Ao["file-modal__file-icon"],children:_.jsx("i",{className:"bi-file"})})]}),_.jsxs("form",{className:Ao["file-modal__form"],onSubmit:l,children:[_.jsx(Qe,{square:!0,size:"sm",type:"submit",variant:"text",color:"secondary",icon:"bi-send-right"}),_.jsx("input",{type:"text",value:s,placeholder:"پیام",className:Te(Ao["file-modal__form-input"],{[Ao["file-modal__form-input--ios"]]:At().isIOS}),onChange:c=>i(c.target.value)})]})]})})}const mr={"attach-modal-body":"_attach-modal-body_qggzu_6","options-modal__item":"_options-modal__item_qggzu_10","options-modal__item-icon":"_options-modal__item-icon_qggzu_32","options-modal__item-title":"_options-modal__item-title_qggzu_41","options-popover":"_options-popover_qggzu_53","options-popover__item":"_options-popover__item_qggzu_72","options-popover__item-icon":"_options-popover__item-icon_qggzu_116"},_D={empty:"_empty_14gp1_6",empty__image:"_empty__image_14gp1_14"};function IQ(){return _.jsxs(je,{display:"flex",alignItems:"center",className:_D.empty,children:[_.jsx("img",{className:_D.empty__image,src:"https://statics.basalam.com/public/admin/j50O7/01-15/cr47e2qcrX4Cd77CDXnshADBpY5qr2B2TjQFtKC2QufOe5MtqQ.svg",alt:"empty illustration"}),_.jsx("span",{children:"توی غرفه‌ت هیچ محصول فعالی وجود نداره"})]})}const vD={"search-box":"_search-box_1s4wx_6","search-box__input":"_search-box__input_1s4wx_10"};function RQ({onSearch:n,placeHolder:e,debounceTime:t=500}){const r=T.useCallback(_S(n,t),[]),s=i=>r(i.target.value.trim());return _.jsxs(je,{p:10,gap:16,display:"flex",alignItems:"center",className:vD["search-box"],children:[_.jsx(Mn,{name:"bi-search"}),_.jsx("input",{type:"text",onChange:s,placeholder:e,className:vD["search-box__input"]})]})}const Yc={"product-item":"_product-item_1q4jz_6","product-item__image":"_product-item__image_1q4jz_10","product-item__title":"_product-item__title_1q4jz_14","product-item__inventory":"_product-item__inventory_1q4jz_22"};function AQ({product:n}){var e;return _.jsx(Wi,{className:Yc["product-item"],value:n.id,children:_.jsxs(je,{p:14,display:"flex",alignItems:"flex-end",justifyContent:"space-between",className:Yc["product-item"],children:[_.jsxs(je,{display:"flex",children:[_.jsx(mM,{src:(e=n.photo)==null?void 0:e.small,ratio:1,className:Yc["product-item__image"]}),_.jsxs(je,{mr:12,children:[_.jsx("p",{className:Yc["product-item__title"],children:n.title}),_.jsxs("span",{className:Yc["product-item__inventory"],children:["موجودی ",n.inventory]})]})]}),_.jsxs(je,{display:"flex",children:[_.jsx("strong",{children:de.rialToToman(n.price,{separator:!0})}),_.jsx(Mn,{name:"bi-toman"})]})]})})}const mf={"product-modal__header":"_product-modal__header_btlib_6","product-modal__list":"_product-modal__list_btlib_9","product-modal__list-items":"_product-modal__list-items_btlib_42","product-modal-body":"_product-modal-body_btlib_50"};function kQ(){const n=At().isMobile;return _.jsxs(je,{display:"flex",alignItems:"center",style:{width:"100%"},children:[_.jsx(je,{ml:8,children:_.jsx(vt,{width:18,height:18})}),_.jsxs(je,{p:14,display:"flex",alignItems:"flex-end",style:{paddingLeft:0},justifyContent:"space-between",className:Yc["product-item"],children:[_.jsxs(je,{display:"flex",children:[_.jsx(vt,{width:44,height:44}),_.jsx(je,{mr:12,children:_.jsx(vt,{width:n?160:300,height:24})})]}),_.jsx(je,{display:"flex",children:_.jsx(vt,{width:n?60:80,height:24})})]})]})}function LQ(){return cf.get("/api_v2/user")}function MQ({userId:n}){return cf.get(`/api_v2/user/get-by-ids/?user_ids=${n}`)}function NQ({productId:n}){return cf.get(`api_v2/product/${n}`)}function OQ({vendorId:n}){return cf.get(`/api_v2/vendor/list?vendor_ids=${n}`)}function PQ({limit:n,offset:e,status:t,orderBy:r,productName:s}){return cf.get("/api_v2/vendor/products",{params:{status:t,page:e,order_by:r,"page-size":n,product_name:s}})}const DQ=(n={})=>Gn(["current-user"],LQ,n),jQ=(n={},e={})=>Gn([`user-${n.userId}`],()=>MQ(n),{...e,select:t=>t[0]}),yD=(n={},e={})=>Gn([`product-${n.productId}`],()=>NQ(n),e),FQ=(n={},e={})=>Gn([`vendor-${n.vendorId}`],()=>OQ(n),e),UQ=(n,e={})=>kp({queryKey:["vendor-products",n],queryFn:({pageParam:t})=>PQ({...n,offset:(t==null?void 0:t.offset)||1}),getNextPageParam:(t,r)=>{const s=r.flatMap(i=>i.products);return t.productsCount>s.length?{offset:Math.ceil(s.length/n.limit+1)}:!1},...e});function BQ({show:n,onClose:e,onSendProducts:t}){const s=At().isMobile,i=T.useRef(),[o,a]=T.useState([]),[l,c]=T.useState({limit:10,orderBy:"id",status:t7.AVAILABLE}),{data:d,isError:f,isLoading:p,hasNextPage:m,fetchNextPage:g}=UQ(l,{enabled:n}),v=T.useMemo(()=>d==null?void 0:d.pages.flatMap(k=>k.products),[d==null?void 0:d.pages])||[],y=k=>c(N=>({...N,productName:k||void 0})),b=k=>{k.length<o.length?setTimeout(()=>{a(k)},0):o.length<3&&setTimeout(()=>{a(k)},0)},S=()=>a([]),E=()=>{e(),S()},C=()=>{setTimeout(()=>{t(o),E()},0)},R=_.jsxs(je,{display:"flex",justifyContent:"space-between",className:mf["product-modal__header"],children:[_.jsx("span",{children:"ارسال محصول"}),_.jsxs("strong",{children:[o.length," از ",3]})]}),I=_.jsxs(je,{gap:16,display:"flex",justifyContent:"flex-end",className:mf["product-modal__footer"],children:[_.jsx(Qe,{label:"ارسال",onClick:C,fullWidth:s,disabled:o.length===0}),_.jsx(Qe,{fullWidth:s,variant:"outline",label:"بستن",onClick:e})]}),A=()=>[...Array.from({length:7}).keys()].map(k=>_.jsx(kQ,{},k));return _.jsxs(lr,{show:n,onClose:E,showClose:!1,isFullScreen:s,headerComponent:R,footerComponent:I,bodyClass:Te(mf["product-modal-body"],"dataset-inp-ProductModal"),children:[_.jsx(RQ,{onSearch:y,placeHolder:"جستجو در بین محصولات..."}),_.jsx("div",{ref:i,className:mf["product-modal__list"],children:_.jsx("div",{className:mf["product-modal__list-items"],children:p?_.jsx(A,{}):v!=null&&v.length?_.jsx(ub,{useWindow:!1,hasError:!!f,fetchMore:g,loadingComponent:A,hasMore:!f&&!!m,getScrollParent:()=>i.current,children:_.jsx(Wi.Group,{onChange:b,value:o,children:v.map(k=>_.jsx(AQ,{product:k},k.id))})}):_.jsx(IQ,{})})})]})}function IS(n){const i=["video/mp4"];return new Promise((o,a)=>{const l=document.createElement("video"),c=URL.createObjectURL(n);l.src=c,l.addEventListener("loadedmetadata",()=>{i.includes(n.type)||(URL.revokeObjectURL(c),a(new Error(`فرمت ویدئو باید ${i.join(" یا ")} باشد`))),n.size>9e7&&(URL.revokeObjectURL(c),a(new Error("حجم ویدئو بیشتر از 90 مگابایت است"))),l.duration>90&&(URL.revokeObjectURL(c),a(new Error("زمان ویدئو بیشتر از 90 ثانیه است"))),l.videoWidth<200&&(URL.revokeObjectURL(c),a(new Error("وضوح تصویر نباید کمتر از 200 پیکسل باشد"))),l.videoHeight<200&&(URL.revokeObjectURL(c),a(new Error("وضوح تصویر نباید کمتر از 200 پیکسل باشد"))),URL.revokeObjectURL(c),o()})})}function $Q(n){const e=["image/jpeg","image/png","image/x-png"];if(!e.includes(n.type))throw new Error(`فرمت تصویر باید ${e.join(" یا ")} باشد`);return!0}function bD(n){return n.every(e=>$Q(e))}function zQ({show:n,onClose:e,anchorEl:t,onSendFile:r,onSendMedia:s,onSendProducts:i,type:o="attach",mode:a="popover"}){var P,H,Z,Q;const{showErrorSnackbar:l}=Mt.useSnackbar(),{publishEvent:c}=Fr(),{featureFlags:d,currentUser:f}=Lt(["featureFlags","currentUser"]),{contact:p}=Tn(["contact"]),m=Dr(),[g,v,y]=[(P=d==null?void 0:d.features)==null?void 0:P.attachFile,(H=d==null?void 0:d.features)==null?void 0:H.attachMedia,((Z=d==null?void 0:d.features)==null?void 0:Z.attachProduct)&&!m],b=!!((Q=f==null?void 0:f.vendor)!=null&&Q.id),[S,E]=T.useState(null),[C,R]=T.useState(null),[I,A]=T.useState(!1),[k,N]=T.useState(!1),[D,M]=T.useState(!1),F=async J=>{requestIdleCallback(()=>{c("chatFormAttachItemClick",{contactId:p==null?void 0:p.id,messageType:Fe.PICTURE})});const ee=J.target.files;R(ee),await de.sleep(250),N(!0)},U=async J=>{requestIdleCallback(()=>{c("chatFormAttachItemClick",{contactId:p==null?void 0:p.id,messageType:Fe.FILE})});const ee=J.target.files;E(ee[0]),await de.sleep(250),A(!0)},$=async J=>{try{requestIdleCallback(()=>{c("chatFormAttachItemClick",{contactId:p==null?void 0:p.id,messageType:Fe.VIDEO})});const ee=J.target.files;await IS(ee[0]),R(ee),await de.sleep(250),N(!0)}catch(ee){l(ee.message)}},q=async()=>{await de.sleep(0),N(!1),await de.sleep(250),R(null)},G=async()=>{await de.sleep(0),A(!1),await de.sleep(250),E(null)},V=async()=>{await de.sleep(0),M(!1)},z=async()=>{await de.sleep(0),e(),requestIdleCallback(()=>{c("chatFormAttachItemClick",{contactId:p==null?void 0:p.id,messageType:Fe.PRODUCT})}),await de.sleep(250),M(!0)},B=()=>{requestIdleCallback(()=>{c("chatFormAttachItemClick",{contactId:p==null?void 0:p.id,messageType:Fe.PRODUCT})}),M(!0)};return _.jsxs("div",{children:[_.jsx(wS,{show:k,media:C,onSend:s,onClose:q}),_.jsx(CQ,{show:I,file:S,onSend:r,onClose:G}),_.jsx(BQ,{show:D,onSendProducts:i,onClose:V}),a==="modal"?_.jsx(lr,{className:"dataset-inp-ChatAreaFormAttach",show:n,showClose:!0,bodyClass:mr["attach-modal-body"],title:" ",hasPopstate:!0,onClose:e,children:_.jsxs("div",{className:mr["options-modal"],children:[o==="attach"&&v&&_.jsxs("label",{htmlFor:"upload-photo",className:mr["options-modal__item"],children:[_.jsx("i",{className:Te("bi-picture-add",mr["options-modal__item-icon"])}),_.jsx("span",{className:mr["options-modal__item-title"],children:"تصویر"}),_.jsx("input",{multiple:!0,type:"file",id:"upload-photo",style:{display:"none"},accept:"image/x-png,image/jpeg",onChange:F})]}),o==="attach"&&v&&_.jsxs("label",{htmlFor:"upload-video",className:mr["options-modal__item"],children:[_.jsx("i",{className:Te("bi-video-square",mr["options-modal__item-icon"])}),_.jsx("span",{className:mr["options-modal__item-title"],children:"ویدئو"}),_.jsx("input",{type:"file",id:"upload-video",accept:"video/mp4",style:{display:"none"},onChange:$})]}),o==="attach"&&g&&_.jsxs("label",{htmlFor:"upload-file",className:mr["options-modal__item"],children:[_.jsx("i",{className:Te("bi-file",mr["options-modal__item-icon"])}),_.jsx("span",{className:mr["options-modal__item-title"],children:"فایل (csv)"}),_.jsx("input",{type:"file",accept:".csv",id:"upload-file",style:{display:"none"},onChange:U})]}),o==="attach"&&y&&b&&_.jsxs("button",{className:mr["options-modal__item"],onClick:z,children:[_.jsx("i",{className:Te("bi-box",mr["options-modal__item-icon"])}),_.jsx("span",{className:mr["options-modal__item-title"],children:"محصول"})]})]})}):_.jsx(tf,{show:n,anchorEl:t,getAwayThreshold:75,position:"bottom-left",transition:"pop-bottom-left",onClose:J=>{J==null||J.stopPropagation(),e()},className:"dataset-inp-ChatAreaFormAttach",children:_.jsxs("div",{className:mr["options-popover"],children:[o==="attach"&&v&&_.jsxs("label",{htmlFor:"upload-photo",className:mr["options-popover__item"],children:[_.jsx("div",{className:mr["options-popover__item-icon"],children:_.jsx("i",{className:"bi-picture-add"})}),_.jsx("span",{children:"تصویر"}),_.jsx("input",{multiple:!0,type:"file",id:"upload-photo",style:{display:"none"},accept:"image/x-png,image/jpeg",onChange:F})]}),o==="attach"&&v&&_.jsxs("label",{htmlFor:"upload-video",className:mr["options-popover__item"],children:[_.jsx("div",{className:mr["options-popover__item-icon"],children:_.jsx("i",{className:"bi-video-square"})}),_.jsx("span",{children:"ویدئو"}),_.jsx("input",{type:"file",id:"upload-video",accept:"video/mp4",style:{display:"none"},onChange:$})]}),o==="attach"&&g&&_.jsxs("label",{htmlFor:"upload-file",className:mr["options-popover__item"],children:[_.jsx("div",{className:mr["options-popover__item-icon"],children:_.jsx("i",{className:"bi-file"})}),_.jsx("span",{children:"فایل (csv)"}),_.jsx("input",{type:"file",accept:".csv",id:"upload-file",style:{display:"none"},onChange:U})]}),o==="attach"&&y&&b&&_.jsxs("button",{className:mr["options-popover__item"],onClick:B,children:[_.jsx("div",{className:mr["options-popover__item-icon"],children:_.jsx("i",{className:"bi-box"})}),_.jsx("span",{children:"محصول"})]})]})})]})}const gf={"drag-and-drop":"_drag-and-drop_6z6lb_6","drag-and-drop__body":"_drag-and-drop__body_6z6lb_24","drag-and-drop__body-icon":"_drag-and-drop__body-icon_6z6lb_48","drag-and-drop__body-text":"_drag-and-drop__body-text_6z6lb_51","drag-and-drop__body-types":"_drag-and-drop__body-types_6z6lb_56"};function qQ({onSendMedia:n}){const e=T.useRef(0),[t,r]=T.useState(!1),[s,i]=T.useState(null),[o,a]=T.useState(!1),{showErrorSnackbar:l}=Mt.useSnackbar(),c=T.useCallback(y=>{try{bD([...y]),i(y),a(!0)}catch(b){l(b.message)}},[]),d=T.useCallback(async y=>{try{await IS(y[0]),i(y),a(!0)}catch(b){l(b.message)}},[]),f=T.useCallback(y=>{y.preventDefault(),y.stopPropagation(),e.current=0,r(!1);const b=y.dataTransfer.files,S=[...b];S.every(E=>E.type.startsWith("image"))?c(b):S.length===1&&S[0].type==="video/mp4"?d(b):l("فایل‌ انتخابی باید چند عکس یا یک ویدئو باشد")},[c,d]),p=T.useCallback(y=>{y.preventDefault(),y.stopPropagation(),e.current+=1,r(!0)},[]),m=T.useCallback(y=>{y.preventDefault(),y.stopPropagation(),e.current-=1,e.current===0&&r(!1)},[]),g=T.useCallback(y=>{y.preventDefault(),y.stopPropagation()},[]),v=async()=>{a(!1),await de.sleep(250),i(null)};return T.useEffect(()=>(At().isPc&&(document.addEventListener("dragenter",p),document.addEventListener("dragleave",m),document.addEventListener("dragend",g),document.addEventListener("dragover",g),document.addEventListener("dragstart",g)),()=>{At().isPc&&(document.removeEventListener("dragenter",p),document.removeEventListener("dragleave",m),document.removeEventListener("dragend",g),document.removeEventListener("dragover",g),document.removeEventListener("dragstart",g))})),_.jsxs("div",{children:[_.jsx(wS,{show:o,media:s,onSend:n,onClose:v}),_.jsx(Mr,{mounted:t,duration:350,transition:"fade",children:y=>_.jsx("div",{className:gf["drag-and-drop"],style:y,onDrop:f,children:_.jsxs("div",{className:gf["drag-and-drop__body"],children:[_.jsx("i",{className:Te("bi-picture",gf["drag-and-drop__body-icon"])}),_.jsx("span",{className:gf["drag-and-drop__body-text"],children:"برای ارسال اینجا رها کنید"}),_.jsx("span",{className:gf["drag-and-drop__body-types"],children:"png, jpg, mp4"})]})})})]})}const rm={edit:"_edit_ze99g_6",edit__body:"_edit__body_ze99g_15","edit__body-title":"_edit__body-title_ze99g_19","edit__body-message":"_edit__body-message_ze99g_30"};function HQ({className:n}){const{contact:e,editingMessage:t}=Tn(["contact","editingMessage"]),{editMessage:r}=ro();T.useEffect(()=>{r(null)},[e==null?void 0:e.id]);const s=()=>{setTimeout(()=>{r(null)},0)};return _.jsxs("div",{className:Te(n,rm.edit),children:[_.jsxs("div",{className:rm.edit__body,onClick:()=>yS(t==null?void 0:t.id),children:[_.jsxs("div",{className:rm["edit__body-title"],children:[_.jsx("i",{className:"bi-edit-square"}),"ویرایش پیام:"]}),_.jsx("p",{className:rm["edit__body-message"],title:Ul(t),children:Ul(t)})]}),_.jsx(Qe,{icon:"bi-close",size:"sm",variant:"plain",color:"secondary",onClick:s})]})}const sm={keyboard:"_keyboard_16ho0_6",keyboard__container:"_keyboard__container_16ho0_17","keyboard__container-row":"_keyboard__container-row_16ho0_27","keyboard__container-row-button":"_keyboard__container-row-button_16ho0_37"};function GQ({show:n,onButtonClick:e}){const t=At(),{chat:r}=Tn(["chat"]),s=r.replyMarkup.keyboard,i=`${(n?s.length:0)*(t.isPc?52:44.5)}px`;return _.jsx("div",{className:sm.keyboard,style:{height:i},children:_.jsx("div",{className:sm.keyboard__container,children:s.map((o,a)=>_.jsx("div",{className:sm["keyboard__container-row"],children:o.map(l=>_.jsx(Qe,{variant:"outline",color:"secondary",label:l.text,size:t.isPc?"xs":"xxs",className:sm["keyboard__container-row-button"],onClick:()=>e(l.text)},l.text))},a))})})}function VQ({type:n,file:e,messageUUID:t}){const r=new FormData;return r.append("file",e),r.append("file_type",n),r.append("message_uuid",t),WK.post("/api_v1.0/store-file",r,{processData:!1,contentType:!1})}const xD=(n={})=>Yn(VQ,n),Nn={"ew__cta-button":"_ew__cta-button_1i102_6","ew__list-item-wrapper":"_ew__list-item-wrapper_1i102_15","ew__list-item":"_ew__list-item_1i102_15","ew__list-item-box":"_ew__list-item-box_1i102_38","ew__list-item-image":"_ew__list-item-image_1i102_45","ew__list-item-icon":"_ew__list-item-icon_1i102_57","ew__list-item-title":"_ew__list-item-title_1i102_62","ew__list-item-desc":"_ew__list-item-desc_1i102_79","ew__list-item-content":"_ew__list-item-content_1i102_93","ew__list-item-red-point":"_ew__list-item-red-point_1i102_99"};function WQ(n={}){return KK.get("/v1/apps",n)}const KQ=({queries:n,queryOptions:e})=>kp({queryOptions:e,queryKey:["apps","plugins",n==null?void 0:n.page,n==null?void 0:n.ids],queryFn:({pageParam:t=1})=>WQ({params:{page:t,...n},paramsSerializer:{indexes:null}})}),Rr={"review-request-modal-body":"_review-request-modal-body_rl02c_6","review-request-modal-header":"_review-request-modal-header_rl02c_15","review-request__loading":"_review-request__loading_rl02c_23","review-request__hint":"_review-request__hint_rl02c_28","review-request__hint-icon":"_review-request__hint-icon_rl02c_40","review-request__hint-title":"_review-request__hint-title_rl02c_46","review-request__hint-text":"_review-request__hint-text_rl02c_51","review-request__items":"_review-request__items_rl02c_57","review-request__footer":"_review-request__footer_rl02c_95","review-request__product":"_review-request__product_rl02c_99","review-request__product-body":"_review-request__product-body_rl02c_113","review-request__product-box":"_review-request__product-box_rl02c_116","review-request__product-photo":"_review-request__product-photo_rl02c_119","review-request__product-title":"_review-request__product-title_rl02c_126","review-request__product-icon":"_review-request__product-icon_rl02c_141","review-request__product-price":"_review-request__product-price_rl02c_144","review-request__buttons":"_review-request__buttons_rl02c_148","review-request__buttons-action":"_review-request__buttons-action_rl02c_156"},im={empty:"_empty_1849n_6",empty__photo:"_empty__photo_1849n_15",empty__message:"_empty__message_1849n_19"};function SD({refetch:n,message:e="",isRefetching:t,title:r="آیتمی موجود نیست!"}){return _.jsxs("section",{className:im.empty,children:[_.jsx("img",{alt:"empty",className:im.empty__photo,src:"https://statics.basalam.com/public-10/admin/j50O7/07-16/WSGQZqDxAHl6MGoQEaP7bYxymOf5t4bQV9CUtFPLIdhuEtPvYW.SVG"}),r&&_.jsx("span",{className:im.empty__title,children:r}),e&&_.jsx("span",{className:im.empty__message,children:e}),n&&_.jsx(Qe,{icon:"bi-refresh-single",onClick:n,loading:t,label:"دوباره امتحان کنیم"})]})}function YQ(n){return{data:n,properties:n==null?void 0:n.flatMap(e=>e.properties)}}function ED(n){var r,s,i,o;const e=n.variationMetadata,t=e?YQ(e):null;return{id:n.itemId,variationMetadata:t,price:n.itemPrice,itemCount:n.itemQuantity,invoiceId:n.itemInvoiceId,orderPaidAt:n.orderPaidAt||n.paidAt,product:{price:n.price,id:n.productId,primaryPrice:n.primaryPrice,name:n.itemTitle||n.title,title:n.itemTitle||n.title,rating:{rating:null},variation:e?t:null,category:{id:n.product.categoryId},photo:{url:(r=n.product.photo)==null?void 0:r.small},photos:n.product.photos??[{resized:{sm:(s=n.product.photo)==null?void 0:s.small}}],vendor:{id:n.vendorId,name:n.vendorTitle||((i=n.product)==null?void 0:i.vendorTitle),identifier:n.vendorIdentifire||((o=n.product)==null?void 0:o.vendorIdentifier)}}}}function XQ(n){const e=[];return n.forEach(t=>{e.some(r=>r.productId===t.productId)||e.push(t)}),e}function QQ({invoiceIds:n}){return Vp.get(`/api_v2.0/item/reviews?ids=${n}`)}function JQ(n){return Vp.post("api_v1.0/review",de.snakize(n))}function ZQ({vendorId:n,customerId:e,limit:t,offset:r=0}){return Vp.get(`api_v1.0/item/unreview?vendor_id=${n}&customer_id=${e}&limit=${t}&offset=${r}`)}function eJ({type:n,itemIds:e}){const t=e!=null&&e.length?`?item_ids=${e.join("&item_ids=")}`:"";return Vp.get(`/api_v2.0/${n}/unreviewed${t}`)}const tJ=(n={},e={})=>Gn([`invoice-${n.invoiceIds[0]}`],()=>QQ(n),e);function nJ(n={}){return Yn(JQ,n)}const rJ=(n={},e={})=>Gn([`unreviewed-item-${n.customerId}`],()=>ZQ(n),e),wD=(n={},e={})=>Gn(["order-unreviewed-items",n.itemIds],()=>eJ(n),{select:t=>({...t,unreviewedItems:t.unreviewedItems.map(r=>ED(r))}),...e});function sJ({show:n,onSendReviewRequest:e,onClose:t}){var y;const[i,o]=T.useState([]),{contact:a}=Tn(["contact"]),{currentUser:l}=Lt(["currentUser"]),{data:c,isLoading:d}=rJ({limit:50,customerId:a==null?void 0:a.id,offset:0*50,vendorId:(y=l==null?void 0:l.vendor)==null?void 0:y.id},{enabled:n}),f=c==null?void 0:c.unreviewedItems,p=b=>{o(b)},m=()=>{o([])},g=()=>{e(i),t(),o([])},v=_.jsxs("section",{className:Rr["review-request__buttons"],children:[_.jsx(Qe,{label:"ارسال درخواست",size:"xl",className:Rr["review-request__buttons-action"],disabled:(f==null?void 0:f.length)===0||i.length===0,onClick:g}),_.jsx(Qe,{label:"پاک کردن",variant:"outline",size:"xl",className:Rr["review-request__buttons-action"],disabled:(f==null?void 0:f.length)===0||i.length===0,onClick:m}),!At().isMobile&&_.jsx(Qe,{label:"انصراف",variant:"outline",size:"xl",className:Rr["review-request__buttons-action"],onClick:t})]});return _.jsx(lr,{show:n,size:"sm",footerComponent:v,isFullScreen:At().isMobile,showClose:At().isMobile,title:"درخواست ثبت تجربه",fullScreen:At().isMobile,footerClass:Rr["review-request__footer"],bodyClass:Rr["review-request-modal-body"],headerClass:Rr["review-request-modal-header"],onClose:t,className:"dataset-inp-ReviewForm",children:d?_.jsx(Cr,{className:Rr["review-request__loading"]}):f!=null&&f.length?_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:Rr["review-request__hint"],children:[_.jsxs("div",{children:[_.jsx("span",{className:Te("bi-lamp",Rr["review-request__hint-icon"])}),_.jsx("span",{className:Rr["review-request__hint-title"],children:"راهنما"})]}),_.jsx("p",{className:Rr["review-request__hint-text"],children:"محصول یا محصولاتی که درخواست ثبت تجربه برای آن‌ها دارید انتخاب کنید"})]}),_.jsx("div",{className:Rr["review-request__items"],children:_.jsx(Wi.Group,{value:i,className:Rr["review-request__checkbox"],onChange:b=>p(b),children:f.map(b=>_.jsxs(Wi,{value:b.itemId,className:Rr["review-request__product"],children:[_.jsx("img",{alt:b.product.productName,src:b.product.photo.small,className:Rr["review-request__product-photo"]}),_.jsxs("div",{className:Rr["review-request__product-body"],children:[_.jsx("span",{className:Rr["review-request__product-title"],children:b.product.productName}),_.jsx(je,{display:"flex","align-items":"center","justify-content":"space-between",className:Rr["review-request__product-box"],children:_.jsxs("span",{className:Rr["review-request__product-price"],children:[_.jsx("span",{className:Te("bi-toman",Rr["review-request__product-icon"])}),_.jsx("span",{children:de.numberSeparator(de.rialToToman(b.product.price))})]})})]})]},b.itemId))})})]}):_.jsx(SD,{title:"هیچ محصولی نیست که براش ثبت تجربه نشده باشه"})})}const Yr={"satisfaction-request-modal-body":"_satisfaction-request-modal-body_y1xmk_6","satisfaction-request__loading":"_satisfaction-request__loading_y1xmk_11","satisfaction-request__hint":"_satisfaction-request__hint_y1xmk_17","satisfaction-request__hint-icon":"_satisfaction-request__hint-icon_y1xmk_28","satisfaction-request__hint-title":"_satisfaction-request__hint-title_y1xmk_34","satisfaction-request__hint-text":"_satisfaction-request__hint-text_y1xmk_39","satisfaction-request__order":"_satisfaction-request__order_y1xmk_45","satisfaction-request__info-title":"_satisfaction-request__info-title_y1xmk_80","satisfaction-request__info-price":"_satisfaction-request__info-price_y1xmk_84","satisfaction-request__checkbox":"_satisfaction-request__checkbox_y1xmk_91","satisfaction-request__body":"_satisfaction-request__body_y1xmk_103","satisfaction-request__body-date":"_satisfaction-request__body-date_y1xmk_114","satisfaction-request__products":"_satisfaction-request__products_y1xmk_120","satisfaction-request__product":"_satisfaction-request__product_y1xmk_120","satisfaction-request__buttons":"_satisfaction-request__buttons_y1xmk_132","satisfaction-request__buttons-action":"_satisfaction-request__buttons-action_y1xmk_139"};function iJ({customerId:n,limit:e,offset:t=0}){return Fl.get(`/v1/vendor/customer/${n}/orders?limit=${e}&offset=${t}&status=sent`)}function oJ({customerId:n,orderId:e,limit:t,offset:r=0}){return Fl.get(`/v1/vendor/customer/${n}/orders?order_ids=${e}&limit=${t}&offset=${r}`)}function aJ({vendorId:n,orderId:e,limit:t,offset:r=0}){return Fl.get(`/v1/user/orders/parcel/posted?vendor_id=${n}&order_ids=${e}&limit=${t}&offset=${r}`)}function lJ(n){return Fl.post("/v1/user/set-satisfied",de.snakize(n))}function cJ({operator:n,agreementId:e}){return Fl.get(`v1/${n}/agreements/${e}`)}function uJ({orderId:n,payload:e}){return Fl.put(`/v1/vendor/orders/${n}/new-agreement`,de.snakize(e))}function dJ({agreementId:n,payload:e}){return Fl.post(`/v1/user/agreements/${n}/determine-agreement`,de.snakize(e))}const fJ=(n={},e={})=>Gn([`satisiable-${n.customerId}`],()=>iJ(n),e),hJ=(n={},e={})=>Gn([`vendor-${n.orderId}`],()=>oJ(n),e),pJ=(n={},e={})=>Gn([`customer-${n.orderId}`],()=>aJ(n),e);function mJ(n={}){return Yn(lJ,n)}function gJ(n={}){return Yn(uJ,n)}function _J(n={}){return Yn(dJ,n)}function vJ(n={},e={}){return Gn(["agreement",n],()=>cJ(n),e)}function yJ({show:n,onSend:e,onClose:t}){const[i,o]=T.useState([]),{contact:a}=Tn(["contact"]),{push:l}=Si(),{data:c,isLoading:d}=fJ({limit:10,customerId:a==null?void 0:a.id,offset:0*10},{enabled:n&&!!(a!=null&&a.id)}),f=c==null?void 0:c.orders,p=b=>{setTimeout(()=>{o(b)},0)},m=()=>{setTimeout(()=>{o([])},0)},g=()=>{t(),m()},v=()=>{setTimeout(()=>{e(i),t()},0)};T.useEffect(()=>{if(n)return l(()=>{g()})},[l,n]);const y=_.jsxs("section",{className:Yr["satisfaction-request__buttons"],children:[_.jsx(Qe,{className:Yr["satisfaction-request__buttons-action"],label:"درخواست ثبت رضایت",size:"lg",disabled:(f==null?void 0:f.length)===0||i.length===0,onClick:v}),_.jsx(Qe,{className:Yr["satisfaction-request__buttons-action"],label:"برداشتن تیک‌ها",variant:"outline",size:"lg",disabled:(f==null?void 0:f.length)===0||i.length===0,onClick:m}),!At().isMobile&&_.jsx(Qe,{className:Yr["satisfaction-request__buttons-action"],label:"انصراف",variant:"outline",size:"lg",onClick:g})]});return _.jsx(lr,{show:n,size:"sm",footerComponent:y,bodyClass:Yr["satisfaction-request-modal-body"],showClose:At().isMobile,title:"درخواست ثبت رضایت",isFullScreen:At().isMobile,onClose:g,className:"dataset-inp-SatisfactionRequestModal",children:d?_.jsx(je,{className:Yr["satisfaction-request__loading"],children:_.jsx(Cr,{})}):f!=null&&f.length?_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:Yr["satisfaction-request__hint"],children:[_.jsxs("div",{children:[_.jsx("span",{className:Te("bi-lamp",Yr["satisfaction-request__hint-icon"])}),_.jsx("span",{className:Yr["satisfaction-request__hint-title"],children:"راهنما"})]}),_.jsx("p",{className:Yr["satisfaction-request__hint-text"],children:"تسویه به صورت خودکار ۷ روز بعد از ارسال انجام می‌شه. ولی می‌تونی به مشتری‌هات درخواست بدی که زودتر ثبت رضایت کنن و زودتر باهات تسویه بشه."})]}),_.jsx("div",{className:Yr["satisfaction-request__order"],children:_.jsx(Wi.Group,{value:i,onChange:b=>p(b),children:f.map(b=>_.jsx(Wi,{value:b.id,className:Yr["satisfaction-request__checkbox"],children:_.jsxs(je,{className:Yr["satisfaction-request__body"],mr:10,children:[_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsxs("span",{className:Yr["satisfaction-request__info-title"],children:["کد سفارش: ",b.id]}),_.jsxs("span",{className:Yr["satisfaction-request__info-price"],children:[_.jsx("span",{children:de.numberSeparator(de.rialToToman(b.orderValue))}),_.jsx("span",{className:"bi-toman"})]})]}),_.jsx("span",{className:Yr["satisfaction-request__body-date"],children:de.jalaliDate(b.paidAt).format("DD MMMM YYYY")}),_.jsx("div",{className:Yr["satisfaction-request__products"],children:b.items.map(S=>_.jsx("img",{alt:S.product.title,src:S.product.photos[0].resized.sm,className:Yr["satisfaction-request__product"]},S.id))})]})},b.id))})})]}):_.jsx(SD,{title:"سفارشی نداری که رضایت مشتری نداشته باشه."})})}function bJ({ids:n=[],utmMedium:e="",widgetCategory:t,utmCampaign:r="",onSendReviewRequest:s,onSendSatisfactionRequest:i}){var Z,Q,J,ee;const[o,a]=T.useState(!1),{publishEvent:l}=Fr(),[c,d]=T.useState(JSON.parse(de.bsLocalStorage.getItem(`viewedExtensions-${t}`)||"[]")),[f,p]=T.useState(!1),[m,g]=T.useState(!1),{featureFlags:v,currentUser:y}=Lt(["featureFlags","currentUser"]),{chat:b}=Tn(["chat"]),{pushOnce:S}=Si(),{fetchUpdatedMessages:E}=ro(),{emitEvent:C}=Mt.useEmitter(),R=!!((Z=y==null?void 0:y.vendor)!=null&&Z.id),[I,A,k]=[(Q=v==null?void 0:v.features)==null?void 0:Q.attachReview,(J=v==null?void 0:v.features)==null?void 0:J.attachSatisfaction,((ee=v==null?void 0:v.features)==null?void 0:ee.createFactor)&&[1511021,7590280,240129,4078136,3817004,213773,12698361,7590280,430,7590280,1497826].includes(y==null?void 0:y.id)||de.isStaging(window.location.href)],{data:N,isLoading:D}=KQ({enabled:!!(n!=null&&n.length),queries:{ids:n,perPage:50,page:1}}),M=(N==null?void 0:N.pages.flatMap(K=>K.data))||[],F=new Map;n.forEach((K,W)=>F.set(K,W)),M.sort((K,W)=>F.get(K.id)-F.get(W.id));const U=()=>{setTimeout(()=>{a(!1)},0)},$=()=>{setTimeout(()=>{requestIdleCallback(()=>{var K,W;l("vendorChatExtensionClick",{userName:y==null?void 0:y.name,vendorId:(K=y==null?void 0:y.vendor)==null?void 0:K.id,vendorName:(W=y==null?void 0:y.vendor)==null?void 0:W.title})}),a(!0),S(()=>{U()})},0)},q=K=>{let W=[...c,K];W=Array.from(new Set(W)),de.bsLocalStorage.setItem(`viewedExtensions-${t}`,JSON.stringify(W)),d(W)},G=(K,W)=>{setTimeout(()=>{requestIdleCallback(()=>{var re,pe;l("vendorChatExtensionItemClick",{widgetCategory:t,itemRank:W+1,extensionId:K.id,itemTitle:K.title,userName:y==null?void 0:y.name,path:window.location.pathname,vendorId:(re=y==null?void 0:y.vendor)==null?void 0:re.id,vendorName:(pe=y==null?void 0:y.vendor)==null?void 0:pe.title,itemSubtitle:K.shortDescription||K.description})})},0),q(K.id);const te=new URL(`${mn.appsUrl}/apps/${K.id}`);window.WebViewInterface&&te.searchParams.set("client","app"),te.searchParams.set("screen.type","chrome_tab"),te.searchParams.set("utm_source","vendor.basalam.com"),te.searchParams.set("utm_medium",e),te.searchParams.set("utm_campaign",r),window.open(te.href)},V=()=>{p(!0),setTimeout(()=>{a(!1),q("review")},250)},z=()=>{g(!0),setTimeout(()=>{q("satisfaction"),a(!1)},250)},B=()=>{var K,W;C("show-factor-create-modal",{chatId:b==null?void 0:b.id,userId:(K=b==null?void 0:b.contact)==null?void 0:K.id,hashId:(W=b==null?void 0:b.contact)==null?void 0:W.identifier,onCreated:()=>{E()}}),setTimeout(()=>{a(!1),q("factor")},250)},P=async()=>{await de.sleep(0),p(!1)},H=async()=>{await de.sleep(0),g(!1)};return _.jsxs(_.Fragment,{children:[_.jsx(Qe,{className:Te(Nn["ew__cta-button"]),square:!0,size:"xxs",color:"secondary",onClick:$,children:(M==null?void 0:M.length)&&(c==null?void 0:c.length)!==M.length+2&&_.jsxs(_.Fragment,{children:[_.jsx("img",{width:"24",src:"https://statics.basalam.com/public-141/admin/yDBE2/10-27/NTOPeNbfztR7ibwypIEE7WyqihpbdYt0tfrVOSR7ZQBFiNQJ3Y.SVG",alt:"apps"}),_.jsx("span",{className:Nn["ew__list-item-red-point"]})]})}),_.jsxs(lr,{show:o,title:"افزونه‌های مرتبط",onClose:U,children:[D&&_.jsx(Cr,{}),I&&R&&_.jsx("div",{className:Nn["ew__list-item-wrapper"],onClick:()=>V(),children:_.jsxs(je,{className:Nn["ew__list-item"],display:"flex",alignItems:"center",children:[_.jsxs(je,{display:"flex",className:Nn["ew__list-item-box"],children:[!c.includes("review")&&_.jsx("span",{className:Nn["ew__list-item-red-point"]}),_.jsx("i",{className:Te(Nn["ew__list-item-icon"],"bi-star")}),_.jsx("div",{className:Nn["ew__list-item-content"],children:_.jsx("p",{className:Nn["ew__list-item-title"],children:"درخواست ثبت تجربه"})})]}),_.jsx(Mn,{name:"bi-angle-left"})]})}),A&&R&&_.jsx("div",{className:Nn["ew__list-item-wrapper"],onClick:()=>z(),children:_.jsxs(je,{className:Nn["ew__list-item"],display:"flex",alignItems:"center",children:[_.jsxs(je,{display:"flex",className:Nn["ew__list-item-box"],children:[!c.includes("satisfaction")&&_.jsx("span",{className:Nn["ew__list-item-red-point"]}),_.jsx("i",{className:Te(Nn["ew__list-item-icon"],"bi-tick-single")}),_.jsx("div",{className:Nn["ew__list-item-content"],children:_.jsx("p",{className:Nn["ew__list-item-title"],children:"درخواست ثبت رضایت"})})]}),_.jsx(Mn,{name:"bi-angle-left"})]})}),k&&R&&_.jsx("div",{className:Nn["ew__list-item-wrapper"],onClick:B,children:_.jsxs(je,{className:Nn["ew__list-item"],display:"flex",alignItems:"center",children:[_.jsxs(je,{display:"flex",className:Nn["ew__list-item-box"],children:[_.jsx("i",{className:Te(Nn["ew__list-item-icon"],"bi-factor")}),_.jsx("div",{className:Nn["ew__list-item-content"],children:_.jsx("p",{className:Nn["ew__list-item-title"],children:"ایجاد فاکتور"})})]}),_.jsx(Mn,{name:"bi-angle-left"})]})}),M==null?void 0:M.map((K,W)=>_.jsx("div",{className:Nn["ew__list-item-wrapper"],onClick:()=>G(K,W),children:_.jsxs(je,{className:Nn["ew__list-item"],display:"flex",alignItems:"center",children:[_.jsxs(je,{display:"flex",className:Nn["ew__list-item-box"],children:[!c.includes(K.id)&&_.jsx("span",{className:Nn["ew__list-item-red-point"]}),_.jsx("img",{className:Nn["ew__list-item-image"],src:K.logo.url,alt:K.title}),_.jsxs("div",{className:Nn["ew__list-item-content"],children:[_.jsx("p",{className:Nn["ew__list-item-title"],children:K.title}),_.jsx("p",{className:Nn["ew__list-item-desc"],children:K.shortDescription||K.description})]})]}),_.jsx(Mn,{name:"bi-angle-left"})]})},K.id))]}),_.jsx(sJ,{show:f,onClose:P,onSendReviewRequest:s}),_.jsx(yJ,{show:m,onSend:i,onClose:H})]})}const TD={messages:"_messages_nk3nh_6",messages__button:"_messages__button_nk3nh_31"};function xJ({messages:n,onSend:e}){const{chat:t,contact:r}=Tn(["chat","contact"]),{publishEvent:s}=Fr(),{currentUser:i}=Lt(["currentUser"]),{replaceMessage:o,addMessage:a}=ro(),{mutateAsync:l}=Hc(),c=async d=>{const f=Vn();try{const p={uuid:f,isNew:!0,chatId:t==null?void 0:t.id,content:{text:d},messageType:Fe.TEXT,messageMetadata:{receiverCouponHint:!0}};a({...p,chatId:t.id,sender:i,isManuallyAdded:!0,status:Dt.SENDING});const m=await l(p);o(f,{...m.data,uuid:f,isManuallyAdded:!0}),requestIdleCallback(()=>{var g;s("chatReadyMessageClick",{text:d,vendorId:(g=r==null?void 0:r.vendor)==null?void 0:g.id})}),e()}catch{o(f,p=>({...p,status:Dt.ERROR}))}};return _.jsx("div",{className:TD.messages,children:n.map(d=>_.jsx(Qe,{size:"xxs",label:d,variant:"outline",color:"secondary",onClick:()=>c(d),className:TD.messages__button},d))})}function om(n){if(typeof n!="string"||!n)throw new Error("expected a non-empty string, got: "+n)}function RS(n){if(typeof n!="number")throw new Error("expected a number, got: "+n)}const SJ=1,EJ=1,ql="emoji",Xc="keyvalue",AS="favorites",wJ="tokens",CD="tokens",TJ="unicode",ID="count",CJ="group",IJ="order",RD="group-order",kS="eTag",am="url",AD="skinTone",Qc="readonly",LS="readwrite",kD="skinUnicodes",RJ="skinUnicodes",AJ="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",kJ="en";function LJ(n,e){const t=new Set,r=[];for(const s of n){const i=e(s);t.has(i)||(t.add(i),r.push(s))}return r}function LD(n){return LJ(n,e=>e.unicode)}function MJ(n){function e(t,r,s){const i=r?n.createObjectStore(t,{keyPath:r}):n.createObjectStore(t);if(s)for(const[o,[a,l]]of Object.entries(s))i.createIndex(o,a,{multiEntry:l});return i}e(Xc),e(ql,TJ,{[CD]:[wJ,!0],[RD]:[[CJ,IJ]],[kD]:[RJ,!0]}),e(AS,void 0,{[ID]:[""]})}const MS={},lm={},cm={};function MD(n,e,t){t.onerror=()=>e(t.error),t.onblocked=()=>e(new Error("IDB blocked")),t.onsuccess=()=>n(t.result)}async function NJ(n){const e=await new Promise((t,r)=>{const s=indexedDB.open(n,SJ);MS[n]=s,s.onupgradeneeded=i=>{i.oldVersion<EJ&&MJ(s.result)},MD(t,r,s)});return e.onclose=()=>NS(n),e}function OJ(n){return lm[n]||(lm[n]=NJ(n)),lm[n]}function ea(n,e,t,r){return new Promise((s,i)=>{const o=n.transaction(e,t,{durability:"relaxed"}),a=typeof e=="string"?o.objectStore(e):e.map(c=>o.objectStore(c));let l;r(a,o,c=>{l=c}),o.oncomplete=()=>s(l),o.onerror=()=>i(o.error)})}function NS(n){const e=MS[n],t=e&&e.result;if(t){t.close();const r=cm[n];if(r)for(const s of r)s()}delete MS[n],delete lm[n],delete cm[n]}function PJ(n){return new Promise((e,t)=>{NS(n);const r=indexedDB.deleteDatabase(n);MD(e,t,r)})}function DJ(n,e){let t=cm[n];t||(t=cm[n]=[]),t.push(e)}const jJ=new Set([":D","XD",":'D","O:)",":X",":P",";P","XP",":L",":Z",":j","8D","XO","8)",":B",":O",":S",":'o","Dx","X(","D:",":C",">0)",":3","</3","<3","\\M/",":E","8#"]);function Jc(n){return n.split(/[\s_]+/).map(e=>!e.match(/\w/)||jJ.has(e)?e.toLowerCase():e.replace(/[)(:,]/g,"").replace(/’/g,"'").toLowerCase()).filter(Boolean)}const FJ=2;function ND(n){return n.filter(Boolean).map(e=>e.toLowerCase()).filter(e=>e.length>=FJ)}function UJ(n){return n.map(({annotation:t,emoticon:r,group:s,order:i,shortcodes:o,skins:a,tags:l,emoji:c,version:d})=>{const f=[...new Set(ND([...(o||[]).map(Jc).flat(),...l.map(Jc).flat(),...Jc(t),r]))].sort(),p={annotation:t,group:s,order:i,tags:l,tokens:f,unicode:c,version:d};if(r&&(p.emoticon=r),o&&(p.shortcodes=o),a){p.skinTones=[],p.skinUnicodes=[],p.skinVersions=[];for(const{tone:m,emoji:g,version:v}of a)p.skinTones.push(m),p.skinUnicodes.push(g),p.skinVersions.push(v)}return p})}function OD(n,e,t,r){n[e](t).onsuccess=s=>r&&r(s.target.result)}function Hl(n,e,t){OD(n,"get",e,t)}function PD(n,e,t){OD(n,"getAll",e,t)}function OS(n){n.commit&&n.commit()}function BJ(n,e){let t=n[0];for(let r=1;r<n.length;r++){const s=n[r];e(t)>e(s)&&(t=s)}return t}function DD(n,e){const t=BJ(n,s=>s.length),r=[];for(const s of t)n.some(i=>i.findIndex(o=>e(o)===e(s))===-1)||r.push(s);return r}async function $J(n){return!await PS(n,Xc,am)}async function zJ(n,e,t){const[r,s]=await Promise.all([kS,am].map(i=>PS(n,Xc,i)));return r===t&&s===e}async function qJ(n,e){return ea(n,ql,Qc,(r,s,i)=>{let o;const a=()=>{r.getAll(o&&IDBKeyRange.lowerBound(o,!0),50).onsuccess=l=>{const c=l.target.result;for(const d of c)if(o=d.unicode,e(d))return i(d);if(c.length<50)return i();a()}};a()})}async function jD(n,e,t,r){try{const s=UJ(e);await ea(n,[ql,Xc],LS,([i,o],a)=>{let l,c,d=0;function f(){++d===2&&p()}function p(){if(!(l===r&&c===t)){i.clear();for(const m of s)i.put(m);o.put(r,kS),o.put(t,am),OS(a)}}Hl(o,kS,m=>{l=m,f()}),Hl(o,am,m=>{c=m,f()})})}finally{}}async function HJ(n,e){return ea(n,ql,Qc,(t,r,s)=>{const i=IDBKeyRange.bound([e,0],[e+1,0],!1,!0);PD(t.index(RD),i,s)})}async function FD(n,e){const t=ND(Jc(e));return t.length?ea(n,ql,Qc,(r,s,i)=>{const o=[],a=()=>{o.length===t.length&&l()},l=()=>{const c=DD(o,d=>d.unicode);i(c.sort((d,f)=>d.order<f.order?-1:1))};for(let c=0;c<t.length;c++){const d=t[c],f=c===t.length-1?IDBKeyRange.bound(d,d+"￿",!1,!0):IDBKeyRange.only(d);PD(r.index(CD),f,p=>{o.push(p),a()})}}):[]}async function GJ(n,e){const t=await FD(n,e);return t.length?t.filter(r=>(r.shortcodes||[]).map(i=>i.toLowerCase()).includes(e.toLowerCase()))[0]||null:await qJ(n,s=>(s.shortcodes||[]).includes(e.toLowerCase()))||null}async function VJ(n,e){return ea(n,ql,Qc,(t,r,s)=>Hl(t,e,i=>{if(i)return s(i);Hl(t.index(kD),e,o=>s(o||null))}))}function PS(n,e,t){return ea(n,e,Qc,(r,s,i)=>Hl(r,t,i))}function WJ(n,e,t,r){return ea(n,e,LS,(s,i)=>{s.put(r,t),OS(i)})}function KJ(n,e){return ea(n,AS,LS,(t,r)=>Hl(t,e,s=>{t.put((s||0)+1,e),OS(r)}))}function YJ(n,e,t){return t===0?[]:ea(n,[AS,ql],Qc,([r,s],i,o)=>{const a=[];r.index(ID).openCursor(void 0,"prev").onsuccess=l=>{const c=l.target.result;if(!c)return o(a);function d(m){if(a.push(m),a.length===t)return o(a);c.continue()}const f=c.primaryKey,p=e.byName(f);if(p)return d(p);Hl(s,f,m=>{if(m)return d(m);c.continue()})}})}const um="";function XJ(n,e){const t=new Map;for(const s of n){const i=e(s);for(const o of i){let a=t;for(let c=0;c<o.length;c++){const d=o.charAt(c);let f=a.get(d);f||(f=new Map,a.set(d,f)),a=f}let l=a.get(um);l||(l=[],a.set(um,l)),l.push(s)}}return(s,i)=>{let o=t;for(let c=0;c<s.length;c++){const d=s.charAt(c),f=o.get(d);if(f)o=f;else return[]}if(i)return o.get(um)||[];const a=[],l=[o];for(;l.length;){const d=[...l.shift().entries()].sort((f,p)=>f[0]<p[0]?-1:1);for(const[f,p]of d)f===um?a.push(...p):l.push(p)}return a}}const QJ=["name","url"];function JJ(n){const e=n&&Array.isArray(n),t=e&&n.length&&(!n[0]||QJ.some(r=>!(r in n[0])));if(!e||t)throw new Error("Custom emojis are in the wrong format")}function UD(n){JJ(n);const e=(p,m)=>p.name.toLowerCase()<m.name.toLowerCase()?-1:1,t=n.sort(e),s=XJ(n,p=>[...new Set((p.shortcodes||[]).map(m=>Jc(m)).flat())]),i=p=>s(p,!0),o=p=>s(p,!1),a=p=>{const m=Jc(p),g=m.map((v,y)=>(y<m.length-1?i:o)(v));return DD(g,v=>v.name).sort(e)},l=new Map,c=new Map;for(const p of n){c.set(p.name.toLowerCase(),p);for(const m of p.shortcodes||[])l.set(m.toLowerCase(),p)}return{all:t,search:a,byShortcode:p=>l.get(p.toLowerCase()),byName:p=>c.get(p.toLowerCase())}}const ZJ=typeof wrappedJSObject<"u";function _f(n){if(!n)return n;if(ZJ&&(n=structuredClone(n)),delete n.tokens,n.skinTones){const e=n.skinTones.length;n.skins=Array(e);for(let t=0;t<e;t++)n.skins[t]={tone:n.skinTones[t],unicode:n.skinUnicodes[t],version:n.skinVersions[t]};delete n.skinTones,delete n.skinUnicodes,delete n.skinVersions}return n}function BD(n){n||console.warn("emoji-picker-element is more efficient if the dataSource server exposes an ETag header.")}const eZ=["annotation","emoji","group","order","tags","version"];function tZ(n){if(!n||!Array.isArray(n)||!n[0]||typeof n[0]!="object"||eZ.some(e=>!(e in n[0])))throw new Error("Emoji data is in the wrong format")}function $D(n,e){if(Math.floor(n.status/100)!==2)throw new Error("Failed to fetch: "+e+": "+n.status)}async function nZ(n){const e=await fetch(n,{method:"HEAD"});$D(e,n);const t=e.headers.get("etag");return BD(t),t}async function DS(n){const e=await fetch(n);$D(e,n);const t=e.headers.get("etag");BD(t);const r=await e.json();return tZ(r),[t,r]}function rZ(n){for(var e="",t=new Uint8Array(n),r=t.byteLength,s=-1;++s<r;)e+=String.fromCharCode(t[s]);return e}function sZ(n){for(var e=n.length,t=new ArrayBuffer(e),r=new Uint8Array(t),s=-1;++s<e;)r[s]=n.charCodeAt(s);return t}async function zD(n){const e=JSON.stringify(n);let t=sZ(e);const r=await crypto.subtle.digest("SHA-1",t),s=rZ(r);return btoa(s)}async function iZ(n,e){let t,r=await nZ(e);if(!r){const s=await DS(e);r=s[0],t=s[1],r||(r=await zD(t))}await zJ(n,e,r)||(t||(t=(await DS(e))[1]),await jD(n,t,e,r))}async function oZ(n,e){let[t,r]=await DS(e);t||(t=await zD(r)),await jD(n,r,e,t)}class aZ{constructor({dataSource:e=AJ,locale:t=kJ,customEmoji:r=[]}={}){this.dataSource=e,this.locale=t,this._dbName=`emoji-picker-element-${this.locale}`,this._db=void 0,this._lazyUpdate=void 0,this._custom=UD(r),this._clear=this._clear.bind(this),this._ready=this._init()}async _init(){const e=this._db=await OJ(this._dbName);DJ(this._dbName,this._clear);const t=this.dataSource;await $J(e)?await oZ(e,t):this._lazyUpdate=iZ(e,t)}async ready(){const e=async()=>(this._ready||(this._ready=this._init()),this._ready);await e(),this._db||await e()}async getEmojiByGroup(e){return RS(e),await this.ready(),LD(await HJ(this._db,e)).map(_f)}async getEmojiBySearchQuery(e){om(e),await this.ready();const t=this._custom.search(e),r=LD(await FD(this._db,e)).map(_f);return[...t,...r]}async getEmojiByShortcode(e){om(e),await this.ready();const t=this._custom.byShortcode(e);return t||_f(await GJ(this._db,e))}async getEmojiByUnicodeOrName(e){om(e),await this.ready();const t=this._custom.byName(e);return t||_f(await VJ(this._db,e))}async getPreferredSkinTone(){return await this.ready(),await PS(this._db,Xc,AD)||0}async setPreferredSkinTone(e){return RS(e),await this.ready(),WJ(this._db,Xc,AD,e)}async incrementFavoriteEmojiCount(e){return om(e),await this.ready(),KJ(this._db,e)}async getTopFavoriteEmoji(e){return RS(e),await this.ready(),(await YJ(this._db,this._custom,e)).map(_f)}set customEmoji(e){this._custom=UD(e)}get customEmoji(){return this._custom.all}async _shutdown(){await this.ready();try{await this._lazyUpdate}catch{}}_clear(){this._db=this._ready=this._lazyUpdate=void 0}async close(){await this._shutdown(),await NS(this._dbName)}async delete(){await this._shutdown(),await PJ(this._dbName)}}const jS=[[-1,"✨","custom"],[0,"😀","smileys-emotion"],[1,"👋","people-body"],[3,"🐱","animals-nature"],[4,"🍎","food-drink"],[5,"🏠️","travel-places"],[6,"⚽","activities"],[7,"📝","objects"],[8,"⛔️","symbols"],[9,"🏁","flags"]].map(([n,e,t])=>({id:n,emoji:e,name:t})),FS=jS.slice(1),lZ=2,qD=6,HD=typeof requestIdleCallback=="function"?requestIdleCallback:setTimeout;function GD(n){return n.unicode.includes("‍")}const cZ={"🫨":15.1,"🫠":14,"🥲":13.1,"🥻":12.1,"🥰":11,"🤩":5,"👱‍♀️":4,"🤣":3,"👁️‍🗨️":2,"😀":1,"😐️":.7,"😃":.6},uZ=1e3,dZ="🖐️",fZ=8,hZ=["😊","😒","❤️","👍️","😍","😂","😭","☺️","😔","😩","😏","💕","🙌","😘"],VD='"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif',pZ=(n,e)=>n<e?-1:n>e?1:0,WD=(n,e)=>{const t=document.createElement("canvas");t.width=t.height=1;const r=t.getContext("2d");return r.textBaseline="top",r.font=`100px ${VD}`,r.fillStyle=e,r.scale(.01,.01),r.fillText(n,0,0),r.getImageData(0,0,1,1).data},mZ=(n,e)=>{const t=[...n].join(","),r=[...e].join(",");return t===r&&!t.startsWith("0,0,0,")};function gZ(n){const e=WD(n,"#000"),t=WD(n,"#fff");return e&&t&&mZ(e,t)}function _Z(){const n=Object.entries(cZ);try{for(const[e,t]of n)if(gZ(e))return t}catch{}finally{}return n[0][1]}let US;const BS=()=>(US||(US=new Promise(n=>HD(()=>n(_Z())))),US),$S=new Map,vZ="️",yZ="\uD83C",bZ="‍",xZ=127995,SZ=57339;function EZ(n,e){if(e===0)return n;const t=n.indexOf(bZ);return t!==-1?n.substring(0,t)+String.fromCodePoint(xZ+e-1)+n.substring(t):(n.endsWith(vZ)&&(n=n.substring(0,n.length-1)),n+yZ+String.fromCodePoint(SZ+e-1))}function ko(n){n.preventDefault(),n.stopPropagation()}function zS(n,e,t){return e+=n?-1:1,e<0?e=t.length-1:e>=t.length&&(e=0),e}function KD(n,e){const t=new Set,r=[];for(const s of n){const i=e(s);t.has(i)||(t.add(i),r.push(s))}return r}function wZ(n,e){const t=r=>{const s={};for(const i of r)typeof i.tone=="number"&&i.version<=e&&(s[i.tone]=i.unicode);return s};return n.map(({unicode:r,skins:s,shortcodes:i,url:o,name:a,category:l,annotation:c})=>({unicode:r,name:a,shortcodes:i,url:o,category:l,annotation:c,id:r||a,skins:s&&t(s)}))}const dm=requestAnimationFrame;let TZ=typeof ResizeObserver=="function";function CZ(n,e,t){let r;TZ?(r=new ResizeObserver(s=>t(s[0].contentRect.width)),r.observe(n)):dm(()=>t(n.getBoundingClientRect().width)),e.addEventListener("abort",()=>{r&&r.disconnect()})}function YD(n){{const e=document.createRange();return e.selectNode(n.firstChild),e.getBoundingClientRect().width}}let qS;function IZ(n,e,t){for(const r of n){const s=t(r),i=YD(s);typeof qS>"u"&&(qS=YD(e));const o=i/1.8<qS;$S.set(r.unicode,o)}}function RZ(n){return KD(n,e=>e)}function AZ(n){n&&(n.scrollTop=0)}function vf(n,e,t){let r=n.get(e);return r||(r=t(),n.set(e,r)),r}function XD(n){return""+n}function kZ(n){const e=document.createElement("template");return e.innerHTML=n,e}const LZ=new WeakMap,MZ=new WeakMap,NZ=Symbol("un-keyed"),OZ="replaceChildren"in Element.prototype;function PZ(n,e){OZ?n.replaceChildren(...e):(n.innerHTML="",n.append(...e))}function DZ(n,e){let t=n.firstChild,r=0;for(;t;){if(e[r]!==t)return!0;t=t.nextSibling,r++}return r!==e.length}function jZ(n,e){const{targetNode:t}=e;let{targetParentNode:r}=e,s=!1;r?s=DZ(r,n):(s=!0,e.targetNode=void 0,e.targetParentNode=r=t.parentNode),s&&PZ(r,n)}function FZ(n,e){for(const t of e){const{targetNode:r,currentExpression:s,binding:{expressionIndex:i,attributeName:o,attributeValuePre:a,attributeValuePost:l}}=t,c=n[i];if(s!==c)if(t.currentExpression=c,o)r.setAttribute(o,a+XD(c)+l);else{let d;Array.isArray(c)?jZ(c,t):c instanceof Element?(d=c,r.replaceWith(d)):r.nodeValue=XD(c),d&&(t.targetNode=d)}}}function UZ(n){let e="",t=!1,r=!1,s=-1;const i=new Map,o=[];for(let l=0,c=n.length;l<c;l++){const d=n[l];if(e+=d,l===c-1)break;for(let b=0;b<d.length;b++)switch(d.charAt(b)){case"<":{d.charAt(b+1)==="/"?o.pop():(t=!0,o.push(++s));break}case">":{t=!1,r=!1;break}case"=":{r=!0;break}}const f=o[o.length-1],p=vf(i,f,()=>[]);let m,g,v;if(r){const b=/(\S+)="?([^"=]*)$/.exec(d);m=b[1],g=b[2],v=/^[^">]*/.exec(n[l+1])[0]}const y={attributeName:m,attributeValuePre:g,attributeValuePost:v,expressionIndex:l};p.push(y),!t&&!r&&(e+=" ")}return{template:kZ(e),elementsToBindings:i}}function BZ(n,e){const t=[],r=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let s=n,i=-1;do{const o=e.get(++i);if(o)for(let a=0;a<o.length;a++){const l=o[a],c=l.attributeName?s:s.firstChild,d={binding:l,targetNode:c,targetParentNode:void 0,currentExpression:void 0};t.push(d)}}while(s=r.nextNode());return t}function $Z(n){const{template:e,elementsToBindings:t}=vf(LZ,n,()=>UZ(n)),r=e.cloneNode(!0).content.firstElementChild,s=BZ(r,t);return function(o){return FZ(o,s),r}}function zZ(n){const e=vf(MZ,n,()=>new Map);let t=NZ;function r(i,...o){const a=vf(e,i,()=>new Map);return vf(a,t,()=>$Z(i))(o)}function s(i,o,a){return i.map((l,c)=>{const d=t;t=a(l);try{return o(l,c)}finally{t=d}})}return{map:s,html:r}}function qZ(n,e,t,r,s,i,o,a){const{labelWithSkin:l,titleForEmoji:c,unicodeWithSkin:d}=t,{html:f,map:p}=zZ(e);function m(y,b,S){return p(y,(E,C)=>f`<button role="${b?"option":"menuitem"}" aria-selected="${e.searchMode?C===e.activeSearchItem:""}" aria-label="${l(E,e.currentSkinTone)}" title="${c(E)}" class="emoji ${b&&C===e.activeSearchItem?"active":""}" id="${`${S}-${E.id}`}">${E.unicode?d(E,e.currentSkinTone):f`<img class="custom-emoji" src="${E.url}" alt="" loading="lazy">`}</button>`,E=>`${S}-${E.id}`)}const v=f`<section data-ref="rootElement" class="picker" aria-label="${e.i18n.regionLabel}" style="${e.pickerStyle}"><div class="pad-top"></div><div class="search-row"><div class="search-wrapper"><input id="search" class="search" type="search" role="combobox" enterkeyhint="search" placeholder="${e.i18n.searchLabel}" autocapitalize="none" autocomplete="off" spellcheck="true" aria-expanded="${!!(e.searchMode&&e.currentEmojis.length)}" aria-controls="search-results" aria-describedby="search-description" aria-autocomplete="list" aria-activedescendant="${e.activeSearchItemId?`emo-${e.activeSearchItemId}`:""}" data-ref="searchElement" data-on-input="onSearchInput" data-on-keydown="onSearchKeydown"><label class="sr-only" for="search">${e.i18n.searchLabel}</label> <span id="search-description" class="sr-only">${e.i18n.searchDescription}</span></div><div class="skintone-button-wrapper ${e.skinTonePickerExpandedAfterAnimation?"expanded":""}"><button id="skintone-button" class="emoji ${e.skinTonePickerExpanded?"hide-focus":""}" aria-label="${e.skinToneButtonLabel}" title="${e.skinToneButtonLabel}" aria-describedby="skintone-description" aria-haspopup="listbox" aria-expanded="${e.skinTonePickerExpanded}" aria-controls="skintone-list" data-on-click="onClickSkinToneButton">${e.skinToneButtonText}</button></div><span id="skintone-description" class="sr-only">${e.i18n.skinToneDescription}</span><div data-ref="skinToneDropdown" id="skintone-list" class="skintone-list hide-focus ${e.skinTonePickerExpanded?"":"hidden no-animate"}" style="transform:translateY(${e.skinTonePickerExpanded?0:"calc(-1 * var(--num-skintones) * var(--total-emoji-size))"})" role="listbox" aria-label="${e.i18n.skinTonesLabel}" aria-activedescendant="skintone-${e.activeSkinTone}" aria-hidden="${!e.skinTonePickerExpanded}" tabIndex="-1" data-on-focusout="onSkinToneOptionsFocusOut" data-on-click="onSkinToneOptionsClick" data-on-keydown="onSkinToneOptionsKeydown" data-on-keyup="onSkinToneOptionsKeyup">${p(e.skinTones,(y,b)=>f`<div id="skintone-${b}" class="emoji ${b===e.activeSkinTone?"active":""}" aria-selected="${b===e.activeSkinTone}" role="option" title="${e.i18n.skinTones[b]}" aria-label="${e.i18n.skinTones[b]}">${y}</div>`,y=>y)}</div></div><div class="nav" role="tablist" style="grid-template-columns:repeat(${e.groups.length},1fr)" aria-label="${e.i18n.categoriesLabel}" data-on-keydown="onNavKeydown" data-on-click="onNavClick">${p(e.groups,y=>f`<button role="tab" class="nav-button" aria-controls="tab-${y.id}" aria-label="${e.i18n.categories[y.name]}" aria-selected="${!e.searchMode&&e.currentGroup.id===y.id}" title="${e.i18n.categories[y.name]}" data-group-id="${y.id}"><div class="nav-emoji emoji">${y.emoji}</div></button>`,y=>y.id)}</div><div class="indicator-wrapper"><div class="indicator" style="transform:translateX(${(e.isRtl?-1:1)*e.currentGroupIndex*100}%)"></div></div><div class="message ${e.message?"":"gone"}" role="alert" aria-live="polite">${e.message}</div><div data-ref="tabpanelElement" class="tabpanel ${!e.databaseLoaded||e.message?"gone":""}" role="${e.searchMode?"region":"tabpanel"}" aria-label="${e.searchMode?e.i18n.searchResultsLabel:e.i18n.categories[e.currentGroup.name]}" id="${e.searchMode?"":`tab-${e.currentGroup.id}`}" tabIndex="0" data-on-click="onEmojiClick"><div data-action="calculateEmojiGridStyle">${p(e.currentEmojisWithCategories,(y,b)=>f`<div><div id="menu-label-${b}" class="category ${e.currentEmojisWithCategories.length===1&&e.currentEmojisWithCategories[0].category===""?"gone":""}" aria-hidden="true">${e.searchMode?e.i18n.searchResultsLabel:y.category?y.category:e.currentEmojisWithCategories.length>1?e.i18n.categories.custom:e.i18n.categories[e.currentGroup.name]}</div><div class="emoji-menu" role="${e.searchMode?"listbox":"menu"}" aria-labelledby="menu-label-${b}" id="${e.searchMode?"search-results":""}">${m(y.emojis,e.searchMode,"emo")}</div></div>`,y=>y.category)}</div></div><div class="favorites emoji-menu ${e.message?"gone":""}" role="menu" aria-label="${e.i18n.favoritesLabel}" style="padding-inline-end:${`${e.scrollbarWidth}px`}" data-on-click="onEmojiClick">${m(e.currentFavorites,!1,"fav")}</div><button data-ref="baselineEmoji" aria-hidden="true" tabindex="-1" class="abs-pos hidden emoji baseline-emoji">😀</button></section>`;if(a){n.appendChild(v);const y=(b,S)=>{for(const E of n.querySelectorAll(`[${b}]`))S(E,E.getAttribute(b))};for(const b of["click","focusout","input","keydown","keyup"])y(`data-on-${b}`,(S,E)=>{S.addEventListener(b,r[E])});y("data-ref",(b,S)=>{i[S]=b}),y("data-action",(b,S)=>{s[S](b)}),o.addEventListener("abort",()=>{n.removeChild(v)})}}const fm=typeof queueMicrotask=="function"?queueMicrotask:n=>Promise.resolve().then(n);function HZ(n){let e=!1,t;const r=new Map,s=new Set;let i;const o=()=>{if(e)return;const c=[...s];s.clear();try{for(const d of c)d()}finally{i=!1,s.size&&(i=!0,fm(o))}},a=new Proxy({},{get(c,d){if(t){let f=r.get(d);f||(f=new Set,r.set(d,f)),f.add(t)}return c[d]},set(c,d,f){c[d]=f;const p=r.get(d);if(p){for(const m of p)s.add(m);i||(i=!0,fm(o))}return!0}}),l=c=>{const d=()=>{const f=t;t=d;try{return c()}finally{t=f}};return d()};return n.addEventListener("abort",()=>{e=!0}),{state:a,createEffect:l}}function HS(n,e,t){if(n.length!==e.length)return!1;for(let r=0;r<n.length;r++)if(!t(n[r],e[r]))return!1;return!0}const GS=[],{assign:hm}=Object;function GZ(n,e){const t={},r=new AbortController,s=r.signal,{state:i,createEffect:o}=HZ(s);hm(i,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),hm(i,e),hm(i,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:fZ,isRtl:!1,scrollbarWidth:0,currentGroupIndex:0,groups:FS,databaseLoaded:!1,activeSearchItemId:void 0}),o(()=>{i.currentGroup!==i.groups[i.currentGroupIndex]&&(i.currentGroup=i.groups[i.currentGroupIndex])});const a=K=>{n.getElementById(K).focus()},l=K=>n.getElementById(`emo-${K.id}`),c=(K,W)=>{t.rootElement.dispatchEvent(new CustomEvent(K,{detail:W,bubbles:!0,composed:!0}))},d=(K,W)=>K.id===W.id,f=(K,W)=>{const{category:te,emojis:re}=K,{category:pe,emojis:Ee}=W;return te!==pe?!1:HS(re,Ee,d)},p=K=>{HS(i.currentEmojis,K,d)||(i.currentEmojis=K)},m=K=>{i.searchMode!==K&&(i.searchMode=K)},g=K=>{HS(i.currentEmojisWithCategories,K,f)||(i.currentEmojisWithCategories=K)},v=(K,W)=>W&&K.skins&&K.skins[W]||K.unicode,S={labelWithSkin:(K,W)=>RZ([K.name||v(K,W),K.annotation,...K.shortcodes||GS].filter(Boolean)).join(", "),titleForEmoji:K=>K.annotation||(K.shortcodes||GS).join(", "),unicodeWithSkin:v},E={onClickSkinToneButton:H,onEmojiClick:z,onNavClick:q,onNavKeydown:G,onSearchKeydown:$,onSkinToneOptionsClick:P,onSkinToneOptionsFocusOut:J,onSkinToneOptionsKeydown:Z,onSkinToneOptionsKeyup:Q,onSearchInput:ee},C={calculateEmojiGridStyle:A};let R=!0;o(()=>{qZ(n,i,S,E,C,t,s,R),R=!1}),i.emojiVersion||BS().then(K=>{K||(i.message=i.i18n.emojiUnsupportedMessage)}),o(()=>{async function K(){let W=!1;const te=setTimeout(()=>{W=!0,i.message=i.i18n.loadingMessage},uZ);try{await i.database.ready(),i.databaseLoaded=!0}catch(re){console.error(re),i.message=i.i18n.networkErrorMessage}finally{clearTimeout(te),W&&(W=!1,i.message="")}}i.database&&K()}),o(()=>{i.pickerStyle=`
297 --num-groups: ${i.groups.length};
298 --indicator-opacity: ${i.searchMode?0:1};
299 --num-skintones: ${qD};`}),o(()=>{i.customEmoji&&i.database&&I()}),o(()=>{i.customEmoji&&i.customEmoji.length?i.groups!==jS&&(i.groups=jS):i.groups!==FS&&(i.currentGroupIndex&&i.currentGroupIndex--,i.groups=FS)}),o(()=>{async function K(){i.databaseLoaded&&(i.currentSkinTone=await i.database.getPreferredSkinTone())}K()}),o(()=>{i.skinTones=Array(qD).fill().map((K,W)=>EZ(i.skinToneEmoji,W))}),o(()=>{i.skinToneButtonText=i.skinTones[i.currentSkinTone]}),o(()=>{i.skinToneButtonLabel=i.i18n.skinToneLabel.replace("{skinTone}",i.i18n.skinTones[i.currentSkinTone])}),o(()=>{async function K(){const{database:W}=i,te=(await Promise.all(hZ.map(re=>W.getEmojiByUnicodeOrName(re)))).filter(Boolean);i.defaultFavoriteEmojis=te}i.databaseLoaded&&K()});function I(){i.database.customEmoji=i.customEmoji||GS}o(()=>{async function K(){I();const{database:W,defaultFavoriteEmojis:te,numColumns:re}=i,pe=await W.getTopFavoriteEmoji(re),Ee=await M(KD([...pe,...te],le=>le.unicode||le.name).slice(0,re));i.currentFavorites=Ee}i.databaseLoaded&&i.defaultFavoriteEmojis&&K()});function A(K){CZ(K,s,W=>{{const te=getComputedStyle(t.rootElement),re=parseInt(te.getPropertyValue("--num-columns"),10),pe=te.getPropertyValue("direction")==="rtl",le=K.parentElement.getBoundingClientRect().width-W;i.numColumns=re,i.scrollbarWidth=le,i.isRtl=pe}})}o(()=>{async function K(){const{searchText:W,currentGroup:te,databaseLoaded:re,customEmoji:pe}=i;if(!re)i.currentEmojis=[],i.searchMode=!1;else if(W.length>=lZ){const Ee=await U(W);i.searchText===W&&(p(Ee),m(!0))}else{const{id:Ee}=te;if(Ee!==-1||pe&&pe.length){const le=await F(Ee);i.currentGroup.id===Ee&&(p(le),m(!1))}}}K()}),o(()=>{const{currentEmojis:K,emojiVersion:W}=i,te=K.filter(re=>re.unicode).filter(re=>GD(re)&&!$S.has(re.unicode));if(!W&&te.length)p(K),dm(()=>k(te));else{const re=W?K:K.filter(N);p(re),dm(()=>AZ(t.tabpanelElement))}});function k(K){IZ(K,t.baselineEmoji,l),i.currentEmojis=i.currentEmojis}function N(K){return!K.unicode||!GD(K)||$S.get(K.unicode)}async function D(K){const W=i.emojiVersion||await BS();return K.filter(({version:te})=>!te||te<=W)}async function M(K){return wZ(K,i.emojiVersion||await BS())}async function F(K){const W=K===-1?i.customEmoji:await i.database.getEmojiByGroup(K);return M(await D(W))}async function U(K){return M(await D(await i.database.getEmojiBySearchQuery(K)))}o(()=>{}),o(()=>{function K(){const{searchMode:te,currentEmojis:re}=i;if(te)return[{category:"",emojis:re}];const pe=new Map;for(const Ee of re){const le=Ee.category||"";let Ie=pe.get(le);Ie||(Ie=[],pe.set(le,Ie)),Ie.push(Ee)}return[...pe.entries()].map(([Ee,le])=>({category:Ee,emojis:le})).sort((Ee,le)=>i.customCategorySorting(Ee.category,le.category))}const W=K();g(W)}),o(()=>{i.activeSearchItemId=i.activeSearchItem!==-1&&i.currentEmojis[i.activeSearchItem].id}),o(()=>{const{rawSearchText:K}=i;HD(()=>{i.searchText=(K||"").trim(),i.activeSearchItem=-1})});function $(K){if(!i.searchMode||!i.currentEmojis.length)return;const W=te=>{ko(K),i.activeSearchItem=zS(te,i.activeSearchItem,i.currentEmojis)};switch(K.key){case"ArrowDown":return W(!1);case"ArrowUp":return W(!0);case"Enter":if(i.activeSearchItem===-1)i.activeSearchItem=0;else return ko(K),V(i.currentEmojis[i.activeSearchItem].id)}}function q(K){const{target:W}=K,te=W.closest(".nav-button");if(!te)return;const re=parseInt(te.dataset.groupId,10);t.searchElement.value="",i.rawSearchText="",i.searchText="",i.activeSearchItem=-1,i.currentGroupIndex=i.groups.findIndex(pe=>pe.id===re)}function G(K){const{target:W,key:te}=K,re=pe=>{pe&&(ko(K),pe.focus())};switch(te){case"ArrowLeft":return re(W.previousElementSibling);case"ArrowRight":return re(W.nextElementSibling);case"Home":return re(W.parentElement.firstElementChild);case"End":return re(W.parentElement.lastElementChild)}}async function V(K){const W=await i.database.getEmojiByUnicodeOrName(K),te=[...i.currentEmojis,...i.currentFavorites].find(pe=>pe.id===K),re=te.unicode&&v(te,i.currentSkinTone);await i.database.incrementFavoriteEmojiCount(K),c("emoji-click",{emoji:W,skinTone:i.currentSkinTone,...re&&{unicode:re},...te.name&&{name:te.name}})}async function z(K){const{target:W}=K;if(!W.classList.contains("emoji"))return;ko(K);const te=W.id.substring(4);V(te)}function B(K){i.currentSkinTone=K,i.skinTonePickerExpanded=!1,a("skintone-button"),c("skin-tone-change",{skinTone:K}),i.database.setPreferredSkinTone(K)}function P(K){const{target:{id:W}}=K,te=W&&W.match(/^skintone-(\d)/);if(!te)return;ko(K);const re=parseInt(te[1],10);B(re)}function H(K){i.skinTonePickerExpanded=!i.skinTonePickerExpanded,i.activeSkinTone=i.currentSkinTone,i.skinTonePickerExpanded&&(ko(K),dm(()=>a("skintone-list")))}o(()=>{i.skinTonePickerExpanded?t.skinToneDropdown.addEventListener("transitionend",()=>{i.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):i.skinTonePickerExpandedAfterAnimation=!1});function Z(K){if(!i.skinTonePickerExpanded)return;const W=async te=>{ko(K),i.activeSkinTone=te};switch(K.key){case"ArrowUp":return W(zS(!0,i.activeSkinTone,i.skinTones));case"ArrowDown":return W(zS(!1,i.activeSkinTone,i.skinTones));case"Home":return W(0);case"End":return W(i.skinTones.length-1);case"Enter":return ko(K),B(i.activeSkinTone);case"Escape":return ko(K),i.skinTonePickerExpanded=!1,a("skintone-button")}}function Q(K){if(i.skinTonePickerExpanded)switch(K.key){case" ":return ko(K),B(i.activeSkinTone)}}async function J(K){const{relatedTarget:W}=K;(!W||W.id!=="skintone-list")&&(i.skinTonePickerExpanded=!1)}function ee(K){i.rawSearchText=K.target.value}return{$set(K){hm(i,K)},$destroy(){r.abort()}}}const VZ="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",WZ="en";var KZ={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},YZ=":host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.custom-emoji,.emoji,button.emoji{height:var(--total-emoji-size);width:var(--total-emoji-size)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.custom-emoji{padding:var(--emoji-padding);object-fit:contain;pointer-events:none;background-repeat:no-repeat;background-position:center center;background-size:var(--emoji-size) var(--emoji-size)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}";const QD=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],XZ=`:host{--emoji-font-family:${VD}}`;class JD extends HTMLElement{constructor(e){super(),this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=YZ+XZ,this.shadowRoot.appendChild(t),this._ctx={locale:WZ,dataSource:VZ,skinToneEmoji:dZ,customCategorySorting:pZ,customEmoji:null,i18n:KZ,emojiVersion:null,...e};for(const r of QD)r!=="database"&&Object.prototype.hasOwnProperty.call(this,r)&&(this._ctx[r]=this[r],delete this[r]);this._dbFlush()}connectedCallback(){this._cmp||(this._cmp=GZ(this.shadowRoot,this._ctx))}disconnectedCallback(){fm(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:e}=this._ctx;e.close().catch(t=>console.error(t))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(e,t,r){this._set(e.replace(/-([a-z])/g,(s,i)=>i.toUpperCase()),e==="emoji-version"?parseFloat(r):r)}_set(e,t){this._ctx[e]=t,this._cmp&&this._cmp.$set({[e]:t}),["locale","dataSource"].includes(e)&&this._dbFlush()}_dbCreate(){const{locale:e,dataSource:t,database:r}=this._ctx;(!r||r.locale!==e||r.dataSource!==t)&&this._set("database",new aZ({locale:e,dataSource:t}))}_dbFlush(){fm(()=>this._dbCreate())}}const ZD={};for(const n of QD)ZD[n]={get(){return n==="database"&&this._dbCreate(),this._ctx[n]},set(e){if(n==="database")throw new Error("database is read-only");this._set(n,e)}};Object.defineProperties(JD.prototype,ZD),customElements.get("emoji-picker")||customElements.define("emoji-picker",JD);const Ms={"glyph-picker":"_glyph-picker_1xyr6_6","glyph-picker-body":"_glyph-picker-body_1xyr6_10","glyph-picker-body--sticker":"_glyph-picker-body--sticker_1xyr6_14","glyph-picker__stickers":"_glyph-picker__stickers_1xyr6_29","glyph-picker__stickers-packs":"_glyph-picker__stickers-packs_1xyr6_43","glyph-picker__stickers-packs-item-logo":"_glyph-picker__stickers-packs-item-logo_1xyr6_61","glyph-picker__stickers-packs-item":"_glyph-picker__stickers-packs-item_1xyr6_61","glyph-picker__stickers-packs-item--active":"_glyph-picker__stickers-packs-item--active_1xyr6_82","glyph-picker__stickers-packs-item-icon":"_glyph-picker__stickers-packs-item-icon_1xyr6_118","glyph-picker__stickers-items":"_glyph-picker__stickers-items_1xyr6_123","glyph-picker__stickers-items-sticker":"_glyph-picker__stickers-items-sticker_1xyr6_135","glyph-picker__stickers-items-sticker-img":"_glyph-picker__stickers-items-sticker-img_1xyr6_178","glyph-picker__tab-btn":"_glyph-picker__tab-btn_1xyr6_191"};function QZ({className:n,onSelectEmoji:e,onSelectSticker:t}){const r=T.useRef(),[s,i]=T.useState("EMOJI"),[o,a]=T.useState("RECENT"),c=Dr()?"https://gateway.hamsalam.ir/public-20/admin/j50O7/05-11/TfWt3TjzBrFcCLIZxaKeaLradT3LQFZfIsVAa3d7JCh0h6z542.json":"https://statics.basalam.com/public-20/admin/j50O7/05-11/TfWt3TjzBrFcCLIZxaKeaLradT3LQFZfIsVAa3d7JCh0h6z542.json",{data:d}=FY({onSuccess(g){a(g[1].slug)},select:g=>{const v=[{stickers:[],name:"اخیر",slug:"RECENT",icon:_.jsx("svg",{className:Ms["glyph-picker__stickers-packs-item-icon"],xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:_.jsx("path",{d:"M256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512zM232 256C232 264 236 271.5 242.7 275.1L338.7 339.1C349.7 347.3 364.6 344.3 371.1 333.3C379.3 322.3 376.3 307.4 365.3 300L280 243.2V120C280 106.7 269.3 96 255.1 96C242.7 96 231.1 106.7 231.1 120L232 256z"})})},...g],y=JSON.parse(de.bsLocalStorage.getItem(xr.RECENT_USED_STICKERS)||"[]");if((y==null?void 0:y.length)>0){const b=y.filter(S=>v.some(E=>E.slug!=="RECENT"&&E.stickers.some(C=>(C==null?void 0:C.id)===(S==null?void 0:S.id))));v[0].stickers=b}return v}}),f=async g=>{var y;await de.sleep(0),(y=document.querySelector(`#chat-message-form-sticker-${g==null?void 0:g.id}`))==null||y.blur(),t(g);const v=d[0];if(v.stickers.some(b=>(g==null?void 0:g.id)===(b==null?void 0:b.id))){const b=v.stickers.findIndex(E=>(g==null?void 0:g.id)===(E==null?void 0:E.id)),S=v.stickers.splice(b,1)[0];v.stickers.splice(0,0,S)}else v.stickers.unshift(g);delete v.icon,de.bsLocalStorage.setItem(xr.RECENT_USED_STICKERS,JSON.stringify(v.stickers))};T.useEffect(()=>{const g=r.current;return g&&g.addEventListener("emoji-click",e),()=>{g&&g.removeEventListener("emoji-click",e)}},[r,e]),T.useEffect(()=>{const g=r.current;if(g){const v=document.createElement("style");v.innerHTML=`
300 .picker {
301 border: none;
302 }
303
304 .search-row {
305 display: none;
306 }
307
308 .favorites {
309 display: none;
310 }
311
312 .indicator {
313 border-radius: 3px 3px 0 0;
314 }
315
316 .tabpanel {
317 @media (min-width: 576px) {
318 -webkit-overflow-scrolling: touch;
319
320 &::-webkit-scrollbar {
321 background: none;
322 padding: 2px;
323 width: 8px;
324 }
325
326 &::-webkit-scrollbar-track {
327 background-color: rgba(0, 0, 0, 0.2);
328 }
329
330 &::-webkit-scrollbar-thumb {
331 background-color: rgba(0, 0, 0, 0.3);
332
333 &:hover {
334 background-color: rgba(0, 0, 0, 0.5);
335 }
336 }
337
338 &::-webkit-scrollbar-corner {
339 background-color: rgba(0, 0, 0, 0);
340 }
341 }
342 }
343 `,g.shadowRoot.append(v)}},[r]);const p=g=>{setTimeout(()=>{i(g)},0)},m=g=>{setTimeout(()=>{a(g)},0)};return _.jsxs("div",{className:Te(n,Ms["glyph-picker"],{[Ms["glyph-picker--sticker"]]:s==="STICKER"}),children:[_.jsxs(je,{className:Te(Ms["glyph-picker-body"],{[Ms["glyph-picker-body--sticker"]]:s==="STICKER"}),display:"flex",alignItems:"flex-start",justifyContent:"flex-start",children:[_.jsx("emoji-picker",{class:"light","emoji-version":"15.0",ref:r,"data-source":c}),_.jsxs("div",{className:Ms["glyph-picker__stickers"],children:[_.jsx("div",{className:Ms["glyph-picker__stickers-packs"],children:d==null?void 0:d.filter(g=>g.stickers.length>0).map(g=>_.jsx("button",{className:Te(Ms["glyph-picker__stickers-packs-item"],{[Ms["glyph-picker__stickers-packs-item--active"]]:g.slug===o}),onClick:()=>m(g.slug),children:g.icon??_.jsx("img",{className:Ms["glyph-picker__stickers-packs-item-logo"],src:g.stickers[0].url,alt:g.name})},g.slug))}),_.jsx("div",{className:Ms["glyph-picker__stickers-items"],children:d==null?void 0:d.find(g=>g.slug===o).stickers.map(g=>_.jsx("button",{id:`chat-message-form-sticker-${g==null?void 0:g.id}`,className:Ms["glyph-picker__stickers-items-sticker"],onClick:()=>f(g),"aria-label":"انتخاب استیکر",children:_.jsx("img",{className:Ms["glyph-picker__stickers-items-sticker-img"],src:g.url})},g==null?void 0:g.id))})]})]}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"center",children:[_.jsx(Qe,{className:Ms["glyph-picker__tab-btn"],variant:"text",color:s==="EMOJI"?"primary":"secondary",icon:"bi-emoji",size:"md",square:!0,onClick:()=>p("EMOJI")}),_.jsx(Qe,{className:Ms["glyph-picker__tab-btn"],variant:"text",color:s==="STICKER"?"primary":"secondary",icon:"bi-sticker",size:"md",square:!0,onClick:()=>p("STICKER")})]})]})}const Gl={"attached-product":"_attached-product_jjmzi_6","attached-product__photo":"_attached-product__photo_jjmzi_12","attached-product__info":"_attached-product__info_jjmzi_19","attached-product__info-title":"_attached-product__info-title_jjmzi_28","attached-product__info-primary-price":"_attached-product__info-primary-price_jjmzi_41","attached-product__info-price":"_attached-product__info-price_jjmzi_47"};function JZ({className:n,onClose:e}){const{chatModalData:t}=Lt(["chatModalData"]),r=t==null?void 0:t.attachedProductId,{data:s,isLoading:i}=yD({productId:r},{enabled:!!r});return(i||s)&&r&&_.jsxs("div",{className:Te(n,Gl["attached-product"]),children:[s?_.jsx("img",{className:Gl["attached-product__photo"],src:s.photo.extraSmall,alt:s.title}):_.jsx(vt,{width:36,height:36}),_.jsxs("div",{className:Gl["attached-product__info"],children:[s?_.jsxs("span",{className:Gl["attached-product__info-title"],children:[_.jsx("i",{className:"bi-attach"}),s.title]}):_.jsx(vt,{width:150,height:20}),s?_.jsxs(_.Fragment,{children:[s.primaryPrice&&_.jsx("span",{className:Gl["attached-product__info-primary-price"],children:de.numberSeparator(de.rialToToman(s.primaryPrice))}),_.jsxs("span",{className:Gl["attached-product__info-price"],children:[de.numberSeparator(de.rialToToman(s.price)),_.jsx("i",{className:"bi-toman"})]})]}):_.jsx(je,{mt:2,children:_.jsx(vt,{width:100,height:20})})]}),s&&_.jsx(Qe,{className:Gl["attached-product__close"],icon:"bi-close",variant:"text",color:"secondary",size:"sm",square:!0,onClick:e})]})}function ZZ(){return Rx.get("/api_v1.0/flags/chat_config?parse-data=true")}function eee(){return Rx.get("/api_v1.0/flags/extensions_widget_configs?parse-data=true")}function tee(n){return Rx.get(`/api_v2.0/vendors/${n}/environments/${mn.growthbookApiKey}/safe_call_status`)}const nee=(n={})=>Gn(["feature-flags"],async()=>{const{value:e}=await ZZ();return de.camelize(e)},n),ree=(n={})=>Gn(["extensions-config"],async()=>{const{value:e}=await eee();return de.camelize(e)},n),see=(n,e={})=>Gn(["secure-call-status",n],()=>tee(n),e);var VS={exports:{}},ej;function iee(){return ej||(ej=1,function(n){(function(e,t){n.exports?n.exports=t():window.ysFixWebmDuration=t()})("fix-webm-duration",function(){var e={172351395:{name:"EBML",type:"Container"},646:{name:"EBMLVersion",type:"Uint"},759:{name:"EBMLReadVersion",type:"Uint"},754:{name:"EBMLMaxIDLength",type:"Uint"},755:{name:"EBMLMaxSizeLength",type:"Uint"},642:{name:"DocType",type:"String"},647:{name:"DocTypeVersion",type:"Uint"},645:{name:"DocTypeReadVersion",type:"Uint"},108:{name:"Void",type:"Binary"},63:{name:"CRC-32",type:"Binary"},190023271:{name:"SignatureSlot",type:"Container"},16010:{name:"SignatureAlgo",type:"Uint"},16026:{name:"SignatureHash",type:"Uint"},16037:{name:"SignaturePublicKey",type:"Binary"},16053:{name:"Signature",type:"Binary"},15963:{name:"SignatureElements",type:"Container"},15995:{name:"SignatureElementList",type:"Container"},9522:{name:"SignedElement",type:"Binary"},139690087:{name:"Segment",type:"Container"},21863284:{name:"SeekHead",type:"Container"},3515:{name:"Seek",type:"Container"},5035:{name:"SeekID",type:"Binary"},5036:{name:"SeekPosition",type:"Uint"},88713574:{name:"Info",type:"Container"},13220:{name:"SegmentUID",type:"Binary"},13188:{name:"SegmentFilename",type:"String"},1882403:{name:"PrevUID",type:"Binary"},1868715:{name:"PrevFilename",type:"String"},2013475:{name:"NextUID",type:"Binary"},1999803:{name:"NextFilename",type:"String"},1092:{name:"SegmentFamily",type:"Binary"},10532:{name:"ChapterTranslate",type:"Container"},10748:{name:"ChapterTranslateEditionUID",type:"Uint"},10687:{name:"ChapterTranslateCodec",type:"Uint"},10661:{name:"ChapterTranslateID",type:"Binary"},710577:{name:"TimecodeScale",type:"Uint"},1161:{name:"Duration",type:"Float"},1121:{name:"DateUTC",type:"Date"},15273:{name:"Title",type:"String"},3456:{name:"MuxingApp",type:"String"},5953:{name:"WritingApp",type:"String"},103:{name:"Timecode",type:"Uint"},6228:{name:"SilentTracks",type:"Container"},6359:{name:"SilentTrackNumber",type:"Uint"},39:{name:"Position",type:"Uint"},43:{name:"PrevSize",type:"Uint"},35:{name:"SimpleBlock",type:"Binary"},32:{name:"BlockGroup",type:"Container"},33:{name:"Block",type:"Binary"},34:{name:"BlockVirtual",type:"Binary"},13729:{name:"BlockAdditions",type:"Container"},38:{name:"BlockMore",type:"Container"},110:{name:"BlockAddID",type:"Uint"},37:{name:"BlockAdditional",type:"Binary"},27:{name:"BlockDuration",type:"Uint"},122:{name:"ReferencePriority",type:"Uint"},123:{name:"ReferenceBlock",type:"Int"},125:{name:"ReferenceVirtual",type:"Int"},36:{name:"CodecState",type:"Binary"},13730:{name:"DiscardPadding",type:"Int"},14:{name:"Slices",type:"Container"},104:{name:"TimeSlice",type:"Container"},76:{name:"LaceNumber",type:"Uint"},77:{name:"FrameNumber",type:"Uint"},75:{name:"BlockAdditionID",type:"Uint"},78:{name:"Delay",type:"Uint"},79:{name:"SliceDuration",type:"Uint"},72:{name:"ReferenceFrame",type:"Container"},73:{name:"ReferenceOffset",type:"Uint"},74:{name:"ReferenceTimeCode",type:"Uint"},47:{name:"EncryptedBlock",type:"Binary"},106212971:{name:"Tracks",type:"Container"},46:{name:"TrackEntry",type:"Container"},87:{name:"TrackNumber",type:"Uint"},13253:{name:"TrackUID",type:"Uint"},3:{name:"TrackType",type:"Uint"},57:{name:"FlagEnabled",type:"Uint"},8:{name:"FlagDefault",type:"Uint"},5546:{name:"FlagForced",type:"Uint"},28:{name:"FlagLacing",type:"Uint"},11751:{name:"MinCache",type:"Uint"},11768:{name:"MaxCache",type:"Uint"},254851:{name:"DefaultDuration",type:"Uint"},216698:{name:"DefaultDecodedFieldDuration",type:"Uint"},209231:{name:"TrackTimecodeScale",type:"Float"},4991:{name:"TrackOffset",type:"Int"},5614:{name:"MaxBlockAdditionID",type:"Uint"},4974:{name:"Name",type:"String"},177564:{name:"Language",type:"String"},6:{name:"CodecID",type:"String"},9122:{name:"CodecPrivate",type:"Binary"},362120:{name:"CodecName",type:"String"},13382:{name:"AttachmentLink",type:"Uint"},1742487:{name:"CodecSettings",type:"String"},1785920:{name:"CodecInfoURL",type:"String"},438848:{name:"CodecDownloadURL",type:"String"},42:{name:"CodecDecodeAll",type:"Uint"},12203:{name:"TrackOverlay",type:"Uint"},5802:{name:"CodecDelay",type:"Uint"},5819:{name:"SeekPreRoll",type:"Uint"},9764:{name:"TrackTranslate",type:"Container"},9980:{name:"TrackTranslateEditionUID",type:"Uint"},9919:{name:"TrackTranslateCodec",type:"Uint"},9893:{name:"TrackTranslateTrackID",type:"Binary"},96:{name:"Video",type:"Container"},26:{name:"FlagInterlaced",type:"Uint"},5048:{name:"StereoMode",type:"Uint"},5056:{name:"AlphaMode",type:"Uint"},5049:{name:"OldStereoMode",type:"Uint"},48:{name:"PixelWidth",type:"Uint"},58:{name:"PixelHeight",type:"Uint"},5290:{name:"PixelCropBottom",type:"Uint"},5307:{name:"PixelCropTop",type:"Uint"},5324:{name:"PixelCropLeft",type:"Uint"},5341:{name:"PixelCropRight",type:"Uint"},5296:{name:"DisplayWidth",type:"Uint"},5306:{name:"DisplayHeight",type:"Uint"},5298:{name:"DisplayUnit",type:"Uint"},5299:{name:"AspectRatioType",type:"Uint"},963876:{name:"ColourSpace",type:"Binary"},1029411:{name:"GammaValue",type:"Float"},230371:{name:"FrameRate",type:"Float"},97:{name:"Audio",type:"Container"},53:{name:"SamplingFrequency",type:"Float"},14517:{name:"OutputSamplingFrequency",type:"Float"},31:{name:"Channels",type:"Uint"},15739:{name:"ChannelPositions",type:"Binary"},8804:{name:"BitDepth",type:"Uint"},98:{name:"TrackOperation",type:"Container"},99:{name:"TrackCombinePlanes",type:"Container"},100:{name:"TrackPlane",type:"Container"},101:{name:"TrackPlaneUID",type:"Uint"},102:{name:"TrackPlaneType",type:"Uint"},105:{name:"TrackJoinBlocks",type:"Container"},109:{name:"TrackJoinUID",type:"Uint"},64:{name:"TrickTrackUID",type:"Uint"},65:{name:"TrickTrackSegmentUID",type:"Binary"},70:{name:"TrickTrackFlag",type:"Uint"},71:{name:"TrickMasterTrackUID",type:"Uint"},68:{name:"TrickMasterTrackSegmentUID",type:"Binary"},11648:{name:"ContentEncodings",type:"Container"},8768:{name:"ContentEncoding",type:"Container"},4145:{name:"ContentEncodingOrder",type:"Uint"},4146:{name:"ContentEncodingScope",type:"Uint"},4147:{name:"ContentEncodingType",type:"Uint"},4148:{name:"ContentCompression",type:"Container"},596:{name:"ContentCompAlgo",type:"Uint"},597:{name:"ContentCompSettings",type:"Binary"},4149:{name:"ContentEncryption",type:"Container"},2017:{name:"ContentEncAlgo",type:"Uint"},2018:{name:"ContentEncKeyID",type:"Binary"},2019:{name:"ContentSignature",type:"Binary"},2020:{name:"ContentSigKeyID",type:"Binary"},2021:{name:"ContentSigAlgo",type:"Uint"},2022:{name:"ContentSigHashAlgo",type:"Uint"},206814059:{name:"Cues",type:"Container"},59:{name:"CuePoint",type:"Container"},51:{name:"CueTime",type:"Uint"},55:{name:"CueTrackPositions",type:"Container"},119:{name:"CueTrack",type:"Uint"},113:{name:"CueClusterPosition",type:"Uint"},112:{name:"CueRelativePosition",type:"Uint"},50:{name:"CueDuration",type:"Uint"},4984:{name:"CueBlockNumber",type:"Uint"},106:{name:"CueCodecState",type:"Uint"},91:{name:"CueReference",type:"Container"},22:{name:"CueRefTime",type:"Uint"},23:{name:"CueRefCluster",type:"Uint"},4959:{name:"CueRefNumber",type:"Uint"},107:{name:"CueRefCodecState",type:"Uint"},155296873:{name:"Attachments",type:"Container"},8615:{name:"AttachedFile",type:"Container"},1662:{name:"FileDescription",type:"String"},1646:{name:"FileName",type:"String"},1632:{name:"FileMimeType",type:"String"},1628:{name:"FileData",type:"Binary"},1710:{name:"FileUID",type:"Uint"},1653:{name:"FileReferral",type:"Binary"},1633:{name:"FileUsedStartTime",type:"Uint"},1634:{name:"FileUsedEndTime",type:"Uint"},4433776:{name:"Chapters",type:"Container"},1465:{name:"EditionEntry",type:"Container"},1468:{name:"EditionUID",type:"Uint"},1469:{name:"EditionFlagHidden",type:"Uint"},1499:{name:"EditionFlagDefault",type:"Uint"},1501:{name:"EditionFlagOrdered",type:"Uint"},54:{name:"ChapterAtom",type:"Container"},13252:{name:"ChapterUID",type:"Uint"},5716:{name:"ChapterStringUID",type:"String"},17:{name:"ChapterTimeStart",type:"Uint"},18:{name:"ChapterTimeEnd",type:"Uint"},24:{name:"ChapterFlagHidden",type:"Uint"},1432:{name:"ChapterFlagEnabled",type:"Uint"},11879:{name:"ChapterSegmentUID",type:"Binary"},11964:{name:"ChapterSegmentEditionUID",type:"Uint"},9155:{name:"ChapterPhysicalEquiv",type:"Uint"},15:{name:"ChapterTrack",type:"Container"},9:{name:"ChapterTrackNumber",type:"Uint"},0:{name:"ChapterDisplay",type:"Container"},5:{name:"ChapString",type:"String"},892:{name:"ChapLanguage",type:"String"},894:{name:"ChapCountry",type:"String"},10564:{name:"ChapProcess",type:"Container"},10581:{name:"ChapProcessCodecID",type:"Uint"},1293:{name:"ChapProcessPrivate",type:"Binary"},10513:{name:"ChapProcessCommand",type:"Container"},10530:{name:"ChapProcessTime",type:"Uint"},10547:{name:"ChapProcessData",type:"Binary"},39109479:{name:"Tags",type:"Container"},13171:{name:"Tag",type:"Container"},9152:{name:"Targets",type:"Container"},10442:{name:"TargetTypeValue",type:"Uint"},9162:{name:"TargetType",type:"String"},9157:{name:"TagTrackUID",type:"Uint"},9161:{name:"TagEditionUID",type:"Uint"},9156:{name:"TagChapterUID",type:"Uint"},9158:{name:"TagAttachmentUID",type:"Uint"},10184:{name:"SimpleTag",type:"Container"},1443:{name:"TagName",type:"String"},1146:{name:"TagLanguage",type:"String"},1156:{name:"TagDefault",type:"Uint"},1159:{name:"TagString",type:"String"},1157:{name:"TagBinary",type:"Binary"}};function t(d,f){d.prototype=Object.create(f.prototype),d.prototype.constructor=d}function r(d,f){this.name=d||"Unknown",this.type=f||"Unknown"}r.prototype.updateBySource=function(){},r.prototype.setSource=function(d){this.source=d,this.updateBySource()},r.prototype.updateByData=function(){},r.prototype.setData=function(d){this.data=d,this.updateByData()};function s(d,f){r.call(this,d,f||"Uint")}t(s,r);function i(d){return d.length%2===1?"0"+d:d}s.prototype.updateBySource=function(){this.data="";for(var d=0;d<this.source.length;d++){var f=this.source[d].toString(16);this.data+=i(f)}},s.prototype.updateByData=function(){var d=this.data.length/2;this.source=new Uint8Array(d);for(var f=0;f<d;f++){var p=this.data.substr(f*2,2);this.source[f]=parseInt(p,16)}},s.prototype.getValue=function(){return parseInt(this.data,16)},s.prototype.setValue=function(d){this.setData(i(d.toString(16)))};function o(d,f){r.call(this,d,f||"Float")}t(o,r),o.prototype.getFloatArrayType=function(){return this.source&&this.source.length===4?Float32Array:Float64Array},o.prototype.updateBySource=function(){var d=this.source.reverse(),f=this.getFloatArrayType(),p=new f(d.buffer);this.data=p[0]},o.prototype.updateByData=function(){var d=this.getFloatArrayType(),f=new d([this.data]),p=new Uint8Array(f.buffer);this.source=p.reverse()},o.prototype.getValue=function(){return this.data},o.prototype.setValue=function(d){this.setData(d)};function a(d,f){r.call(this,d,f||"Container")}t(a,r),a.prototype.readByte=function(){return this.source[this.offset++]},a.prototype.readUint=function(){for(var d=this.readByte(),f=8-d.toString(2).length,p=d-(1<<7-f),m=0;m<f;m++)p*=256,p+=this.readByte();return p},a.prototype.updateBySource=function(){for(this.data=[],this.offset=0;this.offset<this.source.length;this.offset=p){var d=this.readUint(),f=this.readUint(),p=Math.min(this.offset+f,this.source.length),m=this.source.slice(this.offset,p),g=e[d]||{name:"Unknown",type:"Unknown"},v=r;switch(g.type){case"Container":v=a;break;case"Uint":v=s;break;case"Float":v=o;break}var y=new v(g.name,g.type);y.setSource(m),this.data.push({id:d,idHex:d.toString(16),data:y})}},a.prototype.writeUint=function(d,f){for(var p=1,m=128;d>=m&&p<8;p++,m*=128);if(!f)for(var g=m+d,v=p-1;v>=0;v--){var y=g%256;this.source[this.offset+v]=y,g=(g-y)/256}this.offset+=p},a.prototype.writeSections=function(d){this.offset=0;for(var f=0;f<this.data.length;f++){var p=this.data[f],m=p.data.source,g=m.length;this.writeUint(p.id,d),this.writeUint(g,d),d||this.source.set(m,this.offset),this.offset+=g}return this.offset},a.prototype.updateByData=function(){var d=this.writeSections("draft");this.source=new Uint8Array(d),this.writeSections()},a.prototype.getSectionById=function(d){for(var f=0;f<this.data.length;f++){var p=this.data[f];if(p.id===d)return p.data}return null};function l(d){a.call(this,"File","File"),this.setSource(d)}t(l,a),l.prototype.fixDuration=function(d,f){var p=f&&f.logger;p===void 0?p=function(b){console.log(b)}:p||(p=function(){});var m=this.getSectionById(139690087);if(!m)return p("[fix-webm-duration] Segment section is missing"),!1;var g=m.getSectionById(88713574);if(!g)return p("[fix-webm-duration] Info section is missing"),!1;var v=g.getSectionById(710577);if(!v)return p("[fix-webm-duration] TimecodeScale section is missing"),!1;var y=g.getSectionById(1161);if(y)if(y.getValue()<=0)p("[fix-webm-duration] Duration section is present, but the value is empty"),y.setValue(d);else return p("[fix-webm-duration] Duration section is present"),!1;else p("[fix-webm-duration] Duration section is missing"),y=new o("Duration","Float"),y.setValue(d),g.data.push({id:1161,data:y});return v.setValue(1e6),g.updateByData(),m.updateByData(),this.updateByData(),!0},l.prototype.toBlob=function(d){return new Blob([this.source.buffer],{type:d||"video/webm"})};function c(d,f,p,m){if(typeof p=="object"&&(m=p,p=void 0),!p)return new Promise(function(v){c(d,f,v,m)});try{var g=new FileReader;g.onloadend=function(){try{var v=new l(new Uint8Array(g.result));v.fixDuration(f,m)&&(d=v.toBlob(d.type))}catch{}p(d)},g.readAsArrayBuffer(d)}catch{p(d)}}return c.default=c,c})}(VS)),VS.exports}var oee=iee();const aee=ba(oee);function lee(){const n=At().isIOS,e=T.useRef(),t=T.useRef(),r=T.useRef([]),s=T.useRef(),i=T.useRef(),[o,a]=T.useState(!1),{timeSpent:l,start:c,reset:d}=Mt.useCountUp(Number.MAX_SAFE_INTEGER),{showErrorSnackbar:f}=Mt.useSnackbar(),p=async()=>{try{t.current=await navigator.mediaDevices.getUserMedia({audio:!0}),n?de.bsSessionStorage.setItem(xr.MICROPHONE_PERMISSION,1):de.bsLocalStorage.setItem(xr.MICROPHONE_PERMISSION,1)}catch(y){throw f("خطا در درسترسی به میکروفون"),n?de.bsSessionStorage.setItem(xr.MICROPHONE_PERMISSION,0):de.bsLocalStorage.setItem(xr.MICROPHONE_PERMISSION,0),y}},m=async()=>{const y=de.bsLocalStorage.getItem(xr.MICROPHONE_PERMISSION,0),b=de.bsSessionStorage.getItem(xr.MICROPHONE_PERMISSION,0);if(n){if(!b)return await p(),!1}else if(!y)return await p(),!1;await p();const S={mimeType:MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4"};return s.current=new MediaRecorder(t.current,S),s.current.addEventListener("dataavailable",({data:E})=>{E.size>0&&r.current.push(E)}),s.current.addEventListener("stop",()=>{const E=new Blob(r.current,{type:"audio/mp3"}),C=Date.now()-i.current;aee(E,C,R=>{e.current=new File([R],"voice.mp3",{type:"audio/mp3"})}),t.current.getTracks().forEach(R=>R.stop())}),s.current.start(100),!0},g=async()=>{var y;try{e.current=null,r.current=[],s.current=null;const b=await m();return b&&(a(!0),i.current=Date.now(),c(),(y=navigator==null?void 0:navigator.vibrate)==null||y.call(navigator,50)),b}catch(b){return console.error(b),a(!1),!1}},v=()=>{var y,b;try{(y=s.current)!=null&&y.state&&((b=s.current)==null?void 0:b.state)!=="inactive"&&s.current.stop(),a(!1),d()}catch(S){console.error(S)}};return T.useEffect(()=>{o||v()},[o]),{stop:v,time:l,file:e,start:g,isRecording:o}}function cee(){var c;const n=cS(),{contact:e,messages:t}=Tn(["contact","messages"]),{featureFlags:r}=Lt(["featureFlags"]),[s,i]=T.useState(de.bsLocalStorage.getItem(xr.READY_MESSAGE_SENT)||[]),o=(c=e==null?void 0:e.vendor)==null?void 0:c.id;return{...T.useMemo(()=>{var f,p;const d={messages:[],enable:!1};return!o||t.length===0||s.includes(o)||(f=r==null?void 0:r.cantReceiveMessage)!=null&&f.includes(e==null?void 0:e.id)?d:((p=n("test_chat_ready_messages"))==null?void 0:p.value)||d},[o,n,s,e==null?void 0:e.id,t.length,r==null?void 0:r.cantReceiveMessage]),onSendMessage:()=>{const d=[...s,o];de.bsLocalStorage.setItem(xr.READY_MESSAGE_SENT,d),i(d)}}}function uee(n){if(!n||!n.isContentEditable)throw new Error("The provided element is not contenteditable.");let e=0,t=0;const r=window.getSelection();if(r.rangeCount>0){const s=r.getRangeAt(0),i=s.cloneRange();i.selectNodeContents(n),i.setEnd(s.startContainer,s.startOffset),e=i.cloneContents().querySelectorAll("br").length,t=i.toString().length}return{chars:t,lines:e}}function dee(n,e){const t=window.getSelection(),r=document.createRange();let s=0;const i=[n];let o,a=!1;for(;!a&&(o=i.pop());)if(o.nodeType===3){const l=s+o.length;e<=l&&(r.setStart(o,e-s),r.setEnd(o,e-s),a=!0),s=l}else{let l=o.childNodes.length;for(;l--;)i.push(o.childNodes[l])}t.removeAllRanges(),t.addRange(r)}const tj=-50,nj=-100;function fee(){var kn,Fs,fi,Qt;const n=At(),{chat:e,messages:t,replyingMessage:r,editingMessage:s,selectedMessageIds:i,hasNextPage:o}=Tn(["chat","hasNextPage","replyingMessage","messages","editingMessage","selectedMessageIds"]),{currentUser:a,chatModalData:l}=Lt(["currentUser","chatModalData"]),c=T.useRef(),d=T.useRef(),f=T.useRef(),p=T.useRef(),m=T.useRef(),g=T.useRef(!1),v=T.useRef(null),{file:y,stop:b,time:S,start:E,isRecording:C}=lee(),{messages:R,enable:I,onSendMessage:A}=cee(),k=!!((kn=a==null?void 0:a.vendor)!=null&&kn.isActive),N=!!((Fs=a==null?void 0:a.vendor)!=null&&Fs.orderCount),D=(e==null?void 0:e.contact)&&a&&(e==null?void 0:e.contact.id)===a.id,[M,F]=T.useState(null),[U,$]=T.useState(!0),[q,G]=T.useState(!1),[V,z]=T.useState(!1),[B,P]=T.useState(!1),[H,Z]=T.useState(!1),[Q,J]=T.useState(!1),[ee,K]=T.useState(!1),[W,te]=T.useState(!1),[re,pe]=T.useState(null),[Ee,le]=T.useState(!1),[Ie,be]=T.useState(!1),[ge,Ae]=T.useState(!1),{emitEvent:Re}=Mt.useEmitter(),{publishEvent:tt}=Fr(),{showErrorSnackbar:et}=Mt.useSnackbar(),{setIsEditing:Oe,setIsLoadingNextMessages:ht,setChat:Xe}=ai(),{mutateAsync:Je}=xD(),{mutateAsync:qe}=Hc(),{mutateAsync:Ue}=BY(),{mutateAsync:it}=gJ(),{mutate:nt,isLoading:dt}=qc({onSuccess:()=>{Xe(fe=>({...fe,contactIsBlocked:!1})),Re(Ct.UPDATE_CHAT_LIST_BY_ID,{chatId:e==null?void 0:e.id,chatUpdate:{contactIsBlocked:!1}})}}),{addMessage:Ot,replaceMessage:xt,replyMessage:rt,editMessage:Me,editRepliedMessages:lt,getPreviousMessages:Vt,scrollToBottomVirtuoso:vn,virtuosoRef:pt}=ro(),mt=((Qt=(fi=e==null?void 0:e.replyMarkup)==null?void 0:fi.keyboard)==null?void 0:Qt.length)>0,gt=(e==null?void 0:e.chatType)===Bt.BOT&&t.length===0,Wt=Dr(),ot=()=>{var fe;return((fe=f.current)==null?void 0:fe.innerText)||""},nn=fe=>{f.current.innerHTML=fe.replace(/\n/g,"<br />"),fe.length===0&&!U&&!s&&$(!0),fe.length>0&&U&&setTimeout(()=>{$(!1)},10)},tn=fe=>{var Ve,ze,It,Yt,rn,dn,jn,$r,zr,ua,bg;if(console.error(fe),o&&((Ve=t.at(-1))!=null&&Ve.id)&&((ze=e==null?void 0:e.lastMessage)!=null&&ze.id&&e.lastMessage.id!==t.at(-1).id||e!=null&&e.searchedMessage)&&Vt({pageParam:{messageId:0,limit:20,cmp:ja.LESS_THAN}}).then(()=>{ht(!1),vn(pt)}),(rn=(Yt=(It=fe.response)==null?void 0:It.data)==null?void 0:Yt.error)!=null&&rn.messages?fe.response.data.error.messages.forEach(Xs=>{et(Xs.text)}):(jn=(dn=fe.response)==null?void 0:dn.data)!=null&&jn.errors?fe.response.data.errors.forEach(Xs=>{et(Xs.message)}):(zr=($r=fe.response)==null?void 0:$r.data)!=null&&zr.message?et(fe.response.data.message):fe.name==="AxiosError"?et("یه مشکلی پیش اومده! دوباره امتحان کن!"):et("خطا"),fe.name==="AxiosError"&&((ua=fe.config)==null?void 0:ua.baseURL)===mn.uploadioUrl){const Xs=fe.config.data,wu=Xs.get("message_uuid");xt(wu,qf=>({...qf,status:Dt.ERROR,uploadPayload:{file:Xs.get("file"),type:Xs.get("file_type")}}))}if(fe.name==="AxiosError"&&[mn.chatUrl,mn.conversation].includes((bg=fe.config)==null?void 0:bg.baseURL)){const Xs=JSON.parse(fe.config.data).uuid;Xs&&xt(Xs,wu=>({...wu,status:Dt.ERROR}))}},En=(fe,Ve=null)=>{l&&requestIdleCallback(()=>{var ze,It,Yt,rn,dn;tt("sendMessage",{entityId:Ve,messageType:fe,receiverId:(ze=e==null?void 0:e.contact)==null?void 0:ze.id,receiverIsVendor:!!((It=e==null?void 0:e.contact)!=null&&It.vendor),receiverLastActivity:(Yt=e==null?void 0:e.contact)==null?void 0:Yt.lastActivity,receiverVendorId:((dn=(rn=e==null?void 0:e.contact)==null?void 0:rn.vendor)==null?void 0:dn.id)||null})})},$n=async(fe,Ve=null)=>{try{const ze=Array.from({length:fe.length},()=>Vn()),It={isNew:!0,chatId:e==null?void 0:e.id,messageType:Fe.PRODUCT,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss")};ze.forEach((Yt,rn)=>{Ot({...It,uuid:Yt,sender:a,isManuallyAdded:!0,chatId:e.id,status:Dt.SENDING,content:{entityId:fe[rn],text:Ve}})}),await Promise.all(ze.map(async(Yt,rn)=>{const dn=await qe({...It,content:{entityId:fe[rn],text:Ve}});xt(Yt,{...dn.data,uuid:Yt,isManuallyAdded:!0,content:dn.data.content}),En(Fe.PRODUCT,fe[rn])}))}catch(ze){tn(ze)}yn()},_n=async fe=>{var Ve;try{(Ve=f.current)==null||Ve.focus(),await de.sleep(0),fe==null||fe.preventDefault();const ze=ot();if(ze.trim().length===0)return;if(l!=null&&l.attachedProductId&&!W){$n([l.attachedProductId],ze),te(!0),nn("");return}const It=Vn(),Yt=r,rn={uuid:It,isNew:!0,content:{text:ze},chatId:e==null?void 0:e.id,messageType:Fe.TEXT,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss"),...Yt&&{repliedMessageId:Yt==null?void 0:Yt.id}};Ot({...rn,sender:a,isManuallyAdded:!0,chatId:e.id,repliedMessage:r,status:Dt.SENDING}),rt(null),nn("");const dn=await qe(rn);xt(It,{...dn.data,uuid:It,isManuallyAdded:!0,repliedMessage:Yt}),En(Fe.TEXT)}catch(ze){tn(ze)}},sr=async fe=>{try{const Ve=Vn(),ze={uuid:Ve,isNew:!0,content:{text:fe},chatId:e==null?void 0:e.id,messageType:Fe.TEXT,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss")};Ot({...ze,sender:a,isManuallyAdded:!0,chatId:e.id,status:Dt.SENDING});const It=await qe(ze);xt(Ve,{...It.data,uuid:Ve,isManuallyAdded:!0}),En(Fe.TEXT)}catch(Ve){tn(Ve)}},wr=async fe=>{try{l!=null&&l.attachedProductId&&!W&&($n([l.attachedProductId]),te(!0));const Ve=Vn(),ze=r,It={uuid:Ve,isNew:!0,chatId:e==null?void 0:e.id,messageType:Fe.STICKER,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss"),attachment:{files:[{id:fe==null?void 0:fe.id,url:fe.url}]},...ze&&{repliedMessageId:ze==null?void 0:ze.id}};Ot({...It,sender:a,isManuallyAdded:!0,chatId:e.id,status:Dt.SENDING,content:{files:[{id:fe==null?void 0:fe.id,url:fe.url}]}}),rt(null);const Yt=await qe(It);xt(Ve,{...Yt.data,uuid:Ve,isManuallyAdded:!0,repliedMessage:ze}),En(Fe.STICKER,fe==null?void 0:fe.id)}catch(Ve){tn(Ve)}},ws=async()=>{var fe,Ve;try{l!=null&&l.attachedProductId&&!W&&($n([l.attachedProductId]),te(!0));const ze=Vn(),It=r,Yt={uuid:ze,isNew:!0,chatId:e==null?void 0:e.id,messageType:Fe.VOICE,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss"),...It&&{repliedMessageId:It==null?void 0:It.id}};Ot({...Yt,sender:a,isManuallyAdded:!0,chatId:e.id,status:Dt.SENDING,content:{files:[{id:Vn(),url:URL.createObjectURL(y.current)}]}}),rt(null);const rn=await Je({type:"chat.voice",file:y.current}),dn=await qe({...Yt,attachment:{files:[{id:(fe=rn.data.files[0])==null?void 0:fe.id,url:rn.data.files[0].url}]}});xt(ze,{...dn.data,uuid:ze,isManuallyAdded:!0,repliedMessage:It}),En(Fe.VOICE,(Ve=rn.data.files[0])==null?void 0:Ve.id)}catch(ze){tn(ze)}},es=async fe=>{try{l!=null&&l.attachedProductId&&!W&&($n([l.attachedProductId]),te(!0));const Ve=Array.from({length:fe.length},()=>Vn()),ze=r,It={isNew:!0,chatId:e==null?void 0:e.id,messageType:Fe.REVIEW,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss"),content:{text:"",entityId:Vn()},...ze&&{repliedMessageId:ze==null?void 0:ze.id}};Ve.forEach((Yt,rn)=>{Ot({...It,uuid:Yt,sender:a,isManuallyAdded:!0,chatId:e.id,status:Dt.SENDING,content:{text:"",entityId:fe[rn]}})}),rt(null),await Promise.all(Ve.map(async(Yt,rn)=>{const dn=fe[rn];if(!dn)return;const jn=await qe({...It,uuid:Yt,content:{text:"",entityId:dn}});xt(Yt,{...jn.data,uuid:Yt,isManuallyAdded:!0,repliedMessage:ze,content:{text:"",entityId:dn,...jn.data.content}}),En(Fe.REVIEW,dn)}))}catch(Ve){tn(Ve)}},ds=async fe=>{try{const Ve=await Promise.all(fe.map(async rn=>{const dn={topic:i7.SATISFACTION,metadata:{attachment:null,phone_number:null,tracking_code:null}};return(await it({orderId:rn,payload:dn})).id}));l!=null&&l.attachedProductId&&!W&&($n([l.attachedProductId]),te(!0));const ze=Array.from({length:fe.length},()=>Vn()),It=r,Yt={isNew:!0,chatId:e==null?void 0:e.id,messageType:Fe.AGREEMENT,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss"),content:{text:"",entityId:Vn()},...It&&{repliedMessageId:It==null?void 0:It.id}};ze.forEach((rn,dn)=>{const jn=Ve[dn];jn&&Ot({...Yt,uuid:rn,sender:a,isManuallyAdded:!0,chatId:e.id,status:Dt.SENDING,content:{text:"",entityId:jn}})}),rt(null),await Promise.all(ze.map(async(rn,dn)=>{const jn=Ve[dn];if(!jn)return;const $r=await qe({...Yt,uuid:rn,content:{text:"",entityId:jn},...dn===fe.length-1});xt(rn,{...$r.data,uuid:rn,isManuallyAdded:!0,repliedMessage:It,content:{text:"",entityId:jn,...$r.data.content}}),En(Fe.AGREEMENT,jn)}))}catch(Ve){tn(Ve)}},fs=async({files:fe,caption:Ve,mode:ze})=>{try{l!=null&&l.attachedProductId&&!W&&($n([l.attachedProductId]),te(!0));const It=Array.from({length:fe.length},()=>Vn()),Yt=r,rn={isNew:!0,messageType:ze,chatId:e==null?void 0:e.id,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss"),...Yt&&{repliedMessageId:Yt==null?void 0:Yt.id}};It.forEach((jn,$r)=>{Ot({...rn,uuid:jn,sender:a,isManuallyAdded:!0,status:Dt.SENDING,content:{files:[{id:Vn(),url:fe[$r].src}],...$r===fe.length-1&&Ve&&{text:Ve}}})}),rt(null);const dn=await Promise.all(It.map(async(jn,$r)=>{const zr=fe[$r].file,{data:ua}=await Je({file:zr,messageUUID:jn,type:ze===Fe.PICTURE?hx.CHAT_PHOTO:hx.CHAT_VIDEO});return{...ua.files[0],localUrl:URL.createObjectURL(zr)}}));await Promise.all(It.map(async(jn,$r)=>{const zr=dn[$r];if(!zr)return;const ua=await qe({...rn,attachment:{files:[zr]},...$r===fe.length-1&&Ve&&{content:{text:Ve}}});xt(jn,{...ua.data,uuid:jn,isManuallyAdded:!0,repliedMessage:Yt,content:{...ua.data.content,files:[{...zr,url:zr.localUrl,originalUrl:zr.url}]}}),En(ze,zr==null?void 0:zr.id)}))}catch(It){tn(It)}yn()},oe=async({file:fe,caption:Ve})=>{try{l!=null&&l.attachedProductId&&!W&&($n([l.attachedProductId]),te(!0));const ze=Vn(),It=r,Yt={isNew:!0,chatId:e.id,messageType:Fe.FILE,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss"),...It&&{repliedMessageId:It.id}};Ot({...Yt,uuid:ze,sender:a,isManuallyAdded:!0,chatId:e.id,status:Dt.SENDING,content:{files:[{id:Vn(),url:fe.src,name:fe.name,size:fe.size,type:fe.type}],...Ve&&{text:Ve}}}),rt(null);const{data:rn}=await Je({file:fe.file,messageUUID:ze,type:hx.CHAT_FILE}),dn=await qe({...Yt,...Ve&&{content:{text:Ve}},attachment:{files:[{size:fe.size,type:fe.type,name:fe.name,id:rn.files[0].id,url:rn.files[0].url}]}});xt(ze,{...dn.data,uuid:ze,isManuallyAdded:!0,repliedMessage:It,content:{...dn.data.content,files:[{id:Vn(),url:fe.src,name:fe.name,size:fe.size,type:fe.type}]}}),En(Fe.FILE,rn.files[0].id)}catch(ze){tn(ze)}yn()},ce=async()=>{const fe=ot(),Ve=s;if(!(fe.trim().length===0||!Ve))try{const ze={...Ve,content:{...Ve.content,text:fe}};xt(Ve.id,{...ze,status:Dt.SENDING});const It=await Ue({content:{text:fe},messageId:Ve.id});Me(null),xt(Ve.id,It==null?void 0:It.data),lt(Ve.id,fe)}catch(ze){xt(Ve.id,Ve),tn(ze)}finally{Oe(!1)}},_e=fe=>{fe.key==="Enter"&&!fe.shiftKey&&n.isPc&&(fe.preventDefault(),s?ce():_n())},ie=()=>{const fe=ot();(fe.length===0||fe.length===1&&fe.charCodeAt(0)===10)&&!U&&!s?$(!0):U&&$(!1)},xe=async fe=>{try{const Ve=[...fe];Ve.every(ze=>ze.type.startsWith("image"))?(bD(Ve),F(Ve),Z(!0)):Ve.length===1&&Ve[0].type==="video/mp4"?(await IS(fe[0]),F(Ve),Z(!0)):et("فایل‌ انتخابی باید چند عکس یا یک ویدئو باشد")}catch(Ve){et(Ve.message)}},Le=fe=>{fe.clipboardData.files.length===0||(fe.preventDefault(),xe(fe.clipboardData.files))},Be=T.useCallback(fe=>{var Ve;fe.target!==c.current&&!c.current.contains(fe.target)&&(Ie&&be(!1),setTimeout(()=>{J(!1)},0),(Ve=f.current)==null||Ve.blur())},[f,Ie]),Se=T.useCallback(fe=>{const Ve=ot(),{chars:ze,lines:It}=uee(f.current),Yt=ze+It,rn=Ve.slice(0,Math.max(0,Yt)),dn=Ve.substring(Yt,Ve.length),jn=fe.detail.unicode;nn(rn+jn+dn),dee(f.current,ze+jn.length)},[]),ct=()=>{setTimeout(()=>{b(),le(!1),z(!1)},0),S.seconds>1&&setTimeout(ws,400)},at=()=>{setTimeout(()=>{b(),z(!1),le(!1)},0)},ut=async()=>{g.current=!0,!Ee&&(v.current&&clearTimeout(v.current),v.current=setTimeout(async()=>{be(!1),g.current&&await E()&&z(!0)},500),document.addEventListener("touchend",Ft))},St=()=>{var fe,Ve;g.current=!1,be(!1),v.current&&(clearTimeout(v.current),v.current=null),!Ee&&(pe(null),p.current.style.left.replace("px","")<=nj?(at(),(fe=navigator==null?void 0:navigator.vibrate)==null||fe.call(navigator,50)):p.current.style.top.replace("px","")<=tj?(le(!0),(Ve=navigator==null?void 0:navigator.vibrate)==null||Ve.call(navigator,50),setTimeout(()=>z(!1),800)):C&&ct(),p.current.style.top=0,p.current.style.left=0,p.current.style.opacity=1,p.current.style.transform="scale(1)",document.removeEventListener("touchend",Ft))},ft=fe=>{if(Ee||!C)return;const Ve=p.current.getBoundingClientRect(),ze={y:fe.touches[0].clientY-Ve.top,x:fe.touches[0].clientX-Ve.left},It=tj-50,Yt=nj-50;if(ze.x<=0&&ze.x>Yt&&re!=="VERTICAL"){pe("HORIZONTAL"),p.current.style.left=`${ze.x}px`;const rn=.7,dn=1-ze.x*-1/(Yt*-1);dn>rn&&(p.current.style.transform=`scale(${dn})`,p.current.style.opacity=dn),ze.x>-20&&pe(null)}ze.y<=0&&ze.y>It&&re!=="HORIZONTAL"&&(pe("VERTICAL"),p.current.style.top=`${ze.y}px`,ze.y>-20&&pe(null))},De=async()=>{n.isMobile&&be(!0),Ee?ct():n.isPc?await E()&&le(!0):at()},se=()=>{setTimeout(()=>{te(!0)},0)},Pe=()=>{setTimeout(()=>{G(!0)},0)},We=()=>{setTimeout(()=>{Q?J(!1):(K(!1),J(!0))},0)},an=()=>{setTimeout(()=>{ee?K(!1):(J(!1),K(!0))},0)},yn=()=>{setTimeout(()=>{G(!1)},0)},Ft=()=>{g.current&&St()},zn=async()=>{Z(!1),await de.sleep(250),F(null)},wn=()=>{requestIdleCallback(()=>{var fe;tt("chatFormBotStartButtonClick",{contactId:(fe=e==null?void 0:e.contact)==null?void 0:fe.id})}),sr("/start")},{data:Wn}=ree();return T.useEffect(()=>(document.addEventListener("click",Be),()=>document.removeEventListener("click",Be)),[Be]),T.useEffect(()=>{const fe=lS();(fe==null?void 0:fe.length)>0?nn(fe):nn(""),n.isPc&&setTimeout(()=>{var Ve;(Ve=f.current)==null||Ve.focus()},10),te(!1)},[e==null?void 0:e.id]),T.useEffect(()=>()=>{document.removeEventListener("touchend",Ft),v.current&&clearTimeout(v.current)},[]),T.useEffect(()=>{s?($(!1),P(!0)):($(!0),setTimeout(()=>P(!1),200))},[s]),T.useEffect(()=>{i.size>0?Ae(!0):setTimeout(()=>{Ae(!1)},400)},[i]),T.useEffect(()=>{const fe=()=>{document.visibilityState==="visible"&&f.current&&n.isPc&&f.current.focus()};return document.addEventListener("visibilitychange",fe),()=>{document.removeEventListener("visibilitychange",fe)}},[]),_.jsxs("div",{ref:c,className:Kt["form-container"],children:[I&&_.jsx(xJ,{messages:R,onSend:A}),_.jsx(JZ,{className:Te(Kt["form__attached-product"],{[Kt["form__attached-product--show"]]:(l==null?void 0:l.attachedProductId)&&!W}),onClose:se}),_.jsx(lQ,{className:Te(Kt.form__reply,{[Kt["form__reply--show"]]:!!r})}),_.jsx(HQ,{className:Te(Kt.form__edit,{[Kt["form__edit--show"]]:!!s})}),_.jsxs("div",{className:Kt.form,children:[_.jsx(Mr,{mounted:V,duration:350,transition:"fade",children:fe=>_.jsxs("div",{className:Kt["form__lock-voice"],style:fe,children:[_.jsx("i",{className:Te(Kt["form__lock-voice-icon"],Ee?"bi-lock":"bi-unlock",{[Kt["form__lock-voice-icon--lock"]]:Ee})}),_.jsx("i",{className:"bi-angle-up"})]})}),_.jsx(cQ,{}),_.jsxs("div",{className:Te(Kt.form__body,{[Kt["form__body--show-send"]]:!U},{[Kt["form__body--deleted"]]:ge}),children:[_.jsxs("div",{className:Kt["form__body-actions"],style:{width:`${U?mt?104:56:24}px`},children:[B?_.jsx("button",{"aria-label":"ویرایش",className:Te(Kt["form__body-actions-send"],{[Kt["form__body-actions-send--show"]]:!U}),onClick:ce,children:_.jsx("i",{className:"bi-tick-single"})}):_.jsx("button",{"aria-label":"ارسال",className:Te(Kt["form__body-actions-send"],{[Kt["form__body-actions-send--show"]]:!U}),onClick:_n,children:_.jsx("i",{className:"bi-send-right-fill"})}),_.jsxs("div",{className:Te(Kt["form__body-actions-voice-attachments"],{[Kt["form__body-actions-voice-attachments--show"]]:U}),children:[_.jsx(Cd,{show:Ie,label:"برای ضبط صدا نگه دارید",placement:"top",children:!Wt&&_.jsxs("button",{ref:p,className:Te(Kt["form__body-actions-voice"],{[Kt["form__body-actions-voice--show"]]:U,[Kt["form__body-actions-voice--recording"]]:C}),onClick:De,onTouchMove:ft,onTouchEnd:St,onTouchStart:ut,children:[_.jsx("div",{className:Kt["form__body-actions-voice-wave-wrapper"],children:_.jsx("div",{className:Te(Kt["form__body-actions-voice-wave"],{[Kt["form__body-actions-voice-wave--show"]]:C})})}),Ee?_.jsx("i",{className:"bi-send-right"}):_.jsx("div",{className:Te(Kt["form__body-actions-voice-icon-wrapper"],{[Kt["form__body-actions-voice-icon-wrapper--show"]]:U}),children:_.jsx("i",{className:"bi-microphone"})})]})}),_.jsx("button",{ref:m,"aria-label":"الحاق",className:Te(Kt["form__body-attachments-external"]),onClick:Pe,children:_.jsx("i",{className:"bi-link"})}),mt&&_.jsx("button",{"aria-label":"صفحه‌کلید ربات",className:Te(Kt["form__body-bot-keyboard"]),onClick:an,children:_.jsx("i",{className:ee?"bi-angle-up":"bi-buttons"})})]})]}),_.jsx(Mr,{mounted:!C,duration:350,transition:"fade",children:fe=>_.jsxs(_.Fragment,{children:[_.jsxs("form",{style:fe,ref:d,className:Te(Kt["form__body-form"],{[Kt["form__body-form--ios"]]:n.isIOS}),onSubmit:_n,children:[U&&_.jsx("span",{className:Kt["form__body-form-input-placeholder"],children:"متن پیام"}),_.jsx("span",{"aria-label":"متن پیام",ref:f,contentEditable:!0,id:"chat-message-form-input",className:Te(Kt["form__body-form-input"],{[Kt["form__body-form-input--ios"]]:n.isIOS}),onPaste:Le,onInput:ie,onKeyDown:_e,onFocus:()=>!n.isPc&&J(!1)})]}),_.jsx("button",{"aria-label":"ایموجی",className:Te(Kt["form__body-attachments-external"],{[Kt["form__body-attachments-external--hidden"]]:C}),onClick:We,children:_.jsx("i",{className:Q?"bi-keyboard":"bi-emoji"})}),_.jsx(Mr,{mounted:!mt&&k&&N&&!s&&U&&!D,duration:150,transition:"fade",children:Ve=>_.jsx("div",{style:Ve,children:_.jsx(bJ,{utmMedium:"referral",utmCampaign:"chat",widgetCategory:"chatbot",ids:Wn==null?void 0:Wn.chatExtensionsIds,onSendReviewRequest:es,onSendSatisfactionRequest:ds})})})]})}),_.jsx(Mr,{mounted:C&&Ee,duration:350,transition:"fade",children:fe=>_.jsx("div",{className:Kt["form__body-voice-cancel-btn"],style:fe,children:_.jsx(Qe,{label:"لغو",variant:"text",size:"xs",onClick:at})})}),_.jsx(Mr,{mounted:C,duration:350,transition:"fade",children:fe=>_.jsxs("div",{className:Kt["form__body-voice-timer"],style:fe,children:[_.jsxs("div",{className:Kt["form__body-voice-timer-time"],children:[_.jsx("span",{children:S.formattedMinutes}),":",_.jsx("span",{children:S.formattedSeconds})]}),_.jsx("span",{className:Kt["form__body-voice-timer-bullet"]})]})})]}),_.jsx(Mr,{mounted:C&&!Ee,duration:350,transition:"fade",children:fe=>_.jsx("div",{className:Kt["form__voice-cancel"],style:fe,children:_.jsxs("span",{className:Kt["form__voice-cancel-text"],children:["برای لغو کردن به سمت چپ بکشید ",_.jsx("i",{className:"bi-angle-left"})]})})}),_.jsx(Mr,{mounted:!!(e!=null&&e.contactIsBlocked),duration:350,transition:"fade",children:fe=>_.jsx("div",{style:fe,className:Kt.form__blocked,onClick:()=>nt({status:Fc.UNBLOCK,payload:{chatIds:[e==null?void 0:e.id]}}),children:dt||!(e!=null&&e.contactIsBlocked)?_.jsx(Cr,{size:"sm",variant:"ellipsis"}):_.jsx("span",{className:Kt["form__blocked-text"],children:"رفع مسدودیت"})})}),_.jsx(Mr,{mounted:gt,duration:350,transition:"fade",children:fe=>_.jsx("div",{style:fe,className:Kt.form__blocked,onClick:wn,children:_.jsx("span",{className:Kt["form__blocked-text"],children:"شروع"})})})]}),_.jsx(QZ,{className:Te(Kt["form__glyph-picker"],{[Kt["form__glyph-picker--show"]]:Q}),onSelectSticker:wr,onSelectEmoji:Se}),mt&&_.jsx(GQ,{show:ee,onButtonClick:sr}),_.jsx(zQ,{show:q,anchorEl:m.current,mode:n.isMobile&&!n.isForceMobile?"modal":"popover",onSendFile:oe,onSendMedia:fs,onClose:yn,onSendProducts:$n}),_.jsx(qQ,{onSendMedia:fs}),_.jsx(wS,{media:M,show:H,defaultCaption:M&&ot(),onSend:fs,onClose:zn})]})}const Ns={"chat-area-header":"_chat-area-header_1db8y_6","chat-area-header__back":"_chat-area-header__back_1db8y_15","chat-area-header__contact":"_chat-area-header__contact_1db8y_21","chat-area-header__saved-message__avatar":"_chat-area-header__saved-message__avatar_1db8y_35","chat-area-header__avatar":"_chat-area-header__avatar_1db8y_44","chat-area-header__info":"_chat-area-header__info_1db8y_47","chat-area-header__info-name":"_chat-area-header__info-name_1db8y_55","chat-area-header__info-name-official":"_chat-area-header__info-name-official_1db8y_73","chat-area-header__info-activity":"_chat-area-header__info-activity_1db8y_87","chat-area-header__vendor-placeholder":"_chat-area-header__vendor-placeholder_1db8y_98","chat-area-header__vendor":"_chat-area-header__vendor_1db8y_98","chat-area-header__call":"_chat-area-header__call_1db8y_108","chat-area-header__menu":"_chat-area-header__menu_1db8y_111","chat-area-header__contact--vendor":"_chat-area-header__contact--vendor_1db8y_31"},rj={"chat-area-skeleton":"_chat-area-skeleton_wccpd_6","chat-area-skeleton--show":"_chat-area-skeleton--show_wccpd_16"};function sj({show:n,className:e,radius:t=4,width:r="100%",height:s="100%"}){const[i,o]=T.useState(!0);return T.useEffect(()=>{n?o(!0):setTimeout(()=>{o(!1)},500)},[n]),i?_.jsx(vt,{width:r,height:s,radius:t,className:Te(e,rj["chat-area-skeleton"],{[rj["chat-area-skeleton--show"]]:n})}):null}const pm={modal__image:"_modal__image_10y8f_6",modal__title:"_modal__title_10y8f_12",modal__description:"_modal__description_10y8f_19",modal__hint:"_modal__hint_10y8f_25"},hee={BAD_TIME_TO_CALL:{title:"غرفه‌دار در دسترس نیست",description:"غرفه‌دار فقط بین ساعت 10 تا 21 در دسترسه و الان نمی‌تونه به تماست پاسخ بده.",icon:"https://statics.basalam.com/public-128/admin/67gZL/09-13/qibJi4bz65zvqgiT7NLuBjked5D3XXhcluMw5nx494WNDf6a8v.SVG"},FAILED_TO_CALL:{title:"تماس امن دسترس نیست",description:"به دلایل فنی تماس امن در حال حاضر در دسترس نیست. لطفا چند دقیقه دیگه دوباره تلاش کن",icon:"https://statics.basalam.com/public-128/admin/67gZL/09-13/qibJi4bz65zvqgiT7NLuBjked5D3XXhcluMw5nx494WNDf6a8v.SVG"},SUCCESS:{title:"تماس با غرفه‌دار",icon:"https://statics.basalam.com/public-128/admin/67gZL/09-13/wkT8COSDmjIbsUXkpWdeOlGjzcFbxr0yqsgD5IEZ2bpIm8sFsY.SVG",description:"با تماس باسلامی می‌تونی بدون این‌که شماره‌ت نشون داده بشه، راحت‌تر و سریع‌تر با غرفه‌دار صحبت کنی."},VENDOR_IS_BUSY:{title:"غرفه‌دار در حال مکالمه‌ست",description:"غرفه‌دار الان داره با یه مشتری دیگه صحبت می‌کنه. چند دقیقه دیگه دوباره باهاش تماس بگیر.",icon:"https://statics.basalam.com/public-128/admin/67gZL/09-13/frSarZzviJCCtbt663mmjBqoSLNR5kIVsDIjx2qq9FlVWsfCFD.SVG"},CHANNEL_CAPACITY_IS_FULL:{title:"تماس امن دسترس نیست",description:"به دلایل فنی تماس امن در حال حاضر در دسترس نیست. لطفا چند دقیقه دیگه دوباره تلاش کن",icon:"https://statics.basalam.com/public-128/admin/67gZL/09-13/qibJi4bz65zvqgiT7NLuBjked5D3XXhcluMw5nx494WNDf6a8v.SVG"}};function pee({state:n,onClose:e,vendorId:t}){const{publishEvent:r}=Fr(),s=n.error||"SUCCESS",i=hee[s],o=()=>{requestIdleCallback(()=>{r("chatSecureCallNumberClick",{vendorId:t})}),e()};return _.jsx(lr,{show:!0,showHeader:!0,onClose:e,primaryButton:n.callNumber?_.jsx(Qe,{size:"sm",fullWidth:!0,label:"برقراری تماس باسلامی",component:"a",onClick:o,href:`tel://${n.callNumber}`}):_.jsx(Qe,{fullWidth:!0,variant:"outline",label:"بستن",onClick:e}),children:_.jsxs(je,{display:"flex",flexDirection:"column",alignItems:"center",children:[_.jsx(mM,{className:pm.modal__image,src:i.icon}),_.jsx("div",{className:pm.modal__title,children:i.title}),_.jsx("div",{className:pm.modal__description,children:i.description}),!!n.callNumber&&_.jsx("div",{className:pm.modal__hint,children:"با سیم‌کارتی تماس بگیر که باهاش تو باسلام ثبت‌نام کردی"})]})})}const Zc={jcm__info:"_jcm__info_1suxx_6","jcm__info-title":"_jcm__info-title_1suxx_13","jcm__info-members":"_jcm__info-members_1suxx_18","jcm__info-description":"_jcm__info-description_1suxx_22",jcm__footer:"_jcm__footer_1suxx_26","jcm__footer-btn":"_jcm__footer-btn_1suxx_31"};function mee({show:n,onClose:e}){var r;const{contact:t}=Tn(["contact"]);return _.jsxs(lr,{className:"dataset-inp-ChannelInfoModal",show:n,size:"sm",onClose:e,children:[_.jsxs("div",{className:Zc.jcm__info,children:[_.jsx(zs,{src:(r=t.avatar)==null?void 0:r.medium,size:"64"}),_.jsx("span",{className:Zc["jcm__info-title"],children:t.name}),!!t.membersCount&&_.jsxs("span",{className:Zc["jcm__info-members"],children:[t.membersCount," عضو"]}),_.jsx("p",{className:Zc["jcm__info-description"],children:t.description})]}),_.jsx("div",{className:Zc.jcm__footer,children:_.jsx(Qe,{className:Zc["jcm__footer-btn"],variant:"outline",label:"بستن",onClick:e})})]})}const gee=(n={},e={})=>Gn([`user-activity-${n.userId}`],()=>eQ(n),e);function ij({noOptionMenu:n=!1}){var ee,K,W,te,re,pe,Ee,le,Ie,be;const{chat:e,contact:t}=Tn(["chat","contact"]),{closeChat:r}=Wc(),{setChat:s}=ai(),{publishEvent:i}=Fr(),o=Dr(),{currentUser:a,featureFlags:l}=Lt(["currentUser","featureFlags"]),c=(ee=l==null?void 0:l.features)==null?void 0:ee.blockContact,d=At(),{data:f}=see((K=t==null?void 0:t.vendor)==null?void 0:K.id,{enabled:!d.isPc&&!!((W=t==null?void 0:t.vendor)!=null&&W.id)&&t.vendor.status===n7.ACTIVE}),p=f==null?void 0:f.result,m=o?`${mn.baseUrl}/${(te=t.vendor)==null?void 0:te.identifier}`:`/${(re=t.vendor)==null?void 0:re.identifier}`,[g,v]=T.useState(!1),[y,b]=T.useState(!1),[S,E]=T.useState(null),[C,R]=T.useState(!1),[I,A]=T.useState(!1),k=!y&&((pe=t.avatar)==null?void 0:pe.small),N=t&&a&&t.id===a.id,D=T.useRef(),{data:M,isLoading:F}=gee({userId:t.id,onlyMaxActionTime:!0},{enabled:(e==null?void 0:e.chatType)===Bt.PRIVATE&&!!t.id}),{mutate:U,isLoading:$}=HY({onError:to,onSuccess:ge=>{E(ge),requestIdleCallback(()=>{var Ae;i("chatSecureCallRequest",{errorMessage:ge.error,vendorId:(Ae=t==null?void 0:t.vendor)==null?void 0:Ae.id})})}}),q=()=>{v(!1),U({chatId:e==null?void 0:e.id,receiverUserId:t==null?void 0:t.id})};T.useEffect(()=>{p&&(requestIdleCallback(()=>{var ge;i("chatSecureCallIconView",{vendorId:(ge=t==null?void 0:t.vendor)==null?void 0:ge.id})}),de.bsLocalStorage.getItem(xr.SECURE_CALL_TOOLTIP)||(v(!0),de.bsLocalStorage.setItem(xr.SECURE_CALL_TOOLTIP,"true"),setTimeout(()=>{v(!1)},5e3)))},[p]);const G=T.useMemo(()=>ad((M==null?void 0:M.lastActivity)||t.lastActivity),[M,t.lastActivity]),V=T.useMemo(()=>w8((M==null?void 0:M.lastActivity)||t.lastActivity),[M,t.lastActivity]),z=(e==null?void 0:e.chatType)===Bt.PRIVATE?wa:"div",B=()=>{[Bt.BOT,Bt.CHANNEL].includes(e==null?void 0:e.chatType)&&A(!0)},P=()=>{setTimeout(()=>{o?r():window.history.back()},0)},H=()=>{setTimeout(()=>{R(!1)},0)},Z=()=>{setTimeout(()=>{R(!0)},0)},Q=()=>{s(ge=>({...ge,contactIsBlocked:!0}))},J=()=>{requestIdleCallback(()=>{var ge;i("chatVendorIconClick",{vendorId:(ge=t==null?void 0:t.vendor)==null?void 0:ge.id})})};return _.jsxs("div",{className:Ns["chat-area-header"],children:[!d.isPc&&_.jsx(Qe,{className:Ns["chat-area-header__back"],icon:"bi-right",size:"xxs",color:"secondary",variant:"text",square:!0,onClick:P}),_.jsx(z,{className:Te(Ns["chat-area-header__contact"],{[Ns["chat-area-header__contact--vendor"]]:(Ee=t==null?void 0:t.vendor)==null?void 0:Ee.id}),to:GP(t),onClick:B,children:_.jsxs(je,{display:"flex",alignItems:"center",children:[N?_.jsx("div",{className:Ns["chat-area-header__saved-message__avatar"],children:_.jsx(Mn,{name:"bi-saved-message-fill",color:"white"})}):_.jsxs("div",{className:Ns["chat-area-header__avatar"],children:[_.jsx(zs,{src:(le=t.avatar)==null?void 0:le.small,size:"40",status:k?"offline":G,onLoad:()=>b(!0)}),_.jsx(sj,{show:k,radius:"50%"})]}),_.jsxs("div",{className:Ns["chat-area-header__info"],children:[_.jsxs("div",{className:Ns["chat-area-header__info-name"],children:[(e==null?void 0:e.chatType)===Bt.CHANNEL&&_.jsx("i",{className:"bi-megaphone-fill"}),_.jsx("span",{children:N?"پیام های ذخیره شده":t.name}),!t.name&&_.jsx(vt,{width:175,height:24}),!!t.badge&&!N&&_.jsx(je,{mr:8,display:"flex",alignItems:"center",children:_.jsx(Xo,{label:t.badge,size:"sm",color:"black"})}),!!t.verified&&_.jsx("i",{className:Te("bi-tick-single",Ns["chat-area-header__info-name-official"])})]}),(e==null?void 0:e.chatType)===Bt.PRIVATE&&!N&&_.jsxs("div",{className:Ns["chat-area-header__info-activity"],children:[_.jsx("span",{children:V}),_.jsx(sj,{show:F,width:"132px"})]}),(e==null?void 0:e.chatType)===Bt.BOT&&_.jsx("div",{className:Ns["chat-area-header__info-activity"],children:_.jsx("span",{children:"ربات"})})]})]})}),_.jsxs("div",{className:Ns["chat-area-header__vendor-placeholder"],children:[p&&_.jsx(Cd,{size:"sm",show:g,label:"می‌تونی با غرفه‌دار تماس امن بگیری",children:_.jsx(Qe,{variant:"plain",icon:"bi-phone",color:"secondary",onClick:q,loading:$,className:Ns["chat-area-header__call"]})}),!!((Ie=t==null?void 0:t.vendor)!=null&&Ie.id)&&_.jsx(wa,{to:m,className:Ns["chat-area-header__vendor"],onClick:J,children:_.jsx(Mn,{name:"bi-vendor",color:"var(--gray-800)"})})]}),!n&&_.jsx("div",{ref:D,className:Ns["chat-area-header__menu"],children:_.jsx(Qe,{icon:"bi-more-v",size:"xs",color:"secondary",variant:"plain",onClick:Z})}),!n&&_.jsx(uP,{chat:e,contact:t,show:C,mode:d.isMobile&&!d.isForceMobile?"modal":"popover",anchorEl:D.current,options:{rules:!0,report:!0,delete:!1,block:c},onBlock:Q,onClose:H}),_.jsx(mee,{show:I,onClose:()=>A(!1)}),S&&_.jsx(pee,{state:S,onClose:()=>E(null),vendorId:(be=t==null?void 0:t.vendor)==null?void 0:be.id})]})}const oj={"chat-area-messages-container":"_chat-area-messages-container_l8x39_6","chat-area-messages-container--ios":"_chat-area-messages-container--ios_l8x39_12"},aj={"hint-box":"_hint-box_ulpuw_6","hint-box__list-container":"_hint-box__list-container_ulpuw_28"};function _ee(){const{featureFlags:n}=Lt(["featureFlags"]),e=n==null?void 0:n.newHintBox,t=i=>_.jsx(wa,{to:i.href,children:i.text}),r=i=>_.jsx(Qe,{component:i.component,underlined:i.underlined,color:i.color,size:i.size,variant:i.variant,href:i.href,target:i.target,children:i.text}),s=i=>{var a;const o=i.text.split(" ");return(a=i.metadatas)==null||a.forEach(l=>{if(l.position!==0){const c=l.position-1;switch(l.type){case"link":{o.splice(c,0,t(l));break}case"button":{o.splice(c,0,r(l));break}}}}),o};return _.jsx("div",{className:aj["hint-box"],children:_.jsx("ul",{className:aj["hint-box__list-container"],children:e.map((i,o)=>_.jsx("li",{children:s(i).map((a,l)=>_.jsxs(T.Fragment,{children:[a," "]},l))},o))})})}const vee={"date-label":"_date-label_rcucs_6"};function lj({date:n}){const e=T.useMemo(()=>{const t=de.jalaliDate(),r=de.jalaliDate(n),s=t.format("YYYY")===r.format("YYYY"),i=t.startOf("day").diff(r.startOf("day"),"day");return i===0?"امروز":i===1?"دیروز":s?de.jalaliDate(n).format("D MMMM"):de.jalaliDate(n).format("D MMMM YYYY")},[n]);return _.jsx("div",{className:vee["date-label"],children:e})}const mm={"chat-area-messages":"_chat-area-messages_4rlr3_6","chat-area-messages--lock-scroll":"_chat-area-messages--lock-scroll_4rlr3_56","chat-area-messages__unReadMessages":"_chat-area-messages__unReadMessages_4rlr3_65"},gm={"scroll-to-down":"_scroll-to-down_hx4z3_6","scroll-to-down--show":"_scroll-to-down--show_hx4z3_27","scroll-to-down__unseen":"_scroll-to-down__unseen_hx4z3_31","scroll-to-down__unseen--countless":"_scroll-to-down__unseen--countless_hx4z3_44"};function yee({count:n,onClick:e,scrollerRef:t,countless:r=!1,shouldShowWhenScrollDown:s=!1}){const[i,o]=T.useState(s),a=T.useRef(s),l=T.useRef(0),c=T.useRef(null),d=T.useRef(s),f=T.useCallback(()=>{c.current&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{const m=t.current.offsetHeight,v=t.current.scrollHeight-m-m,y=t.current.scrollTop;let b;!d.current&&y>v?b=!1:y>l.current?b=!0:b=!1,l.current=y,b!==a.current&&(a.current=b,o(b))})},[]),p=T.useCallback(()=>{T.startTransition(()=>e())},[e]);return T.useEffect(()=>{d.current=s,a.current!==s&&(a.current=s,o(s))},[s]),T.useEffect(()=>(t.current&&t.current.addEventListener("scroll",f,{passive:!0}),()=>{c.current&&cancelAnimationFrame(c.current),t.current&&t.current.removeEventListener("scroll",f)}),[t,f]),_.jsxs("button",{className:Te(gm["scroll-to-down"],{[gm["scroll-to-down--show"]]:i}),onClick:p,children:[n>0&&_.jsx("span",{className:Te(gm["scroll-to-down__unseen"],{[gm["scroll-to-down__unseen--countless"]]:r}),children:r?"":n}),_.jsx("i",{className:"bi-angle-down"})]})}const cj=T.memo(yee),WS={"messages-skeleton":"_messages-skeleton_g3h7v_6","fade-in":"_fade-in_g3h7v_1","messages-skeleton__message":"_messages-skeleton__message_g3h7v_19","messages-skeleton__message--sender":"_messages-skeleton__message--sender_g3h7v_29","messages-skeleton__message--receiver":"_messages-skeleton__message--receiver_g3h7v_32","chat-widget-mobile":"_chat-widget-mobile_g3h7v_1"};function bee(){const n=[{type:"receiver",height:60,width:12},{type:"receiver",height:48,width:38},{type:"sender",height:72,width:20},{type:"sender",height:56,width:12},{type:"receiver",height:84,width:25},{type:"sender",height:64,width:18},{type:"receiver",height:52,width:40},{type:"sender",height:68,width:50}],t=At().isMobile;return _.jsx("div",{className:WS["messages-skeleton"],children:n.map((r,s)=>_.jsx("div",{style:{width:"100%"},children:_.jsx(je,{display:"flex",justifyContent:r.type==="sender"?"flex-start":"flex-end",children:_.jsx("div",{className:`${WS["messages-skeleton__message"]} ${WS[`messages-skeleton__message--${r.type}`]}`,style:{width:`${t?r.width+20:r.width}%`},children:_.jsx(vt,{width:"100%",height:r.height,radius:"8px",waveColor:r.type==="sender"?"var(--primary-200)":"var(--gray-100)",backgroundColor:r.type==="sender"?"var(--primary-100)":"white"})})})},s))})}const KS={"message-text":"_message-text_12kfn_6","message-text__link":"_message-text__link_12kfn_13"};function xee({message:n}){const e=n.messageType===Fe.CALL?"":n.content.text,{chat:t}=Tn(["chat"]),{currentUser:r}=Lt(["currentUser"]),{replaceMessage:s,addMessage:i}=ro(),{mutateAsync:o}=Hc(),a=T.useMemo(()=>{var f;return((f=n.content.links)==null?void 0:f.filter(p=>p.isBasalamLink))||[]},[n]),l=T.useMemo(()=>{if(!e)return[];const f=a.map(g=>g.url);if(f.length===0)return[{type:"text",text:e}];const p=[];let m=e;return f.forEach(g=>{const v=m.indexOf(g);v!==-1&&(v>0&&p.push({type:"text",text:m.slice(0,Math.max(0,v))}),p.push({text:g,type:"link",url:g.startsWith("http")?g:`https://${g}`}),m=m.slice(Math.max(0,v+g.length)))}),m&&p.push({type:"text",text:m}),p},[e,a]),c=T.useCallback(f=>f.type==="link"&&f.text.startsWith("/")&&(t==null?void 0:t.chatType)===Bt.BOT,[t]),d=T.useCallback(async f=>{if(!c(f))return;const p=Vn();try{const m={uuid:p,isNew:!0,chatId:t==null?void 0:t.id,content:{text:f.text},messageType:Fe.TEXT};i({...m,chatId:t.id,sender:r,isManuallyAdded:!0,status:Dt.SENDING});const g=await o(m);s(p,{...g.data,uuid:p,isManuallyAdded:!0})}catch{s(p,m=>({...m,status:Dt.ERROR}))}},[i,t.id,r,o,s,c]);return _.jsx("p",{className:KS["message-text"],children:l.map((f,p)=>f.type==="link"&&!f.text.startsWith("/")?_.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:KS["message-text__link"],children:f.text},p):_.jsx("span",{onClick:()=>d(f),className:Te({[KS["message-text__link"]]:c(f)}),children:f.text},p))})}const Lo={"message-user":"_message-user_tq40e_6","message-user__container":"_message-user__container_tq40e_17","message-user__title":"_message-user__title_tq40e_26","message-user__follower":"_message-user__follower_tq40e_35","message-user__follower-count":"_message-user__follower-count_tq40e_45","message-user__following":"_message-user__following_tq40e_48"};function See(){return _.jsx("div",{className:Lo["message-user"],children:_.jsxs("div",{className:Lo["message-user__container"],children:[_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[_.jsx(vt,{width:40,height:40,radius:"50%"}),_.jsx(vt,{width:120,height:At().isPc?24:21,className:Lo["message-user__title"]})]}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",mt:16,children:[_.jsx(vt,{width:90,height:18}),_.jsx(je,{mr:16,children:_.jsx(vt,{width:90,height:18})})]})]})})}function Eee({message:n}){var r;const e={};e.userId=(r=n.content)==null?void 0:r.entityId;const{data:t}=jQ(e,{enabled:!!e.userId});return t?_.jsx(wa,{className:Lo["message-user"],to:GP(t),children:_.jsx("div",{children:_.jsxs("div",{className:Lo["message-user__container"],children:[_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[_.jsx(zs,{size:"40",src:t.avatar&&t.avatar.small}),_.jsx("span",{className:Lo["message-user__title"],title:t.name,children:t.name})]}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",mt:16,children:[_.jsxs("p",{className:Lo["message-user__follower"],children:[_.jsx("span",{className:Lo["message-user__follower-count"],children:t.userFollowerCount}),_.jsx("span",{children:"دنبال‌شونده"})]}),_.jsxs("p",{className:Lo["message-user__following"],children:[_.jsx("span",{className:Lo["message-user__follower-count"],children:t.userFollowingCount}),_.jsx("span",{children:"دنبال‌شده"})]})]})]})})}):_.jsx(See,{})}const $a={"message-file":"_message-file_1e0z6_6","message-file__info":"_message-file__info_1e0z6_18","message-file__info-name":"_message-file__info-name_1e0z6_21","message-file__info-size":"_message-file__info-size_1e0z6_29","message-file__info-type":"_message-file__info-type_1e0z6_33","message-file__icon":"_message-file__icon_1e0z6_39","message-file__progress":"_message-file__progress_1e0z6_60"};function wee({message:n}){const e=T.useRef(),t=n.content.files[0],[r,s]=T.useState(!1),[i,o]=T.useState(!1),[a,l]=T.useState(0),c=T.useMemo(()=>gD((t==null?void 0:t.size)||0,{round:0,symbols:{B:"بایت",kB:"کیلوبایت",MB:"مگابایت",GB:"گیگابایت"}}),[t]),d=()=>{const p=URL.createObjectURL(e.current),m=document.createElement("a");m.href=p,m.setAttribute("download",t.name),m.click(),URL.revokeObjectURL(p)},f=async()=>{try{o(!0);const{data:p}=await hr({url:t.url,method:"GET",responseType:"blob",onDownloadProgress:m=>{l(m.total?Math.floor(m.loaded/m.total*100):0)}});await de.sleep(500),s(!0),e.current=p,d()}catch(p){console.error(p)}finally{await de.sleep(500),o(!1)}};return t&&_.jsxs("div",{className:$a["message-file"],children:[_.jsxs("div",{className:$a["message-file__info"],children:[_.jsx("span",{className:$a["message-file__info-name"],dir:"auto",children:t.name}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[_.jsx("span",{className:$a["message-file__info-size"],children:c}),_.jsx("span",{className:$a["message-file__info-type"],children:t.type})]})]}),i&&_.jsx(sb,{size:36,color:"white",thickness:3,value:a,className:$a["message-file__progress"]}),r&&!i&&_.jsx("div",{className:$a["message-file__icon"],onClick:d,children:_.jsx("i",{className:"bi-file"})}),!i&&!r&&_.jsx("div",{className:$a["message-file__icon"],onClick:f,children:_.jsx("i",{className:"bi-download"})})]})}const eu={call:"_call_1vi7y_6","call__icon-wrapper":"_call__icon-wrapper_1vi7y_9","call__icon-wrapper--gray":"_call__icon-wrapper--gray_1vi7y_19",call__title:"_call__title_1vi7y_22",call__duration:"_call__duration_1vi7y_25"};function Tee({message:n}){var o,a;const e=(o=n.content)==null?void 0:o.metadata,{currentUser:t}=Lt(["currentUser"]),r=((a=n.sender)==null?void 0:a.id)==(t==null?void 0:t.id),s=e!=null&&e.isAnswered?r?"bi-outgoing-call":"bi-incoming-call":"bi-phone-fill",i=e!=null&&e.isAnswered?e.duration<60?`${e.duration} ثانیه`:`${Math.floor(e.duration/60)}:${e.duration%60} دقیقه`:"بی‌پاسخ";return _.jsxs("div",{className:eu.call,children:[_.jsx("div",{className:Te(eu["call__icon-wrapper"],{[eu["call__icon-wrapper--gray"]]:!r}),children:_.jsx(Mn,{name:s})}),_.jsxs("div",{className:eu.call__info,children:[_.jsx("div",{className:eu.call__title,children:r?"تماس با غرفه‌دار":"تماس مشتری"}),_.jsx("div",{className:eu.call__duration,children:i})]})]})}const Mo={"message-voice":"_message-voice_lh7fu_6","message-voice__btn":"_message-voice__btn_lh7fu_16","message-voice__btn--playing":"_message-voice__btn--playing_lh7fu_20","message-voice__duration":"_message-voice__duration_lh7fu_23","message-voice__range":"_message-voice__range_lh7fu_29"};function Cee({message:n}){var U;const e=T.useRef(),[t,r]=T.useState(0),[s,i]=T.useState(!1),[o,a]=T.useState(),[l,c]=T.useState(!1),[d,f]=T.useState(!1),[p,m]=T.useState(!0),g=At().isPc,v=T.useMemo(()=>`${Math.ceil(Math.random()*100)}%`,[]),y=T.useMemo(()=>de.durationDate(o*1e3),[o]),b=T.useMemo(()=>de.durationDate(t*1e3),[t]),S=s?b:y,E=p&&!d,C=()=>new Promise(($,q)=>{try{if(!e.current){q(new Error("Audio element not available"));return}if(e.current.duration===1/0){e.current.currentTime=Number.MAX_SAFE_INTEGER;const G=()=>{try{e.current.currentTime=0,e.current.removeEventListener("timeupdate",G),$(e.current.duration)}catch(V){q(V)}};e.current.addEventListener("timeupdate",G)}else Number.isNaN(e.current.duration)||e.current.duration<=0?q(new Error("Invalid audio duration")):$(e.current.duration)}catch(G){q(G)}}),R=$=>{if(!(d||!e.current))try{const q=Math.ceil($.target.value);r(q),e.current.currentTime=q}catch(q){console.error("Error setting audio time:",q),f(!0)}},I=()=>{var $,q,G;if(!(E||d||!e.current))try{s?($=e.current)==null||$.pause():(G=(q=e.current)==null?void 0:q.play())==null||G.catch(V=>{console.error("Error playing audio:",V),f(!0)})}catch(V){console.error("Error toggling audio:",V),f(!0)}},A=T.useCallback(()=>{i(!0)},[]),k=T.useCallback(()=>{i(!1)},[]),N=T.useCallback(()=>{if(i(!1),e.current)try{e.current.currentTime=0}catch($){console.error("Error resetting audio time:",$)}},[]),D=T.useCallback(()=>{try{e.current&&!Number.isNaN(e.current.currentTime)&&r(Math.floor(e.current.currentTime))}catch($){console.error("Error updating audio time:",$)}},[]),M=T.useCallback(async()=>{try{const $=await C();if($&&!Number.isNaN($)&&$>0)a($),c(!0),m(!1);else throw new Error("Invalid audio duration received")}catch($){console.error("Error loading audio metadata:",$),f(!0),m(!1)}},[]),F=T.useCallback($=>{console.warn("Audio error:",$),f(!0),m(!1),i(!1)},[]);return T.useEffect(()=>{var q,G,V;const $=(V=(G=(q=n==null?void 0:n.content)==null?void 0:q.files)==null?void 0:G[0])==null?void 0:V.url;if(!$){f(!0),m(!1);return}try{e.current=new Audio($),e.current.addEventListener("ended",N),e.current.addEventListener("play",A),e.current.addEventListener("pause",k),e.current.addEventListener("loadedmetadata",M),e.current.addEventListener("error",F);const z=setTimeout(()=>{!l&&!d&&(console.error("Audio metadata loading timeout"),f(!0),m(!1))},1e4);return()=>{clearTimeout(z),e.current&&(e.current.removeEventListener("ended",N),e.current.removeEventListener("play",A),e.current.removeEventListener("pause",k),e.current.removeEventListener("loadedmetadata",M),e.current.removeEventListener("error",F),e.current.pause(),e.current=null)}}catch(z){console.error("Error creating audio element:",z),f(!0),m(!1)}},[(U=n==null?void 0:n.content)==null?void 0:U.files,N,A,k,M,F,l,d]),T.useEffect(()=>{if(l&&e.current&&!d)try{e.current.addEventListener("timeupdate",D)}catch($){console.error("Error adding timeupdate listener:",$)}return()=>{if(e.current)try{e.current.removeEventListener("timeupdate",D)}catch($){console.error("Error removing timeupdate listener:",$)}}},[l,D,d]),d?_.jsxs("div",{className:Te(Mo["message-voice"],Mo["message-voice--error"]),children:[_.jsx("span",{className:Mo["message-voice__duration"],children:"Audio unavailable"}),_.jsx("input",{value:0,max:100,className:Mo["message-voice__range"],type:"range",disabled:!0,style:{"--background-position-x":"0%"}}),_.jsx(Qe,{className:Mo["message-voice__btn"],icon:"bi-exclamation-triangle",size:g?"md":"sm",square:!0,disabled:!0})]}):_.jsxs("div",{className:Mo["message-voice"],children:[_.jsx("span",{className:Mo["message-voice__duration"],children:!E&&o&&_.jsxs(_.Fragment,{children:[S.minutes(),":",`0${S.seconds()}`.slice(-2)]})}),_.jsx("input",{value:t,max:Math.floor(o)||100,className:Mo["message-voice__range"],type:"range",disabled:E||d,style:{"--background-position-x":v},onChange:R}),_.jsx(Qe,{className:Te(Mo["message-voice__btn"],{[Mo["message-voice__btn--playing"]]:s}),icon:s?"bi-pause":"bi-play-fill",size:g?"md":"sm",square:!0,onClick:I,loading:E,disabled:d})]})}const No={"message-story":"_message-story_1bgu2_6","message-story__content":"_message-story__content_1bgu2_21","message-story__content--skeleton":"_message-story__content--skeleton_1bgu2_37","message-story__content-photo":"_message-story__content-photo_1bgu2_21","message-story__content-vendor":"_message-story__content-vendor_1bgu2_55","message-story__content-vendor-name":"_message-story__content-vendor-name_1bgu2_65","message-story__content-ended":"_message-story__content-ended_1bgu2_75"};function Iee(n){return VK.get(`/api_v2.0/story_data/${n}`)}const Ree=(n,e={})=>Gn(["story",n],()=>Iee(n),e);function Aee(){return _.jsx("div",{className:No["message-story"],children:_.jsx("div",{className:Te(No["message-story__content"],No["message-story__content--skeleton"]),children:_.jsx(vt,{className:No["message-story__content-photo"]})})})}function kee({message:n}){var d,f,p;const e=n.content.entityId,t=Cc(),{data:r,isLoading:s,isError:i}=Ree(e,{enabled:!!e}),o=(d=r==null?void 0:r.data)==null?void 0:d.stories[0],a=(f=r==null?void 0:r.data)==null?void 0:f.vendor,l=!(r!=null&&r.data),c=()=>{o&&t(`/${a.identifier}/story/${o.id}`)};return _.jsx("div",{className:No["message-story"],onClick:c,children:s&&!i?_.jsx(Aee,{}):_.jsx("div",{className:No["message-story__content"],children:l?_.jsx("div",{className:No["message-story__content-ended"],children:_.jsx("span",{children:"زمان نمایش این استوری تمام شده"})}):_.jsxs(_.Fragment,{children:[_.jsx("img",{className:No["message-story__content-photo"],src:o.photo?o.photo.url:o.video.thumbnail,alt:a.title}),_.jsxs("div",{className:No["message-story__content-vendor"],children:[_.jsx(zs,{src:(p=a.logo)==null?void 0:p.extraSmall,size:"28"}),_.jsx("span",{className:No["message-story__content-vendor-name"],children:a.title})]})]})})})}const Vl={"message-video":"_message-video_v9mum_6","message-video__body":"_message-video__body_v9mum_18","message-video__body-player":"_message-video__body-player_v9mum_26","message-video__body-skeleton":"_message-video__body-skeleton_v9mum_31","message-video__body-skeleton--hide":"_message-video__body-skeleton--hide_v9mum_50","message-video__modal-player":"_message-video__modal-player_v9mum_53","message-video__modal-close":"_message-video__modal-close_v9mum_62"},_m=new Map,vm=new Map;async function Lee(n){if(!n)return n;if(_m.has(n))return _m.get(n);if(vm.has(n))return vm.get(n);const e=(async()=>{try{const t=await fetch(n);if(!t.ok)throw new Error(`Failed to fetch: ${t.status}`);const r=await t.blob(),s=URL.createObjectURL(r);return _m.set(n,s),s}catch(t){return console.error("Media cache fetch error:",t),n}finally{vm.delete(n)}})();return vm.set(n,e),e}function uj(n){return _m.get(n)}function dj(n){const e=uj(n),[t,r]=T.useState(e||null),[s,i]=T.useState(!e&&!!n),[o,a]=T.useState(null);return T.useEffect(()=>{if(!n){r(null),i(!1);return}const l=uj(n);if(l){r(l),i(!1);return}i(!0),a(null),Lee(n).then(c=>{r(c),i(!1)}).catch(c=>{a(c),r(n),i(!1)})},[n]),{cachedUrl:t,isLoading:s,error:o}}const Mee=284;function Nee({message:n}){const e=T.useRef(),[t,r]=T.useState(!1),[s,i]=T.useState(!1),o=n.content.files[0],{cachedUrl:a}=dj(o==null?void 0:o.url),l=o!=null&&o.height&&(o!=null&&o.width)?`${o.height*(Mee/o.width)}px`:void 0,c=T.useCallback(()=>{r(!0)},[]);return T.useEffect(()=>{const d=e.current;return d==null||d.addEventListener("loadeddata",c),()=>{d==null||d.removeEventListener("loadeddata",c)}},[c]),_.jsxs("div",{className:Vl["message-video"],children:[_.jsxs("div",{className:Vl["message-video__body"],style:{height:l},onClick:()=>i(!0),children:[_.jsx(Bd,{ref:e,src:a||"",controls:!1,preload:"metadata",className:Vl["message-video__body-player"]}),_.jsx(vt,{className:Te(Vl["message-video__body-skeleton"],{[Vl["message-video__body-skeleton--hide"]]:t}),radius:0})]}),_.jsx(lr,{className:"dataset-inp-MessageVideo",isPlain:!0,show:s,bottomSheetMode:!1,wrapperComponent:_.jsx("button",{className:Vl["message-video__modal-close"],onClick:()=>i(!1),"aria-label":"بستن پخش ویدیو",children:_.jsx("i",{className:"bi-close"})}),onClose:()=>i(!1),children:_.jsx(Bd,{autoplay:!0,controls:!0,src:a||"",className:Vl["message-video__modal-player"]})})]})}const On={"message-review":"_message-review_f6fry_6","message-review--done":"_message-review--done_f6fry_21","message-review__product":"_message-review__product_f6fry_24","message-review__product-body":"_message-review__product-body_f6fry_34","message-review__product-photo":"_message-review__product-photo_f6fry_49","message-review__product-name":"_message-review__product-name_f6fry_56","message-review__product-icon":"_message-review__product-icon_f6fry_74","message-review__product-price":"_message-review__product-price_f6fry_89","message-review__pending":"_message-review__pending_f6fry_103","message-review__pending-icon":"_message-review__pending-icon_f6fry_112","message-review__pending-text":"_message-review__pending-text_f6fry_121","message-review__form":"_message-review__form_f6fry_132","message-review__form-title":"_message-review__form-title_f6fry_137","message-review__form-action":"_message-review__form-action_f6fry_158","message-review__order":"_message-review__order_f6fry_166","message-review__order-title":"_message-review__order-title_f6fry_170","message-review__order-product":"_message-review__order-product_f6fry_176"};function Oee({message:n}){const{currentUser:e}=Lt(["currentUser"]);return _.jsxs("div",{className:On["message-review"],children:[_.jsxs("section",{className:On["message-review__product"],children:[_.jsx(vt,{width:48,radius:8,height:48,className:On["message-review__product-photo"]}),_.jsxs("div",{className:On["message-review__product-body"],children:[_.jsx(vt,{width:"80%",height:21,className:On["message-review__product-name"]}),_.jsx(je,{mt:8,children:_.jsx(vt,{width:80,height:26,className:On["message-review__product-price"]})})]})]}),+n.sender.id===(e==null?void 0:e.id)?_.jsx("div",{className:On["message-review__pending"],children:_.jsx(vt,{width:150,height:21,className:On["message-review__pending-text"]})}):_.jsxs("div",{className:On["message-review__form"],children:[_.jsx(vt,{width:"100%",height:21,className:On["message-review__form-title"]}),_.jsx(je,{my:12,display:"flex",alignItems:"flex-start",justifyContent:"space-between",children:_.jsx(vt,{width:"100%",height:65})}),_.jsxs(je,{mt:12,display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsx(vt,{height:36,className:On["message-review__form-action"]}),_.jsx(vt,{height:36,className:On["message-review__form-action"]})]})]})]})}const Vs={"variation-list__item":"_variation-list__item_1hgka_6","variation-list__list-item":"_variation-list__list-item_1hgka_12","variation-list__item-inner":"_variation-list__item-inner_1hgka_16","variation-list__title":"_variation-list__title_1hgka_20","variation-list__value":"_variation-list__value_1hgka_31","variation-list__value-divider":"_variation-list__value-divider_1hgka_36","variation-list__value-name":"_variation-list__value-name_1hgka_44","variation-list__value-separator":"_variation-list__value-separator_1hgka_56","variation-list":"_variation-list_1hgka_6","color-badge":"_color-badge_1hgka_68","variation-list--horizontal":"_variation-list--horizontal_1hgka_74","variation-list--wrap-items":"_variation-list--wrap-items_1hgka_85","variation-list__more-variation":"_variation-list__more-variation_1hgka_88","chat-widget-mobile":"_chat-widget-mobile_1hgka_1"};function fj({className:n,properties:e,size:t="md",isWrapItems:r,isHorizontal:s,valueClassName:i}){const o=Te(n,Vs["variation-list"],Vs[`variation-list--size-${t}`],r?Vs["variation-list--wrap-items"]:"",s?Vs["variation-list--horizontal"]:""),a=T.useMemo(()=>e?e.reduce((l,c)=>(c.properties.forEach(({property:d,value:f})=>{const p=l.find(({id:m})=>m===d.id);p?p.values.some(({id:m})=>m===f.id)||p.values.push({id:f.id,title:f.title}):l.push({id:d.id,title:d.title,values:[{id:f.id,title:f.title}]})}),l),[]):[],[e]);return a.length===0?null:_.jsx("div",{className:o,children:_.jsxs("span",{className:Vs["variation-list__item"],children:[a.map((l,c)=>{var d;return _.jsxs(T.Fragment,{children:[_.jsxs("span",{className:Vs["variation-list__title"],children:[l.title,":"]}),a.length===1?_.jsx("span",{className:Vs["variation-list__variations"],children:l.values.map((f,p)=>_.jsx("span",{className:Vs["variation-list__list-item"],children:_.jsxs("span",{className:Vs["variation-list__item-inner"],children:[p>0&&_.jsx("span",{className:Vs["variation-list__value-separator"],children:"و"}),_.jsx("span",{className:Te(i,Vs["variation-list__value-name"]),children:f.title})]})},`v__${f.id}`))}):_.jsxs(_.Fragment,{children:[_.jsx("span",{className:Te(i,Vs["variation-list__value-name"]),children:(d=l==null?void 0:l.values[0])==null?void 0:d.title}),a.length-1!==c&&_.jsx("span",{className:Te(i,Vs["variation-list__value-divider"])})]})]},c)}),a.length>1&&e.length>1&&_.jsx("span",{className:Vs["variation-list__more-variation"],children:"و چند تنوع دیگه"})]})})}const Pee=O.arrayOf(O.shape({value:O.shape({id:O.number,title:O.string,value:O.string}),property:O.shape({id:O.number,type:O.string,title:O.string})}));fj.propTypes={isWrapItems:O.bool,isHorizontal:O.bool,valueClassName:O.string,properties:Pee,size:O.oneOf(["sm","md"])};const Dee=T.memo(fj);function jee({message:n}){var I,A,k,N,D,M;const e=At(),{emitEvent:t}=Mt.useEmitter(),[r,s]=T.useState(0),{currentUser:i}=Lt(["currentUser"]),o=(I=n==null?void 0:n.content)==null?void 0:I.entityId,{data:a,isLoading:l,isError:c,refetch:d}=tJ({invoiceIds:[o]},{enabled:!!o}),f=(A=a==null?void 0:a.products)==null?void 0:A[0],p=(a==null?void 0:a.resultCount)>0,m=(N=(k=a==null?void 0:a.reviews)==null?void 0:k[0])==null?void 0:N.variationMetadata,g=(M=(D=a==null?void 0:a.unreviewedItems)==null?void 0:D[0])==null?void 0:M.variationMetadata,y=Dr()?`${mn.baseUrl}/p/${f==null?void 0:f.id}`:`/p/${f==null?void 0:f.id}`,b=(m==null?void 0:m.length)>0&&m||(g==null?void 0:g.length)>0&&g||null,{mutate:S,isLoading:E}=nJ({onSuccess:d}),C=()=>{var U;const F={star:r,isPublic:!0,invoiceItemId:(U=n==null?void 0:n.content)==null?void 0:U.entityId};S(F)},R=()=>{var F,U;t(Fa.SHOW_ADD_OR_EDIT_REVIEW_MODAL,{initialStep:1,onCreated:d,initialStars:r,items:(U=(F=a==null?void 0:a.unreviewedItems)==null?void 0:F.map)==null?void 0:U.call(F,ED)})};return l||c||!f?_.jsx(Oee,{message:n}):_.jsx("div",{className:Te(On["message-review"],{[On["message-review--done"]]:p}),"data-from":"chat","data-component":"review-request",children:p?_.jsxs("section",{className:On["message-review__order"],children:[_.jsxs("span",{className:On["message-review__order-title"],children:[_.jsx(Mn,{name:"bi-tick-single",color:"var(--gray-800)"}),"تجربه خرید ثبت شد"]}),_.jsx("img",{className:On["message-review__order-product"],src:f.photo.small,alt:f.title})]}):_.jsxs(_.Fragment,{children:[_.jsxs(wa,{to:y,className:On["message-review__product"],children:[_.jsx("img",{alt:f.title,src:f.photo.small,className:On["message-review__product-photo"]}),_.jsxs("div",{className:On["message-review__product-body"],children:[_.jsx("span",{className:On["message-review__product-name"],children:f.title}),!!b&&_.jsx(Dee,{isShowColor:!0,isHorizontal:!0,size:e.isPc?"md":"sm",properties:b}),_.jsxs("span",{className:On["message-review__product-price"],children:[de.numberSeparator(de.rialToToman(f.price)),_.jsx(je,{children:_.jsx("span",{className:Te("bi-toman",On["message-review__product-icon"])})})]})]})]}),+n.sender.id===(i==null?void 0:i.id)?_.jsxs("div",{className:On["message-review__pending"],children:[_.jsx("i",{className:Te("bi-info",On["message-review__pending-icon"])}),_.jsx("span",{className:On["message-review__pending-text"],children:"در انتظار ثبت تجربه"})]}):_.jsxs("div",{className:On["message-review__form"],children:[_.jsx("span",{className:On["message-review__form-title"],children:"به این محصولی که خریدی چند ستاره میدی؟"}),_.jsx(je,{mt:12,children:_.jsx(Eb,{size:e.isMobile?"sm":"lg",value:r,showIndex:!0,isButton:!0,onChange:s})}),!!r&&_.jsxs(je,{mt:36,display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsx(Qe,{className:On["message-review__form-action"],size:e.isMobile?"xs":"md",label:"نوشتن تجربه خرید",disabled:E,onClick:R}),_.jsx(Qe,{className:On["message-review__form-action"],size:e.isMobile?"xs":"md",label:"ثبت",variant:"outline",loading:E,onClick:C})]})]})]})})}const tu={"message-vendor":"_message-vendor_v0zfb_6","message-vendor__container":"_message-vendor__container_v0zfb_15","message-vendor__title":"_message-vendor__title_v0zfb_25"};function Fee(){return _.jsx("div",{className:"message-vendor",children:_.jsx("div",{className:tu["message-vendor__container"],children:_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[_.jsx(vt,{width:40,height:40,radius:"50%",className:tu["message-vendor__img"]}),_.jsx(vt,{width:120,height:At().isPc?24:21,className:tu["message-vendor__title"]})]})})})}function Uee({message:n}){var o,a;const e={};e.vendorId=(o=n.content)==null?void 0:o.entityId;const{data:t}=FQ(e,{enabled:!!e.vendorId}),r=(a=t==null?void 0:t.vendors)==null?void 0:a[0],i=Dr()?`${mn.baseUrl}/${r==null?void 0:r.identifier}`:`/${r==null?void 0:r.identifier}`;return r?_.jsx(wa,{className:tu["message-vendor"],to:i,children:_.jsx("div",{children:_.jsx("div",{className:tu["message-vendor__container"],children:_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[_.jsx(zs,{size:"40",src:r.logo&&r.logo.small}),_.jsx("span",{className:tu["message-vendor__title"],title:r.title,children:r.title})]})})})}):_.jsx(Fee,{})}const Sr={coupon:"_coupon_1sqyt_6",coupon__inner:"_coupon__inner_1sqyt_17",coupon__header:"_coupon__header_1sqyt_27","coupon__header-icon":"_coupon__header-icon_1sqyt_37","coupon__header-title":"_coupon__header-title_1sqyt_50","coupon__header-description":"_coupon__header-description_1sqyt_66","coupon__header-content":"_coupon__header-content_1sqyt_73",coupon__divider:"_coupon__divider_1sqyt_78",coupon__footer:"_coupon__footer_1sqyt_104","coupon__footer-text":"_coupon__footer-text_1sqyt_118","coupon__footer-icon":"_coupon__footer-icon_1sqyt_131","coupon--disabled":"_coupon--disabled_1sqyt_140"};function Bee({icon:n,title:e,vendor:t,isDeleted:r,isExpired:s,description:i,dividerClassName:o}){return _.jsx("div",{className:Te(Sr.coupon,{[Sr["coupon--disabled"]]:r||s}),children:_.jsxs("div",{className:Sr.coupon__inner,children:[_.jsxs("div",{className:Sr.coupon__header,children:[_.jsx("div",{className:Sr["coupon__header-icon"],children:_.jsx("i",{className:n})}),_.jsxs("div",{className:Sr["coupon__header-content"],children:[_.jsxs("div",{className:Sr["coupon__header-title"],children:[_.jsx("p",{children:e}),r&&_.jsx(Xo,{label:"حذف‌شده",color:"black",size:"sm"}),!r&&s&&_.jsx(Xo,{label:"منقضی‌شده",color:"black",size:"sm"})]}),_.jsx("p",{className:Sr["coupon__header-description"],children:i})]})]}),_.jsx("div",{className:Te(Sr.coupon__divider,o)}),_.jsxs("div",{className:Sr.coupon__footer,children:[_.jsx("i",{className:Te("bi-vendor",Sr["coupon__footer-icon"])}),_.jsx("span",{className:Sr["coupon__footer-text"],children:`از غرفه ${(t==null?void 0:t.title)||""}`})]})]})})}const yf={"message-coupon":"_message-coupon_sp7x3_6","message-coupon--sender":"_message-coupon--sender_sp7x3_9","message-coupon__coupon":"_message-coupon__coupon_sp7x3_9","message-coupon--receiver":"_message-coupon--receiver_sp7x3_12"};function $ee({className:n,dividerClassName:e}){const t=At().isPc;return _.jsx("div",{className:Te(Sr.coupon,n),children:_.jsxs("div",{className:Sr.coupon__inner,children:[_.jsxs("div",{className:Sr.coupon__header,children:[_.jsx("div",{className:Sr["coupon__header-icon"]}),_.jsxs("div",{className:Sr["coupon__header-content"],children:[_.jsx("div",{className:Sr["coupon__header-title"],children:_.jsx(vt,{height:t?21:19,width:"40%",backgroundColor:"var(--gray-025)",waveColor:"var(--gray-050)"})}),_.jsx("div",{className:Sr["coupon__header-description"],children:_.jsx(vt,{height:t?21:18,width:"80%",backgroundColor:"var(--gray-025)",waveColor:"var(--gray-050)"})})]})]}),_.jsx("div",{className:Te(Sr.coupon__divider,e)}),_.jsxs("div",{className:Sr.coupon__footer,children:[_.jsx(vt,{height:t?20:16,width:16,backgroundColor:"var(--gray-025)",waveColor:"var(--gray-050)"}),_.jsx(vt,{height:t?21:18,width:"40%",className:Sr["coupon__footer-text"],backgroundColor:"var(--gray-025)",waveColor:"var(--gray-050)"})]})]})})}function zee(n){return YK.get("/v2/coupon",{params:{ids:n.ids.join(",")}})}const qee=(n={},e={})=>Gn(["coupon",n.ids],()=>zee(n),e);function Hee({message:n}){var d,f;const e=(d=n==null?void 0:n.content)==null?void 0:d.entityId,{currentUser:t}=Lt(["currentUser"]),r=Dr(),s=Number(((f=n==null?void 0:n.sender)==null?void 0:f.id)||0)===Number((t==null?void 0:t.id)||0),{data:i,isLoading:o,isError:a}=qee({ids:[e]},{enabled:!!e}),l=T.useMemo(()=>{var p;return(i==null?void 0:i.resultCount)>0?(p=i==null?void 0:i.data)==null?void 0:p[0]:null},[i]),c=()=>{var m,g;const p=r?`${mn.baseUrl}/${(m=l==null?void 0:l.vendor)==null?void 0:m.identifier}`:`/${(g=l==null?void 0:l.vendor)==null?void 0:g.identifier}`;window.open(p,"_blank")};return _.jsx("div",{className:Te(yf["message-coupon"],{[yf["message-coupon--sender"]]:s},{[yf["message-coupon--receiver"]]:!s}),children:o||a?_.jsx($ee,{dividerClassName:yf["message-coupon__coupon"]}):_.jsx("div",{onClick:c,children:_.jsx(Bee,{...l,dividerClassName:yf["message-coupon__coupon"]})})})}const Xn={factor:"_factor_v9ev4_10",factor__product__item:"_factor__product__item_v9ev4_25","factor__product__item-image":"_factor__product__item-image_v9ev4_31","factor__product__item-box":"_factor__product__item-box_v9ev4_38","factor__product__item-title":"_factor__product__item-title_v9ev4_44","factor__product__item-variation":"_factor__product__item-variation_v9ev4_61","factor__product__item-quantity":"_factor__product__item-quantity_v9ev4_64","factor__product__item-quantity--separator":"_factor__product__item-quantity--separator_v9ev4_71",factor__price:"_factor__price_v9ev4_80",factor__icon:"_factor__icon_v9ev4_91",factor__divider:"_factor__divider_v9ev4_95","factor__divider--sender":"_factor__divider--sender_v9ev4_98","factor__divider--receiver":"_factor__divider--receiver_v9ev4_101",factor__status:"_factor__status_v9ev4_104","chat-widget-mobile":"_chat-widget-mobile_v9ev4_1"},Ws={"variation-list__item":"_variation-list__item_1hgka_6","variation-list__list-item":"_variation-list__list-item_1hgka_12","variation-list__item-inner":"_variation-list__item-inner_1hgka_16","variation-list__title":"_variation-list__title_1hgka_20","variation-list__value":"_variation-list__value_1hgka_31","variation-list__value-divider":"_variation-list__value-divider_1hgka_36","variation-list__value-name":"_variation-list__value-name_1hgka_44","variation-list__value-separator":"_variation-list__value-separator_1hgka_56","variation-list":"_variation-list_1hgka_6","color-badge":"_color-badge_1hgka_68","variation-list--horizontal":"_variation-list--horizontal_1hgka_74","variation-list--wrap-items":"_variation-list--wrap-items_1hgka_85","variation-list__more-variation":"_variation-list__more-variation_1hgka_88","chat-widget-mobile":"_chat-widget-mobile_1hgka_1"};function hj({className:n,properties:e,size:t="md",isWrapItems:r,isHorizontal:s,valueClassName:i}){const o=Te(n,Ws["variation-list"],Ws[`variation-list--size-${t}`],r?Ws["variation-list--wrap-items"]:"",s?Ws["variation-list--horizontal"]:""),a=e.reduce((l,{property:c,value:d})=>{const f={...c,values:[d]},p=l.find(({id:m})=>m===c.id);return p?p.values.some(({id:m})=>m===d.id)||p.values.push(d):l.push(f),l},[]);return a.length===0?null:_.jsx("div",{className:o,children:_.jsxs("span",{className:Ws["variation-list__item"],children:[a.map((l,c)=>{var d;return _.jsxs(T.Fragment,{children:[_.jsxs("span",{className:Ws["variation-list__title"],children:[l.title,":"]}),a.length===1?_.jsx("span",{className:Ws["variation-list__variations"],children:l.values.map((f,p)=>_.jsx("span",{className:Ws["variation-list__list-item"],children:_.jsxs("span",{className:Ws["variation-list__item-inner"],children:[p>0&&_.jsx("span",{className:Ws["variation-list__value-separator"],children:"و"}),_.jsx("span",{className:Te(i,Ws["variation-list__value-name"]),children:f.title})]})},`v__${f.id}`))}):_.jsxs(_.Fragment,{children:[_.jsx("span",{className:Te(i,Ws["variation-list__value-name"]),children:(d=l==null?void 0:l.values[0])==null?void 0:d.title}),a.length-1!==c&&_.jsx("span",{className:Te(i,Ws["variation-list__value-divider"])})]})]},c)}),a.length>1&&e.length>1&&_.jsx("span",{className:Ws["variation-list__more-variation"],children:"و چند تنوع دیگه"})]})})}const Gee=O.arrayOf(O.shape({value:O.shape({id:O.number,title:O.string,value:O.string}),property:O.shape({id:O.number,type:O.string,title:O.string})}));hj.propTypes={isWrapItems:O.bool,isHorizontal:O.bool,valueClassName:O.string,properties:Gee,size:O.oneOf(["sm","md"])};const Vee=T.memo(hj);function Wee(){return _.jsxs("section",{className:Xn.factor,children:[_.jsx("div",{className:Xn.factor__product,children:[1,2].map(n=>_.jsxs("div",{className:Xn.factor__product__item,children:[_.jsx(vt,{className:Xn["factor__product__item-image"],width:48,height:48,radius:8}),_.jsxs("div",{className:Xn["factor__product__item-box"],children:[_.jsxs("div",{children:[_.jsx(vt,{className:Xn["factor__product__item-title"],width:100,height:14,radius:4,mb:8}),_.jsx(vt,{width:60,height:12,radius:4})]}),_.jsx(je,{display:"flex",alignItems:"center",children:_.jsx(vt,{width:50,height:18,radius:4})})]})]},n))}),_.jsx(vt,{width:"100%",height:1,className:Xn.factor__divider}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsx(vt,{width:70,height:14,radius:4}),_.jsx(vt,{width:80,height:18,radius:4})]}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,mt:8,children:[_.jsx(vt,{width:"100%",height:32,radius:8}),_.jsx(vt,{width:"100%",height:32,radius:8})]}),_.jsxs(je,{display:"flex",gap:4,mt:10,alignItems:"center",children:[_.jsx(vt,{width:20,height:20,radius:10}),_.jsx(vt,{width:80,height:14,radius:4})]})]})}function Kee({factorId:n}){return XK.get(`/v2/factors/${n}`)}const Yee=(n={},e={})=>Gn(["factor",n.factorId],()=>Kee(n),e);function Xee({message:n}){var I,A,k,N,D,M,F,U,$,q,G,V,z,B,P,H,Z,Q,J;const{currentUser:e}=Lt(["currentUser"]),t=(I=n.content)==null?void 0:I.entityId,r=At().isPc,s=Nl(),{emitEvent:i}=Mt.useEmitter(),o=Cc(),a=+((A=n.sender)==null?void 0:A.id)==+(e==null?void 0:e.id),{data:l,isLoading:c,isError:d}=Yee({factorId:t},{enabled:!!t}),f=((k=l==null?void 0:l.status)==null?void 0:k.code)===bO.PAID,p=((N=l==null?void 0:l.status)==null?void 0:N.code)===bO.PAYMENT_WAITING,m=T.useMemo(()=>{var ee,K,W;return((W=(K=(ee=l==null?void 0:l.order)==null?void 0:ee.vendors)==null?void 0:K[0])==null?void 0:W.items)||[]},[l]),g=T.useMemo(()=>{var K,W,te;const ee=((te=(W=(K=l==null?void 0:l.order)==null?void 0:K.costs)==null?void 0:W.products)==null?void 0:te.grand)||0;return de.numberSeparator(de.rialToToman(ee))},[(F=(M=(D=l==null?void 0:l.order)==null?void 0:D.costs)==null?void 0:M.products)==null?void 0:F.grand]),v=T.useMemo(()=>{var K,W,te,re,pe;let ee=((te=(W=(K=l==null?void 0:l.order)==null?void 0:K.costs)==null?void 0:W.total)==null?void 0:te.grand)||0;return f||(ee+=((pe=(re=l==null?void 0:l.order)==null?void 0:re.serviceFee)==null?void 0:pe.amount)||0),de.numberSeparator(de.rialToToman(ee))},[(q=($=(U=l==null?void 0:l.order)==null?void 0:U.costs)==null?void 0:$.total)==null?void 0:q.grand,(V=(G=l==null?void 0:l.order)==null?void 0:G.serviceFee)==null?void 0:V.amount,f]),y=T.useCallback(()=>{s.invalidateQueries({queryKey:["factor",t]})},[s,t]),b=T.useCallback(()=>{i("show-factor-payment-modal",{id:t})},[t]),S=T.useCallback(()=>{i("show-factor-details-modal",{id:t,onSuccess:y})},[t,y]),E=T.useCallback(()=>{var ee;i("show-address-list-modal",{onSubmit:y,onEditAddress:y,onAddNewAddress:y,selectedAddress:(ee=l==null?void 0:l.order)==null?void 0:ee.address})},[(z=l==null?void 0:l.order)==null?void 0:z.address,y]),C=T.useCallback(()=>{var ee;o(`/account/orders/${(ee=l==null?void 0:l.order)==null?void 0:ee.id}`)},[(B=l==null?void 0:l.order)==null?void 0:B.id,o]),R=ee=>{o(`/p/${ee}`)};return c||d?_.jsx(Wee,{}):_.jsxs("section",{className:Xn.factor,children:[_.jsxs("div",{className:Xn.factor__product,children:[m.slice(0,4).map(({product:ee,id:K,quantity:W,title:te,variation:re,price:pe})=>{var Ee,le,Ie;return _.jsxs("div",{onClick:()=>R(ee==null?void 0:ee.id),className:Xn.factor__product__item,children:[_.jsx("img",{className:Xn["factor__product__item-image"],src:(Ie=(le=(Ee=ee==null?void 0:ee.photos)==null?void 0:Ee[0])==null?void 0:le.resized)==null?void 0:Ie.sm,alt:te}),_.jsxs("div",{className:Xn["factor__product__item-box"],children:[_.jsxs("div",{children:[_.jsx("div",{className:Xn["factor__product__item-title"],children:te}),_.jsxs(je,{alignItems:"flex-end",display:"flex",children:[_.jsxs("p",{className:Te(Xn["factor__product__item-quantity"],{[Xn["factor__product__item-quantity--separator"]]:!!(re!=null&&re.properties)}),children:[W," عدد"]}),re&&_.jsx(Vee,{isShowColor:!0,isHorizontal:!0,size:r?"md":"sm",className:Xn["factor__product__item-variation"],properties:re.properties})]})]}),_.jsxs(je,{display:"flex",alignItems:"center",children:[_.jsx("span",{className:Xn.factor__price,children:de.numberSeparator(de.rialToToman(pe*W))}),_.jsx("span",{className:Te("bi-toman",Xn.factor__icon)})]})]})]},K)}),m.length>4&&_.jsxs("span",{children:["و",m.length-4,"محصول دیگر"]})]}),_.jsx("hr",{className:Te(Xn.factor__divider,Xn[`factor__divider--${a?"sender":"receiver"}`])}),a?_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsx("span",{children:"قیمت محصولات"}),_.jsxs(je,{display:"flex",alignItems:"center",children:[_.jsx("span",{className:Xn.factor__price,children:g}),_.jsx("span",{className:Te("bi-toman",Xn.factor__icon)})]})]}):(P=l==null?void 0:l.order)!=null&&P.address?_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsx("span",{children:"جمع فاکتور"}),_.jsxs(je,{display:"flex",alignItems:"center",children:[_.jsx("span",{className:Xn.factor__price,children:v}),_.jsx("span",{className:Te("bi-toman",Xn.factor__icon)})]})]}):_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsx("span",{children:"انتخاب آدرس"}),_.jsx(Qe,{variant:"text",label:"افزودن آدرس",icon:"bi-angle-left",iconPosition:"end",size:"sm",onClick:E,className:Xn["instant-buy-address__btn"]})]}),a?_.jsx(je,{mt:8,children:_.jsx(Qe,{fullWidth:!0,label:"جزئیات فاکتور",size:r?"xs":"xxs",variant:"outline",icon:"bi-angle-left",iconPosition:"center-end",color:"secondary",onClick:S})}):p?_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,mt:8,children:[_.jsx(Qe,{fullWidth:!0,disabled:!((H=l==null?void 0:l.order)!=null&&H.address),label:"پرداخت فاکتور",size:r?"xs":"xxs",onClick:b}),_.jsx(Qe,{fullWidth:!0,label:"جزئیات فاکتور",variant:"outline",color:"secondary",size:r?"xs":"xxs",onClick:S})]}):f?_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,mt:8,children:[_.jsx(Qe,{fullWidth:!0,label:"جزئیات سفارش",size:"xs",onClick:C}),_.jsx(Qe,{fullWidth:!0,label:"جزئیات فاکتور",variant:"outline",color:"secondary",size:r?"xs":"xxs",onClick:S})]}):_.jsx(je,{mt:8,children:_.jsx(Qe,{fullWidth:!0,label:"جزئیات فاکتور",size:r?"xs":"xxs",variant:"outline",icon:"bi-angle-left",iconPosition:"center-end",color:"secondary",onClick:S})}),_.jsxs(je,{display:"flex",gap:4,mt:10,alignItems:"center",children:[_.jsx(Mn,{name:f?"bi-tick-single":"bi-info",size:"20",color:`#${(Z=l==null?void 0:l.status)==null?void 0:Z.color}`||"var(--gray-600)"}),_.jsx("span",{className:Xn.factor__status,style:{color:`#${(Q=l==null?void 0:l.status)==null?void 0:Q.color}`||"var(--gray-600)"},children:(J=l==null?void 0:l.status)==null?void 0:J.text})]})]})}const pj={hint:"_hint_gah7o_6",hint__link:"_hint__link_gah7o_14"};function Qee(){const{contact:n}=Tn(["contact"]),{publishEvent:e}=Fr(),t=r=>{r.stopPropagation(),window.open(`${mn.vendorDashboardUrl}/create-coupon`,"_blank"),requestIdleCallback(()=>{e("chatCreateCouponClick",{contactId:n==null?void 0:n.id})})};return _.jsxs("div",{className:pj.hint,children:[_.jsx("div",{children:"مشتری ازت خواسته اگه می‌تونی بهش تخفیف بدی. اگه مایلی، براش کد تخفیف بساز."}),_.jsx($d,{onClick:t,label:"ساخت کد تخفیف",className:pj.hint__link})]})}const bf={"message-picture":"_message-picture_oqki6_6","message-picture__backdrop":"_message-picture__backdrop_oqki6_29","message-picture__img":"_message-picture__img_oqki6_38","message-picture__img--collapsed":"_message-picture__img--collapsed_oqki6_44"};var Ur=function(){return Ur=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Ur.apply(this,arguments)};typeof window<"u"&&(window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),typeof window.CustomEvent!="function"&&(window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}));function mj(n,e){for(var t=n.length;t--;)if(n[t].pointerId===e.pointerId)return t;return-1}function YS(n,e){var t;if(e.touches){t=0;for(var r=0,s=e.touches;r<s.length;r++){var i=s[r];i.pointerId=t++,YS(n,i)}return}t=mj(n,e),t>-1&&n.splice(t,1),n.push(e)}function Jee(n,e){if(e.touches){for(;n.length;)n.pop();return}var t=mj(n,e);t>-1&&n.splice(t,1)}function gj(n){n=n.slice(0);for(var e=n.pop(),t;t=n.pop();)e={clientX:(t.clientX-e.clientX)/2+e.clientX,clientY:(t.clientY-e.clientY)/2+e.clientY};return e}function XS(n){if(n.length<2)return 0;var e=n[0],t=n[1];return Math.sqrt(Math.pow(Math.abs(t.clientX-e.clientX),2)+Math.pow(Math.abs(t.clientY-e.clientY),2))}var xf={down:"mousedown",move:"mousemove",up:"mouseup mouseleave"};typeof window<"u"&&(typeof window.PointerEvent=="function"?xf={down:"pointerdown",move:"pointermove",up:"pointerup pointerleave pointercancel"}:typeof window.TouchEvent=="function"&&(xf={down:"touchstart",move:"touchmove",up:"touchend touchcancel"}));function QS(n,e,t,r){xf[n].split(" ").forEach(function(s){e.addEventListener(s,t,r)})}function JS(n,e,t){xf[n].split(" ").forEach(function(r){e.removeEventListener(r,t)})}var Zee=typeof document<"u"&&!!document.documentMode,ZS;function ete(){return ZS||(ZS=document.createElement("div").style)}var _j=["webkit","moz","ms"],ym={};function eE(n){if(ym[n])return ym[n];var e=ete();if(n in e)return ym[n]=n;for(var t=n[0].toUpperCase()+n.slice(1),r=_j.length;r--;){var s="".concat(_j[r]).concat(t);if(s in e)return ym[n]=s}}function bm(n,e){return parseFloat(e[eE(n)])||0}function xm(n,e,t){t===void 0&&(t=window.getComputedStyle(n));var r=e==="border"?"Width":"";return{left:bm("".concat(e,"Left").concat(r),t),right:bm("".concat(e,"Right").concat(r),t),top:bm("".concat(e,"Top").concat(r),t),bottom:bm("".concat(e,"Bottom").concat(r),t)}}function nu(n,e,t){n.style[eE(e)]=t}function tte(n,e){var t=eE("transform");nu(n,"transition","".concat(t," ").concat(e.duration,"ms ").concat(e.easing))}function nte(n,e,t){var r=e.x,s=e.y,i=e.scale,o=e.isSVG;if(nu(n,"transform","scale(".concat(i,") translate(").concat(r,"px, ").concat(s,"px)")),o&&Zee){var a=window.getComputedStyle(n).getPropertyValue("transform");n.setAttribute("transform",a)}}function tE(n){var e=n.parentNode,t=window.getComputedStyle(n),r=window.getComputedStyle(e),s=n.getBoundingClientRect(),i=e.getBoundingClientRect();return{elem:{style:t,width:s.width,height:s.height,top:s.top,bottom:s.bottom,left:s.left,right:s.right,margin:xm(n,"margin",t),border:xm(n,"border",t)},parent:{style:r,width:i.width,height:i.height,top:i.top,bottom:i.bottom,left:i.left,right:i.right,padding:xm(e,"padding",r),border:xm(e,"border",r)}}}function rte(n){var e=n.ownerDocument,t=n.parentNode;return e&&t&&e.nodeType===9&&t.nodeType===1&&e.documentElement.contains(t)}function ste(n){return(n.getAttribute("class")||"").trim()}function ite(n,e){return n.nodeType===1&&" ".concat(ste(n)," ").indexOf(" ".concat(e," "))>-1}function ote(n,e){for(var t=n;t!=null;t=t.parentNode)if(ite(t,e.excludeClass)||e.exclude.indexOf(t)>-1)return!0;return!1}var ate=/^http:[\w\.\/]+svg$/;function lte(n){return ate.test(n.namespaceURI)&&n.nodeName.toLowerCase()!=="svg"}function cte(n){var e={};for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e}var vj={animate:!1,canvas:!1,cursor:"move",disablePan:!1,disableZoom:!1,disableXAxis:!1,disableYAxis:!1,duration:200,easing:"ease-in-out",exclude:[],excludeClass:"panzoom-exclude",handleStartEvent:function(n){n.preventDefault(),n.stopPropagation()},maxScale:4,minScale:.125,overflow:"hidden",panOnlyWhenZoomed:!1,pinchAndPan:!1,relative:!1,setTransform:nte,startX:0,startY:0,startScale:1,step:.3,touchAction:"none"};function yj(n,e){if(!n)throw new Error("Panzoom requires an element as an argument");if(n.nodeType!==1)throw new Error("Panzoom requires an element with a nodeType of 1");if(!rte(n))throw new Error("Panzoom should be called on elements that have been attached to the DOM");e=Ur(Ur({},vj),e);var t=lte(n),r=n.parentNode;r.style.overflow=e.overflow,r.style.userSelect="none",r.style.touchAction=e.touchAction,(e.canvas?r:n).style.cursor=e.cursor,n.style.userSelect="none",n.style.touchAction=e.touchAction,nu(n,"transformOrigin",typeof e.origin=="string"?e.origin:t?"0 0":"50% 50%");function s(){r.style.overflow="",r.style.userSelect="",r.style.touchAction="",r.style.cursor="",n.style.cursor="",n.style.userSelect="",n.style.touchAction="",nu(n,"transformOrigin","")}function i(B){B===void 0&&(B={});for(var P in B)B.hasOwnProperty(P)&&(e[P]=B[P]);(B.hasOwnProperty("cursor")||B.hasOwnProperty("canvas"))&&(r.style.cursor=n.style.cursor="",(e.canvas?r:n).style.cursor=e.cursor),B.hasOwnProperty("overflow")&&(r.style.overflow=B.overflow),B.hasOwnProperty("touchAction")&&(r.style.touchAction=B.touchAction,n.style.touchAction=B.touchAction)}var o=0,a=0,l=1,c=!1;v(e.startScale,{animate:!1,force:!0}),setTimeout(function(){g(e.startX,e.startY,{animate:!1,force:!0})});function d(B,P,H){if(!H.silent){var Z=new CustomEvent(B,{detail:P});n.dispatchEvent(Z)}}function f(B,P,H){var Z={x:o,y:a,scale:l,isSVG:t,originalEvent:H};return requestAnimationFrame(function(){typeof P.animate=="boolean"&&(P.animate?tte(n,P):nu(n,"transition","none")),P.setTransform(n,Z,P),d(B,Z,P),d("panzoomchange",Z,P)}),Z}function p(B,P,H,Z){var Q=Ur(Ur({},e),Z),J={x:o,y:a,opts:Q};if(!Q.force&&(Q.disablePan||Q.panOnlyWhenZoomed&&l===Q.startScale))return J;if(B=parseFloat(B),P=parseFloat(P),Q.disableXAxis||(J.x=(Q.relative?o:0)+B),Q.disableYAxis||(J.y=(Q.relative?a:0)+P),Q.contain){var ee=tE(n),K=ee.elem.width/l,W=ee.elem.height/l,te=K*H,re=W*H,pe=(te-K)/2,Ee=(re-W)/2;if(Q.contain==="inside"){var le=(-ee.elem.margin.left-ee.parent.padding.left+pe)/H,Ie=(ee.parent.width-te-ee.parent.padding.left-ee.elem.margin.left-ee.parent.border.left-ee.parent.border.right+pe)/H;J.x=Math.max(Math.min(J.x,Ie),le);var be=(-ee.elem.margin.top-ee.parent.padding.top+Ee)/H,ge=(ee.parent.height-re-ee.parent.padding.top-ee.elem.margin.top-ee.parent.border.top-ee.parent.border.bottom+Ee)/H;J.y=Math.max(Math.min(J.y,ge),be)}else if(Q.contain==="outside"){var le=(-(te-ee.parent.width)-ee.parent.padding.left-ee.parent.border.left-ee.parent.border.right+pe)/H,Ie=(pe-ee.parent.padding.left)/H;J.x=Math.max(Math.min(J.x,Ie),le);var be=(-(re-ee.parent.height)-ee.parent.padding.top-ee.parent.border.top-ee.parent.border.bottom+Ee)/H,ge=(Ee-ee.parent.padding.top)/H;J.y=Math.max(Math.min(J.y,ge),be)}}return Q.roundPixels&&(J.x=Math.round(J.x),J.y=Math.round(J.y)),J}function m(B,P){var H=Ur(Ur({},e),P),Z={scale:l,opts:H};if(!H.force&&H.disableZoom)return Z;var Q=e.minScale,J=e.maxScale;if(H.contain){var ee=tE(n),K=ee.elem.width/l,W=ee.elem.height/l;if(K>1&&W>1){var te=ee.parent.width-ee.parent.border.left-ee.parent.border.right,re=ee.parent.height-ee.parent.border.top-ee.parent.border.bottom,pe=te/K,Ee=re/W;e.contain==="inside"?J=Math.min(J,pe,Ee):e.contain==="outside"&&(Q=Math.max(Q,pe,Ee))}}return Z.scale=Math.min(Math.max(B,Q),J),Z}function g(B,P,H,Z){var Q=p(B,P,l,H);return o!==Q.x||a!==Q.y?(o=Q.x,a=Q.y,f("panzoompan",Q.opts,Z)):{x:o,y:a,scale:l,isSVG:t,originalEvent:Z}}function v(B,P,H){var Z=m(B,P),Q=Z.opts;if(!(!Q.force&&Q.disableZoom)){B=Z.scale;var J=o,ee=a;if(Q.focal){var K=Q.focal;J=(K.x/B-K.x/l+o*B)/B,ee=(K.y/B-K.y/l+a*B)/B}var W=p(J,ee,B,{relative:!1,force:!0});return o=W.x,a=W.y,l=B,f("panzoomzoom",Q,H)}}function y(B,P){var H=Ur(Ur(Ur({},e),{animate:!0}),P);return v(l*Math.exp((B?1:-1)*H.step),H)}function b(B){return y(!0,B)}function S(B){return y(!1,B)}function E(B,P,H,Z){var Q=tE(n),J={width:Q.parent.width-Q.parent.padding.left-Q.parent.padding.right-Q.parent.border.left-Q.parent.border.right,height:Q.parent.height-Q.parent.padding.top-Q.parent.padding.bottom-Q.parent.border.top-Q.parent.border.bottom},ee=P.clientX-Q.parent.left-Q.parent.padding.left-Q.parent.border.left-Q.elem.margin.left,K=P.clientY-Q.parent.top-Q.parent.padding.top-Q.parent.border.top-Q.elem.margin.top;t||(ee-=Q.elem.width/l/2,K-=Q.elem.height/l/2);var W={x:ee/J.width*(J.width*B),y:K/J.height*(J.height*B)};return v(B,Ur(Ur({},H),{animate:!1,focal:W}),Z)}function C(B,P){B.preventDefault();var H=Ur(Ur(Ur({},e),P),{animate:!1}),Z=B.deltaY===0&&B.deltaX?B.deltaX:B.deltaY,Q=Z<0?1:-1,J=m(l*Math.exp(Q*H.step/3),H).scale;return E(J,B,H,B)}function R(B){var P=Ur(Ur(Ur({},e),{animate:!0,force:!0}),B);l=m(P.startScale,P).scale;var H=p(P.startX,P.startY,l,P);return o=H.x,a=H.y,f("panzoomreset",P)}var I,A,k,N,D,M,F=[];function U(B){if(!ote(B.target,e)){YS(F,B),c=!0,e.handleStartEvent(B),I=o,A=a,d("panzoomstart",{x:o,y:a,scale:l,isSVG:t,originalEvent:B},e);var P=gj(F);k=P.clientX,N=P.clientY,D=l,M=XS(F)}}function $(B){if(!(!c||I===void 0||A===void 0||k===void 0||N===void 0)){YS(F,B);var P=gj(F),H=F.length>1,Z=l;if(H){M===0&&(M=XS(F));var Q=XS(F)-M;Z=m(Q*e.step/80+D).scale,E(Z,P,{animate:!1},B)}(!H||e.pinchAndPan)&&g(I+(P.clientX-k)/Z,A+(P.clientY-N)/Z,{animate:!1},B)}}function q(B){F.length===1&&d("panzoomend",{x:o,y:a,scale:l,isSVG:t,originalEvent:B},e),Jee(F,B),c&&(c=!1,I=A=k=N=void 0)}var G=!1;function V(){G||(G=!0,QS("down",e.canvas?r:n,U),QS("move",document,$,{passive:!0}),QS("up",document,q,{passive:!0}))}function z(){G=!1,JS("down",e.canvas?r:n,U),JS("move",document,$),JS("up",document,q)}return e.noBind||V(),{bind:V,destroy:z,eventNames:xf,getPan:function(){return{x:o,y:a}},getScale:function(){return l},getOptions:function(){return cte(e)},handleDown:U,handleMove:$,handleUp:q,pan:g,reset:R,resetStyle:s,setOptions:i,setStyle:function(B,P){return nu(n,B,P)},zoom:v,zoomIn:b,zoomOut:S,zoomToPoint:E,zoomWithWheel:C}}yj.defaultOptions=vj;const ru={magnifier__header:"_magnifier__header_ewhjg_6",magnifier__header_button:"_magnifier__header_button_ewhjg_27",magnifier__header_user:"_magnifier__header_user_ewhjg_47",magnifier__header_user_avatar:"_magnifier__header_user_avatar_ewhjg_64",magnifier__header_user_name:"_magnifier__header_user_name_ewhjg_71"},bj=300,Sf=100,ute=10,dte=T.forwardRef(function({magnifierSrc:e,children:t,disabled:r,style:s,contact:i,closeMagnifier:o},a){var W,te;const{push:l}=Si(),c=T.useRef(null),d=T.useRef(null),f=T.useRef(),[p,m]=T.useState(0),[g,v]=T.useState(0),[y,b]=T.useState((W=c.current)==null?void 0:W.getBoundingClientRect()),[S,E]=T.useState(!1),[C,R]=T.useState(!1),[I,A]=T.useState(!1),[k,N]=T.useState("0 0"),[D,M]=T.useState({x:0,y:0}),[F,U]=T.useState(Sf),q=At().isMobile,G=T.useCallback(()=>{U(Sf),N("0 0")},[]),V=T.useCallback(async()=>{I||(A(!0),q||(f.current=yj(c.current,{maxScale:5,minScale:1,touchAction:"",contain:"outside"})))},[I]),z=T.useCallback(()=>{var re;q&&((re=f.current)==null||re.destroy()),G(),A(!1)},[G]),B=re=>{let pe=window.Event?re.pageX:re.clientX;pe-=document.documentElement.scrollLeft||document.body.scrollLeft;let Ee=window.Event?re.pageY:re.clientY;Ee-=document.documentElement.scrollTop||document.body.scrollTop,m(pe-D.x),v(Ee-D.y)},P=re=>{const pe=window.getComputedStyle(re,null).getPropertyValue("-webkit-transform");function Ee(be){let ge;if(be==="none")ge=0;else{const Ae=be.split("(")[1].split(")")[0].split(","),Re=Ae[0],tt=Ae[1];ge=Math.round(Math.atan2(tt,Re)*(180/Math.PI))}return ge<0?ge+=360:ge}const le=pe.match(/matrix(?:(3d)\(-{0,1}\d+\.?\d*(?:, -{0,1}\d+\.?\d*)*, (-{0,1}\d+\.?\d*), (-{0,1}\d+\.?\d*), (-{0,1}\d+\.?\d*), -{0,1}\d+\.?\d*\)|\(-{0,1}\d+\.?\d*(?:, -{0,1}\d+\.?\d*)*, (-{0,1}\d+\.?\d*), (-{0,1}\d+\.?\d*)\))/);let Ie=[0,0,0];return le&&(le[1]==="3d"?Ie=le.slice(2,5):(le.push(0),Ie=le.slice(5,9)),Ie.push(Ee(pe))),Ie},H=()=>{let re=c.current;b(re.getBoundingClientRect());let pe=0,Ee=0;for(;re;){const le=P(re);if(re.tagName==="BODY"){const Ie=re.scrollLeft||document.documentElement.scrollLeft,be=re.scrollTop||document.documentElement.scrollTop;pe+=re.offsetLeft-Ie+re.clientLeft+Number.parseInt(le[0],10),Ee+=re.offsetTop-be+re.clientTop+Number.parseInt(le[1],10)}else pe+=re.offsetLeft-re.scrollLeft+re.clientLeft+Number.parseInt(le[0],10),Ee+=re.offsetTop-re.scrollTop+re.clientTop+Number.parseInt(le[1],10);re=re.offsetParent}M({x:pe,y:Ee})},Z=re=>{re.preventDefault(),!r&&(H(),B(re),y&&N(`${p*100/y.width}% ${g*100/y.height}%`))},Q=re=>{if(r)return;S||(U(Sf),E(!0));const pe=F+ute*(re.deltaY<0?1:-1);pe>bj?U(bj):pe<Sf?(E(!1),U(Sf)):U(pe)},J=()=>{!f.current||r||(f.current.getScale()===1?f.current.setOptions({touchAction:""}):f.current.setOptions({touchAction:"none"}))};T.useEffect(()=>{r||V();const re=l(()=>{o()});return()=>{z(),re()}},[r,o,l]);const ee={top:0,left:0,width:"100%",height:"100%",position:"absolute",transition:"all 200ms",backgroundPosition:k,backgroundSize:`${F}%`,cursor:S?"zoom-in":"auto",opacity:S&&C?1:0,backgroundImage:`url(${e})`},K=()=>{if(!e)return;const re=document.createElement("a");re.href=e,re.download=`image-${Date.now()}.jpg`,re.target="_blank",re.click(),window.URL.revokeObjectURL(re.href)};return _.jsxs("div",{ref:a,className:"magnifier",onWheel:Q,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),style:{...s,position:"relative"},children:[!r&&_.jsxs("div",{className:ru.magnifier__header,children:[_.jsxs(je,{display:"flex",alignItems:"center",gap:12,children:[_.jsx(Qe,{className:ru.magnifier__header_button,onClick:o,size:q?"xs":"md",title:"خروج از تصویر","aria-label":"خروج از تصویر",icon:"bi-close"}),_.jsx(Qe,{className:ru.magnifier__header_button,onClick:K,size:q?"xs":"md",title:"دانلود تصویر","aria-label":"دانلود تصویر",icon:"bi-download"})]}),i&&_.jsxs("div",{className:ru.magnifier__header_user,children:[((te=i.avatar)==null?void 0:te.small)&&_.jsx(zs,{size:q?"28":"40",className:ru.magnifier__header_user_avatar,src:i.avatar.small,alt:i.name}),_.jsx("span",{className:ru.magnifier__header_user_name,children:i.name})]})]}),_.jsx("div",{ref:c,className:"magnifier__source",onTouchEnd:J,children:t}),!r&&!q&&_.jsx("span",{ref:d,className:"magnifier__glass",style:ee,onMouseMove:Z})]})}),fte=T.memo(dte);function Sm(){return!!document.querySelector(".chat-modal__body")}function hte({message:n}){var R;const e=At(),{contact:t}=Tn(["contact"]),r=350,s=e.isPc?384:284,i=T.useRef(),o=T.useRef(),a=T.useRef(),[l,c]=T.useState(!1),[d,f]=T.useState(!1),p=(R=n.content.files[0])==null?void 0:R.url,{cachedUrl:m,isLoading:g}=dj(p),v=T.useMemo(()=>{const I=n.content.files[0];if(!(I!=null&&I.width)||!(I!=null&&I.height))return{width:"auto",height:"auto"};if(I.width<=s)return{width:I.width,height:I.height};const A=I.height/I.width;return{width:s,height:s*A}},[s,n.content.files]),y=()=>{let I=0,A=0;if(Sm()){const k=document.querySelector(".chat-modal .bs-modal__dialog").offsetWidth,N=document.querySelector(".chat-modal .bs-modal__dialog").offsetHeight;I=(window.innerWidth-k)/2,A=(window.innerHeight-N)/2}return{offsetX:I,offsetY:A}},b=()=>{const I=i.current.getBoundingClientRect(),A={top:I.top,modalOffsetX:0,modalOffsetY:0,left:I.left,width:I.width,height:I.height},{offsetX:k,offsetY:N}=y();return A.modalOffsetX=k,A.modalOffsetY=N,A.top-=N,A.left-=k,A},S=async({property:I,from:A,to:k})=>{await de.animateValue({to:k,from:A,duration:r,step:N=>i.current.style[I]=`${N}px`})},E=async()=>{if(!l||d||n.status===Dt.ERROR||n.status===Dt.SENDING)return;f(!0),o.current=b(),a.current.style.width=`${o.current.width}px`,a.current.style.height=`${o.current.height}px`,i.current.style.width=`${o.current.width}px`,i.current.style.height=`${o.current.height}px`,i.current.style.left=`${o.current.left}px`,i.current.style.top=`${o.current.top}px`,i.current.style.position="fixed",i.current.style.zIndex="99";const I=o.current.width/o.current.height;let A,k;if(Sm()){const U=document.querySelector(".chat-modal .bs-modal__dialog"),$=U.offsetWidth,q=U.offsetHeight;A=$-40,k=q-40}else A=e.isPc?window.innerWidth-200:window.innerWidth,k=e.isPc?window.innerHeight-200:window.innerHeight-100;let N=o.current.width,D=o.current.height;A/k<I?(N=A,D=A/I):(D=k,N=k*I);let M,F;if(Sm()){const U=document.querySelector(".chat-modal .bs-modal__dialog"),$=U.offsetWidth,q=U.offsetHeight;M=$/2-N/2+o.current.modalOffsetX,F=q/2-D/2+o.current.modalOffsetY}else M=window.innerWidth/2-N/2-o.current.modalOffsetX,F=window.innerHeight/2-D/2-o.current.modalOffsetY;await Promise.all([S({to:N,property:"width",from:o.current.width}),S({to:D,property:"height",from:o.current.height}),S({to:M,property:"left",from:o.current.left+o.current.modalOffsetX}),S({to:F,property:"top",from:o.current.top+o.current.modalOffsetY})]),document.querySelector("#chat-area-messages").classList.add(mm["chat-area-messages--lock-scroll"])},C=T.useCallback(async I=>{if(!d)return;I==null||I.stopPropagation(),f(!1);const{offsetX:A,offsetY:k}=y(),N=i.current.getBoundingClientRect();let D,M;Sm()?(D=N.left-A+o.current.modalOffsetX,M=N.top-k+o.current.modalOffsetY):(D=N.left-A,M=N.top-k),await Promise.all([S({property:"width",to:o.current.width,from:N.width}),S({property:"height",to:o.current.height,from:N.height}),S({from:D,property:"left",to:o.current.left+o.current.modalOffsetX}),S({from:M,property:"top",to:o.current.top+o.current.modalOffsetY})]),i.current.style.width="100%",i.current.style.height="auto",i.current.style.left="unset",i.current.style.top="unset",i.current.style.position="relative",setTimeout(()=>i.current.style.zIndex="1",100),document.querySelector("#chat-area-messages").classList.remove(mm["chat-area-messages--lock-scroll"])},[d,i,o]);return _.jsxs("div",{ref:a,className:bf["message-picture"],onTouchStart:I=>I.stopPropagation(),onTouchEnd:I=>I.stopPropagation(),onContextMenu:I=>I.stopPropagation(),children:[_.jsx(Mr,{mounted:d,transition:"fade",duration:r,children:I=>_.jsx("div",{className:bf["message-picture__backdrop"],style:I,onClick:C})}),_.jsx(fte,{ref:i,magnifierSrc:m,disabled:!d,style:{width:v.width,height:v.height},contact:t,closeMagnifier:C,children:g?_.jsx("div",{className:bf["message-picture__img"],style:{width:v.width,height:v.height}}):_.jsx("img",{className:Te(bf["message-picture__img"],{[bf["message-picture__img--collapsed"]]:d}),src:m,alt:"",onClick:E,onLoad:()=>c(!0),onTouchStart:I=>I.stopPropagation(),onTouchEnd:I=>I.stopPropagation(),onContextMenu:I=>I.stopPropagation()})})]})}const xj={"message-sticker":"_message-sticker_1ifsf_6","message-sticker__img":"_message-sticker__img_1ifsf_13"};function pte({message:n}){var t;const e=(t=n==null?void 0:n.content)==null?void 0:t.files[0];return _.jsx("div",{className:xj["message-sticker"],children:_.jsx("img",{src:e==null?void 0:e.url,alt:"استیکر",className:xj["message-sticker__img"]})})}function mte(n){return Ax.get(`/api/api_v1.0/trigger/product_reminders?product_id=${n}`)}function gte(n){return Ax.post("/api/api_v1.0/trigger/product_reminders",de.snakize({productId:n}))}function _te(n){return Ax.delete("/api/api_v1.0/trigger/product_reminders",{data:de.snakize({productId:n})})}const vte=(n,e)=>Gn(["product-reminder",e],()=>mte(e),{enabled:n}),yte=(n={})=>Yn(gte,n),bte=(n={})=>Yn(_te,n);function xte({className:n,productId:e}){const t=Nl(),{isPc:r}=At(),{isLoggedIn:s}=Lt(["isLoggedIn"]),{isFetching:i,data:o}=vte(s,e),a=o&&o.data!==!1,{mutate:l,isLoading:c}=yte({onError:to,onSuccess:()=>{setTimeout(()=>t.invalidateQueries(["product-reminder",e]),100)}}),{mutate:d,isLoading:f}=bte({onError:to,onSuccess:()=>{setTimeout(()=>t.invalidateQueries(["product-reminder",e]),100)}}),p=m=>{m.stopPropagation(),a?d(e):l(e)};return _.jsx(Qe,{fullWidth:!0,size:r?"sm":"xxs",className:n,icon:"bi-notification",onClick:p,variant:a?"outline":"fill",loading:i||c||f,label:a?"لازم نیست اطلاع بدی":"موجود شد اطلاع بده"})}const Un={"message-product":"_message-product_14ldn_6","message-product__container":"_message-product__container_14ldn_24","message-product__container-main":"_message-product__container-main_14ldn_35","message-product__image":"_message-product__image_14ldn_40","message-product__content":"_message-product__content_14ldn_52","message-product__title":"_message-product__title_14ldn_64","message-product__star":"_message-product__star_14ldn_85","message-product__not-exist":"_message-product__not-exist_14ldn_94","message-product__rating":"_message-product__rating_14ldn_109","message-product__rating-count":"_message-product__rating-count_14ldn_120","message-product__vendor":"_message-product__vendor_14ldn_129","message-product__vendor-icon":"_message-product__vendor-icon_14ldn_141","message-product__vendor-text":"_message-product__vendor-text_14ldn_153","message-product__discount":"_message-product__discount_14ldn_158","message-product__primary-price":"_message-product__primary-price_14ldn_166","message-product__btn":"_message-product__btn_14ldn_176","message-product__status-text":"_message-product__status-text_14ldn_179","message-product__price":"_message-product__price_14ldn_188","message-product__icon":"_message-product__icon_14ldn_199"};function Ste(){const n=At().isPc;return _.jsx("div",{className:Un["message-product"],children:_.jsxs("div",{className:Un["message-product__container"],children:[_.jsxs("div",{className:Un["message-product__container-main"],children:[_.jsx("div",{children:_.jsx(vt,{width:n?80:70,height:n?80:70,radius:0})}),_.jsxs("div",{className:Un["message-product__content"],children:[_.jsx("div",{className:Un["message-product__title"],children:_.jsx(vt,{width:"100%",height:n?28:24})}),_.jsx("div",{className:Un["message-product__vendor"],children:_.jsx(vt,{width:80,height:20})}),_.jsxs(je,{mt:12,display:"flex",alignItems:"flex-start",justifyContent:"space-between",children:[_.jsx(vt,{width:80,height:n?18:15}),_.jsx(vt,{width:80,height:n?18:15})]}),_.jsx(je,{mt:8,display:"flex",justifyContent:"flex-end",alignItems:"flex-end",children:_.jsx(vt,{width:80,height:n?27:24})})]})]}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsx(vt,{width:160,height:n?40:32}),_.jsx(vt,{width:120,height:n?40:32})]})]})})}const Ete=()=>{const{injection:n}=Lt(["injection"]);return e=>{n!=null&&n.addToCart?n.addToCart(e):console.warn("add to cart should be injected from host project")}};function wte({message:n,contactHashId:e}){var C,R,I,A,k;const t=(C=n==null?void 0:n.content)==null?void 0:C.entityId,r=Ete(),{isPc:s}=At(),i=Dr(),{isError:o,isLoading:a,data:l}=yD({productId:t},{enabled:!!t}),c=de.getDiscountPercent(l==null?void 0:l.primaryPrice,l==null?void 0:l.price),d=i?`${mn.baseUrl}/${(R=l==null?void 0:l.vendor)==null?void 0:R.identifier}/product/${l==null?void 0:l.id}?form=chat&page=${e}`:`/${(I=l==null?void 0:l.vendor)==null?void 0:I.identifier}/product/${l==null?void 0:l.id}?form=chat&page=${e}`,f=i?`${mn.baseUrl}/${(A=l==null?void 0:l.vendor)==null?void 0:A.identifier}`:`/${(k=l==null?void 0:l.vendor)==null?void 0:k.identifier}`,p=()=>{window.open(d,"_blank")},m=()=>{window.open(f,"_blank")},g=(N,D)=>{N.stopPropagation(),r(D)},v=l==null?void 0:l.isAvailable,y=l==null?void 0:l.isSaleable,b=l==null?void 0:l.vendor.isActive,S=l==null?void 0:l.canAddToCart,E=T.useMemo(()=>{if(b)if(S)if(v){if(!y)return"NOT_EXIST"}else return"UNAVAILABLE";else return"VENDOR_PERSON_INACTIVE";else return"VENDOR_INACTIVE";return"ACTIVE"},[b,v,y]);return a||o?_.jsx(Ste,{}):_.jsx("div",{onClick:p,className:Un["message-product"],children:_.jsxs("div",{className:Un["message-product__container"],children:[_.jsxs("div",{className:Un["message-product__container-main"],children:[_.jsx("div",{onClick:p,children:_.jsx("img",{className:Un["message-product__image"],src:l.photo.small,alt:l.title})}),_.jsxs("div",{className:Un["message-product__content"],children:[_.jsx("p",{onClick:p,className:Un["message-product__title"],children:l.title}),_.jsxs("div",{onClick:m,className:Un["message-product__vendor"],title:`${l.vendor.city.title} | ${l.vendor.title}`,children:[_.jsx("span",{className:Te("bi-vendor-fill",Un["message-product__vendor-icon"])}),_.jsx("div",{className:Un["message-product__vendor-text"],children:`${l.vendor.city.title} | ${l.vendor.title}`})]}),_.jsxs(je,{mt:8,display:"flex",alignItems:"flex-start",justifyContent:"space-between",children:[!!l.rating&&_.jsxs(je,{display:"flex",children:[_.jsx("span",{className:Te("bi-star-fill",Un["message-product__star"])}),_.jsx("span",{className:Un["message-product__rating"],children:l.rating}),_.jsxs("span",{className:Un["message-product__rating-count"],children:["(",l.reviewCount," نظر)"]})]}),!!l.primaryPrice&&E==="ACTIVE"&&_.jsxs(je,{display:"flex",alignItems:"flex-end",children:[_.jsx("div",{className:Un["message-product__primary-price"],children:de.numberSeparator(de.rialToToman(l.primaryPrice))}),_.jsxs("div",{className:Un["message-product__discount"],children:["%",c]})]})]}),E==="NOT_EXIST"&&_.jsxs(je,{className:Un["message-product__not-exist"],mt:8,display:"flex",justifyContent:"flex-end",alignItems:"center",children:[_.jsx("hr",{}),_.jsx("span",{children:"ناموجود"})]}),E==="ACTIVE"&&_.jsx(je,{mt:8,display:"flex",justifyContent:"flex-end",alignItems:"center",children:_.jsxs(je,{display:"flex",alignItems:"center",children:[_.jsx("span",{className:Un["message-product__price"],children:de.numberSeparator(de.rialToToman(l.price))}),_.jsx("span",{className:Te("bi-toman",Un["message-product__icon"])})]})})]})]}),_.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[l.canAddToCart&&E==="ACTIVE"&&_.jsx(Qe,{fullWidth:!0,className:Un["message-product__btn"],size:s?"sm":"xxs",onClick:N=>g(N,l),iconPosition:"center-start",icon:"bi-shopping-cart",children:"افزودن به سبد"}),E==="UNAVAILABLE"&&_.jsx("p",{className:Un["message-product__status-text"],children:"محصول در دسترس نیست."}),E==="VENDOR_INACTIVE"&&_.jsx("p",{className:Un["message-product__status-text"],children:"غرفه غیرفعاله."}),E==="VENDOR_PERSON_INACTIVE"&&_.jsx("p",{className:Un["message-product__status-text"],children:"غرفه‌دار مدتی نبوده."}),E==="NOT_EXIST"&&_.jsx(xte,{className:Un["message-product__btn"],productId:l.id}),_.jsx(Qe,{variant:"outline",color:"secondary",size:s?"sm":"xxs",icon:s?void 0:"bi-angle-left",iconPosition:s?void 0:"center-end",onClick:p,children:"جزئیات محصول"})]})]})})}const Ks={message__reply:"_message__reply_1i5q4_6","message__reply--sender":"_message__reply--sender_1i5q4_17","message__reply--receiver":"_message__reply--receiver_1i5q4_20","message__reply-photo":"_message__reply-photo_1i5q4_23","message__reply-body":"_message__reply-body_1i5q4_32","message__reply-body-sender":"_message__reply-body-sender_1i5q4_38","message__reply-body-message":"_message__reply-body-message_1i5q4_45",message__footer:"_message__footer_1i5q4_51","message__footer-seen":"_message__footer-seen_1i5q4_56","message__footer-unseen":"_message__footer-unseen_1i5q4_63","message__footer-sending":"_message__footer-sending_1i5q4_70","message__footer-error":"_message__footer-error_1i5q4_77","message__footer-time":"_message__footer-time_1i5q4_84"},Ss={"message-agreement":"_message-agreement_1ph1l_6","message-agreement__order":"_message-agreement__order_1ph1l_23","message-agreement__order-title":"_message-agreement__order-title_1ph1l_26","message-agreement__order-line":"_message-agreement__order-line_1ph1l_31","message-agreement__order-details-text":"_message-agreement__order-details-text_1ph1l_36","message-agreement__order-items":"_message-agreement__order-items_1ph1l_41","message-agreement__order-items-product":"_message-agreement__order-items-product_1ph1l_47","message-agreement__order-items-more":"_message-agreement__order-items-more_1ph1l_55","message-agreement__loading":"_message-agreement__loading_1ph1l_69","message-agreement__loading--owner":"_message-agreement__loading--owner_1ph1l_73"};function Tte({isOwner:n}){return _.jsxs("section",{className:Ss["message-agreement"],children:[_.jsxs("section",{className:Ss["message-agreement__order"],children:[_.jsx(vt,{width:"70%",height:21,className:Ss["message-agreement__order-title"]}),_.jsxs("div",{className:Ss["message-agreement__order-items"],children:[_.jsx(vt,{width:44,height:44}),_.jsx(je,{mr:8,children:_.jsx(vt,{width:44,height:44})})]})]}),_.jsx("section",{children:_.jsx("div",{className:Te(Ss["message-agreement__loading"],{[Ss["message-agreement__loading--owner"]]:n}),children:_.jsx(vt,{width:"100%",height:"100%"})})})]})}function Cte({message:n}){var V,z,B,P,H,Z,Q,J,ee;const e=Cc(),{emitEvent:t}=Mt.useEmitter(),{contact:r}=Tn(["contact"]),{currentUser:s}=Lt(["currentUser"]),o=+n.sender.id===(s==null?void 0:s.id),a=(V=n==null?void 0:n.content)==null?void 0:V.entityId,l=o?"vendor":"user",{data:c,isError:d,isLoading:f,refetch:p}=vJ({operator:l,agreementId:a},{enabled:!!a}),{mutate:m,isLoading:g}=_J(),v={[Wr.REVIEW]:!1,[Wr.OPEN_LINK]:!1,[Wr.ACCEPT_REQUEST]:g,[Wr.REJECT_REQUEST]:g},y=((z=c==null?void 0:c.details)==null?void 0:z.variant)===Bc.INFO?"var(--gray-600)":((B=c==null?void 0:c.details)==null?void 0:B.variant)===Bc.SUCCESS?"var(--success)":"var(--error)",b=[Bc.INFO,Bc.REVIEW].includes((P=c==null?void 0:c.details)==null?void 0:P.variant)?"bi-info":((H=c==null?void 0:c.details)==null?void 0:H.variant)===Bc.SUCCESS?"bi-tick":"bi-cancel",S=T.useMemo(()=>{var K;return(K=c==null?void 0:c.items)==null?void 0:K.map(W=>({...W,product:{name:W.title,price:W.price,id:W.productId,photos:W.photos,vendor:r==null?void 0:r.vendor,...W.product}}))},[c==null?void 0:c.items,r==null?void 0:r.vendor]),E=o?((Z=c==null?void 0:c.details)==null?void 0:Z.variant)===Bc.REVIEW:(Q=c==null?void 0:c.buttons)==null?void 0:Q.some(K=>K.action===Wr.REVIEW),{data:C,isError:R,isLoading:I,refetch:A}=wD({type:o?"vendor":"user",itemIds:S==null?void 0:S.map(K=>K.id)},{enabled:!!E}),k=C==null?void 0:C.unreviewedItems,N=f||I&&E,D=d||R&&E,M=K=>{t(Fa.SHOW_ADD_OR_EDIT_REVIEW_MODAL,{items:K,onClose:A})},F=K=>{o?window.open(`${mn.vendorDashboardUrl}/orders/${K}`,"_blank"):e(`/account/orders/${K}`)},U=K=>{const W={[Wr.REVIEW]:"bi-star",[Wr.OPEN_LINK]:"bi-angle-left",[Wr.REJECT_REQUEST]:"bi-close",[Wr.ACCEPT_REQUEST]:"bi-tick-single"},te={[Wr.REVIEW]:"center-start",[Wr.OPEN_LINK]:"center-end",[Wr.REJECT_REQUEST]:"center-start",[Wr.ACCEPT_REQUEST]:"center-start"};return{icon:W[K],position:te[K]}},$=T.useMemo(()=>C&&Object.values((C==null?void 0:C.reviewStatus)||{}).includes(!1),[C]),q=K=>{const W={status:K===Wr.ACCEPT_REQUEST?yO.ACCEPTED:yO.REJECTED};m({agreementId:c.id,payload:W},{onSuccess:()=>{p()},onError:te=>{to(te)}})},G=K=>{({[Wr.REVIEW]:()=>M(k),[Wr.REJECT_REQUEST]:()=>q(K),[Wr.ACCEPT_REQUEST]:()=>q(K),[Wr.OPEN_LINK]:()=>F(c==null?void 0:c.orderId)})[K]()};return N||D||!c?_.jsx(Tte,{isOwner:o}):_.jsx("section",{className:Ss["message-agreement"],"data-from":"chat","data-component":"agreement-request",children:_.jsxs("div",{className:Ss["message-agreement__order"],children:[_.jsx("span",{className:Ss["message-agreement__order-title"],children:c.description}),_.jsxs("div",{className:Ss["message-agreement__order-items"],children:[(J=c==null?void 0:c.items)==null?void 0:J.slice(0,4).map(K=>_.jsx("img",{className:Ss["message-agreement__order-items-product"],src:K.photo[0].resized.sm,alt:K.title},K==null?void 0:K.id)),((ee=c==null?void 0:c.items)==null?void 0:ee.length)>4&&_.jsx("div",{className:Ss["message-agreement__order-items-more"],children:`+${c.items.length-4}`})]}),_.jsx("div",{className:Ss["message-agreement__order-line"]}),k&&k.length===0?$?_.jsxs(je,{display:"flex",gap:4,mt:10,alignItems:"center",children:[_.jsx(Mn,{name:"bi-star-fill",size:"20",color:"var(--warning)"}),_.jsx("span",{className:Ss["message-agreement__order-details-text"],children:"ثبت رضایت شد"})]}):_.jsxs(je,{display:"flex",gap:4,mt:10,alignItems:"center",children:[_.jsx(Mn,{name:"bi-star-fill",size:"20",color:"var(--warning)"}),_.jsx("span",{className:Ss["message-agreement__order-details-text"],children:"تجربه خرید ثبت شد"})]}):(c==null?void 0:c.details)&&_.jsxs(je,{display:"flex",gap:4,mt:10,alignItems:"center",children:[_.jsx(Mn,{name:b,size:"20",color:y}),_.jsx("span",{className:Ss["message-agreement__order-details-text"],children:c.details.text})]}),(c==null?void 0:c.buttons)&&(!k||(k==null?void 0:k.length)>0)&&_.jsx(je,{display:"flex",gap:4,mt:10,alignItems:"center",flexDirection:"column",children:c.buttons.map((K,W)=>_.jsx(Qe,{color:K.priority,variant:K.priority===s7.PRIMARY?"fill":"outline",label:K.label,iconPosition:U(K.action).position,icon:U(K.action).icon,loading:v[K.action],onClick:()=>G(K.action),fullWidth:!0,size:"xs"},W))})]})})}const Ar={"message-satisfaction":"_message-satisfaction_4uwkb_6","message-satisfaction__order":"_message-satisfaction__order_4uwkb_21","message-satisfaction__cancel":"_message-satisfaction__cancel_4uwkb_21","message-satisfaction__order-title":"_message-satisfaction__order-title_4uwkb_24","message-satisfaction__order-items":"_message-satisfaction__order-items_4uwkb_30","message-satisfaction__order-items-product":"_message-satisfaction__order-items-product_4uwkb_36","message-satisfaction__order-items-more":"_message-satisfaction__order-items-more_4uwkb_43","message-satisfaction__review":"_message-satisfaction__review_4uwkb_53","message-satisfaction__pending":"_message-satisfaction__pending_4uwkb_58","message-satisfaction__problem":"_message-satisfaction__problem_4uwkb_58","message-satisfaction__success":"_message-satisfaction__success_4uwkb_58","message-satisfaction__pending-text":"_message-satisfaction__pending-text_4uwkb_70","message-satisfaction__problem-text":"_message-satisfaction__problem-text_4uwkb_70","message-satisfaction__success-text":"_message-satisfaction__success-text_4uwkb_70","message-satisfaction__form":"_message-satisfaction__form_4uwkb_76","message-satisfaction__loading":"_message-satisfaction__loading_4uwkb_81","message-satisfaction__loading--owner":"_message-satisfaction__loading--owner_4uwkb_85"};function Ite({isOwner:n}){return _.jsxs("section",{className:Ar["message-satisfaction"],children:[_.jsxs("section",{className:Ar["message-satisfaction__order"],children:[_.jsx(vt,{width:"70%",height:21,className:Ar["message-satisfaction__order-title"]}),_.jsxs("div",{className:Ar["message-satisfaction__order-items"],children:[_.jsx(vt,{width:44,height:44}),_.jsx(je,{mr:8,children:_.jsx(vt,{width:44,height:44})})]})]}),_.jsx("section",{children:_.jsx("div",{className:Te(Ar["message-satisfaction__loading"],{[Ar["message-satisfaction__loading--owner"]]:n}),children:_.jsx(vt,{width:"100%",height:"100%"})})})]})}function Rte({message:n}){var J,ee,K,W,te,re,pe,Ee;const e=Cc(),{emitEvent:t}=Mt.useEmitter(),{publishEvent:r}=Fr(),{contact:s}=Tn(["contact"]),{currentUser:i}=Lt(["currentUser"]),o=1,a=0,l=s==null?void 0:s.id,c=(J=s==null?void 0:s.vendor)==null?void 0:J.id,d=+n.sender.id,f=(ee=n==null?void 0:n.content)==null?void 0:ee.entityId,p=d===(i==null?void 0:i.id),{data:m,isError:g,isLoading:v,refetch:y}=hJ({limit:o,offset:a,customerId:l,orderId:f},{enabled:p&&!!f}),{data:b,isError:S,isLoading:E,refetch:C}=pJ({limit:o,offset:a,vendorId:c,orderId:f},{enabled:!p&&!!f&&!!c}),R=m?g:S,I=m?y:C,A=((K=m==null?void 0:m.orders)==null?void 0:K[0])||((W=b==null?void 0:b.parcels)==null?void 0:W[0]),k=((te=A==null?void 0:A.exactStatus)==null?void 0:te.id)===Lp.SATISFIED,N=T.useMemo(()=>{var le;return(le=A==null?void 0:A.items)==null?void 0:le.map(Ie=>({...Ie,product:{name:Ie.title,price:Ie.price,id:Ie.productId,photos:Ie.photos,vendor:s==null?void 0:s.vendor,...Ie.product}}))},[A==null?void 0:A.items,s==null?void 0:s.vendor]),{data:D,isError:M,isLoading:F,refetch:U}=wD({type:p?"vendor":"user",itemIds:N==null?void 0:N.map(le=>le.id)},{enabled:k}),$=D==null?void 0:D.unreviewedItems,q=(m?v:E)||F&&k,G=k?$!=null&&$.length||M?"رضایت ثبت شد":"تجربه خرید ثبت شد":"سفارش رو تحویل گرفتید؟ راضی بودید؟",V=le=>{t(Fa.SHOW_ADD_OR_EDIT_REVIEW_MODAL,{items:le,onClose:U})},{mutate:z,isLoading:B}=mJ({onSuccess:()=>{setTimeout(I,1250),V(XQ(N))}}),P=()=>{z({orderId:f,vendorId:c}),r("chatSatisfactionClick",{invoiceId:f})},H=()=>{z({orderId:f,vendorId:c}),requestIdleCallback(()=>{r("chatProblemResolvedClick",{invoiceId:f})})},Z=()=>{e(`/account/orders/${A==null?void 0:A.hashId}?submit-problem=${c}`)},Q=()=>{p?window.open(`${mn.vendorDashboardUrl}/orders/${A.id}`,"_blank"):e(`/account/orders/${A==null?void 0:A.hashId}`)};return q||R||!A?_.jsx(Ite,{isOwner:p}):_.jsxs("section",{className:Ar["message-satisfaction"],"data-from":"chat","data-component":"satisfaction-request",children:[_.jsxs("section",{className:Ar["message-satisfaction__order"],children:[_.jsxs("span",{className:Ar["message-satisfaction__order-title"],children:[k&&_.jsx(Mn,{name:"bi-tick-single",color:"var(--gray-800)"}),G]}),_.jsxs("div",{className:Ar["message-satisfaction__order-items"],children:[N==null?void 0:N.slice(0,4).map(le=>_.jsx("img",{className:Ar["message-satisfaction__order-items-product"],src:le.product.photos[0].resized.sm,alt:le.product.name},le==null?void 0:le.id)),(A==null?void 0:A.items.length)>4&&_.jsx("div",{className:Ar["message-satisfaction__order-items-more"],children:_.jsx("i",{className:"bi-more"})})]})]}),((re=A==null?void 0:A.exactStatus)==null?void 0:re.id)===Lp.POSTED?p?_.jsxs("div",{className:Ar["message-satisfaction__pending"],children:[_.jsx(Mn,{name:"bi-info",color:"var(--primary)"}),_.jsx("span",{className:Ar["message-satisfaction__pending-text"],children:"منتظر ثبت رضایت"})]}):_.jsxs("div",{className:Ar["message-satisfaction__form"],children:[_.jsx(Qe,{fullWidth:!0,size:"md",icon:"bi-tick-single",label:"تحویل گرفتم و رضایت دارم",loading:B,onClick:P}),_.jsx(je,{mt:8,children:_.jsx(Qe,{fullWidth:!0,variant:"outline",size:"md",icon:"bi-angle-left",iconPosition:"end",label:"مشاهده جزئیات سفارش",disabled:B,onClick:Z})})]}):k?($==null?void 0:$.length)>0?_.jsx("section",{className:Ar["message-satisfaction__review"],children:p?_.jsxs("div",{className:Ar["message-satisfaction__success"],children:[_.jsx(Mn,{name:"bi-info",color:"var(--primary)"}),_.jsx("span",{className:Ar["message-satisfaction__success-text"],children:"منتظر ثبت تجربه"})]}):_.jsxs(je,{mt:16,display:"flex",flexDirection:"column",gap:16,children:["با ثبت تجربه خریدت‌ به مشتری‌های بعدی این محصول کمک می‌کنی.",_.jsx(Qe,{onClick:()=>V($),label:"ثبت تجربه",icon:"bi-star",size:"md",fullWidth:!0})]})}):null:p&&((pe=A==null?void 0:A.exactStatus)==null?void 0:pe.id)!==Lp.REFUND?_.jsxs("div",{className:Ar["message-satisfaction__problem"],children:[_.jsx(Mn,{name:"bi-info",color:"var(--primary)"}),_.jsx("span",{className:Ar["message-satisfaction__problem-text"],children:"در حال بررسی وضعیت سفارش"})]}):_.jsxs(je,{mt:16,gap:8,display:"flex",flexDirection:"column",className:Ar["message-satisfaction__cancel"],children:[((Ee=A==null?void 0:A.exactStatus)==null?void 0:Ee.id)===Lp.PROBLEM&&_.jsx(Qe,{fullWidth:!0,size:"md",icon:"bi-tick-single",label:"مشکلم حل شد و راضی هستم",loading:B,onClick:H}),_.jsx(Qe,{fullWidth:!0,variant:"outline",icon:"bi-angle-left",iconPosition:"end",label:"مشاهده وضعیت سفارش",size:"md",onClick:Q})]})]})}const su={"order-process":"_order-process_1opdr_10","order-process__header":"_order-process__header_1opdr_13","order-process__header-title":"_order-process__header-title_1opdr_16","order-process__divider--sender":"_order-process__divider--sender_1opdr_20","order-process__divider--receiver":"_order-process__divider--receiver_1opdr_23","order-process__message":"_order-process__message_1opdr_26","chat-widget-mobile":"_chat-widget-mobile_1opdr_1"};function Ate({message:n}){var r,s,i;const{currentUser:e}=Lt(["currentUser"]),t=(s=(r=n.content)==null?void 0:r.orderProcess)==null?void 0:s.data;return _.jsxs("section",{className:su["order-process"],children:[_.jsx("header",{className:su["order-process__header"],children:_.jsx("span",{className:su["order-process__header-title"],children:(t==null?void 0:t.title)||""})}),_.jsx("hr",{className:su[`order-process__divider--${+((i=n.sender)==null?void 0:i.id)==+(e==null?void 0:e.id)?"sender":"receiver"}`]}),_.jsxs(je,{p:8,children:[(t==null?void 0:t.code)&&_.jsx(Ic,{value:t.code,children:({copy:o,copied:a})=>_.jsxs(je,{mb:8,display:"flex",alignItems:"center",justifyContent:"space-between",children:[_.jsxs("span",{className:su["order-process__message"],children:["کد: ",t.code]}),_.jsx(Qe,{size:"xs",label:"کپی",onClick:o,variant:"outline",icon:a?"bi-tick-single":"bi-copy"})]})}),_.jsx("span",{className:su["order-process__message"],children:(t==null?void 0:t.text)||""}),(t==null?void 0:t.link)&&_.jsx(je,{mt:8,children:_.jsx($d,{target:"_blank",rel:"noreferrer",href:t.link,label:t.linkTitle||"لینک"})})]})]})}const In={"options-modal__item":"_options-modal__item_14wo3_6","options-modal__item-icon":"_options-modal__item-icon_14wo3_28","options-modal__item-title":"_options-modal__item-title_14wo3_37","options-popover":"_options-popover_14wo3_49","options-popover__item":"_options-popover__item_14wo3_69","options-popover__item-icon":"_options-popover__item-icon_14wo3_128"},Sj={"delete-confirm__btn":"_delete-confirm__btn_1o4au_6"};function kte({show:n,onDelete:e,onClose:t}){const r=()=>{setTimeout(()=>{e(),t()},0)};return _.jsx(Md,{show:n,onClose:t,title:"حذف پیام",confirmLabel:"حذف پیام",cancelLabel:"لغو",cancelColor:"primary",cancelVariant:At().isMobile?"text":"outline",confirmVariant:At().isMobile?"text":"fill",confirmButtonProps:{icon:"bi-delete",className:Sj["delete-confirm__btn"]},cancelButtonProps:{icon:"bi-close",className:Sj["delete-confirm__btn"]},onConfirm:r,children:_.jsxs("p",{children:["این پیام برای طرف مقابل نیز حذف خواهد شد.",_.jsx("br",{}),"آیا از حذف این پیام مطمئن هستید؟"]})})}function Lte({mode:n,show:e,coords:t,message:r,onClose:s,options:i={copy:!0,reply:!0,delete:!0,edit:!0,forward:!0,select:!0}}){var P;const[o,a]=T.useState(!1),{chat:l,contact:c}=Tn(["chat","contact"]),{setSelectedMessageIds:d,setForwardModalData:f,setIsEditing:p}=ai(),{deleteMessage:m,replyMessage:g,editMessage:v}=ro(),{pushOnce:y}=Si(),{currentUser:b,chatModalData:S}=Lt(["currentUser","chatModalData"]),{mutate:E,isLoading:C}=PY({onSuccess:()=>{v(null),m==null||m(r.id)}}),{showErrorSnackbar:R}=Mt.useSnackbar(),I=i.copy&&r.content.text&&r.messageType!==Fe.CALL,A=i.reply&&r.status!==Dt.ERROR,k=i.delete&&!r.seenAt&&r.messageType!==Fe.CALL&&r.status!==Dt.ERROR&&(b==null?void 0:b.id)===+r.sender.id,N=i.edit&&!r.seenAt&&!!((P=r.content)!=null&&P.text)&&r.messageType!==Fe.CALL&&r.status!==Dt.ERROR&&(b==null?void 0:b.id)===+r.sender.id||(l==null?void 0:l.chatType)===Bt.CHANNEL&&bS(c),D=i.forward&&!S&&![Fe.ORDER,Fe.REVIEW,Fe.FILE,Fe.CALL].includes(r.messageType)&&((b==null?void 0:b.id)===+r.sender.id||[Fe.TEXT,Fe.PRODUCT].includes(r.messageType)),M=i.select&&D,F=async H=>{H==null||H.stopPropagation(),s(),await de.sleep(250),a(!0)},U=H=>{H==null||H.stopPropagation(),y(()=>{g(null)}),setTimeout(()=>{var Z;s(),g(r),(Z=document.querySelector("#chat-message-form-input"))==null||Z.focus()},0)},$=H=>{H==null||H.stopPropagation(),f(r),setTimeout(()=>{s()},0)},q=H=>{H==null||H.stopPropagation(),d(Z=>{g(null),v(null);const Q=new Set(Z);return Q.add(String(r.id)),Q}),setTimeout(()=>{s()},0)},G=H=>{H==null||H.stopPropagation(),setTimeout(()=>{s(),p(!0),v(r)},0)},V=H=>{H==null||H.stopPropagation(),setTimeout(()=>{E({messageIds:[r==null?void 0:r.id]},{onError:Z=>{var Q,J,ee;(ee=(J=(Q=Z.response)==null?void 0:Q.data)==null?void 0:J.error)!=null&&ee.messages&&Z.response.data.error.messages.forEach(K=>{R(K.text)})}})},0)},z=T.useMemo(()=>{var H;return(H=document.getSelection())!=null&&H.toString()?document.getSelection().toString():r.content.text},[r]),B=T.useCallback(()=>{a(!1)},[]);return _.jsxs("div",{children:[n==="modal"?_.jsx(lr,{showClose:!0,showHeader:!0,show:e,onClose:s,className:"dataset-inp-ChatMessageOptionsMenu",children:_.jsxs("div",{className:In["options-modal"],children:[I&&_.jsx(Ic,{value:z,children:({copy:H,copied:Z})=>_.jsxs("button",{className:In["options-modal__item"],onClick:async()=>{H(),await de.sleep(200),s()},children:[_.jsx("i",{className:Te(`bi-${Z?"tick-single":"copy"}`,In["options-modal__item-icon"])}),_.jsx("span",{className:In["options-modal__item-title"],children:"کپی"})]})}),A&&_.jsxs("button",{className:In["options-modal__item"],onClick:U,children:[_.jsx("i",{className:Te("bi-reply",In["options-modal__item-icon"])}),_.jsx("span",{className:In["options-modal__item-title"],children:"پاسخ"})]}),D&&_.jsxs("button",{className:In["options-modal__item"],onClick:$,children:[_.jsx("div",{className:In["options-modal__item-icon"],children:_.jsx("i",{className:"bi-arrow-up-right"})}),_.jsx("span",{className:In["options-modal__item-title"],children:"ارسال به"})]}),N&&_.jsxs("button",{className:In["options-modal__item"],onClick:G,children:[_.jsx("div",{className:In["options-modal__item-icon"],children:_.jsx("i",{className:"bi-edit-square"})}),_.jsx("span",{className:In["options-modal__item-title"],children:"ویرایش"})]}),k&&_.jsxs("button",{className:In["options-modal__item"],onClick:F,children:[_.jsx("div",{className:In["options-modal__item-icon"],children:C?_.jsx(Cr,{size:"md",color:"black"}):_.jsx("i",{className:"bi-delete"})}),_.jsx("span",{className:In["options-modal__item-title"],children:"حذف"})]}),M&&_.jsxs("button",{className:In["options-modal__item"],onClick:q,children:[_.jsx("div",{className:In["options-modal__item-icon"],children:_.jsx("i",{className:"bi-tick-circle"})}),_.jsx("span",{className:In["options-modal__item-title"],children:"انتخاب"})]})]})}):_.jsx(tf,{className:"dataset-inp-ChatMessageOptionsMenu",show:e,coords:t,transition:"pop-top-right",position:"bottom-left",getAwayThreshold:75,onClose:H=>{H==null||H.stopPropagation(),s()},children:_.jsxs("div",{className:In["options-popover"],children:[I&&_.jsx(Ic,{value:z,children:({copy:H,copied:Z})=>_.jsxs("button",{className:In["options-popover__item"],onClick:async Q=>{Q==null||Q.stopPropagation(),H(),await de.sleep(200),s()},children:[_.jsx("div",{className:In["options-popover__item-icon"],children:_.jsx("i",{className:`bi-${Z?"tick-single":"copy"}`})}),_.jsx("span",{children:"کپی"})]})}),A&&_.jsxs("button",{className:In["options-popover__item"],onClick:U,children:[_.jsx("div",{className:In["options-popover__item-icon"],children:_.jsx("i",{className:"bi-reply"})}),_.jsx("span",{children:"پاسخ"})]}),D&&_.jsxs("button",{className:In["options-popover__item"],onClick:$,children:[_.jsx("div",{className:In["options-popover__item-icon"],children:_.jsx("i",{className:"bi-arrow-up-right"})}),_.jsx("span",{children:"ارسال به"})]}),N&&_.jsxs("button",{className:In["options-popover__item"],onClick:G,children:[_.jsx("div",{className:In["options-popover__item-icon"],children:_.jsx("i",{className:"bi-edit-square"})}),_.jsx("span",{children:"ویرایش"})]}),k&&_.jsxs("button",{className:In["options-popover__item"],onClick:F,children:[_.jsx("div",{className:In["options-popover__item-icon"],children:C?_.jsx(Cr,{size:"sm",color:"black"}):_.jsx("i",{className:"bi-delete"})}),_.jsx("span",{children:"حذف"})]}),M&&_.jsxs("button",{className:In["options-popover__item"],onClick:q,children:[_.jsx("div",{className:In["options-popover__item-icon"],children:_.jsx("i",{className:"bi-tick-circle"})}),_.jsx("span",{children:"انتخاب"})]})]})}),_.jsx(kte,{show:o,onDelete:V,onClose:B})]})}const Mte=T.memo(Lte);function Nte({message:n,chatType:e,contactId:t,contactName:r,replyMessage:s,contactHashId:i,replaceMessage:o,longPressTimerRef:a,selectedMessageIds:l,setRepliedMessageId:c,setScrollToRepliedMessage:d}){var ee,K,W,te,re,pe,Ee,le,Ie;const{isMobile:f,isForceMobile:p}=At(),{pushOnce:m}=Si(),{virtuosoRef:g}=ro(),{currentUser:v,featureFlags:y}=Lt(["featureFlags","currentUser"]),{messages:b}=Tn(["messages"]),S=T.useRef(),E=T.useRef(),[C,R]=T.useState(!1),[I,A]=T.useState(!1),[k,N]=T.useState({top:0,left:0}),{mutateAsync:D}=xD(),{mutateAsync:M}=Hc(),F=(ee=y==null?void 0:y.features)==null?void 0:ee.editMessage,U=((K=y==null?void 0:y.features)==null?void 0:K.deleteMessage)&&!nm(e),$=(W=y==null?void 0:y.features)==null?void 0:W.forward,q=$&&!!((te=y==null?void 0:y.features)!=null&&te.selectMessage),G=+((re=n.sender)==null?void 0:re.id)==+(v==null?void 0:v.id),V=v&&t===v.id,z=T.useMemo(()=>de.gregoryDate(n.createdAt).format("HH:mm"),[n.createdAt]),B=T.useMemo(()=>({copy:!0,reply:!nm(e),edit:F,delete:U,select:q,forward:$}),[e,F,U,q,$]),P=T.useCallback(()=>{A(!1)},[]),H=async be=>{var ge;if(![Dt.ERROR,Dt.SENDING].includes(n.status)){f&&l.size===0&&!((ge=E.current)!=null&&ge.contains(be.target))&&A(!0);return}try{R(!0);const Ae=_X(n);if(n.uploadPayload){const{data:tt}=await D(Ae.uploadPayload);Ae.attachment={files:tt.files}}const Re=await M(Ae);o(n.uuid,{...Re.data,uuid:n.uuid,status:Dt.SENT})}catch(Ae){no(Ae)}finally{R(!1)}},Z=()=>{var be;!f&&l.size===0&&(m(()=>{s(null)}),s(n),(be=document.querySelector("#chat-message-form-input"))==null||be.focus())},Q=T.useCallback(be=>{l.size===0&&!a.current&&n.status!==Dt.SENDING&&(be.preventDefault(),N({top:be.pageY,left:be.pageX}),A(!0))},[l,a,n.status]);T.useEffect(()=>{const be=S.current;return be==null||be.addEventListener("contextmenu",Q),()=>{be==null||be.removeEventListener("contextmenu",Q)}},[Q]);const J=async(be,ge)=>{try{await vS(be,b,g)==="not-found"&&d(be),c(ge)}catch{}};return _.jsxs(_.Fragment,{children:[_.jsxs("div",{ref:S,className:Ks.message,onClick:H,onDoubleClick:Z,children:[_.jsxs("div",{ref:E,children:[n.repliedMessage&&_.jsxs("div",{className:Te(Ks.message__reply,{[Ks["message__reply--sender"]]:G,[Ks["message__reply--receiver"]]:!G}),onClick:()=>{var be;return J((be=n==null?void 0:n.repliedMessage)==null?void 0:be.id,n==null?void 0:n.id)},children:[n.repliedMessage.messageType===Fe.PICTURE&&_.jsx("img",{className:Ks["message__reply-photo"],src:n.repliedMessage.content.files[0].url}),_.jsxs("div",{className:Ks["message__reply-body"],children:[_.jsxs("span",{className:Ks["message__reply-body-sender"],children:[((Ee=(pe=n==null?void 0:n.repliedMessage)==null?void 0:pe.sender)==null?void 0:Ee.id)==(v==null?void 0:v.id)?"شما":`${r}`,":"]}),_.jsx("p",{className:Ks["message__reply-body-message"],children:Ul(n.repliedMessage)})]})]}),n.messageType===Fe.VOICE&&_.jsx(Cee,{message:n}),n.messageType===Fe.PICTURE&&_.jsx(hte,{message:n}),n.messageType===Fe.VIDEO&&_.jsx(Nee,{message:n}),n.messageType===Fe.VENDOR&&_.jsx(Uee,{message:n}),n.messageType===Fe.USER&&_.jsx(Eee,{message:n}),n.messageType===Fe.STICKER&&_.jsx(pte,{message:n}),n.messageType===Fe.REVIEW&&_.jsx(jee,{message:n}),n.messageType===Fe.ORDER&&_.jsx(Rte,{message:n}),n.messageType===Fe.AGREEMENT&&_.jsx(Cte,{message:n}),n.messageType===Fe.STORY&&_.jsx(kee,{message:n}),n.messageType===Fe.ORDER_PROCESS&&_.jsx(Ate,{message:n}),n.messageType===Fe.PRODUCT&&_.jsx(wte,{message:n,contactHashId:i}),n.messageType===Fe.FILE&&_.jsx(wee,{message:n}),n.messageType===Fe.CALL&&_.jsx(Tee,{message:n}),n.messageType===Fe.COUPON&&_.jsx(Hee,{message:n}),n.messageType===Fe.FACTOR&&_.jsx(Xee,{message:n})]}),_.jsx(xee,{message:n}),!G&&!!((Ie=(le=n==null?void 0:n.content)==null?void 0:le.metadata)!=null&&Ie.receiverCouponHint)&&_.jsx(Qee,{}),_.jsxs("div",{className:Ks.message__footer,children:[_.jsx("span",{className:Ks["message__footer-time"],children:z}),!nm(e)&&_.jsxs(_.Fragment,{children:[n.status===Dt.ERROR&&!C&&_.jsx("i",{className:Te("bi-info",Ks["message__footer-error"])}),(n.status===Dt.SENDING||C)&&_.jsx("i",{className:Te("bi-time",Ks["message__footer-sending"])}),G&&(n.seenAt||V)&&!C&&n.status!==Dt.SENDING&&n.status!==Dt.ERROR&&_.jsx("i",{className:Te("bi-tick-double",Ks["message__footer-seen"])}),G&&!n.seenAt&&!V&&!C&&n.status!==Dt.SENDING&&n.status!==Dt.ERROR&&_.jsx("i",{className:Te("bi-tick-single",Ks["message__footer-unseen"])})]})]})]}),_.jsx(Mte,{message:n,coords:k,show:I,anchorEl:S.current,mode:f&&!p?"modal":"popover",options:B,onClose:P})]})}const Ote=T.memo(Nte),Wl={checkbox:"_checkbox_fboza_6",checkbox__input:"_checkbox__input_fboza_15",checkbox__box:"_checkbox__box_fboza_22",checkbox__checkmark:"_checkbox__checkmark_fboza_45","checkbox--sm":"_checkbox--sm_fboza_60",checkbox__icon:"_checkbox__icon_fboza_64","checkbox--md":"_checkbox--md_fboza_68","checkbox--lg":"_checkbox--lg_fboza_76","checkbox--checked":"_checkbox--checked_fboza_84","checkbox--disabled":"_checkbox--disabled_fboza_98",ripple:"_ripple_fboza_1","chat-widget-mobile":"_chat-widget-mobile_fboza_1"};function Pte({value:n,onChange:e,className:t,size:r="md",checked:s=!1,disabled:i=!1}){const o=l=>{i||e&&e(l)},a=Te(Wl.checkbox,Wl[`checkbox--${r}`],{[Wl["checkbox--checked"]]:s,[Wl["checkbox--disabled"]]:i},t);return _.jsxs("label",{className:a,children:[_.jsx("input",{type:"checkbox",checked:s,onChange:o,value:n,disabled:i,className:Wl.checkbox__input}),_.jsx("div",{className:Wl.checkbox__box,children:_.jsx("div",{className:Wl.checkbox__checkmark,children:_.jsx("i",{className:"bi-tick-single"})})})]})}function Dte(n={},e={}){const{onSwipeLeft:t,onSwipeRight:r,onSwipeUp:s,onSwipeDown:i}=n,{threshold:o=50,preventDefault:a=!1,maxSwipeDistance:l=100,intentDetectionThreshold:c=20,disabled:d=!1}=e,f=T.useRef(null),p=T.useRef(null),m=T.useRef(!1),[g,v]=T.useState(!1),[y,b]=T.useState(!1),[S,E]=T.useState(null),[C,R]=T.useState({x:0,y:0}),I=T.useRef(null),A=(F,U,$)=>Math.min(Math.max(F,U),$),k=T.useCallback(F=>{d||F.touches.length===1&&(f.current=F.touches[0].clientX,p.current=F.touches[0].clientY,m.current=!1,b(!1),E(null),R({x:0,y:0}))},[d]),N=T.useCallback(F=>{if(d||f.current===null||p.current===null)return;const U=F.touches[0].clientX,$=F.touches[0].clientY;let q=U-f.current,G=$-p.current;const V=Math.abs(q),z=Math.abs(G);if((!m.current&&t&&q<0&&V>c&&z<c||r&&q>0&&V>c&&z<c||s&&G<0&&z>c&&V<c||i&&G>0&&z>c&&V<c)&&(v(!0),m.current=!0),!m.current)return;let B=null;V>z?q>0&&r?B="right":q<0&&t&&(B="left"):G>0&&i?B="down":G<0&&s&&(B="up"),B&&(q=A(q,-l,l),G=A(G,-l,l),E(B),R({x:q,y:G}),a&&F.preventDefault())},[d,t,c,r,s,i,l,a]),D=T.useCallback(()=>{v(!1),E(null),R({x:0,y:0}),f.current=null,p.current=null,m.current=!1},[]),M=T.useCallback(()=>{if(d)return;if(!m.current||!S){D();return}const{x:F,y:U}=C;let $=!1;switch(S){case"left":{t&&-F>=o&&(t(),$=!0);break}case"right":{r&&F>=o&&(r(),$=!0);break}case"up":{s&&-U>=o&&(s(),$=!0);break}case"down":{i&&U>=o&&(i(),$=!0);break}default:console.warn("Define correct position to swipe ...")}b($),D()},[d,S,C,t,r,s,i,o,D]);return T.useEffect(()=>{const F=I.current;if(F)return F.addEventListener("touchstart",k,{passive:!0}),F.addEventListener("touchmove",N,{passive:!1}),F.addEventListener("touchend",M,{passive:!0}),F.addEventListener("touchcancel",M,{passive:!0}),()=>{F.removeEventListener("touchstart",k),F.removeEventListener("touchmove",N),F.removeEventListener("touchend",M),F.removeEventListener("touchcancel",M)}},[k,N,M]),{isSwiping:g,hasSwiped:y,swipeDistance:C,swipeDirection:S,ref:I}}function jte(n={}){const{messages:e=[],selectedMessageIds:t=new Set,setSelectedMessageIds:r,longPressDelay:s=600,dragThreshold:i=40,disabled:o=!1,containerRef:a,maxSelectableMessages:l=1/0}=n,c=T.useRef(null),d=T.useRef(null),f=T.useRef(null),p=T.useRef(!1),m=T.useRef(!1),g=T.useRef(null),v=T.useRef(new Set),y=T.useRef(null),b=T.useRef(null),[S,E]=T.useState(!1),[C,R]=T.useState(!1),[I,A]=T.useState(null),k=T.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(clearInterval(d.current),d.current=null)},[]),N=T.useCallback(V=>{a!=null&&a.current&&(V?b.current!==null&&(a.current.style.overflowY=b.current,b.current=null):(b.current=a.current.style.overflowY||"auto",a.current.style.overflowY="hidden"))},[a]),D=T.useCallback(V=>{if(!(a!=null&&a.current)||!p.current)return;const z=a.current,B=z.getBoundingClientRect(),P=100,H=10,Z=V-B.top,Q=B.bottom-V;d.current&&(clearInterval(d.current),d.current=null),Z<P&&z.scrollTop>0?d.current=setInterval(()=>{z.scrollTop=Math.max(0,z.scrollTop-H),z.scrollTop===0&&(clearInterval(d.current),d.current=null)},16):Q<P&&z.scrollTop<z.scrollHeight-z.clientHeight&&(d.current=setInterval(()=>{const J=z.scrollHeight-z.clientHeight;z.scrollTop=Math.min(J,z.scrollTop+H),z.scrollTop===J&&(clearInterval(d.current),d.current=null)},16))},[a]),M=T.useCallback(V=>{const B=document.elementsFromPoint(window.innerWidth/2,V).find(P=>P.id&&P.id.startsWith("chat-area-messages-message-"));return B?B.id.replace("chat-area-messages-message-",""):null},[]),F=T.useCallback((V,z)=>{const B=e.findIndex(Q=>String(Q.id)===String(V)),P=e.findIndex(Q=>String(Q.id)===String(z));if(B===-1||P===-1)return[];const H=Math.min(B,P),Z=Math.max(B,P);return e.slice(H,Z+1)},[e]),U=T.useCallback(V=>{if(!g.current||!V)return;const B=F(g.current,V).map(P=>String(P.id));r(()=>{const P=new Set(v.current);if(!Number.isFinite(l))return B.forEach(Z=>P.add(Z)),P;if(P.size+B.filter(Z=>!P.has(Z)).length>l){navigator.vibrate&&navigator.vibrate([50,100,50]);let Z=0;const Q=l-P.size;return B.forEach(J=>{!P.has(J)&&Z<Q&&(P.add(J),Z+=1)}),P}return B.forEach(Z=>P.add(Z)),P})},[F,r,l]),$=T.useCallback((V,z)=>{if(o)return;k();const B=V.touches[0];f.current={x:B.clientX,y:B.clientY,timestamp:Date.now(),messageId:String(z)},R(!0),m.current=!0,c.current=setTimeout(()=>{R(!1),m.current=!1,r(P=>{const H=new Set(P);return H.add(String(z)),H}),E(!0),p.current=!0,A(String(z)),g.current=String(z),v.current=new Set(t),v.current.add(String(z)),y.current=B.clientY,N(!1),navigator.vibrate&&navigator.vibrate(50)},s)},[o,t,r,s,k,N]),q=T.useCallback(V=>{if(o||!f.current)return;const z=V.touches[0],B=Math.abs(z.clientX-f.current.x),P=Math.abs(z.clientY-f.current.y),H=Math.hypot(B,P);if(m.current&&H>i){k(),R(!1),m.current=!1;return}if(p.current&&!m.current)if(Number.isFinite(l)&&t.size>=l)d.current&&(clearInterval(d.current),d.current=null);else{D(z.clientY);const Q=M(z.clientY);Q&&Q!==y.current&&(U(Q),y.current=Q)}},[o,i,k,D,M,U,t.size,l]),G=T.useCallback(()=>{o||(k(),m.current&&(R(!1),m.current=!1),p.current&&(E(!1),p.current=!1,A(null),g.current=null,v.current=new Set,y.current=null,N(!0)),f.current=null)},[o,k,N]);return T.useEffect(()=>()=>{k(),N(!0)},[k,N]),T.useEffect(()=>{t.size===0&&p.current&&(E(!1),p.current=!1,A(null),g.current=null,v.current=new Set,y.current=null,N(!0))},[t.size,N]),{isLongPressing:C,handleTouchEnd:G,isDragSelecting:S,handleTouchMove:q,handleTouchStart:$,longPressTimerRef:c,dragStartMessageId:I}}const Fte=T.forwardRef(function({message:e,chatType:t,chatId:r,isGroup:s,isDayStarter:i,isDialogueStarter:o,chatSearchedMessageId:a,contactName:l,contactHashId:c,contactId:d,containerRef:f,setRepliedMessageId:p,setScrollToRepliedMessage:m,lastSeenId:g},v){var tt,et,Oe,ht,Xe,Je;const{currentUser:b,featureFlags:S}=Lt(["currentUser","featureFlags"]),{messages:E,selectedMessageIds:C}=Tn(["messages","selectedMessageIds"]),{setSelectedMessageIds:R}=ai(),{replaceMessage:I,replyMessage:A,addMessage:k}=ro(),{showSuccessSnackbar:N}=Mt.useSnackbar(),{mutateAsync:D}=Hc(),{mutate:M,isLoading:F}=GY(),U=(tt=S==null?void 0:S.features)==null?void 0:tt.selectMessage,$=+((et=e.sender)==null?void 0:et.id)==+(b==null?void 0:b.id),q=!$&&s,G=Te(cn.message__wrapper__content,cn[`message__wrapper__content--${$?"sender":"receiver"}`],`message-${e.messageType.toLowerCase().replace("_","-")}`,{[cn["message__wrapper__content--highlight"]]:a===e.id,[cn["message__wrapper__content--sticker"]]:e.messageType===Fe.STICKER,[cn["message__wrapper__content--error"]]:e.status===Dt.ERROR,[cn["message__wrapper__content--deleted"]]:e.status===Dt.DELETED,[cn["message__wrapper__content--starter-sender"]]:(o||i)&&$,[cn["message__wrapper__content--starter-receiver"]]:(o||i)&&!$,[cn["message__wrapper__content--highlight-reverse"]]:a===e.id&&$}),V=T.useCallback(qe=>{if(typeof qe=="function"){R(Ue=>{const it=qe(Ue);return!Number.isFinite(U)||it.size<=U?it:(navigator.vibrate&&navigator.vibrate(50),new Set([...it].slice(0,U)))});return}if(!Number.isFinite(U)){R(qe);return}if(qe.size<=U)R(qe);else{navigator.vibrate&&navigator.vibrate(50);const Ue=new Set([...qe].slice(0,U));R(Ue)}},[U,R]),{isDragSelecting:z,isLongPressing:B,handleTouchStart:P,handleTouchMove:H,handleTouchEnd:Z,longPressTimerRef:Q}=jte({messages:E,containerRef:f,selectedMessageIds:C,maxSelectableMessages:U,setSelectedMessageIds:V}),{ref:J,isSwiping:ee,swipeDistance:K}=Dte({onSwipeLeft:()=>{[Dt.ERROR,Dt.SENDING].includes(e==null?void 0:e.status)||A(e)}},{threshold:30,preventDefault:!0,disabled:C.size>0||z||B}),W=T.useMemo(()=>C.has(String(e.id)),[C,e.id]),te=T.useCallback(qe=>{V(Ue=>{const it=new Set(Ue),nt=String(qe);return it.has(nt)?it.delete(nt):it.add(nt),it})},[V]),re=T.useCallback(qe=>{C.size>0&&!z&&!B&&(qe.preventDefault(),qe.stopPropagation(),te(e.id))},[C.size,z,B,te,e.id]),pe=T.useCallback(qe=>{P(qe,e.id)},[P,e.id]),Ee=T.useCallback(qe=>{H(qe)},[H]),le=T.useCallback(qe=>{Z(qe)},[Z]),Ie=qe=>{M(qe,{onError:Ue=>{to(Ue)},onSuccess:()=>{N("درخواست با موفقیت ارسال شد!")}})},be=async({label:qe})=>{const Ue=Vn(),it={chatId:r,uuid:Ue,isNew:!0,content:{text:qe},messageType:Fe.TEXT};k({...it,chatId:r,sender:b,isManuallyAdded:!0,status:Dt.SENDING});const nt=await D(it);I(Ue,{...nt.data,uuid:Ue,isManuallyAdded:!0})},ge=({type:qe,data:Ue,label:it,buttonId:nt})=>{({[Mp.MESSAGE]:()=>be({label:it}),[Mp.URL]:()=>window.open(Ue.url,"_blank"),[Mp.CALLBACK]:()=>Ie({messageId:e.id,buttonId:nt})})[qe]()},Ae=({replyMarkup:qe})=>qe.map((it,nt)=>{if(it.length===0)return null;const dt=it.length===1?100:Math.floor(100/it.length);return _.jsx("div",{className:cn["message__wrapper__buttons-row"],children:it.map(({id:Ot,type:xt,label:rt,data:Me})=>_.jsx("div",{className:cn["message__wrapper__buttons-btn"],style:{width:`${dt}%`},children:_.jsx(Qe,{onClick:()=>ge({type:xt,data:Me,label:rt,buttonId:Ot}),size:"xxs",color:"secondary",loading:xt===Mp.CALLBACK&&F,variant:"outline",fullWidth:!0,children:rt})},`button-${Ot}`))},`row-${nt}`)});T.useEffect(()=>{typeof v=="function"?v(J.current,{message:e,lastSeenId:g,chatType:t}):v&&(v.current=J.current)},[v]);const Re={transform:ee?`translateX(${K.x}px)`:void 0,transition:ee?"none":"transform 0.3s ease-out, padding-left 0.3s ease-out"};return _.jsxs("div",{className:Te(cn.message__wrapper,{[cn["message__wrapper--selected"]]:W,[cn["message__wrapper--long-pressing"]]:B,[cn["message__wrapper--drag-selecting"]]:z,[cn["message__wrapper--select-mode"]]:C.size>0}),onClick:re,onTouchStart:pe,onTouchMove:Ee,onTouchEnd:le,ref:J,style:Re,"data-message-id":e==null?void 0:e.id,id:`chat-area-messages-message-${e==null?void 0:e.id}`,children:[_.jsxs(je,{display:"flex",alignItems:"center",flexDirection:"column",className:Te(cn.message__wrapper__container,{[cn["message__wrapper__container--sender"]]:$,[cn["message__wrapper__container--receiver"]]:!$}),children:[_.jsxs(je,{style:{width:"100%"},display:"flex",justifyContent:$?"flex-start":"flex-end",children:[_.jsx(je,{display:"flex",flexDirection:"column",className:G,style:{transition:"transform 200ms ease-in"},children:_.jsx(Ote,{message:e,chatType:t,contactName:l,contactHashId:c,contactId:d,replaceMessage:I,setRepliedMessageId:p,setScrollToRepliedMessage:m,selectedMessageIds:C,longPressTimerRef:Q,replyMessage:A})}),q&&_.jsx("div",{className:cn.message__wrapper__avatar,children:(i||o)&&_.jsx("a",{target:"_blank",rel:"noreferrer","aria-label":"نمایش پروفایل کاربر",href:`${mn.baseUrl}/user/${(Oe=e.sender)==null?void 0:Oe.hashId}`,children:_.jsx(zs,{size:"32",src:(ht=e.sender)==null?void 0:ht.avatar,alt:"پروفایل کاربر"})})})]}),((Je=(Xe=e.content)==null?void 0:Xe.replyMarkup)==null?void 0:Je.length)>0&&_.jsx("div",{className:cn.message__wrapper__buttons,children:Ae({replyMarkup:e.content.replyMarkup})})]}),_.jsx(Mr,{mounted:ee&&!z,transition:"slide-left",duration:250,children:qe=>_.jsx("div",{className:Te(cn["message__wrapper-reply-swipe"],{[cn["message__wrapper-reply-swipe-me"]]:$}),style:qe,children:_.jsx(Mn,{name:"bi-reply"})})}),C.size>0&&_.jsx("div",{className:cn.message__wrapper__checkbox,children:_.jsx(Pte,{onChange:qe=>te(qe.target.value),value:String(e.id),checked:W,size:"md"})})]})}),Ute=T.memo(Fte),nE={loading__container:"_loading__container_375k9_6",loading__container__content:"_loading__container__content_375k9_20",loading__container__text:"_loading__container__text_375k9_25"};function Bte(){return _.jsx("div",{className:nE.loading__container,children:_.jsxs("div",{className:nE.loading__container__content,children:[_.jsx(Cr,{size:"lg"}),_.jsx("span",{className:nE.loading__container__text,children:"در حال بارگذاری پیام‌های جدید..."})]})})}function $te(){var lt,Vt,vn;const n=T.useRef(new Set),e=T.useRef(null),t=T.useRef([]),{chat:r,contact:s,messages:i,hasNextPage:o,hasChatUpdate:a,selectedMessageIds:l,isLoadingNextMessages:c,isLoading:d,hasNextMessages:f,messageIdToSearch:p,hasPreviousMessages:m}=Tn(["chat","contact","messages","hasNextPage","hasChatUpdate","selectedMessageIds","isLoadingNextMessages","isLoading","hasNextMessages","messageIdToSearch","hasPreviousMessages"]),{setSelectedMessageIds:g,setScrollToRepliedMessage:v,setScrollToReplierMessage:y}=ai(),{featureFlags:b,currentUser:S,socketConnected:E,isLoggedIn:C}=Lt(["currentUser","featureFlags","socketConnected","isLoggedIn"]),{emitEvent:R}=Mt.useEmitter(),{setContainer:I,setVirtuoso:A,getNextMessages:k,getPreviousMessages:N,scrollToBottom:D,seenMessages:M,editMessage:F,containerRef:U,virtuosoRef:$}=ro(),{push:q,pushOnce:G}=Si(),{mutate:V}=zY({retry:2,retryDelay:2e3}),[z,B]=T.useState(),[P,H]=T.useState(!1),[Z,Q]=T.useState(!0),[J,ee]=T.useState(!1),K=T.useRef(0),W=T.useRef(1e4),te=T.useRef(!1),re=T.useRef(!1),pe=T.useRef(0),Ee=((lt=b==null?void 0:b.hintBox)==null?void 0:lt.show)&&!nm(r==null?void 0:r.chatType),le=T.useCallback(pt=>{const mt=[];let gt=null;return pt.forEach(Wt=>{if(Wt.status===Dt.DELETED)return;const ot=de.gregoryDate(Wt.createdAt).startOf("day");(!gt||ot.diff(gt,"day")!==0&&Wt.createdAt)&&(mt.push({type:"date",data:Wt.createdAt}),gt=ot),Wt.unReadMessages?mt.push({type:"unread"}):mt.push({type:"message",data:Wt})}),mt},[]),Ie=T.useMemo(()=>le(i),[i,le]),be=T.useCallback((pt,mt=!0)=>{const gt=[...new Set(pt)].filter(ot=>!n.current.has(ot));if(gt.length===0)return;gt.forEach(ot=>n.current.add(ot));const Wt=Math.max(...gt.map(Number));if(E)M([...new Set(gt)]),t.current=[],mt&&(R(Ct.PUBLISH_TO_SOCKET,{payload:{type:Uc.MESSAGE_SEEN,data:{chatId:r==null?void 0:r.id,messageIds:gt,chatType:r==null?void 0:r.chatType,senderId:(s==null?void 0:s.id)||0,receiverId:S==null?void 0:S.id}}}),R(Ct.UPDATE_LAST_SEEN_MESSAGE,{chatId:r==null?void 0:r.id,lastSeenMessageId:Wt,messageIds:gt}));else if(C){const ot={chatId:r==null?void 0:r.id,messageIds:gt,chatType:r==null?void 0:r.chatType,senderId:(s==null?void 0:s.id)||0,receiverId:S==null?void 0:S.id};V(ot,{onError:nn=>{to(nn)},onSuccess:()=>{M(gt),t.current=[],R(Ct.UPDATE_LAST_SEEN_MESSAGE,{chatId:r==null?void 0:r.id,lastSeenMessageId:Wt,messageIds:gt})}})}R(Ct.BROADCAST_TO_ALL,{customType:"seenMessages",data:{chatId:r==null?void 0:r.id,messageIds:gt}})},[C,r==null?void 0:r.id,s==null?void 0:s.id,S==null?void 0:S.id,R,M,V,E]),ge=T.useCallback(_S(be,250),[be]);T.useEffect(()=>(e.current=new IntersectionObserver(pt=>{pt.forEach(mt=>{if(mt.isIntersecting){const gt=mt.target.dataset.messageId;gt&&(t.current.push(gt),ge([...t.current]))}})},{threshold:.3}),()=>{e.current&&e.current.disconnect()}),[ge]),T.useEffect(()=>{U.current&&I(U.current)},[U,I]),T.useEffect(()=>{$.current&&A($.current)},[$,A]),T.useEffect(()=>{R(Ct.ADD_EVENT_LISTENER,{event:"seenMessages",callback:({data:pt})=>{const{chatId:mt,messageIds:gt}=pt;mt&&mt===(r==null?void 0:r.id)&&ge(gt,!1)}})},[ge,R,r==null?void 0:r.id]);const Ae=T.useCallback(async()=>{try{await vS(z,i,$)==="not-found"&&y(z),B()}catch{}},[z,i,$,y]),Re=T.useCallback(()=>{g(new Set)},[g]),tt=T.useMemo(()=>i.at(-1),[i]),et=T.useMemo(()=>{let pt=0;if(Ie.length>0&&!d){pt=Ie.length;const mt=Ie.findIndex(gt=>gt.type==="unread");return mt!==-1&&(pt=mt),Math.max(0,pt)}return 0},[Ie,d]),Oe=T.useMemo(()=>Ie.length>0&&!d&&et>0,[Ie.length,d,et]);T.useEffect(()=>{H(!1),Q(!0),ee(!1),W.current=1e4,K.current=0,te.current=!1,re.current=!1,pe.current=0},[r==null?void 0:r.id,(Vt=r==null?void 0:r.searchedMessage)==null?void 0:Vt.id,p]),T.useEffect(()=>{if(Oe&&!P){const pt=setTimeout(()=>{H(!0)},100);return()=>clearTimeout(pt)}},[Oe,P]);const ht=T.useCallback(pt=>{var Wt,ot;if(pt.key!=="ArrowUp")return;const mt=document.querySelector("#chat-message-form-input"),gt=(Wt=mt==null?void 0:mt.textContent)==null?void 0:Wt.trim();tt&&String((ot=tt.sender)==null?void 0:ot.id)===String(S==null?void 0:S.id)&&!(tt!=null&&tt.seenAt)&&!gt&&(G(()=>{F(null)}),F(tt))},[S==null?void 0:S.id,tt,F,G]);T.useEffect(()=>{if(l.size>0)return q(Re)},[Re,q,l.size]),T.useEffect(()=>(document.addEventListener("keydown",ht),()=>document.removeEventListener("keydown",ht)),[ht]);const Xe=T.useMemo(()=>!!(r!=null&&r.unseenMessageCount)&&!Z||a&&o||!Z&&J,[a,o,r==null?void 0:r.unseenMessageCount,Z,J]),Je=T.useCallback(()=>{if(z)return Ae();if(o)return D();tm($)},[z,Ae,o,D]),qe=T.useMemo(()=>{const pt=Ie.length,mt=K.current;if(mt>0&&pt!==mt&&P){const gt=pt-mt;if(gt>0){const Wt=te.current,ot=re.current;Wt?(W.current-=gt,te.current=!1):ot&&(re.current=!1)}}return K.current=pt,W.current},[Ie.length,P]),Ue=T.useCallback(()=>f?_.jsx(je,{py:24,display:"flex",alignItems:"center",justifyContent:"center",style:{width:"100%"},children:_.jsx(Cr,{className:"bs-infinite-scroll__loading"})}):null,[f]),it=T.useCallback(()=>Ee?_.jsxs(_.Fragment,{children:[m&&_.jsx(je,{py:12,display:"flex",alignItems:"center",justifyContent:"center",style:{width:"100%"},children:_.jsx(Cr,{className:"bs-infinite-scroll__loading"})}),_.jsx(_ee,{},"hint-box"),c&&_.jsx(Bte,{},"loading-next-messages")]}):null,[Ee,m,c]),nt=T.useMemo(()=>({Footer:Ue,Header:it}),[Ue,it]),dt=T.useCallback(pt=>{pt&&P&&(te.current=!0,N())},[N,P]),Ot=T.useCallback(pt=>{pt&&(re.current=!0,k())},[k]),xt=T.useCallback(()=>{const pt=U.current;if(!pt)return;const mt=pt.scrollTop,gt=pt.scrollHeight,Wt=pt.clientHeight,ot=pe.current,nn=mt>ot,En=mt+Wt>=gt-150;ee(nn),Q(En),pe.current=mt},[U]);T.useEffect(()=>{const pt=U.current;if(pt)return pt.addEventListener("scroll",xt,{passive:!0}),()=>{pt.removeEventListener("scroll",xt)}},[U,xt]);const rt=T.useCallback(pt=>{pt?e.current.observe(pt):e.current.unobserve(pt)},[]),Me=T.useCallback((pt,mt)=>{var gt,Wt,ot,nn;switch(mt.type){case"date":return _.jsx(lj,{date:mt.data},`date-${mt.data}`);case"unread":return _.jsx("div",{className:mm["chat-area-messages__unReadMessages"],id:"unReadMessages",children:"پیام‌های خوانده نشده"},"unReadMessages");case"message":{const tn=mt.data,En=Ie[pt-1],$n=!En||En.type!=="message"||+((Wt=(gt=En.data)==null?void 0:gt.sender)==null?void 0:Wt.id)!=+((ot=tn.sender)==null?void 0:ot.id),_n=(sr,{message:wr,lastSeenId:ws,chatType:es})=>{var _e;const ds=String((_e=wr==null?void 0:wr.sender)==null?void 0:_e.id)!==String(S==null?void 0:S.id),fs=!n.current.has(wr.id),oe=[Bt.CHANNEL,Bt.GROUP].includes(es)&&ws<=wr.id,ce=[Bt.BOT,Bt.PRIVATE].includes(es)&&!(wr!=null&&wr.seenAt);(oe||ce)&&ds&&fs&&rt(sr)};return _.jsx(Ute,{ref:_n,lastSeenId:r==null?void 0:r.lastSeenId,message:tn,chatType:r==null?void 0:r.chatType,chatId:r==null?void 0:r.id,isGroup:(r==null?void 0:r.chatType)===Bt.GROUP,isDayStarter:!1,isDialogueStarter:$n,chatSearchedMessageId:(nn=r==null?void 0:r.searchedMessage)==null?void 0:nn.id,contactHashId:s==null?void 0:s.hashId,contactId:s==null?void 0:s.id,contactName:s==null?void 0:s.name,containerRef:U,setScrollToRepliedMessage:v,setRepliedMessageId:B},tn.id||tn.uuid)}default:return null}},[Ie,r==null?void 0:r.lastSeenId,r==null?void 0:r.chatType,r==null?void 0:r.id,(vn=r==null?void 0:r.searchedMessage)==null?void 0:vn.id,s==null?void 0:s.hashId,s==null?void 0:s.id,s==null?void 0:s.name,U,v,S==null?void 0:S.id,rt]);return _.jsxs("div",{ref:U,id:"chat-area-messages",className:mm["chat-area-messages"],children:[d?_.jsx(bee,{}):Oe&&_.jsx(Zd,{ref:$,customScrollParent:U.current,components:nt,firstItemIndex:qe,initialTopMostItemIndex:et,data:Ie,atTopStateChange:dt,atBottomStateChange:Ot,atBottomThreshold:100,atTopThreshold:200,totalCount:Ie.length||0,itemContent:Me,increaseViewportBy:{top:200,bottom:200},skipAnimationFrameInResizeObserver:!0,logLevel:qs.DEBUG}),_.jsx(cj,{onClick:Je,shouldShowWhenScrollDown:Xe,count:r==null?void 0:r.unseenMessageCount,scrollerRef:U,countless:a&&o})]})}const zte=T.memo($te),Os={cc:"_cc_1v13h_6",cc__header:"_cc__header_1v13h_15","cc__header-icon":"_cc__header-icon_1v13h_20","cc__header-title":"_cc__header-title_1v13h_25",cc__description:"_cc__description_1v13h_31",cc__actions:"_cc__actions_1v13h_36","cc__actions-reply":"_cc__actions-reply_1v13h_42","cc__actions-reply--mini":"_cc__actions-reply--mini_1v13h_46","cc__actions-left":"_cc__actions-left_1v13h_54","cc__actions-left-report":"_cc__actions-left-report_1v13h_61","cc__actions-left-report-spam":"_cc__actions-left-report-spam_1v13h_61",cc__placeholder:"_cc__placeholder_1v13h_72"};function qte(){const n=cS(),{chat:e}=Tn(["chat"]),{setChat:t}=ai(),{emitEvent:r,subEvent:s,offEvent:i}=Mt.useEmitter(),{mutate:o,isLoading:a}=qc({onSuccess:()=>{t(v=>({...v,showApprovals:!1,contactIsBlocked:!0}))}}),{mutate:l,isLoading:c}=UY({onError:to,onSuccess:()=>{var v;t(y=>({...y,showApprovals:!1})),(v=document.querySelector("#chat-message-form-input"))==null||v.focus()}}),d=T.useMemo(()=>{var v;return e!=null&&e.showApprovals&&((v=n("chat_confirmation_prompt"))==null?void 0:v.value)||"hide"},[e==null?void 0:e.showApprovals,n]),f=()=>{l({chat_id:e==null?void 0:e.id,approvals:!0})},p=()=>{var v;r(Fa.SHOW_REPORT_CONTENT_MODAL,{source:"CHAT",entityType:"CONVERSATION_USER",entityId:(v=e==null?void 0:e.contact)==null?void 0:v.id,reportType:fx.CONVERSATION_USER})},m=()=>{var v;r(Fa.SHOW_REPORT_CONTENT_MODAL,{source:"CHAT",reasonId:r7.SPAM,entityType:"CONVERSATION_USER",entityId:(v=e==null?void 0:e.contact)==null?void 0:v.id,reportType:fx.CONVERSATION_USER})},g=T.useCallback(v=>{var y;v.entityId===((y=e==null?void 0:e.contact)==null?void 0:y.id)&&(t(b=>({...b,showApprovals:!1})),v.button.action.data==="101"?o({status:Fc.BLOCK,payload:{chatIds:[e==null?void 0:e.id]}}):e!=null&&e.showApprovals&&l({chat_id:e==null?void 0:e.id,approvals:!0}))},[e==null?void 0:e.contact,e==null?void 0:e.id,e==null?void 0:e.showApprovals,t]);return T.useEffect(()=>(s("report",g,{autoOff:!1}),()=>{i("report",g)}),[g]),(e==null?void 0:e.showApprovals)&&d!=="hide"&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:Os.cc,children:[_.jsxs("div",{className:Os.cc__header,children:[_.jsx("i",{className:Te("bi-privacy-fill",Os["cc__header-icon"])}),_.jsx("span",{className:Os["cc__header-title"],children:"پاسخ این کاربر رو میدی؟"})]}),_.jsx("p",{className:Os.cc__description,children:"این کاربر، اولین باره به شما پیام می‌ده. در صورت تمایل به گفت‌وگو با این کاربر، «تأیید و پاسخ» رو بزن. یا اگر نیازه، می‌تونی گزارش تخلف ثبت کنی."}),_.jsxs("div",{className:Os.cc__actions,children:[d==="single_button"&&_.jsxs(_.Fragment,{children:[_.jsx(Qe,{size:At().isMobile?"xs":"sm",label:"تایید و پاسخ",loading:c,className:Os["cc__actions-reply"],disabled:a,onClick:f}),_.jsx("div",{className:Os["cc__actions-left"],children:_.jsx(Qe,{size:At().isMobile?"xs":"sm",label:"گزارش",variant:"outline",className:Os["cc__actions-left-report"],disabled:a||c,onClick:p})})]}),d==="multiple_button"&&_.jsxs(_.Fragment,{children:[_.jsx(Qe,{label:"تایید و پاسخ",loading:c,size:At().isMobile?"xs":"sm",disabled:a,className:Te(Os["cc__actions-reply"],Os["cc__actions-reply--mini"]),onClick:f}),_.jsxs("div",{className:Os["cc__actions-left"],children:[_.jsx(Qe,{variant:"outline",label:"گزارش هرزنامه",size:At().isMobile?"xs":"sm",className:Os["cc__actions-left-report-spam"],disabled:a||c,onClick:m}),_.jsx(Qe,{variant:"outline",label:"گزارش به علتی دیگر",size:At().isMobile?"xs":"sm",className:Os["cc__actions-left-report"],disabled:a||c,onClick:p})]})]})]})]}),_.jsx("div",{className:Os.cc__placeholder})]})}const Hte={bottom__bar:"_bottom__bar_1jpte_6"};function Gte(){return _.jsx("div",{className:Hte.bottom__bar})}const za={"contact-list-item-container":"_contact-list-item-container_kz2yq_6","contact-list-item":"_contact-list-item_kz2yq_6","contact-list-item__top":"_contact-list-item__top_kz2yq_54","contact-list-item__top__saved-message__avatar":"_contact-list-item__top__saved-message__avatar_kz2yq_59","contact-list-item__top-avatar":"_contact-list-item__top-avatar_kz2yq_68","contact-list-item__top-sender":"_contact-list-item__top-sender_kz2yq_71","contact-list-item__top-sender-name":"_contact-list-item__top-sender-name_kz2yq_87","contact-list-item__top-sender-vendor":"_contact-list-item__top-sender-vendor_kz2yq_127"};function Vte({chat:n,contact:e,onClick:t}){var f,p,m;const r=T.useRef(),s=!At().isPc,[i,o]=T.useState(!1),{currentUser:a}=Lt(["currentUser"]),l=((f=e==null?void 0:e.avatar)==null?void 0:f.extraSmall)&&!i,c=e&&a&&e.id===a.id,d=T.useMemo(()=>ad(e==null?void 0:e.lastActivity),[e==null?void 0:e.lastActivity]);return _.jsx("div",{ref:r,className:za["contact-list-item-container"],children:_.jsx("div",{className:za["contact-list-item"],onClick:()=>t==null?void 0:t(n),children:_.jsxs("div",{className:za["contact-list-item__top"],children:[c?_.jsx("div",{className:za["contact-list-item__top__saved-message__avatar"],children:_.jsx(Mn,{name:"bi-saved-message-fill",color:"white"})}):_.jsxs("div",{className:za["contact-list-item__top-avatar"],children:[_.jsx(zs,{src:(p=e==null?void 0:e.avatar)==null?void 0:p.extraSmall,size:s?"40":"44",status:l?"offline":d,onLoad:()=>o(!0)}),_.jsx(uS,{show:l,radius:"50%"})]}),_.jsxs("div",{className:za["contact-list-item__top-sender"],children:[_.jsxs("div",{className:za["contact-list-item__top-sender-name"],children:[_.jsx("span",{children:c?"پیام های ذخیره شده":e==null?void 0:e.name}),!!(e!=null&&e.badge)&&!c&&_.jsx(Xo,{label:e==null?void 0:e.badge,size:"sm",color:"black"})]}),!!(e!=null&&e.vendor)&&!c&&_.jsxs("span",{className:za["contact-list-item__top-sender-vendor"],children:[_.jsx("i",{className:"bi-vendor"}),(m=e.vendor)==null?void 0:m.title]})]})]})})})}const iu={"contact-list":"_contact-list_q0inf_6","contact-list__header":"_contact-list__header_q0inf_39","contact-list__header-search":"_contact-list__header-search_q0inf_46","contact-list__header-filter":"_contact-list__header-filter_q0inf_49","contact-list__items":"_contact-list__items_q0inf_52","contact-list__items--full-height":"_contact-list__items--full-height_q0inf_83"},us={"contact-list-filter":"_contact-list-filter_3tnxp_6","contact-list-filter__btn":"_contact-list-filter__btn_3tnxp_10","contact-list-filter__btn--active":"_contact-list-filter__btn--active_3tnxp_25","contact-list-filter__dropdown":"_contact-list-filter__dropdown_3tnxp_32","contact-list-filter__dropdown-item":"_contact-list-filter__dropdown-item_3tnxp_51","contact-list-filter__modal-item":"_contact-list-filter__modal-item_3tnxp_92","contact-list-filter__modal-item-title":"_contact-list-filter__modal-item-title_3tnxp_114"},Ej=T.forwardRef(function({className:e,disabled:t,onChange:r},s){var v;const i=T.useRef(),[o,a]=T.useState(),[l,c]=T.useState(null),d=At(),{currentUser:f}=Lt(["currentUser"]),p=(v=f==null?void 0:f.vendor)==null?void 0:v.isActive,m=T.useCallback(y=>{c(y),setTimeout(()=>a(!1),200)},[]),g=y=>{m(y),setTimeout(()=>{r(y)},0)};return T.useImperativeHandle(s,()=>({updateFilter:m}),[m]),_.jsxs("div",{className:e,ref:s,children:[_.jsx("div",{ref:i,className:us["contact-list-filter"],children:_.jsx(Qe,{className:Te(us["contact-list-filter__btn"],{[us["contact-list-filter__btn--active"]]:l!==null}),icon:"bi-filter",variant:"text",color:"secondary",size:"md",square:!0,disabled:t,onClick:()=>a(!0)})}),d.isPc&&_.jsx(tf,{show:!!o,anchorEl:i.current,transition:"fade",position:"bottom-left",onClose:()=>a(!1),className:"dataset-inp-ChatListFilter",children:_.jsxs("div",{className:us["contact-list-filter__dropdown"],children:[_.jsxs("button",{className:us["contact-list-filter__dropdown-item"],onClick:()=>g(null),children:[_.jsx(gs,{value:"",checked:l===null}),_.jsx("span",{className:us["contact-list-filter__dropdown-title"],children:"همه گفت‌و‌گوها"})]}),_.jsxs("button",{className:us["contact-list-filter__dropdown-item"],onClick:()=>g("unseen"),children:[_.jsx(gs,{value:"unseen",checked:l==="unseen"}),_.jsx("span",{className:us["contact-list-filter__dropdown-title"],children:"خوانده نشده‌ها"})]}),p&&_.jsxs("button",{className:us["contact-list-filter__dropdown-item"],onClick:()=>g("order"),children:[_.jsx(gs,{value:"order",checked:l==="order"}),_.jsx("span",{className:us["contact-list-filter__dropdown-title"],children:"سفارش‌های جاری"})]})]})}),!d.isPc&&_.jsx(lr,{show:o,showClose:!1,title:"فیلتر",onClose:()=>a(!1),showHeader:!0,className:"dataset-inp-ChatListFilter",children:_.jsxs("div",{className:us["contact-list-filter__modal"],children:[_.jsxs("button",{className:us["contact-list-filter__modal-item"],onClick:()=>g(null),children:[_.jsx(gs,{value:"",checked:l===null}),_.jsx("span",{className:us["contact-list-filter__modal-item-title"],children:"همه گفت‌و‌گوها"})]}),_.jsxs("button",{className:us["contact-list-filter__modal-item"],onClick:()=>g("unseen"),children:[_.jsx(gs,{value:"unseen",checked:l==="unseen"}),_.jsx("span",{className:us["contact-list-filter__modal-item-title"],children:"خوانده نشده‌ها"})]}),p&&_.jsxs("button",{className:us["contact-list-filter__modal-item"],onClick:()=>g("order"),children:[_.jsx(gs,{value:"order",checked:l==="order"}),_.jsx("span",{className:us["contact-list-filter__modal-item-title"],children:"سفارش‌های جاری"})]})]})})]})}),so={"contact-list-search__box":"_contact-list-search__box_1vwxn_6","contact-list-search__box--disabled":"_contact-list-search__box--disabled_1vwxn_19","contact-list-search__box--focus":"_contact-list-search__box--focus_1vwxn_22","contact-list-search__box-icon":"_contact-list-search__box-icon_1vwxn_25","contact-list-search__box-input":"_contact-list-search__box-input_1vwxn_28","contact-list-search__box-clear":"_contact-list-search__box-clear_1vwxn_37","contact-list-search__types":"_contact-list-search__types_1vwxn_45","contact-list-search__types--show":"_contact-list-search__types--show_1vwxn_53","contact-list-search__types-radio":"_contact-list-search__types-radio_1vwxn_57"};function wj({disabled:n,onSearch:e,className:t,placeholder:r="جست‌وجو در گفت‌وگوها"}){const s=T.useRef(),i=T.useRef(),[o,a]=T.useState(""),[l,c]=T.useState("MESSAGES"),[d,f]=T.useState(!1),p=v=>{a(v.target.value),clearTimeout(i.current),i.current=setTimeout(()=>e({query:v.target.value,type:l}),500)},m=v=>{c(v.target.value),setTimeout(()=>{e({query:o,type:v.target.value})},0)},g=()=>{a(""),setTimeout(()=>{var v;e({query:"",type:"MESSAGES"}),(v=s.current)==null||v.blur()},0),clearTimeout(i.current)};return _.jsxs("div",{className:Te(t,so["contact-list-search"]),children:[_.jsxs("div",{className:Te(so["contact-list-search__box"],{[so["contact-list-search__box--focus"]]:d,[so["contact-list-search__box--disabled"]]:n}),children:[_.jsx("i",{className:Te("bi-search",so["contact-list-search__box-icon"])}),_.jsx("input",{ref:s,className:so["contact-list-search__box-input"],type:"text",placeholder:r,value:o,disabled:n,onInput:p,onFocus:()=>f(!0),onBlur:()=>f(!1)}),_.jsx(Mr,{mounted:o.length>0,transition:"fade",duration:250,children:v=>_.jsx("button",{"aria-label":"بستن",className:so["contact-list-search__box-clear"],style:v,onClick:g,children:_.jsx("i",{className:"bi-close"})})})]}),_.jsxs("div",{className:Te(so["contact-list-search__types"],{[so["contact-list-search__types--show"]]:!!o}),children:[_.jsx(gs,{className:so["contact-list-search__types-radio"],label:"متن گفت‌وگوها",value:"MESSAGES",checked:l==="MESSAGES",onChange:m}),_.jsx(gs,{className:so["contact-list-search__types-radio"],label:"اسم آدم‌ها",value:"CONTACTS",checked:l==="CONTACTS",onChange:m})]})]})}function Wte({className:n,onSend:e}){var b,S;const t=T.useRef(),{isLoggedIn:r,featureFlags:s}=Lt(["isLoggedIn","featureFlags"]),{search:i,applyFilter:o,isSearching:a,isFiltering:l,chats:c,getNextChats:d}=xS({limit:30,autoUpdate:!1,filterChannels:!0}),[f,p]=[(b=s==null?void 0:s.features)==null?void 0:b.searchChatList,(S=s==null?void 0:s.features)==null?void 0:S.unseenChatListFilter],m=(f||p)&&r,g=T.useCallback((E,C)=>{const R={chat:C,contact:C.contact,onClick:I=>{e(I)}};return _.jsx(Vte,{...R})},[]),v=()=>{t.current.updateFilter(null),setTimeout(()=>{o(null)},0)},y=c.length>0;return _.jsxs("div",{id:"contact-list",className:Te(iu["contact-list"],n),children:[m&&_.jsxs("header",{className:iu["contact-list__header"],children:[f&&_.jsx(wj,{disabled:l,className:iu["contact-list__header-search"],onSearch:i}),p&&_.jsx(Ej,{ref:t,disabled:a,className:iu["contact-list__header-filter"],onChange:o})]}),y?_.jsx(Zd,{className:Te(iu["contact-list__items"],{[iu["contact-list__items--full-height"]]:!m}),data:c,endReached:d,itemContent:(E,C)=>g(E,C)}):!a&&!l?_.jsx(Zp,{}):a?_.jsx(SS,{searchType:"CONTACTS"}):_.jsx(ES,{onFilterClear:v})]})}const Kte=T.memo(Wte),rE={"forward-modal":"_forward-modal_iv3of_6","forward-modal__list":"_forward-modal__list_iv3of_22","forward-modal-body":"_forward-modal-body_iv3of_60"};function Yte(){const{showSuccessSnackbar:n}=Mt.useSnackbar(),{mutateAsync:e}=Hc(),{mutate:t}=jY(),{openChat:r}=Wc(),{setForwardModalData:s,setSelectedMessageIds:i}=ai(),{replaceMessage:o,addMessage:a}=ro(),{push:l}=Si(),{publishEvent:c}=Fr(),{containerRef:d,messages:f,forwardModalData:p}=Tn(["containerRef","messages","forwardModalData"]),{currentUser:m}=Lt(["currentUser"]),{emitEvent:g}=Mt.useEmitter(),v=async(k,N)=>{if(n("پیام با موفقیت ارسال شد"),requestIdleCallback(()=>{c("chatForwardMessage",{messageType:k.messageType,userIsVendor:!!(m!=null&&m.vendor)})}),s(null),g(Ct.UPDATE_CHAT_LIST_LAST_MESSAGE,{chatId:N.id,message:{...k,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss")}}),k.chatId===N.id){const D=d.current;setTimeout(()=>{em(D,D.scrollHeight)},0)}else r({chat:N})},y=async({message:k,userChat:N})=>{try{await de.sleep(0);const D=k.content.text;if(!D||D.trim().length===0)return;const M=N==null?void 0:N.id,F=Vn(),U={chatId:M,uuid:F,isNew:!0,content:{text:D},forwardFrom:k.id,messageType:Fe.TEXT},$=k.chatId===M;$&&a({...U,sender:m,isManuallyAdded:!0,status:Dt.SENDING});const q=await e(U);$&&o(F,{...q.data,uuid:F,isManuallyAdded:!0}),v(k,N)}catch(D){no(D)}},b=async({message:k,userChat:N})=>{var D,M,F,U,$,q,G,V,z;try{await de.sleep(0);const B=k.content.text,P=Vn(),H=N==null?void 0:N.id,Z={id:(F=(M=(D=k.content)==null?void 0:D.files)==null?void 0:M[0])==null?void 0:F.id,url:((q=($=(U=k.content)==null?void 0:U.files)==null?void 0:$[0])==null?void 0:q.originalUrl)||((z=(V=(G=k.content)==null?void 0:G.files)==null?void 0:V[0])==null?void 0:z.url)},Q={chatId:H,uuid:P,isNew:!0,forwardFrom:k.id,attachment:{files:[Z]},messageType:k.messageType,...B&&{content:{text:B}}},J=k.chatId===H;J&&a({...Q,uuid:P,sender:m,isManuallyAdded:!0,status:Dt.SENDING,message:{files:[{id:Z.id,url:Z.url}],...B&&{text:B}}});const ee=await e(Q);J&&o(P,{...ee.data,uuid:P,isManuallyAdded:!0,message:{...ee.data.message,files:[{...Z,url:Z.url,originalUrl:Z.url}]}}),v(k,N)}catch(B){no(B)}},S=async({message:k,userChat:N})=>{var D,M,F,U,$,q;try{await de.sleep(0);const G=Vn(),V=N==null?void 0:N.id,z={id:(F=(M=(D=k.content)==null?void 0:D.files)==null?void 0:M[0])==null?void 0:F.id,url:(q=($=(U=k.content)==null?void 0:U.files)==null?void 0:$[0])==null?void 0:q.url},B={chatId:V,uuid:G,isNew:!0,forwardFrom:k.id,attachment:{files:[z]},messageType:Fe.STICKER},P=k.chatId===V;P&&a({...B,chatId:V,sender:m,isManuallyAdded:!0,status:Dt.SENDING,message:{files:[{id:z.id,url:z.url}]}});const H=await e(B);P&&o(G,{...H.data,uuid:G,isManuallyAdded:!0}),v(k,N)}catch(G){no(G)}},E=async({message:k,userChat:N})=>{var D,M,F,U,$,q;try{await de.sleep(0);const G=Vn(),V=N==null?void 0:N.id,z=k.chatId===V,B={id:(F=(M=(D=k.content)==null?void 0:D.files)==null?void 0:M[0])==null?void 0:F.id,url:(q=($=(U=k.content)==null?void 0:U.files)==null?void 0:$[0])==null?void 0:q.url},P={chatId:V,uuid:G,isNew:!0,forwardFrom:k.id,attachment:{files:[B]},messageType:Fe.VOICE};z&&a({...P,chatId:V,sender:m,isManuallyAdded:!0,status:Dt.SENDING,message:{files:[{id:B.id,url:B.url}]}});const H=await e(P);z&&o(G,{...H.data,uuid:G,isManuallyAdded:!0}),v(k,N)}catch(G){no(G)}},C=async({message:k,userChat:N})=>{try{await de.sleep(0);const D=Vn(),M=N==null?void 0:N.id,F={chatId:M,uuid:D,isNew:!0,forwardFrom:k.id,messageType:Fe.PRODUCT,content:{entityId:k.content.entityId}},U=k.chatId===M;U&&a({...F,chatId:M,sender:m,isManuallyAdded:!0,status:Dt.SENDING});const $=await e(F);U&&o(D,{...$.data,uuid:D,isManuallyAdded:!0}),v(k,N)}catch(D){no(D)}},R=async({message:k,userChat:N})=>{try{await de.sleep(0);const D=Vn(),M=N==null?void 0:N.id,F={chatId:M,uuid:D,isNew:!0,forwardFrom:k.id,messageType:Fe.COUPON,content:{entityId:k.content.entityId}},U=k.chatId===M;U&&a({...F,chatId:M,sender:m,isManuallyAdded:!0,status:Dt.SENDING});const $=await e(F);U&&o(D,{...$.data,uuid:D,isManuallyAdded:!0}),v(k,N)}catch(D){no(D)}},I=T.useCallback(async k=>{try{if(Array.isArray(p)){const N=Array.from(p,M=>Number.parseInt(M,10)).sort((M,F)=>M-F),D={chatIds:[k.id],messageIds:N};t(D,{onError:M=>{no(M)},onSuccess:()=>{n(p.length===1?"پیام با موفقیت ارسال شد":"پیام ها با موفقیت ارسال شدند"),requestIdleCallback(()=>{c("chatMessagesBulkForwardSubmit",{recipientUserId:k.id})}),s(null),i(new Set);const M=f.find(F=>F.id===N.at(-1));M&&g(Ct.UPDATE_CHAT_LIST_LAST_MESSAGE,{chatId:k.id,message:{...M,createdAt:de.gregoryDate().format("YYYY-MM-DD HH:mm:ss")}})}})}else({[Fe.TEXT]:y,[Fe.VIDEO]:b,[Fe.VOICE]:E,[Fe.PICTURE]:b,[Fe.COUPON]:R,[Fe.STICKER]:S,[Fe.PRODUCT]:C})[p.messageType]({message:p,userChat:k})}catch(N){no(N)}},[p]),A=()=>{s(null)};return T.useEffect(()=>p?l(()=>{A()}):void 0,[p,l]),_.jsx(lr,{size:"sm",showClose:!0,show:!!p,title:"ارسال در گفت‌وگو",bodyClass:rE["forward-modal-body"],onClose:A,className:"dataset-inp-ChatForwardModal",children:_.jsx("div",{className:rE["forward-modal"],children:_.jsx(Kte,{className:rE["forward-modal__list"],onSend:I})})})}const Xte={"chat-warnings":"_chat-warnings_1ba1u_6"};function Qte(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var sE={exports:{}},ou=typeof Reflect=="object"?Reflect:null,Tj=ou&&typeof ou.apply=="function"?ou.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)},Em;ou&&typeof ou.ownKeys=="function"?Em=ou.ownKeys:Object.getOwnPropertySymbols?Em=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Em=function(e){return Object.getOwnPropertyNames(e)};function Jte(n){console&&console.warn&&console.warn(n)}var Cj=Number.isNaN||function(e){return e!==e};function Bn(){Bn.init.call(this)}sE.exports=Bn,sE.exports.once=nne,Bn.EventEmitter=Bn,Bn.prototype._events=void 0,Bn.prototype._eventsCount=0,Bn.prototype._maxListeners=void 0;var Ij=10;function wm(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(Bn,"defaultMaxListeners",{enumerable:!0,get:function(){return Ij},set:function(n){if(typeof n!="number"||n<0||Cj(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");Ij=n}}),Bn.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Bn.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Cj(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Rj(n){return n._maxListeners===void 0?Bn.defaultMaxListeners:n._maxListeners}Bn.prototype.getMaxListeners=function(){return Rj(this)},Bn.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s=e==="error",i=this._events;if(i!==void 0)s=s&&i.error===void 0;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=i[e];if(l===void 0)return!1;if(typeof l=="function")Tj(l,this,t);else for(var c=l.length,d=Nj(l,c),r=0;r<c;++r)Tj(d[r],this,t);return!0};function Aj(n,e,t,r){var s,i,o;if(wm(t),i=n._events,i===void 0?(i=n._events=Object.create(null),n._eventsCount=0):(i.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),i=n._events),o=i[e]),o===void 0)o=i[e]=t,++n._eventsCount;else if(typeof o=="function"?o=i[e]=r?[t,o]:[o,t]:r?o.unshift(t):o.push(t),s=Rj(n),s>0&&o.length>s&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=o.length,Jte(a)}return n}Bn.prototype.addListener=function(e,t){return Aj(this,e,t,!1)},Bn.prototype.on=Bn.prototype.addListener,Bn.prototype.prependListener=function(e,t){return Aj(this,e,t,!0)};function Zte(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function kj(n,e,t){var r={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},s=Zte.bind(r);return s.listener=t,r.wrapFn=s,s}Bn.prototype.once=function(e,t){return wm(t),this.on(e,kj(this,e,t)),this},Bn.prototype.prependOnceListener=function(e,t){return wm(t),this.prependListener(e,kj(this,e,t)),this},Bn.prototype.removeListener=function(e,t){var r,s,i,o,a;if(wm(t),s=this._events,s===void 0)return this;if(r=s[e],r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,r.listener||t));else if(typeof r!="function"){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;i===0?r.shift():ene(r,i),r.length===1&&(s[e]=r[0]),s.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this},Bn.prototype.off=Bn.prototype.removeListener,Bn.prototype.removeAllListeners=function(e){var t,r,s;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var i=Object.keys(r),o;for(s=0;s<i.length;++s)o=i[s],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=r[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this};function Lj(n,e,t){var r=n._events;if(r===void 0)return[];var s=r[e];return s===void 0?[]:typeof s=="function"?t?[s.listener||s]:[s]:t?tne(s):Nj(s,s.length)}Bn.prototype.listeners=function(e){return Lj(this,e,!0)},Bn.prototype.rawListeners=function(e){return Lj(this,e,!1)},Bn.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):Mj.call(n,e)},Bn.prototype.listenerCount=Mj;function Mj(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Bn.prototype.eventNames=function(){return this._eventsCount>0?Em(this._events):[]};function Nj(n,e){for(var t=new Array(e),r=0;r<e;++r)t[r]=n[r];return t}function ene(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function tne(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function nne(n,e){return new Promise(function(t,r){function s(o){n.removeListener(e,i),r(o)}function i(){typeof n.removeListener=="function"&&n.removeListener("error",s),t([].slice.call(arguments))}Oj(n,e,i,{once:!0}),e!=="error"&&rne(n,s,{once:!0})})}function rne(n,e,t){typeof n.on=="function"&&Oj(n,"error",e,t)}function Oj(n,e,t,r){if(typeof n.on=="function")r.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function s(i){r.once&&n.removeEventListener(e,s),t(i)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var sne=sE.exports,Pj=Qte(sne),gr;(function(n){n[n.timeout=1]="timeout",n[n.transportClosed=2]="transportClosed",n[n.clientDisconnected=3]="clientDisconnected",n[n.clientClosed=4]="clientClosed",n[n.clientConnectToken=5]="clientConnectToken",n[n.clientRefreshToken=6]="clientRefreshToken",n[n.subscriptionUnsubscribed=7]="subscriptionUnsubscribed",n[n.subscriptionSubscribeToken=8]="subscriptionSubscribeToken",n[n.subscriptionRefreshToken=9]="subscriptionRefreshToken",n[n.transportWriteError=10]="transportWriteError",n[n.connectionClosed=11]="connectionClosed",n[n.badConfiguration=12]="badConfiguration"})(gr||(gr={}));var qa;(function(n){n[n.connectCalled=0]="connectCalled",n[n.transportClosed=1]="transportClosed",n[n.noPing=2]="noPing",n[n.subscribeTimeout=3]="subscribeTimeout",n[n.unsubscribeError=4]="unsubscribeError"})(qa||(qa={}));var Ef;(function(n){n[n.disconnectCalled=0]="disconnectCalled",n[n.unauthorized=1]="unauthorized",n[n.badProtocol=2]="badProtocol",n[n.messageSizeLimit=3]="messageSizeLimit"})(Ef||(Ef={}));var Tm;(function(n){n[n.subscribeCalled=0]="subscribeCalled",n[n.transportClosed=1]="transportClosed"})(Tm||(Tm={}));var Cm;(function(n){n[n.unsubscribeCalled=0]="unsubscribeCalled",n[n.unauthorized=1]="unauthorized",n[n.clientClosed=2]="clientClosed"})(Cm||(Cm={}));var kr;(function(n){n.Disconnected="disconnected",n.Connecting="connecting",n.Connected="connected"})(kr||(kr={}));var Ps;(function(n){n.Unsubscribed="unsubscribed",n.Subscribing="subscribing",n.Subscribed="subscribed"})(Ps||(Ps={}));function ine(n,e){return n.lastIndexOf(e,0)===0}function Dj(n){return n==null?!1:typeof n=="function"}function one(n,e){if(globalThis.console){const t=globalThis.console[n];Dj(t)&&t.apply(globalThis.console,e)}}function ane(n,e){return Math.floor(Math.random()*(e-n+1)+n)}function Im(n,e,t){n>31&&(n=31);const r=ane(0,Math.min(t,e*Math.pow(2,n)));return Math.min(t,e+r)}function lne(n){return"error"in n&&n.error!==null}function Rm(n){return Math.min(n*1e3,2147483647)}class cne extends Pj{constructor(e,t,r){super(),this._resubscribeTimeout=null,this._refreshTimeout=null,this.channel=t,this.state=Ps.Unsubscribed,this._centrifuge=e,this._token="",this._getToken=null,this._data=null,this._getData=null,this._recover=!1,this._offset=null,this._epoch=null,this._recoverable=!1,this._positioned=!1,this._joinLeave=!1,this._minResubscribeDelay=500,this._maxResubscribeDelay=2e4,this._resubscribeTimeout=null,this._resubscribeAttempts=0,this._promises={},this._promiseId=0,this._inflight=!1,this._refreshTimeout=null,this._setOptions(r),this._centrifuge._debugEnabled?(this.on("state",s=>{this._centrifuge._debug("subscription state",t,s.oldState,"->",s.newState)}),this.on("error",s=>{this._centrifuge._debug("subscription error",t,s)})):this.on("error",function(){Function.prototype()})}ready(e){return this.state===Ps.Unsubscribed?Promise.reject({code:gr.subscriptionUnsubscribed,message:this.state}):this.state===Ps.Subscribed?Promise.resolve():new Promise((t,r)=>{const s={resolve:t,reject:r};e&&(s.timeout=setTimeout(function(){r({code:gr.timeout,message:"timeout"})},e)),this._promises[this._nextPromiseId()]=s})}subscribe(){this._isSubscribed()||(this._resubscribeAttempts=0,this._setSubscribing(Tm.subscribeCalled,"subscribe called"))}unsubscribe(){this._setUnsubscribed(Cm.unsubscribeCalled,"unsubscribe called",!0)}publish(e){const t=this;return this._methodCall().then(function(){return t._centrifuge.publish(t.channel,e)})}presence(){const e=this;return this._methodCall().then(function(){return e._centrifuge.presence(e.channel)})}presenceStats(){const e=this;return this._methodCall().then(function(){return e._centrifuge.presenceStats(e.channel)})}history(e){const t=this;return this._methodCall().then(function(){return t._centrifuge.history(t.channel,e)})}_methodCall(){return this._isSubscribed()?Promise.resolve():this._isUnsubscribed()?Promise.reject({code:gr.subscriptionUnsubscribed,message:this.state}):new Promise((e,t)=>{const r=setTimeout(function(){t({code:gr.timeout,message:"timeout"})},this._centrifuge._config.timeout);this._promises[this._nextPromiseId()]={timeout:r,resolve:e,reject:t}})}_nextPromiseId(){return++this._promiseId}_needRecover(){return this._recover===!0}_isUnsubscribed(){return this.state===Ps.Unsubscribed}_isSubscribing(){return this.state===Ps.Subscribing}_isSubscribed(){return this.state===Ps.Subscribed}_setState(e){if(this.state!==e){const t=this.state;return this.state=e,this.emit("state",{newState:e,oldState:t,channel:this.channel}),!0}return!1}_usesToken(){return this._token!==""||this._getToken!==null}_clearSubscribingState(){this._resubscribeAttempts=0,this._clearResubscribeTimeout()}_clearSubscribedState(){this._clearRefreshTimeout()}_setSubscribed(e){if(!this._isSubscribing())return;this._clearSubscribingState(),e.recoverable&&(this._recover=!0,this._offset=e.offset||0,this._epoch=e.epoch||""),this._setState(Ps.Subscribed);const t=this._centrifuge._getSubscribeContext(this.channel,e);this.emit("subscribed",t),this._resolvePromises();const r=e.publications;if(r&&r.length>0)for(const s in r)r.hasOwnProperty(s)&&this._handlePublication(r[s]);e.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),Rm(e.ttl)))}_setSubscribing(e,t){this._isSubscribing()||(this._isSubscribed()&&this._clearSubscribedState(),this._setState(Ps.Subscribing)&&this.emit("subscribing",{channel:this.channel,code:e,reason:t}),this._subscribe(!1,!1))}_subscribe(e,t){if(this._centrifuge._debug("subscribing on",this.channel),this._centrifuge.state!==kr.Connected&&!e)return this._centrifuge._debug("delay subscribe on",this.channel,"till connected"),null;const r=this,s={channel:r.channel};return!this._usesToken()||this._token?r._getData?(r._getData(s).then(function(i){r._isSubscribing()&&(r._data=i,r._sendSubscribe(r._token,!1))}),null):r._sendSubscribe(r._token,t):(e||this._getSubscriptionToken().then(function(i){if(r._isSubscribing()){if(!i){r._failUnauthorized();return}r._token=i,r._getData?r._getData(s).then(function(o){r._isSubscribing()&&(r._data=o,r._sendSubscribe(i,!1))}):r._sendSubscribe(i,!1)}}).catch(function(i){if(r._isSubscribing()){if(i instanceof Kl){r._failUnauthorized();return}r.emit("error",{type:"subscribeToken",channel:r.channel,error:{code:gr.subscriptionSubscribeToken,message:i!==void 0?i.toString():""}}),r._scheduleResubscribe()}}),null)}_sendSubscribe(e,t){const s={channel:this.channel};if(e&&(s.token=e),this._data&&(s.data=this._data),this._positioned&&(s.positioned=!0),this._recoverable&&(s.recoverable=!0),this._joinLeave&&(s.join_leave=!0),this._needRecover()){s.recover=!0;const o=this._getOffset();o&&(s.offset=o);const a=this._getEpoch();a&&(s.epoch=a)}const i={subscribe:s};return this._inflight=!0,this._centrifuge._call(i,t).then(o=>{this._inflight=!1;const a=o.reply.subscribe;this._handleSubscribeResponse(a),o.next&&o.next()},o=>{this._inflight=!1,this._handleSubscribeError(o.error),o.next&&o.next()}),i}_handleSubscribeError(e){if(this._isSubscribing()){if(e.code===gr.timeout){this._centrifuge._disconnect(qa.subscribeTimeout,"subscribe timeout",!0);return}this._subscribeError(e)}}_handleSubscribeResponse(e){this._isSubscribing()&&this._setSubscribed(e)}_setUnsubscribed(e,t,r){this._isUnsubscribed()||(this._isSubscribed()&&(r&&this._centrifuge._unsubscribe(this),this._clearSubscribedState()),this._isSubscribing()&&(this._inflight&&r&&this._centrifuge._unsubscribe(this),this._clearSubscribingState()),this._setState(Ps.Unsubscribed)&&this.emit("unsubscribed",{channel:this.channel,code:e,reason:t}),this._rejectPromises({code:gr.subscriptionUnsubscribed,message:this.state}))}_handlePublication(e){const t=this._centrifuge._getPublicationContext(this.channel,e);this.emit("publication",t),e.offset&&(this._offset=e.offset)}_handleJoin(e){const t=this._centrifuge._getJoinLeaveContext(e.info);this.emit("join",{channel:this.channel,info:t})}_handleLeave(e){const t=this._centrifuge._getJoinLeaveContext(e.info);this.emit("leave",{channel:this.channel,info:t})}_resolvePromises(){for(const e in this._promises)this._promises.hasOwnProperty(e)&&(this._promises[e].timeout&&clearTimeout(this._promises[e].timeout),this._promises[e].resolve(),delete this._promises[e])}_rejectPromises(e){for(const t in this._promises)this._promises.hasOwnProperty(t)&&(this._promises[t].timeout&&clearTimeout(this._promises[t].timeout),this._promises[t].reject(e),delete this._promises[t])}_scheduleResubscribe(){const e=this,t=this._getResubscribeDelay();this._resubscribeTimeout=setTimeout(function(){e._isSubscribing()&&e._subscribe(!1,!1)},t)}_subscribeError(e){if(this._isSubscribing())if(e.code<100||e.code===109||e.temporary===!0){e.code===109&&(this._token="");const t={channel:this.channel,type:"subscribe",error:e};this._centrifuge.state===kr.Connected&&this.emit("error",t),this._scheduleResubscribe()}else this._setUnsubscribed(e.code,e.message,!1)}_getResubscribeDelay(){const e=Im(this._resubscribeAttempts,this._minResubscribeDelay,this._maxResubscribeDelay);return this._resubscribeAttempts++,e}_setOptions(e){e&&(e.since&&(this._offset=e.since.offset,this._epoch=e.since.epoch,this._recover=!0),e.data&&(this._data=e.data),e.getData&&(this._getData=e.getData),e.minResubscribeDelay!==void 0&&(this._minResubscribeDelay=e.minResubscribeDelay),e.maxResubscribeDelay!==void 0&&(this._maxResubscribeDelay=e.maxResubscribeDelay),e.token&&(this._token=e.token),e.getToken&&(this._getToken=e.getToken),e.positioned===!0&&(this._positioned=!0),e.recoverable===!0&&(this._recoverable=!0),e.joinLeave===!0&&(this._joinLeave=!0))}_getOffset(){const e=this._offset;return e!==null?e:0}_getEpoch(){const e=this._epoch;return e!==null?e:""}_clearRefreshTimeout(){this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)}_clearResubscribeTimeout(){this._resubscribeTimeout!==null&&(clearTimeout(this._resubscribeTimeout),this._resubscribeTimeout=null)}_getSubscriptionToken(){this._centrifuge._debug("get subscription token for channel",this.channel);const e={channel:this.channel},t=this._getToken;if(t===null)throw this.emit("error",{type:"configuration",channel:this.channel,error:{code:gr.badConfiguration,message:"provide a function to get channel subscription token"}}),new Kl("");return t(e)}_refresh(){this._clearRefreshTimeout();const e=this;this._getSubscriptionToken().then(function(t){if(!e._isSubscribed())return;if(!t){e._failUnauthorized();return}e._token=t;const s={sub_refresh:{channel:e.channel,token:t}};e._centrifuge._call(s).then(i=>{const o=i.reply.sub_refresh;e._refreshResponse(o),i.next&&i.next()},i=>{e._refreshError(i.error),i.next&&i.next()})}).catch(function(t){if(t instanceof Kl){e._failUnauthorized();return}e.emit("error",{type:"refreshToken",channel:e.channel,error:{code:gr.subscriptionRefreshToken,message:t!==void 0?t.toString():""}}),e._refreshTimeout=setTimeout(()=>e._refresh(),e._getRefreshRetryDelay())})}_refreshResponse(e){this._isSubscribed()&&(this._centrifuge._debug("subscription token refreshed, channel",this.channel),this._clearRefreshTimeout(),e.expires===!0&&(this._refreshTimeout=setTimeout(()=>this._refresh(),Rm(e.ttl))))}_refreshError(e){this._isSubscribed()&&(e.code<100||e.temporary===!0?(this.emit("error",{type:"refresh",channel:this.channel,error:e}),this._refreshTimeout=setTimeout(()=>this._refresh(),this._getRefreshRetryDelay())):this._setUnsubscribed(e.code,e.message,!0))}_getRefreshRetryDelay(){return Im(0,1e4,2e4)}_failUnauthorized(){this._setUnsubscribed(Cm.unauthorized,"unauthorized",!0)}}class une{constructor(e,t){this.endpoint=e,this.options=t,this._transport=null}name(){return"sockjs"}subName(){return"sockjs-"+this._transport.transport}emulation(){return!1}supported(){return this.options.sockjs!==null}initialize(e,t){this._transport=new this.options.sockjs(this.endpoint,null,this.options.sockjsOptions),this._transport.onopen=()=>{t.onOpen()},this._transport.onerror=r=>{t.onError(r)},this._transport.onclose=r=>{t.onClose(r)},this._transport.onmessage=r=>{t.onMessage(r.data)}}close(){this._transport.close()}send(e){this._transport.send(e)}}class jj{constructor(e,t){this.endpoint=e,this.options=t,this._transport=null}name(){return"websocket"}subName(){return"websocket"}emulation(){return!1}supported(){return this.options.websocket!==void 0&&this.options.websocket!==null}initialize(e,t){let r="";e==="protobuf"&&(r="centrifuge-protobuf"),r!==""?this._transport=new this.options.websocket(this.endpoint,r):this._transport=new this.options.websocket(this.endpoint),e==="protobuf"&&(this._transport.binaryType="arraybuffer"),this._transport.onopen=()=>{t.onOpen()},this._transport.onerror=s=>{t.onError(s)},this._transport.onclose=s=>{t.onClose(s)},this._transport.onmessage=s=>{t.onMessage(s.data)}}close(){this._transport.close()}send(e){this._transport.send(e)}}class dne{constructor(e,t){this.endpoint=e,this.options=t,this._abortController=null,this._utf8decoder=new TextDecoder,this._protocol="json"}name(){return"http_stream"}subName(){return"http_stream"}emulation(){return!0}_handleErrors(e){if(!e.ok)throw new Error(e.status);return e}_fetchEventTarget(e,t,r){const s=new EventTarget,i=e.options.fetch;return i(t,r).then(e._handleErrors).then(o=>{s.dispatchEvent(new Event("open"));let a="",l=0,c=new Uint8Array;const d=o.body.getReader();return new e.options.readableStream({start(f){function p(){return d.read().then(({done:m,value:g})=>{if(m){s.dispatchEvent(new Event("close")),f.close();return}try{if(e._protocol==="json")for(a+=e._utf8decoder.decode(g);l<a.length;)if(a[l]===`
344 `){const v=a.substring(0,l);s.dispatchEvent(new MessageEvent("message",{data:v})),a=a.substring(l+1),l=0}else++l;else{const v=new Uint8Array(c.length+g.length);for(v.set(c),v.set(g,c.length),c=v;;){const y=e.options.decoder.decodeReply(c);if(y.ok){const b=c.slice(0,y.pos);s.dispatchEvent(new MessageEvent("message",{data:b})),c=c.slice(y.pos);continue}break}}}catch(v){s.dispatchEvent(new Event("error",{detail:v})),s.dispatchEvent(new Event("close")),f.close();return}p()}).catch(function(m){s.dispatchEvent(new Event("error",{detail:m})),s.dispatchEvent(new Event("close")),f.close()})}return p()}})}).catch(o=>{s.dispatchEvent(new Event("error",{detail:o})),s.dispatchEvent(new Event("close"))}),s}supported(){return this.options.fetch!==null&&this.options.readableStream!==null&&typeof TextDecoder<"u"&&typeof AbortController<"u"&&typeof EventTarget<"u"&&typeof Event<"u"&&typeof MessageEvent<"u"&&typeof Error<"u"}initialize(e,t,r){this._protocol=e,this._abortController=new AbortController;let s,i;e==="json"?(s={Accept:"application/json","Content-Type":"application/json"},i=r):(s={Accept:"application/octet-stream","Content-Type":"application/octet-stream"},i=r);const o={method:"POST",headers:s,body:i,mode:"cors",credentials:"same-origin",cache:"no-cache",signal:this._abortController.signal},a=this._fetchEventTarget(this,this.endpoint,o);a.addEventListener("open",()=>{t.onOpen()}),a.addEventListener("error",l=>{this._abortController.abort(),t.onError(l)}),a.addEventListener("close",()=>{this._abortController.abort(),t.onClose({code:4,reason:"connection closed"})}),a.addEventListener("message",l=>{t.onMessage(l.data)})}close(){this._abortController.abort()}send(e,t,r){let s,i;const o={session:t,node:r,data:e};this._protocol==="json"?(s={"Content-Type":"application/json"},i=JSON.stringify(o)):(s={"Content-Type":"application/octet-stream"},i=this.options.encoder.encodeEmulationRequest(o));const a=this.options.fetch,l={method:"POST",headers:s,body:i,mode:"cors",credentials:"same-origin",cache:"no-cache"};a(this.options.emulationEndpoint,l)}}class fne{constructor(e,t){this.endpoint=e,this.options=t,this._protocol="json",this._transport=null,this._onClose=null}name(){return"sse"}subName(){return"sse"}emulation(){return!0}supported(){return this.options.eventsource!==null&&this.options.fetch!==null}initialize(e,t,r){let s;globalThis&&globalThis.document&&globalThis.document.baseURI?s=new URL(this.endpoint,globalThis.document.baseURI):s=new URL(this.endpoint),s.searchParams.append("cf_connect",r);const i={},o=new this.options.eventsource(s.toString(),i);this._transport=o;const a=this;o.onopen=function(){t.onOpen()},o.onerror=function(l){o.close(),t.onError(l),t.onClose({code:4,reason:"connection closed"})},o.onmessage=function(l){t.onMessage(l.data)},a._onClose=function(){t.onClose({code:4,reason:"connection closed"})}}close(){this._transport.close(),this._onClose!==null&&this._onClose()}send(e,t,r){const s={session:t,node:r,data:e},i={"Content-Type":"application/json"},o=JSON.stringify(s),a=this.options.fetch,l={method:"POST",headers:i,body:o,mode:"cors",credentials:"same-origin",cache:"no-cache"};a(this.options.emulationEndpoint,l)}}function Am(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(d){try{c(r.next(d))}catch(f){o(f)}}function l(d){try{c(r.throw(d))}catch(f){o(f)}}function c(d){d.done?i(d.value):s(d.value).then(a,l)}c((r=r.apply(n,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;class hne{constructor(e,t){this.endpoint=e,this.options=t,this._transport=null,this._stream=null,this._writer=null,this._utf8decoder=new TextDecoder,this._protocol="json"}name(){return"webtransport"}subName(){return"webtransport"}emulation(){return!1}supported(){return this.options.webtransport!==void 0&&this.options.webtransport!==null}initialize(e,t){return Am(this,void 0,void 0,function*(){let r;globalThis&&globalThis.document&&globalThis.document.baseURI?r=new URL(this.endpoint,globalThis.document.baseURI):r=new URL(this.endpoint),e==="protobuf"&&r.searchParams.append("cf_protocol","protobuf"),this._protocol=e;const s=new EventTarget;this._transport=new this.options.webtransport(r.toString()),this._transport.closed.then(()=>{t.onClose({code:4,reason:"connection closed"})}).catch(()=>{t.onClose({code:4,reason:"connection closed"})});try{yield this._transport.ready}catch{this.close();return}let i;try{i=yield this._transport.createBidirectionalStream()}catch{this.close();return}this._stream=i,this._writer=this._stream.writable.getWriter(),s.addEventListener("close",()=>{t.onClose({code:4,reason:"connection closed"})}),s.addEventListener("message",o=>{t.onMessage(o.data)}),this._startReading(s),t.onOpen()})}_startReading(e){return Am(this,void 0,void 0,function*(){const t=this._stream.readable.getReader();let r="",s=0,i=new Uint8Array;try{for(;;){const{done:o,value:a}=yield t.read();if(a.length>0)if(this._protocol==="json")for(r+=this._utf8decoder.decode(a);s<r.length;)if(r[s]===`
345 `){const l=r.substring(0,s);e.dispatchEvent(new MessageEvent("message",{data:l})),r=r.substring(s+1),s=0}else++s;else{const l=new Uint8Array(i.length+a.length);for(l.set(i),l.set(a,i.length),i=l;;){const c=this.options.decoder.decodeReply(i);if(c.ok){const d=i.slice(0,c.pos);e.dispatchEvent(new MessageEvent("message",{data:d})),i=i.slice(c.pos);continue}break}}if(o)break}}catch{e.dispatchEvent(new Event("close"))}})}close(){return Am(this,void 0,void 0,function*(){try{this._writer&&(yield this._writer.close()),this._transport.close()}catch{}})}send(e){return Am(this,void 0,void 0,function*(){let t;this._protocol==="json"?t=new TextEncoder().encode(e+`
346 `):t=e;try{yield this._writer.write(t)}catch{this.close()}})}}class Fj{name(){return"json"}encodeCommands(e){return e.map(t=>JSON.stringify(t)).join(`
347 `)}decodeReplies(e){return e.trim().split(`
348 `).map(t=>JSON.parse(t))}}const pne={token:"",getToken:null,data:null,getData:null,debug:!1,name:"js",version:"",fetch:null,readableStream:null,websocket:null,eventsource:null,sockjs:null,sockjsOptions:{},emulationEndpoint:"/emulation",minReconnectDelay:500,maxReconnectDelay:2e4,timeout:5e3,maxServerPingDelay:1e4,networkEventTarget:null};class Kl extends Error{constructor(e){super(e),this.name=this.constructor.name}}class km extends Pj{constructor(e,t){super(),this._reconnectTimeout=null,this._refreshTimeout=null,this._serverPingTimeout=null,this.state=kr.Disconnected,this._endpoint=e,this._emulation=!1,this._transports=[],this._currentTransportIndex=0,this._triedAllTransports=!1,this._transportWasOpen=!1,this._transport=null,this._transportId=0,this._deviceWentOffline=!1,this._transportClosed=!0,this._codec=new Fj,this._reconnecting=!1,this._reconnectTimeout=null,this._reconnectAttempts=0,this._client=null,this._session="",this._node="",this._subs={},this._serverSubs={},this._commandId=0,this._commands=[],this._batching=!1,this._refreshRequired=!1,this._refreshTimeout=null,this._callbacks={},this._token="",this._data=null,this._dispatchPromise=Promise.resolve(),this._serverPing=0,this._serverPingTimeout=null,this._sendPong=!1,this._promises={},this._promiseId=0,this._debugEnabled=!1,this._networkEventsSet=!1,this._config=Object.assign(Object.assign({},pne),t),this._configure(),this._debugEnabled?(this.on("state",r=>{this._debug("client state",r.oldState,"->",r.newState)}),this.on("error",r=>{this._debug("client error",r)})):this.on("error",function(){Function.prototype()})}newSubscription(e,t){if(this.getSubscription(e)!==null)throw new Error("Subscription to the channel "+e+" already exists");const r=new cne(this,e,t);return this._subs[e]=r,r}getSubscription(e){return this._getSub(e)}removeSubscription(e){e&&(e.state!==Ps.Unsubscribed&&e.unsubscribe(),this._removeSubscription(e))}subscriptions(){return this._subs}ready(e){return this.state===kr.Disconnected?Promise.reject({code:gr.clientDisconnected,message:"client disconnected"}):this.state===kr.Connected?Promise.resolve():new Promise((t,r)=>{const s={resolve:t,reject:r};e&&(s.timeout=setTimeout(function(){r({code:gr.timeout,message:"timeout"})},e)),this._promises[this._nextPromiseId()]=s})}connect(){if(this._isConnected()){this._debug("connect called when already connected");return}if(this._isConnecting()){this._debug("connect called when already connecting");return}this._debug("connect called"),this._reconnectAttempts=0,this._startConnecting()}disconnect(){this._disconnect(Ef.disconnectCalled,"disconnect called",!1)}setToken(e){this._token=e}send(e){const t={send:{data:e}},r=this;return this._methodCall().then(function(){return r._transportSendCommands([t])?Promise.resolve():Promise.reject(r._createErrorObject(gr.transportWriteError,"transport write error"))})}rpc(e,t){const r={rpc:{method:e,data:t}},s=this;return this._methodCall().then(function(){return s._callPromise(r,function(i){return{data:i.rpc.data}})})}publish(e,t){const r={publish:{channel:e,data:t}},s=this;return this._methodCall().then(function(){return s._callPromise(r,function(){return{}})})}history(e,t){const r={history:this._getHistoryRequest(e,t)},s=this;return this._methodCall().then(function(){return s._callPromise(r,function(i){const o=i.history,a=[];if(o.publications)for(let l=0;l<o.publications.length;l++)a.push(s._getPublicationContext(e,o.publications[l]));return{publications:a,epoch:o.epoch||"",offset:o.offset||0}})})}presence(e){const t={presence:{channel:e}},r=this;return this._methodCall().then(function(){return r._callPromise(t,function(s){const i=s.presence.presence;for(const o in i)if(i.hasOwnProperty(o)){const a=i[o].conn_info,l=i[o].chan_info;a&&(i[o].connInfo=a),l&&(i[o].chanInfo=l)}return{clients:i}})})}presenceStats(e){const t={presence_stats:{channel:e}},r=this;return this._methodCall().then(function(){return r._callPromise(t,function(s){const i=s.presence_stats;return{numUsers:i.num_users,numClients:i.num_clients}})})}startBatching(){this._batching=!0}stopBatching(){const e=this;Promise.resolve().then(function(){Promise.resolve().then(function(){e._batching=!1,e._flush()})})}_debug(...e){this._debugEnabled&&one("debug",e)}_formatOverride(){}_configure(){if(!("Promise"in globalThis))throw new Error("Promise polyfill required");if(!this._endpoint)throw new Error("endpoint configuration required");if(this._config.token!==null&&(this._token=this._config.token),this._config.data!==null&&(this._data=this._config.data),this._codec=new Fj,this._formatOverride(),(this._config.debug===!0||typeof localStorage<"u"&&localStorage.getItem("centrifuge.debug"))&&(this._debugEnabled=!0),this._debug("config",this._config),typeof this._endpoint!="string")if(typeof this._endpoint=="object"&&this._endpoint instanceof Array){this._transports=this._endpoint,this._emulation=!0;for(const e in this._transports)if(this._transports.hasOwnProperty(e)){const t=this._transports[e];if(!t.endpoint||!t.transport)throw new Error("malformed transport configuration");const r=t.transport;if(["websocket","http_stream","sse","sockjs","webtransport"].indexOf(r)<0)throw new Error("unsupported transport name: "+r)}}else throw new Error("unsupported url configuration type: only string or array of objects are supported")}_setState(e){if(this.state!==e){this._reconnecting=!1;const t=this.state;return this.state=e,this.emit("state",{newState:e,oldState:t}),!0}return!1}_isDisconnected(){return this.state===kr.Disconnected}_isConnecting(){return this.state===kr.Connecting}_isConnected(){return this.state===kr.Connected}_nextCommandId(){return++this._commandId}_setNetworkEvents(){if(this._networkEventsSet)return;let e=null;this._config.networkEventTarget!==null?e=this._config.networkEventTarget:typeof globalThis.addEventListener<"u"&&(e=globalThis),e&&(e.addEventListener("offline",()=>{this._debug("offline event triggered"),(this.state===kr.Connected||this.state===kr.Connecting)&&(this._disconnect(qa.transportClosed,"transport closed",!0),this._deviceWentOffline=!0)}),e.addEventListener("online",()=>{this._debug("online event triggered"),this.state===kr.Connecting&&(this._deviceWentOffline&&!this._transportClosed&&(this._deviceWentOffline=!1,this._transportClosed=!0),this._clearReconnectTimeout(),this._startReconnecting())}),this._networkEventsSet=!0)}_getReconnectDelay(){const e=Im(this._reconnectAttempts,this._config.minReconnectDelay,this._config.maxReconnectDelay);return this._reconnectAttempts+=1,e}_clearOutgoingRequests(){for(const e in this._callbacks)if(this._callbacks.hasOwnProperty(e)){const t=this._callbacks[e];clearTimeout(t.timeout);const r=t.errback;if(!r)continue;r({error:this._createErrorObject(gr.connectionClosed,"connection closed")})}this._callbacks={}}_clearConnectedState(){this._client=null,this._clearServerPingTimeout(),this._clearRefreshTimeout();for(const e in this._subs){if(!this._subs.hasOwnProperty(e))continue;const t=this._subs[e];t.state===Ps.Subscribed&&t._setSubscribing(Tm.transportClosed,"transport closed")}for(const e in this._serverSubs)this._serverSubs.hasOwnProperty(e)&&this.emit("subscribing",{channel:e})}_handleWriteError(e){for(const t of e){const r=t.id;if(!(r in this._callbacks))continue;const s=this._callbacks[r];clearTimeout(this._callbacks[r].timeout),delete this._callbacks[r];const i=s.errback;i({error:this._createErrorObject(gr.transportWriteError,"transport write error")})}}_transportSendCommands(e){if(!e.length)return!0;if(!this._transport)return!1;try{this._transport.send(this._codec.encodeCommands(e),this._session,this._node)}catch(t){return this._debug("error writing commands",t),this._handleWriteError(e),!1}return!0}_initializeTransport(){let e;this._config.websocket!==null?e=this._config.websocket:typeof globalThis.WebSocket!="function"&&typeof globalThis.WebSocket!="object"||(e=globalThis.WebSocket);let t=null;this._config.sockjs!==null?t=this._config.sockjs:typeof globalThis.SockJS<"u"&&(t=globalThis.SockJS);let r=null;this._config.eventsource!==null?r=this._config.eventsource:typeof globalThis.EventSource<"u"&&(r=globalThis.EventSource);let s=null;this._config.fetch!==null?s=this._config.fetch:typeof globalThis.fetch<"u"&&(s=globalThis.fetch);let i=null;if(this._config.readableStream!==null?i=this._config.readableStream:typeof globalThis.ReadableStream<"u"&&(i=globalThis.ReadableStream),this._emulation){this._currentTransportIndex>=this._transports.length&&(this._triedAllTransports=!0,this._currentTransportIndex=0);let g=0;for(;;){if(g>=this._transports.length)throw new Error("no supported transport found");const v=this._transports[this._currentTransportIndex],y=v.transport,b=v.endpoint;if(y==="websocket"){if(this._debug("trying websocket transport"),this._transport=new jj(b,{websocket:e}),!this._transport.supported()){this._debug("websocket transport not available"),this._currentTransportIndex++,g++;continue}}else if(y==="webtransport"){if(this._debug("trying webtransport transport"),this._transport=new hne(b,{webtransport:globalThis.WebTransport,decoder:this._codec,encoder:this._codec}),!this._transport.supported()){this._debug("webtransport transport not available"),this._currentTransportIndex++,g++;continue}}else if(y==="http_stream"){if(this._debug("trying http_stream transport"),this._transport=new dne(b,{fetch:s,readableStream:i,emulationEndpoint:this._config.emulationEndpoint,decoder:this._codec,encoder:this._codec}),!this._transport.supported()){this._debug("http_stream transport not available"),this._currentTransportIndex++,g++;continue}}else if(y==="sse"){if(this._debug("trying sse transport"),this._transport=new fne(b,{eventsource:r,fetch:s,emulationEndpoint:this._config.emulationEndpoint}),!this._transport.supported()){this._debug("sse transport not available"),this._currentTransportIndex++,g++;continue}}else if(y==="sockjs"){if(this._debug("trying sockjs"),this._transport=new une(b,{sockjs:t,sockjsOptions:this._config.sockjsOptions}),!this._transport.supported()){this._debug("sockjs transport not available"),this._currentTransportIndex++,g++;continue}}else throw new Error("unknown transport "+y);break}}else{if(ine(this._endpoint,"http"))throw new Error("Provide explicit transport endpoints configuration in case of using HTTP (i.e. using array of TransportEndpoint instead of a single string), or use ws(s):// scheme in an endpoint if you aimed using WebSocket transport");if(this._debug("client will use websocket"),this._transport=new jj(this._endpoint,{websocket:e}),!this._transport.supported())throw new Error("WebSocket not available")}const o=this,a=this._transport,l=this._nextTransportId();o._debug("id of transport",l);let c=!1,d=!0;this._transport.name()==="sse"&&(d=!1);const f=[];if(this._transport.emulation()){const g=o._sendConnect(!0);if(f.push(g),d){const v=o._sendSubscribeCommands(!0,!0);for(const y in v)v.hasOwnProperty(y)&&f.push(v[y])}}this._setNetworkEvents();const p=this._codec.encodeCommands(f);this._transportClosed=!1;let m;m=setTimeout(function(){a.close()},this._config.timeout),this._transport.initialize(this._codec.name(),{onOpen:function(){if(m&&(clearTimeout(m),m=null),o._transportId!=l){o._debug("open callback from non-actual transport"),a.close();return}c=!0,o._debug(a.subName(),"transport open"),o._transportWasOpen=!0,!a.emulation()&&(o.startBatching(),o._sendConnect(!1),d&&o._sendSubscribeCommands(!0,!1),o.stopBatching())},onError:function(g){if(o._transportId!=l){o._debug("error callback from non-actual transport");return}o._debug("transport level error",g)},onClose:function(g){if(m&&(clearTimeout(m),m=null),o._transportId!=l){o._debug("close callback from non-actual transport");return}o._debug(a.subName(),"transport closed"),o._transportClosed=!0;let v="connection closed",y=!0,b=0;if(g&&"code"in g&&g.code&&(b=g.code),g&&g.reason)try{const S=JSON.parse(g.reason);v=S.reason,y=S.reconnect}catch{v=g.reason,(b>=3500&&b<4e3||b>=4500&&b<5e3)&&(y=!1)}b<3e3?(b===1009?(b=Ef.messageSizeLimit,v="message size limit exceeded",y=!1):(b=qa.transportClosed,v="transport closed"),o._emulation&&!o._transportWasOpen&&(o._currentTransportIndex++,o._currentTransportIndex>=o._transports.length&&(o._triedAllTransports=!0,o._currentTransportIndex=0))):o._transportWasOpen=!0,o._isConnecting()&&!c&&o.emit("error",{type:"transport",error:{code:gr.transportClosed,message:"transport closed"},transport:a.name()}),o._reconnecting=!1,o._disconnect(b,v,y)},onMessage:function(g){o._dataReceived(g)}},p)}_sendConnect(e){const t=this._constructConnectCommand(),r=this;return this._call(t,e).then(s=>{const i=s.reply.connect;r._connectResponse(i),s.next&&s.next()},s=>{r._connectError(s.error),s.next&&s.next()}),t}_startReconnecting(){if(this._debug("start reconnecting"),!this._isConnecting()){this._debug("stop reconnecting: client not in connecting state");return}if(this._reconnecting){this._debug("reconnect already in progress, return from reconnect routine");return}if(this._transportClosed===!1){this._debug("waiting for transport close");return}this._reconnecting=!0;const e=this,t=this._token==="";if(!(this._refreshRequired||t&&this._config.getToken!==null)){this._config.getData?this._config.getData().then(function(s){e._isConnecting()&&(e._data=s,e._initializeTransport())}):this._initializeTransport();return}this._getToken().then(function(s){if(e._isConnecting()){if(s==null||s==null){e._failUnauthorized();return}e._token=s,e._debug("connection token refreshed"),e._config.getData?e._config.getData().then(function(i){e._isConnecting()&&(e._data=i,e._initializeTransport())}):e._initializeTransport()}}).catch(function(s){if(!e._isConnecting())return;if(s instanceof Kl){e._failUnauthorized();return}e.emit("error",{type:"connectToken",error:{code:gr.clientConnectToken,message:s!==void 0?s.toString():""}});const i=e._getReconnectDelay();e._debug("error on connection token refresh, reconnect after "+i+" milliseconds",s),e._reconnecting=!1,e._reconnectTimeout=setTimeout(()=>{e._startReconnecting()},i)})}_connectError(e){this.state===kr.Connecting&&(e.code===109&&(this._refreshRequired=!0),e.code<100||e.temporary===!0||e.code===109?(this.emit("error",{type:"connect",error:e}),this._debug("closing transport due to connect error"),this._reconnecting=!1,this._disconnect(e.code,e.message,!0)):this._disconnect(e.code,e.message,!1))}_scheduleReconnect(){if(!this._isConnecting())return;let e=!1;this._emulation&&!this._transportWasOpen&&!this._triedAllTransports&&(e=!0);let t=this._getReconnectDelay();e&&(t=0),this._debug("reconnect after "+t+" milliseconds"),this._reconnectTimeout=setTimeout(()=>{this._startReconnecting()},t)}_constructConnectCommand(){const e={};this._token&&(e.token=this._token),this._data&&(e.data=this._data),this._config.name&&(e.name=this._config.name),this._config.version&&(e.version=this._config.version);const t={};let r=!1;for(const s in this._serverSubs)if(this._serverSubs.hasOwnProperty(s)&&this._serverSubs[s].recoverable){r=!0;const i={recover:!0};this._serverSubs[s].offset&&(i.offset=this._serverSubs[s].offset),this._serverSubs[s].epoch&&(i.epoch=this._serverSubs[s].epoch),t[s]=i}return r&&(e.subs=t),{connect:e}}_getHistoryRequest(e,t){const r={channel:e};return t!==void 0&&(t.since&&(r.since={offset:t.since.offset},t.since.epoch&&(r.since.epoch=t.since.epoch)),t.limit!==void 0&&(r.limit=t.limit),t.reverse===!0&&(r.reverse=!0)),r}_methodCall(){return this._isConnected()?Promise.resolve():new Promise((e,t)=>{const r=setTimeout(function(){t({code:gr.timeout,message:"timeout"})},this._config.timeout);this._promises[this._nextPromiseId()]={timeout:r,resolve:e,reject:t}})}_callPromise(e,t){return new Promise((r,s)=>{this._call(e,!1).then(i=>{r(t(i.reply)),i.next&&i.next()},i=>{s(i.error),i.next&&i.next()})})}_dataReceived(e){this._serverPing>0&&this._waitServerPing();const t=this._codec.decodeReplies(e);this._dispatchPromise=this._dispatchPromise.then(()=>{let r;this._dispatchPromise=new Promise(s=>{r=s}),this._dispatchSynchronized(t,r)})}_dispatchSynchronized(e,t){let r=Promise.resolve();for(const s in e)e.hasOwnProperty(s)&&(r=r.then(()=>this._dispatchReply(e[s])));r=r.then(()=>{t()})}_dispatchReply(e){let t;const r=new Promise(i=>{t=i});if(e==null)return this._debug("dispatch: got undefined or null reply"),t(),r;const s=e.id;return s&&s>0?this._handleReply(e,t):e.push?this._handlePush(e.push,t):this._handleServerPing(t),r}_call(e,t){return new Promise((r,s)=>{e.id=this._nextCommandId(),this._registerCall(e.id,r,s),t||this._addCommand(e)})}_startConnecting(){this._debug("start connecting"),this._setState(kr.Connecting)&&this.emit("connecting",{code:qa.connectCalled,reason:"connect called"}),this._client=null,this._startReconnecting()}_disconnect(e,t,r){if(this._isDisconnected())return;const s=this.state,i={code:e,reason:t};let o=!1;if(r?o=this._setState(kr.Connecting):(o=this._setState(kr.Disconnected),this._rejectPromises({code:gr.clientDisconnected,message:"disconnected"})),this._clearOutgoingRequests(),s===kr.Connecting&&this._clearReconnectTimeout(),s===kr.Connected&&this._clearConnectedState(),o&&(this._isConnecting()?this.emit("connecting",i):this.emit("disconnected",i)),this._transport){this._debug("closing existing transport");const a=this._transport;this._transport=null,a.close(),this._transportClosed=!0,this._nextTransportId()}else this._debug("no transport to close");this._scheduleReconnect()}_failUnauthorized(){this._disconnect(Ef.unauthorized,"unauthorized",!1)}_getToken(){if(this._debug("get connection token"),!this._config.getToken)throw this.emit("error",{type:"configuration",error:{code:gr.badConfiguration,message:"token expired but no getToken function set in the configuration"}}),new Kl("");return this._config.getToken({})}_refresh(){const e=this._client,t=this;this._getToken().then(function(r){if(e!==t._client)return;if(!r){t._failUnauthorized();return}if(t._token=r,t._debug("connection token refreshed"),!t._isConnected())return;const s={refresh:{token:t._token}};t._call(s,!1).then(i=>{const o=i.reply.refresh;t._refreshResponse(o),i.next&&i.next()},i=>{t._refreshError(i.error),i.next&&i.next()})}).catch(function(r){if(t._isConnected()){if(r instanceof Kl){t._failUnauthorized();return}t.emit("error",{type:"refreshToken",error:{code:gr.clientRefreshToken,message:r!==void 0?r.toString():""}}),t._refreshTimeout=setTimeout(()=>t._refresh(),t._getRefreshRetryDelay())}})}_refreshError(e){e.code<100||e.temporary===!0?(this.emit("error",{type:"refresh",error:e}),this._refreshTimeout=setTimeout(()=>this._refresh(),this._getRefreshRetryDelay())):this._disconnect(e.code,e.message,!1)}_getRefreshRetryDelay(){return Im(0,5e3,1e4)}_refreshResponse(e){this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),e.expires&&(this._client=e.client,this._refreshTimeout=setTimeout(()=>this._refresh(),Rm(e.ttl)))}_removeSubscription(e){e!==null&&delete this._subs[e.channel]}_unsubscribe(e){if(!this._isConnected())return;const r={unsubscribe:{channel:e.channel}},s=this;this._call(r,!1).then(i=>{i.next&&i.next()},i=>{i.next&&i.next(),s._disconnect(qa.unsubscribeError,"unsubscribe error",!0)})}_getSub(e){const t=this._subs[e];return t||null}_isServerSub(e){return this._serverSubs[e]!==void 0}_sendSubscribeCommands(e,t){const r=[];for(const s in this._subs){if(!this._subs.hasOwnProperty(s))continue;const i=this._subs[s];if(i._inflight!==!0&&i.state===Ps.Subscribing){const o=i._subscribe(e,t);o&&r.push(o)}}return r}_connectResponse(e){if(this._transportWasOpen=!0,this._reconnectAttempts=0,this._refreshRequired=!1,this._isConnected())return;this._client=e.client,this._setState(kr.Connected),this._refreshTimeout&&clearTimeout(this._refreshTimeout),e.expires&&(this._refreshTimeout=setTimeout(()=>this._refresh(),Rm(e.ttl))),this._session=e.session,this._node=e.node,this.startBatching(),this._sendSubscribeCommands(!1,!1),this.stopBatching();const t={client:e.client,transport:this._transport.subName()};e.data&&(t.data=e.data),this.emit("connected",t),this._resolvePromises(),this._processServerSubs(e.subs||{}),e.ping&&e.ping>0?(this._serverPing=e.ping*1e3,this._sendPong=e.pong===!0,this._waitServerPing()):this._serverPing=0}_processServerSubs(e){for(const t in e){if(!e.hasOwnProperty(t))continue;const r=e[t];this._serverSubs[t]={offset:r.offset,epoch:r.epoch,recoverable:r.recoverable||!1};const s=this._getSubscribeContext(t,r);this.emit("subscribed",s)}for(const t in e){if(!e.hasOwnProperty(t))continue;const r=e[t];if(r.recovered){const s=r.publications;if(s&&s.length>0)for(const i in s)s.hasOwnProperty(i)&&this._handlePublication(t,s[i])}}for(const t in this._serverSubs)this._serverSubs.hasOwnProperty(t)&&(e[t]||(this.emit("unsubscribed",{channel:t}),delete this._serverSubs[t]))}_clearRefreshTimeout(){this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)}_clearReconnectTimeout(){this._reconnectTimeout!==null&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=null)}_clearServerPingTimeout(){this._serverPingTimeout!==null&&(clearTimeout(this._serverPingTimeout),this._serverPingTimeout=null)}_waitServerPing(){this._config.maxServerPingDelay!==0&&this._isConnected()&&(this._clearServerPingTimeout(),this._serverPingTimeout=setTimeout(()=>{this._isConnected()&&this._disconnect(qa.noPing,"no ping",!0)},this._serverPing+this._config.maxServerPingDelay))}_getSubscribeContext(e,t){const r={channel:e,positioned:!1,recoverable:!1,wasRecovering:!1,recovered:!1};t.recovered&&(r.recovered=!0),t.positioned&&(r.positioned=!0),t.recoverable&&(r.recoverable=!0),t.was_recovering&&(r.wasRecovering=!0);let s="";"epoch"in t&&(s=t.epoch);let i=0;return"offset"in t&&(i=t.offset),(r.positioned||r.recoverable)&&(r.streamPosition={offset:i,epoch:s}),t.data&&(r.data=t.data),r}_handleReply(e,t){const r=e.id;if(!(r in this._callbacks)){t();return}const s=this._callbacks[r];if(clearTimeout(this._callbacks[r].timeout),delete this._callbacks[r],lne(e)){const i=s.errback;if(!i){t();return}const o=e.error;i({error:o,next:t})}else{const i=s.callback;if(!i)return;i({reply:e,next:t})}}_handleJoin(e,t){const r=this._getSub(e);if(!r){if(this._isServerSub(e)){const s={channel:e,info:this._getJoinLeaveContext(t.info)};this.emit("join",s)}return}r._handleJoin(t)}_handleLeave(e,t){const r=this._getSub(e);if(!r){if(this._isServerSub(e)){const s={channel:e,info:this._getJoinLeaveContext(t.info)};this.emit("leave",s)}return}r._handleLeave(t)}_handleUnsubscribe(e,t){const r=this._getSub(e);if(!r){this._isServerSub(e)&&(delete this._serverSubs[e],this.emit("unsubscribed",{channel:e}));return}t.code<2500?r._setUnsubscribed(t.code,t.reason,!1):r._setSubscribing(t.code,t.reason)}_handleSubscribe(e,t){this._serverSubs[e]={offset:t.offset,epoch:t.epoch,recoverable:t.recoverable||!1},this.emit("subscribed",this._getSubscribeContext(e,t))}_handleDisconnect(e){const t=e.code;let r=!0;(t>=3500&&t<4e3||t>=4500&&t<5e3)&&(r=!1),this._disconnect(t,e.reason,r)}_getPublicationContext(e,t){const r={channel:e,data:t.data};return t.offset&&(r.offset=t.offset),t.info&&(r.info=this._getJoinLeaveContext(t.info)),t.tags&&(r.tags=t.tags),r}_getJoinLeaveContext(e){const t={client:e.client,user:e.user};return e.conn_info&&(t.connInfo=e.conn_info),e.chan_info&&(t.chanInfo=e.chan_info),t}_handlePublication(e,t){const r=this._getSub(e);if(!r){if(this._isServerSub(e)){const s=this._getPublicationContext(e,t);this.emit("publication",s),t.offset!==void 0&&(this._serverSubs[e].offset=t.offset)}return}r._handlePublication(t)}_handleMessage(e){this.emit("message",{data:e.data})}_handleServerPing(e){if(this._sendPong){const t={};this._transportSendCommands([t])}e()}_handlePush(e,t){const r=e.channel;e.pub?this._handlePublication(r,e.pub):e.message?this._handleMessage(e.message):e.join?this._handleJoin(r,e.join):e.leave?this._handleLeave(r,e.leave):e.unsubscribe?this._handleUnsubscribe(r,e.unsubscribe):e.subscribe?this._handleSubscribe(r,e.subscribe):e.disconnect&&this._handleDisconnect(e.disconnect),t()}_flush(){const e=this._commands.slice(0);this._commands=[],this._transportSendCommands(e)}_createErrorObject(e,t,r){const s={code:e,message:t};return r&&(s.temporary=!0),s}_registerCall(e,t,r){this._callbacks[e]={callback:t,errback:r,timeout:null},this._callbacks[e].timeout=setTimeout(()=>{delete this._callbacks[e],Dj(r)&&r({error:this._createErrorObject(gr.timeout,"timeout")})},this._config.timeout)}_addCommand(e){this._batching?this._commands.push(e):this._transportSendCommands([e])}_nextPromiseId(){return++this._promiseId}_nextTransportId(){return++this._transportId}_resolvePromises(){for(const e in this._promises)this._promises.hasOwnProperty(e)&&(this._promises[e].timeout&&clearTimeout(this._promises[e].timeout),this._promises[e].resolve(),delete this._promises[e])}_rejectPromises(e){for(const t in this._promises)this._promises.hasOwnProperty(t)&&(this._promises[t].timeout&&clearTimeout(this._promises[t].timeout),this._promises[t].reject(e),delete this._promises[t])}}km.SubscriptionState=Ps,km.State=kr,km.UnauthorizedError=Kl;const mne=()=>{const n=Date.now(),e=Math.random().toString(36).slice(2,11),t=Math.floor(Math.random()*1e3);return`client_${n}_${e}_${t}`},gne=n=>{try{return typeof structuredClone<"u"?structuredClone(n):JSON.parse(JSON.stringify(n))}catch(e){return console.error("Failed to sanitize data for broadcast:",e),{error:"Data could not be serialized",originalType:typeof n}}},ta=(n,e)=>{if(!n)return console.warn("Broadcast channel is not available"),!1;try{const t=gne(e);return n.postMessage(t),!0}catch(t){return console.warn("Failed to broadcast message:",t),console.warn("Problematic message:",e),!1}},_ne=(n="dalan-chat-broadcast-channel")=>{const[e,t]=T.useState(!1),[r,s]=T.useState(new Set),{subEvent:i,offEvent:o}=Mt.useEmitter(),a=T.useRef(null),l=T.useRef(mne()),c=T.useRef(Date.now()),d=T.useRef(null),f=T.useRef(null),p=T.useRef(!1),m=T.useCallback(()=>{try{const q=de.bsLocalStorage.getItem(`${n}_client_registry`);return q?JSON.parse(q):{}}catch{return{}}},[n]),g=T.useCallback(q=>{try{de.bsLocalStorage.setItem(`${n}_client_registry`,JSON.stringify(q))}catch(G){console.warn("Failed to update client registry:",G)}},[n]),v=T.useCallback(()=>{try{const q=de.bsLocalStorage.getItem(`${n}_connection_status`);return q?JSON.parse(q):{isConnected:!1,lastUpdate:0,leaderId:null}}catch{return{isConnected:!1,lastUpdate:0,leaderId:null}}},[n]),y=T.useCallback((q,G=null)=>{try{const V={isConnected:q,lastUpdate:Date.now(),leaderId:G||(e?l.current:null)};de.bsLocalStorage.setItem(`${n}_connection_status`,JSON.stringify(V))}catch(V){console.warn("Failed to update connection status:",V)}},[n,e]),b=T.useCallback(()=>{const q=m(),G=Date.now(),V={};return Object.entries(q).forEach(([z,B])=>{G-B.lastSeen<12e3&&(V[z]=B)}),g(V),V},[m,g]),S=T.useCallback(()=>{if(p.current)return null;p.current=!0;try{const q=b(),G=Object.keys(q);if(G.length===0)return t(!1),s(new Set),y(!1,null),null;s(new Set(G));let V=G[0],z=q[V].timestamp;G.forEach(H=>{q[H].timestamp<z&&(z=q[H].timestamp,V=H)});const B=V===l.current;t(B);const P=v();return y(P.isConnected,V),ta(a.current,{leaderId:V,timestamp:Date.now(),type:"LEADER_SELECTED",fromClientId:l.current}),V}finally{p.current=!1}},[b,v,y]),E=T.useCallback(()=>{const q=m();q[l.current]={lastSeen:Date.now(),timestamp:c.current},g(q),ta(a.current,{type:"HEARTBEAT",timestamp:Date.now(),clientId:l.current,fromClientId:l.current})},[m,g]),C=T.useCallback(q=>a.current?ta(a.current,{...q,timestamp:Date.now(),fromClientId:l.current}):(console.warn("Broadcast channel not available"),!1),[]),R=T.useCallback(q=>C({data:q,type:"WEBSOCKET_MESSAGE"}),[C]),I=T.useCallback(q=>C({data:q,type:"WARNING_MESSAGE"}),[C]),A=T.useCallback(q=>(y(q),C({isConnected:q,type:"CONNECTION_STATUS"})),[C,y]),k=T.useCallback(()=>{ta(a.current,{timestamp:Date.now(),fromClientId:l.current,type:"REQUEST_CONNECTION_STATUS"})},[]),N=T.useRef({markAsRead:[],leaderChange:[],seenMessages:[],warningMessage:[],addMessageEvent:[],websocketMessage:[],connectionStatus:[],setUnseenMessages:[],publishToWebSocket:[],replaceMessageEvent:[]}),D=T.useCallback(({event:q,callback:G})=>(N.current[q]&&N.current[q].push(G),()=>{N.current[q]&&(N.current[q]=N.current[q].filter(V=>V!==G))}),[]),M=T.useCallback(({event:q,callback:G})=>{N.current[q]&&(N.current[q]=N.current[q].filter(V=>V!==G))},[]),F=T.useCallback(({event:q,data:G})=>{N.current[q]&&N.current[q].forEach(V=>{try{V(G)}catch(z){console.error(`Error in ${q} event listener:`,z)}})},[]),U=T.useCallback(q=>{if(!a.current)return console.warn("Broadcast channel not available"),!1;const G=v();return G.leaderId?G.leaderId===l.current?(F({event:"publishToWebSocket",data:{data:q,fromClientId:l.current}}),!0):ta(a.current,{data:q,timestamp:Date.now(),fromClientId:l.current,type:"PUBLISH_TO_WEBSOCKET_REQUEST"}):(console.warn("No leader available to publish message"),!1)},[v,F]),$=T.useCallback(()=>{const q=v(),G=m();(q.leaderId&&!G[q.leaderId]||!q.leaderId&&Object.keys(G).length>0)&&S()},[v,m,S]);return T.useEffect(()=>{try{a.current=new BroadcastChannel(n);const q=m();q[l.current]={lastSeen:Date.now(),timestamp:c.current},g(q),a.current.addEventListener("message",P=>{try{const{type:H,fromClientId:Z,...Q}=P.data;if(Z===l.current)return;switch(H){case"HEARTBEAT":{s(J=>new Set([...J,Q.clientId]));break}case"LEADER_SELECTED":{const J=Q.leaderId===l.current;t(J),F({event:"leaderChange",data:{isLeader:J,leaderId:Q.leaderId}});break}case"WEBSOCKET_MESSAGE":{F({data:Q.data,event:"websocketMessage"});break}case"WARNING_MESSAGE":{F({data:Q.data,event:"warningMessage"});break}case"CONNECTION_STATUS":{F({event:"connectionStatus",data:{isConnected:Q.isConnected,fromClientId:Z}});break}case"REQUEST_CONNECTION_STATUS":{const J=v();J.leaderId===l.current&&ta(a.current,{timestamp:Date.now(),fromClientId:l.current,type:"CONNECTION_STATUS_RESPONSE",isConnected:J.isConnected});break}case"CONNECTION_STATUS_RESPONSE":{F({event:"connectionStatus",data:{fromClientId:Z,isResponse:!0,isConnected:Q.isConnected}});break}case"CLIENT_DISCONNECT":{s(ee=>{const K=new Set(ee);return K.delete(Q.clientId),K}),v().leaderId===Q.clientId&&setTimeout(S,50);break}case"LEADER_VERIFICATION_REQUEST":{v().leaderId===l.current&&ta(a.current,{timestamp:Date.now(),leaderId:l.current,fromClientId:l.current,type:"LEADER_VERIFICATION_RESPONSE"});break}case"PUBLISH_TO_WEBSOCKET_REQUEST":{v().leaderId===l.current&&F({event:"publishToWebSocket",data:{fromClientId:Z,data:Q.data}});break}default:{Q.customType&&F({data:Q,event:Q.customType});break}}}catch(H){console.error("Error handling broadcast message:",H)}});const G=Math.random()*100+50;setTimeout(S,G),setTimeout(k,G+100),E(),d.current=setInterval(E,3e3);const V=setInterval($,5e3),z=()=>{try{ta(a.current,{timestamp:Date.now(),type:"CLIENT_DISCONNECT",clientId:l.current,fromClientId:l.current});const P=m();delete P[l.current],g(P);const H=v();H.leaderId===l.current&&H.isConnected&&(y(!1,null),ta(a.current,{isConnected:!1,timestamp:Date.now(),type:"CONNECTION_STATUS",fromClientId:l.current}))}catch(P){console.error("Error during unload:",P)}};window.addEventListener("beforeunload",z),window.addEventListener("unload",z);const B=()=>{try{document.hidden||(E(),setTimeout($,100))}catch(P){console.error("Error handling visibility change:",P)}};return document.addEventListener("visibilitychange",B),()=>{try{d.current&&clearInterval(d.current),f.current&&clearTimeout(f.current),V&&clearInterval(V),z(),a.current&&a.current.close(),window.removeEventListener("beforeunload",z),window.removeEventListener("unload",z),document.removeEventListener("visibilitychange",B)}catch(P){console.error("Error during cleanup:",P)}}}catch(q){console.error("Error initializing broadcast channel:",q)}},[n,m,g,S,E,F,k,v,y,$]),T.useEffect(()=>{try{return i(Ct.ADD_EVENT_LISTENER,D,{autoOff:!1}),i(Ct.BROADCAST_TO_ALL,C,{autoOff:!1}),()=>{o(Ct.ADD_EVENT_LISTENER,D),o(Ct.BROADCAST_TO_ALL,C)}}catch(q){console.error("Error setting up event listeners:",q)}},[D,C,o,i]),{isLeader:e,selectLeader:S,sendHeartbeat:E,broadcastToAll:C,connectedClients:r,addEventListener:D,removeEventListener:M,broadcastWarningMessage:I,requestConnectionStatus:k,sendToLeaderForPublishing:U,broadcastWebsocketMessage:R,broadcastConnectionStatus:A,clientId:l.current,broadcastChannel:a.current}},Yl=Object.freeze({CHAT_PRIVATE_WARN:Symbol("chat.private.warn")});function vne(){var Z,Q;const{isLeader:n,connectedClients:e,clientId:t,broadcastWebsocketMessage:r,broadcastWarningMessage:s,broadcastConnectionStatus:i,addEventListener:o,broadcastToAll:a,requestConnectionStatus:l,sendToLeaderForPublishing:c}=_ne(),{emitEvent:d,subEvent:f}=Mt.useEmitter(),{publishEvent:p}=Fr(),{setChatSocketMessages:m}=$i(),{currentUser:g,featureFlags:v}=Lt(["currentUser","featureFlags"]),{processSocketMessage:y}=uD(),b=g==null?void 0:g.id,S=!!b&&((Z=v==null?void 0:v.features)==null?void 0:Z.chat)&&((Q=v==null?void 0:v.features)==null?void 0:Q.websocket),{data:E}=AY({enabled:S&&n}),[C,R]=T.useState({}),[I,A]=T.useState([]),[k,N]=T.useState(!1),[D,M]=T.useState(null),F=T.useRef(null),U=T.useRef(!1),$=T.useRef(!1);T.useEffect(()=>{if(F.current===null)try{F.current=new km(`${mn.WebsocketUrl}/connection/websocket`),M(null)}catch(J){console.error("Failed to initialize Centrifuge (likely due to localStorage being disabled):",J),M(J),F.current=null}},[]);const q=T.useCallback(()=>{N(!0),i(!0)},[i]),G=T.useCallback(()=>{N(!1),i(!1)},[i]),V=T.useCallback(({data:J})=>{const ee=de.camelize(typeof J=="string"?JSON.parse(J):J);A(K=>[...K,ee]),y(ee),r(ee)},[A,y,r]),z=T.useCallback(({data:J})=>{(K=>{R(W=>{let te={...W};switch(K.type){case Yl.CHAT_PRIVATE_WARN.description:{te={...te,[K.data.chat_id]:{...K,shouldShow:!0}};break}}try{de.bsLocalStorage.setItem(xr.CHAT_WARN,JSON.stringify({[Yl.CHAT_PRIVATE_WARN.description]:{...te}}))}catch(re){console.warn("Failed to save warning message to localStorage:",re)}return m({...te}),p("showWarningInChat",{type:K.type,chatId:K.data.chat_id}),{...te}})})(J),s(J)},[s,m,p]),B=T.useCallback(()=>{if(!(!S||!E||!b||!n||$.current||!F.current)){if(D){console.warn("Cannot initialize WebSocket due to Centrifuge initialization error:",D);return}$.current=!0;try{F.current.setToken(E.data),F.current.removeAllListeners("publication"),F.current.on("publication",({channel:ee,data:K})=>{ee===`personal:#${b}`&&V({data:K})});const J=F.current.getSubscription(`public:USER_${b}:warn`);if(J)J.on("publication",z),J.subscribe();else{const ee=F.current.newSubscription(`public:USER_${b}:warn`);ee.on("publication",z),ee.subscribe()}F.current.connect()}catch(J){console.error("Failed to initialize WebSocket:",J),$.current=!1}}},[S,E,b,n,V,z,D]),P=T.useCallback(()=>{if(F.current&&F.current.state===Ol.CONNECTED)try{F.current.disconnect(),N(!1)}catch(J){console.error("Failed to disconnect WebSocket:",J)}$.current=!1},[]),H=T.useCallback(({channel:J=`personal:#${b}`,payload:ee})=>{if(n){if(!F.current||F.current.state!==Ol.CONNECTED){console.warn("Centrifuge is not connected");return}try{F.current.publish(J,JSON.stringify(de.snakize(ee)))}catch(K){console.error("Failed to publish message",K)}}else try{c(ee)}catch(K){console.error("Failed to publish via leader:",K)}},[n,c,b]);return T.useEffect(()=>n?o({event:"publishToWebSocket",callback:({data:K})=>{var W;if(((W=F.current)==null?void 0:W.state)===Ol.CONNECTED)try{H({channel:`personal:#${b}`,payload:K})}catch(te){console.error("Failed to publish to WebSocket:",te)}else console.warn("WebSocket not connected, cannot publish message")}}):void 0,[n,o,H,b]),T.useEffect(()=>{f(Ct.PUBLISH_TO_SOCKET,H)},[d,H]),T.useEffect(()=>{const J=o({event:"websocketMessage",callback:W=>{A(te=>[...te,W]),y(W)}}),ee=o({event:"warningMessage",callback:W=>{R(te=>{let re={...te};switch(W.type){case Yl.CHAT_PRIVATE_WARN.description:{re={...re,[W.data.chat_id]:{...W,shouldShow:!0}};break}}try{de.bsLocalStorage.setItem(xr.CHAT_WARN,JSON.stringify({[Yl.CHAT_PRIVATE_WARN.description]:{...re}}))}catch(pe){console.warn("Failed to save warning message to localStorage:",pe)}return m({...re}),p("showWarningInChat",{chatId:W.data.chat_id,type:W.type}),{...re}})}}),K=o({event:"connectionStatus",callback:({isConnected:W})=>{W!==void 0&&N(W)}});return()=>{J(),ee(),K()}},[o,d,m,p]),T.useEffect(()=>{!n&&!U.current&&(U.current=!0,setTimeout(()=>{l()},300))},[n,l]),T.useEffect(()=>{n&&S&&E&&b&&!D?B():n||P()},[n,S,E,b,B,P,D]),T.useEffect(()=>{if(F.current)return F.current.on(Ol.CONNECTED,q),F.current.on(Ol.DISCONNECTED,G),()=>{F.current&&(F.current.off(Ol.CONNECTED,q),F.current.off(Ol.DISCONNECTED,G))}},[q,G]),T.useEffect(()=>o({event:"leaderChange",callback:({isLeader:ee})=>{ee?S&&E&&b&&!D&&setTimeout(B,100):P(),U.current=!1}}),[o,S,E,b,B,P,D]),{messages:I,firstTab:n,clientId:t,broadcastToAll:a,warningMessages:C,publishToSocket:H,connectedClients:e,addEventListener:o,centrifugeError:D,isConnected:D?!1:k}}const ci={"card-to-card-payment":"_card-to-card-payment_sdqa7_6","card-to-card-payment__close":"_card-to-card-payment__close_sdqa7_11","card-to-card-payment__info-container":"_card-to-card-payment__info-container_sdqa7_20","card-to-card-payment__icon":"_card-to-card-payment__icon_sdqa7_23","card-to-card-payment__title":"_card-to-card-payment__title_sdqa7_37","card-to-card-payment__description":"_card-to-card-payment__description_sdqa7_48","card-to-card-payment__actions":"_card-to-card-payment__actions_sdqa7_58","card-to-card-payment__buttons":"_card-to-card-payment__buttons_sdqa7_65","card-to-card-payment__action":"_card-to-card-payment__action_sdqa7_58","card-to-card-payment__action--white":"_card-to-card-payment__action--white_sdqa7_79","card-to-card-payment__coupon":"_card-to-card-payment__coupon_sdqa7_82","card-to-card-payment__coupon-code":"_card-to-card-payment__coupon-code_sdqa7_92"};function yne({title:n,iconUrl:e,buttons:t,onClose:r,isClosable:s,couponCode:i,description:o,backgroundColor:a}){const{showErrorSnackbar:l}=Mt.useSnackbar(),{publishEvent:c}=Fr(),d=async(f,p)=>{switch(p.action_type){case"call_api":{try{const{endpoint:m,method:g,body:v,params:y}=p.action_meta,b=ls(m);p.publish_event&&requestIdleCallback(()=>{c(p.publish_event.name,p.publish_event.data)}),await b.request({method:g,params:y,data:v})}catch(m){l(m.message)}break}case"open_link":{p.publish_event&&requestIdleCallback(()=>{c(p.publish_event.name,p.publish_event.data)}),window.open(p.action_meta.url,"_blank");break}case"close":{p.publish_event&&requestIdleCallback(()=>{c(p.publish_event.name,p.publish_event.data)}),r();break}}};return _.jsxs("div",{className:ci["card-to-card-payment"],style:{backgroundColor:`#${a}`},children:[s&&_.jsx("div",{className:ci["card-to-card-payment__close"],onClick:r,children:_.jsx("i",{className:"bi-close"})}),_.jsxs("div",{className:ci["card-to-card-payment__info-container"],children:[_.jsx("div",{className:ci["card-to-card-payment__icon"],children:_.jsx("img",{alt:"warning",src:e})}),_.jsxs("div",{className:ci["card-to-card-payment__info"],children:[_.jsx("div",{className:ci["card-to-card-payment__title"],children:n}),_.jsx("div",{className:ci["card-to-card-payment__description"],dangerouslySetInnerHTML:{__html:Ec.sanitize(o)}})]})]}),_.jsxs("div",{className:ci["card-to-card-payment__actions"],children:[t&&t.length>0&&_.jsx("div",{className:ci["card-to-card-payment__buttons"],children:t.map(f=>_.jsx(Qe,{className:Te(ci["card-to-card-payment__action"],{[ci["card-to-card-payment__action--white"]]:f.color==="secondary"||f.variant==="outline"}),onClick:p=>d(p,f),size:f.size||"xs",color:f.color,variant:f.variant,children:f.text},JSON.stringify(f)))}),i&&_.jsxs("div",{className:ci["card-to-card-payment__coupon"],children:[_.jsx("span",{className:ci["card-to-card-payment__coupon-code"],children:i.code}),_.jsx(Ic,{value:i.code,children:({copy:f,copied:p})=>_.jsx("div",{children:_.jsx(Qe,{variant:"fill",color:"secondary",onClick:f,size:"xs",icon:p?"bi-tick-single":"bi-copy",children:"کپی کد"})})})]})]})]})}const bne=T.memo(yne);function xne({chatId:n}){var i;const[,e]=T.useState(!1);Lt(["chatSocketMessages"]);const t=JSON.parse(de.bsLocalStorage.getItem(xr.CHAT_WARN)),r=(i=t==null?void 0:t[Yl.CHAT_PRIVATE_WARN.description])==null?void 0:i[n],s=()=>{const o={...t[Yl.CHAT_PRIVATE_WARN.description],[n]:{...r,shouldShow:!1}};de.bsLocalStorage.setItem(xr.CHAT_WARN,JSON.stringify({[Yl.CHAT_PRIVATE_WARN.description]:{...o}})),e(a=>!a)};return t?_.jsx("div",{className:Xte["chat-warnings"],children:(r==null?void 0:r.shouldShow)&&_.jsx(bne,{title:r.data.title,description:r.data.description,buttons:r.data.buttons,iconUrl:r.data.icon,backgroundColor:r.data.background_color,couponCode:r.data.coupon_code,isClosable:r.data.closeable,onClose:s})}):null}const Sne=T.memo(xne);function Ene(){var o,a;const{chat:n}=Tn(["chat"]),e=At(),{featureFlags:t,currentUser:r}=Lt(["featureFlags","currentUser"]),s=T.useMemo(()=>{var l,c;return(l=t==null?void 0:t.features)!=null&&l.sendMessage&&((t==null?void 0:t.cantReceiveMessage)||[]).includes((c=n==null?void 0:n.contact)==null?void 0:c.id)===!1&&[Bt.PRIVATE,Bt.BOT,Bt.GROUP].includes(n==null?void 0:n.chatType)?!0:bS(n==null?void 0:n.contact)},[n==null?void 0:n.chatType,n==null?void 0:n.contact,t==null?void 0:t.cantReceiveMessage,(o=t==null?void 0:t.features)==null?void 0:o.sendMessage]),i=T.useMemo(()=>{var c;return!(n&&r&&((c=n.contact)==null?void 0:c.id)===r.id)},[n,r]);return _.jsxs(aQ,{chatId:n==null?void 0:n.id,messageId:(n==null?void 0:n.lastSeenId)||((a=n==null?void 0:n.searchedMessage)==null?void 0:a.id),children:[_.jsx(ij,{noOptionMenu:!i}),_.jsx(Sne,{chatId:n==null?void 0:n.id}),_.jsx("div",{className:Te(oj["chat-area-messages-container"],{[oj["chat-area-messages-container--ios"]]:e.isIOS}),children:_.jsx(zte,{})}),s?_.jsx(fee,{}):_.jsx(Gte,{}),_.jsx(qte,{}),_.jsx(Yte,{})]})}const iE={"chat-main-empty":"_chat-main-empty_95dz0_14","chat-main-empty__img":"_chat-main-empty__img_95dz0_25","chat-main-empty__title":"_chat-main-empty__title_95dz0_30"};function wne(){return _.jsxs("div",{className:iE["chat-main-empty"],children:[_.jsx("img",{alt:"گفت‌وگو کنید",className:iE["chat-main-empty__img"],src:"https://statics.basalam.com/public/admin/3KVn1/01-17/pUnFcqXFpQvDQHUKFEV80uQiKqlwWgm907fPanEvbIHvlyXfcj.svg"}),_.jsx("span",{className:iE["chat-main-empty__title"],children:"گفت‌وگو کنید"})]})}const Tne={"chat-main":"_chat-main_18bpj_6"},Ti={message:"_message_1se7z_6",message__avatar:"_message__avatar_1se7z_24",message__title:"_message__title_1se7z_27",message__text:"_message__text_1se7z_34","message--linkable":"_message--linkable_1se7z_43","message--receiver":"_message--receiver_1se7z_53","message--starter-receiver":"_message--starter-receiver_1se7z_60","message--new":"_message--new_1se7z_68","message--error":"_message--error_1se7z_84",message__footer:"_message__footer_1se7z_90","message__footer-time":"_message__footer-time_1se7z_95"};function Cne({message:n}){const t=T.useRef(),r=T.useRef(),{emitEvent:s}=Mt.useEmitter(),i=Te(Ti.message,Ti["message--receiver"],{[Ti["message--new"]]:n.isNew,[Ti["message--starter-receiver"]]:!0,[Ti["message--touching"]]:!!r.current,[Ti["message--error"]]:n.status===Dt.ERROR,[Ti["message--linkable"]]:!!n.link||n.aggregationDataUserIds&&n.verbId===9}),o=T.useMemo(()=>de.gregoryDate(n.createdAt).format("HH:mm"),[n.createdAt]),a=()=>{const l=n.verbId;n.aggregationDataUserIds&&l===9?s(Fa.OPEN_SHOW_FOLLOWERS,n.aggregationDataUserIds):n.link&&window.open(n.link,"_blank")};return _.jsxs("div",{onClick:a,ref:t,className:i,id:`chat-area-messages-message-${n==null?void 0:n.id}`,style:{transition:"all 200ms ease-in"},children:[_.jsxs(je,{display:"flex",children:[_.jsx(je,{className:Ti.message__avatar,children:_.jsx(zs,{size:At().isPc?"64":"40",alt:"profile",src:n.avatar})}),_.jsxs(je,{children:[_.jsx(je,{className:Ti.message__title,children:_.jsx("span",{dangerouslySetInnerHTML:{__html:Ec.sanitize(n.title)}})}),_.jsx(je,{className:Ti.message__text,children:_.jsx("span",{dangerouslySetInnerHTML:{__html:Ec.sanitize(n.message)}})})]})]}),_.jsx("div",{className:Ti.message__footer,children:_.jsx("span",{className:Ti["message__footer-time"],children:o})})]})}const Ine=T.memo(Cne),au={"chat-area-messages":"_chat-area-messages_st8uz_6","chat-area-messages--show":"_chat-area-messages--show_st8uz_49","chat-area-messages__unReadMessages":"_chat-area-messages__unReadMessages_st8uz_69","chat-area-messages__scroll-to-down":"_chat-area-messages__scroll-to-down_st8uz_86","chat-area-messages__empty":"_chat-area-messages__empty_st8uz_89","chat-area-messages__empty-text":"_chat-area-messages__empty-text_st8uz_93"};function Rne({isChatExist:n}){const e=T.useRef(),{messages:t,isFetchedFirstPage:r,hasMoreMessages:s,getNextMessages:i,selectedTab:o}=Bl(["messages","isFetchedFirstPage","hasMoreMessages","getNextMessages","selectedTab"]),[a,l]=T.useState(!1),{setContainerRef:c}=ff(),d=p=>{const m=t[p],g=t[p-1];if(!g)return!0;if(!m)return!1;const v=de.gregoryDate(m.createdAt),y=de.gregoryDate(g.createdAt);return v.startOf("day").diff(y.startOf("day"),"day")!==0};T.useEffect(()=>{c(e)},[e]),T.useEffect(()=>{l(!1)},[o]),T.useEffect(()=>{!s&&t.length===0&&r&&l(!0)},[s,r]);const f=T.useCallback(()=>{em(e.current,e.current.scrollHeight)},[e]);return _.jsxs("div",{id:"notification-area-messages",className:Te(au["chat-area-messages"],{[au["chat-area-messages--show"]]:n&&r}),ref:e,children:[_.jsxs(ep,{isReverse:!0,threshold:.7,useWindow:!1,initialLoad:!1,hasMore:s,loadMore:i,loader:_.jsx(je,{display:"flex",alignItems:"center",justifyContent:"center",py:12,style:{width:"100%"},children:_.jsx(Cr,{})},"loading"),children:[t==null?void 0:t.map((p,m)=>{const g=d(m);return p.unReadMessages?_.jsx("div",{className:au["chat-area-messages__unReadMessages"],id:"unReadMessages",children:"اعلان‌های خوانده نشده"},"unReadMessages"):_.jsxs(T.Fragment,{children:[g&&_.jsx(lj,{date:p.createdAt}),_.jsx(Ine,{message:p})]},p.id)}),a&&_.jsxs(je,{className:au["chat-area-messages__empty"],display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",children:[_.jsx(je,{display:"flex",children:_.jsx("img",{src:"https://statics.basalam.com/public-44/admin/Ddrd75/11-19/jTNKNytQPLypVzaYZAiygTdA6cATfnAJqN3L08jz2eo4E8RwgK.SVG",alt:"اعلان نداری"})}),_.jsx(je,{mt:16,children:_.jsx("p",{className:au["chat-area-messages__empty-text"],children:"فعلا اعلان نداری!"})})]})]}),_.jsx("div",{className:au["chat-area-messages__scroll-to-down"],children:_.jsx(cj,{onClick:f,scrollerRef:e})})]})}const Ane=T.memo(Rne),Lm={"notification-tabs__tabs":"_notification-tabs__tabs_vxzvu_6","notification-tabs__tab":"_notification-tabs__tab_vxzvu_6","notification-tabs__tab--selected":"_notification-tabs__tab--selected_vxzvu_29","notification-tabs__tab-count":"_notification-tabs__tab-count_vxzvu_33"};function kne(){const{tabs:n,selectedTab:e,isLoadingFetchNotifications:t,refetchNotifications:r}=Bl(["tabs","selectedTab","isLoadingFetchNotifications","refetchNotifications"]),{currentUser:s}=Lt(["currentUser"]),{publishEvent:i}=Fr(),{setSelectedTab:o}=ff(),a=l=>{requestIdleCallback(()=>{i("notificationCategoryView",{countUnseen:l==null?void 0:l.count,categoryName:l==null?void 0:l.title,orderCount:(s==null?void 0:s.orderCount)||null})})};return(n==null?void 0:n.length)===0?null:_.jsx("div",{className:Lm["notification-tabs__tabs"],children:n==null?void 0:n.map(l=>_.jsxs(Qe,{size:At().isPc?"sm":"xxs",color:"secondary",variant:"outline",disabled:t,onClick:()=>{o(l),a(l),r()},className:Te([Lm["notification-tabs__tab"],{[Lm["notification-tabs__tab--selected"]]:e.identifier===l.identifier}]),children:[l.title,!!l.count&&e.identifier!==l.identifier&&_.jsx("span",{className:Lm["notification-tabs__tab-count"],children:l.count})]},l.title))})}const Lne=T.memo(kne);function Mne({children:n}){var U;const{featureFlags:e,currentUser:t}=Lt(["featureFlags","currentUser"]),{selectedTab:r,containerRef:s,messages:i,unseenMessageCount:o}=Bl(["selectedTab","containerRef","messages","unseenMessageCount"]),{updateTabs:a,setSelectedTab:l,updateMessages:c,setGetNextMessages:d,setHasMoreMessages:f,setIsFetchedFirstPage:p,setIsLoadingFetchNotifications:m,updateUnseenMessageCount:g,setRefetchNotifications:v}=ff(),y=Nl(),{publishEvent:b}=Fr(),S=e==null?void 0:e.notificationTabs,E=t!=null&&t.vendor?"vendor":"user",{mutate:C}=NX(),R=()=>{C(void 0,{onError:$=>to($),onSuccess:()=>{g($=>({...$,count:0,tabsUnreadCount:Object.keys($.tabsUnreadCount).reduce((q,G)=>({...q,[G]:0}),{})})),a($=>$.map(q=>({...q,count:0}))),requestIdleCallback(()=>{b("notificationReadAll",{})})}})},{fetchNextPage:I,refetch:A,hasNextPage:k,isError:N,data:D,isLoading:M}=JP(r==null?void 0:r.identifier,20,{enabled:!1,onSuccess:$=>{p(!0),c(q=>{const V=[...[...(($==null?void 0:$.pages.at(-1).notifications)||[]).map(P=>{var H,Z,Q,J;return{id:P.id,title:P.title,readAt:P.readAt,message:P.message,link:P.metaData.link,createdAt:P.createdAt,avatar:P.metaData.icon.url,verbId:((Z=(H=P.verb)==null?void 0:H.data)==null?void 0:Z.id)||P.verbId,aggregationDataUserIds:(J=(Q=P.metaData)==null?void 0:Q.aggregationData)==null?void 0:J.userIds}})].reverse(),...q],z=V.reverse().findIndex((P,H,Z)=>P.readAt||H===Z.length-1),B=V.find(P=>P.unReadMessages);return z!==-1&&z!==0&&!B&&V.splice(z,0,{unReadMessages:!0,createdAt:V[z].createdAt}),[...V].reverse()})}});T.useEffect(()=>{v(A)},[A]);const F=T.useCallback(()=>{!M&&k&&I()},[M,I,k]);return T.useEffect(()=>{m(M)},[M]),T.useEffect(()=>()=>{c([]),p(!1),y.removeQueries({exact:!0,queryKey:["user","notifications",r==null?void 0:r.identifier,20]})},[r,y]),T.useEffect(()=>{f(!N&&!!k)},[N,k]),T.useEffect(()=>{var $;if(i.length>0&&(($=D==null?void 0:D.pages)==null?void 0:$.length)===1){if(i.some(q=>q.unReadMessages)){const q=document.querySelector("#unReadMessages");lD(s.current,q.offsetTop-q.offsetHeight*5)}else lD(s.current,s.current.scrollHeight);R()}else if(i.length>0){const q=s.current.offsetHeight,G=s.current.scrollTop,z=s.current.scrollHeight-q-q;G>z&&em(s.current,s.current.scrollHeight)}},[i,(U=D==null?void 0:D.pages)==null?void 0:U.length]),T.useEffect(()=>{d(F)},[F]),Mt.useEffectNoImmediate(()=>{r&&A()},[r]),T.useEffect(()=>{if(t&&S){const $=S.tabs.filter(q=>q.visibility===E||q.visibility==="all").map(q=>({...q,count:(o==null?void 0:o.tabsUnreadCount[q.identifier])||0}));a($),l($[0])}},[t]),n}const Nne=T.memo(Mne);function One(){const{notification:n}=Bl(["notification"]);return _.jsxs(Nne,{children:[_.jsx(ij,{noOptionMenu:!0}),_.jsx(Lne,{}),_.jsx(Ane,{isChatExist:!!n})]})}function oE({className:n}){const{closeChat:e}=Wc(),{identifier:t}=Tn(["identifier"]),{push:r}=Si(),s=t===Zi.NOTIFICATION,i=T.useCallback(()=>{t&&e()},[e,t]);return T.useEffect(()=>r(a=>{i(a)}),[i,r]),_.jsx("div",{id:"chat-main",className:Te(n,Tne["chat-main"]),children:t?s?_.jsx(One,{}):_.jsx(Ene,{}):_.jsx(wne,{})})}const aE={"chat-not-available":"_chat-not-available_1wu4s_6","chat-not-available__photo":"_chat-not-available__photo_1wu4s_16","chat-not-available__text":"_chat-not-available__text_1wu4s_20"};function Uj({message:n="گفتگو فعلا قطعه. خودش دوباره درست می‌شه. به گیرنده خودت دست نزن!"}){return _.jsxs("div",{className:aE["chat-not-available"],children:[_.jsx("img",{className:aE["chat-not-available__photo"],src:"https://statics.basalam.com/public/admin/j50O7/01-15/5iyIDOlpMHAw9wRfW2cUYdYzLl0TKyu5LIUs3HqGt2dK2gugQD.svg",alt:""}),_.jsx("span",{className:aE["chat-not-available__text"],children:n})]})}const Ci={jcm__info:"_jcm__info_duk5w_6","jcm__info-title":"_jcm__info-title_duk5w_13","jcm__info-members":"_jcm__info-members_duk5w_18","jcm__info-description":"_jcm__info-description_duk5w_22",jcm__footer:"_jcm__footer_duk5w_26","jcm__footer-btn":"_jcm__footer-btn_duk5w_31","jcm__footer-divider":"_jcm__footer-divider_duk5w_34"};function Pne({show:n,identifier:e,onAccept:t,onReject:r}){const{emitEvent:s}=Mt.useEmitter(),{publishEvent:i}=Fr(),{chat:o}=Tn(["chat"]),{mutate:a,isLoading:l}=RY({onError:p=>{no(p)},onSuccess:()=>{s(Ct.UPDATE_CHAT_LIST),t==null||t(e)}}),c=(o==null?void 0:o.group)||(o==null?void 0:o.channel),d=()=>{a({channelIdentifier:e}),requestIdleCallback(()=>{i("chatJoinModalButtonClick",{itemTitle:c==null?void 0:c.title,vendorIdentifier:c==null?void 0:c.link})})},f=()=>{r==null||r()};return _.jsxs(lr,{noClose:!0,size:"sm",show:n,className:"dataset-inp-JoinChannelModal",children:[c?_.jsxs("div",{className:Ci.jcm__info,children:[_.jsx(zs,{src:c.avatar,size:"64"}),_.jsx("span",{className:Ci["jcm__info-title"],children:c.title}),_.jsxs("span",{className:Ci["jcm__info-members"],children:[c.membersCount," عضو"]}),_.jsx("p",{className:Ci["jcm__info-description"],children:c.description})]}):_.jsxs("div",{className:Ci.jcm__info,children:[_.jsx(vt,{width:64,height:64,radius:"50%"}),_.jsx(vt,{className:Ci["jcm__info-title"],width:180,height:21,radius:0}),_.jsx(vt,{className:Ci["jcm__info-members"],width:80,height:21,radius:0}),_.jsx(vt,{radius:0,width:210,height:21,className:Ci["jcm__info-description"]})]}),_.jsxs("div",{className:Ci.jcm__footer,children:[_.jsx(Qe,{disabled:!c,className:Ci["jcm__footer-btn"],label:"عضویت",loading:l,onClick:d}),_.jsx("span",{className:Ci["jcm__footer-divider"]}),_.jsx(Qe,{className:Ci["jcm__footer-btn"],disabled:l,variant:l?"disabled":"outline",label:"انصراف",onClick:f})]})]})}const na={"resizable-sidebar":"_resizable-sidebar_1c53f_6","resizable-sidebar--snapping":"_resizable-sidebar--snapping_1c53f_15","resizable-sidebar--no-resize":"_resizable-sidebar--no-resize_1c53f_18","resizable-sidebar__content":"_resizable-sidebar__content_1c53f_21","resizable-sidebar__handle-line":"_resizable-sidebar__handle-line_1c53f_27","resizable-sidebar__handle":"_resizable-sidebar__handle_1c53f_27","resizable-sidebar__handle--hovered":"_resizable-sidebar__handle--hovered_1c53f_48","resizable-sidebar__handle--active":"_resizable-sidebar__handle--active_1c53f_56"},Dne=80,jne=500,Bj=420,wf=80,lE=400;function Fne({children:n,className:e,onWidthChange:t,disabled:r=!1,initialWidth:s=Bj}){var N;const{featureFlags:i}=Lt(["featureFlags"]),o=((N=i==null?void 0:i.features)==null?void 0:N.canResizeChatList)&&!r,[a,l]=T.useState(()=>{const D=de.bsLocalStorage.getItem(xr.CHAT_SIDEBAR_WIDTH);return D?Number.parseInt(D,10):s}),[c,d]=T.useState(!1),[f,p]=T.useState(!1),[m,g]=T.useState(!1),v=T.useRef(null),y=T.useRef(0),b=T.useRef(0),S=T.useRef(null),E=a<=wf,C=T.useCallback(D=>{if(!o)return;d(!0),y.current=D.clientX,b.current=a,document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.documentElement.style.cursor="col-resize";const M=document.createElement("style");M.id="resize-cursor-override",M.textContent="* { cursor: col-resize !important; }",document.head.append(M),D.preventDefault()},[a,o]),R=T.useCallback(D=>{if(!c)return;const M=D.clientX-y.current;let F=Math.min(jne,Math.max(Dne,b.current-M));if(F>wf&&F<lE){const U=Math.abs(F-wf),$=Math.abs(F-lE);F=U<$?wf:lE,f||(p(!0),setTimeout(()=>p(!1),300))}l(F),t==null||t(F)},[c,t,f]),I=T.useCallback(()=>{if(!c)return;d(!1),document.body.style.userSelect="",document.body.style.cursor="",document.documentElement.style.cursor="";const D=document.querySelector("#resize-cursor-override");D&&D.remove(),de.bsLocalStorage.setItem(xr.CHAT_SIDEBAR_WIDTH,a.toString())},[c,a]),A=T.useCallback(()=>{o&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{g(!0)},150))},[o]),k=T.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),g(!1)},[]);return T.useEffect(()=>{if(c)return document.addEventListener("mousemove",R),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",I)}},[c,R,I]),T.useEffect(()=>{t==null||t(a)},[a,t]),T.useEffect(()=>()=>{document.body.style.userSelect="",document.body.style.cursor="",document.documentElement.style.cursor="";const D=document.querySelector("#resize-cursor-override");D&&D.remove(),S.current&&clearTimeout(S.current)},[]),T.useEffect(()=>{o===!1&&(l(Bj),de.bsLocalStorage.removeItem(xr.CHAT_SIDEBAR_WIDTH))},[o]),_.jsxs("div",{className:Te(na["resizable-sidebar"],e,{[na["resizable-sidebar--snapping"]]:f,[na["resizable-sidebar--no-resize"]]:!o}),style:{width:`${a}px`},children:[_.jsx("div",{ref:v,className:Te(na["resizable-sidebar__content"],{[na["resizable-sidebar__content--compact"]]:E}),"data-compact":E,children:n}),o&&_.jsx("div",{className:Te(na["resizable-sidebar__handle"],{[na["resizable-sidebar__handle--active"]]:c,[na["resizable-sidebar__handle--hovered"]]:m&&!c}),onMouseDown:C,onMouseEnter:A,onMouseLeave:k,children:_.jsx("div",{className:na["resizable-sidebar__handle-line"]})})]})}function $j({children:n,className:e,height:t="90vh",showContacts:r=!0,openedChatIdentifier:s}){var M,F,U;const i=At(),{pathname:o}=window.location,{identifier:a}=Tn(["identifier"]),l=Dr(),c=T.useRef(),[d,f]=T.useState(()=>{const $=de.bsLocalStorage.getItem(xr.CHAT_SIDEBAR_WIDTH);return $?Number.parseInt($,10):420}),[p,m]=T.useState(!1),{featureFlags:g,pagesBasePath:v}=Lt(["featureFlags","pagesBasePath"]),y=(M=g==null?void 0:g.features)==null?void 0:M.canResizeChatList,[b,S]=T.useState(!1),E=s||(o.includes("/chat/")?o.split("/chat/")[1]:null),C=l?"100%":t,R=((F=g==null?void 0:g.features)==null?void 0:F.chat)===void 0?!0:(U=g==null?void 0:g.features)==null?void 0:U.chat,I=T.useCallback($=>{const q=lS();l||window.history.pushState({chat:1,__N:!0,options:{},as:`${v}/${$}`,url:`${v}/[identifier]?identifier=${$}`},"",`${v}/${$}${!a&&(q==null?void 0:q.length)>0?`?text=${q}`:""}`)},[v]),A=T.useCallback(()=>{var $;WP(($=c.current)==null?void 0:$.identifier)&&m(!0)},[]),k=T.useCallback($=>{if(!$.state.isCustomHistory){const{pathname:q}=window.location,G=q!=null&&q.startsWith(v)?q.replace(`${v}`,"").replace("/",""):null;G&&G!==a?c.current.openChat({preventOpenChat:!0,identifier:G}):$.state.chat||c.current.closeChat()}},[v,a]),N=T.useCallback(async()=>{m(!1),await de.sleep(250),c.current.closeChat()},[]),D=T.useCallback(async $=>{m(!1),await de.sleep(250),c.current.openChat({identifier:$})},[]);return T.useEffect(()=>(window.addEventListener("popstate",k),()=>{window.removeEventListener("popstate",k)}),[k]),T.useEffect(()=>{E&&c.current.openChat({identifier:E})},[]),T.useEffect(()=>(document.body.style.overflow=a?"hidden":"auto",()=>{document.body.style.overflow=""}),[a]),_.jsx(tx,{children:_.jsx(XP,{onChatOpen:I,onChatJoin:A,ref:c,children:_.jsxs("div",{className:Te(ss["chat-page"],{[ss["chat-widget-mobile"]]:l},e),style:{height:C},children:[_.jsx(Jh,{className:ss["chat-page__container"],fluid:!i.isPc,children:R?i.isPc?_.jsxs("div",{className:ss["chat-page__container-grid"],children:[r&&_.jsx(Fne,{className:ss["chat-page__container-grid-list"],onWidthChange:f,initialWidth:d,disabled:b,children:_.jsx(cD,{className:ss["chat-page__list"],isCompact:d<=wf,onSearchStateChange:S})}),_.jsx("div",{className:ss["chat-page__container-grid-main"],style:{width:r?`calc(100% - ${d+(y?6:0)}px)`:"100%"},children:_.jsx(oE,{className:ss["chat-page__main"]})})]}):_.jsxs(Rc,{noGutter:!0,className:ss["chat-page__container-grid"],children:[r&&_.jsx(Rc.Col,{xs:12,className:Te(ss["chat-page__container-grid-list"],{[ss["chat-page__container-grid-list--open"]]:a,[ss["chat-page__container-grid-list--close"]]:!a}),children:_.jsx(cD,{className:ss["chat-page__list"]})}),_.jsx(Rc.Col,{xs:12,className:Te(ss["chat-page__container-grid-main"],{[ss["chat-page__container-grid-main--open"]]:a,[ss["chat-page__container-grid-main--close"]]:!a}),children:_.jsx(oE,{className:ss["chat-page__main"]})})]}):_.jsx(Uj,{})}),_.jsx(Pne,{show:p,identifier:a,onAccept:D,onReject:N}),n&&n({isOpen:!!a})]})})})}function Une({mobile:n,password:e}){return oP({url:"/login",method:"post",headers:{SetTokenInCookie:!0},data:{mobile:n,password:e,client_id:mn.CLIENT_ID}})}function Bne(){return oP.get("/light/whoami")}const $ne=(n={})=>Yn(Une,n);function zne(){const{target:n}=Lt(["target"]),[e,t]=T.useState(""),[r,s]=T.useState(""),{mutate:i,isLoading:o}=$ne();if(n==="staging"&&de.isProduction()){window.location=VP();return}const a=l=>{l.preventDefault(),i({mobile:e,password:r},{onSuccess:({token:c})=>{c!=null&&c.accessToken&&MK(c.accessToken),window.location="/chat"}})};return _.jsx(Jh,{children:_.jsx("div",{className:"login-page",children:_.jsxs("form",{onSubmit:a,className:"login-page__form",children:[_.jsx("img",{className:"login-page__form-logo",src:"https://statics.basalam.com/public-12/admin/b28/09-23/OCegXdnf9jIo6P0aydZn3UDIfIoFQRm8vANNDu2Brsab78zo5B.SVG",alt:"Basalam"}),_.jsx(Nd,{wrapperClassName:"login-page__form-input",placeholder:"0912000000",title:"موبایل",ltrInput:!0,align:"left",value:e,onChange:l=>t(l.target.value)}),_.jsx(Nd,{wrapperClassName:"login-page__form-input",placeholder:"xxxxxxxx",title:"رمز عبور",ltrInput:!0,align:"left",type:"password",value:r,onChange:l=>s(l.target.value)}),_.jsx(Qe,{className:"login-page__form-btn",type:"submit",label:"ورود",loading:o})]})})})}const qne={"chat-modal__main":"_chat-modal__main_globy_6"};function Hne(){var d,f;const[n,e]=T.useState(!1),{publishEvent:t}=Fr(),r=T.useRef(null),{closeChatModal:s}=$i(),{chatModalData:i,featureFlags:o}=Lt(["chatModalData","featureFlags"]),a=((d=o==null?void 0:o.features)==null?void 0:d.chat)===void 0?!0:(f=o==null?void 0:o.features)==null?void 0:f.chat,l=T.useCallback(()=>{e(!0),de.lockBodyScroll()},[]),c=T.useCallback(()=>{e(!1),de.unlockBodyScroll()},[]);return T.useEffect(()=>{i?(r.current.openChat({identifier:i.identifier}),t("chatModalView",{identifier:i.identifier})):r.current.closeChat()},[i]),_.jsx(tx,{children:_.jsx(XP,{onChatOpen:l,onChatClose:c,ref:r,children:_.jsx(lr,{isPlain:!0,show:n,isFullScreen:!At().isPc,bodyClass:"chat-modal__body",className:"chat-modal dataset-inp-ChatModal",onClose:s,children:a?_.jsx(oE,{className:qne["chat-modal__main"]}):_.jsx(Uj,{})})})})}function Gne(){const{openChatModal:n,openDirectModal:e}=$i();return _.jsxs(je,{display:"flex",alignItems:"center",justifyContent:"center",gap:12,style:{width:"100vw",height:"100vh"},children:[_.jsx(Hne,{}),_.jsx(Qe,{label:"نمایش مدال گفت‌وگو",size:At().isPc?"lg":"xs",onClick:()=>n("b28",{attachedProductId:4614113})}),_.jsx(Qe,{label:"نمایش مدال اشتراک‌گذاری در گفت‌وگو",size:At().isPc?"lg":"xs",onClick:()=>e({messageType:Fe.PRODUCT,messagePayload:{entityId:9808322}})})]})}/**
349 * @remix-run/router v1.18.0
350 *
351 * Copyright (c) Remix Software Inc.
352 *
353 * This source code is licensed under the MIT license found in the
354 * LICENSE.md file in the root directory of this source tree.
355 *
356 * @license MIT
357 */function Er(){return Er=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Er.apply(this,arguments)}var Nr;(function(n){n.Pop="POP",n.Push="PUSH",n.Replace="REPLACE"})(Nr||(Nr={}));function Vne(n){n===void 0&&(n={});let{initialEntries:e=["/"],initialIndex:t,v5Compat:r=!1}=n,s;s=e.map((m,g)=>d(m,typeof m=="string"?null:m.state,g===0?"default":void 0));let i=l(t??s.length-1),o=Nr.Pop,a=null;function l(m){return Math.min(Math.max(m,0),s.length-1)}function c(){return s[i]}function d(m,g,v){g===void 0&&(g=null);let y=cE(s?c().pathname:"/",m,g,v);return Xl(y.pathname.charAt(0)==="/","relative pathnames are not supported in memory history: "+JSON.stringify(m)),y}function f(m){return typeof m=="string"?m:Mm(m)}return{get index(){return i},get action(){return o},get location(){return c()},createHref:f,createURL(m){return new URL(f(m),"http://localhost")},encodeLocation(m){let g=typeof m=="string"?ra(m):m;return{pathname:g.pathname||"",search:g.search||"",hash:g.hash||""}},push(m,g){o=Nr.Push;let v=d(m,g);i+=1,s.splice(i,s.length,v),r&&a&&a({action:o,location:v,delta:1})},replace(m,g){o=Nr.Replace;let v=d(m,g);s[i]=v,r&&a&&a({action:o,location:v,delta:0})},go(m){o=Nr.Pop;let g=l(i+m),v=s[g];i=g,a&&a({action:o,location:v,delta:m})},listen(m){return a=m,()=>{a=null}}}}function gn(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function Xl(n,e){if(!n){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Wne(){return Math.random().toString(36).substr(2,8)}function cE(n,e,t,r){return t===void 0&&(t=null),Er({pathname:typeof n=="string"?n:n.pathname,search:"",hash:""},typeof e=="string"?ra(e):e,{state:t,key:e&&e.key||r||Wne()})}function Mm(n){let{pathname:e="/",search:t="",hash:r=""}=n;return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function ra(n){let e={};if(n){let t=n.indexOf("#");t>=0&&(e.hash=n.substr(t),n=n.substr(0,t));let r=n.indexOf("?");r>=0&&(e.search=n.substr(r),n=n.substr(0,r)),n&&(e.pathname=n)}return e}var Qn;(function(n){n.data="data",n.deferred="deferred",n.redirect="redirect",n.error="error"})(Qn||(Qn={}));const Kne=new Set(["lazy","caseSensitive","path","id","index","children"]);function Yne(n){return n.index===!0}function Tf(n,e,t,r){return t===void 0&&(t=[]),r===void 0&&(r={}),n.map((s,i)=>{let o=[...t,String(i)],a=typeof s.id=="string"?s.id:o.join("-");if(gn(s.index!==!0||!s.children,"Cannot specify children on an index route"),gn(!r[a],'Found a route id collision on id "'+a+`". Route id's must be globally unique within Data Router usages`),Yne(s)){let l=Er({},s,e(s),{id:a});return r[a]=l,l}else{let l=Er({},s,e(s),{id:a,children:void 0});return r[a]=l,s.children&&(l.children=Tf(s.children,e,o,r)),l}})}function Ql(n,e,t){return t===void 0&&(t="/"),Nm(n,e,t,!1)}function Nm(n,e,t,r){let s=typeof e=="string"?ra(e):e,i=Cf(s.pathname||"/",t);if(i==null)return null;let o=zj(n);Qne(o);let a=null;for(let l=0;a==null&&l<o.length;++l){let c=lre(i);a=ore(o[l],c,r)}return a}function Xne(n,e){let{route:t,pathname:r,params:s}=n;return{id:t.id,pathname:r,params:s,data:e[t.id],handle:t.handle}}function zj(n,e,t,r){e===void 0&&(e=[]),t===void 0&&(t=[]),r===void 0&&(r="");let s=(i,o,a)=>{let l={relativePath:a===void 0?i.path||"":a,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};l.relativePath.startsWith("/")&&(gn(l.relativePath.startsWith(r),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(r.length));let c=Ha([r,l.relativePath]),d=t.concat(l);i.children&&i.children.length>0&&(gn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),zj(i.children,e,d,c)),!(i.path==null&&!i.index)&&e.push({path:c,score:sre(c,i.index),routesMeta:d})};return n.forEach((i,o)=>{var a;if(i.path===""||!((a=i.path)!=null&&a.includes("?")))s(i,o);else for(let l of qj(i.path))s(i,o,l)}),e}function qj(n){let e=n.split("/");if(e.length===0)return[];let[t,...r]=e,s=t.endsWith("?"),i=t.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let o=qj(r.join("/")),a=[];return a.push(...o.map(l=>l===""?i:[i,l].join("/"))),s&&a.push(...o),a.map(l=>n.startsWith("/")&&l===""?"/":l)}function Qne(n){n.sort((e,t)=>e.score!==t.score?t.score-e.score:ire(e.routesMeta.map(r=>r.childrenIndex),t.routesMeta.map(r=>r.childrenIndex)))}const Jne=/^:[\w-]+$/,Zne=3,ere=2,tre=1,nre=10,rre=-2,Hj=n=>n==="*";function sre(n,e){let t=n.split("/"),r=t.length;return t.some(Hj)&&(r+=rre),e&&(r+=ere),t.filter(s=>!Hj(s)).reduce((s,i)=>s+(Jne.test(i)?Zne:i===""?tre:nre),r)}function ire(n,e){return n.length===e.length&&n.slice(0,-1).every((r,s)=>r===e[s])?n[n.length-1]-e[e.length-1]:0}function ore(n,e,t){t===void 0&&(t=!1);let{routesMeta:r}=n,s={},i="/",o=[];for(let a=0;a<r.length;++a){let l=r[a],c=a===r.length-1,d=i==="/"?e:e.slice(i.length)||"/",f=Gj({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},d),p=l.route;if(!f&&c&&t&&!r[r.length-1].route.index&&(f=Gj({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!f)return null;Object.assign(s,f.params),o.push({params:s,pathname:Ha([i,f.pathname]),pathnameBase:dre(Ha([i,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(i=Ha([i,f.pathnameBase]))}return o}function Gj(n,e){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[t,r]=are(n.path,n.caseSensitive,n.end),s=e.match(t);if(!s)return null;let i=s[0],o=i.replace(/(.)\/+$/,"$1"),a=s.slice(1);return{params:r.reduce((c,d,f)=>{let{paramName:p,isOptional:m}=d;if(p==="*"){let v=a[f]||"";o=i.slice(0,i.length-v.length).replace(/(.)\/+$/,"$1")}const g=a[f];return m&&!g?c[p]=void 0:c[p]=(g||"").replace(/%2F/g,"/"),c},{}),pathname:i,pathnameBase:o,pattern:n}}function are(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!0),Xl(n==="*"||!n.endsWith("*")||n.endsWith("/*"),'Route path "'+n+'" will be treated as if it were '+('"'+n.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+n.replace(/\*$/,"/*")+'".'));let r=[],s="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,l)=>(r.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return n.endsWith("*")?(r.push({paramName:"*"}),s+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?s+="\\/*$":n!==""&&n!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),r]}function lre(n){try{return n.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Xl(!1,'The URL path "'+n+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),n}}function Cf(n,e){if(e==="/")return n;if(!n.toLowerCase().startsWith(e.toLowerCase()))return null;let t=e.endsWith("/")?e.length-1:e.length,r=n.charAt(t);return r&&r!=="/"?null:n.slice(t)||"/"}function cre(n,e){e===void 0&&(e="/");let{pathname:t,search:r="",hash:s=""}=typeof n=="string"?ra(n):n;return{pathname:t?t.startsWith("/")?t:ure(t,e):e,search:fre(r),hash:hre(s)}}function ure(n,e){let t=e.replace(/\/+$/,"").split("/");return n.split("/").forEach(s=>{s===".."?t.length>1&&t.pop():s!=="."&&t.push(s)}),t.length>1?t.join("/"):"/"}function uE(n,e,t,r){return"Cannot include a '"+n+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+t+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function Vj(n){return n.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function dE(n,e){let t=Vj(n);return e?t.map((r,s)=>s===t.length-1?r.pathname:r.pathnameBase):t.map(r=>r.pathnameBase)}function fE(n,e,t,r){r===void 0&&(r=!1);let s;typeof n=="string"?s=ra(n):(s=Er({},n),gn(!s.pathname||!s.pathname.includes("?"),uE("?","pathname","search",s)),gn(!s.pathname||!s.pathname.includes("#"),uE("#","pathname","hash",s)),gn(!s.search||!s.search.includes("#"),uE("#","search","hash",s)));let i=n===""||s.pathname==="",o=i?"/":s.pathname,a;if(o==null)a=t;else{let f=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),f-=1;s.pathname=p.join("/")}a=f>=0?e[f]:"/"}let l=cre(s,a),c=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&t.endsWith("/");return!l.pathname.endsWith("/")&&(c||d)&&(l.pathname+="/"),l}const Ha=n=>n.join("/").replace(/\/\/+/g,"/"),dre=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),fre=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,hre=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;class Wj{constructor(e,t,r,s){s===void 0&&(s=!1),this.status=e,this.statusText=t||"",this.internal=s,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function Om(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}const Kj=["post","put","patch","delete"],pre=new Set(Kj),mre=["get",...Kj],gre=new Set(mre),_re=new Set([301,302,303,307,308]),vre=new Set([307,308]),hE={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},yre={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},If={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},pE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bre=n=>({hasErrorBoundary:!!n.hasErrorBoundary}),Yj="remix-router-transitions";function xre(n){const e=n.window?n.window:typeof window<"u"?window:void 0,t=typeof e<"u"&&typeof e.document<"u"&&typeof e.document.createElement<"u",r=!t;gn(n.routes.length>0,"You must provide a non-empty routes array to createRouter");let s;if(n.mapRouteProperties)s=n.mapRouteProperties;else if(n.detectErrorBoundary){let oe=n.detectErrorBoundary;s=ce=>({hasErrorBoundary:oe(ce)})}else s=bre;let i={},o=Tf(n.routes,s,void 0,i),a,l=n.basename||"/",c=n.unstable_dataStrategy||Cre,d=n.unstable_patchRoutesOnMiss,f=Er({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},n.future),p=null,m=new Set,g=null,v=null,y=null,b=n.hydrationData!=null,S=Ql(o,n.history.location,l),E=null;if(S==null&&!d){let oe=Ds(404,{pathname:n.history.location.pathname}),{matches:ce,route:_e}=aF(o);S=ce,E={[_e.id]:oe}}S&&d&&!n.hydrationData&&ws(S,o,n.history.location.pathname).active&&(S=null);let C;if(!S)C=!1,S=[];else if(S.some(oe=>oe.route.lazy))C=!1;else if(!S.some(oe=>oe.route.loader))C=!0;else if(f.v7_partialHydration){let oe=n.hydrationData?n.hydrationData.loaderData:null,ce=n.hydrationData?n.hydrationData.errors:null,_e=ie=>ie.route.loader?typeof ie.route.loader=="function"&&ie.route.loader.hydrate===!0?!1:oe&&oe[ie.route.id]!==void 0||ce&&ce[ie.route.id]!==void 0:!0;if(ce){let ie=S.findIndex(xe=>ce[xe.route.id]!==void 0);C=S.slice(0,ie+1).every(_e)}else C=S.every(_e)}else C=n.hydrationData!=null;let R,I={historyAction:n.history.action,location:n.history.location,matches:S,initialized:C,navigation:hE,restoreScrollPosition:n.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:n.hydrationData&&n.hydrationData.loaderData||{},actionData:n.hydrationData&&n.hydrationData.actionData||null,errors:n.hydrationData&&n.hydrationData.errors||E,fetchers:new Map,blockers:new Map},A=Nr.Pop,k=!1,N,D=!1,M=new Map,F=null,U=!1,$=!1,q=[],G=[],V=new Map,z=0,B=-1,P=new Map,H=new Set,Z=new Map,Q=new Map,J=new Set,ee=new Map,K=new Map,W=new Map,te=!1;function re(){if(p=n.history.listen(oe=>{let{action:ce,location:_e,delta:ie}=oe;if(te){te=!1;return}Xl(K.size===0||ie!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let xe=ot({currentLocation:I.location,nextLocation:_e,historyAction:ce});if(xe&&ie!=null){te=!0,n.history.go(ie*-1),Wt(xe,{state:"blocked",location:_e,proceed(){Wt(xe,{state:"proceeding",proceed:void 0,reset:void 0,location:_e}),n.history.go(ie)},reset(){let Le=new Map(I.blockers);Le.set(xe,If),le({blockers:Le})}});return}return Ae(ce,_e)}),t){Ure(e,M);let oe=()=>Bre(e,M);e.addEventListener("pagehide",oe),F=()=>e.removeEventListener("pagehide",oe)}return I.initialized||Ae(Nr.Pop,I.location,{initialHydration:!0}),R}function pe(){p&&p(),F&&F(),m.clear(),N&&N.abort(),I.fetchers.forEach((oe,ce)=>rt(ce)),I.blockers.forEach((oe,ce)=>gt(ce))}function Ee(oe){return m.add(oe),()=>m.delete(oe)}function le(oe,ce){ce===void 0&&(ce={}),I=Er({},I,oe);let _e=[],ie=[];f.v7_fetcherPersist&&I.fetchers.forEach((xe,Le)=>{xe.state==="idle"&&(J.has(Le)?ie.push(Le):_e.push(Le))}),[...m].forEach(xe=>xe(I,{deletedFetchers:ie,unstable_viewTransitionOpts:ce.viewTransitionOpts,unstable_flushSync:ce.flushSync===!0})),f.v7_fetcherPersist&&(_e.forEach(xe=>I.fetchers.delete(xe)),ie.forEach(xe=>rt(xe)))}function Ie(oe,ce,_e){var ie,xe;let{flushSync:Le}=_e===void 0?{}:_e,Be=I.actionData!=null&&I.navigation.formMethod!=null&&io(I.navigation.formMethod)&&I.navigation.state==="loading"&&((ie=oe.state)==null?void 0:ie._isRedirect)!==!0,Se;ce.actionData?Object.keys(ce.actionData).length>0?Se=ce.actionData:Se=null:Be?Se=I.actionData:Se=null;let ct=ce.loaderData?iF(I.loaderData,ce.loaderData,ce.matches||[],ce.errors):I.loaderData,at=I.blockers;at.size>0&&(at=new Map(at),at.forEach((ft,De)=>at.set(De,If)));let ut=k===!0||I.navigation.formMethod!=null&&io(I.navigation.formMethod)&&((xe=oe.state)==null?void 0:xe._isRedirect)!==!0;a&&(o=a,a=void 0),U||A===Nr.Pop||(A===Nr.Push?n.history.push(oe,oe.state):A===Nr.Replace&&n.history.replace(oe,oe.state));let St;if(A===Nr.Pop){let ft=M.get(I.location.pathname);ft&&ft.has(oe.pathname)?St={currentLocation:I.location,nextLocation:oe}:M.has(oe.pathname)&&(St={currentLocation:oe,nextLocation:I.location})}else if(D){let ft=M.get(I.location.pathname);ft?ft.add(oe.pathname):(ft=new Set([oe.pathname]),M.set(I.location.pathname,ft)),St={currentLocation:I.location,nextLocation:oe}}le(Er({},ce,{actionData:Se,loaderData:ct,historyAction:A,location:oe,initialized:!0,navigation:hE,revalidation:"idle",restoreScrollPosition:wr(oe,ce.matches||I.matches),preventScrollReset:ut,blockers:at}),{viewTransitionOpts:St,flushSync:Le===!0}),A=Nr.Pop,k=!1,D=!1,U=!1,$=!1,q=[],G=[]}async function be(oe,ce){if(typeof oe=="number"){n.history.go(oe);return}let _e=mE(I.location,I.matches,l,f.v7_prependBasename,oe,f.v7_relativeSplatPath,ce==null?void 0:ce.fromRouteId,ce==null?void 0:ce.relative),{path:ie,submission:xe,error:Le}=Xj(f.v7_normalizeFormMethod,!1,_e,ce),Be=I.location,Se=cE(I.location,ie,ce&&ce.state);Se=Er({},Se,n.history.encodeLocation(Se));let ct=ce&&ce.replace!=null?ce.replace:void 0,at=Nr.Push;ct===!0?at=Nr.Replace:ct===!1||xe!=null&&io(xe.formMethod)&&xe.formAction===I.location.pathname+I.location.search&&(at=Nr.Replace);let ut=ce&&"preventScrollReset"in ce?ce.preventScrollReset===!0:void 0,St=(ce&&ce.unstable_flushSync)===!0,ft=ot({currentLocation:Be,nextLocation:Se,historyAction:at});if(ft){Wt(ft,{state:"blocked",location:Se,proceed(){Wt(ft,{state:"proceeding",proceed:void 0,reset:void 0,location:Se}),be(oe,ce)},reset(){let De=new Map(I.blockers);De.set(ft,If),le({blockers:De})}});return}return await Ae(at,Se,{submission:xe,pendingError:Le,preventScrollReset:ut,replace:ce&&ce.replace,enableViewTransition:ce&&ce.unstable_viewTransition,flushSync:St})}function ge(){if(nt(),le({revalidation:"loading"}),I.navigation.state!=="submitting"){if(I.navigation.state==="idle"){Ae(I.historyAction,I.location,{startUninterruptedRevalidation:!0});return}Ae(A||I.historyAction,I.navigation.location,{overrideNavigation:I.navigation})}}async function Ae(oe,ce,_e){N&&N.abort(),N=null,A=oe,U=(_e&&_e.startUninterruptedRevalidation)===!0,sr(I.location,I.matches),k=(_e&&_e.preventScrollReset)===!0,D=(_e&&_e.enableViewTransition)===!0;let ie=a||o,xe=_e&&_e.overrideNavigation,Le=Ql(ie,ce,l),Be=(_e&&_e.flushSync)===!0,Se=ws(Le,ie,ce.pathname);if(Se.active&&Se.matches&&(Le=Se.matches),!Le){let{error:se,notFoundMatches:Pe,route:We}=nn(ce.pathname);Ie(ce,{matches:Pe,loaderData:{},errors:{[We.id]:se}},{flushSync:Be});return}if(I.initialized&&!$&&Mre(I.location,ce)&&!(_e&&_e.submission&&io(_e.submission.formMethod))){Ie(ce,{matches:Le},{flushSync:Be});return}N=new AbortController;let ct=lu(n.history,ce,N.signal,_e&&_e.submission),at;if(_e&&_e.pendingError)at=[cu(Le).route.id,{type:Qn.error,error:_e.pendingError}];else if(_e&&_e.submission&&io(_e.submission.formMethod)){let se=await Re(ct,ce,_e.submission,Le,Se.active,{replace:_e.replace,flushSync:Be});if(se.shortCircuited)return;if(se.pendingActionResult){let[Pe,We]=se.pendingActionResult;if(ui(We)&&Om(We.error)&&We.error.status===404){N=null,Ie(ce,{matches:se.matches,loaderData:{},errors:{[Pe]:We.error}});return}}Le=se.matches||Le,at=se.pendingActionResult,xe=vE(ce,_e.submission),Be=!1,Se.active=!1,ct=lu(n.history,ct.url,ct.signal)}let{shortCircuited:ut,matches:St,loaderData:ft,errors:De}=await tt(ct,ce,Le,Se.active,xe,_e&&_e.submission,_e&&_e.fetcherSubmission,_e&&_e.replace,_e&&_e.initialHydration===!0,Be,at);ut||(N=null,Ie(ce,Er({matches:St||Le},oF(at),{loaderData:ft,errors:De})))}async function Re(oe,ce,_e,ie,xe,Le){Le===void 0&&(Le={}),nt();let Be=jre(ce,_e);if(le({navigation:Be},{flushSync:Le.flushSync===!0}),xe){let at=await es(ie,ce.pathname,oe.signal);if(at.type==="aborted")return{shortCircuited:!0};if(at.type==="error"){let{boundaryId:ut,error:St}=tn(ce.pathname,at);return{matches:at.partialMatches,pendingActionResult:[ut,{type:Qn.error,error:St}]}}else if(at.matches)ie=at.matches;else{let{notFoundMatches:ut,error:St,route:ft}=nn(ce.pathname);return{matches:ut,pendingActionResult:[ft.id,{type:Qn.error,error:St}]}}}let Se,ct=Rf(ie,ce);if(!ct.route.action&&!ct.route.lazy)Se={type:Qn.error,error:Ds(405,{method:oe.method,pathname:ce.pathname,routeId:ct.route.id})};else if(Se=(await Ue("action",oe,[ct],ie))[0],oe.signal.aborted)return{shortCircuited:!0};if(Zl(Se)){let at;return Le&&Le.replace!=null?at=Le.replace:at=nF(Se.response.headers.get("Location"),new URL(oe.url),l)===I.location.pathname+I.location.search,await qe(oe,Se,{submission:_e,replace:at}),{shortCircuited:!0}}if(Jl(Se))throw Ds(400,{type:"defer-action"});if(ui(Se)){let at=cu(ie,ct.route.id);return(Le&&Le.replace)!==!0&&(A=Nr.Push),{matches:ie,pendingActionResult:[at.route.id,Se]}}return{matches:ie,pendingActionResult:[ct.route.id,Se]}}async function tt(oe,ce,_e,ie,xe,Le,Be,Se,ct,at,ut){let St=xe||vE(ce,Le),ft=Le||Be||hF(St),De=!U&&(!f.v7_partialHydration||!ct);if(ie){if(De){let fe=et(ut);le(Er({navigation:St},fe!==void 0?{actionData:fe}:{}),{flushSync:at})}let Qt=await es(_e,ce.pathname,oe.signal);if(Qt.type==="aborted")return{shortCircuited:!0};if(Qt.type==="error"){let{boundaryId:fe,error:Ve}=tn(ce.pathname,Qt);return{matches:Qt.partialMatches,loaderData:{},errors:{[fe]:Ve}}}else if(Qt.matches)_e=Qt.matches;else{let{error:fe,notFoundMatches:Ve,route:ze}=nn(ce.pathname);return{matches:Ve,loaderData:{},errors:{[ze.id]:fe}}}}let se=a||o,[Pe,We]=Qj(n.history,I,_e,ft,ce,f.v7_partialHydration&&ct===!0,f.v7_skipActionErrorRevalidation,$,q,G,J,Z,H,se,l,ut);if(En(Qt=>!(_e&&_e.some(fe=>fe.route.id===Qt))||Pe&&Pe.some(fe=>fe.route.id===Qt)),B=++z,Pe.length===0&&We.length===0){let Qt=vn();return Ie(ce,Er({matches:_e,loaderData:{},errors:ut&&ui(ut[1])?{[ut[0]]:ut[1].error}:null},oF(ut),Qt?{fetchers:new Map(I.fetchers)}:{}),{flushSync:at}),{shortCircuited:!0}}if(De){let Qt={};if(!ie){Qt.navigation=St;let fe=et(ut);fe!==void 0&&(Qt.actionData=fe)}We.length>0&&(Qt.fetchers=Oe(We)),le(Qt,{flushSync:at})}We.forEach(Qt=>{V.has(Qt.key)&&lt(Qt.key),Qt.controller&&V.set(Qt.key,Qt.controller)});let an=()=>We.forEach(Qt=>lt(Qt.key));N&&N.signal.addEventListener("abort",an);let{loaderResults:yn,fetcherResults:Ft}=await it(I.matches,_e,Pe,We,oe);if(oe.signal.aborted)return{shortCircuited:!0};N&&N.signal.removeEventListener("abort",an),We.forEach(Qt=>V.delete(Qt.key));let zn=lF([...yn,...Ft]);if(zn){if(zn.idx>=Pe.length){let Qt=We[zn.idx-Pe.length].key;H.add(Qt)}return await qe(oe,zn.result,{replace:Se}),{shortCircuited:!0}}let{loaderData:wn,errors:Wn}=sF(I,_e,Pe,yn,ut,We,Ft,ee);ee.forEach((Qt,fe)=>{Qt.subscribe(Ve=>{(Ve||Qt.done)&&ee.delete(fe)})}),f.v7_partialHydration&&ct&&I.errors&&Object.entries(I.errors).filter(Qt=>{let[fe]=Qt;return!Pe.some(Ve=>Ve.route.id===fe)}).forEach(Qt=>{let[fe,Ve]=Qt;Wn=Object.assign(Wn||{},{[fe]:Ve})});let kn=vn(),Fs=pt(B),fi=kn||Fs||We.length>0;return Er({matches:_e,loaderData:wn,errors:Wn},fi?{fetchers:new Map(I.fetchers)}:{})}function et(oe){if(oe&&!ui(oe[1]))return{[oe[0]]:oe[1].data};if(I.actionData)return Object.keys(I.actionData).length===0?null:I.actionData}function Oe(oe){return oe.forEach(ce=>{let _e=I.fetchers.get(ce.key),ie=Af(void 0,_e?_e.data:void 0);I.fetchers.set(ce.key,ie)}),new Map(I.fetchers)}function ht(oe,ce,_e,ie){if(r)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");V.has(oe)&&lt(oe);let xe=(ie&&ie.unstable_flushSync)===!0,Le=a||o,Be=mE(I.location,I.matches,l,f.v7_prependBasename,_e,f.v7_relativeSplatPath,ce,ie==null?void 0:ie.relative),Se=Ql(Le,Be,l),ct=ws(Se,Le,Be);if(ct.active&&ct.matches&&(Se=ct.matches),!Se){Ot(oe,ce,Ds(404,{pathname:Be}),{flushSync:xe});return}let{path:at,submission:ut,error:St}=Xj(f.v7_normalizeFormMethod,!0,Be,ie);if(St){Ot(oe,ce,St,{flushSync:xe});return}let ft=Rf(Se,at);if(k=(ie&&ie.preventScrollReset)===!0,ut&&io(ut.formMethod)){Xe(oe,ce,at,ft,Se,ct.active,xe,ut);return}Z.set(oe,{routeId:ce,path:at}),Je(oe,ce,at,ft,Se,ct.active,xe,ut)}async function Xe(oe,ce,_e,ie,xe,Le,Be,Se){nt(),Z.delete(oe);function ct(ze){if(!ze.route.action&&!ze.route.lazy){let It=Ds(405,{method:Se.formMethod,pathname:_e,routeId:ce});return Ot(oe,ce,It,{flushSync:Be}),!0}return!1}if(!Le&&ct(ie))return;let at=I.fetchers.get(oe);dt(oe,Fre(Se,at),{flushSync:Be});let ut=new AbortController,St=lu(n.history,_e,ut.signal,Se);if(Le){let ze=await es(xe,_e,St.signal);if(ze.type==="aborted")return;if(ze.type==="error"){let{error:It}=tn(_e,ze);Ot(oe,ce,It,{flushSync:Be});return}else if(ze.matches){if(xe=ze.matches,ie=Rf(xe,_e),ct(ie))return}else{Ot(oe,ce,Ds(404,{pathname:_e}),{flushSync:Be});return}}V.set(oe,ut);let ft=z,se=(await Ue("action",St,[ie],xe))[0];if(St.signal.aborted){V.get(oe)===ut&&V.delete(oe);return}if(f.v7_fetcherPersist&&J.has(oe)){if(Zl(se)||ui(se)){dt(oe,Ga(void 0));return}}else{if(Zl(se))if(V.delete(oe),B>ft){dt(oe,Ga(void 0));return}else return H.add(oe),dt(oe,Af(Se)),qe(St,se,{fetcherSubmission:Se});if(ui(se)){Ot(oe,ce,se.error);return}}if(Jl(se))throw Ds(400,{type:"defer-action"});let Pe=I.navigation.location||I.location,We=lu(n.history,Pe,ut.signal),an=a||o,yn=I.navigation.state!=="idle"?Ql(an,I.navigation.location,l):I.matches;gn(yn,"Didn't find any matches after fetcher action");let Ft=++z;P.set(oe,Ft);let zn=Af(Se,se.data);I.fetchers.set(oe,zn);let[wn,Wn]=Qj(n.history,I,yn,Se,Pe,!1,f.v7_skipActionErrorRevalidation,$,q,G,J,Z,H,an,l,[ie.route.id,se]);Wn.filter(ze=>ze.key!==oe).forEach(ze=>{let It=ze.key,Yt=I.fetchers.get(It),rn=Af(void 0,Yt?Yt.data:void 0);I.fetchers.set(It,rn),V.has(It)&&lt(It),ze.controller&&V.set(It,ze.controller)}),le({fetchers:new Map(I.fetchers)});let kn=()=>Wn.forEach(ze=>lt(ze.key));ut.signal.addEventListener("abort",kn);let{loaderResults:Fs,fetcherResults:fi}=await it(I.matches,yn,wn,Wn,We);if(ut.signal.aborted)return;ut.signal.removeEventListener("abort",kn),P.delete(oe),V.delete(oe),Wn.forEach(ze=>V.delete(ze.key));let Qt=lF([...Fs,...fi]);if(Qt){if(Qt.idx>=wn.length){let ze=Wn[Qt.idx-wn.length].key;H.add(ze)}return qe(We,Qt.result)}let{loaderData:fe,errors:Ve}=sF(I,I.matches,wn,Fs,void 0,Wn,fi,ee);if(I.fetchers.has(oe)){let ze=Ga(se.data);I.fetchers.set(oe,ze)}pt(Ft),I.navigation.state==="loading"&&Ft>B?(gn(A,"Expected pending action"),N&&N.abort(),Ie(I.navigation.location,{matches:yn,loaderData:fe,errors:Ve,fetchers:new Map(I.fetchers)})):(le({errors:Ve,loaderData:iF(I.loaderData,fe,yn,Ve),fetchers:new Map(I.fetchers)}),$=!1)}async function Je(oe,ce,_e,ie,xe,Le,Be,Se){let ct=I.fetchers.get(oe);dt(oe,Af(Se,ct?ct.data:void 0),{flushSync:Be});let at=new AbortController,ut=lu(n.history,_e,at.signal);if(Le){let se=await es(xe,_e,ut.signal);if(se.type==="aborted")return;if(se.type==="error"){let{error:Pe}=tn(_e,se);Ot(oe,ce,Pe,{flushSync:Be});return}else if(se.matches)xe=se.matches,ie=Rf(xe,_e);else{Ot(oe,ce,Ds(404,{pathname:_e}),{flushSync:Be});return}}V.set(oe,at);let St=z,De=(await Ue("loader",ut,[ie],xe))[0];if(Jl(De)&&(De=await fF(De,ut.signal,!0)||De),V.get(oe)===at&&V.delete(oe),!ut.signal.aborted){if(J.has(oe)){dt(oe,Ga(void 0));return}if(Zl(De))if(B>St){dt(oe,Ga(void 0));return}else{H.add(oe),await qe(ut,De);return}if(ui(De)){Ot(oe,ce,De.error);return}gn(!Jl(De),"Unhandled fetcher deferred data"),dt(oe,Ga(De.data))}}async function qe(oe,ce,_e){let{submission:ie,fetcherSubmission:xe,replace:Le}=_e===void 0?{}:_e;ce.response.headers.has("X-Remix-Revalidate")&&($=!0);let Be=ce.response.headers.get("Location");gn(Be,"Expected a Location header on the redirect Response"),Be=nF(Be,new URL(oe.url),l);let Se=cE(I.location,Be,{_isRedirect:!0});if(t){let De=!1;if(ce.response.headers.has("X-Remix-Reload-Document"))De=!0;else if(pE.test(Be)){const se=n.history.createURL(Be);De=se.origin!==e.location.origin||Cf(se.pathname,l)==null}if(De){Le?e.location.replace(Be):e.location.assign(Be);return}}N=null;let ct=Le===!0?Nr.Replace:Nr.Push,{formMethod:at,formAction:ut,formEncType:St}=I.navigation;!ie&&!xe&&at&&ut&&St&&(ie=hF(I.navigation));let ft=ie||xe;if(vre.has(ce.response.status)&&ft&&io(ft.formMethod))await Ae(ct,Se,{submission:Er({},ft,{formAction:Be}),preventScrollReset:k});else{let De=vE(Se,ie);await Ae(ct,Se,{overrideNavigation:De,fetcherSubmission:xe,preventScrollReset:k})}}async function Ue(oe,ce,_e,ie){try{let xe=await Ire(c,oe,ce,_e,ie,i,s);return await Promise.all(xe.map((Le,Be)=>{if(Ore(Le)){let Se=Le.result;return{type:Qn.redirect,response:kre(Se,ce,_e[Be].route.id,ie,l,f.v7_relativeSplatPath)}}return Are(Le)}))}catch(xe){return _e.map(()=>({type:Qn.error,error:xe}))}}async function it(oe,ce,_e,ie,xe){let[Le,...Be]=await Promise.all([_e.length?Ue("loader",xe,_e,ce):[],...ie.map(Se=>{if(Se.matches&&Se.match&&Se.controller){let ct=lu(n.history,Se.path,Se.controller.signal);return Ue("loader",ct,[Se.match],Se.matches).then(at=>at[0])}else return Promise.resolve({type:Qn.error,error:Ds(404,{pathname:Se.path})})})]);return await Promise.all([dF(oe,_e,Le,Le.map(()=>xe.signal),!1,I.loaderData),dF(oe,ie.map(Se=>Se.match),Be,ie.map(Se=>Se.controller?Se.controller.signal:null),!0)]),{loaderResults:Le,fetcherResults:Be}}function nt(){$=!0,q.push(...En()),Z.forEach((oe,ce)=>{V.has(ce)&&(G.push(ce),lt(ce))})}function dt(oe,ce,_e){_e===void 0&&(_e={}),I.fetchers.set(oe,ce),le({fetchers:new Map(I.fetchers)},{flushSync:(_e&&_e.flushSync)===!0})}function Ot(oe,ce,_e,ie){ie===void 0&&(ie={});let xe=cu(I.matches,ce);rt(oe),le({errors:{[xe.route.id]:_e},fetchers:new Map(I.fetchers)},{flushSync:(ie&&ie.flushSync)===!0})}function xt(oe){return f.v7_fetcherPersist&&(Q.set(oe,(Q.get(oe)||0)+1),J.has(oe)&&J.delete(oe)),I.fetchers.get(oe)||yre}function rt(oe){let ce=I.fetchers.get(oe);V.has(oe)&&!(ce&&ce.state==="loading"&&P.has(oe))&&lt(oe),Z.delete(oe),P.delete(oe),H.delete(oe),J.delete(oe),I.fetchers.delete(oe)}function Me(oe){if(f.v7_fetcherPersist){let ce=(Q.get(oe)||0)-1;ce<=0?(Q.delete(oe),J.add(oe)):Q.set(oe,ce)}else rt(oe);le({fetchers:new Map(I.fetchers)})}function lt(oe){let ce=V.get(oe);gn(ce,"Expected fetch controller: "+oe),ce.abort(),V.delete(oe)}function Vt(oe){for(let ce of oe){let _e=xt(ce),ie=Ga(_e.data);I.fetchers.set(ce,ie)}}function vn(){let oe=[],ce=!1;for(let _e of H){let ie=I.fetchers.get(_e);gn(ie,"Expected fetcher: "+_e),ie.state==="loading"&&(H.delete(_e),oe.push(_e),ce=!0)}return Vt(oe),ce}function pt(oe){let ce=[];for(let[_e,ie]of P)if(ie<oe){let xe=I.fetchers.get(_e);gn(xe,"Expected fetcher: "+_e),xe.state==="loading"&&(lt(_e),P.delete(_e),ce.push(_e))}return Vt(ce),ce.length>0}function mt(oe,ce){let _e=I.blockers.get(oe)||If;return K.get(oe)!==ce&&K.set(oe,ce),_e}function gt(oe){I.blockers.delete(oe),K.delete(oe)}function Wt(oe,ce){let _e=I.blockers.get(oe)||If;gn(_e.state==="unblocked"&&ce.state==="blocked"||_e.state==="blocked"&&ce.state==="blocked"||_e.state==="blocked"&&ce.state==="proceeding"||_e.state==="blocked"&&ce.state==="unblocked"||_e.state==="proceeding"&&ce.state==="unblocked","Invalid blocker state transition: "+_e.state+" -> "+ce.state);let ie=new Map(I.blockers);ie.set(oe,ce),le({blockers:ie})}function ot(oe){let{currentLocation:ce,nextLocation:_e,historyAction:ie}=oe;if(K.size===0)return;K.size>1&&Xl(!1,"A router only supports one blocker at a time");let xe=Array.from(K.entries()),[Le,Be]=xe[xe.length-1],Se=I.blockers.get(Le);if(!(Se&&Se.state==="proceeding")&&Be({currentLocation:ce,nextLocation:_e,historyAction:ie}))return Le}function nn(oe){let ce=Ds(404,{pathname:oe}),_e=a||o,{matches:ie,route:xe}=aF(_e);return En(),{notFoundMatches:ie,route:xe,error:ce}}function tn(oe,ce){return{boundaryId:cu(ce.partialMatches).route.id,error:Ds(400,{type:"route-discovery",pathname:oe,message:ce.error!=null&&"message"in ce.error?ce.error:String(ce.error)})}}function En(oe){let ce=[];return ee.forEach((_e,ie)=>{(!oe||oe(ie))&&(_e.cancel(),ce.push(ie),ee.delete(ie))}),ce}function $n(oe,ce,_e){if(g=oe,y=ce,v=_e||null,!b&&I.navigation===hE){b=!0;let ie=wr(I.location,I.matches);ie!=null&&le({restoreScrollPosition:ie})}return()=>{g=null,y=null,v=null}}function _n(oe,ce){return v&&v(oe,ce.map(ie=>Xne(ie,I.loaderData)))||oe.key}function sr(oe,ce){if(g&&y){let _e=_n(oe,ce);g[_e]=y()}}function wr(oe,ce){if(g){let _e=_n(oe,ce),ie=g[_e];if(typeof ie=="number")return ie}return null}function ws(oe,ce,_e){if(d)if(oe){let ie=oe[oe.length-1].route;if(ie.path&&(ie.path==="*"||ie.path.endsWith("/*")))return{active:!0,matches:Nm(ce,_e,l,!0)}}else return{active:!0,matches:Nm(ce,_e,l,!0)||[]};return{active:!1,matches:null}}async function es(oe,ce,_e){let ie=oe,xe=ie.length>0?ie[ie.length-1].route:null;for(;;){let Le=a==null,Be=a||o;try{await Tre(d,ce,ie,Be,i,s,W,_e)}catch(ut){return{type:"error",error:ut,partialMatches:ie}}finally{Le&&(o=[...o])}if(_e.aborted)return{type:"aborted"};let Se=Ql(Be,ce,l),ct=!1;if(Se){let ut=Se[Se.length-1].route;if(ut.index)return{type:"success",matches:Se};if(ut.path&&ut.path.length>0)if(ut.path==="*")ct=!0;else return{type:"success",matches:Se}}let at=Nm(Be,ce,l,!0);if(!at||ie.map(ut=>ut.route.id).join("-")===at.map(ut=>ut.route.id).join("-"))return{type:"success",matches:ct?Se:null};if(ie=at,xe=ie[ie.length-1].route,xe.path==="*")return{type:"success",matches:ie}}}function ds(oe){i={},a=Tf(oe,s,void 0,i)}function fs(oe,ce){let _e=a==null;eF(oe,ce,a||o,i,s),_e&&(o=[...o],le({}))}return R={get basename(){return l},get future(){return f},get state(){return I},get routes(){return o},get window(){return e},initialize:re,subscribe:Ee,enableScrollRestoration:$n,navigate:be,fetch:ht,revalidate:ge,createHref:oe=>n.history.createHref(oe),encodeLocation:oe=>n.history.encodeLocation(oe),getFetcher:xt,deleteFetcher:Me,dispose:pe,getBlocker:mt,deleteBlocker:gt,patchRoutes:fs,_internalFetchControllers:V,_internalActiveDeferreds:ee,_internalSetRoutes:ds},R}function Sre(n){return n!=null&&("formData"in n&&n.formData!=null||"body"in n&&n.body!==void 0)}function mE(n,e,t,r,s,i,o,a){let l,c;if(o){l=[];for(let f of e)if(l.push(f),f.route.id===o){c=f;break}}else l=e,c=e[e.length-1];let d=fE(s||".",dE(l,i),Cf(n.pathname,t)||n.pathname,a==="path");return s==null&&(d.search=n.search,d.hash=n.hash),(s==null||s===""||s===".")&&c&&c.route.index&&!_E(d.search)&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),r&&t!=="/"&&(d.pathname=d.pathname==="/"?t:Ha([t,d.pathname])),Mm(d)}function Xj(n,e,t,r){if(!r||!Sre(r))return{path:t};if(r.formMethod&&!Dre(r.formMethod))return{path:t,error:Ds(405,{method:r.formMethod})};let s=()=>({path:t,error:Ds(400,{type:"invalid-body"})}),i=r.formMethod||"get",o=n?i.toUpperCase():i.toLowerCase(),a=cF(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!io(o))return s();let p=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((m,g)=>{let[v,y]=g;return""+m+v+"="+y+`
358 `},""):String(r.body);return{path:t,submission:{formMethod:o,formAction:a,formEncType:r.formEncType,formData:void 0,json:void 0,text:p}}}else if(r.formEncType==="application/json"){if(!io(o))return s();try{let p=typeof r.body=="string"?JSON.parse(r.body):r.body;return{path:t,submission:{formMethod:o,formAction:a,formEncType:r.formEncType,formData:void 0,json:p,text:void 0}}}catch{return s()}}}gn(typeof FormData=="function","FormData is not available in this environment");let l,c;if(r.formData)l=gE(r.formData),c=r.formData;else if(r.body instanceof FormData)l=gE(r.body),c=r.body;else if(r.body instanceof URLSearchParams)l=r.body,c=rF(l);else if(r.body==null)l=new URLSearchParams,c=new FormData;else try{l=new URLSearchParams(r.body),c=rF(l)}catch{return s()}let d={formMethod:o,formAction:a,formEncType:r&&r.formEncType||"application/x-www-form-urlencoded",formData:c,json:void 0,text:void 0};if(io(d.formMethod))return{path:t,submission:d};let f=ra(t);return e&&f.search&&_E(f.search)&&l.append("index",""),f.search="?"+l,{path:Mm(f),submission:d}}function Ere(n,e){let t=n;if(e){let r=n.findIndex(s=>s.route.id===e);r>=0&&(t=n.slice(0,r))}return t}function Qj(n,e,t,r,s,i,o,a,l,c,d,f,p,m,g,v){let y=v?ui(v[1])?v[1].error:v[1].data:void 0,b=n.createURL(e.location),S=n.createURL(s),E=v&&ui(v[1])?v[0]:void 0,C=E?Ere(t,E):t,R=v?v[1].statusCode:void 0,I=o&&R&&R>=400,A=C.filter((N,D)=>{let{route:M}=N;if(M.lazy)return!0;if(M.loader==null)return!1;if(i)return typeof M.loader!="function"||M.loader.hydrate?!0:e.loaderData[M.id]===void 0&&(!e.errors||e.errors[M.id]===void 0);if(wre(e.loaderData,e.matches[D],N)||l.some($=>$===N.route.id))return!0;let F=e.matches[D],U=N;return Zj(N,Er({currentUrl:b,currentParams:F.params,nextUrl:S,nextParams:U.params},r,{actionResult:y,actionStatus:R,defaultShouldRevalidate:I?!1:a||b.pathname+b.search===S.pathname+S.search||b.search!==S.search||Jj(F,U)}))}),k=[];return f.forEach((N,D)=>{if(i||!t.some(q=>q.route.id===N.routeId)||d.has(D))return;let M=Ql(m,N.path,g);if(!M){k.push({key:D,routeId:N.routeId,path:N.path,matches:null,match:null,controller:null});return}let F=e.fetchers.get(D),U=Rf(M,N.path),$=!1;p.has(D)?$=!1:c.includes(D)?$=!0:F&&F.state!=="idle"&&F.data===void 0?$=a:$=Zj(U,Er({currentUrl:b,currentParams:e.matches[e.matches.length-1].params,nextUrl:S,nextParams:t[t.length-1].params},r,{actionResult:y,actionStatus:R,defaultShouldRevalidate:I?!1:a})),$&&k.push({key:D,routeId:N.routeId,path:N.path,matches:M,match:U,controller:new AbortController})}),[A,k]}function wre(n,e,t){let r=!e||t.route.id!==e.route.id,s=n[t.route.id]===void 0;return r||s}function Jj(n,e){let t=n.route.path;return n.pathname!==e.pathname||t!=null&&t.endsWith("*")&&n.params["*"]!==e.params["*"]}function Zj(n,e){if(n.route.shouldRevalidate){let t=n.route.shouldRevalidate(e);if(typeof t=="boolean")return t}return e.defaultShouldRevalidate}async function Tre(n,e,t,r,s,i,o,a){let l=[e,...t.map(c=>c.route.id)].join("-");try{let c=o.get(l);c||(c=n({path:e,matches:t,patch:(d,f)=>{a.aborted||eF(d,f,r,s,i)}}),o.set(l,c)),c&&Nre(c)&&await c}finally{o.delete(l)}}function eF(n,e,t,r,s){if(n){var i;let o=r[n];gn(o,"No route found to patch children into: routeId = "+n);let a=Tf(e,s,[n,"patch",String(((i=o.children)==null?void 0:i.length)||"0")],r);o.children?o.children.push(...a):o.children=a}else{let o=Tf(e,s,["patch",String(t.length||"0")],r);t.push(...o)}}async function tF(n,e,t){if(!n.lazy)return;let r=await n.lazy();if(!n.lazy)return;let s=t[n.id];gn(s,"No route found in manifest");let i={};for(let o in r){let l=s[o]!==void 0&&o!=="hasErrorBoundary";Xl(!l,'Route "'+s.id+'" has a static property "'+o+'" defined but its lazy function is also returning a value for this property. '+('The lazy route property "'+o+'" will be ignored.')),!l&&!Kne.has(o)&&(i[o]=r[o])}Object.assign(s,i),Object.assign(s,Er({},e(s),{lazy:void 0}))}function Cre(n){return Promise.all(n.matches.map(e=>e.resolve()))}async function Ire(n,e,t,r,s,i,o,a){let l=r.reduce((f,p)=>f.add(p.route.id),new Set),c=new Set,d=await n({matches:s.map(f=>{let p=l.has(f.route.id);return Er({},f,{shouldLoad:p,resolve:g=>(c.add(f.route.id),p?Rre(e,t,f,i,o,g,a):Promise.resolve({type:Qn.data,result:void 0}))})}),request:t,params:s[0].params,context:a});return s.forEach(f=>gn(c.has(f.route.id),'`match.resolve()` was not called for route id "'+f.route.id+'". You must call `match.resolve()` on every match passed to `dataStrategy` to ensure all routes are properly loaded.')),d.filter((f,p)=>l.has(s[p].route.id))}async function Rre(n,e,t,r,s,i,o){let a,l,c=d=>{let f,p=new Promise((v,y)=>f=y);l=()=>f(),e.signal.addEventListener("abort",l);let m=v=>typeof d!="function"?Promise.reject(new Error("You cannot call the handler for a route which defines a boolean "+('"'+n+'" [routeId: '+t.route.id+"]"))):d({request:e,params:t.params,context:o},...v!==void 0?[v]:[]),g;return i?g=i(v=>m(v)):g=(async()=>{try{return{type:"data",result:await m()}}catch(v){return{type:"error",result:v}}})(),Promise.race([g,p])};try{let d=t.route[n];if(t.route.lazy)if(d){let f,[p]=await Promise.all([c(d).catch(m=>{f=m}),tF(t.route,s,r)]);if(f!==void 0)throw f;a=p}else if(await tF(t.route,s,r),d=t.route[n],d)a=await c(d);else if(n==="action"){let f=new URL(e.url),p=f.pathname+f.search;throw Ds(405,{method:e.method,pathname:p,routeId:t.route.id})}else return{type:Qn.data,result:void 0};else if(d)a=await c(d);else{let f=new URL(e.url),p=f.pathname+f.search;throw Ds(404,{pathname:p})}gn(a.result!==void 0,"You defined "+(n==="action"?"an action":"a loader")+" for route "+('"'+t.route.id+"\" but didn't return anything from your `"+n+"` ")+"function. Please return a value or `null`.")}catch(d){return{type:Qn.error,result:d}}finally{l&&e.signal.removeEventListener("abort",l)}return a}async function Are(n){let{result:e,type:t,status:r}=n;if(uF(e)){let o;try{let a=e.headers.get("Content-Type");a&&/\bapplication\/json\b/.test(a)?e.body==null?o=null:o=await e.json():o=await e.text()}catch(a){return{type:Qn.error,error:a}}return t===Qn.error?{type:Qn.error,error:new Wj(e.status,e.statusText,o),statusCode:e.status,headers:e.headers}:{type:Qn.data,data:o,statusCode:e.status,headers:e.headers}}if(t===Qn.error)return{type:Qn.error,error:e,statusCode:Om(e)?e.status:r};if(Pre(e)){var s,i;return{type:Qn.deferred,deferredData:e,statusCode:(s=e.init)==null?void 0:s.status,headers:((i=e.init)==null?void 0:i.headers)&&new Headers(e.init.headers)}}return{type:Qn.data,data:e,statusCode:r}}function kre(n,e,t,r,s,i){let o=n.headers.get("Location");if(gn(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!pE.test(o)){let a=r.slice(0,r.findIndex(l=>l.route.id===t)+1);o=mE(new URL(e.url),a,s,!0,o,i),n.headers.set("Location",o)}return n}function nF(n,e,t){if(pE.test(n)){let r=n,s=r.startsWith("//")?new URL(e.protocol+r):new URL(r),i=Cf(s.pathname,t)!=null;if(s.origin===e.origin&&i)return s.pathname+s.search+s.hash}return n}function lu(n,e,t,r){let s=n.createURL(cF(e)).toString(),i={signal:t};if(r&&io(r.formMethod)){let{formMethod:o,formEncType:a}=r;i.method=o.toUpperCase(),a==="application/json"?(i.headers=new Headers({"Content-Type":a}),i.body=JSON.stringify(r.json)):a==="text/plain"?i.body=r.text:a==="application/x-www-form-urlencoded"&&r.formData?i.body=gE(r.formData):i.body=r.formData}return new Request(s,i)}function gE(n){let e=new URLSearchParams;for(let[t,r]of n.entries())e.append(t,typeof r=="string"?r:r.name);return e}function rF(n){let e=new FormData;for(let[t,r]of n.entries())e.append(t,r);return e}function Lre(n,e,t,r,s,i){let o={},a=null,l,c=!1,d={},f=r&&ui(r[1])?r[1].error:void 0;return t.forEach((p,m)=>{let g=e[m].route.id;if(gn(!Zl(p),"Cannot handle redirect results in processLoaderData"),ui(p)){let v=p.error;f!==void 0&&(v=f,f=void 0),a=a||{};{let y=cu(n,g);a[y.route.id]==null&&(a[y.route.id]=v)}o[g]=void 0,c||(c=!0,l=Om(p.error)?p.error.status:500),p.headers&&(d[g]=p.headers)}else Jl(p)?(s.set(g,p.deferredData),o[g]=p.deferredData.data,p.statusCode!=null&&p.statusCode!==200&&!c&&(l=p.statusCode),p.headers&&(d[g]=p.headers)):(o[g]=p.data,p.statusCode&&p.statusCode!==200&&!c&&(l=p.statusCode),p.headers&&(d[g]=p.headers))}),f!==void 0&&r&&(a={[r[0]]:f},o[r[0]]=void 0),{loaderData:o,errors:a,statusCode:l||200,loaderHeaders:d}}function sF(n,e,t,r,s,i,o,a){let{loaderData:l,errors:c}=Lre(e,t,r,s,a);for(let d=0;d<i.length;d++){let{key:f,match:p,controller:m}=i[d];gn(o!==void 0&&o[d]!==void 0,"Did not find corresponding fetcher result");let g=o[d];if(!(m&&m.signal.aborted))if(ui(g)){let v=cu(n.matches,p==null?void 0:p.route.id);c&&c[v.route.id]||(c=Er({},c,{[v.route.id]:g.error})),n.fetchers.delete(f)}else if(Zl(g))gn(!1,"Unhandled fetcher revalidation redirect");else if(Jl(g))gn(!1,"Unhandled fetcher deferred data");else{let v=Ga(g.data);n.fetchers.set(f,v)}}return{loaderData:l,errors:c}}function iF(n,e,t,r){let s=Er({},e);for(let i of t){let o=i.route.id;if(e.hasOwnProperty(o)?e[o]!==void 0&&(s[o]=e[o]):n[o]!==void 0&&i.route.loader&&(s[o]=n[o]),r&&r.hasOwnProperty(o))break}return s}function oF(n){return n?ui(n[1])?{actionData:{}}:{actionData:{[n[0]]:n[1].data}}:{}}function cu(n,e){return(e?n.slice(0,n.findIndex(r=>r.route.id===e)+1):[...n]).reverse().find(r=>r.route.hasErrorBoundary===!0)||n[0]}function aF(n){let e=n.length===1?n[0]:n.find(t=>t.index||!t.path||t.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:e}],route:e}}function Ds(n,e){let{pathname:t,routeId:r,method:s,type:i,message:o}=e===void 0?{}:e,a="Unknown Server Error",l="Unknown @remix-run/router error";return n===400?(a="Bad Request",i==="route-discovery"?l='Unable to match URL "'+t+'" - the `unstable_patchRoutesOnMiss()` '+(`function threw the following error:
359 `+o):s&&t&&r?l="You made a "+s+' request to "'+t+'" but '+('did not provide a `loader` for route "'+r+'", ')+"so there is no way to handle the request.":i==="defer-action"?l="defer() is not supported in actions":i==="invalid-body"&&(l="Unable to encode submission body")):n===403?(a="Forbidden",l='Route "'+r+'" does not match URL "'+t+'"'):n===404?(a="Not Found",l='No route matches URL "'+t+'"'):n===405&&(a="Method Not Allowed",s&&t&&r?l="You made a "+s.toUpperCase()+' request to "'+t+'" but '+('did not provide an `action` for route "'+r+'", ')+"so there is no way to handle the request.":s&&(l='Invalid request method "'+s.toUpperCase()+'"')),new Wj(n||500,a,new Error(l),!0)}function lF(n){for(let e=n.length-1;e>=0;e--){let t=n[e];if(Zl(t))return{result:t,idx:e}}}function cF(n){let e=typeof n=="string"?ra(n):n;return Mm(Er({},e,{hash:""}))}function Mre(n,e){return n.pathname!==e.pathname||n.search!==e.search?!1:n.hash===""?e.hash!=="":n.hash===e.hash?!0:e.hash!==""}function Nre(n){return typeof n=="object"&&n!=null&&"then"in n}function Ore(n){return uF(n.result)&&_re.has(n.result.status)}function Jl(n){return n.type===Qn.deferred}function ui(n){return n.type===Qn.error}function Zl(n){return(n&&n.type)===Qn.redirect}function Pre(n){let e=n;return e&&typeof e=="object"&&typeof e.data=="object"&&typeof e.subscribe=="function"&&typeof e.cancel=="function"&&typeof e.resolveData=="function"}function uF(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.headers=="object"&&typeof n.body<"u"}function Dre(n){return gre.has(n.toLowerCase())}function io(n){return pre.has(n.toLowerCase())}async function dF(n,e,t,r,s,i){for(let o=0;o<t.length;o++){let a=t[o],l=e[o];if(!l)continue;let c=n.find(f=>f.route.id===l.route.id),d=c!=null&&!Jj(c,l)&&(i&&i[l.route.id])!==void 0;if(Jl(a)&&(s||d)){let f=r[o];gn(f,"Expected an AbortSignal for revalidating fetcher deferred result"),await fF(a,f,s).then(p=>{p&&(t[o]=p||t[o])})}}}async function fF(n,e,t){if(t===void 0&&(t=!1),!await n.deferredData.resolveData(e)){if(t)try{return{type:Qn.data,data:n.deferredData.unwrappedData}}catch(s){return{type:Qn.error,error:s}}return{type:Qn.data,data:n.deferredData.data}}}function _E(n){return new URLSearchParams(n).getAll("index").some(e=>e==="")}function Rf(n,e){let t=typeof e=="string"?ra(e).search:e.search;if(n[n.length-1].route.index&&_E(t||""))return n[n.length-1];let r=Vj(n);return r[r.length-1]}function hF(n){let{formMethod:e,formAction:t,formEncType:r,text:s,formData:i,json:o}=n;if(!(!e||!t||!r)){if(s!=null)return{formMethod:e,formAction:t,formEncType:r,formData:void 0,json:void 0,text:s};if(i!=null)return{formMethod:e,formAction:t,formEncType:r,formData:i,json:void 0,text:void 0};if(o!==void 0)return{formMethod:e,formAction:t,formEncType:r,formData:void 0,json:o,text:void 0}}}function vE(n,e){return e?{state:"loading",location:n,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}:{state:"loading",location:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function jre(n,e){return{state:"submitting",location:n,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text}}function Af(n,e){return n?{state:"loading",formMethod:n.formMethod,formAction:n.formAction,formEncType:n.formEncType,formData:n.formData,json:n.json,text:n.text,data:e}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Fre(n,e){return{state:"submitting",formMethod:n.formMethod,formAction:n.formAction,formEncType:n.formEncType,formData:n.formData,json:n.json,text:n.text,data:e?e.data:void 0}}function Ga(n){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:n}}function Ure(n,e){try{let t=n.sessionStorage.getItem(Yj);if(t){let r=JSON.parse(t);for(let[s,i]of Object.entries(r||{}))i&&Array.isArray(i)&&e.set(s,new Set(i||[]))}}catch{}}function Bre(n,e){if(e.size>0){let t={};for(let[r,s]of e)t[r]=[...s];try{n.sessionStorage.setItem(Yj,JSON.stringify(t))}catch(r){Xl(!1,"Failed to save applied view transitions in sessionStorage ("+r+").")}}}function kf(){return kf=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},kf.apply(this,arguments)}const Pm=T.createContext(null),pF=T.createContext(null),Lf=T.createContext(null),yE=T.createContext(null),ec=T.createContext({outlet:null,matches:[],isDataRoute:!1}),mF=T.createContext(null);function Mf(){return T.useContext(yE)!=null}function bE(){return Mf()||gn(!1),T.useContext(yE).location}function gF(n){T.useContext(Lf).static||T.useLayoutEffect(n)}function $re(){let{isDataRoute:n}=T.useContext(ec);return n?Zre():zre()}function zre(){Mf()||gn(!1);let n=T.useContext(Pm),{basename:e,future:t,navigator:r}=T.useContext(Lf),{matches:s}=T.useContext(ec),{pathname:i}=bE(),o=JSON.stringify(dE(s,t.v7_relativeSplatPath)),a=T.useRef(!1);return gF(()=>{a.current=!0}),T.useCallback(function(c,d){if(d===void 0&&(d={}),!a.current)return;if(typeof c=="number"){r.go(c);return}let f=fE(c,JSON.parse(o),i,d.relative==="path");n==null&&e!=="/"&&(f.pathname=f.pathname==="/"?e:Ha([e,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[e,r,o,i,n])}function qre(n,e,t,r){Mf()||gn(!1);let{navigator:s}=T.useContext(Lf),{matches:i}=T.useContext(ec),o=i[i.length-1],a=o?o.params:{};o&&o.pathname;let l=o?o.pathnameBase:"/";o&&o.route;let c=bE(),d;d=c;let f=d.pathname||"/",p=f;if(l!=="/"){let v=l.replace(/^\//,"").split("/");p="/"+f.replace(/^\//,"").split("/").slice(v.length).join("/")}let m=Ql(n,{pathname:p});return Kre(m&&m.map(v=>Object.assign({},v,{params:Object.assign({},a,v.params),pathname:Ha([l,s.encodeLocation?s.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?l:Ha([l,s.encodeLocation?s.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,t,r)}function Hre(){let n=Jre(),e=Om(n)?n.status+" "+n.statusText:n instanceof Error?n.message:JSON.stringify(n),t=n instanceof Error?n.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return T.createElement(T.Fragment,null,T.createElement("h2",null,"Unexpected Application Error!"),T.createElement("h3",{style:{fontStyle:"italic"}},e),t?T.createElement("pre",{style:s},t):null,null)}const Gre=T.createElement(Hre,null);class Vre extends T.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error!==void 0?T.createElement(ec.Provider,{value:this.props.routeContext},T.createElement(mF.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Wre(n){let{routeContext:e,match:t,children:r}=n,s=T.useContext(Pm);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),T.createElement(ec.Provider,{value:e},r)}function Kre(n,e,t,r){var s;if(e===void 0&&(e=[]),t===void 0&&(t=null),r===void 0&&(r=null),n==null){var i;if((i=t)!=null&&i.errors)n=t.matches;else return null}let o=n,a=(s=t)==null?void 0:s.errors;if(a!=null){let d=o.findIndex(f=>f.route.id&&(a==null?void 0:a[f.route.id])!==void 0);d>=0||gn(!1),o=o.slice(0,Math.min(o.length,d+1))}let l=!1,c=-1;if(t&&r&&r.v7_partialHydration)for(let d=0;d<o.length;d++){let f=o[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:p,errors:m}=t,g=f.route.loader&&p[f.route.id]===void 0&&(!m||m[f.route.id]===void 0);if(f.route.lazy||g){l=!0,c>=0?o=o.slice(0,c+1):o=[o[0]];break}}}return o.reduceRight((d,f,p)=>{let m,g=!1,v=null,y=null;t&&(m=a&&f.route.id?a[f.route.id]:void 0,v=f.route.errorElement||Gre,l&&(c<0&&p===0?(ese("route-fallback"),g=!0,y=null):c===p&&(g=!0,y=f.route.hydrateFallbackElement||null)));let b=e.concat(o.slice(0,p+1)),S=()=>{let E;return m?E=v:g?E=y:f.route.Component?E=T.createElement(f.route.Component,null):f.route.element?E=f.route.element:E=d,T.createElement(Wre,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:t!=null},children:E})};return t&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?T.createElement(Vre,{location:t.location,revalidation:t.revalidation,component:v,error:m,children:S(),routeContext:{outlet:null,matches:b,isDataRoute:!0}}):S()},null)}var _F=function(n){return n.UseBlocker="useBlocker",n.UseRevalidator="useRevalidator",n.UseNavigateStable="useNavigate",n}(_F||{}),vF=function(n){return n.UseBlocker="useBlocker",n.UseLoaderData="useLoaderData",n.UseActionData="useActionData",n.UseRouteError="useRouteError",n.UseNavigation="useNavigation",n.UseRouteLoaderData="useRouteLoaderData",n.UseMatches="useMatches",n.UseRevalidator="useRevalidator",n.UseNavigateStable="useNavigate",n.UseRouteId="useRouteId",n}(vF||{});function Yre(n){let e=T.useContext(Pm);return e||gn(!1),e}function Xre(n){let e=T.useContext(pF);return e||gn(!1),e}function Qre(n){let e=T.useContext(ec);return e||gn(!1),e}function yF(n){let e=Qre(),t=e.matches[e.matches.length-1];return t.route.id||gn(!1),t.route.id}function Jre(){var n;let e=T.useContext(mF),t=Xre(),r=yF();return e!==void 0?e:(n=t.errors)==null?void 0:n[r]}function Zre(){let{router:n}=Yre(_F.UseNavigateStable),e=yF(vF.UseNavigateStable),t=T.useRef(!1);return gF(()=>{t.current=!0}),T.useCallback(function(s,i){i===void 0&&(i={}),t.current&&(typeof s=="number"?n.navigate(s):n.navigate(s,kf({fromRouteId:e},i)))},[n,e])}const bF={};function ese(n,e,t){bF[n]||(bF[n]=!0)}function tse(n){let{to:e,replace:t,state:r,relative:s}=n;Mf()||gn(!1);let{future:i,static:o}=T.useContext(Lf),{matches:a}=T.useContext(ec),{pathname:l}=bE(),c=$re(),d=fE(e,dE(a,i.v7_relativeSplatPath),l,s==="path"),f=JSON.stringify(d);return T.useEffect(()=>c(JSON.parse(f),{replace:t,state:r,relative:s}),[c,f,s,t,r]),null}function nse(n){let{basename:e="/",children:t=null,location:r,navigationType:s=Nr.Pop,navigator:i,static:o=!1,future:a}=n;Mf()&&gn(!1);let l=e.replace(/^\/*/,"/"),c=T.useMemo(()=>({basename:l,navigator:i,static:o,future:kf({v7_relativeSplatPath:!1},a)}),[l,a,i,o]);typeof r=="string"&&(r=ra(r));let{pathname:d="/",search:f="",hash:p="",state:m=null,key:g="default"}=r,v=T.useMemo(()=>{let y=Cf(d,l);return y==null?null:{location:{pathname:y,search:f,hash:p,state:m,key:g},navigationType:s}},[l,d,f,p,m,g,s]);return v==null?null:T.createElement(Lf.Provider,{value:c},T.createElement(yE.Provider,{children:t,value:v}))}new Promise(()=>{});function rse(n){let e={hasErrorBoundary:n.ErrorBoundary!=null||n.errorElement!=null};return n.Component&&Object.assign(e,{element:T.createElement(n.Component),Component:void 0}),n.HydrateFallback&&Object.assign(e,{hydrateFallbackElement:T.createElement(n.HydrateFallback),HydrateFallback:void 0}),n.ErrorBoundary&&Object.assign(e,{errorElement:T.createElement(n.ErrorBoundary),ErrorBoundary:void 0}),e}function sse(n,e){return xre({basename:e==null?void 0:e.basename,future:kf({},e==null?void 0:e.future,{v7_prependBasename:!0}),history:Vne({initialEntries:e==null?void 0:e.initialEntries,initialIndex:e==null?void 0:e.initialIndex}),hydrationData:e==null?void 0:e.hydrationData,routes:n,mapRouteProperties:rse,unstable_dataStrategy:e==null?void 0:e.unstable_dataStrategy,unstable_patchRoutesOnMiss:e==null?void 0:e.unstable_patchRoutesOnMiss}).initialize()}const ise="6";try{window.__reactRouterVersion=ise}catch{}const ose=T.createContext({isTransitioning:!1}),ase=T.createContext(new Map),xF=Pz["startTransition"],SF=nH["flushSync"];function lse(n){xF?xF(n):n()}function Nf(n){SF?SF(n):n()}class cse{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",e(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",t(r))}})}}function use(n){let{fallbackElement:e,router:t,future:r}=n,[s,i]=T.useState(t.state),[o,a]=T.useState(),[l,c]=T.useState({isTransitioning:!1}),[d,f]=T.useState(),[p,m]=T.useState(),[g,v]=T.useState(),y=T.useRef(new Map),{v7_startTransition:b}=r||{},S=T.useCallback(k=>{b?lse(k):k()},[b]),E=T.useCallback((k,N)=>{let{deletedFetchers:D,unstable_flushSync:M,unstable_viewTransitionOpts:F}=N;D.forEach($=>y.current.delete($)),k.fetchers.forEach(($,q)=>{$.data!==void 0&&y.current.set(q,$.data)});let U=t.window==null||t.window.document==null||typeof t.window.document.startViewTransition!="function";if(!F||U){M?Nf(()=>i(k)):S(()=>i(k));return}if(M){Nf(()=>{p&&(d&&d.resolve(),p.skipTransition()),c({isTransitioning:!0,flushSync:!0,currentLocation:F.currentLocation,nextLocation:F.nextLocation})});let $=t.window.document.startViewTransition(()=>{Nf(()=>i(k))});$.finished.finally(()=>{Nf(()=>{f(void 0),m(void 0),a(void 0),c({isTransitioning:!1})})}),Nf(()=>m($));return}p?(d&&d.resolve(),p.skipTransition(),v({state:k,currentLocation:F.currentLocation,nextLocation:F.nextLocation})):(a(k),c({isTransitioning:!0,flushSync:!1,currentLocation:F.currentLocation,nextLocation:F.nextLocation}))},[t.window,p,d,y,S]);T.useLayoutEffect(()=>t.subscribe(E),[t,E]),T.useEffect(()=>{l.isTransitioning&&!l.flushSync&&f(new cse)},[l]),T.useEffect(()=>{if(d&&o&&t.window){let k=o,N=d.promise,D=t.window.document.startViewTransition(async()=>{S(()=>i(k)),await N});D.finished.finally(()=>{f(void 0),m(void 0),a(void 0),c({isTransitioning:!1})}),m(D)}},[S,o,d,t.window]),T.useEffect(()=>{d&&o&&s.location.key===o.location.key&&d.resolve()},[d,p,s.location,o]),T.useEffect(()=>{!l.isTransitioning&&g&&(a(g.state),c({isTransitioning:!0,flushSync:!1,currentLocation:g.currentLocation,nextLocation:g.nextLocation}),v(void 0))},[l.isTransitioning,g]),T.useEffect(()=>{},[]);let C=T.useMemo(()=>({createHref:t.createHref,encodeLocation:t.encodeLocation,go:k=>t.navigate(k),push:(k,N,D)=>t.navigate(k,{state:N,preventScrollReset:D==null?void 0:D.preventScrollReset}),replace:(k,N,D)=>t.navigate(k,{replace:!0,state:N,preventScrollReset:D==null?void 0:D.preventScrollReset})}),[t]),R=t.basename||"/",I=T.useMemo(()=>({router:t,navigator:C,static:!1,basename:R}),[t,C,R]),A=T.useMemo(()=>({v7_relativeSplatPath:t.future.v7_relativeSplatPath}),[t.future.v7_relativeSplatPath]);return T.createElement(T.Fragment,null,T.createElement(Pm.Provider,{value:I},T.createElement(pF.Provider,{value:s},T.createElement(ase.Provider,{value:y.current},T.createElement(ose.Provider,{value:l},T.createElement(nse,{basename:R,location:s.location,navigationType:s.historyAction,navigator:C,future:A},s.initialized||t.future.v7_partialHydration?T.createElement(dse,{routes:t.routes,future:t.future,state:s}):e))))),null)}const dse=T.memo(fse);function fse(n){let{routes:e,future:t,state:r}=n;return qre(e,void 0,r,t)}var EF;(function(n){n.UseScrollRestoration="useScrollRestoration",n.UseSubmit="useSubmit",n.UseSubmitFetcher="useSubmitFetcher",n.UseFetcher="useFetcher",n.useViewTransitionState="useViewTransitionState"})(EF||(EF={}));var wF;(function(n){n.UseFetcher="useFetcher",n.UseFetchers="useFetchers",n.UseScrollRestoration="useScrollRestoration"})(wF||(wF={}));const hse=sse([{path:"/",element:_.jsx(tse,{to:"/chat"})},{path:"/chat",element:_.jsx($j,{})},{element:_.jsx($j,{}),path:"/chat/:contactHashId"},{path:"/login",element:_.jsx(zne,{})},{path:"/modals",element:_.jsx(Gne,{})}],{initialEntries:["/chat"]});var TF={},Of,CF;function Ii(){if(CF)return Of;CF=1;var n=function(e){return e&&e.Math===Math&&e};return Of=n(typeof globalThis=="object"&&globalThis)||n(typeof window=="object"&&window)||n(typeof self=="object"&&self)||n(typeof Bi=="object"&&Bi)||n(typeof Of=="object"&&Of)||function(){return this}()||Function("return this")(),Of}var xE={},SE,IF;function sa(){return IF||(IF=1,SE=function(n){try{return!!n()}catch{return!0}}),SE}var EE,RF;function Va(){if(RF)return EE;RF=1;var n=sa();return EE=!n(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),EE}var wE,AF;function TE(){if(AF)return wE;AF=1;var n=sa();return wE=!n(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),wE}var CE,kF;function IE(){if(kF)return CE;kF=1;var n=TE(),e=Function.prototype.call;return CE=n?e.bind(e):function(){return e.apply(e,arguments)},CE}var RE={},LF;function pse(){if(LF)return RE;LF=1;var n={}.propertyIsEnumerable,e=Object.getOwnPropertyDescriptor,t=e&&!n.call({1:2},1);return RE.f=t?function(s){var i=e(this,s);return!!i&&i.enumerable}:n,RE}var AE,MF;function NF(){return MF||(MF=1,AE=function(n,e){return{enumerable:!(n&1),configurable:!(n&2),writable:!(n&4),value:e}}),AE}var kE,OF;function di(){if(OF)return kE;OF=1;var n=TE(),e=Function.prototype,t=e.call,r=n&&e.bind.bind(t,t);return kE=n?r:function(s){return function(){return t.apply(s,arguments)}},kE}var LE,PF;function Dm(){if(PF)return LE;PF=1;var n=di(),e=n({}.toString),t=n("".slice);return LE=function(r){return t(e(r),8,-1)},LE}var ME,DF;function jF(){if(DF)return ME;DF=1;var n=di(),e=sa(),t=Dm(),r=Object,s=n("".split);return ME=e(function(){return!r("z").propertyIsEnumerable(0)})?function(i){return t(i)==="String"?s(i,""):r(i)}:r,ME}var NE,FF;function UF(){return FF||(FF=1,NE=function(n){return n==null}),NE}var OE,BF;function $F(){if(BF)return OE;BF=1;var n=UF(),e=TypeError;return OE=function(t){if(n(t))throw new e("Can't call method on "+t);return t},OE}var PE,zF;function jm(){if(zF)return PE;zF=1;var n=jF(),e=$F();return PE=function(t){return n(e(t))},PE}var DE,qF;function Ri(){if(qF)return DE;qF=1;var n=typeof document=="object"&&document.all;return DE=typeof n>"u"&&n!==void 0?function(e){return typeof e=="function"||e===n}:function(e){return typeof e=="function"},DE}var jE,HF;function uu(){if(HF)return jE;HF=1;var n=Ri();return jE=function(e){return typeof e=="object"?e!==null:n(e)},jE}var FE,GF;function Fm(){if(GF)return FE;GF=1;var n=Ii(),e=Ri(),t=function(r){return e(r)?r:void 0};return FE=function(r,s){return arguments.length<2?t(n[r]):n[r]&&n[r][s]},FE}var UE,VF;function mse(){if(VF)return UE;VF=1;var n=di();return UE=n({}.isPrototypeOf),UE}var BE,WF;function gse(){if(WF)return BE;WF=1;var n=Ii(),e=n.navigator,t=e&&e.userAgent;return BE=t?String(t):"",BE}var $E,KF;function _se(){if(KF)return $E;KF=1;var n=Ii(),e=gse(),t=n.process,r=n.Deno,s=t&&t.versions||r&&r.version,i=s&&s.v8,o,a;return i&&(o=i.split("."),a=o[0]>0&&o[0]<4?1:+(o[0]+o[1])),!a&&e&&(o=e.match(/Edge\/(\d+)/),(!o||o[1]>=74)&&(o=e.match(/Chrome\/(\d+)/),o&&(a=+o[1]))),$E=a,$E}var zE,YF;function XF(){if(YF)return zE;YF=1;var n=_se(),e=sa(),t=Ii(),r=t.String;return zE=!!Object.getOwnPropertySymbols&&!e(function(){var s=Symbol("symbol detection");return!r(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&n&&n<41}),zE}var qE,QF;function JF(){if(QF)return qE;QF=1;var n=XF();return qE=n&&!Symbol.sham&&typeof Symbol.iterator=="symbol",qE}var HE,ZF;function e2(){if(ZF)return HE;ZF=1;var n=Fm(),e=Ri(),t=mse(),r=JF(),s=Object;return HE=r?function(i){return typeof i=="symbol"}:function(i){var o=n("Symbol");return e(o)&&t(o.prototype,s(i))},HE}var GE,t2;function vse(){if(t2)return GE;t2=1;var n=String;return GE=function(e){try{return n(e)}catch{return"Object"}},GE}var VE,n2;function r2(){if(n2)return VE;n2=1;var n=Ri(),e=vse(),t=TypeError;return VE=function(r){if(n(r))return r;throw new t(e(r)+" is not a function")},VE}var WE,s2;function yse(){if(s2)return WE;s2=1;var n=r2(),e=UF();return WE=function(t,r){var s=t[r];return e(s)?void 0:n(s)},WE}var KE,i2;function bse(){if(i2)return KE;i2=1;var n=IE(),e=Ri(),t=uu(),r=TypeError;return KE=function(s,i){var o,a;if(i==="string"&&e(o=s.toString)&&!t(a=n(o,s))||e(o=s.valueOf)&&!t(a=n(o,s))||i!=="string"&&e(o=s.toString)&&!t(a=n(o,s)))return a;throw new r("Can't convert object to primitive value")},KE}var YE={exports:{}},XE,o2;function xse(){return o2||(o2=1,XE=!1),XE}var QE,a2;function JE(){if(a2)return QE;a2=1;var n=Ii(),e=Object.defineProperty;return QE=function(t,r){try{e(n,t,{value:r,configurable:!0,writable:!0})}catch{n[t]=r}return r},QE}var l2;function ZE(){if(l2)return YE.exports;l2=1;var n=xse(),e=Ii(),t=JE(),r="__core-js_shared__",s=YE.exports=e[r]||t(r,{});return(s.versions||(s.versions=[])).push({version:"3.41.0",mode:n?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE",source:"https://github.com/zloirock/core-js"}),YE.exports}var ew,c2;function u2(){if(c2)return ew;c2=1;var n=ZE();return ew=function(e,t){return n[e]||(n[e]=t||{})},ew}var tw,d2;function nw(){if(d2)return tw;d2=1;var n=$F(),e=Object;return tw=function(t){return e(n(t))},tw}var rw,f2;function tc(){if(f2)return rw;f2=1;var n=di(),e=nw(),t=n({}.hasOwnProperty);return rw=Object.hasOwn||function(s,i){return t(e(s),i)},rw}var sw,h2;function p2(){if(h2)return sw;h2=1;var n=di(),e=0,t=Math.random(),r=n(1 .toString);return sw=function(s){return"Symbol("+(s===void 0?"":s)+")_"+r(++e+t,36)},sw}var iw,m2;function Pf(){if(m2)return iw;m2=1;var n=Ii(),e=u2(),t=tc(),r=p2(),s=XF(),i=JF(),o=n.Symbol,a=e("wks"),l=i?o.for||o:o&&o.withoutSetter||r;return iw=function(c){return t(a,c)||(a[c]=s&&t(o,c)?o[c]:l("Symbol."+c)),a[c]},iw}var ow,g2;function Sse(){if(g2)return ow;g2=1;var n=IE(),e=uu(),t=e2(),r=yse(),s=bse(),i=Pf(),o=TypeError,a=i("toPrimitive");return ow=function(l,c){if(!e(l)||t(l))return l;var d=r(l,a),f;if(d){if(c===void 0&&(c="default"),f=n(d,l,c),!e(f)||t(f))return f;throw new o("Can't convert object to primitive value")}return c===void 0&&(c="number"),s(l,c)},ow}var aw,_2;function v2(){if(_2)return aw;_2=1;var n=Sse(),e=e2();return aw=function(t){var r=n(t,"string");return e(r)?r:r+""},aw}var lw,y2;function b2(){if(y2)return lw;y2=1;var n=Ii(),e=uu(),t=n.document,r=e(t)&&e(t.createElement);return lw=function(s){return r?t.createElement(s):{}},lw}var cw,x2;function S2(){if(x2)return cw;x2=1;var n=Va(),e=sa(),t=b2();return cw=!n&&!e(function(){return Object.defineProperty(t("div"),"a",{get:function(){return 7}}).a!==7}),cw}var E2;function w2(){if(E2)return xE;E2=1;var n=Va(),e=IE(),t=pse(),r=NF(),s=jm(),i=v2(),o=tc(),a=S2(),l=Object.getOwnPropertyDescriptor;return xE.f=n?l:function(d,f){if(d=s(d),f=i(f),a)try{return l(d,f)}catch{}if(o(d,f))return r(!e(t.f,d,f),d[f])},xE}var uw={},dw,T2;function C2(){if(T2)return dw;T2=1;var n=Va(),e=sa();return dw=n&&e(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),dw}var fw,I2;function Um(){if(I2)return fw;I2=1;var n=uu(),e=String,t=TypeError;return fw=function(r){if(n(r))return r;throw new t(e(r)+" is not an object")},fw}var R2;function Df(){if(R2)return uw;R2=1;var n=Va(),e=S2(),t=C2(),r=Um(),s=v2(),i=TypeError,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l="enumerable",c="configurable",d="writable";return uw.f=n?t?function(p,m,g){if(r(p),m=s(m),r(g),typeof p=="function"&&m==="prototype"&&"value"in g&&d in g&&!g[d]){var v=a(p,m);v&&v[d]&&(p[m]=g.value,g={configurable:c in g?g[c]:v[c],enumerable:l in g?g[l]:v[l],writable:!1})}return o(p,m,g)}:o:function(p,m,g){if(r(p),m=s(m),r(g),e)try{return o(p,m,g)}catch{}if("get"in g||"set"in g)throw new i("Accessors not supported");return"value"in g&&(p[m]=g.value),p},uw}var hw,A2;function k2(){if(A2)return hw;A2=1;var n=Va(),e=Df(),t=NF();return hw=n?function(r,s,i){return e.f(r,s,t(1,i))}:function(r,s,i){return r[s]=i,r},hw}var pw={exports:{}},mw,L2;function Ese(){if(L2)return mw;L2=1;var n=Va(),e=tc(),t=Function.prototype,r=n&&Object.getOwnPropertyDescriptor,s=e(t,"name"),i=s&&(function(){}).name==="something",o=s&&(!n||n&&r(t,"name").configurable);return mw={EXISTS:s,PROPER:i,CONFIGURABLE:o},mw}var gw,M2;function N2(){if(M2)return gw;M2=1;var n=di(),e=Ri(),t=ZE(),r=n(Function.toString);return e(t.inspectSource)||(t.inspectSource=function(s){return r(s)}),gw=t.inspectSource,gw}var _w,O2;function wse(){if(O2)return _w;O2=1;var n=Ii(),e=Ri(),t=n.WeakMap;return _w=e(t)&&/native code/.test(String(t)),_w}var vw,P2;function D2(){if(P2)return vw;P2=1;var n=u2(),e=p2(),t=n("keys");return vw=function(r){return t[r]||(t[r]=e(r))},vw}var yw,j2;function bw(){return j2||(j2=1,yw={}),yw}var xw,F2;function Tse(){if(F2)return xw;F2=1;var n=wse(),e=Ii(),t=uu(),r=k2(),s=tc(),i=ZE(),o=D2(),a=bw(),l="Object already initialized",c=e.TypeError,d=e.WeakMap,f,p,m,g=function(S){return m(S)?p(S):f(S,{})},v=function(S){return function(E){var C;if(!t(E)||(C=p(E)).type!==S)throw new c("Incompatible receiver, "+S+" required");return C}};if(n||i.state){var y=i.state||(i.state=new d);y.get=y.get,y.has=y.has,y.set=y.set,f=function(S,E){if(y.has(S))throw new c(l);return E.facade=S,y.set(S,E),E},p=function(S){return y.get(S)||{}},m=function(S){return y.has(S)}}else{var b=o("state");a[b]=!0,f=function(S,E){if(s(S,b))throw new c(l);return E.facade=S,r(S,b,E),E},p=function(S){return s(S,b)?S[b]:{}},m=function(S){return s(S,b)}}return xw={set:f,get:p,has:m,enforce:g,getterFor:v},xw}var U2;function Cse(){if(U2)return pw.exports;U2=1;var n=di(),e=sa(),t=Ri(),r=tc(),s=Va(),i=Ese().CONFIGURABLE,o=N2(),a=Tse(),l=a.enforce,c=a.get,d=String,f=Object.defineProperty,p=n("".slice),m=n("".replace),g=n([].join),v=s&&!e(function(){return f(function(){},"length",{value:8}).length!==8}),y=String(String).split("String"),b=pw.exports=function(S,E,C){p(d(E),0,7)==="Symbol("&&(E="["+m(d(E),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),C&&C.getter&&(E="get "+E),C&&C.setter&&(E="set "+E),(!r(S,"name")||i&&S.name!==E)&&(s?f(S,"name",{value:E,configurable:!0}):S.name=E),v&&C&&r(C,"arity")&&S.length!==C.arity&&f(S,"length",{value:C.arity});try{C&&r(C,"constructor")&&C.constructor?s&&f(S,"prototype",{writable:!1}):S.prototype&&(S.prototype=void 0)}catch{}var R=l(S);return r(R,"source")||(R.source=g(y,typeof E=="string"?E:"")),S};return Function.prototype.toString=b(function(){return t(this)&&c(this).source||o(this)},"toString"),pw.exports}var Sw,B2;function Ise(){if(B2)return Sw;B2=1;var n=Ri(),e=Df(),t=Cse(),r=JE();return Sw=function(s,i,o,a){a||(a={});var l=a.enumerable,c=a.name!==void 0?a.name:i;if(n(o)&&t(o,c,a),a.global)l?s[i]=o:r(i,o);else{try{a.unsafe?s[i]&&(l=!0):delete s[i]}catch{}l?s[i]=o:e.f(s,i,{value:o,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return s},Sw}var Ew={},ww,$2;function Rse(){if($2)return ww;$2=1;var n=Math.ceil,e=Math.floor;return ww=Math.trunc||function(r){var s=+r;return(s>0?e:n)(s)},ww}var Tw,z2;function Cw(){if(z2)return Tw;z2=1;var n=Rse();return Tw=function(e){var t=+e;return t!==t||t===0?0:n(t)},Tw}var Iw,q2;function Ase(){if(q2)return Iw;q2=1;var n=Cw(),e=Math.max,t=Math.min;return Iw=function(r,s){var i=n(r);return i<0?e(i+s,0):t(i,s)},Iw}var Rw,H2;function kse(){if(H2)return Rw;H2=1;var n=Cw(),e=Math.min;return Rw=function(t){var r=n(t);return r>0?e(r,9007199254740991):0},Rw}var Aw,G2;function kw(){if(G2)return Aw;G2=1;var n=kse();return Aw=function(e){return n(e.length)},Aw}var Lw,V2;function Lse(){if(V2)return Lw;V2=1;var n=jm(),e=Ase(),t=kw(),r=function(s){return function(i,o,a){var l=n(i),c=t(l);if(c===0)return!s&&-1;var d=e(a,c),f;if(s&&o!==o){for(;c>d;)if(f=l[d++],f!==f)return!0}else for(;c>d;d++)if((s||d in l)&&l[d]===o)return s||d||0;return!s&&-1}};return Lw={includes:r(!0),indexOf:r(!1)},Lw}var Mw,W2;function K2(){if(W2)return Mw;W2=1;var n=di(),e=tc(),t=jm(),r=Lse().indexOf,s=bw(),i=n([].push);return Mw=function(o,a){var l=t(o),c=0,d=[],f;for(f in l)!e(s,f)&&e(l,f)&&i(d,f);for(;a.length>c;)e(l,f=a[c++])&&(~r(d,f)||i(d,f));return d},Mw}var Nw,Y2;function Ow(){return Y2||(Y2=1,Nw=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),Nw}var X2;function Mse(){if(X2)return Ew;X2=1;var n=K2(),e=Ow(),t=e.concat("length","prototype");return Ew.f=Object.getOwnPropertyNames||function(s){return n(s,t)},Ew}var Pw={},Q2;function Nse(){return Q2||(Q2=1,Pw.f=Object.getOwnPropertySymbols),Pw}var Dw,J2;function Ose(){if(J2)return Dw;J2=1;var n=Fm(),e=di(),t=Mse(),r=Nse(),s=Um(),i=e([].concat);return Dw=n("Reflect","ownKeys")||function(a){var l=t.f(s(a)),c=r.f;return c?i(l,c(a)):l},Dw}var jw,Z2;function Pse(){if(Z2)return jw;Z2=1;var n=tc(),e=Ose(),t=w2(),r=Df();return jw=function(s,i,o){for(var a=e(i),l=r.f,c=t.f,d=0;d<a.length;d++){var f=a[d];!n(s,f)&&!(o&&n(o,f))&&l(s,f,c(i,f))}},jw}var Fw,eU;function Dse(){if(eU)return Fw;eU=1;var n=sa(),e=Ri(),t=/#|\.prototype\./,r=function(l,c){var d=i[s(l)];return d===a?!0:d===o?!1:e(c)?n(c):!!c},s=r.normalize=function(l){return String(l).replace(t,".").toLowerCase()},i=r.data={},o=r.NATIVE="N",a=r.POLYFILL="P";return Fw=r,Fw}var Uw,tU;function nU(){if(tU)return Uw;tU=1;var n=Ii(),e=w2().f,t=k2(),r=Ise(),s=JE(),i=Pse(),o=Dse();return Uw=function(a,l){var c=a.target,d=a.global,f=a.stat,p,m,g,v,y,b;if(d?m=n:f?m=n[c]||s(c,{}):m=n[c]&&n[c].prototype,m)for(g in l){if(y=l[g],a.dontCallGetSet?(b=e(m,g),v=b&&b.value):v=m[g],p=o(d?g:c+(f?".":"#")+g,a.forced),!p&&v!==void 0){if(typeof y==typeof v)continue;i(y,v)}(a.sham||v&&v.sham)&&t(y,"sham",!0),r(m,g,y,a)}},Uw}var Bw={},$w,rU;function jse(){if(rU)return $w;rU=1;var n=K2(),e=Ow();return $w=Object.keys||function(r){return n(r,e)},$w}var sU;function Fse(){if(sU)return Bw;sU=1;var n=Va(),e=C2(),t=Df(),r=Um(),s=jm(),i=jse();return Bw.f=n&&!e?Object.defineProperties:function(a,l){r(a);for(var c=s(l),d=i(l),f=d.length,p=0,m;f>p;)t.f(a,m=d[p++],c[m]);return a},Bw}var zw,iU;function Use(){if(iU)return zw;iU=1;var n=Fm();return zw=n("document","documentElement"),zw}var qw,oU;function Bse(){if(oU)return qw;oU=1;var n=Um(),e=Fse(),t=Ow(),r=bw(),s=Use(),i=b2(),o=D2(),a=">",l="<",c="prototype",d="script",f=o("IE_PROTO"),p=function(){},m=function(S){return l+d+a+S+l+"/"+d+a},g=function(S){S.write(m("")),S.close();var E=S.parentWindow.Object;return S=null,E},v=function(){var S=i("iframe"),E="java"+d+":",C;return S.style.display="none",s.appendChild(S),S.src=String(E),C=S.contentWindow.document,C.open(),C.write(m("document.F=Object")),C.close(),C.F},y,b=function(){try{y=new ActiveXObject("htmlfile")}catch{}b=typeof document<"u"?document.domain&&y?g(y):v():g(y);for(var S=t.length;S--;)delete b[c][t[S]];return b()};return r[f]=!0,qw=Object.create||function(E,C){var R;return E!==null?(p[c]=n(E),R=new p,p[c]=null,R[f]=E):R=b(),C===void 0?R:e.f(R,C)},qw}var Hw,aU;function lU(){if(aU)return Hw;aU=1;var n=Pf(),e=Bse(),t=Df().f,r=n("unscopables"),s=Array.prototype;return s[r]===void 0&&t(s,r,{configurable:!0,value:e(null)}),Hw=function(i){s[r][i]=!0},Hw}var cU;function $se(){if(cU)return TF;cU=1;var n=nU(),e=nw(),t=kw(),r=Cw(),s=lU();return n({target:"Array",proto:!0},{at:function(o){var a=e(this),l=t(a),c=r(o),d=c>=0?c:l+c;return d<0||d>=l?void 0:a[d]}}),s("at"),TF}var Gw,uU;function dU(){if(uU)return Gw;uU=1;var n=Ii(),e=di();return Gw=function(t,r){return e(n[t].prototype[r])},Gw}var Vw,fU;function zse(){if(fU)return Vw;fU=1,$se();var n=dU();return Vw=n("Array","at"),Vw}var Ww,hU;function qse(){if(hU)return Ww;hU=1;var n=zse();return Ww=n,Ww}var Kw,pU;function Hse(){if(pU)return Kw;pU=1;var n=qse();return Kw=n,Kw}Hse();var mU={},Yw,gU;function Gse(){if(gU)return Yw;gU=1;var n=Dm(),e=di();return Yw=function(t){if(n(t)==="Function")return e(t)},Yw}var Xw,_U;function Vse(){if(_U)return Xw;_U=1;var n=Gse(),e=r2(),t=TE(),r=n(n.bind);return Xw=function(s,i){return e(s),i===void 0?s:t?r(s,i):function(){return s.apply(i,arguments)}},Xw}var Qw,vU;function Wse(){if(vU)return Qw;vU=1;var n=Dm();return Qw=Array.isArray||function(t){return n(t)==="Array"},Qw}var Jw,yU;function Kse(){if(yU)return Jw;yU=1;var n=Pf(),e=n("toStringTag"),t={};return t[e]="z",Jw=String(t)==="[object z]",Jw}var Zw,bU;function Yse(){if(bU)return Zw;bU=1;var n=Kse(),e=Ri(),t=Dm(),r=Pf(),s=r("toStringTag"),i=Object,o=t(function(){return arguments}())==="Arguments",a=function(l,c){try{return l[c]}catch{}};return Zw=n?t:function(l){var c,d,f;return l===void 0?"Undefined":l===null?"Null":typeof(d=a(c=i(l),s))=="string"?d:o?t(c):(f=t(c))==="Object"&&e(c.callee)?"Arguments":f},Zw}var eT,xU;function Xse(){if(xU)return eT;xU=1;var n=di(),e=sa(),t=Ri(),r=Yse(),s=Fm(),i=N2(),o=function(){},a=s("Reflect","construct"),l=/^\s*(?:class|function)\b/,c=n(l.exec),d=!l.test(o),f=function(g){if(!t(g))return!1;try{return a(o,[],g),!0}catch{return!1}},p=function(g){if(!t(g))return!1;switch(r(g)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return d||!!c(l,i(g))}catch{return!0}};return p.sham=!0,eT=!a||e(function(){var m;return f(f.call)||!f(Object)||!f(function(){m=!0})||m})?p:f,eT}var tT,SU;function Qse(){if(SU)return tT;SU=1;var n=Wse(),e=Xse(),t=uu(),r=Pf(),s=r("species"),i=Array;return tT=function(o){var a;return n(o)&&(a=o.constructor,e(a)&&(a===i||n(a.prototype))?a=void 0:t(a)&&(a=a[s],a===null&&(a=void 0))),a===void 0?i:a},tT}var nT,EU;function Jse(){if(EU)return nT;EU=1;var n=Qse();return nT=function(e,t){return new(n(e))(t===0?0:t)},nT}var rT,wU;function Zse(){if(wU)return rT;wU=1;var n=Vse(),e=di(),t=jF(),r=nw(),s=kw(),i=Jse(),o=e([].push),a=function(l){var c=l===1,d=l===2,f=l===3,p=l===4,m=l===6,g=l===7,v=l===5||m;return function(y,b,S,E){for(var C=r(y),R=t(C),I=s(R),A=n(b,S),k=0,N=E||i,D=c?N(y,I):d||g?N(y,0):void 0,M,F;I>k;k++)if((v||k in R)&&(M=R[k],F=A(M,k,C),l))if(c)D[k]=F;else if(F)switch(l){case 3:return!0;case 5:return M;case 6:return k;case 2:o(D,M)}else switch(l){case 4:return!1;case 7:o(D,M)}return m?-1:f||p?p:D}};return rT={forEach:a(0),map:a(1),filter:a(2),some:a(3),every:a(4),find:a(5),findIndex:a(6),filterReject:a(7)},rT}var TU;function eie(){if(TU)return mU;TU=1;var n=nU(),e=Zse().findIndex,t=lU(),r="findIndex",s=!0;return r in[]&&Array(1)[r](function(){s=!1}),n({target:"Array",proto:!0,forced:s},{findIndex:function(o){return e(this,o,arguments.length>1?arguments[1]:void 0)}}),t(r),mU}var sT,CU;function tie(){if(CU)return sT;CU=1,eie();var n=dU();return sT=n("Array","findIndex"),sT}var iT,IU;function nie(){if(IU)return iT;IU=1;var n=tie();return iT=n,iT}var oT,RU;function rie(){if(RU)return oT;RU=1;var n=nie();return oT=n,oT}rie(),function(){if(typeof window>"u"||typeof t<"u")return;var n=window,e=[];function t(r){var s=this;r=String(r);var i="$BroadcastChannel$"+r+"$";e[i]=e[i]||[],e[i].push(this),this._name=r,this._id=i,this._closed=!1,this._mc=new MessageChannel,this._mc.port1.start(),this._mc.port2.start(),n.addEventListener("storage",function(o){if(o.storageArea===(n==null?void 0:n.localStorage)&&o.newValue!==null&&o.key.substring(0,i.length)===i){var a=JSON.parse(o.newValue);s._mc.port2.postMessage(a)}})}t.prototype={get name(){return this._name},postMessage:function(r){var l,c;var s=this;if(this._closed){var i=new Error;throw i.name="InvalidStateError",i}var o=JSON.stringify(r),a=this._id+String(Date.now())+"$"+String(Math.random());(c=(l=n==null?void 0:n.localStorage)==null?void 0:l.setItem)==null||c.call(l,a,o),setTimeout(function(){var d,f;(f=(d=n==null?void 0:n.localStorage)==null?void 0:d.removeItem)==null||f.call(d,a)},500),e[this._id].forEach(function(d){d!==s&&d._mc.port2.postMessage(JSON.parse(o))})},close:function(){if(!this._closed){this._closed=!0,this._mc.port1.close(),this._mc.port2.close();var r=e[this._id].indexOf(this);e[this._id].splice(r,1)}},get onmessage(){return this._mc.port1.onmessage},set onmessage(r){this._mc.port1.onmessage=r},addEventListener:function(r,s){return this._mc.port1.addEventListener.apply(this._mc.port1,arguments)},removeEventListener:function(r,s){return this._mc.port1.removeEventListener.apply(this._mc.port1,arguments)},dispatchEvent:function(r){return this._mc.port1.dispatchEvent.apply(this._mc.port1,arguments)}},n.BroadcastChannel=n.BroadcastChannel||t}();function sie({children:n}){const[e,t]=T.useState(!1);return T.useEffect(()=>t(!0),[]),e&&n}const Wa={"contact-list-item-container":"_contact-list-item-container_kz2yq_6","contact-list-item":"_contact-list-item_kz2yq_6","contact-list-item__top":"_contact-list-item__top_kz2yq_54","contact-list-item__top__saved-message__avatar":"_contact-list-item__top__saved-message__avatar_kz2yq_59","contact-list-item__top-avatar":"_contact-list-item__top-avatar_kz2yq_68","contact-list-item__top-sender":"_contact-list-item__top-sender_kz2yq_71","contact-list-item__top-sender-name":"_contact-list-item__top-sender-name_kz2yq_87","contact-list-item__top-sender-vendor":"_contact-list-item__top-sender-vendor_kz2yq_127"};function iie({chat:n,contact:e,onClick:t}){var f,p,m;const r=T.useRef(),s=!At().isPc,[i,o]=T.useState(!1),{currentUser:a}=Lt(["currentUser"]),l=((f=e==null?void 0:e.avatar)==null?void 0:f.extraSmall)&&!i,c=e&&a&&e.id===a.id,d=T.useMemo(()=>ad(e==null?void 0:e.lastActivity),[e==null?void 0:e.lastActivity]);return _.jsx("div",{ref:r,className:Wa["contact-list-item-container"],children:_.jsx("div",{className:Wa["contact-list-item"],onClick:()=>t==null?void 0:t(n),children:_.jsxs("div",{className:Wa["contact-list-item__top"],children:[c?_.jsx("div",{className:Wa["contact-list-item__top__saved-message__avatar"],children:_.jsx(Mn,{name:"bi-saved-message-fill",color:"white"})}):_.jsxs("div",{className:Wa["contact-list-item__top-avatar"],children:[_.jsx(zs,{src:(p=e==null?void 0:e.avatar)==null?void 0:p.extraSmall,size:s?"40":"44",status:l?"offline":d,onLoad:()=>o(!0)}),_.jsx(uS,{show:l,radius:"50%"})]}),_.jsxs("div",{className:Wa["contact-list-item__top-sender"],children:[_.jsxs("div",{className:Wa["contact-list-item__top-sender-name"],children:[_.jsx("span",{children:c?"پیام های ذخیره شده":e==null?void 0:e.name}),!!(e!=null&&e.badge)&&!c&&_.jsx(Xo,{label:e==null?void 0:e.badge,size:"sm",color:"black"})]}),!!(e!=null&&e.vendor)&&!c&&_.jsxs("span",{className:Wa["contact-list-item__top-sender-vendor"],children:[_.jsx("i",{className:"bi-vendor"}),(m=e.vendor)==null?void 0:m.title]})]})]})})})}const nc={"contact-list-item-checkbox-wrapper":"_contact-list-item-checkbox-wrapper_q0inf_6","contact-list":"_contact-list_q0inf_6","contact-list__header":"_contact-list__header_q0inf_39","contact-list__header-search":"_contact-list__header-search_q0inf_46","contact-list__header-filter":"_contact-list__header-filter_q0inf_49","contact-list__items":"_contact-list__items_q0inf_52","contact-list__items--full-height":"_contact-list__items--full-height_q0inf_83"};function oie({className:n,multiSelect:e}){var b,S;const t=T.useRef(),{isLoggedIn:r,featureFlags:s}=Lt(["isLoggedIn","featureFlags"]),{search:i,applyFilter:o,isSearching:a,isFiltering:l,chats:c,getNextChats:d}=xS({limit:30,autoUpdate:!1,filterChannels:!0}),[f,p]=[(b=s==null?void 0:s.features)==null?void 0:b.searchChatList,(S=s==null?void 0:s.features)==null?void 0:S.unseenChatListFilter],m=(f||p)&&r,g=T.useCallback((E,C)=>{const R={chat:C,contact:C.contact};return _.jsx(Wi,{value:C.contact.id,className:nc["contact-list-item-checkbox-wrapper"],children:_.jsx(iie,{...R})})},[]),v=()=>{t.current.updateFilter(null),setTimeout(()=>{o(null)},0)},y=c.length>0;return _.jsxs("div",{id:"contact-list",className:Te(nc["contact-list"],n),children:[m&&_.jsxs("header",{className:nc["contact-list__header"],children:[f&&_.jsx(wj,{disabled:l,className:nc["contact-list__header-search"],onSearch:i}),p&&_.jsx(Ej,{ref:t,disabled:a,className:nc["contact-list__header-filter"],onChange:o})]}),y?_.jsx(Wi.Group,{onChange:e.onChange,value:e.selected,children:_.jsx(Zd,{className:Te(nc["contact-list__items"],{[nc["contact-list__items--full-height"]]:!m}),data:c,endReached:d,itemContent:(E,C)=>g(E,C)})}):!a&&!l?_.jsx(Zp,{}):a?_.jsx(SS,{searchType:"CONTACTS"}):_.jsx(ES,{onFilterClear:v})]})}const aie=T.memo(oie),rc={"direct-modal":"_direct-modal_14vx4_6","direct-modal__list":"_direct-modal__list_14vx4_22","direct-modal__caption":"_direct-modal__caption_14vx4_33","direct-modal__caption-input":"_direct-modal__caption-input_14vx4_41","direct-modal__footer":"_direct-modal__footer_14vx4_44","direct-modal__footer-button":"_direct-modal__footer-button_14vx4_51","direct-modal-body":"_direct-modal-body_14vx4_60"};function lie(){const[n,e]=T.useState(""),{showSuccessSnackbar:t}=Mt.useSnackbar(),{closeDirectModal:r,openDirectModal:s}=$i(),{directModalData:i}=Lt(["directModalData"]),{mutateAsync:o}=DY(),a=T.useRef(),[l,c]=T.useState([]),d=!!(l!=null&&l.length),f=S=>{setTimeout(()=>{c(S)},0)};T.useEffect(()=>{const S=new URLSearchParams(window.location.search),E=S.get("multiSelect"),C=S.get("messageType"),R=S.get("entityId"),I=S.get("payloadText");E==="true"&&s({messageType:C,messagePayload:{entityId:R,text:I}})},[]);const p=T.useCallback(async()=>{const S=(i==null?void 0:i.messageType)===Fe.TEXT;try{r();const E=a.current,{entityId:C,text:R}=i.messagePayload||{},I={text:[R,E].filter(Boolean).join(`\r
360 \r
361 `)||void 0};!S&&C&&(I.entityId=C),await o({message:I,receivers:l,messageType:i.messageType}),t("با موفقیت ارسال شد!"),e(""),a.current=""}catch(E){no(E)}},[l]),m=S=>{e(S.target.value),a.current=S.target.value},g=()=>{e("")},v=()=>{c([])},y=()=>{v(),g(),r()},b=_.jsxs("div",{className:rc["direct-modal__footer"],children:[d&&_.jsx("div",{className:rc["direct-modal__caption"],children:_.jsx(Nd,{value:n,wrapperClassName:rc["direct-modal__caption-input"],placeholder:"توضیحات",onChange:m})}),_.jsx(Qe,{className:rc["direct-modal__footer-button"],color:"primary",label:"ارسال",icon:"bi bi-send-right",disabled:!d,onClick:p})]});return _.jsx(lr,{size:"sm",showClose:!0,show:!!i,footerComponent:b,title:"ارسال در گفت‌وگو",bodyClass:rc["direct-modal-body"],onClose:y,className:"dataset-inp-ChatDirectModal",children:_.jsx("div",{className:rc["direct-modal"],children:_.jsx(aie,{className:rc["direct-modal__list"],multiSelect:{selected:l,onChange:f}})})})}const aT={features:{chat:!0,forward:!0,websocket:!0,attachFile:!0,deleteChat:!0,attachMedia:!0,sendMessage:!0,selectMessage:25,editMessage:!0,savedMessage:!0,attachReview:!0,blockContact:!0,attachProduct:!0,deleteMessage:!0,searchChatList:!0,restoreArchive:!1,requestArchive:!1,canResizeChatList:!0,attachSatisfaction:!0,chatListMoreOptions:!0,unseenChatListFilter:!0,toastExcludedRoutes:["/chat"],botsList:[{contact:{badge:null,vendor:null,verified:!1,description:null,id:1223372036731,hashId:"product_desc_bot",name:"توضیح ساز هوشمند برای محصولات باسلامی",avatar:"https://statics.basalam.com/public-133/admin/ylMQL/09-27/xoPOMLEWogrlUTrwiz2vSZL0fJebILN0Vx22u4xMQ3GTXLcHz0.png"}}]},hintBox:{show:!0,showReportButton:!0,text:`هشدار!
362 لطفا به هیچ وجه اطلاعات خصوصی مثل اطلاعات هویتی، کد اعتبارسنجی، رمز، اطلاعات حساب و سایر اطلاعات محرمانه‌ت رو توی چت برای کسی ارسال نکن، حتی برای اعضای تیم باسلام!
363 پرداخت پول سفارش در باسلام فقط از طریق سبد خرید و درگاه بانک انجام می‌شه. در صورت پرداخت بیرون از باسلام (مثلا کارت به کارت و...) پشتیبانی باسلام، تضمین رضایت و بازگشت پولت رو از دست می‌دی.
364 اگر توی چت، رفتار نامناسب یا مشکوکی از کسی دیدی، حتما گزارش کن.`},newHintBox:[{text:"طبق فقط سفارش‌هایی پشتیبانی دارند که از سبد خرید و  درگاه پرداخت باسلام ثبت بشن.",metadatas:[{size:"sm",position:2,component:"a",type:"button",text:"قوانین",target:"_blank",underlined:!0,variant:"text-link",href:"/about/messaging-terms"}]},{text:"لطفا به هیچ وجه، اطلاعات خصوصی و بانکیت رو اینجا برای کسی ارسال نکن. باسلام هیچوقت از طریق گفت‌وگو درخواست اطلاعات نمی‌کنه."},{text:"اگر تخلفی در چت دیدی، گزارش کن."}],cantReceiveMessage:[2587468,869029,718323,68565,814019,759404,225310,3989321,3055810,463105,2479521,3009063,5111597,2564801],cache:{version:3,enabled:!1},secureCallActiveVendors:[222934,266,907326,176716,194860,18895,209096,419590,350306,969214,68244,643346,158865,42734,1139177,1006152,494949,270678,23402,105204,79835,220743,134519,727256,949450,190006,518467,537129,1030094,55899,206209,568073,611769,514815,702,382947,807804,314592,815094,1023525,794812,544083,248488,441392,736211,46826,922558,735112,730261,473828,944153,221800,498011,285435,850513,703715,329745,126503,747707,996156,634027,53388,478692,522246,552229,792392,102129,433888,708460,323069,174536],notificationTabs:{enabled:!0,showReadAll:!0,showSettings:!1,tabs:[{title:"همه",visiblity:"all",identifier:"all",visibility:"all"},{visiblity:"vendor",title:"مدیریت غرفه",visibility:"vendor",identifier:"vendor_management"},{visiblity:"all",visibility:"all",title:"اطلاعیه‌ها",identifier:"notice"},{title:"خرید‌ها",visiblity:"all",visibility:"all",identifier:"purchase"},{visiblity:"all",visibility:"all",identifier:"social",title:"شبکه اجتماعی"}]},ces:{cache:90,enabled:!0},allowNotLogin:!0,allowedLinks:["https://basalam.com"]},ia={"new-message-toast":"_new-message-toast_n481e_6","new-message-toast__content":"_new-message-toast__content_n481e_17","new-message-toast__content-inner":"_new-message-toast__content-inner_n481e_22","new-message-toast__avatar-container":"_new-message-toast__avatar-container_n481e_26","new-message-toast__text-container":"_new-message-toast__text-container_n481e_30","new-message-toast__name":"_new-message-toast__name_n481e_34","new-message-toast__message":"_new-message-toast__message_n481e_39","new-message-toast__button-container":"_new-message-toast__button-container_n481e_44","new-message-toast__close-button":"_new-message-toast__close-button_n481e_49"};function cie({t:n,contactName:e,contactAvatar:t,lastMessage:r,onClick:s}){const i=Ul(r),{hideSnackbar:o}=Mt.useSnackbar(),a=l=>{l.stopPropagation(),o(n.id)};return _.jsxs("div",{className:ia["new-message-toast"],style:{opacity:n.visible?1:0,transition:"all 0.3s ease",transform:`translateY(${n.visible?0:-100}%)`},onClick:s,children:[_.jsx("div",{className:ia["new-message-toast__content"],children:_.jsxs("div",{className:ia["new-message-toast__content-inner"],children:[_.jsx("div",{className:ia["new-message-toast__avatar-container"],children:_.jsx(zs,{size:"40",src:t,alt:""})}),_.jsxs("div",{className:ia["new-message-toast__text-container"],children:[_.jsx("p",{className:ia["new-message-toast__name"],children:e}),_.jsx("p",{className:ia["new-message-toast__message"],children:i})]})]})}),_.jsx("div",{className:ia["new-message-toast__button-container"],onClick:a,children:_.jsx(Mn,{size:"24",className:ia["new-message-toast__close-button"],icon:"bi-close"})})]})}function uie({children:n}){const e=Nl(),{setIsLoggedIn:t,setCurrentUser:r,setFeatureFlags:s,setSocketMessages:i,setSocketConnected:o,setUnseenMessages:a,setChatSocketMessages:l}=$i(),{target:c,options:d,isLoggedIn:f,user:p}=Lt(["user","target","options","isLoggedIn"]),{emitEvent:m}=Mt.useEmitter(),{updateUnseenMessageCount:g}=ff(),{data:v}=nee({initialData:aT,enabled:!!(d!=null&&d.featureFlagFetch),placeholderData:aT}),{messages:y,warningMessages:b,isConnected:S,addEventListener:E}=vne(),C=T.useCallback(I=>{e.resetQueries({queryKey:["factor",I]})},[e]);T.useEffect(()=>typeof window>"u"?void 0:(window.__dalan=window.__dalan||{},window.__dalan.resetFactor=C,()=>{window.__dalan.resetFactor===C&&(window.__dalan.resetFactor=void 0)}),[C]),T.useEffect(()=>{l(b)},[b]),T.useEffect(()=>{o(S)},[S]),T.useEffect(()=>{i(y)},[y]),T.useEffect(()=>{v&&s(v)},[v]),T.useEffect(()=>{t(f)},[f]),T.useEffect(()=>{const I=E({event:"setUnseenMessages",callback:({data:A})=>{a(k=>"notification"in A?A:{...k,chat:A.chat})}});return()=>{I()}},[E,a]),LY({enabled:!!f,refetchInterval:18e4,onSuccess:I=>{a(A=>({...A,chat:I.unseenMessageCount})),m(Ct.BROADCAST_TO_ALL,{customType:"setUnseenMessages",data:{chat:I.unseenMessageCount}})}}),ZP({enabled:!!f,onSuccess:I=>{g(I),a(A=>({...A,notification:I.count}))}});const{data:R}=DQ({enabled:!!(f&&(d!=null&&d.currentUserFetch)),onError:I=>{var A;((A=I==null?void 0:I.response)==null?void 0:A.status)===403&&c==="staging"&&(de.isProduction()?window.location=VP():window.location.pathname!=="/login"&&(window.location="/login"))}});return T.useEffect(()=>{d!=null&&d.currentUserFetch?r(R):r(p)},[d==null?void 0:d.currentUserFetch,R,p]),n}function die({user:n,target:e,children:t,injection:r,isLoggedIn:s,featureFlags:i,pagesBasePath:o="/chat",options:a={currentUserFetch:!0,featureFlagFetch:!0,toastOptions:{enabled:!0,replace:!0,duration:4e3,position:"top-right",onOpen:({identifier:l})=>{window.location.href=`/chat/${l}`}}}}){const{setDefaultValue:l}=$i(),{subEvent:c}=Mt.useEmitter(),{showCustomSnackbar:d,hideSnackbar:f}=Mt.useSnackbar(),p=T.useMemo(()=>new PW({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,refetchOnMount:!1}}}),[]);T.useEffect(()=>{l({user:n,target:e,options:a,injection:r,isLoggedIn:s,pagesBasePath:o,toastOptions:a.toastOptions||{},featureFlags:i||aT})},[n,e,a,r,s,o,i,a.toastOptions]);const m=T.useCallback(({chatData:g,t:v})=>{var y,b,S;return _.jsx(cie,{t:v,contactName:(y=g.contact)==null?void 0:y.name,contactAvatar:(S=(b=g.contact)==null?void 0:b.avatar)==null?void 0:S.small,lastMessage:g.lastMessage,onClick:()=>{var E,C;(E=a.toastOptions)!=null&&E.onOpen&&a.toastOptions.onOpen({t:v,identifier:(C=g.contact)==null?void 0:C.identifier}),f(v.id)}})},[a.toastOptions,o]);return T.useEffect(()=>{c(Ct.NEW_MESSAGE_TOAST,g=>{var v,y,b;(v=a.toastOptions)!=null&&v.replace&&f(),d(S=>m({chatData:g,t:S}),{position:(y=a.toastOptions)==null?void 0:y.position,duration:(b=a.toastOptions)==null?void 0:b.duration})})},[m,c]),_.jsx(tx,{children:_.jsxs(BW,{client:p,children:[_.jsx(uie,{}),t,_.jsx(sie,{children:_.jsx(lie,{})})]})})}const fie=function(){return null};function hie(){const n=At(),[e,t]=T.useState(!0),[r,s]=T.useState(!1),i=Dr(),o=async()=>{try{(await Bne()).id&&s(!0)}catch(a){console.error(a)}finally{t(!1)}};return T.useEffect(()=>{o()},[]),e?_.jsx(je,{display:"flex",justifyContent:"center",style:{height:"100vh",width:i?"100%":"100vw"},children:_.jsx(Cr,{variant:"ellipsis"})}):_.jsxs(die,{isLoggedIn:r,target:"staging",children:[_.jsx(use,{router:hse}),_.jsx(Ab,{position:n.isPc?"top-right":"top-center"}),_.jsx(fie,{initialIsOpen:!1})]})}var Bm={},AU;function pie(){if(AU)return Bm;AU=1;var n=LL();return Bm.createRoot=n.createRoot,Bm.hydrateRoot=n.hydrateRoot,Bm}var mie=pie();const gie=ba(mie);let jf=null;const _ie=["#dalan-chat-root","#dalan-chat-button",".bs-modal",".bs-backdrop",".bs-popover",'[role="dialog"]','[role="menu"]','[role="listbox"]',".options-modal",".options-popover"];function kU(n){if(!document.querySelector("#dalan-chat-root"))return;const t=n.target;_ie.some(s=>t.closest(s))||lT()}function lT(){const n=document.querySelector("#dalan-chat-root");n&&(jf&&(jf.unmount(),jf=null),document.removeEventListener("mousedown",kU),n.remove())}function LU(){if(document.querySelector("#dalan-chat-root"))return;const n=document.createElement("div");n.id="dalan-chat-root";const e=Dr();e&&e.token&&xa.set(Ix,e.token);const t=(e==null?void 0:e.clickOutsideClose)===!0||(e==null?void 0:e.clickOutsideClose)==="true",r={zIndex:9999,right:"20px",bottom:"80px",width:"500px",height:"700px",position:"fixed",background:"#fff",borderRadius:"12px",boxShadow:"0 0 20px rgba(0,0,0,0.3)"};Object.assign(n.style,r,e==null?void 0:e.widgetStyle),document.body.append(n),jf=gie.createRoot(n),jf.render(_.jsx(hie,{})),t&&document.addEventListener("mousedown",kU)}window.mountChatWidget=LU,window.unmountChatWidget=lT;function vie(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var MU={exports:{}};(function(n,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(l,c,d){if(d=d||{},l=l.trim(),c=c.trim(),!c){if(!d.alwaysNormalize)return l;var f=a.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");return f.path=a.normalizePath(f.path),a.buildURLFromParts(f)}var p=a.parseURL(c);if(!p)throw new Error("Error trying to parse relative URL.");if(p.scheme)return d.alwaysNormalize?(p.path=a.normalizePath(p.path),a.buildURLFromParts(p)):c;var m=a.parseURL(l);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var g=s.exec(m.path);m.netLoc=g[1],m.path=g[2]}m.netLoc&&!m.path&&(m.path="/");var v={scheme:m.scheme,netLoc:p.netLoc,path:null,params:p.params,query:p.query,fragment:p.fragment};if(!p.netLoc&&(v.netLoc=m.netLoc,p.path[0]!=="/"))if(!p.path)v.path=m.path,p.params||(v.params=m.params,p.query||(v.query=m.query));else{var y=m.path,b=y.substring(0,y.lastIndexOf("/")+1)+p.path;v.path=a.normalizePath(b)}return v.path===null&&(v.path=d.alwaysNormalize?a.normalizePath(p.path):p.path),a.buildURLFromParts(v)},parseURL:function(l){var c=r.exec(l);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(i,"");l.length!==(l=l.replace(o,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};n.exports=a})()})(MU);var cT=MU.exports;function NU(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,r)}return t}function Xr(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?NU(Object(t),!0).forEach(function(r){xie(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):NU(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function yie(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function bie(n){var e=yie(n,"string");return typeof e=="symbol"?e:String(e)}function xie(n,e,t){return e=bie(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Or(){return Or=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Or.apply(this,arguments)}const bt=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},Sie=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=Eie},Eie=Number.MAX_SAFE_INTEGER||9007199254740991;let Y=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n}({}),Gt=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),Ce=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.UNKNOWN="unknown",n}({});const sc=function(){},uT={trace:sc,debug:sc,log:sc,warn:sc,info:sc,error:sc};let Ff=uT;function wie(n){const e=self.console[n];return e?e.bind(self.console,`[${n}] >`):sc}function Tie(n,...e){e.forEach(function(t){Ff[t]=n[t]?n[t].bind(n):wie(t)})}function Cie(n,e){if(typeof console=="object"&&n===!0||typeof n=="object"){Tie(n,"debug","log","info","warn","error");try{Ff.log(`Debug logs enabled for "${e}" in hls.js version 1.5.4`)}catch{Ff=uT}}else Ff=uT}const he=Ff,Iie=/^(\d+)x(\d+)$/,OU=/(.+?)=(".*?"|.*?)(?:,|$)/g;class cr{constructor(e){typeof e=="string"&&(e=cr.parseAttrList(e)),Or(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=Iie.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const r={},s='"';for(OU.lastIndex=0;(t=OU.exec(e))!==null;){let i=t[2];i.indexOf(s)===0&&i.lastIndexOf(s)===i.length-1&&(i=i.slice(1,-1));const o=t[1].trim();r[o]=i}return r}}function Rie(n){return n!=="ID"&&n!=="CLASS"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function Aie(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"}class dT{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const r=t.attr;for(const s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){he.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=Or(new cr({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=new Date(this.attr["END-DATE"]);bt(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(bt(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&bt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Uf{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var Dn={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class fT{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Dn.AUDIO]:null,[Dn.VIDEO]:null,[Dn.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const r=e.split("@",2);let s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=cT.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class $m extends fT{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Uf,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!bt(this.programDateTime))return null;const e=bt(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,i,o=!1){const{elementaryStreams:a}=this,l=a[e];if(!l){a[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:i,partial:o};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,i)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Dn.AUDIO]=null,e[Dn.VIDEO]=null,e[Dn.AUDIOVIDEO]=null}}class PU extends fT{constructor(e,t,r,s,i){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Uf,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const o=e.enumeratedString("BYTERANGE");o&&this.setByteRange(o,i),i&&(this.fragOffset=i.fragOffset+i.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}const kie=10;class DU{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?bt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||kie}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function hT(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0))}function Lie(n){const e=pT(n).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Mie(n){const e=function(r,s,i){const o=r[s];r[s]=r[i],r[i]=o};e(n,0,3),e(n,1,2),e(n,4,5),e(n,6,7)}function Nie(n){const e=n.split(":");let t=null;if(e[0]==="data"&&e.length===2){const r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){const i=s[0]==="base64",o=s[1];i?(r.splice(-1,1),t=hT(o)):t=Lie(o)}}return t}function pT(n){return Uint8Array.from(unescape(encodeURIComponent(n)),e=>e.charCodeAt(0))}const du=typeof self<"u"?self:void 0;var rr={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},js={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function jU(n){switch(n){case js.FAIRPLAY:return rr.FAIRPLAY;case js.PLAYREADY:return rr.PLAYREADY;case js.WIDEVINE:return rr.WIDEVINE;case js.CLEARKEY:return rr.CLEARKEY}}var FU={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Oie(n){if(n===FU.WIDEVINE)return rr.WIDEVINE}function UU(n){switch(n){case rr.FAIRPLAY:return js.FAIRPLAY;case rr.PLAYREADY:return js.PLAYREADY;case rr.WIDEVINE:return js.WIDEVINE;case rr.CLEARKEY:return js.CLEARKEY}}function mT(n){const{drmSystems:e,widevineLicenseUrl:t}=n,r=e?[rr.FAIRPLAY,rr.WIDEVINE,rr.PLAYREADY,rr.CLEARKEY].filter(s=>!!e[s]):[];return!r[rr.WIDEVINE]&&t&&r.push(rr.WIDEVINE),r}const BU=function(n){return du!=null&&(n=du.navigator)!=null&&n.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Pie(n,e,t,r){let s;switch(n){case rr.FAIRPLAY:s=["cenc","sinf"];break;case rr.WIDEVINE:case rr.PLAYREADY:s=["cenc"];break;case rr.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return Die(s,e,t,r)}function Die(n,e,t,r){return[{initDataTypes:n,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(i=>({contentType:`audio/mp4; codecs="${i}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(i=>({contentType:`video/mp4; codecs="${i}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function ic(n,e,t){return Uint8Array.prototype.slice?n.slice(e,t):new Uint8Array(Array.prototype.slice.call(n,e,t))}const gT=(n,e)=>e+10<=n.length&&n[e]===73&&n[e+1]===68&&n[e+2]===51&&n[e+3]<255&&n[e+4]<255&&n[e+6]<128&&n[e+7]<128&&n[e+8]<128&&n[e+9]<128,$U=(n,e)=>e+10<=n.length&&n[e]===51&&n[e+1]===68&&n[e+2]===73&&n[e+3]<255&&n[e+4]<255&&n[e+6]<128&&n[e+7]<128&&n[e+8]<128&&n[e+9]<128,Bf=(n,e)=>{const t=e;let r=0;for(;gT(n,e);){r+=10;const s=zm(n,e+6);r+=s,$U(n,e+10)&&(r+=10),e+=r}if(r>0)return n.subarray(t,t+r)},zm=(n,e)=>{let t=0;return t=(n[e]&127)<<21,t|=(n[e+1]&127)<<14,t|=(n[e+2]&127)<<7,t|=n[e+3]&127,t},jie=(n,e)=>gT(n,e)&&zm(n,e+6)+10<=n.length-e,_T=n=>{const e=qU(n);for(let t=0;t<e.length;t++){const r=e[t];if(zU(r))return qie(r)}},zU=n=>n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp",Fie=n=>{const e=String.fromCharCode(n[0],n[1],n[2],n[3]),t=zm(n,4),r=10;return{type:e,size:t,data:n.subarray(r,r+t)}},qU=n=>{let e=0;const t=[];for(;gT(n,e);){const r=zm(n,e+6);e+=10;const s=e+r;for(;e+8<s;){const i=Fie(n.subarray(e)),o=Uie(i);o&&t.push(o),e+=i.size+10}$U(n,e)&&(e+=10)}return t},Uie=n=>n.type==="PRIV"?Bie(n):n.type[0]==="W"?zie(n):$ie(n),Bie=n=>{if(n.size<2)return;const e=Oo(n.data,!0),t=new Uint8Array(n.data.subarray(e.length+1));return{key:n.type,info:e,data:t.buffer}},$ie=n=>{if(n.size<2)return;if(n.type==="TXXX"){let t=1;const r=Oo(n.data.subarray(t),!0);t+=r.length+1;const s=Oo(n.data.subarray(t));return{key:n.type,info:r,data:s}}const e=Oo(n.data.subarray(1));return{key:n.type,data:e}},zie=n=>{if(n.type==="WXXX"){if(n.size<2)return;let t=1;const r=Oo(n.data.subarray(t),!0);t+=r.length+1;const s=Oo(n.data.subarray(t));return{key:n.type,info:r,data:s}}const e=Oo(n.data);return{key:n.type,data:e}},qie=n=>{if(n.data.byteLength===8){const e=new Uint8Array(n.data),t=e[3]&1;let r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Oo=(n,e=!1)=>{const t=Hie();if(t){const c=t.decode(n);if(e){const d=c.indexOf("\0");return d!==-1?c.substring(0,d):c}return c.replace(/\0/g,"")}const r=n.length;let s,i,o,a="",l=0;for(;l<r;){if(s=n[l++],s===0&&e)return a;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(s);break;case 12:case 13:i=n[l++],a+=String.fromCharCode((s&31)<<6|i&63);break;case 14:i=n[l++],o=n[l++],a+=String.fromCharCode((s&15)<<12|(i&63)<<6|(o&63)<<0);break}}return a};let vT;function Hie(){if(!navigator.userAgent.includes("PlayStation 4"))return!vT&&typeof self.TextDecoder<"u"&&(vT=new self.TextDecoder("utf-8")),vT}const Po={hexDump:function(n){let e="";for(let t=0;t<n.length;t++){let r=n[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},qm=Math.pow(2,32)-1,Gie=[].push,HU={video:1,audio:2,id3:3,text:4};function Br(n){return String.fromCharCode.apply(null,n)}function GU(n,e){const t=n[e]<<8|n[e+1];return t<0?65536+t:t}function $t(n,e){const t=WU(n,e);return t<0?4294967296+t:t}function VU(n,e){let t=$t(n,e);return t*=Math.pow(2,32),t+=$t(n,e+4),t}function WU(n,e){return n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3]}function yT(n,e,t){n[e]=t>>24,n[e+1]=t>>16&255,n[e+2]=t>>8&255,n[e+3]=t&255}function Vie(n){const e=n.byteLength;for(let t=0;t<e;){const r=$t(n,t);if(r>8&&n[t+4]===109&&n[t+5]===111&&n[t+6]===111&&n[t+7]===102)return!0;t=r>1?t+r:e}return!1}function on(n,e){const t=[];if(!e.length)return t;const r=n.byteLength;for(let s=0;s<r;){const i=$t(n,s),o=Br(n.subarray(s+4,s+8)),a=i>1?s+i:r;if(o===e[0])if(e.length===1)t.push(n.subarray(s+8,a));else{const l=on(n.subarray(s+8,a),e.slice(1));l.length&&Gie.apply(t,l)}s=a}return t}function Wie(n){const e=[],t=n[0];let r=8;const s=$t(n,r);r+=4;let i=0,o=0;t===0?(i=$t(n,r+=4),o=$t(n,r+=4)):(i=VU(n,r+=8),o=VU(n,r+=8)),r+=2;let a=n.length+o;const l=GU(n,r);r+=2;for(let c=0;c<l;c++){let d=r;const f=$t(n,d);d+=4;const p=f&2147483647;if((f&2147483648)>>>31===1)return he.warn("SIDX has hierarchical references (not supported)"),null;const g=$t(n,d);d+=4,e.push({referenceSize:p,subsegmentDuration:g,info:{duration:g/s,start:a,end:a+p-1}}),a+=p,d+=4,r=d}return{earliestPresentationTime:i,timescale:s,version:t,referencesCount:l,references:e}}function KU(n){const e=[],t=on(n,["moov","trak"]);for(let s=0;s<t.length;s++){const i=t[s],o=on(i,["tkhd"])[0];if(o){let a=o[0];const l=$t(o,a===0?12:20),c=on(i,["mdia","mdhd"])[0];if(c){a=c[0];const d=$t(c,a===0?12:20),f=on(i,["mdia","hdlr"])[0];if(f){const p=Br(f.subarray(8,12)),m={soun:Dn.AUDIO,vide:Dn.VIDEO}[p];if(m){const g=on(i,["mdia","minf","stbl","stsd"])[0],v=Kie(g);e[l]={timescale:d,type:m},e[m]=Xr({timescale:d,id:l},v)}}}}}return on(n,["moov","mvex","trex"]).forEach(s=>{const i=$t(s,4),o=e[i];o&&(o.default={duration:$t(s,12),flags:$t(s,20)})}),e}function Kie(n){const e=n.subarray(8),t=e.subarray(86),r=Br(e.subarray(4,8));let s=r;const i=r==="enca"||r==="encv";if(i){const a=on(e,[r])[0].subarray(r==="enca"?28:78);on(a,["sinf"]).forEach(c=>{const d=on(c,["schm"])[0];if(d){const f=Br(d.subarray(4,8));if(f==="cbcs"||f==="cenc"){const p=on(c,["frma"])[0];p&&(s=Br(p))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const o=on(t,["avcC"])[0];s+="."+Hm(o[1])+Hm(o[2])+Hm(o[3]);break}case"mp4a":{const o=on(e,[r])[0],a=on(o.subarray(28),["esds"])[0];if(a&&a.length>12){let l=4;if(a[l++]!==3)break;l=bT(a,l),l+=2;const c=a[l++];if(c&128&&(l+=2),c&64&&(l+=a[l++]),a[l++]!==4)break;l=bT(a,l);const d=a[l++];if(d===64)s+="."+Hm(d);else break;if(l+=12,a[l++]!==5)break;l=bT(a,l);const f=a[l++];let p=(f&248)>>3;p===31&&(p+=1+((f&7)<<3)+((a[l]&224)>>5)),s+="."+p}break}case"hvc1":case"hev1":{const o=on(t,["hvcC"])[0],a=o[1],l=["","A","B","C"][a>>6],c=a&31,d=$t(o,2),f=(a&32)>>5?"H":"L",p=o[12],m=o.subarray(6,12);s+="."+l+c,s+="."+d.toString(16).toUpperCase(),s+="."+f+p;let g="";for(let v=m.length;v--;){const y=m[v];(y||g)&&(g="."+y.toString(16).toUpperCase()+g)}s+=g;break}case"dvh1":case"dvhe":{const o=on(t,["dvcC"])[0],a=o[2]>>1&127,l=o[2]<<5&32|o[3]>>3&31;s+="."+Do(a)+"."+Do(l);break}case"vp09":{const o=on(t,["vpcC"])[0],a=o[4],l=o[5],c=o[6]>>4&15;s+="."+Do(a)+"."+Do(l)+"."+Do(c);break}case"av01":{const o=on(t,["av1C"])[0],a=o[1]>>>5,l=o[1]&31,c=o[2]>>>7?"H":"M",d=(o[2]&64)>>6,f=(o[2]&32)>>5,p=a===2&&d?f?12:10:d?10:8,m=(o[2]&16)>>4,g=(o[2]&8)>>3,v=(o[2]&4)>>2,y=o[2]&3;s+="."+a+"."+Do(l)+c+"."+Do(p)+"."+m+"."+g+v+y+"."+Do(1)+"."+Do(1)+"."+Do(1)+"."+0;break}}return{codec:s,encrypted:i}}function bT(n,e){const t=e+5;for(;n[e++]&128&&e<t;);return e}function Hm(n){return("0"+n.toString(16).toUpperCase()).slice(-2)}function Do(n){return(n<10?"0":"")+n}function Yie(n,e){if(!n||!e)return n;const t=e.keyId;return t&&e.isCommonEncryption&&on(n,["moov","trak"]).forEach(s=>{const o=on(s,["mdia","minf","stbl","stsd"])[0].subarray(8);let a=on(o,["enca"]);const l=a.length>0;l||(a=on(o,["encv"])),a.forEach(c=>{const d=l?c.subarray(28):c.subarray(78);on(d,["sinf"]).forEach(p=>{const m=YU(p);if(m){const g=m.subarray(8,24);g.some(v=>v!==0)||(he.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Po.hexDump(g)} -> ${Po.hexDump(t)}`),m.set(t,8))}})})}),n}function YU(n){const e=on(n,["schm"])[0];if(e){const t=Br(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return on(n,["schi","tenc"])[0]}return he.error("[eme] missing 'schm' box"),null}function Xie(n,e){return on(e,["moof","traf"]).reduce((t,r)=>{const s=on(r,["tfdt"])[0],i=s[0],o=on(r,["tfhd"]).reduce((a,l)=>{const c=$t(l,4),d=n[c];if(d){let f=$t(s,4);if(i===1){if(f===qm)return he.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),a;f*=qm+1,f+=$t(s,8)}const p=d.timescale||9e4,m=f/p;if(bt(m)&&(a===null||m<a))return m}return a},null);return o!==null&&bt(o)&&(t===null||o<t)?o:t},null)}function Qie(n,e){let t=0,r=0,s=0;const i=on(n,["moof","traf"]);for(let o=0;o<i.length;o++){const a=i[o],l=on(a,["tfhd"])[0],c=$t(l,4),d=e[c];if(!d)continue;const f=d.default,p=$t(l,0)|(f==null?void 0:f.flags);let m=f==null?void 0:f.duration;p&8&&(p&2?m=$t(l,12):m=$t(l,8));const g=d.timescale||9e4,v=on(a,["trun"]);for(let y=0;y<v.length;y++){if(t=Jie(v[y]),!t&&m){const b=$t(v[y],4);t=m*b}d.type===Dn.VIDEO?r+=t/g:d.type===Dn.AUDIO&&(s+=t/g)}}if(r===0&&s===0){let o=1/0,a=0,l=0;const c=on(n,["sidx"]);for(let d=0;d<c.length;d++){const f=Wie(c[d]);if(f!=null&&f.references){o=Math.min(o,f.earliestPresentationTime/f.timescale);const p=f.references.reduce((m,g)=>m+g.info.duration||0,0);a=Math.max(a,p+f.earliestPresentationTime/f.timescale),l=a-o}}if(l&&bt(l))return l}return r||s}function Jie(n){const e=$t(n,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0;const s=$t(n,4);for(let i=0;i<s;i++){if(e&256){const o=$t(n,t);r+=o,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function Zie(n,e,t){on(e,["moof","traf"]).forEach(r=>{on(r,["tfhd"]).forEach(s=>{const i=$t(s,4),o=n[i];if(!o)return;const a=o.timescale||9e4;on(r,["tfdt"]).forEach(l=>{const c=l[0],d=t*a;if(d){let f=$t(l,4);if(c===0)f-=d,f=Math.max(f,0),yT(l,4,f);else{f*=Math.pow(2,32),f+=$t(l,8),f-=d,f=Math.max(f,0);const p=Math.floor(f/(qm+1)),m=Math.floor(f%(qm+1));yT(l,4,p),yT(l,8,m)}}})})})}function eoe(n){const e={valid:null,remainder:null},t=on(n,["moof"]);if(t.length<2)return e.remainder=n,e;const r=t[t.length-1];return e.valid=ic(n,0,r.byteOffset-8),e.remainder=ic(n,r.byteOffset-8),e}function Ai(n,e){const t=new Uint8Array(n.length+e.length);return t.set(n),t.set(e,n.length),t}function XU(n,e){const t=[],r=e.samples,s=e.timescale,i=e.id;let o=!1;return on(r,["moof"]).map(l=>{const c=l.byteOffset-8;on(l,["traf"]).map(f=>{const p=on(f,["tfdt"]).map(m=>{const g=m[0];let v=$t(m,4);return g===1&&(v*=Math.pow(2,32),v+=$t(m,8)),v/s})[0];return p!==void 0&&(n=p),on(f,["tfhd"]).map(m=>{const g=$t(m,4),v=$t(m,0)&16777215,y=(v&1)!==0,b=(v&2)!==0,S=(v&8)!==0;let E=0;const C=(v&16)!==0;let R=0;const I=(v&32)!==0;let A=8;g===i&&(y&&(A+=8),b&&(A+=4),S&&(E=$t(m,A),A+=4),C&&(R=$t(m,A),A+=4),I&&(A+=4),e.type==="video"&&(o=toe(e.codec)),on(f,["trun"]).map(k=>{const N=k[0],D=$t(k,0)&16777215,M=(D&1)!==0;let F=0;const U=(D&4)!==0,$=(D&256)!==0;let q=0;const G=(D&512)!==0;let V=0;const z=(D&1024)!==0,B=(D&2048)!==0;let P=0;const H=$t(k,4);let Z=8;M&&(F=$t(k,Z),Z+=4),U&&(Z+=4);let Q=F+c;for(let J=0;J<H;J++){if($?(q=$t(k,Z),Z+=4):q=E,G?(V=$t(k,Z),Z+=4):V=R,z&&(Z+=4),B&&(N===0?P=$t(k,Z):P=WU(k,Z),Z+=4),e.type===Dn.VIDEO){let ee=0;for(;ee<V;){const K=$t(r,Q);if(Q+=4,noe(o,r[Q])){const W=r.subarray(Q,Q+K);QU(W,o?2:1,n+P/s,t)}Q+=K,ee+=K+4}}n+=q/s}}))})})}),t}function toe(n){if(!n)return!1;const e=n.indexOf("."),t=e<0?n:n.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function noe(n,e){if(n){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function QU(n,e,t,r){const s=JU(n);let i=0;i+=e;let o=0,a=0,l=0;for(;i<s.length;){o=0;do{if(i>=s.length)break;l=s[i++],o+=l}while(l===255);a=0;do{if(i>=s.length)break;l=s[i++],a+=l}while(l===255);const c=s.length-i;let d=i;if(a<c)i+=a;else if(a>c){he.error(`Malformed SEI payload. ${a} is too small, only ${c} bytes left to parse.`);break}if(o===4){if(s[d++]===181){const p=GU(s,d);if(d+=2,p===49){const m=$t(s,d);if(d+=4,m===1195456820){const g=s[d++];if(g===3){const v=s[d++],y=31&v,b=64&v,S=b?2+y*3:0,E=new Uint8Array(S);if(b){E[0]=v;for(let C=1;C<S;C++)E[C]=s[d++]}r.push({type:g,payloadType:o,pts:t,bytes:E})}}}}}else if(o===5&&a>16){const f=[];for(let g=0;g<16;g++){const v=s[d++].toString(16);f.push(v.length==1?"0"+v:v),(g===3||g===5||g===7||g===9)&&f.push("-")}const p=a-16,m=new Uint8Array(p);for(let g=0;g<p;g++)m[g]=s[d++];r.push({payloadType:o,pts:t,uuid:f.join(""),userData:Oo(m),userDataBytes:m})}}}function JU(n){const e=n.byteLength,t=[];let r=1;for(;r<e-2;)n[r]===0&&n[r+1]===0&&n[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return n;const s=e-t.length,i=new Uint8Array(s);let o=0;for(r=0;r<s;o++,r++)o===t[0]&&(o++,t.shift()),i[r]=n[o];return i}function roe(n){const e=n[0];let t="",r="",s=0,i=0,o=0,a=0,l=0,c=0;if(e===0){for(;Br(n.subarray(c,c+1))!=="\0";)t+=Br(n.subarray(c,c+1)),c+=1;for(t+=Br(n.subarray(c,c+1)),c+=1;Br(n.subarray(c,c+1))!=="\0";)r+=Br(n.subarray(c,c+1)),c+=1;r+=Br(n.subarray(c,c+1)),c+=1,s=$t(n,12),i=$t(n,16),a=$t(n,20),l=$t(n,24),c=28}else if(e===1){c+=4,s=$t(n,c),c+=4;const f=$t(n,c);c+=4;const p=$t(n,c);for(c+=4,o=4294967296*f+p,Sie(o)||(o=Number.MAX_SAFE_INTEGER,he.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),a=$t(n,c),c+=4,l=$t(n,c),c+=4;Br(n.subarray(c,c+1))!=="\0";)t+=Br(n.subarray(c,c+1)),c+=1;for(t+=Br(n.subarray(c,c+1)),c+=1;Br(n.subarray(c,c+1))!=="\0";)r+=Br(n.subarray(c,c+1)),c+=1;r+=Br(n.subarray(c,c+1)),c+=1}const d=n.subarray(c,n.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:o,presentationTimeDelta:i,eventDuration:a,id:l,payload:d}}function soe(n,...e){const t=e.length;let r=8,s=t;for(;s--;)r+=e[s].byteLength;const i=new Uint8Array(r);for(i[0]=r>>24&255,i[1]=r>>16&255,i[2]=r>>8&255,i[3]=r&255,i.set(n,4),s=0,r=8;s<t;s++)i.set(e[s],r),r+=e[s].byteLength;return i}function ioe(n,e,t){if(n.byteLength!==16)throw new RangeError("Invalid system id");let r,s;r=0,s=new Uint8Array;let i;r>0?(i=new Uint8Array(4),e.length>0&&new DataView(i.buffer).setUint32(0,e.length,!1)):i=new Uint8Array;const o=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(o.buffer).setUint32(0,t.byteLength,!1),soe([112,115,115,104],new Uint8Array([r,0,0,0]),n,i,s,o,t||new Uint8Array)}function ooe(n){if(!(n instanceof ArrayBuffer)||n.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},t=new DataView(n),r=t.getUint32(0);if(n.byteLength!==r&&r>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Po.hexDump(new Uint8Array(n,12,16));const i=t.getUint32(28);if(e.version===0){if(r-32<i)return null;e.data=new Uint8Array(n,32,i)}else if(e.version===1){e.kids=[];for(let o=0;o<i;o++)e.kids.push(new Uint8Array(n,32+o*16,16))}return e}let Gm={};class fu{static clearKeyUriToKeyIdMap(){Gm={}}constructor(e,t,r,s=[1],i=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=i,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case js.FAIRPLAY:case js.WIDEVINE:case js.PLAYREADY:case js.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&he.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const r=aoe(e);return new fu(this.method,this.uri,"identity",this.keyFormatVersions,r)}const t=Nie(this.uri);if(t)switch(this.keyFormat){case js.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case js.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ioe(r,null,t);const s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),i=String.fromCharCode.apply(null,Array.from(s)),o=i.substring(i.indexOf("<"),i.length),c=new DOMParser().parseFromString(o,"text/xml").getElementsByTagName("KID")[0];if(c){const d=c.childNodes[0]?c.childNodes[0].nodeValue:c.getAttribute("VALUE");if(d){const f=hT(d).subarray(0,16);Mie(f),this.keyId=f}}break}default:{let r=t.subarray(0,16);if(r.length!==16){const s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Gm[this.uri];if(!r){const s=Object.keys(Gm).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Gm[this.uri]=r}this.keyId=r}return this}}function aoe(n){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=n>>8*(15-t)&255;return e}const ZU=/\{\$([a-zA-Z0-9-_]+)\}/g;function eB(n){return ZU.test(n)}function Ys(n,e,t){if(n.variableList!==null||n.hasVariableRefs)for(let r=t.length;r--;){const s=t[r],i=e[s];i&&(e[s]=xT(n,i))}}function xT(n,e){if(n.variableList!==null||n.hasVariableRefs){const t=n.variableList;return e.replace(ZU,r=>{const s=r.substring(2,r.length-1),i=t==null?void 0:t[s];return i===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):i})}return e}function tB(n,e,t){let r=n.variableList;r||(n.variableList=r={});let s,i;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{const o=new self.URL(t).searchParams;if(o.has(s))i=o.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(o){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${o.message}`))}}else s=e.NAME,i=e.VALUE;s in r?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=i||""}function loe(n,e,t){const r=e.IMPORT;if(t&&r in t){let s=n.variableList;s||(n.variableList=s={}),s[r]=t[r]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function oc(n=!0){return typeof self>"u"?void 0:(n||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const Vm={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function coe(n,e){const t=Vm[e];return!!t&&!!t[n.slice(0,4)]}function ST(n,e,t=!0){return!n.split(",").some(r=>!nB(r,e,t))}function nB(n,e,t=!0){var r;const s=oc(t);return(r=s==null?void 0:s.isTypeSupported($f(n,e)))!=null?r:!1}function $f(n,e){return`${e}/mp4;codecs="${n}"`}function rB(n){if(n){const e=n.substring(0,4);return Vm.video[e]}return 2}function Wm(n){return n.split(",").reduce((e,t)=>{const r=Vm.video[t];return r?(r*2+e)/(e?3:2):(Vm.audio[t]+e)/(e?2:1)},0)}const ET={};function uoe(n,e=!0){if(ET[n])return ET[n];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[n];for(let r=0;r<t.length;r++)if(nB(t[r],"audio",e))return ET[n]=t[r],t[r];return n}const doe=/flac|opus/i;function Km(n,e=!0){return n.replace(doe,t=>uoe(t.toLowerCase(),e))}function sB(n,e){return n&&n!=="mp4a"?n:e}function foe(n){const e=n.split(".");if(e.length>2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return n}const iB=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,oB=/#EXT-X-MEDIA:(.*)/g,hoe=/^#EXT(?:INF|-X-TARGETDURATION):/m,aB=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),poe=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class jo{static findGroup(e,t){for(let r=0;r<e.length;r++){const s=e[r];if(s.id===t)return s}}static resolve(e,t){return cT.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return hoe.test(e)}static parseMasterPlaylist(e,t){const r=eB(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},i=[];iB.lastIndex=0;let o;for(;(o=iB.exec(e))!=null;)if(o[1]){var a;const c=new cr(o[1]);Ys(s,c,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const d=xT(s,o[2]),f={attrs:c,bitrate:c.decimalInteger("BANDWIDTH")||c.decimalInteger("AVERAGE-BANDWIDTH"),name:c.NAME,url:jo.resolve(d,t)},p=c.decimalResolution("RESOLUTION");p&&(f.width=p.width,f.height=p.height),moe(c.CODECS,f),(a=f.unknownCodecs)!=null&&a.length||i.push(f),s.levels.push(f)}else if(o[3]){const c=o[3],d=o[4];switch(c){case"SESSION-DATA":{const f=new cr(d);Ys(s,f,["DATA-ID","LANGUAGE","VALUE","URI"]);const p=f["DATA-ID"];p&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[p]=f);break}case"SESSION-KEY":{const f=lB(d,t,s);f.encrypted&&f.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(f)):he.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${d}"`);break}case"DEFINE":{{const f=new cr(d);Ys(s,f,["NAME","VALUE","QUERYPARAM"]),tB(s,f,t)}break}case"CONTENT-STEERING":{const f=new cr(d);Ys(s,f,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:jo.resolve(f["SERVER-URI"],t),pathwayId:f["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=cB(d);break}}}const l=i.length>0&&i.length<s.levels.length;return s.levels=l?i:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s;const i={},o=r.levels,a={AUDIO:o.map(c=>({id:c.attrs.AUDIO,audioCodec:c.audioCodec})),SUBTITLES:o.map(c=>({id:c.attrs.SUBTITLES,textCodec:c.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(oB.lastIndex=0;(s=oB.exec(e))!==null;){const c=new cr(s[1]),d=c.TYPE;if(d){const f=a[d],p=i[d]||[];i[d]=p,Ys(r,c,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const m=c.LANGUAGE,g=c["ASSOC-LANGUAGE"],v=c.CHANNELS,y=c.CHARACTERISTICS,b=c["INSTREAM-ID"],S={attrs:c,bitrate:0,id:l++,groupId:c["GROUP-ID"]||"",name:c.NAME||m||"",type:d,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:m,url:c.URI?jo.resolve(c.URI,t):""};if(g&&(S.assocLang=g),v&&(S.channels=v),y&&(S.characteristics=y),b&&(S.instreamId=b),f!=null&&f.length){const E=jo.findGroup(f,S.groupId)||f[0];uB(S,E,"audioCodec"),uB(S,E,"textCodec")}p.push(S)}}return i}static parseLevelPlaylist(e,t,r,s,i,o){const a=new DU(t),l=a.fragments;let c=null,d=0,f=0,p=0,m=0,g=null,v=new $m(s,t),y,b,S,E=-1,C=!1,R=null;for(aB.lastIndex=0,a.m3u8=e,a.hasVariableRefs=eB(e);(y=aB.exec(e))!==null;){C&&(C=!1,v=new $m(s,t),v.start=p,v.sn=d,v.cc=m,v.level=r,c&&(v.initSegment=c,v.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,R&&(v.setByteRange(R),R=null)));const N=y[1];if(N){v.duration=parseFloat(N);const D=(" "+y[2]).slice(1);v.title=D||null,v.tagList.push(D?["INF",N,D]:["INF",N])}else if(y[3]){if(bt(v.duration)){v.start=p,S&&hB(v,S,a),v.sn=d,v.level=r,v.cc=m,l.push(v);const D=(" "+y[3]).slice(1);v.relurl=xT(a,D),dB(v,g),g=v,p+=v.duration,d++,f=0,C=!0}}else if(y[4]){const D=(" "+y[4]).slice(1);g?v.setByteRange(D,g):v.setByteRange(D)}else if(y[5])v.rawProgramDateTime=(" "+y[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),E===-1&&(E=l.length);else{if(y=y[0].match(poe),!y){he.warn("No matches on slow regex match for level playlist!");continue}for(b=1;b<y.length&&!(typeof y[b]<"u");b++);const D=(" "+y[b]).slice(1),M=(" "+y[b+1]).slice(1),F=y[b+2]?(" "+y[b+2]).slice(1):"";switch(D){case"PLAYLIST-TYPE":a.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":d=a.startSN=parseInt(M);break;case"SKIP":{const U=new cr(M);Ys(a,U,["RECENTLY-REMOVED-DATERANGES"]);const $=U.decimalInteger("SKIPPED-SEGMENTS");if(bt($)){a.skippedSegments=$;for(let G=$;G--;)l.unshift(null);d+=$}const q=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");q&&(a.recentlyRemovedDateranges=q.split(" "));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(M),1);break;case"VERSION":a.version=parseInt(M);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(M||F)&&v.tagList.push(F?[M,F]:[M]);break;case"DISCONTINUITY":m++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([D]);break;case"BITRATE":v.tagList.push([D,M]);break;case"DATERANGE":{const U=new cr(M);Ys(a,U,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Ys(a,U,U.clientAttrs);const $=new dT(U,a.dateRanges[U.ID]);$.isValid||a.skippedSegments?a.dateRanges[$.id]=$:he.warn(`Ignoring invalid DATERANGE tag: "${M}"`),v.tagList.push(["EXT-X-DATERANGE",M]);break}case"DEFINE":{{const U=new cr(M);Ys(a,U,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in U?loe(a,U,o):tB(a,U,t)}break}case"DISCONTINUITY-SEQUENCE":m=parseInt(M);break;case"KEY":{const U=lB(M,t,a);if(U.isSupported()){if(U.method==="NONE"){S=void 0;break}S||(S={}),S[U.keyFormat]&&(S=Or({},S)),S[U.keyFormat]=U}else he.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${M}"`);break}case"START":a.startTimeOffset=cB(M);break;case"MAP":{const U=new cr(M);if(Ys(a,U,["BYTERANGE","URI"]),v.duration){const $=new $m(s,t);fB($,U,r,S),c=$,v.initSegment=c,c.rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=c.rawProgramDateTime)}else{const $=v.byteRangeEndOffset;if($){const q=v.byteRangeStartOffset;R=`${$-q}@${q}`}else R=null;fB(v,U,r,S),c=v,C=!0}break}case"SERVER-CONTROL":{const U=new cr(M);a.canBlockReload=U.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=U.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&U.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),a.holdBack=U.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const U=new cr(M);a.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{let U=a.partList;U||(U=a.partList=[]);const $=f>0?U[U.length-1]:void 0,q=f++,G=new cr(M);Ys(a,G,["BYTERANGE","URI"]);const V=new PU(G,v,t,q,$);U.push(V),v.duration+=V.duration;break}case"PRELOAD-HINT":{const U=new cr(M);Ys(a,U,["URI"]),a.preloadHint=U;break}case"RENDITION-REPORT":{const U=new cr(M);Ys(a,U,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(U);break}default:he.warn(`line parsed but not handled: ${y}`);break}}}g&&!g.relurl?(l.pop(),p-=g.duration,a.partList&&(a.fragmentHint=g)):a.partList&&(dB(v,g),v.cc=m,a.fragmentHint=v,S&&hB(v,S,a));const I=l.length,A=l[0],k=l[I-1];if(p+=a.skippedSegments*a.targetduration,p>0&&I&&k){a.averagetargetduration=p/I;const N=k.sn;a.endSN=N!=="initSegment"?N:0,a.live||(k.endList=!0),A&&(a.startCC=A.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(p+=a.fragmentHint.duration),a.totalduration=p,a.endCC=m,E>0&&goe(l,E),a}}function lB(n,e,t){var r,s;const i=new cr(n);Ys(t,i,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const o=(r=i.METHOD)!=null?r:"",a=i.URI,l=i.hexadecimalInteger("IV"),c=i.KEYFORMATVERSIONS,d=(s=i.KEYFORMAT)!=null?s:"identity";a&&i.IV&&!l&&he.error(`Invalid IV: ${i.IV}`);const f=a?jo.resolve(a,e):"",p=(c||"1").split("/").map(Number).filter(Number.isFinite);return new fu(o,f,d,p,l)}function cB(n){const t=new cr(n).decimalFloatingPoint("TIME-OFFSET");return bt(t)?t:null}function moe(n,e){let t=(n||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{const s=t.filter(i=>coe(i,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(i=>s.indexOf(i)===-1))}),e.unknownCodecs=t}function uB(n,e,t){const r=e[t];r&&(n[t]=r)}function goe(n,e){let t=n[e];for(let r=e;r--;){const s=n[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function dB(n,e){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):e!=null&&e.programDateTime&&(n.programDateTime=e.endProgramDateTime),bt(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function fB(n,e,t,r){n.relurl=e.URI,e.BYTERANGE&&n.setByteRange(e.BYTERANGE),n.level=t,n.sn="initSegment",r&&(n.levelkeys=r),n.initSegment=null}function hB(n,e,t){n.levelkeys=e;const{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(n)}var Sn={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},zt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function pB(n){const{type:e}=n;switch(e){case Sn.AUDIO_TRACK:return zt.AUDIO;case Sn.SUBTITLE_TRACK:return zt.SUBTITLE;default:return zt.MAIN}}function wT(n,e){let t=n.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class _oe{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.LEVEL_LOADING,this.onLevelLoading,this),e.on(Y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.LEVEL_LOADING,this.onLevelLoading,this),e.off(Y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,s=t.loader,i=r||s,o=new i(t);return this.loaders[e.type]=o,o}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Sn.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){const{id:r,level:s,pathwayId:i,url:o,deliveryDirectives:a}=t;this.load({id:r,level:s,pathwayId:i,responseType:"text",type:Sn.LEVEL,url:o,deliveryDirectives:a})}onAudioTrackLoading(e,t){const{id:r,groupId:s,url:i,deliveryDirectives:o}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Sn.AUDIO_TRACK,url:i,deliveryDirectives:o})}onSubtitleTrackLoading(e,t){const{id:r,groupId:s,url:i,deliveryDirectives:o}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Sn.SUBTITLE_TRACK,url:i,deliveryDirectives:o})}load(e){var t;const r=this.hls.config;let s=this.getInternalLoader(e);if(s){const c=s.context;if(c&&c.url===e.url&&c.level===e.level){he.trace("[playlist-loader]: playlist request ongoing");return}he.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let i;if(e.type===Sn.MANIFEST?i=r.manifestLoadPolicy.default:i=Or({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),bt((t=e.deliveryDirectives)==null?void 0:t.part)){let c;if(e.type===Sn.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===Sn.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===Sn.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){const d=c.partTarget,f=c.targetduration;if(d&&f){const p=Math.max(d*3,f*.8)*1e3;i=Or({},i,{maxTimeToFirstByteMs:Math.min(p,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(p,i.maxTimeToFirstByteMs)})}}}const o=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,d,f,p)=>{const m=this.getInternalLoader(f);this.resetInternalLoader(f.type);const g=c.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(c,f,new Error("no EXTM3U delimiter"),p||null,d);return}d.parsing.start=performance.now(),jo.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(c,d,f,p||null,m):this.handleMasterPlaylist(c,d,f,p)},onError:(c,d,f,p)=>{this.handleNetworkError(d,f,!1,c,p)},onTimeout:(c,d,f)=>{this.handleNetworkError(d,f,!0,void 0,c)}};s.load(e,a,l)}handleMasterPlaylist(e,t,r,s){const i=this.hls,o=e.data,a=wT(e,r),l=jo.parseMasterPlaylist(o,a);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}const{contentSteering:c,levels:d,sessionData:f,sessionKeys:p,startTimeOffset:m,variableList:g}=l;this.variableList=g;const{AUDIO:v=[],SUBTITLES:y,"CLOSED-CAPTIONS":b}=jo.parseMasterPlaylistMedia(o,a,l);v.length&&!v.some(E=>!E.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(he.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new cr({}),bitrate:0,url:""})),i.trigger(Y.MANIFEST_LOADED,{levels:d,audioTracks:v,subtitles:y,captions:b,contentSteering:c,url:a,stats:t,networkDetails:s,sessionData:f,sessionKeys:p,startTimeOffset:m,variableList:g})}handleTrackOrLevelPlaylist(e,t,r,s,i){const o=this.hls,{id:a,level:l,type:c}=r,d=wT(e,r),f=0,p=bt(l)?l:bt(a)?a:0,m=pB(r),g=jo.parseLevelPlaylist(e.data,d,p,m,f,this.variableList);if(c===Sn.MANIFEST){const v={attrs:new cr({}),bitrate:0,details:g,name:"",url:d};o.trigger(Y.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:d,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=g,this.handlePlaylistLoaded(g,e,t,r,s,i)}handleManifestParsingError(e,t,r,s,i){this.hls.trigger(Y.ERROR,{type:Gt.NETWORK_ERROR,details:Ce.MANIFEST_PARSING_ERROR,fatal:t.type===Sn.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:i})}handleNetworkError(e,t,r=!1,s,i){let o=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Sn.LEVEL?o+=`: ${e.level} id: ${e.id}`:(e.type===Sn.AUDIO_TRACK||e.type===Sn.SUBTITLE_TRACK)&&(o+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(o);he.warn(`[playlist-loader]: ${o}`);let l=Ce.UNKNOWN,c=!1;const d=this.getInternalLoader(e);switch(e.type){case Sn.MANIFEST:l=r?Ce.MANIFEST_LOAD_TIMEOUT:Ce.MANIFEST_LOAD_ERROR,c=!0;break;case Sn.LEVEL:l=r?Ce.LEVEL_LOAD_TIMEOUT:Ce.LEVEL_LOAD_ERROR,c=!1;break;case Sn.AUDIO_TRACK:l=r?Ce.AUDIO_TRACK_LOAD_TIMEOUT:Ce.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case Sn.SUBTITLE_TRACK:l=r?Ce.SUBTITLE_TRACK_LOAD_TIMEOUT:Ce.SUBTITLE_LOAD_ERROR,c=!1;break}d&&this.resetInternalLoader(e.type);const f={type:Gt.NETWORK_ERROR,details:l,fatal:c,url:e.url,loader:d,context:e,error:a,networkDetails:t,stats:i};if(s){const p=(t==null?void 0:t.url)||e.url;f.response=Xr({url:p,data:void 0},s)}this.hls.trigger(Y.ERROR,f)}handlePlaylistLoaded(e,t,r,s,i,o){const a=this.hls,{type:l,level:c,id:d,groupId:f,deliveryDirectives:p}=s,m=wT(t,s),g=pB(s),v=typeof s.level=="number"&&g===zt.MAIN?c:void 0;if(!e.fragments.length){const b=new Error("No Segments found in Playlist");a.trigger(Y.ERROR,{type:Gt.NETWORK_ERROR,details:Ce.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:b,reason:b.message,response:t,context:s,level:v,parent:g,networkDetails:i,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const y=e.playlistParsingError;if(y){a.trigger(Y.ERROR,{type:Gt.NETWORK_ERROR,details:Ce.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:s,level:v,parent:g,networkDetails:i,stats:r});return}switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),(!o.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Sn.MANIFEST:case Sn.LEVEL:a.trigger(Y.LEVEL_LOADED,{details:e,level:v||0,id:d||0,stats:r,networkDetails:i,deliveryDirectives:p});break;case Sn.AUDIO_TRACK:a.trigger(Y.AUDIO_TRACK_LOADED,{details:e,id:d||0,groupId:f||"",stats:r,networkDetails:i,deliveryDirectives:p});break;case Sn.SUBTITLE_TRACK:a.trigger(Y.SUBTITLE_TRACK_LOADED,{details:e,id:d||0,groupId:f||"",stats:r,networkDetails:i,deliveryDirectives:p});break}}}function mB(n,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=n,e.dispatchEvent(t)}function gB(n,e){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(e.id))try{if(n.addCue(e),!n.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){he.debug(`[texttrack-utils]: ${r}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,n.addCue(s)}catch(s){he.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(n.mode=t)}function hu(n){const e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues)for(let t=n.cues.length;t--;)n.removeCue(n.cues[t]);e==="disabled"&&(n.mode=e)}function TT(n,e,t,r){const s=n.mode;if(s==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const i=yoe(n.cues,e,t);for(let o=0;o<i.length;o++)(!r||r(i[o]))&&n.removeCue(i[o])}s==="disabled"&&(n.mode=s)}function voe(n,e){if(e<n[0].startTime)return 0;const t=n.length-1;if(e>n[t].endTime)return-1;let r=0,s=t;for(;r<=s;){const i=Math.floor((s+r)/2);if(e<n[i].startTime)s=i-1;else if(e>n[i].startTime&&r<t)r=i+1;else return i}return n[r].startTime-e<e-n[s].startTime?r:s}function yoe(n,e,t){const r=[],s=voe(n,e);if(s>-1)for(let i=s,o=n.length;i<o;i++){const a=n[i];if(a.startTime>=e&&a.endTime<=t)r.push(a);else if(a.startTime>t)return r}return r}function Ym(n){const e=[];for(let t=0;t<n.length;t++){const r=n[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(n[t])}return e}var ki={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const boe=.25;function CT(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function _B(n,e,t,r,s){let i=new n(e,t,"");try{i.value=r,s&&(i.type=s)}catch{i=new n(e,t,JSON.stringify(s?Xr({type:s},r):r))}return i}const Xm=(()=>{const n=CT();try{n&&new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function IT(n,e){return n.getTime()/1e3-e}function xoe(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Soe{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Y.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Y.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(hu(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if(r.kind==="metadata"&&r.label==="id3")return mB(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;const{samples:i}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=CT();if(o)for(let a=0;a<i.length;a++){const l=i[a].type;if(l===ki.emsg&&!r||!s)continue;const c=qU(i[a].data);if(c){const d=i[a].pts;let f=d+i[a].duration;f>Xm&&(f=Xm),f-d<=0&&(f=d+boe);for(let m=0;m<c.length;m++){const g=c[m];if(!zU(g)){this.updateId3CueEnds(d,l);const v=_B(o,d,f,g,l);v&&this.id3Track.addCue(v)}}}}}updateId3CueEnds(e,t){var r;const s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let i=s.length;i--;){const o=s[i];o.type===t&&o.startTime<e&&o.endTime===Xm&&(o.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){const{id3Track:i,hls:o}=this;if(!o)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:l}}=o;if(i&&(a||l)){let c;s==="audio"?c=d=>d.type===ki.audioId3&&l:s==="video"?c=d=>d.type===ki.emsg&&a:c=d=>d.type===ki.audioId3&&l||d.type===ki.emsg&&a,TT(i,t,r,c)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:i}=t,o=Object.keys(i);if(s){const d=Object.keys(r).filter(f=>!o.includes(f));for(let f=d.length;f--;){const p=d[f];Object.keys(r[p].cues).forEach(m=>{s.removeCue(r[p].cues[m])}),delete r[p]}}const a=t.fragments[t.fragments.length-1];if(o.length===0||!bt(a==null?void 0:a.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=a.programDateTime/1e3-a.start,c=CT();for(let d=0;d<o.length;d++){const f=o[d],p=i[f],m=IT(p.startDate,l),g=r[f],v=(g==null?void 0:g.cues)||{};let y=(g==null?void 0:g.durationKnown)||!1,b=Xm;const S=p.endDate;if(S)b=IT(S,l),y=!0;else if(p.endOnNext&&!y){const C=o.reduce((R,I)=>{if(I!==p.id){const A=i[I];if(A.class===p.class&&A.startDate>p.startDate&&(!R||p.startDate<R.startDate))return A}return R},null);C&&(b=IT(C.startDate,l),y=!0)}const E=Object.keys(p.attr);for(let C=0;C<E.length;C++){const R=E[C];if(!Rie(R))continue;const I=v[R];if(I)y&&!g.durationKnown&&(I.endTime=b);else if(c){let A=p.attr[R];Aie(R)&&(A=xoe(A));const k=_B(c,m,b,{key:R,data:A},ki.dateRange);k&&(k.id=f,this.id3Track.addCue(k),v[R]=k)}}r[f]={cues:v,dateRange:p,durationKnown:y}}}}class Eoe{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:i,liveSyncDurationCount:o,lowLatencyMode:a}=this.config,l=this.hls.userConfig;let c=a&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||c===0)&&(c=i!==void 0?i:o*s);const d=s;return c+Math.min(this.stallCount*1,d)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;const s=r.edge,i=e-t-this.edgeStalled,o=s-r.totalduration,a=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,i),a)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Y.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Y.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===Ce.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&he.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:i}=this.config;if(!s||i===1||!t.live)return;const o=this.targetLatency;if(o===null)return;const a=r-o,l=Math.min(this.maxLatency,o+t.targetduration);if(a<l&&a>.05&&this.forwardBufferLength>1){const d=Math.min(2,Math.max(1,i)),f=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;e.playbackRate=Math.min(d,Math.max(1,f))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const RT=["NONE","TYPE-0","TYPE-1",null];function woe(n){return RT.indexOf(n)>-1}const Qm=["SDR","PQ","HLG"];function Toe(n){return!!n&&Qm.indexOf(n)>-1}var pu={No:"",Yes:"YES",v2:"v2"};function Coe(n,e){const{canSkipUntil:t,canSkipDateRanges:r,endSN:s}=n,i=e!==void 0?e-s:0;return t&&i<t?r?pu.v2:pu.Yes:pu.No}class AT{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class ac{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return vB(this._audioGroups,e)}hasSubtitleGroup(e){return vB(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function vB(n,e){return!e||!n?!1:n.indexOf(e)!==-1}function kT(n,e){const t=e.startPTS;if(bt(t)){let r=0,s;e.sn>n.sn?(r=t-n.start,s=n):(r=n.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>n.sn?n.cc===e.cc&&n.minEndPTS?e.start=n.start+(n.minEndPTS-n.start):e.start=n.start+n.duration:e.start=Math.max(n.start-e.duration,0)}function yB(n,e,t,r,s,i){r-t<=0&&(he.warn("Fragment should have a positive duration",e),r=t+e.duration,i=s+e.duration);let a=t,l=r;const c=e.startPTS,d=e.endPTS;if(bt(c)){const y=Math.abs(c-t);bt(e.deltaPTS)?e.deltaPTS=Math.max(y,e.deltaPTS):e.deltaPTS=y,a=Math.max(t,c),t=Math.min(t,c),s=Math.min(s,e.startDTS),l=Math.min(r,d),r=Math.max(r,d),i=Math.max(i,e.endDTS)}const f=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=a,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=i;const p=e.sn;if(!n||p<n.startSN||p>n.endSN)return 0;let m;const g=p-n.startSN,v=n.fragments;for(v[g]=e,m=g;m>0;m--)kT(v[m],v[m-1]);for(m=g;m<v.length-1;m++)kT(v[m],v[m+1]);return n.fragmentHint&&kT(v[v.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,f}function Ioe(n,e){let t=null;const r=n.fragments;for(let l=r.length-1;l>=0;l--){const c=r[l].initSegment;if(c){t=c;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let s=0,i;if(koe(n,e,(l,c)=>{l.relurl&&(s=l.cc-c.cc),bt(l.startPTS)&&bt(l.endPTS)&&(c.start=c.startPTS=l.startPTS,c.startDTS=l.startDTS,c.maxStartPTS=l.maxStartPTS,c.endPTS=l.endPTS,c.endDTS=l.endDTS,c.minEndPTS=l.minEndPTS,c.duration=l.endPTS-l.startPTS,c.duration&&(i=c),e.PTSKnown=e.alignedSliding=!0),c.elementaryStreams=l.elementaryStreams,c.loader=l.loader,c.stats=l.stats,l.initSegment&&(c.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(c=>{var d;c&&(!c.initSegment||c.initSegment.relurl===((d=t)==null?void 0:d.relurl))&&(c.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){he.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=Roe(n.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const o=e.fragments;if(s){he.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<o.length;l++)o[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),Aoe(n.partList,e.partList,(l,c)=>{c.elementaryStreams=l.elementaryStreams,c.stats=l.stats}),i?yB(e,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS):bB(n,e),o.length&&(e.totalduration=e.edge-o[0].start),e.driftStartTime=n.driftStartTime,e.driftStart=n.driftStart;const a=e.advancedDateTime;if(e.advanced&&a){const l=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=l),e.driftEndTime=a,e.driftEnd=l}else e.driftEndTime=n.driftEndTime,e.driftEnd=n.driftEnd,e.advancedDateTime=n.advancedDateTime}function Roe(n,e,t){const r=Or({},n);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{const i=new dT(e[s].attr,r[s]);i.isValid?r[s]=i:he.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function Aoe(n,e,t){if(n&&e){let r=0;for(let s=0,i=n.length;s<=i;s++){const o=n[s],a=e[s+r];o&&a&&o.index===a.index&&o.fragment.sn===a.fragment.sn?t(o,a):r--}}}function koe(n,e,t){const r=e.skippedSegments,s=Math.max(n.startSN,e.startSN)-e.startSN,i=(n.fragmentHint?1:0)+(r?e.endSN:Math.min(n.endSN,e.endSN))-e.startSN,o=e.startSN-n.startSN,a=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let c=s;c<=i;c++){const d=l[o+c];let f=a[c];r&&!f&&c<r&&(f=e.fragments[c]=d),d&&f&&t(d,f)}}function bB(n,e){const t=e.startSN+e.skippedSegments-n.startSN,r=n.fragments;t<0||t>=r.length||LT(e,r[t].start)}function LT(n,e){if(e){const t=n.fragments;for(let r=n.skippedSegments;r<t.length;r++)t[r].start+=e;n.fragmentHint&&(n.fragmentHint.start+=e)}}function Loe(n,e=1/0){let t=1e3*n.targetduration;if(n.updated){const r=n.fragments;if(r.length&&t*4>e){const i=r[r.length-1].duration*1e3;i<t&&(t=i)}}else t/=2;return Math.round(t)}function Moe(n,e,t){if(!(n!=null&&n.details))return null;const r=n.details;let s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function xB(n,e,t){var r;return n!=null&&n.details?SB((r=n.details)==null?void 0:r.partList,e,t):null}function SB(n,e,t){if(n)for(let r=n.length;r--;){const s=n[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function EB(n){n.forEach((e,t)=>{const{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Jm(n){switch(n.details){case Ce.FRAG_LOAD_TIMEOUT:case Ce.KEY_LOAD_TIMEOUT:case Ce.LEVEL_LOAD_TIMEOUT:case Ce.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function wB(n,e){const t=Jm(e);return n.default[`${t?"timeout":"error"}Retry`]}function MT(n,e){const t=n.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*n.retryDelayMs,n.maxRetryDelayMs)}function TB(n){return Xr(Xr({},n),{errorRetry:null,timeoutRetry:null})}function Zm(n,e,t,r){if(!n)return!1;const s=r==null?void 0:r.code,i=e<n.maxNumRetry&&(Noe(s)||!!t);return n.shouldRetry?n.shouldRetry(n,e,t,r,i):i}function Noe(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}const CB={search:function(n,e){let t=0,r=n.length-1,s=null,i=null;for(;t<=r;){s=(t+r)/2|0,i=n[s];const o=e(i);if(o>0)t=s+1;else if(o<0)r=s-1;else return i}return null}};function Ooe(n,e,t){if(e===null||!Array.isArray(n)||!n.length||!bt(e))return null;const r=n[0].programDateTime;if(e<(r||0))return null;const s=n[n.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let i=0;i<n.length;++i){const o=n[i];if(Poe(e,t,o))return o}return null}function eg(n,e,t=0,r=0){let s=null;if(n){s=e[n.sn-e[0].sn+1]||null;const o=n.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(s=e[0]);if(s&&(!n||n.level===s.level)&&NT(t,r,s)===0)return s;const i=CB.search(e,NT.bind(null,t,r));return i&&(i!==n||!s)?i:s}function NT(n=0,e=0,t){if(t.start<=n&&t.start+t.duration>n)return 0;const r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=n?1:t.start-r>n&&t.start?-1:0}function Poe(n,e,t){const r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>n}function Doe(n,e){return CB.search(n,t=>t.cc<e?1:t.cc>e?-1:0)}var Qr={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Li={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2};class IB{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=he.log.bind(he,"[info]:"),this.warn=he.warn.bind(he,"[warning]:"),this.error=he.error.bind(he,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(Y.ERROR,this.onError,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Y.ERROR,this.onError,this),e.off(Y.ERROR,this.onErrorOut,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===zt.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;const i=this.hls,o=t.context;switch(t.details){case Ce.FRAG_LOAD_ERROR:case Ce.FRAG_LOAD_TIMEOUT:case Ce.KEY_LOAD_ERROR:case Ce.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case Ce.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:Qr.DoNothing,flags:Li.None};return}case Ce.FRAG_GAP:case Ce.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Qr.SendAlternateToPenaltyBox;return}case Ce.LEVEL_EMPTY_ERROR:case Ce.LEVEL_PARSING_ERROR:{var a,l;const c=t.parent===zt.MAIN?t.level:i.loadLevel;t.details===Ce.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(l=a.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case Ce.LEVEL_LOAD_ERROR:case Ce.LEVEL_LOAD_TIMEOUT:typeof(o==null?void 0:o.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o.level));return;case Ce.AUDIO_TRACK_LOAD_ERROR:case Ce.AUDIO_TRACK_LOAD_TIMEOUT:case Ce.SUBTITLE_LOAD_ERROR:case Ce.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){const c=i.levels[i.loadLevel];if(c&&(o.type===Sn.AUDIO_TRACK&&c.hasAudioGroup(o.groupId)||o.type===Sn.SUBTITLE_TRACK&&c.hasSubtitleGroup(o.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Qr.SendAlternateToPenaltyBox,t.errorAction.flags=Li.MoveAllAlternatesMatchingHost;return}}return;case Ce.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const c=i.levels[i.loadLevel],d=c==null?void 0:c.attrs["HDCP-LEVEL"];d?t.errorAction={action:Qr.SendAlternateToPenaltyBox,flags:Li.MoveAllAlternatesMatchingHDCP,hdcpLevel:d}:this.keySystemError(t)}return;case Ce.BUFFER_ADD_CODEC_ERROR:case Ce.REMUX_ALLOC_ERROR:case Ce.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:i.loadLevel);return;case Ce.INTERNAL_EXCEPTION:case Ce.BUFFER_APPENDING_ERROR:case Ce.BUFFER_FULL_ERROR:case Ce.LEVEL_SWITCH_ERROR:case Ce.BUFFER_STALLED_ERROR:case Ce.BUFFER_SEEK_OVER_HOLE:case Ce.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Qr.DoNothing,flags:Li.None};return}t.type===Gt.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const r=this.hls,s=wB(r.config.playlistLoadPolicy,e),i=this.playlistError++;if(Zm(s,i,Jm(e),e.response))return{action:Qr.RetryRequest,flags:Li.None,retryConfig:s,retryCount:i};const a=this.getLevelSwitchAction(e,t);return s&&(a.retryConfig=s,a.retryCount=i),a}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:i,keyLoadPolicy:o}=t.config,a=wB(e.details.startsWith("key")?o:i,e),l=t.levels.reduce((d,f)=>d+f.fragmentError,0);if(s&&(e.details!==Ce.FRAG_GAP&&s.fragmentError++,Zm(a,l,Jm(e),e.response)))return{action:Qr.RetryRequest,flags:Li.None,retryConfig:a,retryCount:l};const c=this.getLevelSwitchAction(e,r);return a&&(c.retryConfig=a,c.retryCount=l),c}getLevelSwitchAction(e,t){const r=this.hls;t==null&&(t=r.loadLevel);const s=this.hls.levels[t];if(s){var i,o;const c=e.details;s.loadError++,c===Ce.BUFFER_APPEND_ERROR&&s.fragmentError++;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:m,maxAutoLevel:g}=r;r.autoLevelEnabled||(r.loadLevel=-1);const v=(i=e.frag)==null?void 0:i.type,b=(v===zt.AUDIO&&c===Ce.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(c===Ce.BUFFER_ADD_CODEC_ERROR||c===Ce.BUFFER_APPEND_ERROR))&&f.some(({audioCodec:I})=>s.audioCodec!==I),E=e.sourceBufferName==="video"&&(c===Ce.BUFFER_ADD_CODEC_ERROR||c===Ce.BUFFER_APPEND_ERROR)&&f.some(({codecSet:I,audioCodec:A})=>s.codecSet!==I&&s.audioCodec===A),{type:C,groupId:R}=(o=e.context)!=null?o:{};for(let I=f.length;I--;){const A=(I+p)%f.length;if(A!==p&&A>=m&&A<=g&&f[A].loadError===0){var a,l;const k=f[A];if(c===Ce.FRAG_GAP&&e.frag){const N=f[A].details;if(N){const D=eg(e.frag,N.fragments,e.frag.start);if(D!=null&&D.gap)continue}}else{if(C===Sn.AUDIO_TRACK&&k.hasAudioGroup(R)||C===Sn.SUBTITLE_TRACK&&k.hasSubtitleGroup(R))continue;if(v===zt.AUDIO&&(a=s.audioGroups)!=null&&a.some(N=>k.hasAudioGroup(N))||v===zt.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(N=>k.hasSubtitleGroup(N))||b&&s.audioCodec===k.audioCodec||!b&&s.audioCodec!==k.audioCodec||E&&s.codecSet===k.codecSet)continue}d=A;break}}if(d>-1&&r.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:Qr.SendAlternateToPenaltyBox,flags:Li.None,nextAutoLevel:d}}return{action:Qr.SendAlternateToPenaltyBox,flags:Li.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Qr.DoNothing:break;case Qr.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==Ce.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:s,hdcpLevel:i,nextAutoLevel:o}=r;switch(s){case Li.None:this.switchLevel(e,o);break;case Li.MoveAllAlternatesMatchingHDCP:i&&(t.maxHdcpLevel=RT[RT.indexOf(i)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,o)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class tg{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=he.log.bind(he,`${t}:`),this.warn=he.warn.bind(he,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){const r=t==null?void 0:t.renditionReports;if(r){let s=-1;for(let i=0;i<r.length;i++){const o=r[i];let a;try{a=new self.URL(o.URI,t.url).href}catch(l){he.warn(`Could not construct new URL for Rendition Report: ${l}`),a=o.URI||""}if(a===e){s=i;break}else a===e.substring(0,a.length)&&(s=i)}if(s!==-1){const i=r[s],o=parseInt(i["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let a=parseInt(i["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const l=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&l>t.partTarget&&(a+=1)}return new AT(o,a>=0?a:void 0,pu.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){const{details:s,stats:i}=t,o=self.performance.now(),a=i.loading.first?Math.max(0,o-i.loading.first):0;if(s.advancedDateTime=Date.now()-a,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&Ioe(r,s),!this.canLoad||!s.live)return;let l,c,d;if(s.canBlockReload&&s.endSN&&s.advanced){const y=this.hls.config.lowLatencyMode,b=s.lastPartSn,S=s.endSN,E=s.lastPartIndex,C=E!==-1,R=b===S,I=y?0:E;C?(c=R?S+1:b,d=R?I:E+1):c=S+1;const A=s.age,k=A+s.ageHeader;let N=Math.min(k-s.partTarget,s.targetduration*1.5);if(N>0){if(r&&N>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${N} with playlist age: ${s.age}`),N=0;else{const D=Math.floor(N/s.targetduration);if(c+=D,d!==void 0){const M=Math.round(N%s.targetduration/s.partTarget);d+=M}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${A.toFixed(2)}s goal: ${N} skip sn ${D} to part ${d}`)}s.tuneInGoal=N}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,c,d),y||!R){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,c,d));const f=this.hls.mainForwardBufferInfo,p=f?f.end-f.len:0,m=(s.edge-p)*1e3,g=Loe(s,m);s.updated&&o>this.requestScheduled+g&&(this.requestScheduled=i.loading.start),c!==void 0&&s.canBlockReload?this.requestScheduled=i.loading.first+g-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+g<o?this.requestScheduled=o:this.requestScheduled-o<=0&&(this.requestScheduled+=g);let v=this.requestScheduled-o;v=Math.max(0,v),this.log(`reload live playlist ${e} in ${Math.round(v)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),v)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let i=Coe(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,i=pu.No),new AT(r,s,i)}checkRetry(e){const t=e.details,r=Jm(e),s=e.errorAction,{action:i,retryCount:o=0,retryConfig:a}=s||{},l=!!s&&!!a&&(i===Qr.RetryRequest||!s.resolved&&i===Qr.SendAlternateToPenaltyBox);if(l){var c;if(this.requestScheduled=-1,o>=a.maxNumRetry)return!1;if(r&&(c=e.context)!=null&&c.deliveryDirectives)this.warn(`Retrying playlist loading ${o+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const d=MT(a,o);this.timer=self.setTimeout(()=>this.loadPlaylist(),d),this.warn(`Retrying playlist loading ${o+1}/${a.maxNumRetry} after "${t}" in ${d}ms`)}e.levelRetry=!0,s.resolved=!0}return l}}class mu{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class joe{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new mu(e),this.fast_=new mu(t),this.defaultTTFB_=s,this.ttfb_=new mu(e)}update(e,t){const{slow_:r,fast_:s,ttfb_:i}=this;r.halfLife!==e&&(this.slow_=new mu(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new mu(t,s.getEstimate(),s.getTotalWeight())),i.halfLife!==e&&(this.ttfb_=new mu(e,i.getEstimate(),i.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const r=8*t,s=e/1e3,i=r/s;this.fast_.sample(s,i),this.slow_.sample(s,i)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}const RB={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},AB={};function Foe(n,e,t,r,s,i){const o=n.audioCodec?n.audioGroups:null,a=i==null?void 0:i.audioCodec,l=i==null?void 0:i.channels,c=l?parseInt(l):a?1/0:2;let d=null;if(o!=null&&o.length)try{o.length===1&&o[0]?d=e.groups[o[0]].channels:d=o.reduce((f,p)=>{if(p){const m=e.groups[p];if(!m)throw new Error(`Audio track group ${p} not found`);Object.keys(m.channels).forEach(g=>{f[g]=(f[g]||0)+m.channels[g]})}return f},{2:0})}catch{return!0}return n.videoCodec!==void 0&&(n.width>1920&&n.height>1088||n.height>1920&&n.width>1088||n.frameRate>Math.max(r,30)||n.videoRange!=="SDR"&&n.videoRange!==t||n.bitrate>Math.max(s,8e6))||!!d&&bt(c)&&Object.keys(d).some(f=>parseInt(f)>c)}function Uoe(n,e,t){const r=n.videoCodec,s=n.audioCodec;if(!r||!s||!t)return Promise.resolve(RB);const i={width:n.width,height:n.height,bitrate:Math.ceil(Math.max(n.bitrate*.9,n.averageBitrate)),framerate:n.frameRate||30},o=n.videoRange;o!=="SDR"&&(i.transferFunction=o.toLowerCase());const a=r.split(",").map(l=>({type:"media-source",video:Xr(Xr({},i),{},{contentType:$f(l,"video")})}));return s&&n.audioGroups&&n.audioGroups.forEach(l=>{var c;l&&((c=e.groups[l])==null||c.tracks.forEach(d=>{if(d.groupId===l){const f=d.channels||"",p=parseFloat(f);bt(p)&&p>2&&a.push.apply(a,s.split(",").map(m=>({type:"media-source",audio:{contentType:$f(m,"audio"),channels:""+p}})))}}))}),Promise.all(a.map(l=>{const c=Boe(l);return AB[c]||(AB[c]=t.decodingInfo(l))})).then(l=>({supported:!l.some(c=>!c.supported),configurations:a,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:a,decodingInfoResults:[],error:l}))}function Boe(n){const{audio:e,video:t}=n,r=t||e;if(r){const s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function $oe(){if(typeof matchMedia=="function"){const n=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(n.media!==e.media)return n.matches===!0}return!1}function zoe(n,e){let t=!1,r=[];return n&&(t=n!=="SDR",r=[n]),e&&(r=e.allowedVideoRanges||Qm.slice(0),t=e.preferHDR!==void 0?e.preferHDR:$oe(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function qoe(n,e,t,r,s){const i=Object.keys(n),o=r==null?void 0:r.channels,a=r==null?void 0:r.audioCodec,l=o&&parseInt(o)===2;let c=!0,d=!1,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=zoe(e,s);for(let R=i.length;R--;){const I=n[i[R]];c=I.channels[2]>0,f=Math.min(f,I.minHeight),p=Math.min(p,I.minFramerate),m=Math.min(m,I.minBitrate);const A=b.filter(k=>I.videoRanges[k]>0);A.length>0&&(d=!0,v=A)}f=bt(f)?f:0,p=bt(p)?p:0;const S=Math.max(1080,f),E=Math.max(30,p);return m=bt(m)?m:t,t=Math.max(m,t),d||(e=void 0,v=[]),{codecSet:i.reduce((R,I)=>{const A=n[I];if(I===R)return R;if(A.minBitrate>t)return oa(I,`min bitrate of ${A.minBitrate} > current estimate of ${t}`),R;if(!A.hasDefaultAudio)return oa(I,"no renditions with default or auto-select sound found"),R;if(a&&I.indexOf(a.substring(0,4))%5!==0)return oa(I,`audio codec preference "${a}" not found`),R;if(o&&!l){if(!A.channels[o])return oa(I,`no renditions with ${o} channel sound found (channels options: ${Object.keys(A.channels)})`),R}else if((!a||l)&&c&&A.channels[2]===0)return oa(I,"no renditions with stereo sound found"),R;return A.minHeight>S?(oa(I,`min resolution of ${A.minHeight} > maximum of ${S}`),R):A.minFramerate>E?(oa(I,`min framerate of ${A.minFramerate} > maximum of ${E}`),R):v.some(k=>A.videoRanges[k]>0)?A.maxScore<g?(oa(I,`max score of ${A.maxScore} < selected max of ${g}`),R):R&&(Wm(I)>=Wm(R)||A.fragmentError>n[R].fragmentError)?R:(g=A.maxScore,I):(oa(I,`no variants with VIDEO-RANGE of ${JSON.stringify(v)} found`),R)},void 0),videoRanges:v,preferHDR:y,minFramerate:p,minBitrate:m}}function oa(n,e){he.log(`[abr] start candidates with "${n}" ignored because ${e}`)}function Hoe(n){return n.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Goe(n,e,t,r){return n.slice(t,r+1).reduce((s,i)=>{if(!i.codecSet)return s;const o=i.audioGroups;let a=s[i.codecSet];a||(s[i.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,i.bitrate);const l=Math.min(i.height,i.width);return a.minHeight=Math.min(a.minHeight,l),a.minFramerate=Math.min(a.minFramerate,i.frameRate),a.maxScore=Math.max(a.maxScore,i.score),a.fragmentError+=i.fragmentError,a.videoRanges[i.videoRange]=(a.videoRanges[i.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;const d=e.groups[c];a.hasDefaultAudio=a.hasDefaultAudio||e.hasDefaultAudio?d.hasDefault:d.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(d.channels).forEach(f=>{a.channels[f]=(a.channels[f]||0)+d.channels[f]})}),s},{})}function Fo(n,e,t){if("attrs"in n){const r=e.indexOf(n);if(r!==-1)return r}for(let r=0;r<e.length;r++){const s=e[r];if(gu(n,s,t))return r}return-1}function gu(n,e,t){const{groupId:r,name:s,lang:i,assocLang:o,characteristics:a,default:l}=n,c=n.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(i===void 0||e.lang===i)&&(i===void 0||e.assocLang===o)&&(l===void 0||e.default===l)&&(c===void 0||e.forced===c)&&(a===void 0||Voe(a,e.characteristics))&&(t===void 0||t(n,e))}function Voe(n,e=""){const t=n.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function _u(n,e){const{audioCodec:t,channels:r}=n;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function Woe(n,e,t,r,s){const i=e[r],a=e.reduce((p,m,g)=>{const v=m.uri;return(p[v]||(p[v]=[])).push(g),p},{})[i.uri];a.length>1&&(r=Math.max.apply(Math,a));const l=i.videoRange,c=i.frameRate,d=i.codecSet.substring(0,4),f=kB(e,r,p=>{if(p.videoRange!==l||p.frameRate!==c||p.codecSet.substring(0,4)!==d)return!1;const m=p.audioGroups,g=t.filter(v=>!m||m.indexOf(v.groupId)!==-1);return Fo(n,g,s)>-1});return f>-1?f:kB(e,r,p=>{const m=p.audioGroups,g=t.filter(v=>!m||m.indexOf(v.groupId)!==-1);return Fo(n,g,s)>-1})}function kB(n,e,t){for(let r=e;r;r--)if(t(n[r]))return r;for(let r=e+1;r<n.length;r++)if(t(n[r]))return r;return-1}class LB{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:i,media:o}=s;if(!t||!o)return;const a=performance.now(),l=r?r.stats:t.stats,c=r?r.duration:t.duration,d=a-l.loading.start,f=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!i||o.paused||!o.playbackRate||!o.readyState)return;const p=s.mainForwardBufferInfo;if(p===null)return;const m=this.bwEstimator.getEstimateTTFB(),g=Math.abs(o.playbackRate);if(d<=Math.max(m,1e3*(c/(g*2))))return;const v=p.len/g,y=l.loading.first?l.loading.first-l.loading.start:-1,b=l.loaded&&y>-1,S=this.getBwEstimate(),E=s.levels,C=E[t.level],R=l.total||Math.max(l.loaded,Math.round(c*C.averageBitrate/8));let I=b?d-y:d;I<1&&b&&(I=Math.min(d,l.loaded*8/S));const A=b?l.loaded*1e3/I:0,k=A?(R-l.loaded)/A:R*8/S+m/1e3;if(k<=v)return;const N=A?A*8:S;let D=Number.POSITIVE_INFINITY,M;for(M=t.level-1;M>f;M--){const U=E[M].maxBitrate;if(D=this.getTimeToLoadFrag(m/1e3,N,c*U,!E[M].details),D<v)break}if(D>=k||D>c*10)return;s.nextLoadLevel=s.nextAutoLevel=M,b?this.bwEstimator.sample(d-Math.min(m,y),l.loaded):this.bwEstimator.sampleTTFB(d);const F=E[M].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>F&&this.resetEstimator(F),this.clearTimer(),he.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
365 Time to underbuffer: ${v.toFixed(3)} s
366 Estimated load time for current fragment: ${k.toFixed(3)} s
367 Estimated load time for down switch fragment: ${D.toFixed(3)} s
368 TTFB estimate: ${y|0} ms
369 Current BW estimate: ${bt(S)?S|0:"Unknown"} bps
370 New BW estimate: ${this.getBwEstimate()|0} bps
371 Switching to level ${M} @ ${F|0} bps`),s.trigger(Y.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(he.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new joe(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.FRAG_LOADING,this.onFragLoading,this),e.on(Y.FRAG_LOADED,this.onFragLoaded,this),e.on(Y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.FRAG_LOADING,this.onFragLoading,this),e.off(Y.FRAG_LOADED,this.onFragLoaded,this),e.off(Y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Y.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case Ce.BUFFER_ADD_CODEC_ERROR:case Ce.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Ce.FRAG_LOAD_TIMEOUT:{const r=t.frag,{fragCurrent:s,partCurrent:i}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){const o=performance.now(),a=i?i.stats:r.stats,l=o-a.loading.start,c=a.loading.first?a.loading.first-a.loading.start:-1;if(a.loaded&&c>-1){const f=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(f,c),a.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){const i=e+r/t,o=s?this.lastLevelLoadSec:0;return i+o}onLevelLoaded(e,t){const r=this.hls.config,{loading:s}=t.stats,i=s.end-s.start;bt(i)&&(this.lastLevelLoadSec=i/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){const s=r?r.stats:t.stats;if(t.type===zt.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const i=r?r.duration:t.duration,o=this.hls.levels[t.level],a=(o.loaded?o.loaded.bytes:0)+s.loaded,l=(o.loaded?o.loaded.duration:0)+i;o.loaded={bytes:a,duration:l},o.realBitrate=Math.round(8*a/l)}if(t.bitrateTest){const i={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(Y.FRAG_BUFFERED,i),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:s}=t,i=s!=null&&s.stats.loaded?s.stats:r.stats;if(i.aborted||this.ignoreFragment(r))return;const o=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,i.loaded),i.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==zt.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,i=this.findBestLevel(r,t,e,0,s,1,1);if(i>-1)return i;const o=this.hls.firstLevel,a=Math.min(Math.max(o,t),e);return he.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const i=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const o=this.hls.levels;if(o.length>Math.max(e,i)&&o[e].loadError<=o[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){var e;return`${this.getBwEstimate()}_${(e=this.hls.mainForwardBufferInfo)==null?void 0:e.len}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:i,minAutoLevel:o,media:a}=r,l=t?t.duration:e?e.duration:0,c=a&&a.playbackRate!==0?Math.abs(a.playbackRate):1,d=this.getBwEstimate(),f=r.mainForwardBufferInfo,p=(f?f.len:0)/c;let m=i.abrBandWidthFactor,g=i.abrBandWidthUpFactor;if(p){const E=this.findBestLevel(d,o,s,p,0,m,g);if(E>=0)return E}let v=l?Math.min(l,i.maxStarvationDelay):i.maxStarvationDelay;if(!p){const E=this.bitrateTestDelay;E&&(v=(l?Math.min(l,i.maxLoadingDelay):i.maxLoadingDelay)-E,he.info(`[abr] bitrate test took ${Math.round(1e3*E)}ms, set first fragment max fetchDuration to ${Math.round(1e3*v)} ms`),m=g=1)}const y=this.findBestLevel(d,o,s,p,v,m,g);if(he.info(`[abr] ${p?"rebuffering expected":"buffer is empty"}, optimal quality level ${y}`),y>-1)return y;const b=r.levels[o],S=r.levels[r.loadLevel];return(b==null?void 0:b.bitrate)<(S==null?void 0:S.bitrate)?o:r.loadLevel}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,i,o,a){var l;const c=s+i,d=this.lastLoadedFragLevel,f=d===-1?this.hls.firstLevel:d,{fragCurrent:p,partCurrent:m}=this,{levels:g,allAudioTracks:v,loadLevel:y,config:b}=this.hls;if(g.length===1)return 0;const S=g[f],E=!!(S!=null&&(l=S.details)!=null&&l.live),C=y===-1||d===-1;let R,I="SDR",A=(S==null?void 0:S.frameRate)||0;const{audioPreference:k,videoPreference:N}=b,D=this.audioTracksByGroup||(this.audioTracksByGroup=Hoe(v));if(C){if(this.firstSelection!==-1)return this.firstSelection;const q=this.codecTiers||(this.codecTiers=Goe(g,D,t,r)),G=qoe(q,I,e,k,N),{codecSet:V,videoRanges:z,minFramerate:B,minBitrate:P,preferHDR:H}=G;R=V,I=H?z[z.length-1]:z[0],A=B,e=Math.max(e,P),he.log(`[abr] picked start tier ${JSON.stringify(G)}`)}else R=S==null?void 0:S.codecSet,I=S==null?void 0:S.videoRange;const M=m?m.duration:p?p.duration:0,F=this.bwEstimator.getEstimateTTFB()/1e3,U=[];for(let q=r;q>=t;q--){var $;const G=g[q],V=q>f;if(!G)continue;if(b.useMediaCapabilities&&!G.supportedResult&&!G.supportedPromise){const J=navigator.mediaCapabilities;typeof(J==null?void 0:J.decodingInfo)=="function"&&Foe(G,D,I,A,e,k)?(G.supportedPromise=Uoe(G,D,J),G.supportedPromise.then(ee=>{G.supportedResult=ee;const K=this.hls.levels,W=K.indexOf(G);ee.error?he.warn(`[abr] MediaCapabilities decodingInfo error: "${ee.error}" for level ${W} ${JSON.stringify(ee)}`):ee.supported||(he.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${W} ${JSON.stringify(ee)}`),W>-1&&K.length>1&&(he.log(`[abr] Removing unsupported level ${W}`),this.hls.removeLevel(W)))})):G.supportedResult=RB}if(R&&G.codecSet!==R||I&&G.videoRange!==I||V&&A>G.frameRate||!V&&A>0&&A<G.frameRate||G.supportedResult&&!(($=G.supportedResult.decodingInfoResults)!=null&&$[0].smooth)){U.push(q);continue}const z=G.details,B=(m?z==null?void 0:z.partTarget:z==null?void 0:z.averagetargetduration)||M;let P;V?P=a*e:P=o*e;const H=M&&s>=M*2&&i===0?g[q].averageBitrate:g[q].maxBitrate,Z=this.getTimeToLoadFrag(F,P,H*B,z===void 0);if(P>=H&&(q===d||G.loadError===0&&G.fragmentError===0)&&(Z<=F||!bt(Z)||E&&!this.bitrateTestDelay||Z<c)){const J=this.forcedAutoLevel;return q!==y&&(J===-1||J!==y)&&(U.length&&he.trace(`[abr] Skipped level(s) ${U.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${g[U[0]].codecs}" ${g[U[0]].videoRange}; not compatible with "${S.codecs}" ${I}`),he.info(`[abr] switch candidate:${f}->${q} adjustedbw(${Math.round(P)})-bitrate=${Math.round(P-H)} ttfb:${F.toFixed(1)} avgDuration:${B.toFixed(1)} maxFetchDuration:${c.toFixed(1)} fetchDuration:${Z.toFixed(1)} firstSelection:${C} codecSet:${R} videoRange:${I} hls.loadLevel:${y}`)),C&&(this.firstSelection=q),q}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}}class Koe{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var Jr={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Yoe{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Y.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(Y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Y.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let s=r.length;s--;){const i=r[s];if(!i)break;const o=i.end;if(i.start<=e&&o!==null&&e<=o)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:r}=this,s=Object.keys(r);for(let i=s.length;i--;){const o=r[s[i]];if((o==null?void 0:o.body.type)===t&&o.buffered){const a=o.body;if(a.start<=e&&e<=a.end)return a}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);const i=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(o=>{const a=this.fragments[o];if(!a||i>=a.body.sn)return;if(!a.buffered&&!a.loaded){a.body.type===r&&this.removeFragment(a.body);return}const l=a.range[e];l&&l.time.some(c=>{const d=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return d&&this.removeFragment(a.body),d})})}detectPartialFragments(e){const t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;const i=vu(r),o=this.fragments[i];if(!o||o.buffered&&r.gap)return;const a=!r.relurl;Object.keys(t).forEach(l=>{const c=r.elementaryStreams[l];if(!c)return;const d=t[l],f=a||c.partial===!0;o.range[l]=this.getBufferedTimes(r,s,f,d)}),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,(o.body.endList=r.endList||o.body.endList)&&(this.endListFragments[o.body.type]=o),ng(o)||this.removeParts(r.sn-1,r.type)):this.removeFragment(o.body)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){const r=vu(e);let s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){const i={time:[],partial:r},o=e.start,a=e.end,l=e.minEndPTS||a,c=e.maxStartPTS||o;for(let d=0;d<s.length;d++){const f=s.start(d)-this.bufferPadding,p=s.end(d)+this.bufferPadding;if(c>=f&&l<=p){i.time.push({startPTS:Math.max(o,s.start(d)),endPTS:Math.min(a,s.end(d))});break}else if(o<p&&a>f){const m=Math.max(o,s.start(d)),g=Math.min(a,s.end(d));g>m&&(i.partial=!0,i.time.push({startPTS:m,endPTS:g}))}else if(a<=f)break}return i}getPartialFragment(e){let t=null,r,s,i,o=0;const{bufferPadding:a,fragments:l}=this;return Object.keys(l).forEach(c=>{const d=l[c];d&&ng(d)&&(s=d.body.start-a,i=d.body.end+a,e>=s&&e<=i&&(r=Math.min(e-s,i-e),o<=r&&(t=d.body,o=r)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||ng(t))}getState(e){const t=vu(e),r=this.fragments[t];return r?r.buffered?ng(r)?Jr.PARTIAL:Jr.OK:Jr.APPENDING:Jr.NOT_LOADED}isTimeBuffered(e,t,r){let s,i;for(let o=0;o<r.length;o++){if(s=r.start(o)-this.bufferPadding,i=r.end(o)+this.bufferPadding,e>=s&&t<=i)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){const{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;const i=s?null:t,o=vu(r);this.fragments[o]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:s,timeRanges:i}=t;if(r.sn==="initSegment")return;const o=r.type;if(s){let a=this.activePartLists[o];a||(this.activePartLists[o]=a=[]),a.push(s)}this.timeRanges=i,Object.keys(i).forEach(a=>{const l=i[a];this.detectEvictedFragments(a,l,o,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=vu(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,i){s&&!this.hasGaps||Object.keys(this.fragments).forEach(o=>{const a=this.fragments[o];if(!a)return;const l=a.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(a.buffered||i)&&this.removeFragment(l)})}removeFragment(e){const t=vu(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const s=e.sn;this.activePartLists[e.type]=r.filter(i=>i.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function ng(n){var e,t,r;return n.buffered&&(n.body.gap||((e=n.range.video)==null?void 0:e.partial)||((t=n.range.audio)==null?void 0:t.partial)||((r=n.range.audiovideo)==null?void 0:r.partial))}function vu(n){return`${n.type}_${n.level}_${n.sn}`}const Xoe={length:0,start:()=>0,end:()=>0};class Jn{static isBuffered(e,t){try{if(e){const r=Jn.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){const s=Jn.getBuffered(e),i=[];let o;for(o=0;o<s.length;o++)i.push({start:s.start(o),end:s.end(o)});return this.bufferedInfo(i,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(c,d){const f=c.start-d.start;return f||d.end-c.end});let s=[];if(r)for(let c=0;c<e.length;c++){const d=s.length;if(d){const f=s[d-1].end;e[c].start-f<r?e[c].end>f&&(s[d-1].end=e[c].end):s.push(e[c])}else s.push(e[c])}else s=e;let i=0,o,a=t,l=t;for(let c=0;c<s.length;c++){const d=s[c].start,f=s[c].end;if(t+r>=d&&t<f)a=d,l=f,i=l-t;else if(t+r<d){o=d;break}}return{len:i,start:a||0,end:l||0,nextStart:o}}static getBuffered(e){try{return e.buffered}catch(t){return he.log("failed to get media.buffered",t),Xoe}}}class rg{constructor(e,t,r,s=0,i=-1,o=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=sg(),this.buffering={audio:sg(),video:sg(),audiovideo:sg()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=i,this.partial=o}}function sg(){return{start:0,executeStart:0,executeEnd:0,end:0}}function ig(n,e){for(let r=0,s=n.length;r<s;r++){var t;if(((t=n[r])==null?void 0:t.cc)===e)return n[r]}return null}function Qoe(n,e,t){return!!(e&&(t.endCC>t.startCC||n&&n.cc<t.startCC))}function Joe(n,e){const t=n.fragments,r=e.fragments;if(!r.length||!t.length){he.log("No fragments to align");return}const s=ig(t,r[0].cc);if(!s||s&&!s.startPTS){he.log("No frag in previous level to align on");return}return s}function MB(n,e){if(n){const t=n.start+e;n.start=n.startPTS=t,n.endPTS=t+n.duration}}function NB(n,e){const t=e.fragments;for(let r=0,s=t.length;r<s;r++)MB(t[r],n);e.fragmentHint&&MB(e.fragmentHint,n),e.alignedSliding=!0}function Zoe(n,e,t){e&&(eae(n,t,e),!t.alignedSliding&&e&&og(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&bB(e,t))}function eae(n,e,t){if(Qoe(n,t,e)){const r=Joe(t,e);r&&bt(r.start)&&(he.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),NB(r.start,e))}}function og(n,e){if(!n.hasProgramDateTime||!e.hasProgramDateTime)return;const t=n.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,i;const o=Math.min(e.endCC,n.endCC);e.startCC<o&&n.startCC<o&&(s=ig(r,o),i=ig(t,o)),(!s||!i)&&(s=r[Math.floor(r.length/2)],i=ig(t,s.cc)||t[Math.floor(t.length/2)]);const a=s.programDateTime,l=i.programDateTime;if(!a||!l)return;const c=(l-a)/1e3-(i.start-s.start);NB(c,n)}const OB=Math.pow(2,17);class tae{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new aa({type:Gt.NETWORK_ERROR,details:Ce.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,i=s.fLoader,o=s.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(m=>m[0]==="GAP")){l(DB(e));return}else e.gap=!1;const c=this.loader=e.loader=i?new i(s):new o(s),d=PB(e),f=TB(s.fragLoadPolicy.default),p={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:OB};e.stats=c.stats,c.load(d,p,{onSuccess:(m,g,v,y)=>{this.resetLoader(e,c);let b=m.data;v.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(b.slice(0,16)),b=b.slice(16)),a({frag:e,part:null,payload:b,networkDetails:y})},onError:(m,g,v,y)=>{this.resetLoader(e,c),l(new aa({type:Gt.NETWORK_ERROR,details:Ce.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Xr({url:r,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:v,stats:y}))},onAbort:(m,g,v)=>{this.resetLoader(e,c),l(new aa({type:Gt.NETWORK_ERROR,details:Ce.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:v,stats:m}))},onTimeout:(m,g,v)=>{this.resetLoader(e,c),l(new aa({type:Gt.NETWORK_ERROR,details:Ce.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${p.timeout}ms`),networkDetails:v,stats:m}))},onProgress:(m,g,v,y)=>{t&&t({frag:e,part:null,payload:v,networkDetails:y})}})})}loadPart(e,t,r){this.abort();const s=this.config,i=s.fLoader,o=s.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(DB(e,t));return}const c=this.loader=e.loader=i?new i(s):new o(s),d=PB(e,t),f=TB(s.fragLoadPolicy.default),p={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:OB};t.stats=c.stats,c.load(d,p,{onSuccess:(m,g,v,y)=>{this.resetLoader(e,c),this.updateStatsFromPart(e,t);const b={frag:e,part:t,payload:m.data,networkDetails:y};r(b),a(b)},onError:(m,g,v,y)=>{this.resetLoader(e,c),l(new aa({type:Gt.NETWORK_ERROR,details:Ce.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Xr({url:d.url,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:v,stats:y}))},onAbort:(m,g,v)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,c),l(new aa({type:Gt.NETWORK_ERROR,details:Ce.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:v,stats:m}))},onTimeout:(m,g,v)=>{this.resetLoader(e,c),l(new aa({type:Gt.NETWORK_ERROR,details:Ce.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${p.timeout}ms`),networkDetails:v,stats:m}))}})})}updateStatsFromPart(e,t){const r=e.stats,s=t.stats,i=s.total;if(r.loaded+=s.loaded,i){const l=Math.round(e.duration/t.duration),c=Math.min(Math.round(r.loaded/i),l),f=(l-c)*Math.round(r.loaded/c);r.total=r.loaded+f}else r.total=Math.max(r.loaded,r.total);const o=r.loading,a=s.loading;o.start?o.first+=a.first-a.start:(o.start=a.start,o.first=a.first),o.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function PB(n,e=null){const t=e||n,r={frag:n,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,i=t.byteRangeEndOffset;if(bt(s)&&bt(i)){var o;let a=s,l=i;if(n.sn==="initSegment"&&((o=n.decryptdata)==null?void 0:o.method)==="AES-128"){const c=i-s;c%16&&(l=i+(16-c%16)),s!==0&&(r.resetIV=!0,a=s-16)}r.rangeStart=a,r.rangeEnd=l}return r}function DB(n,e){const t=new Error(`GAP ${n.gap?"tag":"attribute"} found`),r={type:Gt.MEDIA_ERROR,details:Ce.FRAG_GAP,fatal:!1,frag:n,error:t,networkDetails:null};return e&&(r.part=e),(e||n).stats.aborted=!0,new aa(r)}class aa extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class nae{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class rae{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function sae(n){const e=n.byteLength,t=e&&new DataView(n.buffer).getUint8(e-1);return t?ic(n,0,e-t):n}class iae{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],i=r[1],o=r[2],a=r[3],l=this.invSubMix,c=l[0],d=l[1],f=l[2],p=l[3],m=new Uint32Array(256);let g=0,v=0,y=0;for(y=0;y<256;y++)y<128?m[y]=y<<1:m[y]=y<<1^283;for(y=0;y<256;y++){let b=v^v<<1^v<<2^v<<3^v<<4;b=b>>>8^b&255^99,e[g]=b,t[b]=g;const S=m[g],E=m[S],C=m[E];let R=m[b]*257^b*16843008;s[g]=R<<24|R>>>8,i[g]=R<<16|R>>>16,o[g]=R<<8|R>>>24,a[g]=R,R=C*16843009^E*65537^S*257^g*16843008,c[b]=R<<24|R>>>8,d[b]=R<<16|R>>>16,f[b]=R<<8|R>>>24,p[b]=R,g?(g=S^m[m[m[C^S]]],v^=m[m[v]]):g=v=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;const i=this.keySize=t.length;if(i!==4&&i!==6&&i!==8)throw new Error("Invalid aes key size="+i);const o=this.ksRows=(i+6+1)*4;let a,l;const c=this.keySchedule=new Uint32Array(o),d=this.invKeySchedule=new Uint32Array(o),f=this.sBox,p=this.rcon,m=this.invSubMix,g=m[0],v=m[1],y=m[2],b=m[3];let S,E;for(a=0;a<o;a++){if(a<i){S=c[a]=t[a];continue}E=S,a%i===0?(E=E<<8|E>>>24,E=f[E>>>24]<<24|f[E>>>16&255]<<16|f[E>>>8&255]<<8|f[E&255],E^=p[a/i|0]<<24):i>6&&a%i===4&&(E=f[E>>>24]<<24|f[E>>>16&255]<<16|f[E>>>8&255]<<8|f[E&255]),c[a]=S=(c[a-i]^E)>>>0}for(l=0;l<o;l++)a=o-l,l&3?E=c[a]:E=c[a-4],l<4||a<=4?d[l]=E:d[l]=g[f[E>>>24]]^v[f[E>>>16&255]]^y[f[E>>>8&255]]^b[f[E&255]],d[l]=d[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){const s=this.keySize+6,i=this.invKeySchedule,o=this.invSBox,a=this.invSubMix,l=a[0],c=a[1],d=a[2],f=a[3],p=this.uint8ArrayToUint32Array_(r);let m=p[0],g=p[1],v=p[2],y=p[3];const b=new Int32Array(e),S=new Int32Array(b.length);let E,C,R,I,A,k,N,D,M,F,U,$,q,G;const V=this.networkToHostOrderSwap;for(;t<b.length;){for(M=V(b[t]),F=V(b[t+1]),U=V(b[t+2]),$=V(b[t+3]),A=M^i[0],k=$^i[1],N=U^i[2],D=F^i[3],q=4,G=1;G<s;G++)E=l[A>>>24]^c[k>>16&255]^d[N>>8&255]^f[D&255]^i[q],C=l[k>>>24]^c[N>>16&255]^d[D>>8&255]^f[A&255]^i[q+1],R=l[N>>>24]^c[D>>16&255]^d[A>>8&255]^f[k&255]^i[q+2],I=l[D>>>24]^c[A>>16&255]^d[k>>8&255]^f[N&255]^i[q+3],A=E,k=C,N=R,D=I,q=q+4;E=o[A>>>24]<<24^o[k>>16&255]<<16^o[N>>8&255]<<8^o[D&255]^i[q],C=o[k>>>24]<<24^o[N>>16&255]<<16^o[D>>8&255]<<8^o[A&255]^i[q+1],R=o[N>>>24]<<24^o[D>>16&255]<<16^o[A>>8&255]<<8^o[k&255]^i[q+2],I=o[D>>>24]<<24^o[A>>16&255]<<16^o[k>>8&255]<<8^o[N&255]^i[q+3],S[t]=V(E^m),S[t+1]=V(I^g),S[t+2]=V(R^v),S[t+3]=V(C^y),m=M,g=F,v=U,y=$,t=t+4}return S.buffer}}const oae=16;class OT{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?sae(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,i)=>{this.softwareDecrypt(new Uint8Array(e),t,r);const o=this.flush();o?s(o.buffer):i(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){const{currentIV:s,currentResult:i,remainderData:o}=this;this.logOnce("JS AES decrypt"),o&&(e=Ai(o,e),this.remainderData=null);const a=this.getValidChunk(e);if(!a.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new iae),l.expandKey(t);const c=i;return this.currentResult=l.decrypt(a.buffer,0,r),this.currentIV=ic(a,-16).buffer,c||null}webCryptoDecrypt(e,t,r){const s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new rae(s,t)),this.fastAesKey.expandKey().then(i=>s?(this.logOnce("WebCrypto AES decrypt"),new nae(s,new Uint8Array(r)).decrypt(e.buffer,i)):Promise.reject(new Error("web crypto not initialized"))).catch(i=>(he.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${i.name}: ${i.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%oae;return r!==e.length&&(t=ic(e,0,r),this.remainderData=ic(e,r)),t}logOnce(e){this.logEnabled&&(he.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const aae={toString:function(n){let e="";const t=n.length;for(let r=0;r<t;r++)e+=`[${n.start(r).toFixed(3)}-${n.end(r).toFixed(3)}]`;return e}},$e={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class ag extends Koe{constructor(e,t,r,s,i){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=$e.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=i,this.logPrefix=s,this.log=he.log.bind(he,`${s}:`),this.warn=he.warn.bind(he,`${s}:`),this.hls=e,this.fragmentLoader=new tae(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new OT(e.config),e.on(Y.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=$e.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const r=t.partList;if(r!=null&&r.length){const i=r[r.length-1];return Jn.isBuffered(this.media,i.start+i.duration/2)}const s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===$e.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:i}=this,o=r?r.currentTime:0,a=Jn.bufferInfo(s||r,o,e.maxBufferHole);if(this.log(`media seeking to ${bt(o)?o.toFixed(3):o}, state: ${i}`),this.state===$e.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,c=t.start-l,d=t.start+t.duration+l;if(!a.len||d<a.start||c>a.end){const f=o>d;(o<c||f)&&(f&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(o,1/0,this.playlistType,!0),this.lastCurrentTime=o),!this.loadedmetadata&&!a.len&&(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(Y.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=$e.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){const s=i=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${i.part?" p: "+i.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(i)};this._doFragLoad(e,t,r,s).then(i=>{if(!i)return;const o=this.state;if(this.fragContextChanged(e)){(o===$e.FRAG_LOADING||!this.fragCurrent&&o===$e.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=$e.IDLE);return}"payload"in i&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(Y.FRAG_LOADED,i)),this._handleFragmentLoadComplete(i)}).catch(i=>{this.state===$e.STOPPED||this.state===$e.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===Jr.APPENDING){const i=e.type,o=this.getFwdBufferInfo(this.mediaBuffer,i),a=Math.max(e.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(a)&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Jr.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:r};this.hls.trigger(Y.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{const{hls:s}=this,{payload:i}=r,o=e.decryptdata;if(i&&i.byteLength>0&&o!=null&&o.key&&o.iv&&o.method==="AES-128"){const a=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),o.key.buffer,o.iv.buffer).catch(l=>{throw s.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const c=self.performance.now();return s.trigger(Y.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:a,tdecrypt:c}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===$e.STOPPED||this.state===$e.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state=$e.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,i,o;const a=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===zt.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${a?aae.toString(Jn.getBuffered(a)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==zt.SUBTITLE){const d=e.elementaryStreams;if(!Object.keys(d).some(f=>!!d[f])){this.state=$e.IDLE;return}}const c=(l=this.levels)==null?void 0:l[e.level];c!=null&&c.fragmentError&&(this.log(`Resetting level fragment error count of ${c.fragmentError} on frag buffered`),c.fragmentError=0)}this.state=$e.IDLE,a&&(!this.loadedmetadata&&e.type==zt.MAIN&&a.buffered.length&&((i=this.fragCurrent)==null?void 0:i.sn)===((o=this.fragPrevious)==null?void 0:o.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:s,partsLoaded:i}=e,o=!i||i.length===0||i.some(l=>!l),a=new rg(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!o);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var i;const o=t==null?void 0:t.details;if(!this.levels||!o)throw new Error(`frag load aborted, missing level${o?"":" detail"}s`);let a=null;if(e.encrypted&&!((i=e.decryptdata)!=null&&i.key)?(this.log(`Loading key for ${e.sn} of [${o.startSN}-${o.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=$e.KEY_LOADING,this.fragCurrent=e,a=this.keyLoader.load(e).then(d=>{if(!this.fragContextChanged(d.frag))return this.hls.trigger(Y.KEY_LOADED,d),this.state===$e.KEY_LOADING&&(this.state=$e.IDLE),d}),this.hls.trigger(Y.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&o.encryptedFragments.length&&this.keyLoader.loadClear(e,o.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const d=o.partList;if(d&&s){r>e.end&&o.fragmentHint&&(e=o.fragmentHint);const f=this.getNextPart(d,e,r);if(f>-1){const p=d[f];this.log(`Loading part sn: ${e.sn} p: ${p.index} cc: ${e.cc} of playlist [${o.startSN}-${o.endSN}] parts [0-${f}-${d.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=p.start+p.duration,this.state=$e.FRAG_LOADING;let m;return a?m=a.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,p,t,s)).catch(g=>this.handleFragLoadError(g)):m=this.doFragPartsLoad(e,p,t,s).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(Y.FRAG_LOADING,{frag:e,part:p,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}else if(!e.url||this.loadedEndOfParts(d,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${o?"of ["+o.startSN+"-"+o.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),bt(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=$e.FRAG_LOADING;const l=this.config.progressive;let c;return l&&a?c=a.then(d=>!d||this.fragContextChanged(d==null?void 0:d.frag)?null:this.fragmentLoader.load(e,s)).catch(d=>this.handleFragLoadError(d)):c=Promise.all([this.fragmentLoader.load(e,l?s:void 0),a]).then(([d])=>(!l&&d&&s&&s(d),d)).catch(d=>this.handleFragLoadError(d)),this.hls.trigger(Y.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,r,s){return new Promise((i,o)=>{var a;const l=[],c=(a=r.details)==null?void 0:a.partList,d=f=>{this.fragmentLoader.loadPart(e,f,s).then(p=>{l[f.index]=p;const m=p.part;this.hls.trigger(Y.FRAG_LOADED,p);const g=xB(r,e.sn,f.index+1)||SB(c,e.sn,f.index+1);if(g)d(g);else return i({frag:e,part:m,partsLoaded:l})}).catch(o)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===Ce.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(Y.ERROR,t)}else this.hls.trigger(Y.ERROR,{type:Gt.OTHER_ERROR,details:Ce.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==$e.PARSING){!this.fragCurrent&&this.state!==$e.STOPPED&&this.state!==$e.ERROR&&(this.state=$e.IDLE);return}const{frag:r,part:s,level:i}=t,o=self.performance.now();r.stats.parsing.end=o,s&&(s.stats.parsing.end=o),this.updateLevelTiming(r,s,i,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:s,sn:i,part:o}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${i} of level ${s}. The current chunk will not be buffered.`),null;const a=t[s],l=o>-1?xB(a,i,o):null,c=l?l.fragment:Moe(a,i,r);return c?(r&&r!==c&&(c.stats=r.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,t,r,s,i){var o;if(!e||this.state!==$e.PARSING)return;const{data1:a,data2:l}=e;let c=a;if(a&&l&&(c=Ai(a,l)),!((o=c)!=null&&o.length))return;const d={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:c};if(this.hls.trigger(Y.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(i)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Jn.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const r=t.currentTime,s=Jn.bufferInfo(t,r,0),i=e.duration,o=Math.min(this.config.maxFragLookUpTolerance*2,i*.25),a=Math.max(Math.min(e.start-o,s.end-o),r+o);e.start-a>o&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){const r=this.getLoadPosition();return bt(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){const{config:{maxBufferHole:s}}=this,i=Jn.bufferInfo(e,t,s);if(i.len===0&&i.nextStart!==void 0){const o=this.fragmentTracker.getBufferedFrag(t,r);if(o&&i.nextStart<o.end)return Jn.bufferInfo(e,t,Math.max(i.nextStart,s))}return i}getMaxBufferLength(e){const{config:t}=this;let r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=zt.MAIN){const r=this.fragmentTracker.getAppendedFrag(e,zt.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,s=r.length;if(!s)return null;const{config:i}=this,o=r[0].start;let a;if(t.live){const l=i.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<o)&&(a=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=o&&(a=r[0]);if(!a){const l=i.lowLatencyMode?t.partEnd:t.fragmentEnd;a=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===Jr.OK||r===Jr.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,i){const o=e.gap,a=this.getNextFragment(this.nextLoadPosition,t);if(a===null)return a;if(e=a,o&&e&&!e.gap&&r.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=i)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,i=!1,o=!0;for(let a=0,l=e.length;a<l;a++){const c=e[a];if(o=o&&!c.independent,s>-1&&r<c.start)break;const d=c.loaded;d?s=-1:(i||c.independent||o)&&c.fragment===t&&(s=a),i=d}return s}loadedEndOfParts(e,t){const r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){const r=this.fragPrevious;let s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=Ooe(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const i=r.sn+1;if(i>=e.startSN&&i<=e.endSN){const o=t[i-e.startSN];r.cc===o.cc&&(s=o,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Doe(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const i=this.hls.liveSyncPosition;i!==null&&(s=this.getFragmentAtPosition(i,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){const{config:s}=this;let{fragPrevious:i}=this,{fragments:o,endSN:a}=r;const{fragmentHint:l}=r,c=s.maxFragLookUpTolerance,d=r.partList,f=!!(s.lowLatencyMode&&d!=null&&d.length&&l);f&&l&&!this.bitrateTest&&(o=o.concat(l),a=l.sn);let p;if(e<t){const m=e>t-c?0:c;p=eg(i,o,e,m)}else p=o[o.length-1];if(p){const m=p.sn-r.startSN,g=this.fragmentTracker.getState(p);if((g===Jr.OK||g===Jr.PARTIAL&&p.gap)&&(i=p),i&&p.sn===i.sn&&(!f||d[0].fragment.sn>p.sn)&&i&&p.level===i.level){const y=o[m+1];p.sn<a&&this.fragmentTracker.getState(y)!==Jr.OK?p=y:p=null}}return p}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const s=this.hls.liveSyncPosition,i=r.currentTime,o=e.fragments[0].start,a=e.edge,l=i>=o-t.maxFragLookUpTolerance&&i<=a;if(s!==null&&r.duration>s&&(i<s||!l)){const c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||i<a-c)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${i.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const i=e.fragments[0].start,o=!t,a=e.alignedSliding&&bt(i);if(o||!a&&!i){const{fragPrevious:l}=this;Zoe(l,r,e);const c=e.fragments[0].start;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),c}return i}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,i=s?this.startTimeOffset:e.startTimeOffset;i!==null&&bt(i)?(r=t+i,i<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${i} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==$e.FRAG_LOADING_WAITING_RETRY)&&(this.state=$e.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const d=this.getCurrentContext(t.chunkMeta);d&&(t.frag=d.frag)}const r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const i=t.details===Ce.FRAG_GAP;i&&this.fragmentTracker.fragBuffered(r,!0);const o=t.errorAction,{action:a,retryCount:l=0,retryConfig:c}=o||{};if(o&&a===Qr.RetryRequest&&c){this.resetStartWhenNotLoaded(this.levelLastLoaded);const d=MT(c,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${c.maxNumRetry} in ${d}ms`),o.resolved=!0,this.retryDate=self.performance.now()+d,this.state=$e.FRAG_LOADING_WAITING_RETRY}else if(c&&o)if(this.resetFragmentErrors(e),l<c.maxNumRetry)!i&&a!==Qr.RemoveAlternatePermanently&&(o.resolved=!0);else{he.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(o==null?void 0:o.action)===Qr.SendAlternateToPenaltyBox?this.state=$e.WAITING_LEVEL:this.state=$e.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===$e.PARSING||this.state===$e.PARSED){const t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len);const i=!s;return i&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),i}return!1}resetFragmentErrors(e){e===zt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==$e.STOPPED&&(this.state=$e.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;const s=Jn.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===$e.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=$e.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var i;const o=r.details;if(!o){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,c)=>{const d=e.elementaryStreams[c];if(d){const f=d.endPTS-d.startPTS;if(f<=0)return this.warn(`Could not parse fragment ${e.sn} ${c} duration reliably (${f})`),l||!1;const p=s?0:yB(o,e,d.startPTS,d.endPTS,d.startDTS,d.endDTS);return this.hls.trigger(Y.LEVEL_PTS_UPDATED,{details:o,level:r,drift:p,type:c,frag:e,start:d.startPTS,end:d.endPTS}),!0}return l},!1)&&((i=this.transmuxer)==null?void 0:i.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=$e.PARSED,this.hls.trigger(Y.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class jB{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;if(e.length)e.length===1?r=e[0]:r=lae(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}}function lae(n,e){const t=new Uint8Array(e);let r=0;for(let s=0;s<n.length;s++){const i=n[s];t.set(i,r),r+=i.length}return t}function cae(){return typeof __HLS_WORKER_BUNDLE__=="function"}function uae(){const n=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(n);return{worker:new self.Worker(e),objectURL:e}}function dae(n){const e=new self.URL(n,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Uo(n="",e=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class PT{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Ai(this.cachedData,e),this.cachedData=null);let r=Bf(e,0),s=r?r.length:0,i;const o=this._audioTrack,a=this._id3Track,l=r?_T(r):void 0,c=e.length;for((this.basePTS===null||this.frameIndex===0&&bt(l))&&(this.basePTS=fae(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ki.audioId3,duration:Number.POSITIVE_INFINITY});s<c;){if(this.canParse(e,s)){const d=this.appendFrame(o,e,s);d?(this.frameIndex++,this.lastPTS=d.sample.pts,s+=d.length,i=s):s=c}else jie(e,s)?(r=Bf(e,s),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ki.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,i=s):s++;if(s===c&&i!==c){const d=ic(e,i);this.cachedData?this.cachedData=Ai(this.cachedData,d):this.cachedData=d}}return{audioTrack:o,videoTrack:Uo(),id3Track:a,textTrack:Uo()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Uo(),id3Track:this._id3Track,textTrack:Uo()}}destroy(){}}const fae=(n,e,t)=>{if(bt(n))return n*90;const r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function hae(n,e,t,r){let s,i,o,a;const l=navigator.userAgent.toLowerCase(),c=r,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;const f=(e[t+2]&60)>>>2;if(f>d.length-1){const p=new Error(`invalid ADTS sampling index:${f}`);n.emit(Y.ERROR,Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_PARSING_ERROR,fatal:!0,error:p,reason:p.message});return}return o=(e[t+2]&1)<<2,o|=(e[t+3]&192)>>>6,he.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${f}`),/firefox/i.test(l)?f>=6?(s=5,a=new Array(4),i=f-3):(s=2,a=new Array(2),i=f):l.indexOf("android")!==-1?(s=2,a=new Array(2),i=f):(s=5,a=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&f>=6?i=f-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(f>=6&&o===1||/vivaldi/i.test(l))||!r&&o===1)&&(s=2,a=new Array(2)),i=f)),a[0]=s<<3,a[0]|=(f&14)>>1,a[1]|=(f&1)<<7,a[1]|=o<<3,s===5&&(a[1]|=(i&14)>>1,a[2]=(i&1)<<7,a[2]|=8,a[3]=0),{config:a,samplerate:d[f],channelCount:o,codec:"mp4a.40."+s,manifestCodec:c}}function FB(n,e){return n[e]===255&&(n[e+1]&246)===240}function UB(n,e){return n[e+1]&1?7:9}function DT(n,e){return(n[e+3]&3)<<11|n[e+4]<<3|(n[e+5]&224)>>>5}function pae(n,e){return e+5<n.length}function lg(n,e){return e+1<n.length&&FB(n,e)}function mae(n,e){return pae(n,e)&&FB(n,e)&&DT(n,e)<=n.length-e}function gae(n,e){if(lg(n,e)){const t=UB(n,e);if(e+t>=n.length)return!1;const r=DT(n,e);if(r<=t)return!1;const s=e+r;return s===n.length||lg(n,s)}return!1}function BB(n,e,t,r,s){if(!n.samplerate){const i=hae(e,t,r,s);if(!i)return;n.config=i.config,n.samplerate=i.samplerate,n.channelCount=i.channelCount,n.codec=i.codec,n.manifestCodec=i.manifestCodec,he.log(`parsed codec:${n.codec}, rate:${i.samplerate}, channels:${i.channelCount}`)}}function $B(n){return 9216e4/n}function _ae(n,e){const t=UB(n,e);if(e+t<=n.length){const r=DT(n,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function zB(n,e,t,r,s){const i=$B(n.samplerate),o=r+s*i,a=_ae(e,t);let l;if(a){const{frameLength:f,headerLength:p}=a,m=p+f,g=Math.max(0,t+m-e.length);g?(l=new Uint8Array(m-p),l.set(e.subarray(t+p,e.length),0)):l=e.subarray(t+p,t+m);const v={unit:l,pts:o};return g||n.samples.push(v),{sample:v,length:m,missing:g}}const c=e.length-t;return l=new Uint8Array(c),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:o},length:c,missing:-1}}let cg=null;const vae=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],yae=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],bae=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],xae=[0,1,1,4];function qB(n,e,t,r,s){if(t+24>e.length)return;const i=HB(e,t);if(i&&t+i.frameLength<=e.length){const o=i.samplesPerFrame*9e4/i.sampleRate,a=r+s*o,l={unit:e.subarray(t,t+i.frameLength),pts:a,dts:a};return n.config=[],n.channelCount=i.channelCount,n.samplerate=i.sampleRate,n.samples.push(l),{sample:l,length:i.frameLength,missing:0}}}function HB(n,e){const t=n[e+1]>>3&3,r=n[e+1]>>1&3,s=n[e+2]>>4&15,i=n[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&i!==3){const o=n[e+2]>>1&1,a=n[e+3]>>6,l=t===3?3-r:r===3?3:4,c=vae[l*14+s-1]*1e3,f=yae[(t===3?0:t===2?1:2)*3+i],p=a===3?1:2,m=bae[t][r],g=xae[r],v=m*8*g,y=Math.floor(m*c/f+o)*g;if(cg===null){const E=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);cg=E?parseInt(E[1]):0}return!!cg&&cg<=87&&r===2&&c>=224e3&&a===0&&(n[e+3]=n[e+3]|128),{sampleRate:f,channelCount:p,frameLength:y,samplesPerFrame:v}}}function jT(n,e){return n[e]===255&&(n[e+1]&224)===224&&(n[e+1]&6)!==0}function GB(n,e){return e+1<n.length&&jT(n,e)}function Sae(n,e){return jT(n,e)&&4<=n.length-e}function VB(n,e){if(e+1<n.length&&jT(n,e)){const r=HB(n,e);let s=4;r!=null&&r.frameLength&&(s=r.frameLength);const i=e+s;return i===n.length||GB(n,i)}return!1}class Eae extends PT{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Bf(e,0);let r=(t==null?void 0:t.length)||0;if(VB(e,r))return!1;for(let s=e.length;r<s;r++)if(gae(e,r))return he.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return mae(e,t)}appendFrame(e,t,r){BB(e,this.observer,t,r,e.manifestCodec);const s=zB(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const wae=/\/emsg[-/]ID3/i;class Tae{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){const i=this.videoTrack=Uo("video",1),o=this.audioTrack=Uo("audio",1),a=this.txtTrack=Uo("text",1);if(this.id3Track=Uo("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=KU(e);if(l.video){const{id:c,timescale:d,codec:f}=l.video;i.id=c,i.timescale=a.timescale=d,i.codec=f}if(l.audio){const{id:c,timescale:d,codec:f}=l.audio;o.id=c,o.timescale=d,o.codec=f}a.id=HU.text,i.sampleDuration=0,i.duration=o.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return Vie(e)}demux(e,t){this.timeOffset=t;let r=e;const s=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ai(this.remainderData,e));const a=eoe(r);this.remainderData=a.remainder,s.samples=a.valid||new Uint8Array}else s.samples=r;const o=this.extractID3Track(s,t);return i.samples=XU(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return r.samples=XU(e,t),{videoTrack:t,audioTrack:Uo(),id3Track:s,textTrack:Uo()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const s=on(e.samples,["emsg"]);s&&s.forEach(i=>{const o=roe(i);if(wae.test(o.schemeIdUri)){const a=bt(o.presentationTime)?o.presentationTime/o.timeScale:t+o.presentationTimeDelta/o.timeScale;let l=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const c=o.payload;r.samples.push({data:c,len:c.byteLength,dts:a,pts:a,type:ki.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const WB=(n,e)=>{let t=0,r=5;e+=r;const s=new Uint32Array(1),i=new Uint32Array(1),o=new Uint8Array(1);for(;r>0;){o[0]=n[e];const a=Math.min(r,8),l=8-a;i[0]=4278190080>>>24+l<<l,s[0]=(o[0]&i[0])>>l,t=t?t<<a|s[0]:s[0],e+=1,r-=a}return t};class Cae extends PT{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const s=KB(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;const t=Bf(e,0);if(!t)return!1;const r=t.length;return e[r]===11&&e[r+1]===119&&_T(t)!==void 0&&WB(e,r)<16}}function KB(n,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const i=e[t+4]>>6;if(i>=3)return-1;const a=[48e3,44100,32e3][i],l=e[t+4]&63,d=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+i]*2;if(t+d>e.length)return-1;const f=e[t+6]>>5;let p=0;f===2?p+=2:(f&1&&f!==1&&(p+=2),f&4&&(p+=2));const m=(e[t+6]<<8|e[t+7])>>12-p&1,v=[2,1,2,3,3,4,4,5][f]+m,y=e[t+5]>>3,b=e[t+5]&7,S=new Uint8Array([i<<6|y<<1|b>>2,(b&3)<<6|f<<3|m<<2|l>>4,l<<4&224]),E=1536/a*9e4,C=r+s*E,R=e.subarray(t,t+d);return n.config=S,n.channelCount=v,n.samplerate=a,n.samples.push({unit:R,pts:C}),d}class Iae{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){const i=r.units;s=i[i.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const r=t.samples,s=r.length;if(s){const i=r[s-1];e.pts=i.pts,e.dts=i.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&he.log(e.pts+"/"+e.dts+":"+e.debug)}}class YB{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),i=Math.min(4,t);if(i===0)throw new Error("no bytes available");s.set(e.subarray(r,r+i)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=i*8,this.bytesAvailable-=i}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&he.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let i=0;i<e;i++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,i,o,a;const l=this.readUByte.bind(this),c=this.readBits.bind(this),d=this.readUEG.bind(this),f=this.readBoolean.bind(this),p=this.skipBits.bind(this),m=this.skipEG.bind(this),g=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);l();const y=l();if(c(5),p(3),l(),g(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){const I=d();if(I===3&&p(1),g(),g(),p(1),f())for(o=I!==3?8:12,a=0;a<o;a++)f()&&(a<6?v(16):v(64))}g();const b=d();if(b===0)d();else if(b===1)for(p(1),m(),m(),i=d(),a=0;a<i;a++)m();g(),p(1);const S=d(),E=d(),C=c(1);C===0&&p(1),p(1),f()&&(e=d(),t=d(),r=d(),s=d());let R=[1,1];if(f()&&f())switch(l()){case 1:R=[1,1];break;case 2:R=[12,11];break;case 3:R=[10,11];break;case 4:R=[16,11];break;case 5:R=[40,33];break;case 6:R=[24,11];break;case 7:R=[20,11];break;case 8:R=[32,11];break;case 9:R=[80,33];break;case 10:R=[18,11];break;case 11:R=[15,11];break;case 12:R=[64,33];break;case 13:R=[160,99];break;case 14:R=[4,3];break;case 15:R=[3,2];break;case 16:R=[2,1];break;case 255:{R=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((S+1)*16-e*2-t*2),height:(2-C)*(E+1)*16-(C?2:4)*(r+s),pixelRatio:R}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Rae extends Iae{parseAVCPES(e,t,r,s,i){const o=this.parseAVCNALu(e,r.data);let a=this.VideoSample,l,c=!1;r.data=null,a&&o.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),o.forEach(d=>{var f;switch(d.type){case 1:{let v=!1;l=!0;const y=d.data;if(c&&y.length>4){const b=new YB(y).readSliceType();(b===2||b===4||b===7||b===9)&&(v=!0)}if(v){var p;(p=a)!=null&&p.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),a.frame=!0,a.key=v;break}case 5:l=!0,(f=a)!=null&&f.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),a.key=!0,a.frame=!0;break;case 6:{l=!0,QU(d.data,1,r.pts,t.samples);break}case 7:{var m,g;l=!0,c=!0;const v=d.data,b=new YB(v).readSPS();if(!e.sps||e.width!==b.width||e.height!==b.height||((m=e.pixelRatio)==null?void 0:m[0])!==b.pixelRatio[0]||((g=e.pixelRatio)==null?void 0:g[1])!==b.pixelRatio[1]){e.width=b.width,e.height=b.height,e.pixelRatio=b.pixelRatio,e.sps=[v],e.duration=i;const S=v.subarray(1,4);let E="avc1.";for(let C=0;C<3;C++){let R=S[C].toString(16);R.length<2&&(R="0"+R),E+=R}e.codec=E}break}case 8:l=!0,e.pps=[d.data];break;case 9:l=!0,e.audFound=!0,a&&this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,a&&(a.debug+="unknown NAL "+d.type+" ");break}a&&l&&a.units.push(d)}),s&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}parseAVCNALu(e,t){const r=t.byteLength;let s=e.naluState||0;const i=s,o=[];let a=0,l,c,d,f=-1,p=0;for(s===-1&&(f=0,p=t[0]&31,s=0,a=1);a<r;){if(l=t[a++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(c=a-s-1,f>=0){const m={data:t.subarray(f,c),type:p};o.push(m)}else{const m=this.getLastNalUnit(e.samples);m&&(i&&a<=4-i&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-i)),c>0&&(m.data=Ai(m.data,t.subarray(0,c)),m.state=0))}a<r?(d=t[a]&31,f=a,p=d,s=0):s=-1}else s=0}if(f>=0&&s>=0){const m={data:t.subarray(f,r),type:p,state:s};o.push(m)}if(o.length===0){const m=this.getLastNalUnit(e.samples);m&&(m.data=Ai(m.data,t))}return e.naluState=s,o}}class Aae{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new OT(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){const s=e[t].unit;if(s.length<=16)return;const i=s.subarray(16,s.length-s.length%16),o=i.buffer.slice(i.byteOffset,i.byteOffset+i.length);this.decryptBuffer(o).then(a=>{const l=new Uint8Array(a);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t);let s=0;for(let i=32;i<e.length-16;i+=160,s+=16)r.set(e.subarray(i,i+16),s);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let s=0;for(let i=32;i<e.length-16;i+=160,s+=16)e.set(r.subarray(s,s+16),i);return e}decryptAvcSample(e,t,r,s,i){const o=JU(i.data),a=this.getAvcEncryptedData(o);this.decryptBuffer(a.buffer).then(l=>{i.data=this.getAvcDecryptedUnit(o,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}const i=e[t].units;for(;!(r>=i.length);r++){const o=i[r];if(!(o.data.length<=48||o.type!==1&&o.type!==5)&&(this.decryptAvcSample(e,t,r,s,o),!this.decrypter.isSync()))return}}}}const Zr=188;class Ka{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new Rae}static probe(e){const t=Ka.syncOffset(e);return t>0&&he.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let r=Math.min(Zr*5,t-Zr)+1,s=0;for(;s<r;){let i=!1,o=-1,a=0;for(let l=s;l<t;l+=Zr)if(e[l]===71&&(t-l===Zr||e[l+Zr]===71)){if(a++,o===-1&&(o=l,o!==0&&(r=Math.min(o+Zr*99,e.length-Zr)+1)),i||(i=FT(e,l)===0),i&&a>1&&(o===0&&a>2||l+Zr>r))return o}else{if(a)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:HU[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Ka.createTrack("video"),this._audioTrack=Ka.createTrack("audio",s),this._id3Track=Ka.createTrack("id3"),this._txtTrack=Ka.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let i;const o=this._videoTrack,a=this._audioTrack,l=this._id3Track,c=this._txtTrack;let d=o.pid,f=o.pesData,p=a.pid,m=l.pid,g=a.pesData,v=l.pesData,y=null,b=this.pmtParsed,S=this._pmtId,E=e.length;if(this.remainderData&&(e=Ai(this.remainderData,e),E=e.length,this.remainderData=null),E<Zr&&!s)return this.remainderData=e,{audioTrack:a,videoTrack:o,id3Track:l,textTrack:c};const C=Math.max(0,Ka.syncOffset(e));E-=(E-C)%Zr,E<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,E,e.buffer.byteLength-E));let R=0;for(let A=C;A<E;A+=Zr)if(e[A]===71){const k=!!(e[A+1]&64),N=FT(e,A),D=(e[A+3]&48)>>4;let M;if(D>1){if(M=A+5+e[A+4],M===A+Zr)continue}else M=A+4;switch(N){case d:k&&(f&&(i=yu(f))&&this.videoParser.parseAVCPES(o,c,i,!1,this._duration),f={data:[],size:0}),f&&(f.data.push(e.subarray(M,A+Zr)),f.size+=A+Zr-M);break;case p:if(k){if(g&&(i=yu(g)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,i);break;case"mp3":this.parseMPEGPES(a,i);break;case"ac3":this.parseAC3PES(a,i);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(M,A+Zr)),g.size+=A+Zr-M);break;case m:k&&(v&&(i=yu(v))&&this.parseID3PES(l,i),v={data:[],size:0}),v&&(v.data.push(e.subarray(M,A+Zr)),v.size+=A+Zr-M);break;case 0:k&&(M+=e[M]+1),S=this._pmtId=kae(e,M);break;case S:{k&&(M+=e[M]+1);const F=Lae(e,M,this.typeSupported,r);d=F.videoPid,d>0&&(o.pid=d,o.segmentCodec=F.segmentVideoCodec),p=F.audioPid,p>0&&(a.pid=p,a.segmentCodec=F.segmentAudioCodec),m=F.id3Pid,m>0&&(l.pid=m),y!==null&&!b&&(he.warn(`MPEG-TS PMT found at ${A} after unknown PID '${y}'. Backtracking to sync byte @${C} to parse all TS packets.`),y=null,A=C-188),b=this.pmtParsed=!0;break}case 17:case 8191:break;default:y=N;break}}else R++;if(R>0){const A=new Error(`Found ${R} TS packet/s that do not start with 0x47`);this.observer.emit(Y.ERROR,Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_PARSING_ERROR,fatal:!1,error:A,reason:A.message})}o.pesData=f,a.pesData=g,l.pesData=v;const I={audioTrack:a,videoTrack:o,id3Track:l,textTrack:c};return s&&this.extractRemainingSamples(I),I}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:s,textTrack:i}=e,o=r.pesData,a=t.pesData,l=s.pesData;let c;if(o&&(c=yu(o))?(this.videoParser.parseAVCPES(r,i,c,!0,this._duration),r.pesData=null):r.pesData=o,a&&(c=yu(a))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,c);break;case"mp3":this.parseMPEGPES(t,c);break;case"ac3":this.parseAC3PES(t,c);break}t.pesData=null}else a!=null&&a.size&&he.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;l&&(c=yu(l))?(this.parseID3PES(s,c),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){const s=this.demux(e,r,!0,!this.config.progressive),i=this.sampleAes=new Aae(this.observer,this.config,t);return this.decrypt(s,i)}decrypt(e,t){return new Promise(r=>{const{audioTrack:s,videoTrack:i}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{i.samples?t.decryptAvcSamples(i.samples,0,0,()=>{r(e)}):r(e)}):i.samples&&t.decryptAvcSamples(i.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0;const s=this.aacOverFlow;let i=t.data;if(s){this.aacOverFlow=null;const f=s.missing,p=s.sample.unit.byteLength;if(f===-1)i=Ai(s.sample.unit,i);else{const m=p-f;s.sample.unit.set(i.subarray(0,f),m),e.samples.push(s.sample),r=s.missing}}let o,a;for(o=r,a=i.length;o<a-1&&!lg(i,o);o++);if(o!==r){let f;const p=o<a-1;p?f=`AAC PES did not start with ADTS header,offset:${o}`:f="No ADTS header found in AAC PES";const m=new Error(f);if(he.warn(`parsing error: ${f}`),this.observer.emit(Y.ERROR,Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_PARSING_ERROR,fatal:!1,levelRetry:p,error:m,reason:f}),!p)return}BB(e,this.observer,i,o,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){const f=$B(e.samplerate);l=s.sample.pts+f}else{he.warn("[tsdemuxer]: AAC PES unknown PTS");return}let c=0,d;for(;o<a;)if(d=zB(e,i,o,l,c),o+=d.length,d.missing){this.aacOverFlow=d;break}else for(c++;o<a-1&&!lg(i,o);o++);}parseMPEGPES(e,t){const r=t.data,s=r.length;let i=0,o=0;const a=t.pts;if(a===void 0){he.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<s;)if(GB(r,o)){const l=qB(e,r,o,a,i);if(l)o+=l.length,i++;else break}else o++}parseAC3PES(e,t){{const r=t.data,s=t.pts;if(s===void 0){he.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const i=r.length;let o=0,a=0,l;for(;a<i&&(l=KB(e,r,a,s,o++))>0;)a+=l}}parseID3PES(e,t){if(t.pts===void 0){he.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const r=Or({},t,{type:this._videoTrack?ki.emsg:ki.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function FT(n,e){return((n[e+1]&31)<<8)+n[e+2]}function kae(n,e){return(n[e+10]&31)<<8|n[e+11]}function Lae(n,e,t,r){const s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},i=(n[e+1]&15)<<8|n[e+2],o=e+3+i-4,a=(n[e+10]&15)<<8|n[e+11];for(e+=12+a;e<o;){const l=FT(n,e),c=(n[e+3]&15)<<8|n[e+4];switch(n[e]){case 207:if(!r){UT("ADTS AAC");break}case 15:s.audioPid===-1&&(s.audioPid=l);break;case 21:s.id3Pid===-1&&(s.id3Pid=l);break;case 219:if(!r){UT("H.264");break}case 27:s.videoPid===-1&&(s.videoPid=l,s.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?he.log("MPEG audio found, not supported in this browser"):s.audioPid===-1&&(s.audioPid=l,s.segmentAudioCodec="mp3");break;case 193:if(!r){UT("AC-3");break}case 129:t.ac3?s.audioPid===-1&&(s.audioPid=l,s.segmentAudioCodec="ac3"):he.log("AC-3 audio found, not supported in this browser");break;case 6:if(s.audioPid===-1&&c>0){let d=e+5,f=c;for(;f>2;){switch(n[d]){case 106:t.ac3!==!0?he.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");break}const m=n[d+1]+2;d+=m,f-=m}}break;case 194:case 135:he.warn("Unsupported EC-3 in M2TS found");break;case 36:he.warn("Unsupported HEVC in M2TS found");break}e+=c+5}return s}function UT(n){he.log(`${n} with AES-128-CBC encryption found in unencrypted stream`)}function yu(n){let e=0,t,r,s,i,o;const a=n.data;if(!n||n.size===0)return null;for(;a[0].length<19&&a.length>1;)a[0]=Ai(a[0],a[1]),a.splice(1,1);if(t=a[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>n.size-6)return null;const c=t[7];c&192&&(i=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,c&64?(o=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,i-o>54e5&&(he.warn(`${Math.round((i-o)/9e4)}s delta between PTS and DTS, align them`),i=o)):o=i),s=t[8];let d=s+9;if(n.size<=d)return null;n.size-=d;const f=new Uint8Array(n.size);for(let p=0,m=a.length;p<m;p++){t=a[p];let g=t.byteLength;if(d)if(d>g){d-=g;continue}else t=t.subarray(d),g-=d,d=0;f.set(t,e),e+=g}return r&&(r-=s+3),{data:f,pts:i,dts:o,len:r}}return null}class Mae extends PT{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Bf(e,0);let r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&_T(t)!==void 0&&WB(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(VB(e,r))return he.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Sae(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return qB(e,t,r,this.basePTS,this.frameIndex)}}class XB{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Ya=Math.pow(2,32)-1;class ve{static init(){ve.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in ve.types)ve.types.hasOwnProperty(e)&&(ve.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);ve.HDLR_TYPES={video:t,audio:r};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);ve.STTS=ve.STSC=ve.STCO=i,ve.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),ve.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),ve.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),ve.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const o=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);ve.FTYP=ve.box(ve.types.ftyp,o,l,o,a),ve.DINF=ve.box(ve.types.dinf,ve.box(ve.types.dref,s))}static box(e,...t){let r=8,s=t.length;const i=s;for(;s--;)r+=t[s].byteLength;const o=new Uint8Array(r);for(o[0]=r>>24&255,o[1]=r>>16&255,o[2]=r>>8&255,o[3]=r&255,o.set(e,4),s=0,r=8;s<i;s++)o.set(t[s],r),r+=t[s].byteLength;return o}static hdlr(e){return ve.box(ve.types.hdlr,ve.HDLR_TYPES[e])}static mdat(e){return ve.box(ve.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(Ya+1)),s=Math.floor(t%(Ya+1));return ve.box(ve.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return ve.box(ve.types.mdia,ve.mdhd(e.timescale,e.duration),ve.hdlr(e.type),ve.minf(e))}static mfhd(e){return ve.box(ve.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?ve.box(ve.types.minf,ve.box(ve.types.smhd,ve.SMHD),ve.DINF,ve.stbl(e)):ve.box(ve.types.minf,ve.box(ve.types.vmhd,ve.VMHD),ve.DINF,ve.stbl(e))}static moof(e,t,r){return ve.box(ve.types.moof,ve.mfhd(e),ve.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=ve.trak(e[t]);return ve.box.apply(null,[ve.types.moov,ve.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(ve.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=ve.trex(e[t]);return ve.box.apply(null,[ve.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(Ya+1)),s=Math.floor(t%(Ya+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return ve.box(ve.types.mvhd,i)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let s,i;for(s=0;s<t.length;s++)i=t[s].flags,r[s+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return ve.box(ve.types.sdtp,r)}static stbl(e){return ve.box(ve.types.stbl,ve.stsd(e),ve.box(ve.types.stts,ve.STTS),ve.box(ve.types.stsc,ve.STSC),ve.box(ve.types.stsz,ve.STSZ),ve.box(ve.types.stco,ve.STCO))}static avc1(e){let t=[],r=[],s,i,o;for(s=0;s<e.sps.length;s++)i=e.sps[s],o=i.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(i));for(s=0;s<e.pps.length;s++)i=e.pps[s],o=i.byteLength,r.push(o>>>8&255),r.push(o&255),r=r.concat(Array.prototype.slice.call(i));const a=ve.box(ve.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,c=e.height,d=e.pixelRatio[0],f=e.pixelRatio[1];return ve.box(ve.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,c>>8&255,c&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,ve.box(ve.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),ve.box(ve.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,f>>24,f>>16&255,f>>8&255,f&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return ve.box(ve.types.mp4a,ve.audioStsd(e),ve.box(ve.types.esds,ve.esds(e)))}static mp3(e){return ve.box(ve.types[".mp3"],ve.audioStsd(e))}static ac3(e){return ve.box(ve.types["ac-3"],ve.audioStsd(e),ve.box(ve.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?ve.box(ve.types.stsd,ve.STSD,ve.mp3(e)):e.segmentCodec==="ac3"?ve.box(ve.types.stsd,ve.STSD,ve.ac3(e)):ve.box(ve.types.stsd,ve.STSD,ve.mp4a(e)):ve.box(ve.types.stsd,ve.STSD,ve.avc1(e))}static tkhd(e){const t=e.id,r=e.duration*e.timescale,s=e.width,i=e.height,o=Math.floor(r/(Ya+1)),a=Math.floor(r%(Ya+1));return ve.box(ve.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,a>>24,a>>16&255,a>>8&255,a&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,i>>8&255,i&255,0,0]))}static traf(e,t){const r=ve.sdtp(e),s=e.id,i=Math.floor(t/(Ya+1)),o=Math.floor(t%(Ya+1));return ve.box(ve.types.traf,ve.box(ve.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),ve.box(ve.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,i&255,o>>24,o>>16&255,o>>8&255,o&255])),ve.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,ve.box(ve.types.trak,ve.tkhd(e),ve.mdia(e))}static trex(e){const t=e.id;return ve.box(ve.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],s=r.length,i=12+16*s,o=new Uint8Array(i);let a,l,c,d,f,p;for(t+=8+i,o.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),a=0;a<s;a++)l=r[a],c=l.duration,d=l.size,f=l.flags,p=l.cts,o.set([c>>>24&255,c>>>16&255,c>>>8&255,c&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,f.degradPrio&61440,f.degradPrio&15,p>>>24&255,p>>>16&255,p>>>8&255,p&255],12+16*a);return ve.box(ve.types.trun,o)}static initSegment(e){ve.types||ve.init();const t=ve.moov(e);return Ai(ve.FTYP,t)}}ve.types=void 0,ve.HDLR_TYPES=void 0,ve.STTS=void 0,ve.STSC=void 0,ve.STCO=void 0,ve.STSZ=void 0,ve.VMHD=void 0,ve.SMHD=void 0,ve.STSD=void 0,ve.FTYP=void 0,ve.DINF=void 0;const QB=9e4;function BT(n,e,t=1,r=!1){const s=n*e*t;return r?Math.round(s):s}function Nae(n,e,t=1,r=!1){return BT(n,e,1/t,r)}function zf(n,e=!1){return BT(n,1e3,1/QB,e)}function Oae(n,e=1){return BT(n,QB,1/e)}const Pae=10*1e3,JB=1024,Dae=1152,jae=1536;let bu=null,$T=null;class ug{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,bu===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);bu=o?parseInt(o[1]):0}if($T===null){const i=navigator.userAgent.match(/Safari\/(\d+)/i);$T=i?parseInt(i[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){he.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){he.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){he.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e.reduce((s,i)=>{const o=i.pts-s;return o<-4294967296?(t=!0,Mi(s,i.pts)):o>0?s:i.pts},e[0].pts);return t&&he.debug("PTS rollover detected"),r}remux(e,t,r,s,i,o,a,l){let c,d,f,p,m,g,v=i,y=i;const b=e.pid>-1,S=t.pid>-1,E=t.samples.length,C=e.samples.length>0,R=a&&E>0||E>1;if((!b||C)&&(!S||R)||this.ISGenerated||a){if(this.ISGenerated){var A,k,N,D;const $=this.videoTrackConfig;$&&(t.width!==$.width||t.height!==$.height||((A=t.pixelRatio)==null?void 0:A[0])!==((k=$.pixelRatio)==null?void 0:k[0])||((N=t.pixelRatio)==null?void 0:N[1])!==((D=$.pixelRatio)==null?void 0:D[1]))&&this.resetInitSegment()}else f=this.generateIS(e,t,i,o);const M=this.isVideoContiguous;let F=-1,U;if(R&&(F=Fae(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,F>0){he.warn(`[mp4-remuxer]: Dropped ${F} out of ${E} video samples due to a missing keyframe`);const $=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(F),t.dropped+=F,y+=(t.samples[0].pts-$)/t.inputTimeScale,U=y}else F===-1&&(he.warn(`[mp4-remuxer]: No keyframe found out of ${E} video samples`),g=!1);if(this.ISGenerated){if(C&&R){const $=this.getVideoStartPts(t.samples),G=(Mi(e.samples[0].pts,$)-$)/t.inputTimeScale;v+=Math.max(0,G),y+=Math.max(0,-G)}if(C){if(e.samplerate||(he.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(e,t,i,o)),d=this.remuxAudio(e,v,this.isAudioContiguous,o,S||R||l===zt.AUDIO?y:void 0),R){const $=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(he.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),f=this.generateIS(e,t,i,o)),c=this.remuxVideo(t,y,M,$)}}else R&&(c=this.remuxVideo(t,y,M,0));c&&(c.firstKeyFrame=F,c.independent=F!==-1,c.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(m=ZB(r,i,this._initPTS,this._initDTS)),s.samples.length&&(p=e$(s,i,this._initPTS))),{audio:d,video:c,initSegment:f,independent:g,text:p,id3:m}}generateIS(e,t,r,s){const i=e.samples,o=t.samples,a=this.typeSupported,l={},c=this._initPTS;let d=!c||s,f="audio/mp4",p,m,g;if(d&&(p=m=1/0),e.config&&i.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:f,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&a.mpeg?new Uint8Array(0):ve.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(g=e.inputTimeScale,!c||g!==c.timescale?p=m=i[0].pts-Math.round(g*r):d=!1)}if(t.sps&&t.pps&&o.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ve.initSegment([t]),metadata:{width:t.width,height:t.height}},d)if(g=t.inputTimeScale,!c||g!==c.timescale){const v=this.getVideoStartPts(o),y=Math.round(g*r);m=Math.min(m,Mi(o[0].dts,v)-y),p=Math.min(p,v-y)}else d=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:p,timescale:g},this._initDTS={baseTime:m,timescale:g}):p=g=void 0,{tracks:l,initPTS:p,timescale:g}}remuxVideo(e,t,r,s){const i=e.inputTimeScale,o=e.samples,a=[],l=o.length,c=this._initPTS;let d=this.nextAvcDts,f=8,p=this.videoSampleDuration,m,g,v=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,b=!1;if(!r||d===null){const B=t*i,P=o[0].pts-Mi(o[0].dts,o[0].pts);bu&&d!==null&&Math.abs(B-P-d)<15e3?r=!0:d=B-P}const S=c.baseTime*i/c.timescale;for(let B=0;B<l;B++){const P=o[B];P.pts=Mi(P.pts-S,d),P.dts=Mi(P.dts-S,d),P.dts<o[B>0?B-1:B].dts&&(b=!0)}b&&o.sort(function(B,P){const H=B.dts-P.dts,Z=B.pts-P.pts;return H||Z}),m=o[0].dts,g=o[o.length-1].dts;const E=g-m,C=E?Math.round(E/(l-1)):p||e.inputTimeScale/30;if(r){const B=m-d,P=B>C,H=B<-1;if((P||H)&&(P?he.warn(`AVC: ${zf(B,!0)} ms (${B}dts) hole between fragments detected at ${t.toFixed(3)}`):he.warn(`AVC: ${zf(-B,!0)} ms (${B}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!H||d>=o[0].pts||bu)){m=d;const Z=o[0].pts-B;if(P)o[0].dts=m,o[0].pts=Z;else for(let Q=0;Q<o.length&&!(o[Q].dts>Z);Q++)o[Q].dts-=B,o[Q].pts-=B;he.log(`Video: Initial PTS/DTS adjusted: ${zf(Z,!0)}/${zf(m,!0)}, delta: ${zf(B,!0)} ms`)}}m=Math.max(0,m);let R=0,I=0,A=m;for(let B=0;B<l;B++){const P=o[B],H=P.units,Z=H.length;let Q=0;for(let J=0;J<Z;J++)Q+=H[J].data.length;I+=Q,R+=Z,P.length=Q,P.dts<A?(P.dts=A,A+=C/4|0||1):A=P.dts,v=Math.min(P.pts,v),y=Math.max(P.pts,y)}g=o[l-1].dts;const k=I+4*R+8;let N;try{N=new Uint8Array(k)}catch(B){this.observer.emit(Y.ERROR,Y.ERROR,{type:Gt.MUX_ERROR,details:Ce.REMUX_ALLOC_ERROR,fatal:!1,error:B,bytes:k,reason:`fail allocating video mdat ${k}`});return}const D=new DataView(N.buffer);D.setUint32(0,k),N.set(ve.types.mdat,4);let M=!1,F=Number.POSITIVE_INFINITY,U=Number.POSITIVE_INFINITY,$=Number.NEGATIVE_INFINITY,q=Number.NEGATIVE_INFINITY;for(let B=0;B<l;B++){const P=o[B],H=P.units;let Z=0;for(let ee=0,K=H.length;ee<K;ee++){const W=H[ee],te=W.data,re=W.data.byteLength;D.setUint32(f,re),f+=4,N.set(te,f),f+=re,Z+=4+re}let Q;if(B<l-1)p=o[B+1].dts-P.dts,Q=o[B+1].pts-P.pts;else{const ee=this.config,K=B>0?P.dts-o[B-1].dts:C;if(Q=B>0?P.pts-o[B-1].pts:C,ee.stretchShortVideoTrack&&this.nextAudioPts!==null){const W=Math.floor(ee.maxBufferHole*i),te=(s?v+s*i:this.nextAudioPts)-P.pts;te>W?(p=te-K,p<0?p=K:M=!0,he.log(`[mp4-remuxer]: It is approximately ${te/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=K}else p=K}const J=Math.round(P.pts-P.dts);F=Math.min(F,p),$=Math.max($,p),U=Math.min(U,Q),q=Math.max(q,Q),a.push(new t$(P.key,p,Z,J))}if(a.length){if(bu){if(bu<70){const B=a[0].flags;B.dependsOn=2,B.isNonSync=0}}else if($T&&q-U<$-F&&C/$<.025&&a[0].cts===0){he.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let B=m;for(let P=0,H=a.length;P<H;P++){const Z=B+a[P].duration,Q=B+a[P].cts;if(P<H-1){const J=Z+a[P+1].cts;a[P].duration=J-Q}else a[P].duration=P?a[P-1].duration:C;a[P].cts=0,B=Z}}}p=M||!p?C:p,this.nextAvcDts=d=g+p,this.videoSampleDuration=p,this.isVideoContiguous=!0;const z={data1:ve.moof(e.sequenceNumber++,m,Or({},e,{samples:a})),data2:N,startPTS:v/i,endPTS:(y+p)/i,startDTS:m/i,endDTS:d/i,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,z}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Dae;case"ac3":return jae;default:return JB}}remuxAudio(e,t,r,s,i){const o=e.inputTimeScale,a=e.samplerate?e.samplerate:o,l=o/a,c=this.getSamplesPerFrame(e),d=c*l,f=this._initPTS,p=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,m=[],g=i!==void 0;let v=e.samples,y=p?0:8,b=this.nextAudioPts||-1;const S=t*o,E=f.baseTime*o/f.timescale;if(this.isAudioContiguous=r=r||v.length&&b>0&&(s&&Math.abs(S-b)<9e3||Math.abs(Mi(v[0].pts-E,S)-b)<20*d),v.forEach(function(G){G.pts=Mi(G.pts-E,S)}),!r||b<0){if(v=v.filter(G=>G.pts>=0),!v.length)return;i===0?b=0:s&&!g?b=Math.max(0,S):b=v[0].pts}if(e.segmentCodec==="aac"){const G=this.config.maxAudioFramesDrift;for(let V=0,z=b;V<v.length;V++){const B=v[V],P=B.pts,H=P-z,Z=Math.abs(1e3*H/o);if(H<=-G*d&&g)V===0&&(he.warn(`Audio frame @ ${(P/o).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*H/o)} ms.`),this.nextAudioPts=b=z=P);else if(H>=G*d&&Z<Pae&&g){let Q=Math.round(H/d);z=P-Q*d,z<0&&(Q--,z+=d),V===0&&(this.nextAudioPts=b=z),he.warn(`[mp4-remuxer]: Injecting ${Q} audio frame @ ${(z/o).toFixed(3)}s due to ${Math.round(1e3*H/o)} ms gap.`);for(let J=0;J<Q;J++){const ee=Math.max(z,0);let K=XB.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);K||(he.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),K=B.unit.subarray()),v.splice(V,0,{unit:K,pts:ee}),z+=d,V++}}B.pts=z,z+=d}}let C=null,R=null,I,A=0,k=v.length;for(;k--;)A+=v[k].unit.byteLength;for(let G=0,V=v.length;G<V;G++){const z=v[G],B=z.unit;let P=z.pts;if(R!==null){const Z=m[G-1];Z.duration=Math.round((P-R)/l)}else if(r&&e.segmentCodec==="aac"&&(P=b),C=P,A>0){A+=y;try{I=new Uint8Array(A)}catch(Z){this.observer.emit(Y.ERROR,Y.ERROR,{type:Gt.MUX_ERROR,details:Ce.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:A,reason:`fail allocating audio mdat ${A}`});return}p||(new DataView(I.buffer).setUint32(0,A),I.set(ve.types.mdat,4))}else return;I.set(B,y);const H=B.byteLength;y+=H,m.push(new t$(!0,c,H,0)),R=P}const N=m.length;if(!N)return;const D=m[m.length-1];this.nextAudioPts=b=R+l*D.duration;const M=p?new Uint8Array(0):ve.moof(e.sequenceNumber++,C/l,Or({},e,{samples:m}));e.samples=[];const F=C/o,U=b/o,q={data1:M,data2:I,startPTS:F,endPTS:U,startDTS:F,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:N};return this.isAudioContiguous=!0,q}remuxEmptyAudio(e,t,r,s){const i=e.inputTimeScale,o=e.samplerate?e.samplerate:i,a=i/o,l=this.nextAudioPts,c=this._initDTS,d=c.baseTime*9e4/c.timescale,f=(l!==null?l:s.startDTS*i)+d,p=s.endDTS*i+d,m=a*JB,g=Math.ceil((p-f)/m),v=XB.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(he.warn("[mp4-remuxer]: remux empty Audio"),!v){he.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const y=[];for(let b=0;b<g;b++){const S=f+b*m;y.push({unit:v,pts:S,dts:S})}return e.samples=y,this.remuxAudio(e,t,r,!1)}}function Mi(n,e){let t;if(e===null)return n;for(e<n?t=-8589934592:t=8589934592;Math.abs(n-e)>4294967296;)n+=t;return n}function Fae(n){for(let e=0;e<n.length;e++)if(n[e].key)return e;return-1}function ZB(n,e,t,r){const s=n.samples.length;if(!s)return;const i=n.inputTimeScale;for(let a=0;a<s;a++){const l=n.samples[a];l.pts=Mi(l.pts-t.baseTime*i/t.timescale,e*i)/i,l.dts=Mi(l.dts-r.baseTime*i/r.timescale,e*i)/i}const o=n.samples;return n.samples=[],{samples:o}}function e$(n,e,t){const r=n.samples.length;if(!r)return;const s=n.inputTimeScale;for(let o=0;o<r;o++){const a=n.samples[o];a.pts=Mi(a.pts-t.baseTime*s/t.timescale,e*s)/s}n.samples.sort((o,a)=>o.pts-a.pts);const i=n.samples;return n.samples=[],{samples:i}}class t${constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class Uae{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(Yie(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=KU(e);s.audio&&(t=n$(s.audio,Dn.AUDIO)),s.video&&(r=n$(s.video,Dn.VIDEO));const i={};s.audio&&s.video?i.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?i.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?i.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:he.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i}remux(e,t,r,s,i,o){var a,l;let{initPTS:c,lastEndTime:d}=this;const f={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};bt(d)||(d=this.lastEndTime=i||0);const p=t.samples;if(!(p!=null&&p.length))return f;const m={initPTS:void 0,timescale:1};let g=this.initData;if((a=g)!=null&&a.length||(this.generateInitSegment(p),g=this.initData),!((l=g)!=null&&l.length))return he.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1);const v=Qie(p,g),y=Xie(g,p),b=y===null?i:y;(Bae(c,b,i,v)||m.timescale!==c.timescale&&o)&&(m.initPTS=b-i,c&&c.timescale===1&&he.warn(`Adjusting initPTS by ${m.initPTS-c.baseTime}`),this.initPTS=c={baseTime:m.initPTS,timescale:1});const S=e?b-c.baseTime/c.timescale:d,E=S+v;Zie(g,p,c.baseTime/c.timescale),v>0?this.lastEndTime=E:(he.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const C=!!g.audio,R=!!g.video;let I="";C&&(I+="audio"),R&&(I+="video");const A={data1:p,startPTS:S,startDTS:S,endPTS:E,endDTS:E,type:I,hasAudio:C,hasVideo:R,nb:1,dropped:0};return f.audio=A.type==="audio"?A:void 0,f.video=A.type!=="audio"?A:void 0,f.initSegment=m,f.id3=ZB(r,i,c,c),s.samples.length&&(f.text=e$(s,i,c)),f}}function Bae(n,e,t,r){if(n===null)return!0;const s=Math.max(r,1),i=e-n.baseTime/n.timescale;return Math.abs(i-t)>s}function n$(n,e){const t=n==null?void 0:n.codec;if(t&&t.length>4)return t;if(e===Dn.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Km(t,!1);const r="mp4a.40.5";return he.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return he.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}let la;try{la=self.performance.now.bind(self.performance)}catch{he.debug("Unable to use Performance API on this environment"),la=du==null?void 0:du.Date.now}const dg=[{demux:Tae,remux:Uae},{demux:Ka,remux:ug},{demux:Eae,remux:ug},{demux:Mae,remux:ug}];dg.splice(2,0,{demux:Cae,remux:ug});class r${constructor(e,t,r,s,i){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=i}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){const i=r.transmuxing;i.executeStart=la();let o=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);const{contiguous:c,discontinuity:d,trackSwitch:f,accurateTimeOffset:p,timeOffset:m,initSegmentChange:g}=s||a,{audioCodec:v,videoCodec:y,defaultInitPts:b,duration:S,initSegmentData:E}=l,C=$ae(o,t);if(C&&C.method==="AES-128"){const k=this.getDecrypter();if(k.isSync()){let N=k.softwareDecrypt(o,C.key.buffer,C.iv.buffer);if(r.part>-1&&(N=k.flush()),!N)return i.executeEnd=la(),zT(r);o=new Uint8Array(N)}else return this.decryptionPromise=k.webCryptoDecrypt(o,C.key.buffer,C.iv.buffer).then(N=>{const D=this.push(N,null,r);return this.decryptionPromise=null,D}),this.decryptionPromise}const R=this.needsProbing(d,f);if(R){const k=this.configureTransmuxer(o);if(k)return he.warn(`[transmuxer] ${k.message}`),this.observer.emit(Y.ERROR,Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_PARSING_ERROR,fatal:!1,error:k,reason:k.message}),i.executeEnd=la(),zT(r)}(d||f||g||R)&&this.resetInitSegment(E,v,y,S,t),(d||g||R)&&this.resetInitialTimestamp(b),c||this.resetContiguity();const I=this.transmux(o,C,m,p,r),A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,i.executeEnd=la(),I}flush(e){const t=e.transmuxing;t.executeStart=la();const{decrypter:r,currentTransmuxState:s,decryptionPromise:i}=this;if(i)return i.then(()=>this.flush(e));const o=[],{timeOffset:a}=s;if(r){const f=r.flush();f&&o.push(this.push(f,null,e))}const{demuxer:l,remuxer:c}=this;if(!l||!c)return t.executeEnd=la(),[zT(e)];const d=l.flush(a);return fg(d)?d.then(f=>(this.flushRemux(o,f,e),o)):(this.flushRemux(o,d,e),o)}flushRemux(e,t,r){const{audioTrack:s,videoTrack:i,id3Track:o,textTrack:a}=t,{accurateTimeOffset:l,timeOffset:c}=this.currentTransmuxState;he.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const d=this.remuxer.remux(s,i,o,a,c,l,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=la()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,i){const{demuxer:o,remuxer:a}=this;!o||!a||(o.resetInitSegment(e,t,r,s),a.resetInitSegment(e,t,r,i))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,i){let o;return t&&t.method==="SAMPLE-AES"?o=this.transmuxSampleAes(e,t,r,s,i):o=this.transmuxUnencrypted(e,r,s,i),o}transmuxUnencrypted(e,t,r,s){const{audioTrack:i,videoTrack:o,id3Track:a,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(i,o,a,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,i){return this.demuxer.demuxSampleAes(e,t,r).then(o=>({remuxResult:this.remuxer.remux(o.audioTrack,o.videoTrack,o.id3Track,o.textTrack,r,s,!1,this.id),chunkMeta:i}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:s,vendor:i}=this;let o;for(let p=0,m=dg.length;p<m;p++){var a;if((a=dg[p].demux)!=null&&a.probe(e)){o=dg[p];break}}if(!o)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,c=this.remuxer,d=o.remux,f=o.demux;(!c||!(c instanceof d))&&(this.remuxer=new d(r,t,s,i)),(!l||!(l instanceof f))&&(this.demuxer=new f(r,t,s),this.probe=f.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new OT(this.config)),e}}function $ae(n,e){let t=null;return n.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const zT=n=>({remuxResult:{},chunkMeta:n});function fg(n){return"then"in n&&n.then instanceof Function}class zae{constructor(e,t,r,s,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=i||null}}class qae{constructor(e,t,r,s,i,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=i,this.initSegmentChange=o}}var s$={exports:{}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,c,d){this.fn=l,this.context=c,this.once=d||!1}function i(l,c,d,f,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new s(d,f||l,p),g=t?t+c:c;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],m]:l._events[g].push(m):(l._events[g]=m,l._eventsCount++),l}function o(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],d,f;if(this._eventsCount===0)return c;for(f in d=this._events)e.call(d,f)&&c.push(t?f.slice(1):f);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(d)):c},a.prototype.listeners=function(c){var d=t?t+c:c,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,m=f.length,g=new Array(m);p<m;p++)g[p]=f[p].fn;return g},a.prototype.listenerCount=function(c){var d=t?t+c:c,f=this._events[d];return f?f.fn?1:f.length:0},a.prototype.emit=function(c,d,f,p,m,g){var v=t?t+c:c;if(!this._events[v])return!1;var y=this._events[v],b=arguments.length,S,E;if(y.fn){switch(y.once&&this.removeListener(c,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,f),!0;case 4:return y.fn.call(y.context,d,f,p),!0;case 5:return y.fn.call(y.context,d,f,p,m),!0;case 6:return y.fn.call(y.context,d,f,p,m,g),!0}for(E=1,S=new Array(b-1);E<b;E++)S[E-1]=arguments[E];y.fn.apply(y.context,S)}else{var C=y.length,R;for(E=0;E<C;E++)switch(y[E].once&&this.removeListener(c,y[E].fn,void 0,!0),b){case 1:y[E].fn.call(y[E].context);break;case 2:y[E].fn.call(y[E].context,d);break;case 3:y[E].fn.call(y[E].context,d,f);break;case 4:y[E].fn.call(y[E].context,d,f,p);break;default:if(!S)for(R=1,S=new Array(b-1);R<b;R++)S[R-1]=arguments[R];y[E].fn.apply(y[E].context,S)}}return!0},a.prototype.on=function(c,d,f){return i(this,c,d,f,!1)},a.prototype.once=function(c,d,f){return i(this,c,d,f,!0)},a.prototype.removeListener=function(c,d,f,p){var m=t?t+c:c;if(!this._events[m])return this;if(!d)return o(this,m),this;var g=this._events[m];if(g.fn)g.fn===d&&(!p||g.once)&&(!f||g.context===f)&&o(this,m);else{for(var v=0,y=[],b=g.length;v<b;v++)(g[v].fn!==d||p&&!g[v].once||f&&g[v].context!==f)&&y.push(g[v]);y.length?this._events[m]=y.length===1?y[0]:y:o(this,m)}return this},a.prototype.removeAllListeners=function(c){var d;return c?(d=t?t+c:c,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a})(s$);var Hae=s$.exports,qT=vie(Hae);class i${constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const i=e.config;this.hls=e,this.id=t,this.useWorker=!!i.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;const o=(d,f)=>{f=f||{},f.frag=this.frag,f.id=this.id,d===Y.ERROR&&(this.error=f.error),this.hls.trigger(d,f)};this.observer=new qT,this.observer.on(Y.FRAG_DECRYPTED,o),this.observer.on(Y.ERROR,o);const a=oc(i.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:a.isTypeSupported("audio/mpeg"),mp3:a.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:a.isTypeSupported('audio/mp4; codecs="ac-3"')},c=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(i.workerPath||cae())){try{i.workerPath?(he.log(`loading Web Worker ${i.workerPath} for "${t}"`),this.workerContext=dae(i.workerPath)):(he.log(`injecting Web Worker for "${t}"`),this.workerContext=uae()),this.onwmsg=p=>this.onWorkerMessage(p);const{worker:f}=this.workerContext;f.addEventListener("message",this.onwmsg),f.onerror=p=>{const m=new Error(`${p.message} (${p.filename}:${p.lineno})`);i.enableWorker=!1,he.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(Y.ERROR,{type:Gt.OTHER_ERROR,details:Ce.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:m})},f.postMessage({cmd:"init",typeSupported:l,vendor:c,id:t,config:JSON.stringify(i)})}catch(f){he.warn(`Error setting up "${t}" Web Worker, fallback to inline`,f),this.resetWorker(),this.error=null,this.transmuxer=new r$(this.observer,l,i,c,t)}return}this.transmuxer=new r$(this.observer,l,i,c,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,i,o,a,l,c,d){var f,p;c.transmuxing.start=self.performance.now();const{transmuxer:m}=this,g=o?o.start:i.start,v=i.decryptdata,y=this.frag,b=!(y&&i.cc===y.cc),S=!(y&&c.level===y.level),E=y?c.sn-y.sn:-1,C=this.part?c.part-this.part.index:-1,R=E===0&&c.id>1&&c.id===(y==null?void 0:y.stats.chunkCount),I=!S&&(E===1||E===0&&(C===1||R&&C<=0)),A=self.performance.now();(S||E||i.stats.parsing.start===0)&&(i.stats.parsing.start=A),o&&(C||!I)&&(o.stats.parsing.start=A);const k=!(y&&((f=i.initSegment)==null?void 0:f.url)===((p=y.initSegment)==null?void 0:p.url)),N=new qae(b,I,l,S,g,k);if(!I||b||k){he.log(`[transmuxer-interface, ${i.type}]: Starting new transmux session for sn: ${c.sn} p: ${c.part} level: ${c.level} id: ${c.id}
372 discontinuity: ${b}
373 trackSwitch: ${S}
374 contiguous: ${I}
375 accurateTimeOffset: ${l}
376 timeOffset: ${g}
377 initSegmentChange: ${k}`);const D=new zae(r,s,t,a,d);this.configureTransmuxer(D)}if(this.frag=i,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:v,chunkMeta:c,state:N},e instanceof ArrayBuffer?[e]:[]);else if(m){const D=m.push(e,v,c,N);fg(D)?(m.async=!0,D.then(M=>{this.handleTransmuxComplete(M)}).catch(M=>{this.transmuxerError(M,c,"transmuxer-interface push error")})):(m.async=!1,this.handleTransmuxComplete(D))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);fg(r)||t.async?(fg(r)||(r=Promise.resolve(r)),r.then(i=>{this.handleFlushResult(i,e)}).catch(i=>{this.transmuxerError(i,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data,r=this.hls;switch(t.event){case"init":{var s;const i=(s=this.workerContext)==null?void 0:s.objectURL;i&&self.URL.revokeObjectURL(i);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":he[t.data.logType]&&he[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function o$(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!xu(n[t].attrs,e[t].attrs))return!1;return!0}function xu(n,e,t){const r=n["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>n[s]!==e[s])}function HT(n,e){return e.label.toLowerCase()===n.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(n.lang||"").toLowerCase())}const a$=100;class l$ extends ag{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",zt.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Y.ERROR,this.onError,this),e.on(Y.BUFFER_RESET,this.onBufferReset,this),e.on(Y.BUFFER_CREATED,this.onBufferCreated,this),e.on(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Y.ERROR,this.onError,this),e.off(Y.BUFFER_RESET,this.onBufferReset,this),e.off(Y.BUFFER_CREATED,this.onBufferCreated,this),e.off(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Y.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:i}){if(r==="main"){const o=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:i},this.log(`InitPTS for cc: ${o} found from main: ${s}`),this.videoTrackCC=o,this.state===$e.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=$e.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(a$),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=$e.IDLE):(this.loadedmetadata=!1,this.state=$e.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case $e.IDLE:this.doTickIdle();break;case $e.WAITING_TRACK:{var e;const{levels:r,trackId:s}=this,i=r==null||(e=r[s])==null?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=$e.WAITING_INIT_PTS}break}case $e.FRAG_LOADING_WAITING_RETRY:{var t;const r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){const{levels:i,trackId:o}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((i==null?void 0:i[o])||null),this.state=$e.IDLE}break}case $e.WAITING_INIT_PTS:{const r=this.waitingData;if(r){const{frag:s,part:i,cache:o,complete:a}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=$e.FRAG_LOADING;const l=o.flush(),c={frag:s,part:i,payload:l,networkDetails:null};this._handleFragmentLoadProgress(c),a&&super._handleFragmentLoadComplete(c)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),c=Jn.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);NT(c.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${c.end} is needed`),this.clearWaitingFragment())}}else this.state=$e.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=$e.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:r,trackId:s}=this,i=e.config;if(!r&&(this.startFragRequested||!i.startFragPrefetch)||!(t!=null&&t[s]))return;const o=t[s],a=o.details;if(!a||a.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(a)){this.state=$e.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Dn.AUDIO,zt.AUDIO));const c=this.getFwdBufferInfo(l,zt.AUDIO);if(c===null)return;const{bufferedTrack:d,switchingTrack:f}=this;if(!f&&this._streamEnded(c,a)){e.trigger(Y.BUFFER_EOS,{type:"audio"}),this.state=$e.ENDED;return}const p=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,zt.MAIN),m=c.len,g=this.getMaxBufferLength(p==null?void 0:p.len),v=a.fragments,y=v[0].start;let b=this.flushing?this.getLoadPosition():c.end;if(f&&r){const R=this.getLoadPosition();d&&!xu(f.attrs,d.attrs)&&(b=R),a.PTSKnown&&R<y&&(c.end>y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=y+.05)}if(m>=g&&!f&&b<v[v.length-1].start)return;let S=this.getNextFragment(b,a),E=!1;if(S&&this.isLoopLoading(S,b)&&(E=!!S.gap,S=this.getNextFragmentLoopLoading(S,a,c,zt.MAIN,g)),!S){this.bufferFlushed=!0;return}const C=p&&S.start>p.end+a.targetduration;if(C||!(p!=null&&p.len)&&c.len){const R=this.getAppendedFrag(S.start,zt.MAIN);if(R===null||(E||(E=!!R.gap||!!C&&p.len===0),C&&!E||E&&c.nextStart&&c.nextStart<R.end))return}this.loadFragment(S,o,b)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new ac(r))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(a$):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=$e.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=$e.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(Y.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:s}=this,{details:i,id:o}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${o}`);return}this.log(`Audio track ${o} loaded [${i.startSN},${i.endSN}]${i.lastPartSn?`[part-${i.lastPartSn}-${i.lastPartIndex}]`:""},duration:${i.totalduration}`);const a=s[o];let l=0;if(i.live||(r=a.details)!=null&&r.live){this.checkLiveUpdate(i);const d=this.mainDetails;if(i.deltaUpdateFailed||!d)return;if(!a.details&&i.hasProgramDateTime&&d.hasProgramDateTime)og(i,d),l=i.fragments[0].start;else{var c;l=this.alignPlaylists(i,a.details,(c=this.levelLastLoaded)==null?void 0:c.details)}}a.details=i,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!i.live)&&this.setStartPosition(this.mainDetails||i,l),this.state===$e.WAITING_TRACK&&!this.waitForCdnTuneIn(i)&&(this.state=$e.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:s,payload:i}=e,{config:o,trackId:a,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const c=l[a];if(!c){this.warn("Audio track is undefined on fragment load progress");return}const d=c.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}const f=o.defaultAudioCodec||c.audioCodec||"mp4a.40.2";let p=this.transmuxer;p||(p=this.transmuxer=new i$(this.hls,zt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const m=this.initPTS[r.cc],g=(t=r.initSegment)==null?void 0:t.data;if(m!==void 0){const y=s?s.index:-1,b=y!==-1,S=new rg(r.level,r.sn,r.stats.chunkCount,i.byteLength,y,b);p.push(i,g,f,"",r,s,d.totalduration,!1,S,m)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:v}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new jB,complete:!1};v.push(new Uint8Array(i)),this.waitingVideoCC=this.videoTrackCC,this.state=$e.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:r,part:s}=t;if(r.type!==zt.AUDIO){if(!this.loadedmetadata&&r.type===zt.MAIN){const i=this.videoBuffer||this.media;i&&Jn.getBuffered(i).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;const i=this.switchingTrack;i&&(this.bufferedTrack=i,this.switchingTrack=null,this.hls.trigger(Y.AUDIO_TRACK_SWITCHED,Xr({},i)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=$e.ERROR;return}switch(t.details){case Ce.FRAG_GAP:case Ce.FRAG_PARSING_ERROR:case Ce.FRAG_DECRYPT_ERROR:case Ce.FRAG_LOAD_ERROR:case Ce.FRAG_LOAD_TIMEOUT:case Ce.KEY_LOAD_ERROR:case Ce.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(zt.AUDIO,t);break;case Ce.AUDIO_TRACK_LOAD_ERROR:case Ce.AUDIO_TRACK_LOAD_TIMEOUT:case Ce.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===$e.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Sn.AUDIO_TRACK&&(this.state=$e.IDLE);break;case Ce.BUFFER_APPEND_ERROR:case Ce.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===Ce.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Ce.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==Dn.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Dn.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===$e.ENDED&&(this.state=$e.IDLE);const r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,zt.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:s}=this,{remuxResult:i,chunkMeta:o}=e,a=this.getCurrentContext(o);if(!a){this.resetWhenMissingContext(o);return}const{frag:l,part:c,level:d}=a,{details:f}=d,{audio:p,text:m,id3:g,initSegment:v}=i;if(this.fragContextChanged(l)||!f){this.fragmentTracker.removeFragment(l);return}if(this.state=$e.PARSING,this.switchingTrack&&p&&this.completeAudioSwitch(this.switchingTrack),v!=null&&v.tracks){const y=l.initSegment||l;this._bufferInitSegment(d,v.tracks,y,o),s.trigger(Y.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:r,tracks:v.tracks})}if(p){const{startPTS:y,endPTS:b,startDTS:S,endDTS:E}=p;c&&(c.elementaryStreams[Dn.AUDIO]={startPTS:y,endPTS:b,startDTS:S,endDTS:E}),l.setElementaryStreamInfo(Dn.AUDIO,y,b,S,E),this.bufferFragmentData(p,l,c,o)}if(g!=null&&(t=g.samples)!=null&&t.length){const y=Or({id:r,frag:l,details:f},g);s.trigger(Y.FRAG_PARSING_METADATA,y)}if(m){const y=Or({id:r,frag:l,details:f},m);s.trigger(Y.FRAG_PARSING_USERDATA,y)}}_bufferInitSegment(e,t,r,s){if(this.state!==$e.PARSING)return;t.video&&delete t.video;const i=t.audio;if(!i)return;i.id="audio";const o=e.audioCodec;this.log(`Init audio buffer, container:${i.container}, codecs[level/parsed]=[${o}/${i.codec}]`),o&&o.split(",").length===1&&(i.levelCodec=o),this.hls.trigger(Y.BUFFER_CODECS,t);const a=i.initSegment;if(a!=null&&a.byteLength){const l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:a};this.hls.trigger(Y.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){const s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===Jr.NOT_LOADED||s===Jr.PARTIAL){var i;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((i=t.details)!=null&&i.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=$e.WAITING_INIT_PTS;const o=this.mainDetails;o&&o.fragments[0].start!==t.details.fragments[0].start&&og(t.details,o)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,i=e.attrs;t&&s&&(s.CHANNELS!==i.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Y.AUDIO_TRACK_SWITCHED,Xr({},e))}}class c$ extends tg{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Y.LEVEL_LOADING,this.onLevelLoading,this),e.on(Y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Y.LEVEL_LOADING,this.onLevelLoading,this),e.off(Y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Y.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:s,details:i}=t,o=this.tracksInGroup[r];if(!o||o.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${o==null?void 0:o.groupId}`);return}const a=o.details;o.details=t.details,this.log(`Audio track ${r} "${o.name}" lang:${o.lang} group:${s} loaded [${i.startSN}-${i.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,s=this.groupIds;let i=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(p=>!r||r.indexOf(p.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(p=>p.default)&&(this.selectDefaultTrack=!1),a.forEach((p,m)=>{p.id=m});else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const l=this.hls.config.audioPreference;if(!i&&l){const p=Fo(l,a,_u);if(p>-1)i=a[p];else{const m=Fo(l,this.tracks);i=this.tracks[m]}}let c=this.findTrackId(i);c===-1&&i&&(c=this.findTrackId(null));const d={audioTracks:a};this.log(`Updating audio tracks, ${a.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(Y.AUDIO_TRACKS_UPDATED,d);const f=this.trackId;if(c!==-1&&f===-1)this.setAudioTrack(c);else if(a.length&&f===-1){var o;const p=new Error(`No audio track selected for current audio group-ID(s): ${(o=this.groupIds)==null?void 0:o.join(",")} track count: ${a.length}`);this.warn(p.message),this.hls.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:p})}}else this.shouldReloadPlaylist(i)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Sn.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const s=this.currentTrack;if(s&&gu(e,s,_u))return s;const i=Fo(e,this.tracksInGroup,_u);if(i>-1){const o=this.tracksInGroup[i];return this.setAudioTrack(i),o}else if(s){let o=t.loadLevel;o===-1&&(o=t.firstAutoLevel);const a=Woe(e,t.levels,r,o,_u);if(a===-1)return null;t.nextLoadLevel=a}if(e.channels||e.audioCodec){const o=Fo(e,r);if(o>-1)return r[o]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,s=t[e],i=s.details&&!s.details.live;if(e===this.trackId&&s===r&&i||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(Y.AUDIO_TRACK_SWITCHING,Xr({},s)),i))return;const o=this.switchParams(s.url,r==null?void 0:r.details);this.loadPlaylist(o)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||gu(e,s,_u)))return r}if(e){const{name:r,lang:s,assocLang:i,characteristics:o,audioCodec:a,channels:l}=e;for(let c=0;c<t.length;c++){const d=t[c];if(gu({name:r,lang:s,assocLang:i,characteristics:o,audioCodec:a,channels:l},d,_u))return c}for(let c=0;c<t.length;c++){const d=t[c];if(xu(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return c}for(let c=0;c<t.length;c++){const d=t[c];if(xu(e.attrs,d.attrs,["LANGUAGE"]))return c}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const r=t.id,s=t.groupId;let i=t.url;if(e)try{i=e.addDirectives(i)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(Y.AUDIO_TRACK_LOADING,{url:i,id:r,groupId:s,deliveryDirectives:e||null})}}}const u$=500;class d$ extends ag{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",zt.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Y.ERROR,this.onError,this),e.on(Y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Y.ERROR,this.onError,this),e.off(Y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Y.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=$e.IDLE,this.setInterval(u$),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=$e.IDLE,!s)return;const i=this.tracksBuffered[this.currentTrackId];if(!i)return;let o;const a=r.start;for(let c=0;c<i.length;c++)if(a>=i[c].start&&a<=i[c].end){o=i[c];break}const l=r.start+r.duration;o?o.end=l:(o={start:a,end:l},i.push(o)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){const{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){const i=s-1;if(i<=0)return;t.endOffsetSubtitles=Math.max(0,i),this.tracksBuffered.forEach(o=>{for(let a=0;a<o.length;){if(o[a].end<=i){o.shift();continue}else if(o[a].start<i)o[a].start=i;else break;a++}}),this.fragmentTracker.removeFragmentsInRange(r,i,zt.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===zt.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const r=t.frag;(r==null?void 0:r.type)===zt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==$e.STOPPED&&(this.state=$e.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(!this.levels||o$(this.levels,t)){this.levels=t.map(r=>new ac(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{const s=new ac(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,zt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(u$)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:s,levels:i}=this,{details:o,id:a}=t;if(!i){this.warn(`Subtitle tracks were reset while loading level ${a}`);return}const l=i[s];if(a>=i.length||a!==s||!l)return;this.log(`Subtitle track ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let c=0;if(o.live||(r=l.details)!=null&&r.live){const f=this.mainDetails;if(o.deltaUpdateFailed||!f)return;const p=f.fragments[0];if(!l.details)o.hasProgramDateTime&&f.hasProgramDateTime?(og(o,f),c=o.fragments[0].start):p&&(c=p.start,LT(o,c));else{var d;c=this.alignPlaylists(o,l.details,(d=this.levelLastLoaded)==null?void 0:d.details),c===0&&p&&(c=p.start,LT(o,c))}}l.details=o,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(this.mainDetails||o,c),this.tick(),o.live&&!this.fragCurrent&&this.media&&this.state===$e.IDLE&&(eg(null,o.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,s=t.decryptdata,i=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){const o=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(a=>{throw i.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.FRAG_DECRYPT_ERROR,fatal:!1,error:a,reason:a.message,frag:t}),a}).then(a=>{const l=performance.now();i.trigger(Y.FRAG_DECRYPTED,{frag:t,payload:a,stats:{tstart:o,tdecrypt:l}})}).catch(a=>{this.warn(`${a.name}: ${a.message}`),this.state=$e.IDLE})}}doTick(){if(!this.media){this.state=$e.IDLE;return}if(this.state===$e.IDLE){const{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;const{config:s}=this,i=this.getLoadPosition(),o=Jn.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,s.maxBufferHole),{end:a,len:l}=o,c=this.getFwdBufferInfo(this.media,zt.MAIN),d=r.details,f=this.getMaxBufferLength(c==null?void 0:c.len)+d.levelTargetDuration;if(l>f)return;const p=d.fragments,m=p.length,g=d.edge;let v=null;const y=this.fragPrevious;if(a<g){const b=s.maxFragLookUpTolerance,S=a>g-b?0:b;v=eg(y,p,Math.max(p[0].start,a),S),!v&&y&&y.start<p[0].start&&(v=p[0])}else v=p[m-1];if(!v)return;if(v=this.mapToInitFragWhenRequired(v),v.sn!=="initSegment"){const b=v.sn-d.startSN,S=p[b-1];S&&S.cc===v.cc&&this.fragmentTracker.getState(S)===Jr.NOT_LOADED&&(v=S)}this.fragmentTracker.getState(v)===Jr.NOT_LOADED&&this.loadFragment(v,r,a)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Gae(this.tracksBuffered[this.currentTrackId]||[])}}class Gae{constructor(e){this.buffered=void 0;const t=(r,s,i)=>{if(s=s>>>0,s>i-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${i})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}}class f$ extends tg{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const r=Ym(this.media.textTracks);for(let i=0;i<r.length;i++)if(r[i].mode==="hidden")t=r[i];else if(r[i].mode==="showing"){t=r[i];break}const s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Y.LEVEL_LOADING,this.onLevelLoading,this),e.on(Y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Y.LEVEL_LOADING,this.onLevelLoading,this),e.off(Y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Y.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Ym(this.media.textTracks).forEach(t=>{hu(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:s,details:i}=t,o=this.tracksInGroup[r];if(!o||o.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${o==null?void 0:o.groupId}`);return}const a=o.details;o.details=t.details,this.log(`Subtitle track ${r} "${o.name}" lang:${o.lang} group:${s} loaded [${i.startSN}-${i.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,s=this.groupIds;let i=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(d=>!r||r.indexOf(d.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(d=>d.default)&&(this.selectDefaultTrack=!1),o.forEach((d,f)=>{d.id=f});else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const a=this.hls.config.subtitlePreference;if(!i&&a){this.selectDefaultTrack=!1;const d=Fo(a,o);if(d>-1)i=o[d];else{const f=Fo(a,this.tracks);i=this.tracks[f]}}let l=this.findTrackId(i);l===-1&&i&&(l=this.findTrackId(null));const c={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(Y.SUBTITLE_TRACKS_UPDATED,c),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const i=t[s];if(!(r&&!i.default||!r&&!e)&&(!e||gu(i,e)))return s}if(e){for(let s=0;s<t.length;s++){const i=t[s];if(xu(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const i=t[s];if(xu(e.attrs,i.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const s=t[r];if(HT(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Sn.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&gu(e,r))return r;const s=Fo(e,this.tracksInGroup);if(s>-1){const i=this.tracksInGroup[s];return this.setSubtitleTrack(s),i}else{if(r)return null;{const i=Fo(e,t);if(i>-1)return t[i]}}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const r=t.id,s=t.groupId;let i=t.url;if(e)try{i=e.addDirectives(i)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(Y.SUBTITLE_TRACK_LOADING,{url:i,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Ym(e.textTracks),r=this.currentTrack;let s;if(r&&(s=t.filter(i=>HT(r,i))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(i=>{i.mode!=="disabled"&&i!==s&&(i.mode="disabled")}),s){const i=this.subtitleDisplay?"showing":"hidden";s.mode!==i&&(s.mode=i)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!bt(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(Y.SUBTITLE_TRACK_SWITCH,{id:e});return}const i=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&i)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));const{id:o,groupId:a="",name:l,type:c,url:d}=s;this.hls.trigger(Y.SUBTITLE_TRACK_SWITCH,{id:o,groupId:a,name:l,type:c,url:d});const f=this.switchParams(s.url,r==null?void 0:r.details);this.loadPlaylist(f)}}class Vae{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){const s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const r=new Promise(i=>{t=i}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){const t=this.queues[e];if(t.length){const r=t[0];try{r.execute()}catch(s){he.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);const i=this.buffers[e];i!=null&&i.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const h$=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class p${constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(Y.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:r,_objectUrl:s}=this;r!==s&&he.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=e.config.preferManagedMediaSource,this.log=he.log.bind(he,t),this.warn=he.warn.bind(he,t),this.error=he.error.bind(he,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(Y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Y.BUFFER_RESET,this.onBufferReset,this),e.on(Y.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Y.BUFFER_EOS,this.onBufferEos,this),e.on(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Y.FRAG_PARSED,this.onFragParsed,this),e.on(Y.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(Y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Y.BUFFER_RESET,this.onBufferReset,this),e.off(Y.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Y.BUFFER_EOS,this.onBufferEos,this),e.off(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Y.FRAG_PARSED,this.onFragParsed,this),e.off(Y.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Vae(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const r=this.media=t.media,s=oc(this.appendSource);if(r&&s){var i;const o=this.mediaSource=new s;this.log(`created media source: ${(i=o.constructor)==null?void 0:i.name}`),o.addEventListener("sourceopen",this._onMediaSourceOpen),o.addEventListener("sourceended",this._onMediaSourceEnded),o.addEventListener("sourceclose",this._onMediaSourceClose),o.addEventListener("startstreaming",this._onStartStreaming),o.addEventListener("endstreaming",this._onEndStreaming);const a=this._objectUrl=self.URL.createObjectURL(o);if(this.appendSource)try{r.removeAttribute("src");const l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&o instanceof l,m$(r),Wae(r,a),r.load()}catch{r.src=a}else r.src=a;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&m$(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(Y.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){const r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(o=>{if(r){const l=this.tracks[o];if(l&&typeof l.buffer.changeType=="function"){var a;const{id:c,codec:d,levelCodec:f,container:p,metadata:m}=t[o],g=sB(l.codec,l.levelCodec),v=g==null?void 0:g.replace(h$,"$1");let y=sB(d,f);const b=(a=y)==null?void 0:a.replace(h$,"$1");if(y&&v!==b){o.slice(0,5)==="audio"&&(y=Km(y,this.hls.config.preferManagedMediaSource));const S=`${p};codecs=${y}`;this.appendChangeType(o,S),this.log(`switching codec ${g} to ${y}`),this.tracks[o]={buffer:l.buffer,codec:d,container:p,levelCodec:f,metadata:m,id:c}}}}else this.pendingTracks[o]=t[o]}),r)return;const i=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==i&&(this.log(`${i} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=i),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:r}=this,s={execute:()=>{const i=this.sourceBuffer[e];i&&(this.log(`changing ${e} sourceBuffer type to ${t}`),i.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:i=>{this.warn(`Failed to change ${e} SourceBuffer type`,i)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:r,operationQueue:s,tracks:i}=this,{data:o,type:a,frag:l,part:c,chunkMeta:d}=t,f=d.buffering[a],p=self.performance.now();f.start=p;const m=l.stats.buffering,g=c?c.stats.buffering:null;m.start===0&&(m.start=p),g&&g.start===0&&(g.start=p);const v=i.audio;let y=!1;a==="audio"&&(v==null?void 0:v.container)==="audio/mpeg"&&(y=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const b=l.start,S={execute:()=>{if(f.executeStart=self.performance.now(),y){const E=this.sourceBuffer[a];if(E){const C=b-E.timestampOffset;Math.abs(C)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${b} (delta: ${C}) sn: ${l.sn})`),E.timestampOffset=b)}}this.appendExecutor(o,a)},onStart:()=>{},onComplete:()=>{const E=self.performance.now();f.executeEnd=f.end=E,m.first===0&&(m.first=E),g&&g.first===0&&(g.first=E);const{sourceBuffer:C}=this,R={};for(const I in C)R[I]=Jn.getBuffered(C[I]);this.appendErrors[a]=0,a==="audio"||a==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(Y.BUFFER_APPENDED,{type:a,frag:l,part:c,chunkMeta:d,parent:l.type,timeRanges:R})},onError:E=>{const C={type:Gt.MEDIA_ERROR,parent:l.type,details:Ce.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:l,part:c,chunkMeta:d,error:E,err:E,fatal:!1};if(E.code===DOMException.QUOTA_EXCEEDED_ERR)C.details=Ce.BUFFER_FULL_ERROR;else{const R=++this.appendErrors[a];C.details=Ce.BUFFER_APPEND_ERROR,this.warn(`Failed ${R}/${r.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer`),R>=r.config.appendErrorMaxRetry&&(C.fatal=!0)}r.trigger(Y.ERROR,C)}};s.append(S,a,!!this.pendingTracks[a])}onBufferFlushing(e,t){const{operationQueue:r}=this,s=i=>({execute:this.removeExecutor.bind(this,i,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Y.BUFFER_FLUSHED,{type:i})},onError:o=>{this.warn(`Failed to remove from ${i} SourceBuffer`,o)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(i=>{r.append(s(i),i)})}onFragParsed(e,t){const{frag:r,part:s}=t,i=[],o=s?s.elementaryStreams:r.elementaryStreams;o[Dn.AUDIOVIDEO]?i.push("audiovideo"):(o[Dn.AUDIO]&&i.push("audio"),o[Dn.VIDEO]&&i.push("video"));const a=()=>{const l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);const c=s?s.stats:r.stats;this.hls.trigger(Y.FRAG_BUFFERED,{frag:r,part:s,stats:c,id:r.type})};i.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(a,i)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,i)=>{const o=this.sourceBuffer[i];return o&&(!t.type||t.type===i)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${i} sourceBuffer now EOS`))),s&&!!(!o||o.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(i=>{const o=this.sourceBuffer[i];o&&(o.ending=!1)});const{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;const i=e.config,o=r.currentTime,a=t.levelTargetDuration,l=t.live&&i.liveBackBufferLength!==null?i.liveBackBufferLength:i.backBufferLength;if(bt(l)&&l>0){const c=Math.max(l,a),d=Math.floor(o/a)*a-c;this.flushBackBuffer(o,a,d)}if(bt(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){const c=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),d=Math.max(c,a),f=Math.floor(o/a)*a+d;this.flushFrontBuffer(o,a,f)}}flushBackBuffer(e,t,r){const{details:s,sourceBuffer:i}=this;this.getSourceBufferTypes().forEach(a=>{const l=i[a];if(l){const c=Jn.getBuffered(l);if(c.length>0&&r>c.start(0)){if(this.hls.trigger(Y.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(Y.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&c.end(c.length-1)-e<t*2){this.log(`Cannot flush ${a} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(Y.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:a})}}})}flushFrontBuffer(e,t,r){const{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(o=>{const a=s[o];if(a){const l=Jn.getBuffered(a),c=l.length;if(c<2)return;const d=l.start(c-1),f=l.end(c-1);if(r>d||e>=d&&e<=f)return;if(a.ended&&e-f<2*t){this.log(`Cannot flush ${o} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(Y.BUFFER_FLUSHING,{startOffset:d,endOffset:1/0,type:o})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:r,mediaSource:s}=this,i=e.fragments[0].start+e.totalduration,o=r.duration,a=bt(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(i>a&&i>o||!bt(o))&&(this.log(`Updating Media Source duration to ${i.toFixed(3)}`),s.duration=i)}updateSeekableRange(e){const t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){const i=Math.max(0,r[0].start),o=Math.max(i,i+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${i}-${o}.`),t.setLiveSeekableRange(i,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};const i=this.getSourceBufferTypes();if(i.length)this.hls.trigger(Y.BUFFER_CREATED,{tracks:this.tracks}),i.forEach(o=>{t.executeNext(o)});else{const o=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:o,reason:o.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const s in e)if(!t[s]){const i=e[s];if(!i)throw Error(`source buffer exists for track ${s}, however track does not`);let o=i.levelCodec||i.codec;o&&s.slice(0,5)==="audio"&&(o=Km(o,this.hls.config.preferManagedMediaSource));const a=`${i.container};codecs=${o}`;this.log(`creating sourceBuffer(${a})`);try{const l=t[s]=r.addSourceBuffer(a),c=s;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.addBufferListener(c,"bufferedchange",(d,f)=>{const p=f.removedRanges;p!=null&&p.length&&this.hls.trigger(Y.BUFFER_FLUSHED,{type:s})}),this.tracks[s]={buffer:l,codec:o,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(l){this.error(`error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,sourceBufferName:s,mimeType:a})}}}get mediaSrc(){var e;const t=((e=this.media)==null?void 0:e.firstChild)||this.media;return t==null?void 0:t.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const i=this.operationQueue.current(e);i&&i.onError(s)}removeExecutor(e,t,r){const{media:s,mediaSource:i,operationQueue:o,sourceBuffer:a}=this,l=a[e];if(!s||!i||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),o.shiftAndExecuteNext(e);return}const c=bt(s.duration)?s.duration:1/0,d=bt(i.duration)?i.duration:1/0,f=Math.max(0,t),p=Math.min(r,c,d);p>f&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${f},${p}] from the ${e} SourceBuffer`),l.remove(f,p)):o.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:r}=this,s=t.map(i=>r.appendBlocker(i));Promise.all(s).then(()=>{e(),t.forEach(i=>{const o=this.sourceBuffer[i];o!=null&&o.updating||r.shiftAndExecuteNext(i)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){const s=this.sourceBuffer[e];if(!s)return;const i=r.bind(this,e);this.listeners[e].push({event:t,listener:i}),s.addEventListener(t,i)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}}function m$(n){const e=n.querySelectorAll("source");[].slice.call(e).forEach(t=>{n.removeChild(t)})}function Wae(n,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,n.appendChild(t)}const g$={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},_$=function(e){let t=e;return g$.hasOwnProperty(e)&&(t=g$[e]),String.fromCharCode(t)},oo=15,ca=100,Kae={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Yae={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Xae={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Qae={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Jae=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Zae{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r=typeof t=="function"?t():t;he.log(`${this.time} [${e}] ${r}`)}}}const lc=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class v${constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class ele{constructor(){this.uchar=" ",this.penState=new v$}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class tle{constructor(e){this.chars=[],this.pos=0,this.currPenState=new v$,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<ca;t++)this.chars.push(new ele);this.logger=e}equals(e){for(let t=0;t<ca;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<ca;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ca;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ca&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ca)}moveCursor(e){const t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=_$(e);if(this.pos>=ca){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<ca;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<ca;r++){const s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class GT{constructor(e){this.rows=[],this.currRow=oo-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<oo;t++)this.rows.push(new tle(e));this.logger=e}reset(){for(let e=0;e<oo;e++)this.rows[e].clear();this.currRow=oo-1}equals(e){let t=!0;for(let r=0;r<oo;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<oo;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<oo;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let a=0;a<oo;a++)this.rows[a].clear();const i=this.currRow+1-this.nrRollUpRows,o=this.lastOutputScreen;if(o){const a=o.rows[i].cueStartTime,l=this.logger.time;if(a!==null&&l!==null&&a<l)for(let c=0;c<this.nrRollUpRows;c++)this.rows[t-this.nrRollUpRows+c+1].copy(o.rows[i+c])}}this.currRow=t;const r=this.rows[this.currRow];if(e.indent!==null){const i=e.indent,o=Math.max(i-1,0);r.setCursor(e.indent),e.color=r.chars[o].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",s=-1;for(let i=0;i<oo;i++){const o=this.rows[i].getTextString();o&&(s=i+1,e?t.push("Row "+s+": '"+o+"'"):t.push(o.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
378 `)),r}getTextAndFormat(){return this.rows}}class y${constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new GT(r),this.nonDisplayedMemory=new GT(r),this.lastOutputScreen=new GT(r),this.currRollUpRow=this.displayedMemory.rows[oo-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[oo-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class b${constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=S$(),this.logger=void 0;const s=this.logger=new Zae;this.channels=[null,new y$(e,t,s),new y$(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,s,i,o=!1;this.logger.time=e;for(let a=0;a<t.length;a+=2)if(s=t[a]&127,i=t[a+1]&127,!(s===0&&i===0)){if(this.logger.log(3,"["+lc([t[a],t[a+1]])+"] -> ("+lc([s,i])+")"),r=this.parseCmd(s,i),r||(r=this.parseMidrow(s,i)),r||(r=this.parsePAC(s,i)),r||(r=this.parseBackgroundAttributes(s,i)),!r&&(o=this.parseChars(s,i),o)){const l=this.currentChannel;l&&l>0?this.channels[l].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!o&&this.logger.log(2,"Couldn't parse cleaned data "+lc([s,i])+" orig: "+lc([t[a],t[a+1]]))}}parseCmd(e,t){const{cmdHistory:r}=this,s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,i=(e===23||e===31)&&t>=33&&t<=35;if(!(s||i))return!1;if(x$(e,t,r))return Su(null,null,r),this.logger.log(3,"Repeated command ("+lc([e,t])+") is dropped"),!0;const o=e===20||e===21||e===23?1:2,a=this.channels[o];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),Su(e,t,r),this.currentChannel=o,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+lc([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r;const s=this.cmdHistory,i=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,o=(e===16||e===24)&&t>=64&&t<=95;if(!(i||o))return!1;if(x$(e,t,s))return Su(null,null,s),!0;const a=e<=23?1:2;t>=64&&t<=95?r=a===1?Kae[e]:Xae[e]:r=a===1?Yae[e]:Qae[e];const l=this.channels[a];return l?(l.setPAC(this.interpretPAC(r,t)),Su(e,t,s),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,i=null;if(e>=25?(r=2,i=e-8):(r=1,i=e),i>=17&&i<=19){let o;i===17?o=t+80:i===18?o=t+112:o=t+144,this.logger.log(2,"Special char '"+_$(o)+"' in channel "+r),s=[o]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){const o=lc(s);this.logger.log(3,"Char codes = "+o.join(",")),Su(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){const r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let i;const o={};e===16||e===24?(i=Math.floor((t-32)/2),o.background=Jae[i],t%2===1&&(o.background=o.background+"_semi")):t===45?o.background="transparent":(o.foreground="black",t===47&&(o.underline=!0));const a=e<=23?1:2;return this.channels[a].setBkgData(o),Su(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}this.cmdHistory=S$()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function Su(n,e,t){t.a=n,t.b=e}function x$(n,e,t){return t.a===n&&t.b===e}function S$(){return{a:null,b:null}}class hg{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var VT=function(){if(du!=null&&du.VTTCue)return self.VTTCue;const n=["","lr","rl"],e=["start","middle","end","left","right"];function t(a,l){if(typeof l!="string"||!Array.isArray(a))return!1;const c=l.toLowerCase();return~a.indexOf(c)?c:!1}function r(a){return t(n,a)}function s(a){return t(e,a)}function i(a,...l){let c=1;for(;c<arguments.length;c++){const d=arguments[c];for(const f in d)a[f]=d[f]}return a}function o(a,l,c){const d=this,f={enumerable:!0};d.hasBeenReset=!1;let p="",m=!1,g=a,v=l,y=c,b=null,S="",E=!0,C="auto",R="start",I=50,A="middle",k=50,N="middle";Object.defineProperty(d,"id",i({},f,{get:function(){return p},set:function(D){p=""+D}})),Object.defineProperty(d,"pauseOnExit",i({},f,{get:function(){return m},set:function(D){m=!!D}})),Object.defineProperty(d,"startTime",i({},f,{get:function(){return g},set:function(D){if(typeof D!="number")throw new TypeError("Start time must be set to a number.");g=D,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",i({},f,{get:function(){return v},set:function(D){if(typeof D!="number")throw new TypeError("End time must be set to a number.");v=D,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",i({},f,{get:function(){return y},set:function(D){y=""+D,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",i({},f,{get:function(){return b},set:function(D){b=D,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",i({},f,{get:function(){return S},set:function(D){const M=r(D);if(M===!1)throw new SyntaxError("An invalid or illegal string was specified.");S=M,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",i({},f,{get:function(){return E},set:function(D){E=!!D,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",i({},f,{get:function(){return C},set:function(D){if(typeof D!="number"&&D!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");C=D,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",i({},f,{get:function(){return R},set:function(D){const M=s(D);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");R=M,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",i({},f,{get:function(){return I},set:function(D){if(D<0||D>100)throw new Error("Position must be between 0 and 100.");I=D,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",i({},f,{get:function(){return A},set:function(D){const M=s(D);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");A=M,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",i({},f,{get:function(){return k},set:function(D){if(D<0||D>100)throw new Error("Size must be between 0 and 100.");k=D,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",i({},f,{get:function(){return N},set:function(D){const M=s(D);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");N=M,this.hasBeenReset=!0}})),d.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o}();class nle{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function E$(n){function e(r,s,i,o){return(r|0)*3600+(s|0)*60+(i|0)+parseFloat(o||0)}const t=n.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class rle{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function w$(n,e,t,r){const s=r?n.split(r):[n];for(const i in s){if(typeof s[i]!="string")continue;const o=s[i].split(t);if(o.length!==2)continue;const a=o[0],l=o[1];e(a,l)}}const WT=new VT(0,0,""),pg=WT.align==="middle"?"middle":"center";function sle(n,e,t){const r=n;function s(){const a=E$(n);if(a===null)throw new Error("Malformed timestamp: "+r);return n=n.replace(/^[^\sa-zA-Z-]+/,""),a}function i(a,l){const c=new rle;w$(a,function(p,m){let g;switch(p){case"region":for(let v=t.length-1;v>=0;v--)if(t[v].id===m){c.set(p,t[v].region);break}break;case"vertical":c.alt(p,m,["rl","lr"]);break;case"line":g=m.split(","),c.integer(p,g[0]),c.percent(p,g[0])&&c.set("snapToLines",!1),c.alt(p,g[0],["auto"]),g.length===2&&c.alt("lineAlign",g[1],["start",pg,"end"]);break;case"position":g=m.split(","),c.percent(p,g[0]),g.length===2&&c.alt("positionAlign",g[1],["start",pg,"end","line-left","line-right","auto"]);break;case"size":c.percent(p,m);break;case"align":c.alt(p,m,["start",pg,"end","left","right"]);break}},/:/,/\s/),l.region=c.get("region",null),l.vertical=c.get("vertical","");let d=c.get("line","auto");d==="auto"&&WT.line===-1&&(d=-1),l.line=d,l.lineAlign=c.get("lineAlign","start"),l.snapToLines=c.get("snapToLines",!0),l.size=c.get("size",100),l.align=c.get("align",pg);let f=c.get("position","auto");f==="auto"&&WT.position===50&&(f=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=f}function o(){n=n.replace(/^\s+/,"")}if(o(),e.startTime=s(),o(),n.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);n=n.slice(3),o(),e.endTime=s(),o(),i(n,e)}function T$(n){return n.replace(/<br(?: \/)?>/gi,`
379 `)}class ile{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new nle,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let i=t.buffer,o=0;for(i=T$(i);o<i.length&&i[o]!=="\r"&&i[o]!==`
380 `;)++o;const a=i.slice(0,o);return i[o]==="\r"&&++o,i[o]===`
381 `&&++o,t.buffer=i.slice(o),a}function s(i){w$(i,function(o,a){},/:/)}try{let i="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;i=r();const a=i.match(/^()?WEBVTT([ \t].*)?$/);if(!(a!=null&&a[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let o=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:i=r(),t.state){case"HEADER":/:/.test(i)?s(i):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new VT(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{sle(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const a=i.indexOf("-->")!==-1;if(!i||a&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
382 `),t.cue.text+=i}continue;case"BADCUE":i||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
383
384 `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const ole=/\r\n|\n\r|\n|\r/g,KT=function(e,t,r=0){return e.slice(r,r+t.length)===t},ale=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),i=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!bt(t)||!bt(r)||!bt(s)||!bt(i))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*i,t},YT=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function XT(n,e,t){return YT(n.toString())+YT(e.toString())+YT(t)}const lle=function(e,t,r){let s=e[t],i=e[s.prevCC];if(!i||!i.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(o=i)!=null&&o.new;){var o;e.ccOffset+=s.start-i.start,s.new=!1,s=i,i=e[s.prevCC]}e.presentationOffset=r};function cle(n,e,t,r,s,i,o){const a=new ile,l=Oo(new Uint8Array(n)).trim().replace(ole,`
385 `).split(`
386 `),c=[],d=e?Oae(e.baseTime,e.timescale):0;let f="00:00.000",p=0,m=0,g,v=!0;a.oncue=function(y){const b=t[r];let S=t.ccOffset;const E=(p-d)/9e4;if(b!=null&&b.new&&(m!==void 0?S=t.ccOffset=b.start:lle(t,r,E)),E){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}S=E-t.presentationOffset}const C=y.endTime-y.startTime,R=Mi((y.startTime+S-m)*9e4,s*9e4)/9e4;y.startTime=Math.max(R,0),y.endTime=Math.max(R+C,0);const I=y.text.trim();y.text=decodeURIComponent(encodeURIComponent(I)),y.id||(y.id=XT(y.startTime,y.endTime,I)),y.endTime>0&&c.push(y)},a.onparsingerror=function(y){g=y},a.onflush=function(){if(g){o(g);return}i(c)},l.forEach(y=>{if(v)if(KT(y,"X-TIMESTAMP-MAP=")){v=!1,y.slice(16).split(",").forEach(b=>{KT(b,"LOCAL:")?f=b.slice(6):KT(b,"MPEGTS:")&&(p=parseInt(b.slice(7)))});try{m=ale(f)/1e3}catch(b){g=b}return}else y===""&&(v=!1);a.parse(y+`
387 `)}),a.flush()}const QT="stpp.ttml.im1t",C$=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,I$=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,ule={left:"start",center:"center",right:"end",start:"start",end:"end"};function R$(n,e,t,r){const s=on(new Uint8Array(n),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}const i=s.map(a=>Oo(a)),o=Nae(e.baseTime,1,e.timescale);try{i.forEach(a=>t(dle(a,o)))}catch(a){r(a)}}function dle(n,e){const s=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},o=Object.keys(i).reduce((f,p)=>(f[p]=s.getAttribute(`ttp:${p}`)||i[p],f),{}),a=s.getAttribute("xml:space")!=="preserve",l=A$(JT(s,"styling","style")),c=A$(JT(s,"layout","region")),d=JT(s,"body","[begin]");return[].map.call(d,f=>{const p=k$(f,a);if(!p||!f.hasAttribute("begin"))return null;const m=e1(f.getAttribute("begin"),o),g=e1(f.getAttribute("dur"),o);let v=e1(f.getAttribute("end"),o);if(m===null)throw L$(f);if(v===null){if(g===null)throw L$(f);v=m+g}const y=new VT(m-e,v-e,p);y.id=XT(y.startTime,y.endTime,y.text);const b=c[f.getAttribute("region")],S=l[f.getAttribute("style")],E=fle(b,S,l),{textAlign:C}=E;if(C){const R=ule[C];R&&(y.lineAlign=R),y.align=C}return Or(y,E),y}).filter(f=>f!==null)}function JT(n,e,t){const r=n.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function A$(n){return n.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function k$(n,e){return[].slice.call(n.childNodes).reduce((t,r,s)=>{var i;return r.nodeName==="br"&&s?t+`
388 `:(i=r.childNodes)!=null&&i.length?k$(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function fle(n,e,t){const r="http://www.w3.org/ns/ttml#styling";let s=null;const i=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return o&&t.hasOwnProperty(o)&&(s=t[o]),i.reduce((a,l)=>{const c=ZT(e,r,l)||ZT(n,r,l)||ZT(s,r,l);return c&&(a[l]=c),a},{})}function ZT(n,e,t){return n&&n.hasAttributeNS(e,t)?n.getAttributeNS(e,t):null}function L$(n){return new Error(`Could not parse ttml timestamp ${n}`)}function e1(n,e){if(!n)return null;let t=E$(n);return t===null&&(C$.test(n)?t=hle(n,e):I$.test(n)&&(t=ple(n,e))),t}function hle(n,e){const t=C$.exec(n),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function ple(n,e){const t=I$.exec(n),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}class M${constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=P$(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(Y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Y.FRAG_LOADING,this.onFragLoading,this),e.on(Y.FRAG_LOADED,this.onFragLoaded,this),e.on(Y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(Y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(Y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(Y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(Y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Y.FRAG_LOADING,this.onFragLoading,this),e.off(Y.FRAG_LOADED,this.onFragLoaded,this),e.off(Y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new hg(this,"textTrack1"),t=new hg(this,"textTrack2"),r=new hg(this,"textTrack3"),s=new hg(this,"textTrack4");this.cea608Parser1=new b$(1,e,t),this.cea608Parser2=new b$(3,r,s)}}addCues(e,t,r,s,i){let o=!1;for(let a=i.length;a--;){const l=i[a],c=mle(l[0],l[1],t,r);if(c>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),o=!0,c/(r-t)>.5))return}if(o||i.push([t,r]),this.config.renderTextTracksNatively){const a=this.captionsTracks[e];this.Cues.newCue(a,t,r,s)}else{const a=this.Cues.newCue(null,t,r,s);this.hls.trigger(Y.CUES_PARSED,{type:"captions",cues:a,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:i}){const{unparsedVttFrags:o}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:i}),o.length&&(this.unparsedVttFrags=[],o.forEach(a=>{this.onFragLoaded(Y.FRAG_LOADED,a)}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){const i=r.textTracks[s];if(O$(i,{name:e,lang:t}))return i}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:s}=this,{label:i,languageCode:o}=t[e],a=this.getExistingTrack(i,o);if(a)r[e]=a,hu(r[e]),mB(r[e],s);else{const l=this.createTextTrack("captions",i,o);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(Y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){const s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{hu(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=P$(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let r=0;r<t.length;r++)hu(t[r])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],s=r.some(i=>i.textCodec===QT);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(o$(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const o=this.media,a=o?Ym(o.textTracks):null;if(this.tracks.forEach((l,c)=>{let d;if(a){let f=null;for(let p=0;p<a.length;p++)if(a[p]&&O$(a[p],l)){f=a[p],a[p]=null;break}f&&(d=f)}if(d)hu(d);else{const f=N$(l);d=this.createTextTrack(f,l.name,l.lang),d&&(d.mode="disabled")}d&&this.textTracks.push(d)}),a!=null&&a.length){const l=a.filter(c=>c!==null).map(c=>c.label);l.length&&he.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const o=this.tracks.map(a=>({label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}));this.hls.trigger(Y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{const s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;const i=`textTrack${s[1]}`,o=this.captionsProperties[i];o&&(o.label=r.name,r.lang&&(o.languageCode=r.lang),o.media=r)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){this.initCea608Parsers();const{cea608Parser1:r,cea608Parser2:s,lastCc:i,lastSn:o,lastPartIndex:a}=this;if(!(!this.enabled||!r||!s)&&t.frag.type===zt.MAIN){var l,c;const{cc:d,sn:f}=t.frag,p=(l=t==null||(c=t.part)==null?void 0:c.index)!=null?l:-1;f===o+1||f===o&&p===a+1||d===i||(r.reset(),s.reset()),this.lastCc=d,this.lastSn=f,this.lastPartIndex=p}}onFragLoaded(e,t){const{frag:r,payload:s}=t;if(r.type===zt.SUBTITLE)if(s.byteLength){const i=r.decryptdata,o="stats"in t;if(i==null||!i.encrypted||o){const a=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===QT?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(Y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;R$(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(Y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{he.log(`Failed to parse IMSC1: ${s}`),r.trigger(Y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;const{frag:r,payload:s}=e,{initPTS:i,unparsedVttFrags:o}=this,a=i.length-1;if(!i[r.cc]&&a===-1){o.push(e);return}const l=this.hls,c=(t=r.initSegment)!=null&&t.data?Ai(r.initSegment.data,new Uint8Array(s)):s;cle(c,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,d=>{this._appendCues(d,r.level),l.trigger(Y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},d=>{const f=d.message==="Missing initPTS for VTT MPEGTS";f?o.push(e):this._fallbackToIMSC1(r,s),he.log(`Failed to parse VTT cue: ${d}`),!(f&&a>r.cc)&&l.trigger(Y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:d})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||R$(t,this.initPTS[e.cc],()=>{r.textCodec=QT,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(i=>gB(s,i))}else{const s=this.tracks[t];if(!s)return;const i=s.default?"default":"subtitles"+t;r.trigger(Y.CUES_PARSED,{type:"subtitles",cues:e,track:i})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===zt.SUBTITLE&&this.onFragLoaded(Y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;const{frag:i,samples:o}=t;if(!(i.type===zt.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let a=0;a<o.length;a++){const l=o[a].bytes;if(l){const c=this.extractCea608Data(l);r.addData(o[a].pts,c[0]),s.addData(o[a].pts,c[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:i}){const{media:o}=this;if(!(!o||o.currentTime<r)){if(!i||i==="video"){const{captionsTracks:a}=this;Object.keys(a).forEach(l=>TT(a[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){const{textTracks:a}=this;Object.keys(a).forEach(l=>TT(a[l],t,s))}}}extractCea608Data(e){const t=[[],[]],r=e[0]&31;let s=2;for(let i=0;i<r;i++){const o=e[s++],a=127&e[s++],l=127&e[s++];if(a===0&&l===0)continue;if((4&o)!==0){const d=3&o;(d===0||d===1)&&(t[d].push(a),t[d].push(l))}}return t}}function N$(n){return n.characteristics&&/transcribes-spoken-dialog/gi.test(n.characteristics)&&/describes-music-and-sound/gi.test(n.characteristics)?"captions":"subtitles"}function O$(n,e){return!!n&&n.kind===N$(e)&&HT(e,n)}function mle(n,e,t,r){return Math.min(e,r)-Math.max(n,t)}function P$(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class mg{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(Y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(Y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&bt(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&he.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((s,i)=>this.isLevelAllowed(s)&&i<=e);return this.clientRect=null,mg.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;const s=(a,l)=>l?a.width!==l.width||a.height!==l.height:!0;let i=e.length-1;const o=Math.max(t,r);for(let a=0;a<e.length;a+=1){const l=e[a];if((l.width>=o||l.height>=o)&&s(l,e[a+1])){i=a;break}}return i}}class D${constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(Y.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Y.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){const s=performance.now();if(t){if(this.lastTime){const i=s-this.lastTime,o=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,l=1e3*o/i,c=this.hls;if(c.trigger(Y.FPS_DROP,{currentDropped:o,currentDecoded:a,totalDroppedFrames:r}),l>0&&o>c.config.fpsDroppedMonitoringThreshold*a){let d=c.currentLevel;he.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(c.autoLevelCapping===-1||c.autoLevelCapping>=d)&&(d=d-1,c.trigger(Y.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:c.currentLevel}),c.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const gg="[eme]";class cc{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=cc.CDMCleanupPromise?[cc.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=he.debug.bind(he,gg),this.log=he.log.bind(he,gg),this.warn=he.warn.bind(he,gg),this.error=he.error.bind(he,gg),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Y.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Y.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===rr.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(o,a,l)=>!!o&&l.indexOf(o)===a,s=t.map(o=>o.audioCodec).filter(r),i=t.map(o=>o.videoCodec).filter(r);return s.length+i.length===0&&i.push("avc1.42e01e"),new Promise((o,a)=>{const l=c=>{const d=c.shift();this.getMediaKeysPromise(d,s,i).then(f=>o({keySystem:d,mediaKeys:f})).catch(f=>{c.length?l(c):f instanceof Ni?a(f):a(new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_NO_ACCESS,error:f,fatal:!0},f.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return BU===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){const s=Pie(e,t,r,this.config.drmSystemOptions),i=this.keySystemAccessPromises[e];let o=i==null?void 0:i.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),o=this.requestMediaKeySystemAccess(e,s);const a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),o.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),a.mediaKeys=l.createMediaKeys().then(d=>(this.log(`Media-keys created for "${e}"`),c.then(f=>f?this.setMediaKeysServerCertificate(d,e,f):d))),a.mediaKeys.catch(d=>{this.error(`Failed to create media-keys for "${e}"}: ${d}`)}),a.mediaKeys})}return o.then(()=>i.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Po.hexDump(e.keyId||[])}`);const s=r.createSession(),i={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),i="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,i,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Po.hexDump(e.keyId)}updateKeySession(e,t){var r;const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Po.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
389 } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{const s=mT(this.config),i=e.map(jU).filter(o=>!!o&&s.indexOf(o)!==-1);return this.getKeySystemSelectionPromise(i).then(({keySystem:o})=>{const a=UU(o);a?t(a):r(new Error(`Unable to find format for key-system "${o}"`))}).catch(r)})}loadKey(e){const t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let i=this.keyIdToKeySessionPromise[r];return i||(i=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:o,mediaKeys:a})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(o,a).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:o,mediaKeys:a,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),i.catch(o=>this.handleError(o))),i}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Ni?this.hls.trigger(Y.ERROR,e.data):this.hls.trigger(Y.ERROR,{type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){const s=jU(e.keyFormat),i=s?[s]:mT(this.config);return this.attemptKeySystemAccess(i)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=mT(this.config)),e.length===0)throw new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),r===null)return;let s,i;if(t==="sinf"&&this.config.drmSystems[rr.FAIRPLAY]){const d=Br(new Uint8Array(r));try{const f=hT(JSON.parse(d).sinf),p=YU(new Uint8Array(f));if(!p)return;s=p.subarray(8,24),i=rr.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const d=ooe(r);if(d===null)return;d.version===0&&d.systemId===FU.WIDEVINE&&d.data&&(s=d.data.subarray(8,24)),i=Oie(d.systemId)}if(!i||!s)return;const o=Po.hexDump(s),{keyIdToKeySessionPromise:a,mediaKeySessions:l}=this;let c=a[o];for(let d=0;d<l.length;d++){const f=l[d],p=f.decryptdata;if(p.pssh||!p.keyId)continue;const m=Po.hexDump(p.keyId);if(o===m||p.uri.replace(/-/g,"").indexOf(o)!==-1){c=a[m],delete a[m],p.pssh=new Uint8Array(r),p.keyId=s,c=a[o]=c.then(()=>this.generateRequestWithPreferredKeySession(f,t,r,"encrypted-event-key-match"));break}}c||(c=a[o]=this.getKeySystemSelectionPromise([i]).then(({keySystem:d,mediaKeys:f})=>{var p;this.throwIfDestroyed();const m=new fu("ISO-23001-7",o,(p=UU(d))!=null?p:"");return m.pssh=new Uint8Array(r),m.keyId=s,this.attemptSetMediaKeys(d,f).then(()=>{this.throwIfDestroyed();const g=this.createMediaKeySessionContext({decryptdata:m,keySystem:d,mediaKeys:f});return this.generateRequestWithPreferredKeySession(g,t,r,"encrypted-event-no-match")})})),c.catch(d=>this.handleError(d))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(i=>r.indexOf(i)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var i,o;const a=(i=this.config.drmSystems)==null||(o=i[e.keySystem])==null?void 0:o.generateRequest;if(a)try{const g=a.call(this.hls,t,r,e);if(!g)throw new Error("Invalid response from configured generateRequest filter");t=g.initDataType,r=e.decryptdata.pssh=g.initData?new Uint8Array(g.initData):null}catch(g){var l;if(this.warn(g.message),(l=this.hls)!=null&&l.config.debug)throw g}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${c} (init data type: ${t} length: ${r?r.byteLength:null})`);const d=new qT,f=e._onmessage=g=>{const v=e.mediaKeysSession;if(!v){d.emit("error",new Error("invalid state"));return}const{messageType:y,message:b}=g;this.log(`"${y}" message event for session "${v.sessionId}" message size: ${b.byteLength}`),y==="license-request"||y==="license-renewal"?this.renewLicense(e,b).catch(S=>{this.handleError(S),d.emit("error",S)}):y==="license-release"?e.keySystem===rr.FAIRPLAY&&(this.updateKeySession(e,pT("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${y}"`)},p=e._onkeystatuseschange=g=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const y=e.keyStatus;d.emit("keyStatus",y),y==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",f),e.mediaKeysSession.addEventListener("keystatuseschange",p);const m=new Promise((g,v)=>{d.on("error",v),d.on("keyStatus",y=>{y.startsWith("usable")?g():y==="output-restricted"?v(new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?v(new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${y}"`)):y==="expired"?v(new Error("key expired while generating request")):this.warn(`unhandled key status change "${y}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var g;this.log(`Request generated for key-session "${(g=e.mediaKeysSession)==null?void 0:g.sessionId}" keyId: ${c}`)}).catch(g=>{throw new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_NO_SESSION,error:g,fatal:!1},`Error generating key-session request: ${g}`)}).then(()=>m).catch(g=>{throw d.removeAllListeners(),this.removeSession(e),g}).then(()=>(d.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Po.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Po.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,r=t.loader,s=new r(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((o,a)=>{const l={responseType:"arraybuffer",url:i},c=t.certLoadPolicy.default,d={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(p,m,g,v)=>{o(p.data)},onError:(p,m,g,v)=>{a(new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:Xr({url:l.url,data:void 0},p)},`"${e}" certificate request failed (${i}). Status: ${p.code} (${p.text})`))},onTimeout:(p,m,g)=>{a(new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(p,m,g)=>{a(new Error("aborted"))}};s.load(l,d,f)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,i)=>{e.setServerCertificate(r).then(o=>{this.log(`setServerCertificate ${o?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(o=>{i(new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:o,fatal:!0},o.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=new DOMParser().parseFromString(r,"application/xml"),i=s.querySelectorAll("HttpHeader");if(i.length>0){let d;for(let f=0,p=i.length;f<p;f++){var o,a;d=i[f];const m=(o=d.querySelector("name"))==null?void 0:o.textContent,g=(a=d.querySelector("value"))==null?void 0:a.textContent;m&&g&&e.setRequestHeader(m,g)}}const l=s.querySelector("Challenge"),c=l==null?void 0:l.textContent;if(!c)throw new Error("Cannot find <Challenge> in key message");return pT(atob(c))}setupLicenseXHR(e,t,r,s){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return i.call(this.hls,e,t,r,s)}).catch(o=>{if(!r.decryptdata)throw o;return e.open("POST",t,!0),i.call(this.hls,e,t,r,s)}).then(o=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:o||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((s,i)=>{const o=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${o}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(a.readyState===4)if(a.status===200){this._requestLicenseFailureCount=0;let l=a.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,a,o,e)}catch(d){this.error(d)}s(l)}else{const l=r.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||a.status>=400&&a.status<500)i(new Ni({type:Gt.KEY_SYSTEM_ERROR,details:Ce.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${o}). Status: ${a.status} (${a.statusText})`));else{const d=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${d} attempts left`),this.requestLicense(e,t).then(s,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,o,e,t).then(({xhr:l,licenseChallenge:c})=>{e.keySystem==rr.PLAYREADY&&(c=this.unpackPlayReadyKeyMessage(l,c)),l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},fu.clearKeyUriToKeyIdMap();const r=t.length;cc.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const r=t.reduce((s,i)=>(s.indexOf(i.keyFormat)===-1&&s.push(i.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(i=>{this.log(`Could not remove session: ${i}`)}).then(()=>t.close()).catch(i=>{this.log(`Could not close session: ${i}`)})}}}cc.CDMCleanupPromise=void 0;class Ni extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var Es;(function(n){n.MANIFEST="m",n.AUDIO="a",n.VIDEO="v",n.MUXED="av",n.INIT="i",n.CAPTION="c",n.TIMED_TEXT="tt",n.KEY="k",n.OTHER="o"})(Es||(Es={}));var t1;(function(n){n.DASH="d",n.HLS="h",n.SMOOTH="s",n.OTHER="o"})(t1||(t1={}));var uc;(function(n){n.OBJECT="CMCD-Object",n.REQUEST="CMCD-Request",n.SESSION="CMCD-Session",n.STATUS="CMCD-Status"})(uc||(uc={}));const gle={[uc.OBJECT]:["br","d","ot","tb"],[uc.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[uc.SESSION]:["cid","pr","sf","sid","st","v"],[uc.STATUS]:["bs","rtp"]};class Eu{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof Eu?r:new Eu(r))),this.value=e,this.params=t}}class j${constructor(e){this.description=void 0,this.description=e}}const _le="Dict";function vle(n){return Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":typeof n=="object"?JSON.stringify(n):String(n)}function yle(n,e,t,r){return new Error(`failed to ${n} "${vle(e)}" as ${t}`,{cause:r})}const F$="Bare Item",ble="Boolean",xle="Byte Sequence",Sle="Decimal",Ele="Integer";function wle(n){return n<-999999999999999||999999999999999<n}const Tle=/[\x00-\x1f\x7f]+/,Cle="Token",Ile="Key";function Bo(n,e,t){return yle("serialize",n,e,t)}function Rle(n){if(typeof n!="boolean")throw Bo(n,ble);return n?"?1":"?0"}function Ale(n){return btoa(String.fromCharCode(...n))}function kle(n){if(ArrayBuffer.isView(n)===!1)throw Bo(n,xle);return`:${Ale(n)}:`}function U$(n){if(wle(n))throw Bo(n,Ele);return n.toString()}function Lle(n){return`@${U$(n.getTime()/1e3)}`}function B$(n,e){if(n<0)return-B$(-n,e);const t=Math.pow(10,e);if(Math.abs(n*t%1-.5)<Number.EPSILON){const s=Math.floor(n*t);return(s%2===0?s:s+1)/t}else return Math.round(n*t)/t}function Mle(n){const e=B$(n,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Bo(n,Sle);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Nle="String";function Ole(n){if(Tle.test(n))throw Bo(n,Nle);return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ple(n){return n.description||n.toString().slice(7,-1)}function $$(n){const e=Ple(n);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Bo(e,Cle);return e}function n1(n){switch(typeof n){case"number":if(!bt(n))throw Bo(n,F$);return Number.isInteger(n)?U$(n):Mle(n);case"string":return Ole(n);case"symbol":return $$(n);case"boolean":return Rle(n);case"object":if(n instanceof Date)return Lle(n);if(n instanceof Uint8Array)return kle(n);if(n instanceof j$)return $$(n);default:throw Bo(n,F$)}}function r1(n){if(/^[a-z*][a-z0-9\-_.*]*$/.test(n)===!1)throw Bo(n,Ile);return n}function s1(n){return n==null?"":Object.entries(n).map(([e,t])=>t===!0?`;${r1(e)}`:`;${r1(e)}=${n1(t)}`).join("")}function z$(n){return n instanceof Eu?`${n1(n.value)}${s1(n.params)}`:n1(n)}function Dle(n){return`(${n.value.map(z$).join(" ")})${s1(n.params)}`}function jle(n,e={whitespace:!0}){if(typeof n!="object")throw Bo(n,_le);const t=n instanceof Map?n.entries():Object.entries(n),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,i])=>{i instanceof Eu||(i=new Eu(i));let o=r1(s);return i.value===!0?o+=s1(i.params):(o+="=",Array.isArray(i.value)?o+=Dle(i):o+=z$(i)),o}).join(`,${r}`)}function Fle(n,e){return jle(n,e)}const Ule=n=>n==="ot"||n==="sf"||n==="st",Ble=n=>typeof n=="number"?bt(n):n!=null&&n!==""&&n!==!1;function $le(n,e){const t=new URL(n),r=new URL(e);if(t.origin!==r.origin)return n;const s=t.pathname.split("/").slice(1),i=r.pathname.split("/").slice(1,-1);for(;s[0]===i[0];)s.shift(),i.shift();for(;i.length;)i.shift(),s.unshift("..");return s.join("/")}function zle(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const i=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?i:i&3|8).toString(16)})}}}const _g=n=>Math.round(n),qle=(n,e)=>(e!=null&&e.baseUrl&&(n=$le(n,e.baseUrl)),encodeURIComponent(n)),vg=n=>_g(n/100)*100,Hle={br:_g,d:_g,bl:vg,dl:vg,mtp:vg,nor:qle,rtp:vg,tb:_g};function Gle(n,e){const t={};if(n==null||typeof n!="object")return t;const r=Object.keys(n).sort(),s=Or({},Hle,e==null?void 0:e.formatters),i=e==null?void 0:e.filter;return r.forEach(o=>{if(i!=null&&i(o))return;let a=n[o];const l=s[o];l&&(a=l(a,e)),!(o==="v"&&a===1)&&(o=="pr"&&a===1||Ble(a)&&(Ule(o)&&typeof a=="string"&&(a=new j$(a)),t[o]=a))}),t}function q$(n,e={}){return n?Fle(Gle(n,e),Or({whitespace:!1},e)):""}function Vle(n,e={}){if(!n)return{};const t=Object.entries(n),r=Object.entries(gle).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((i,o)=>{var a,l;const[c,d]=o,f=((a=r.find(p=>p[1].includes(c)))==null?void 0:a[0])||uc.REQUEST;return(l=i[f])!=null||(i[f]={}),i[f][c]=d,i},{});return Object.entries(s).reduce((i,[o,a])=>(i[o]=q$(a,e),i),{})}function Wle(n,e,t){return Or(n,Vle(e,t))}const Kle="CMCD";function Yle(n,e={}){if(!n)return"";const t=q$(n,e);return`${Kle}=${encodeURIComponent(t)}`}const H$=/CMCD=[^&#]+/;function Xle(n,e,t){const r=Yle(e,t);if(!r)return n;if(H$.test(n))return n.replace(H$,r);const s=n.includes("?")?"&":"?";return`${n}${s}${r}`}class G${constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Es.MANIFEST,su:!this.initialized})}catch(i){he.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=s=>{try{const i=s.frag,o=this.hls.levels[i.level],a=this.getObjectType(i),l={d:i.duration*1e3,ot:a};(a===Es.VIDEO||a===Es.AUDIO||a==Es.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(a)/1e3,l.bl=this.getBufferLength(a)),this.apply(s,l)}catch(i){he.warn("Could not generate segment CMCD data.",i)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||zle(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Y.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:t1.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Or(t,this.createData());const r=t.ot===Es.INIT||t.ot===Es.VIDEO||t.ot===Es.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((i,o)=>(s.includes(o)&&(i[o]=t[o]),i),{})),this.useHeaders?(e.headers||(e.headers={}),Wle(e.headers,t)):e.url=Xle(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Es.TIMED_TEXT;if(e.sn==="initSegment")return Es.INIT;if(t==="audio")return Es.AUDIO;if(t==="main")return this.hls.audioTracks.length?Es.VIDEO:Es.MUXED}getTopBandwidth(e){let t=0,r;const s=this.hls;if(e===Es.AUDIO)r=s.audioTracks;else{const i=s.maxAutoLevel,o=i>-1?i+1:s.levels.length;r=s.levels.slice(0,o)}for(const i of r)i.bitrate>t&&(t=i.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,r=e===Es.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Jn.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new r(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,o,a){t(i),this.loader.load(i,o,a)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new r(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,o,a){t(i),this.loader.load(i,o,a)}}}}const Qle=3e5;class V${constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=he.log.bind(he,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Y.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Y.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((r==null?void 0:r.action)===Qr.SendAlternateToPenaltyBox&&r.flags===Li.MoveAllAlternatesMatchingHost){const s=this.levels;let i=this.pathwayPriority,o=this.pathwayId;if(t.context){const{groupId:a,pathwayId:l,type:c}=t.context;a&&s?o=this.getPathwayForGroupId(a,c,o):l&&(o=l)}o in this.penalizedPathways||(this.penalizedPathways[o]=performance.now()),!i&&s&&(i=s.reduce((a,l)=>(a.indexOf(l.pathwayId)===-1&&a.push(l.pathwayId),a),[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==o),r.resolved||he.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${o} levels: ${s&&s.length} priorities: ${JSON.stringify(i)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(i=>{s-r[i]>Qle&&delete r[i]});for(let i=0;i<e.length;i++){const o=e[i];if(o in r)continue;if(o===this.pathwayId)return;const a=this.hls.nextLoadLevel,l=this.hls.levels[a];if(t=this.getLevelsForPathway(o),t.length>0){this.log(`Setting Pathway to "${o}"`),this.pathwayId=o,EB(t),this.hls.trigger(Y.LEVELS_UPDATED,{levels:t});const c=this.hls.levels[a];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=a);break}}}getPathwayForGroupId(e,t,r){const s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let i=0;i<s.length;i++)if(t===Sn.AUDIO_TRACK&&s[i].hasAudioGroup(e)||t===Sn.SUBTITLE_TRACK&&s[i].hasSubtitleGroup(e))return s[i].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},s={};e.forEach(i=>{const{ID:o,"BASE-ID":a,"URI-REPLACEMENT":l}=i;if(t.some(d=>d.pathwayId===o))return;const c=this.getLevelsForPathway(a).map(d=>{const f=new cr(d.attrs);f["PATHWAY-ID"]=o;const p=f.AUDIO&&`${f.AUDIO}_clone_${o}`,m=f.SUBTITLES&&`${f.SUBTITLES}_clone_${o}`;p&&(r[f.AUDIO]=p,f.AUDIO=p),m&&(s[f.SUBTITLES]=m,f.SUBTITLES=m);const g=K$(d.uri,f["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),v=new ac({attrs:f,audioCodec:d.audioCodec,bitrate:d.bitrate,height:d.height,name:d.name,url:g,videoCodec:d.videoCodec,width:d.width});if(d.audioGroups)for(let y=1;y<d.audioGroups.length;y++)v.addGroupId("audio",`${d.audioGroups[y]}_clone_${o}`);if(d.subtitleGroups)for(let y=1;y<d.subtitleGroups.length;y++)v.addGroupId("text",`${d.subtitleGroups[y]}_clone_${o}`);return v});t.push(...c),W$(this.audioTracks,r,l,o),W$(this.subtitleTracks,s,l,o)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const d=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+d)}const i={responseType:"json",url:s.href},o=t.steeringManifestLoadPolicy.default,a=o.errorRetry||o.timeoutRetry||{},l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},c={onSuccess:(d,f,p,m)=>{this.log(`Loaded steering manifest: "${s}"`);const g=d.data;if(g.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;const{"RELOAD-URI":v,"PATHWAY-CLONES":y,"PATHWAY-PRIORITY":b}=g;if(v)try{this.uri=new self.URL(v,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${v}`);return}this.scheduleRefresh(this.uri||p.url),y&&this.clonePathways(y);const S={steeringManifest:g,url:s.toString()};this.hls.trigger(Y.STEERING_MANIFEST_LOADED,S),b&&this.updatePathwayPriority(b)},onError:(d,f,p,m)=>{if(this.log(`Error loading steering manifest: ${d.code} ${d.text} (${f.url})`),this.stopLoad(),d.code===410){this.enabled=!1,this.log(`Steering manifest ${f.url} no longer available`);return}let g=this.timeToLoad*1e3;if(d.code===429){const v=this.loader;if(typeof(v==null?void 0:v.getResponseHeader)=="function"){const y=v.getResponseHeader("Retry-After");y&&(g=parseFloat(y)*1e3)}this.log(`Steering manifest ${f.url} rate limited`);return}this.scheduleRefresh(this.uri||f.url,g)},onTimeout:(d,f,p)=>{this.log(`Timeout loading steering manifest (${f.url})`),this.scheduleRefresh(this.uri||f.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(i,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;const s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function W$(n,e,t,r){n&&Object.keys(e).forEach(s=>{const i=n.filter(o=>o.groupId===s).map(o=>{const a=Or({},o);return a.details=void 0,a.attrs=new cr(a.attrs),a.url=a.attrs.URI=K$(o.url,o.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),a.groupId=a.attrs["GROUP-ID"]=e[s],a.attrs["PATHWAY-ID"]=r,a});n.push(...i)})}function K$(n,e,t,r){const{HOST:s,PARAMS:i,[t]:o}=r;let a;e&&(a=o==null?void 0:o[e],a&&(n=a));const l=new self.URL(n);return s&&!a&&(l.host=s),i&&Object.keys(i).sort().forEach(c=>{c&&l.searchParams.set(c,i[c])}),l.href}const Jle=/^age:\s*[\d.]+\s*$/im;class Y${constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Uf,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then(()=>{if(!this.stats.aborted)return i(r,t.url)}).catch(o=>(r.open("GET",t.url,!0),i(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(o=>{this.callbacks.onError({code:r.status,text:o.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:o}=r.loadPolicy;if(s)for(const a in s)e.setRequestHeader(a,s[a]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=i&&bt(i)?i:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const s=t.readyState,i=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const o=t.status,a=t.responseType!=="text";if(o>=200&&o<300&&(a&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const l=a?t.response:t.responseText,c=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=c,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;const d=this.callbacks.onProgress;if(d&&d(r,e,l,t),!this.callbacks)return;const f={url:t.responseURL,data:l,code:o};this.callbacks.onSuccess(f,r,e,t)}else{const l=i.loadPolicy.errorRetry,c=r.retry,d={url:e.url,data:void 0,code:o};Zm(l,c,!1,d)?this.retry(l):(he.error(`${o} while loading ${e.url}`),this.callbacks.onError({code:o,text:t.statusText},e,t,r))}}}loadtimeout(){var e;const t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(Zm(t,r,!0))this.retry(t);else{var s;he.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=MT(e,r.retry),r.retry++,he.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Jle.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function Zle(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const ece=/(\d+)-(\d+)\/(\d+)/;class X${constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||sce,this.controller=new self.AbortController,this.stats=new Uf}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const i=tce(e,this.controller.signal),o=r.onProgress,a=e.responseType==="arraybuffer",l=a?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=c&&bt(c)?c:d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(f=>{this.response=this.loader=f;const p=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},d-(p-s.loading.start)),!f.ok){const{status:m,statusText:g}=f;throw new ice(g||"fetch, bad network response",m,f)}return s.loading.first=p,s.total=rce(f.headers)||s.total,o&&bt(t.highWaterMark)?this.loadProgressively(f,s,e,t.highWaterMark,o):a?f.arrayBuffer():e.responseType==="json"?f.json():f.text()}).then(f=>{const p=this.response;if(!p)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const m=f[l];m&&(s.loaded=s.total=m);const g={url:p.url,data:f,code:p.status};o&&!bt(t.highWaterMark)&&o(s,e,f,p),r.onSuccess(g,s,e,p)}).catch(f=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const p=f&&f.code||0,m=f?f.message:null;r.onError({code:p,text:m},e,f?f.details:null,s)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,i){const o=new jB,a=e.body.getReader(),l=()=>a.read().then(c=>{if(c.done)return o.dataLength&&i(t,r,o.flush(),e),Promise.resolve(new ArrayBuffer(0));const d=c.value,f=d.length;return t.loaded+=f,f<s||o.dataLength?(o.push(d),o.dataLength>=s&&i(t,r,o.flush(),e)):i(t,r,d,e),l()}).catch(()=>Promise.reject());return l()}}function tce(n,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Or({},n.headers))};return n.rangeEnd&&t.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),t}function nce(n){const e=ece.exec(n);if(e)return parseInt(e[2])-parseInt(e[1])+1}function rce(n){const e=n.get("Content-Range");if(e){const r=nce(e);if(bt(r))return r}const t=n.get("Content-Length");if(t)return parseInt(t)}function sce(n,e){return new self.Request(n.url,e)}class ice extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const oce=/\s/,ace={newCue(n,e,t,r){const s=[];let i,o,a,l,c;const d=self.VTTCue||self.TextTrackCue;for(let p=0;p<r.rows.length;p++)if(i=r.rows[p],a=!0,l=0,c="",!i.isEmpty()){var f;for(let v=0;v<i.chars.length;v++)oce.test(i.chars[v].uchar)&&a?l++:(c+=i.chars[v].uchar,a=!1);i.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const m=T$(c.trim()),g=XT(e,t,m);n!=null&&(f=n.cues)!=null&&f.getCueById(g)||(o=new d(e,t,m),o.id=g,o.line=p+1,o.align="left",o.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(o))}return n&&s.length&&(s.sort((p,m)=>p.line==="auto"||m.line==="auto"?0:p.line>8&&m.line>8?m.line-p.line:p.line-m.line),s.forEach(p=>gB(n,p))),s}},lce={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Q$=Xr(Xr({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Y$,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:LB,bufferController:p$,capLevelController:mg,errorController:IB,fpsController:D$,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:BU,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:lce},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},cce()),{},{subtitleStreamController:d$,subtitleTrackController:f$,timelineController:M$,audioStreamController:l$,audioTrackController:c$,emeController:cc,cmcdController:G$,contentSteeringController:V$});function cce(){return{cueHandler:ace,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function uce(n,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=i1(n),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(i=>{const o=`${i==="level"?"playlist":i}LoadPolicy`,a=e[o]===void 0,l=[];s.forEach(c=>{const d=`${i}Loading${c}`,f=e[d];if(f!==void 0&&a){l.push(d);const p=t[o].default;switch(e[o]={default:p},c){case"TimeOut":p.maxLoadTimeMs=f,p.maxTimeToFirstByteMs=f;break;case"MaxRetry":p.errorRetry.maxNumRetry=f,p.timeoutRetry.maxNumRetry=f;break;case"RetryDelay":p.errorRetry.retryDelayMs=f,p.timeoutRetry.retryDelayMs=f;break;case"MaxRetryTimeout":p.errorRetry.maxRetryDelayMs=f,p.timeoutRetry.maxRetryDelayMs=f;break}}}),l.length&&he.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${JSON.stringify(e[o])}`)}),Xr(Xr({},t),e)}function i1(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(i1):Object.keys(n).reduce((e,t)=>(e[t]=i1(n[t]),e),{}):n}function dce(n){const e=n.loader;e!==X$&&e!==Y$?(he.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):Zle()&&(n.loader=X$,n.progressive=!0,n.enableSoftwareAES=!0,he.log("[config]: Progressive streaming enabled, using FetchLoader"))}let o1;class fce extends tg{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Y.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Y.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,s=[],i={},o={};let a=!1,l=!1,c=!1;t.levels.forEach(d=>{var f,p;const m=d.attrs;let{audioCodec:g,videoCodec:v}=d;((f=g)==null?void 0:f.indexOf("mp4a.40.34"))!==-1&&(o1||(o1=/chrome|firefox/i.test(navigator.userAgent)),o1&&(d.audioCodec=g=void 0)),g&&(d.audioCodec=g=Km(g,r)),((p=v)==null?void 0:p.indexOf("avc1"))===0&&(v=d.videoCodec=foe(v));const{width:y,height:b,unknownCodecs:S}=d;if(a||(a=!!(y&&b)),l||(l=!!v),c||(c=!!g),S!=null&&S.length||g&&!ST(g,"audio",r)||v&&!ST(v,"video",r))return;const{CODECS:E,"FRAME-RATE":C,"HDCP-LEVEL":R,"PATHWAY-ID":I,RESOLUTION:A,"VIDEO-RANGE":k}=m,D=`${`${I||"."}-`}${d.bitrate}-${A}-${C}-${E}-${k}-${R}`;if(i[D])if(i[D].uri!==d.url&&!d.attrs["PATHWAY-ID"]){const M=o[D]+=1;d.attrs["PATHWAY-ID"]=new Array(M+1).join(".");const F=new ac(d);i[D]=F,s.push(F)}else i[D].addGroupId("audio",m.AUDIO),i[D].addGroupId("text",m.SUBTITLES);else{const M=new ac(d);i[D]=M,o[D]=1,s.push(M)}}),this.filterAndSortMediaOptions(s,t,a,l,c)}filterAndSortMediaOptions(e,t,r,s,i){let o=[],a=[],l=e;if((r||s)&&i&&(l=l.filter(({videoCodec:g,videoRange:v,width:y,height:b})=>(!!g||!!(y&&b))&&Toe(v))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const g=new Error("no level with compatible codecs found in manifest");this.hls.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:g,reason:g.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:g}=this.hls.config;o=t.audioTracks.filter(v=>!v.audioCodec||ST(v.audioCodec,"audio",g)),J$(o)}t.subtitles&&(a=t.subtitles,J$(a));const c=l.slice(0);l.sort((g,v)=>{if(g.attrs["HDCP-LEVEL"]!==v.attrs["HDCP-LEVEL"])return(g.attrs["HDCP-LEVEL"]||"")>(v.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&g.height!==v.height)return g.height-v.height;if(g.frameRate!==v.frameRate)return g.frameRate-v.frameRate;if(g.videoRange!==v.videoRange)return Qm.indexOf(g.videoRange)-Qm.indexOf(v.videoRange);if(g.videoCodec!==v.videoCodec){const y=rB(g.videoCodec),b=rB(v.videoCodec);if(y!==b)return b-y}if(g.uri===v.uri&&g.codecSet!==v.codecSet){const y=Wm(g.codecSet),b=Wm(v.codecSet);if(y!==b)return b-y}return g.averageBitrate!==v.averageBitrate?g.averageBitrate-v.averageBitrate:0});let d=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let g=0;g<c.length;g++)if(c[g].pathwayId===l[0].pathwayId){d=c[g];break}}this._levels=l;for(let g=0;g<l.length;g++)if(l[g]===d){var f;this._firstLevel=g;const v=d.bitrate,y=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${v}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){const b=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);b>y&&y===Q$.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=b)}break}const p=i&&!s,m={levels:l,audioTracks:o,subtitleTracks:a,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:i,video:s,altAudio:!p&&o.some(g=>!!g.url)};this.hls.trigger(Y.MANIFEST_PARSED,m),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const d=new Error("invalid level idx"),f=e<0;if(this.hls.trigger(Y.ERROR,{type:Gt.OTHER_ERROR,details:Ce.LEVEL_SWITCH_ERROR,level:e,fatal:f,error:d,reason:d.message}),f)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,s=this.currentLevel,i=s?s.attrs["PATHWAY-ID"]:void 0,o=t[e],a=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,r===e&&o.details&&s&&i===a)return;this.log(`Switching to level ${e} (${o.height?o.height+"p ":""}${o.videoRange?o.videoRange+" ":""}${o.codecSet?o.codecSet+" ":""}@${o.bitrate})${a?" with Pathway "+a:""} from level ${r}${i?" with Pathway "+i:""}`);const l={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(Y.LEVEL_SWITCHING,l);const c=o.details;if(!c||c.live){const d=this.switchParams(o.uri,s==null?void 0:s.details);this.loadPlaylist(d)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Sn.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===zt.MAIN){const r=t.elementaryStreams;if(!Object.keys(r).some(i=>!!r[i]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;const{level:s,details:i}=t,o=this._levels[s];if(!o){var a;this.warn(`Invalid level index ${s}`),(a=t.deliveryDirectives)!=null&&a.skip&&(i.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(o.fragmentError===0&&(o.loadError=0),this.playlistLoaded(s,t,o.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(i.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}const i=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${i?" Pathway "+i:""} ${s}`),this.clearTimer(),this.hls.trigger(Y.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const r=this._levels.filter((s,i)=>i!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(o=>o.level=-1)),!1));EB(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(Y.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(Y.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function J$(n){const e={};n.forEach(t=>{const r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}class hce{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=Ce.KEY_LOAD_ERROR,r,s,i){return new aa({type:Gt.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:i,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:s}=e;for(let i=0;i<t.length;i++){const o=t[i];if(s<=o.cc&&(r==="initSegment"||o.sn==="initSegment"||r<o.sn)){this.emeController.selectKeySystemFormat(o).then(a=>{o.setKeyFormat(a)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);const i=e.decryptdata;if(!i){const c=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,Ce.KEY_LOAD_ERROR,c))}const o=i.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,Ce.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));let a=this.keyUriToKeyInfo[o];if((r=a)!=null&&r.decryptdata.key)return i.key=a.decryptdata.key,Promise.resolve({frag:e,keyInfo:a});if((s=a)!=null&&s.keyLoadPromise){var l;switch((l=a.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then(c=>(i.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:a}))}}switch(a=this.keyUriToKeyInfo[o]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return i.keyFormat==="identity"?this.loadKeyHTTP(a,e):this.loadKeyEME(a,e);case"AES-128":return this.loadKeyHTTP(a,e);default:return Promise.reject(this.createKeyLoadError(e,Ce.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(i=>(e.mediaKeySessionContext=i,r))).catch(i=>{throw e.keyLoadPromise=null,i})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,s=r.loader,i=new s(r);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((o,a)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=r.keyLoadPolicy.default,d={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(p,m,g,v)=>{const{frag:y,keyInfo:b,url:S}=g;if(!y.decryptdata||b!==this.keyUriToKeyInfo[S])return a(this.createKeyLoadError(y,Ce.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),v));b.decryptdata.key=y.decryptdata.key=new Uint8Array(p.data),y.keyLoader=null,b.loader=null,o({frag:y,keyInfo:b})},onError:(p,m,g,v)=>{this.resetLoader(m),a(this.createKeyLoadError(t,Ce.KEY_LOAD_ERROR,new Error(`HTTP Error ${p.code} loading key ${p.text}`),g,Xr({url:l.url,data:void 0},p)))},onTimeout:(p,m,g)=>{this.resetLoader(m),a(this.createKeyLoadError(t,Ce.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(p,m,g)=>{this.resetLoader(m),a(this.createKeyLoadError(t,Ce.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};i.load(l,d,f)})}resetLoader(e){const{frag:t,keyInfo:r,url:s}=e,i=r.loader;t.keyLoader===i&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],i&&i.destroy()}}function Z$(){return self.SourceBuffer||self.WebKitSourceBuffer}function a1(){if(!oc())return!1;const e=Z$();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function e3(){if(!a1())return!1;const n=oc();return typeof(n==null?void 0:n.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>n.isTypeSupported($f(e,"video")))||["mp4a.40.2","fLaC"].some(e=>n.isTypeSupported($f(e,"audio"))))}function pce(){var n;const e=Z$();return typeof(e==null||(n=e.prototype)==null?void 0:n.changeType)=="function"}const mce=250,yg=2,gce=.1,_ce=.05;class vce{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:r,media:s,stalled:i}=this;if(s===null)return;const{currentTime:o,seeking:a}=s,l=this.seeking&&!a,c=!this.seeking&&a;if(this.seeking=a,o!==e){if(this.moved=!0,a||(this.nudgeRetry=0),i!==null){if(this.stallReported){const y=self.performance.now()-i;he.warn(`playback not stuck anymore @${o}, after ${Math.round(y)}ms`),this.stallReported=!1}this.stalled=null}return}if(c||l){this.stalled=null;return}if(s.paused&&!a||s.ended||s.playbackRate===0||!Jn.getBuffered(s).length){this.nudgeRetry=0;return}const d=Jn.bufferInfo(s,o,0),f=d.nextStart||0;if(a){const y=d.len>yg,b=!f||t&&t.start<=o||f-o>yg&&!this.fragmentTracker.getPartialFragment(o);if(y||b)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var p;if(!(d.len>0)&&!f)return;const b=Math.max(f,d.start||0)-o,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,C=(S==null||(p=S.details)==null?void 0:p.live)?S.details.targetduration*2:yg,R=this.fragmentTracker.getPartialFragment(o);if(b>0&&(b<=C||R)){s.paused||this._trySkipBufferHole(R);return}}const m=self.performance.now();if(i===null){this.stalled=m;return}const g=m-i;if(!a&&g>=mce&&(this._reportStall(d),!this.media))return;const v=Jn.bufferInfo(s,o,r.maxBufferHole);this._tryFixBufferStall(v,g)}_tryFixBufferStall(e,t){const{config:r,fragmentTracker:s,media:i}=this;if(i===null)return;const o=i.currentTime,a=s.getPartialFragment(o);a&&(this._trySkipBufferHole(a)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-o<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(he.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);he.warn(i.message),t.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:r,media:s}=this;if(s===null)return 0;const i=s.currentTime,o=Jn.bufferInfo(s,i,0),a=i<o.start?o.start:o.nextStart;if(a){const l=o.len<=t.maxBufferHole,c=o.len>0&&o.len<1&&s.readyState<3,d=a-i;if(d>0&&(l||c)){if(d>t.maxBufferHole){const{fragmentTracker:p}=this;let m=!1;if(i===0){const g=p.getAppendedFrag(0,zt.MAIN);g&&a<g.end&&(m=!0)}if(!m){const g=e||p.getAppendedFrag(i,zt.MAIN);if(g){let v=!1,y=g.end;for(;y<a;){const b=p.getPartialFragment(y);if(b)y+=b.duration;else{v=!0;break}}if(v)return 0}}}const f=Math.max(a+_ce,i+gce);if(he.warn(`skipping hole, adjusting currentTime from ${i} to ${f}`),this.moved=!0,this.stalled=null,s.currentTime=f,e&&!e.gap){const p=new Error(`fragment loaded with buffer holes, seeking from ${i} to ${f}`);r.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:p,reason:p.message,frag:e})}return f}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;const i=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){const o=i+(s+1)*e.nudgeOffset,a=new Error(`Nudging 'currentTime' from ${i} to ${o}`);he.warn(a.message),r.currentTime=o,t.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const o=new Error(`Playhead still not moving while enough data buffered @${i} after ${e.nudgeMaxRetry} nudges`);he.error(o.message),t.trigger(Y.ERROR,{type:Gt.MEDIA_ERROR,details:Ce.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}}const yce=100;class bce extends ag{constructor(e,t,r){super(e,t,r,"[stream-controller]",zt.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Y.LEVEL_LOADING,this.onLevelLoading,this),e.on(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Y.ERROR,this.onError,this),e.on(Y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Y.BUFFER_CREATED,this.onBufferCreated,this),e.on(Y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(Y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Y.ERROR,this.onError,this),e.off(Y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Y.BUFFER_CREATED,this.onBufferCreated,this),e.off(Y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(yce),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=$e.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=$e.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case $e.WAITING_LEVEL:{const{levels:t,level:r}=this,s=t==null?void 0:t[r],i=s==null?void 0:s.details;if(i&&(!i.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(i))break;this.state=$e.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=$e.IDLE;break}break}case $e.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){const{levels:s,level:i}=this,o=s==null?void 0:s[i];this.resetStartWhenNotLoaded(o||null),this.state=$e.IDLE}}break}this.state===$e.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:s}=this,{config:i,nextLoadLevel:o}=e;if(t===null||!s&&(this.startFragRequested||!i.startFragPrefetch)||this.altAudio&&this.audioOnly||!(r!=null&&r[o]))return;const a=r[o],l=this.getMainFwdBufferInfo();if(l===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(l,c)){const y={};this.altAudio&&(y.type="video"),this.hls.trigger(Y.BUFFER_EOS,y),this.state=$e.ENDED;return}e.loadLevel!==o&&e.manualLevel===-1&&this.log(`Adapting to level ${o} from level ${this.level}`),this.level=e.nextLoadLevel=o;const d=a.details;if(!d||this.state===$e.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=o,this.state=$e.WAITING_LEVEL;return}const f=l.len,p=this.getMaxBufferLength(a.maxBitrate);if(f>=p)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);const m=this.backtrackFragment?this.backtrackFragment.start:l.end;let g=this.getNextFragment(m,d);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==Jr.OK){var v;const b=((v=this.backtrackFragment)!=null?v:g).sn-d.startSN,S=d.fragments[b-1];S&&g.cc===S.cc&&(g=S,this.fragmentTracker.removeFragment(S))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,m)){if(!g.gap){const b=this.audioOnly&&!this.altAudio?Dn.AUDIO:Dn.VIDEO,S=(b===Dn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;S&&this.afterBufferFlushed(S,b,zt.MAIN)}g=this.getNextFragmentLoopLoading(g,d,l,zt.MAIN,p)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,a,m))}loadFragment(e,t,r){const s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===Jr.NOT_LOADED||s===Jr.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,zt.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let r;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const i=this.getLevelDetails();if(i!=null&&i.live){const a=this.getMainFwdBufferInfo();if(!a||a.len<i.targetduration*2)return}if(!t.paused&&e){const a=this.hls.nextLoadLevel,l=e[a],c=this.fragLastKbps;c&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:r=0}else r=0;const o=this.getBufferedFrag(t.currentTime+r);if(o){const a=this.followingBufferedFrag(o);if(a){this.abortCurrentFrag();const l=a.maxStartPTS?a.maxStartPTS:a.start,c=a.duration,d=Math.max(o.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case $e.KEY_LOADING:case $e.FRAG_LOADING:case $e.FRAG_LOADING_WAITING_RETRY:case $e.PARSING:case $e.PARSED:this.state=$e.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new vce(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;bt(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(Y.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(i=>{const o=i.audioCodec;o&&(r=r||o.indexOf("mp4a.40.2")!==-1,s=s||o.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!pce(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==$e.IDLE)return;const s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=$e.WAITING_LEVEL)}onLevelLoaded(e,t){var r;const{levels:s}=this,i=t.level,o=t.details,a=o.totalduration;if(!s){this.warn(`Levels were reset while loading level ${i}`);return}this.log(`Level ${i} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${a}`);const l=s[i],c=this.fragCurrent;c&&(this.state===$e.FRAG_LOADING||this.state===$e.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let d=0;if(o.live||(r=l.details)!=null&&r.live){var f;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,l.details,(f=this.levelLastLoaded)==null?void 0:f.details)}if(l.details=o,this.levelLastLoaded=l,this.hls.trigger(Y.LEVEL_UPDATED,{details:o,level:i}),this.state===$e.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=$e.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,d),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:s,payload:i}=e,{levels:o}=this;if(!o){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const a=o[r.level],l=a.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}const c=a.videoCodec,d=l.PTSKnown||!l.live,f=(t=r.initSegment)==null?void 0:t.data,p=this._getAudioCodec(a),m=this.transmuxer=this.transmuxer||new i$(this.hls,zt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,v=g!==-1,y=new rg(r.level,r.sn,r.stats.chunkCount,i.byteLength,g,v),b=this.initPTS[r.cc];m.push(i,f,p,c,r,s,l.totalduration,d,y,b)}onAudioTrackSwitching(e,t){const r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const i=this.hls;r&&(i.trigger(Y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(Y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=t.id,s=!!this.hls.audioTracks[r].url;if(s){const i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=s,this.tick()}onBufferCreated(e,t){const r=t.tracks;let s,i,o=!1;for(const a in r){const l=r[a];if(l.id==="main"){if(i=a,s=l,a==="video"){const c=r[a];c&&(this.videoBuffer=c.buffer)}}else o=!0}o&&s?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:s}=t;if(r&&r.type!==zt.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===$e.PARSED&&(this.state=$e.IDLE);return}const i=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=$e.ERROR;return}switch(t.details){case Ce.FRAG_GAP:case Ce.FRAG_PARSING_ERROR:case Ce.FRAG_DECRYPT_ERROR:case Ce.FRAG_LOAD_ERROR:case Ce.FRAG_LOAD_TIMEOUT:case Ce.KEY_LOAD_ERROR:case Ce.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(zt.MAIN,t);break;case Ce.LEVEL_LOAD_ERROR:case Ce.LEVEL_LOAD_TIMEOUT:case Ce.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===$e.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Sn.LEVEL&&(this.state=$e.IDLE);break;case Ce.BUFFER_APPEND_ERROR:case Ce.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===Ce.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case Ce.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Jn.getBuffered(e).length){const r=this.state!==$e.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=$e.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Dn.AUDIO||this.audioOnly&&!this.altAudio){const r=(t===Dn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,zt.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}const s=Jn.getBuffered(e),o=(s.length?s.start(0):0)-r;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),r+=o,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{const{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=$e.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const i=e.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),s.trigger(Y.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const r="main",{hls:s}=this,{remuxResult:i,chunkMeta:o}=e,a=this.getCurrentContext(o);if(!a){this.resetWhenMissingContext(o);return}const{frag:l,part:c,level:d}=a,{video:f,text:p,id3:m,initSegment:g}=i,{details:v}=d,y=this.altAudio?void 0:i.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=$e.PARSING,g){if(g!=null&&g.tracks){const E=l.initSegment||l;this._bufferInitSegment(d,g.tracks,E,o),s.trigger(Y.FRAG_PARSING_INIT_SEGMENT,{frag:E,id:r,tracks:g.tracks})}const b=g.initPTS,S=g.timescale;bt(b)&&(this.initPTS[l.cc]={baseTime:b,timescale:S},s.trigger(Y.INIT_PTS_FOUND,{frag:l,id:r,initPTS:b,timescale:S}))}if(f&&v&&l.sn!=="initSegment"){const b=v.fragments[l.sn-1-v.startSN],S=l.sn===v.startSN,E=!b||l.cc>b.cc;if(i.independent!==!1){const{startPTS:C,endPTS:R,startDTS:I,endDTS:A}=f;if(c)c.elementaryStreams[f.type]={startPTS:C,endPTS:R,startDTS:I,endDTS:A};else if(f.firstKeyFrame&&f.independent&&o.id===1&&!E&&(this.couldBacktrack=!0),f.dropped&&f.independent){const k=this.getMainFwdBufferInfo(),N=(k?k.end:this.getLoadPosition())+this.config.maxBufferHole,D=f.firstKeyFramePTS?f.firstKeyFramePTS:C;if(!S&&N<D-this.config.maxBufferHole&&!E){this.backtrack(l);return}else E&&(l.gap=!0);l.setElementaryStreamInfo(f.type,l.start,R,l.start,A,!0)}else S&&C>yg&&(l.gap=!0);l.setElementaryStreamInfo(f.type,C,R,I,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(f,l,c,o,S||E)}else if(S||E)l.gap=!0;else{this.backtrack(l);return}}if(y){const{startPTS:b,endPTS:S,startDTS:E,endDTS:C}=y;c&&(c.elementaryStreams[Dn.AUDIO]={startPTS:b,endPTS:S,startDTS:E,endDTS:C}),l.setElementaryStreamInfo(Dn.AUDIO,b,S,E,C),this.bufferFragmentData(y,l,c,o)}if(v&&m!=null&&(t=m.samples)!=null&&t.length){const b={id:r,frag:l,details:v,samples:m.samples};s.trigger(Y.FRAG_PARSING_METADATA,b)}if(v&&p){const b={id:r,frag:l,details:v,samples:p.samples};s.trigger(Y.FRAG_PARSING_USERDATA,b)}}_bufferInitSegment(e,t,r,s){if(this.state!==$e.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:i,video:o,audiovideo:a}=t;if(i){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),i.metadata.channelCount!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")),l&&l.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&i.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),i.levelCodec=l,i.id="main",this.log(`Init audio buffer, container:${i.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${i.codec}]`)}o&&(o.levelCodec=e.videoCodec,o.id="main",this.log(`Init video buffer, container:${o.container}, codecs[level/parsed]=[${e.videoCodec||""}/${o.codec}]`)),a&&this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),this.hls.trigger(Y.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const d=t[l].initSegment;d!=null&&d.byteLength&&this.hls.trigger(Y.BUFFER_APPENDING,{type:l,data:d,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,zt.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=$e.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const r=e.currentTime;if(Jn.isBuffered(e,r)?t=this.getAppendedFrag(r):Jn.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const s=this.fragPlaying,i=t.level;(!s||t.sn!==s.sn||s.level!==i)&&(this.fragPlaying=t,this.hls.trigger(Y.FRAG_CHANGED,{frag:t}),(!s||s.level!==i)&&this.hls.trigger(Y.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,r=this.currentFrag;if(r&&bt(t)&&bt(r.programDateTime)){const s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Xa{static get version(){return"1.5.4"}static isMSESupported(){return a1()}static isSupported(){return e3()}static getMediaSource(){return oc()}static get Events(){return Y}static get ErrorTypes(){return Gt}static get ErrorDetails(){return Ce}static get DefaultConfig(){return Xa.defaultConfig?Xa.defaultConfig:Q$}static set DefaultConfig(e){Xa.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new qT,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,Cie(e.debug||!1,"Hls instance");const t=this.config=uce(Xa.DefaultConfig,e);this.userConfig=e,t.progressive&&dce(t);const{abrController:r,bufferController:s,capLevelController:i,errorController:o,fpsController:a}=t,l=new o(this),c=this.abrController=new r(this),d=this.bufferController=new s(this),f=this.capLevelController=new i(this),p=new a(this),m=new _oe(this),g=new Soe(this),v=t.contentSteeringController,y=v?new v(this):null,b=this.levelController=new fce(this,y),S=new Yoe(this),E=new hce(this.config),C=this.streamController=new bce(this,S,E);f.setStreamController(C),p.setStreamController(C);const R=[m,b,C];y&&R.splice(1,0,y),this.networkControllers=R;const I=[c,d,f,p,g,S];this.audioTrackController=this.createController(t.audioTrackController,R);const A=t.audioStreamController;A&&R.push(new A(this,S,E)),this.subtitleTrackController=this.createController(t.subtitleTrackController,R);const k=t.subtitleStreamController;k&&R.push(new k(this,S,E)),this.createController(t.timelineController,I),E.emeController=this.emeController=this.createController(t.emeController,I),this.cmcdController=this.createController(t.cmcdController,I),this.latencyController=this.createController(Eoe,I),this.coreComponents=I,R.push(l);const N=l.onErrorOut;typeof N=="function"&&this.on(Y.ERROR,N,l)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(he.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;const s=e===Y.ERROR;this.trigger(Y.ERROR,{type:Gt.OTHER_ERROR,details:Ce.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){he.log("destroy"),this.trigger(Y.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){he.log("attachMedia"),this._media=e,this.trigger(Y.MEDIA_ATTACHING,{media:e})}detachMedia(){he.log("detachMedia"),this.trigger(Y.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,r=this.url,s=this.url=cT.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,he.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Y.MANIFEST_LOADING,{url:e})}startLoad(e=-1){he.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){he.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){he.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){he.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){he.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){he.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){he.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){he.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){he.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(he.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){woe(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let i=s;i--;){const o=e[i].attrs["HDCP-LEVEL"];if(o&&o<=r)return i}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Xa.defaultConfig=void 0;const xce=Object.freeze(Object.defineProperty({__proto__:null,AbrController:LB,AttrList:cr,AudioStreamController:l$,AudioTrackController:c$,BasePlaylistController:tg,BaseSegment:fT,BaseStreamController:ag,BufferController:p$,CMCDController:G$,CapLevelController:mg,ChunkMetadata:rg,ContentSteeringController:V$,DateRange:dT,EMEController:cc,ErrorActionFlags:Li,ErrorController:IB,ErrorDetails:Ce,ErrorTypes:Gt,Events:Y,FPSController:D$,Fragment:$m,Hls:Xa,HlsSkip:pu,HlsUrlParameters:AT,KeySystemFormats:js,KeySystems:rr,Level:ac,LevelDetails:DU,LevelKey:fu,LoadStats:Uf,MetadataSchema:ki,NetworkErrorAction:Qr,Part:PU,PlaylistLevelType:zt,SubtitleStreamController:d$,SubtitleTrackController:f$,TimelineController:M$,default:Xa,getMediaSource:oc,isMSESupported:a1,isSupported:e3},Symbol.toStringTag,{value:"Module"}));return mo.mountChatWidget=LU,mo.unmountChatWidget=lT,Object.defineProperty(mo,Symbol.toStringTag,{value:"Module"}),mo}({});
390