@vanira/sdk 0.0.84 → 0.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/headless/index.cjs +559 -166
- package/dist/headless/index.d.ts +3 -0
- package/dist/headless/index.js +43823 -4080
- package/dist/index.d.ts +43 -0
- package/dist/platforms/browser.cjs +41 -3
- package/dist/platforms/browser.d.ts +3 -0
- package/dist/platforms/browser.js +21303 -689
- package/dist/platforms/react-native.cjs +1 -1
- package/dist/platforms/react-native.js +384 -356
- package/dist/vanira-sdk.es.js +47457 -7701
- package/dist/vanira-sdk.js +579 -229
- package/dist/vanira-sdk.umd.js +612 -219
- package/package.json +8 -6
- package/dist/chunks/html2canvas.js +0 -6
package/dist/headless/index.cjs
CHANGED
|
@@ -1,117 +1,450 @@
|
|
|
1
|
-
"use strict";var Ar=Object.defineProperty;var Ir=(n,e,t)=>e in n?Ar(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e,t)=>Ir(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react");var Oe=typeof document<"u"?document.currentScript:null;const Lr="https://api.vanira.io",m={Form:"vanira_form",Calendar:"vanira_calendar",Navigate:"vanira_navigate",Upload:"vanira_upload",Camera:"vanira_camera",HighlightElement:"vanira_highlight_element",ClickElement:"vanira_click_element",SelectOption:"vanira_select_option",SetDate:"vanira_set_date",TypeText:"vanira_type_text",EraseText:"vanira_erase_text",Draw:"vanira_draw",EraseDraw:"vanira_erase_draw",LiveVision:"vanira_live_vision",CloseLiveCamera:"vanira_close_live_camera",LiveScreen:"vanira_live_screen",CloseLiveScreen:"vanira_close_live_screen",ClipRegion:"vanira_clip_region",TabScreenshot:"vanira_tab_screenshot",ScreenInk:"vanira_screen_ink",ScreenCursor:"vanira_screen_cursor",ScreenClick:"vanira_screen_click",ClearScreenOverlay:"vanira_clear_screen_overlay",PageScan:"vanira_page_scan",PointAt:"vanira_point_at",OutlineTargets:"vanira_outline_targets",ClearGuide:"vanira_clear_guide"},Pr=Object.values(m),Mr=new Set(Pr),Nr=new Set([m.Camera,m.LiveVision,m.LiveScreen]),Dr=new Set([m.Navigate,m.HighlightElement,m.ClickElement,m.SelectOption,m.SetDate,m.TypeText,m.EraseText,m.Draw,m.EraseDraw,m.LiveVision,m.CloseLiveCamera,m.LiveScreen,m.CloseLiveScreen,m.TabScreenshot,m.ScreenInk,m.ScreenCursor,m.ScreenClick,m.ClearScreenOverlay,m.PageScan,m.PointAt,m.OutlineTargets,m.ClearGuide]),Br=new Set([m.TypeText,m.EraseText,m.Draw,m.EraseDraw]);function Y(n){return!!n&&Mr.has(n)}function $r(n){return Y(n)&&Dr.has(n)}function vt(n){return Y(n)&&Br.has(n)}function Qe(n){return Y(n)&&Nr.has(n)}const Rr=new Set([m.Form,m.Calendar]);function Ke(n){return Y(n)&&Rr.has(n)}function yt(n,e,t){return t!=null&&t.action_name?String(t.action_name):n===m.Calendar?"calendar_slot_selected":`user_submitted_${e||"collect_user_data"}`}function gt(n){return Y(n)&&!Qe(n)&&!Ke(n)}const Yt=new Set([m.ScreenInk,m.ScreenCursor,m.ScreenClick,m.ClearScreenOverlay,m.PointAt,m.OutlineTargets,m.ClearGuide]),Ur=new Set([...Yt,m.PageScan,m.TabScreenshot]);function Fr(n){return Y(n)&&Yt.has(n)}function Or(n){return Y(n)&&Ur.has(n)}function Gt(n){if(typeof n=="string")try{return JSON.parse(n)}catch{return{}}return n&&typeof n=="object"?n:{}}const bt={type_on_whiteboard:m.TypeText,write_on_whiteboard:m.TypeText,write_on_white_board:m.TypeText,dom_typing_simulation:m.TypeText,erase_text:m.EraseText,dom_erase:m.EraseText,draw_on_board:m.Draw,erase_drawing_board:m.EraseDraw,open_live_camera:m.LiveVision,live_vision:m.LiveVision,close_live_camera:m.CloseLiveCamera,stop_live_camera:m.CloseLiveCamera,open_live_screen:m.LiveScreen,close_live_screen:m.CloseLiveScreen,screen_ink:m.ScreenInk,screen_cursor:m.ScreenCursor,screen_click:m.ScreenClick,clear_screen_overlay:m.ClearScreenOverlay,tab_screenshot:m.TabScreenshot,capture_tab:m.TabScreenshot,capture_tab_screenshot:m.TabScreenshot,screenshot_tab:m.TabScreenshot,page_scan:m.PageScan,scan_page:m.PageScan,point_at:m.PointAt,outline_targets:m.OutlineTargets,outline_elements:m.OutlineTargets,clear_guide:m.ClearGuide};function wt(n,e){const t=n.text_to_type??(e==null?void 0:e.text_to_type)??n.text??(e==null?void 0:e.text)??n.value??(e==null?void 0:e.value);return typeof t=="string"&&t.trim().length>0}function Vr(n,e){const t=n.fields??(e==null?void 0:e.fields);return Array.isArray(t)?t.length>0:typeof t=="string"?t.split(",").map(r=>r.trim()).filter(Boolean).length>0:!1}function zr(n,e){const t=n==null?void 0:n.preset_id;if(typeof t=="string"&&Y(t))return t;const s=Gt(e).preset_id;if(typeof s=="string"&&Y(s))return s}function ct(n,e,t){const r=Gt(e);let s=zr(n,r);if(s===m.Form&&wt(r,n)&&!Vr(r,n))return m.TypeText;if(s)return s;const i=String(t??"").trim().toLowerCase();if(i&&bt[i])return bt[i];if(wt(r,n))return m.TypeText}const Ae="vanira_latest_call_id",Ze="vanira_prospect_id";function Ie(n){return`vanira_latest_call_id_${n}`}function Le(n){return`vanira_prospect_id_${n}`}function Jt(n){return`vanira_call_meta_${n}`}function Q(n,e){if(!n)return null;try{return n.getItem(e)}catch{return null}}function Pe(n){if(typeof window>"u"||!n)return null;const e=[],t=Q(window.localStorage,Jt(n));if(t)try{const a=JSON.parse(t);a!=null&&a.callId&&e.push({callId:a.callId,prospectId:a.prospectId,updatedAt:a.updatedAt||0})}catch{}const r=(a,l,c)=>{a&&e.push({callId:a,prospectId:l||void 0,updatedAt:c})},s=Q(window.localStorage,Le(n)),i=Q(window.sessionStorage,Le(n)),o=Q(window.localStorage,Ze);return r(Q(window.localStorage,Ie(n)),s||o,2),r(Q(window.sessionStorage,Ie(n)),i||o,1),r(Q(window.localStorage,Ae),o,0),r(Q(window.sessionStorage,Ae),o,0),e.length?(e.sort((a,l)=>l.updatedAt-a.updatedAt),e[0]):null}function Qt(n,e,t){var s,i,o,a,l,c,u,d,p;if(typeof window>"u"||!n||!e)return;const r={callId:e,prospectId:t,updatedAt:Date.now()};try{(s=window.localStorage)==null||s.setItem(Jt(n),JSON.stringify(r)),(i=window.localStorage)==null||i.setItem(Ie(n),e),(o=window.sessionStorage)==null||o.setItem(Ie(n),e),t&&((a=window.localStorage)==null||a.setItem(Le(n),t),(l=window.sessionStorage)==null||l.setItem(Le(n),t)),(c=window.localStorage)==null||c.setItem(Ae,e),(u=window.sessionStorage)==null||u.setItem(Ae,e),t&&((d=window.localStorage)==null||d.setItem(Ze,t),(p=window.sessionStorage)==null||p.setItem(Ze,t))}catch{}}function qr(n){var e;return!!((e=Pe(n))!=null&&e.callId)}const Hr=new Set(["client_tool_call","clearAudio","client_tool_cancel"]);function Kt(n){if(!n||typeof n!="object")return!1;const e=n.event;return typeof e=="string"&&Hr.has(e)}const Ve=16*1024,jr=256*1024;function ze(n,e){return(n==null?void 0:n.readyState)==="open"&&(e==null?void 0:e.readyState)==="open"}function Wr(n,e){return{control:(n==null?void 0:n.readyState)??"missing",mediaBytes:(e==null?void 0:e.readyState)??"missing"}}async function Yr(n,e,t=8e3){if(ze(n,e))return!0;const r=Date.now()+t;for(;Date.now()<r;){if(ze(n,e))return!0;await new Promise(s=>setTimeout(s,50))}return ze(n,e)}async function _t(n){for(;n.bufferedAmount>jr;)await new Promise(e=>setTimeout(e,10))}async function Gr(n){const{bytes:e,filename:t,contentType:r,reason:s,message:i,callId:o,mediaBytesChannel:a,sendControlEvent:l,uploadId:c=crypto.randomUUID(),uploadKind:u="media"}=n,d=e.byteLength,p=d===0?0:Math.ceil(d/Ve);l("client_media_upload_start",{data:{upload_id:c,call_id:o,reason:s,message:i,filename:t,content_type:r,size:d,chunk_count:p,upload_kind:u}});const h=new Uint8Array(e);for(let f=0;f<d;f+=Ve){await _t(a);const y=Math.min(f+Ve,d);a.send(h.subarray(f,y))}return await _t(a),l("client_media_upload_complete",{data:{upload_id:c,call_id:o,reason:s,message:i,chunk_count:p,upload_kind:u}}),{media_id:c,url:"",content_type:r}}async function Jr(n){return typeof n.arrayBuffer=="function"?n.arrayBuffer():new Response(n).arrayBuffer()}let ee=null;const Qr=4e3;function dt(n){if(typeof window>"u")return n||"/";const e=(n||"/").trim();if(!e)return"/";try{const t=new URL(e,window.location.origin);return t.origin!==window.location.origin?e:`${t.pathname}${t.search}${t.hash}`||"/"}catch{return e.startsWith("/")?e:`/${e}`}}function Zt(n,e){ee={targetRoute:dt(n),presetId:e==null?void 0:e.presetId,toolName:e==null?void 0:e.toolName,expiresAt:Date.now()+Qr}}function Kr(n){if(!ee)return null;if(Date.now()>ee.expiresAt)return ee=null,null;const e=dt(n),t=ee.targetRoute;if(!(e===t||e.startsWith(t.split("#")[0])||t.startsWith(e.split("#")[0])))return null;const s=ee;return ee=null,s}function he(){return typeof window>"u"?"/":`${window.location.pathname}${window.location.search}${window.location.hash}`||"/"}class Xt{constructor(e){_(this,"active",!1);_(this,"initialSent",!1);_(this,"lastRoute","");_(this,"sendContext");_(this,"isReady");_(this,"cleanupFns",[]);_(this,"initialRetryTimer",null);_(this,"routePollTimer",null);_(this,"originalPushState",null);_(this,"originalReplaceState",null);this.sendContext=e.sendContext,this.isReady=e.isReady??(()=>!0)}start(){typeof window>"u"||this.active||(this.active=!0,this.initialSent=!1,this.lastRoute=he(),this.attachListeners(),this.scheduleInitialContextSend())}stop(){if(!(!this.active&&this.cleanupFns.length===0)){this.active=!1,this.initialSent=!1,this.initialRetryTimer!==null&&(clearTimeout(this.initialRetryTimer),this.initialRetryTimer=null),this.routePollTimer!==null&&(clearInterval(this.routePollTimer),this.routePollTimer=null);for(const e of this.cleanupFns)try{e()}catch{}this.cleanupFns.length=0,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null)}}onChannelReady(){this.scheduleInitialContextSend()}scheduleInitialContextSend(e=0){if(!(!this.active||this.initialSent)){if(this.isReady()){this.sendRouteContext("call_started"),this.initialSent=!0;return}e>=30||(this.initialRetryTimer=window.setTimeout(()=>this.scheduleInitialContextSend(e+1),100))}}attachListeners(){const e=(i,o=0)=>{const a=()=>{const l=he();l!==this.lastRoute&&this.handleRouteChange(l,i)};o>0?window.setTimeout(a,o):queueMicrotask(a)},t=()=>e("popstate"),r=()=>e("hashchange"),s=i=>{const o=i.detail;if((o==null?void 0:o.initiated_by)==="agent"){e("vanira_navigate_agent",120);return}e("vanira_navigate",120)};window.addEventListener("popstate",t),window.addEventListener("hashchange",r),window.addEventListener("vanira:navigate",s),this.cleanupFns.push(()=>window.removeEventListener("popstate",t),()=>window.removeEventListener("hashchange",r),()=>window.removeEventListener("vanira:navigate",s)),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history),history.pushState=(...i)=>{this.originalPushState(...i),e("pushState")},history.replaceState=(...i)=>{this.originalReplaceState(...i),e("replaceState")},this.routePollTimer=window.setInterval(()=>{if(!this.active)return;const i=he();i!==this.lastRoute&&this.handleRouteChange(i,"location_poll")},1e3)}handleRouteChange(e,t){if(!this.active)return;const r=this.lastRoute;if(r===e)return;if(this.lastRoute=e,!this.initialSent){this.scheduleInitialContextSend();return}!this.isReady()||Kr(e)||this.sendRouteContext("route_changed",r,t,"user")}sendRouteContext(e,t,r,s="user"){const i=he();this.lastRoute=i;const o={ui_state:"page_navigation",navigation_led_by:s,current_route:i,current_page:i,user_action:e==="call_started"?"call_started_on_page":"user_navigated"};e==="call_started"?o.message=`User started the call while viewing ${i}.`:(o.previous_route=t??"",o.message=`User navigated from ${t||"(unknown)"} to ${i}.`,r&&(o.navigation_source=r));try{this.sendContext(o)}catch{}}}const G=class G{constructor(e){_(this,"serverUrl");_(this,"agentId");_(this,"callId");_(this,"prospectId");_(this,"apiKey");_(this,"backendUrl");_(this,"token");_(this,"onConnected");_(this,"onDisconnected");_(this,"onError");_(this,"onTranscription");_(this,"onLocalStream");_(this,"onRemoteTrack");_(this,"onClientToolCall");_(this,"onSessionStarted");_(this,"sessionStartedEmitted",!1);_(this,"pc",null);_(this,"dataChannel",null);_(this,"mediaBytesChannel",null);_(this,"audioElement",null);_(this,"localStream",null);_(this,"micMuted",!1);_(this,"connected",!1);_(this,"icePollInterval",null);_(this,"appliedRemoteCandidates",new Set);_(this,"iceServers");_(this,"callSessionLoaded",!1);_(this,"connectGeneration",0);_(this,"runtime");_(this,"sessionBehavior");_(this,"routeTracker",null);_(this,"_status","idle");_(this,"listeners",new Map);_(this,"liveVision");_(this,"liveVisionAutoStarted",!1);if(!e.agentId)throw new Error("agentId is required");const t=!!(e.apiKey||e.token),r=!!(e.serverUrl&&e.callId),s=G.normalizeIceServers(e.iceServers);if(!t&&!r)throw new Error("apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create");this.agentId=e.agentId,this.sessionBehavior=e.sessionBehavior,this.serverUrl=(e.serverUrl||"").replace(/\/$/,""),this.apiKey=e.apiKey,this.token=e.token,this.backendUrl=(e.backendUrl||Lr).replace(/\/$/,""),s.length&&(this.iceServers=s),r&&(this.callSessionLoaded=!0);const i=typeof window<"u";this.prospectId=e.prospectId;const o=e.sessionBehavior==="continue";if(o&&i&&!e.callId){const l=Pe(this.agentId);l&&(e.callId||(this.callId=l.callId),!this.prospectId&&l.prospectId&&(this.prospectId=l.prospectId))}if(!this.prospectId&&i)try{const l=Pe(this.agentId);this.prospectId=(l==null?void 0:l.prospectId)||window.sessionStorage&&window.sessionStorage.getItem("vanira_prospect_id")||window.localStorage&&window.localStorage.getItem("vanira_prospect_id")||void 0}catch{}e.callId?this.callId=e.callId:o||(this.callId=void 0);const a=e.onSessionStarted;this.onSessionStarted=l=>{a==null||a(l),this.emit("session_started",l)},this.liveVision=e.liveVision,this.onConnected=()=>{var l;this._status="connected",(l=e.onConnected)==null||l.call(e),this.emit("connected"),this.maybeAutoStartLiveCamera()},this.onDisconnected=()=>{var l;this._status="disconnected",(l=e.onDisconnected)==null||l.call(e),this.emit("disconnected")},this.onError=l=>{var u;this._status="error";const c=typeof l=="string"?l:(l==null?void 0:l.message)||"Connection error";(u=e.onError)==null||u.call(e,l),this.emit("error",c)},this.onTranscription=(l,c)=>{var u;(u=e.onTranscription)==null||u.call(e,l,c),this.emit("transcription",{text:l,isFinal:c})},this.onLocalStream=e.onLocalStream||(()=>{}),this.onRemoteTrack=(l,c)=>{var u;(u=e.onRemoteTrack)==null||u.call(e,l,c),this.emit("track",{track:l,stream:c})},this.onClientToolCall=l=>{var d;(d=e.onClientToolCall)==null||d.call(e,l);const c=(l==null?void 0:l.data)||l,u={name:String(c.name||c.tool_name||""),arguments:c.arguments||c.args||{},tool_call_id:String(c.tool_call_id||c.call_id||""),execution_mode:c.execution_mode==="blocking"?"blocking":"fire_and_forget",client_fields:c.client_fields||{}};u.name&&u.tool_call_id&&this.emit("tool_call",u)},this.runtime=e.runtime,typeof window<"u"&&e.trackRouteContext!==!1&&(this.routeTracker=new Xt({sendContext:l=>this.sendContextUpdate(l),isReady:()=>{var l;return((l=this.dataChannel)==null?void 0:l.readyState)==="open"}}))}async createCall(){return this.connect()}async connect(){var t;this._status="connecting";const e=++this.connectGeneration;if(await this.loadCallSession(),!this.isConnectCancelled(e)){if(!this.serverUrl)throw new Error("[VaniraClient] worker_url missing from /calls/create");if(!this.callId)throw new Error("[VaniraClient] call_id missing — must come from POST /calls/create");if(this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}try{this.appliedRemoteCandidates.clear(),this.stopRemoteIcePolling();const r=this.getIceServers();this.pc=new RTCPeerConnection({iceServers:r,iceTransportPolicy:"all"});let s;try{s=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:1}})}catch(d){if(d.name==="NotAllowedError"||d.name==="PermissionDeniedError"||(t=d.message)!=null&&t.includes("Permission denied")){const p=navigator.userAgent,h=/iPad|iPhone|iPod/.test(p)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;let f="Microphone access denied. Please allow microphone access in your browser settings.";h&&(p.includes("CriOS")?f="Microphone access blocked. Please enable it in iOS Settings > Chrome > Microphone, then reload the page.":p.includes("FxiOS")?f="Microphone access blocked. Please enable it in iOS Settings > Firefox > Microphone, then reload the page.":f="Microphone access blocked. Please enable it in iOS Settings > Safari > Microphone (or tap 'aA' > Website Settings > Allow Microphone).");const y=new Error(f);throw y.name=d.name,y}throw d}if(this.isConnectCancelled(e)){s.getTracks().forEach(d=>d.stop());return}if(this.localStream=s,!this.pc||this.isConnectCancelled(e)){s.getTracks().forEach(d=>d.stop());return}if(this.onLocalStream(s),s.getTracks().forEach(d=>{var p;(p=this.pc)==null||p.addTrack(d,s)}),!this.pc)throw new Error("RTCPeerConnection was closed unexpectedly");this.dataChannel=this.pc.createDataChannel("control"),this.dataChannel.onopen=()=>{var d;(d=this.routeTracker)==null||d.onChannelReady()},this.dataChannel.onmessage=d=>{if(typeof d.data=="string")try{this.handleControlEvent(JSON.parse(d.data))}catch{}else if(d.data instanceof ArrayBuffer)try{const p=new TextDecoder().decode(d.data);try{const h=JSON.parse(p);Kt(h)&&this.handleControlEvent(h)}catch{}}catch{}else d.data instanceof Blob&&d.data.text().then(p=>{try{this.handleControlEvent(JSON.parse(p))}catch{}})},this.dataChannel.onerror=d=>{},this.mediaBytesChannel=this.pc.createDataChannel("media-bytes",{ordered:!0}),this.mediaBytesChannel.binaryType="arraybuffer",this.mediaBytesChannel.onopen=()=>{},this.mediaBytesChannel.onerror=d=>{},this.pc.ontrack=d=>{const p=d.track,h=d.streams[0];p.kind==="audio"?(this.audioElement=new Audio,this.audioElement.srcObject=h,this.audioElement.play().catch(f=>{}),this.audioElement.onended=()=>{this.sendEvent("playedStream"),typeof window<"u"&&window.dispatchEvent(new CustomEvent("vanira:agent-playback-ended"))},this.onRemoteTrack(p,h)):p.kind==="video"&&this.onRemoteTrack(p,h)};const i=()=>{var h,f,y,v,g,b,S,w,x,C,k;const d=((h=this.pc)==null?void 0:h.connectionState)==="connected"||((f=this.pc)==null?void 0:f.iceConnectionState)==="connected"||((y=this.pc)==null?void 0:y.iceConnectionState)==="completed",p=((v=this.pc)==null?void 0:v.connectionState)==="failed"||((g=this.pc)==null?void 0:g.iceConnectionState)==="failed"||((b=this.pc)==null?void 0:b.connectionState)==="closed"||((S=this.pc)==null?void 0:S.iceConnectionState)==="closed"||((w=this.pc)==null?void 0:w.connectionState)==="disconnected"||((x=this.pc)==null?void 0:x.iceConnectionState)==="disconnected";((C=this.pc)==null?void 0:C.connectionState)==="connected"&&this.stopRemoteIcePolling(),d&&!this.connected?(this.connected=!0,(k=this.routeTracker)==null||k.start(),this.onConnected()):p&&this.connected&&(this.connected=!1,this.liveVisionAutoStarted=!1,this.onDisconnected())};this.pc.onconnectionstatechange=i,this.pc.oniceconnectionstatechange=i;const o=this.getIceTrickleUrl();this.pc.onicecandidate=d=>{d.candidate&&fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidate:d.candidate.toJSON()})}).catch(p=>{})};const a=await this.pc.createOffer();if(this.isConnectCancelled(e)||(await this.pc.setLocalDescription(a),this.isConnectCancelled(e)))return;const l=this.serverUrl.includes("?")?this.serverUrl:`${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`,c=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offer:this.pc.localDescription,agentId:this.agentId,callId:this.callId})});if(this.isConnectCancelled(e))return;if(!c.ok){const d=await c.json();throw new Error(d.error||`HTTP ${c.status}`)}const{answer:u}=await c.json();if(this.isConnectCancelled(e)||!this.pc||(await this.pc.setRemoteDescription(u),this.isConnectCancelled(e)))return;this.startRemoteIcePolling(o)}catch(r){if(this.isConnectCancelled(e))return;throw this.disconnect(),this.onError(r.message||r),r}}}createCallCacheKey(e,t){const r=this.apiKey?`key:${this.apiKey.slice(0,16)}`:`token:${(this.token||"").slice(-16)}`;return[this.backendUrl,this.agentId,e,t||"",this.prospectId||"",r].join("|")}async postCreateCall(e,t,r){var a,l,c;const s=await fetch(`${this.backendUrl}/calls/create`,{method:"POST",headers:e,body:JSON.stringify({agent_id:this.agentId,type:((a=this.runtime)==null?void 0:a.callType)||"web",mode:t,...(l=this.runtime)!=null&&l.runtimeName?{runtime:this.runtime.runtimeName}:{},prospect_id:this.prospectId,...r?{call_id:r}:{}})});if(!s.ok){const u=await s.json().catch(()=>({}));throw new Error(`[VaniraClient] createCall failed (${s.status}): ${((c=u==null?void 0:u.detail)==null?void 0:c.message)||(u==null?void 0:u.message)||s.statusText}`)}const i=await s.json();if(!i.call_id||!i.worker_url)throw new Error("[VaniraClient] /calls/create response missing call_id or worker_url");const o=G.normalizeIceServers(i.ice_servers);if(!o.length)throw new Error("[VaniraClient] /calls/create response missing ice_servers");return{callId:i.call_id,prospectId:i.prospect_id||this.prospectId,serverUrl:i.worker_url.replace(/\/$/,""),iceServers:o}}applyCreateCallSession(e){if(this.callId=e.callId,this.prospectId=e.prospectId||this.prospectId,this.serverUrl=e.serverUrl,this.iceServers=e.iceServers,this.callSessionLoaded=!0,Qt(this.agentId,this.callId||"",this.prospectId),this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}}async loadCallSession(){if(this.callSessionLoaded)return;if(this.serverUrl&&this.callId){this.callSessionLoaded=!0;return}if(!this.apiKey&&!this.token)throw new Error("[VaniraClient] apiKey or token is required to create a call session");const e={"Content-Type":"application/json"};this.apiKey?e["X-API-Key"]=this.apiKey:this.token&&(e.Authorization=this.token.startsWith("Bearer ")?this.token:`Bearer ${this.token}`);const t=this.sessionBehavior==="continue"?this.callId:void 0,r=this.sessionBehavior==="continue"?"continue":"new",s=this.createCallCacheKey(r,t);let i=G.inflightCreates.get(s);i||(i=this.postCreateCall(e,r,t),G.inflightCreates.set(s,i),i.finally(()=>{G.inflightCreates.get(s)===i&&G.inflightCreates.delete(s)}));const o=await i;this.applyCreateCallSession(o)}getIceServers(){var e;if((e=this.iceServers)!=null&&e.length)return this.iceServers;throw new Error("[VaniraClient] ice_servers missing — pass iceServers from POST /calls/create")}static normalizeIceServers(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const s=r==null?void 0:r.urls,i=Array.isArray(s)?s.filter(Boolean):typeof s=="string"&&s.trim()?[s.trim()]:[];if(!i.length)continue;const o={urls:i.length===1?i[0]:i},a=r.username,l=r.credential;a&&(o.username=a),l&&(o.credential=l),t.push(o)}return t}getWorkerOrigin(){var e;if(!((e=this.serverUrl)!=null&&e.trim()))return"";try{return new URL(this.serverUrl).origin}catch{return this.serverUrl.replace(/\/webrtc.*$/,"").replace(/\/$/,"")}}getIceTrickleUrl(){try{const e=new URL(this.serverUrl);return e.pathname.endsWith("/webrtc")?e.pathname=`${e.pathname}/ice`:e.pathname="/webrtc/ice",e.toString()}catch{return`${this.getWorkerOrigin()}/webrtc/ice?agent_id=${this.agentId}&call_id=${this.callId}`}}startRemoteIcePolling(e){this.stopRemoteIcePolling(),this.icePollInterval=setInterval(async()=>{if(!this.pc){this.stopRemoteIcePolling();return}if(this.pc.connectionState==="connected"){this.stopRemoteIcePolling();return}try{const t=await fetch(e);if(!t.ok)return;const{candidates:r}=await t.json();for(const s of r||[]){const i=JSON.stringify(s);if(!this.appliedRemoteCandidates.has(i)){this.appliedRemoteCandidates.add(i);try{await this.pc.addIceCandidate(s)}catch{}}}}catch{}},150)}stopRemoteIcePolling(){this.icePollInterval!==null&&(clearInterval(this.icePollInterval),this.icePollInterval=null)}sendEvent(e,t={}){var r;if(((r=this.dataChannel)==null?void 0:r.readyState)==="open"){const s={event:e,...t};this.dataChannel.send(JSON.stringify(s))}}async sendEventWhenReady(e,t={},r=1e4){var i;const s=Date.now()+r;for(;Date.now()<s;){if(((i=this.dataChannel)==null?void 0:i.readyState)==="open")return this.sendEvent(e,t),!0;await new Promise(o=>setTimeout(o,50))}return!1}startLiveCamera(e={}){const t={...this.liveVision,...e};this.emit("tool_call",this.buildOpenLiveCameraToolCall(t))}buildOpenLiveCameraToolCall(e={}){const t=e.scope??"until_call_end";return{name:"open_live_camera",tool_call_id:`lv_${crypto.randomUUID()}`,execution_mode:"fire_and_forget",client_fields:{preset_id:m.LiveVision},arguments:{mode:"live",scope:t,target_fps:e.target_fps??1,max_fps:e.max_fps??3,max_width:e.max_width??640,reason:e.reason??"camera_capture",facing_mode:e.facing_mode??"environment",show_preview:e.show_preview??!0,...t==="timed"&&e.duration_sec?{duration_sec:e.duration_sec}:{}}}}maybeAutoStartLiveCamera(){const e=this.liveVision;!(e!=null&&e.enabled)||e.scope!=="full_call"||this.liveVisionAutoStarted||(this.liveVisionAutoStarted=!0,this.emit("tool_call",this.buildOpenLiveCameraToolCall(e)))}handleControlEvent(e){var t;switch(e.event){case"clearAudio":break;case"transcription":this.onTranscription(e.text,e.isFinal);break;case"mark":break;case"client_tool_cancel":{const s=(e.data||e).tool_call_id||e.tool_call_id;this.dispatchBoardAbort("Tool cancelled by server",s);break}case"client_tool_call":{const r=e.tool_call||e.data||e,s=(r==null?void 0:r.tool_call_id)||(r==null?void 0:r.call_id)||e.tool_call_id||"";s&&((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:s}}));const i=(r==null?void 0:r.arguments)||(r==null?void 0:r.args)||{},o=(r==null?void 0:r.client_fields)||{},a=(r==null?void 0:r.name)||(r==null?void 0:r.tool_name)||"",l=ct(o,i,a);if(a==="end_call"){s&&this.sendToolResult(s,{status:"client_ack_end_call",message:"Ending call."}),window.setTimeout(()=>this.disconnect(),120);break}if(l){window.dispatchEvent(new CustomEvent("vanira:preset",{detail:{toolCall:r,client:this}})),this.onClientToolCall(r);break}this.onClientToolCall(r);break}}}disconnect(){var e;this.connectGeneration++,this.stopRemoteIcePolling(),this.appliedRemoteCandidates.clear(),this.audioElement&&(this.audioElement.pause(),this.audioElement.srcObject=null),this.dataChannel&&(this.dataChannel.close(),this.dataChannel=null),this.mediaBytesChannel&&(this.mediaBytesChannel.close(),this.mediaBytesChannel=null),this.pc&&(this.pc.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc.close(),this.pc=null),this.localStream&&(this.localStream.getTracks().forEach(t=>{try{t.stop()}catch{}}),this.localStream=null),this.connected=!1,(e=this.routeTracker)==null||e.stop(),this.callSessionLoaded=!1,this.sessionStartedEmitted=!1,this.serverUrl="",this.callId=void 0,this.micMuted=!1,this.iceServers=void 0,this.onDisconnected()}setMicrophoneMuted(e){var t,r;this.micMuted=e,(t=this.localStream)==null||t.getAudioTracks().forEach(s=>{s.enabled=!e}),(r=this.pc)==null||r.getSenders().forEach(s=>{var i;((i=s.track)==null?void 0:i.kind)==="audio"&&(s.track.enabled=!e)})}isMicrophoneMuted(){return this.micMuted}toggleMicrophoneMuted(){return this.setMicrophoneMuted(!this.micMuted),this.micMuted}isConnectCancelled(e){return e!==this.connectGeneration}dispatchBoardAbort(e,t){typeof window>"u"||window.dispatchEvent(new CustomEvent("vanira:board_abort",{detail:{reason:e,toolCallId:t}}))}sendToolResult(e,t){this.callId,this.sendEvent("client_tool_result",{call_id:this.callId,data:{tool_call_id:e,result:t},result:t})}sendToolAck(e){var t;((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:e}}))}sendContextUpdate(e){this.sendEvent("client_context_update",{data:{context:e}})}sendActionTrigger(e,t={}){this.sendEvent("client_action_trigger",{data:{action_name:e,data:t}})}triggerActionInterrupt(){this.sendEvent("action_interrupt")}async uploadMediaForToolResult(e,t="general"){return this._postMediaUpload(e,t)}async uploadMedia(e,t="general",r=""){return await Yr(this.dataChannel,this.mediaBytesChannel)?this._uploadMediaViaDataChannel(e,t,r):(Wr(this.dataChannel,this.mediaBytesChannel),this._uploadMediaViaHTTP(e,t,r))}async uploadMediaFrame(e,t="camera_capture",r){const s=r&&!(e instanceof File)?new File([e],r,{type:e.type||"image/jpeg"}):e,{media_id:i,url:o,contentType:a}=await this._postMediaUpload(s,t,!0);if(!i||!o)throw new Error("Frame upload failed: server response missing media_id or url");return{media_id:i,url:o,content_type:a}}async _uploadBytesViaDataChannel(e,t,r,s,i){if(!this.callId||!this.mediaBytesChannel)throw new Error("Upload failed: call not ready for WebRTC media upload.");const o=i||(e instanceof File?e.name:s==="frame"?"frame.jpg":"upload.bin"),a=e.type||(s==="frame"?"image/jpeg":"application/octet-stream"),l=await Jr(e);return Gr({bytes:l,filename:o,contentType:a,reason:t,message:r,callId:this.callId,mediaBytesChannel:this.mediaBytesChannel,sendControlEvent:(c,u)=>this.sendEvent(c,u),uploadKind:s})}async _uploadMediaViaDataChannel(e,t,r){const s=await this._uploadBytesViaDataChannel(e,t,r,"media");return{media_id:s.media_id,url:s.url}}async _uploadMediaViaHTTP(e,t="general",r=""){const{media_id:s,url:i,contentType:o}=await this._postMediaUpload(e,t,!0);if(this.dataChannel&&this.dataChannel.readyState==="open"){const a={event:"client_media_update",data:{media_id:s,media_url:i,content_type:o,reason:t,message:r}};this.dataChannel.send(JSON.stringify(a))}return{media_id:s,url:i}}async _postMediaUpload(e,t,r=!1){if(!this.serverUrl)throw new Error("Upload failed: serverUrl is not set. Connect the VaniraClient first.");if(!this.callId)throw new Error("Upload failed: callId is missing.");const s=this.getWorkerOrigin();if(!s)throw new Error("Upload failed: worker_url is not set. Connect the call before uploading media.");const i=`${s}/media/upload`,o=new FormData;o.append("file",e),o.append("call_id",this.callId),o.append("reason",t);const a=await fetch(i,{method:"POST",body:o});if(!a.ok){let p=`HTTP ${a.status}`;try{p=(await a.json()).error||p}catch{}throw new Error(`Upload failed: ${p}`)}const l=await a.json(),c=l.media_id,u=l.url,d=l.content_type||e.type;if(!c||!u)throw new Error("Upload failed: server response missing media_id or url");return r?{media_id:c,url:u,contentType:d}:{media_id:c,url:u,contentType:d}}get status(){return this._status}get isConnected(){return this._status==="connected"}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this}off(e,t){var r;return(r=this.listeners.get(e))==null||r.delete(t),this}emit(e,t){var r;(r=this.listeners.get(e))==null||r.forEach(s=>s(t))}async start(){return await this.connect(),{callId:this.callId||"",prospectId:this.prospectId||"",serverUrl:this.serverUrl||""}}stop(){this.disconnect(),this._status="disconnected"}sendToolError(e,t){this.sendToolResult(e,{status:"error",error:t})}updateContext(e){this.sendContextUpdate(e)}triggerInterrupt(e,t={}){this.triggerActionInterrupt(),this.sendActionTrigger(e,t)}interruptAudioOnly(){this.triggerActionInterrupt()}};_(G,"inflightCreates",new Map);let Me=G;const Zr="vnr-clip-overlay";function Xr(n){var e;return((e=n.classList)==null?void 0:e.contains(Zr))??!1}function en(n){var t;return((t=n.tagName)==null?void 0:t.toLowerCase())==="vanira-convai"?!0:typeof n.closest=="function"&&!!n.closest("vanira-convai")}function er(n){var e;return Xr(n)||en(n)||(e=n.classList)!=null&&e.contains("vnr-screen-overlay-root")?!0:typeof n.closest=="function"&&!!n.closest(".vnr-screen-overlay-root")}async function tr(){const n=document.documentElement.clientWidth,e=document.documentElement.clientHeight;return nr({left:0,top:0,width:n,height:e})}function rr(n,e){if(n.width<=e)return n;const t=e/n.width,r=document.createElement("canvas");r.width=e,r.height=Math.round(n.height*t);const s=r.getContext("2d");return s?(s.drawImage(n,0,0,r.width,r.height),r):n}async function nr(n){const{default:e}=await Promise.resolve().then(()=>require("../chunks/html2canvas.js")),t=window.devicePixelRatio||1,r=window.scrollX+n.left,s=window.scrollY+n.top;return e(document.body,{x:r,y:s,width:n.width,height:n.height,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,scrollX:-window.scrollX,scrollY:-window.scrollY,useCORS:!0,allowTaint:!1,scale:t,ignoreElements:i=>er(i),logging:!1})}async function ut(n,e=.88){try{const t=await new Promise(r=>n.toBlob(s=>r(s),"image/jpeg",e));if(!t)throw new Error("Failed to encode clip as JPEG");return t}catch(t){const r=t instanceof Error?t.message:String(t);throw/tainted|security|cross-origin/i.test(r)?new Error("Could not export this page region (cross-origin content). Try selecting a simpler area."):t}}const tn="vanira:clip-region-active";function Xe(n){typeof window>"u"||window.dispatchEvent(new CustomEvent(tn,{detail:{active:n}}))}const Se="vnr-clip-overlay",xt="2147483647",rn="rgba(0, 0, 0, 0.28)";function nn(n={}){const e=n.minSizePx??24,t=n.hint??"Drag to select an area — release to clip.";return new Promise(r=>{let s=!1,i=!1,o=0,a=0,l=!1,c={left:0,top:0,width:0,height:0},u=!1,d=null;const p=A=>{s||(s=!0,F(),r(A))},h=document.createElement("div");h.className=Se,h.style.cssText=["position:fixed","inset:0",`z-index:${xt}`,"cursor:crosshair","user-select:none","touch-action:none","background:transparent","font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"].join(";");const f=document.createElement("div");f.style.cssText=["position:absolute","display:none","pointer-events:none","border:2px solid #6366f1","border-radius:2px","background:transparent","box-shadow:none"].join(";");const y=document.createElement("div");y.style.cssText=["position:absolute","display:none","pointer-events:none","padding:2px 6px","border-radius:4px","font-size:11px","font-weight:600","color:#fff","background:rgba(15,23,42,0.82)","white-space:nowrap"].join(";");const v=document.createElement("div");v.className=Se,v.style.cssText=["position:fixed","top:16px","left:50%","transform:translateX(-50%)",`z-index:${xt}`,"display:flex","align-items:center","gap:10px","padding:10px 14px","border-radius:14px","background:#0f172a","border:1px solid rgba(255,255,255,0.12)","box-shadow:0 8px 24px rgba(0,0,0,0.25)","max-width:min(520px,calc(100vw - 32px))"].join(";");const g=document.createElement("span");g.style.cssText="flex:1;font-size:13px;color:#e2e8f0;line-height:1.4",g.textContent=t;const b=document.createElement("button");b.type="button",b.textContent="Cancel",b.style.cssText=["padding:8px 12px","border:1px solid rgba(255,255,255,0.15)","border-radius:10px","background:transparent","color:#e2e8f0","font-size:13px","font-weight:600","cursor:pointer"].join(";"),v.appendChild(g),v.appendChild(b);const S=A=>{A.key==="Escape"&&!i&&p(null)},w=()=>u&&c.width>=e&&c.height>=e,x=()=>{u=!1,c={left:0,top:0,width:0,height:0},C()},C=()=>{if(!u||c.width<1||c.height<1){f.style.display="none",y.style.display="none";return}f.style.display="block",f.style.left=`${c.left}px`,f.style.top=`${c.top}px`,f.style.width=`${c.width}px`,f.style.height=`${c.height}px`,f.style.boxShadow=`0 0 0 9999px ${rn}`,y.style.display="block",y.textContent=`${Math.round(c.width)} × ${Math.round(c.height)}`,y.style.left=`${c.left}px`,y.style.top=`${Math.max(8,c.top-26)}px`},k=A=>{const T=A instanceof Error?A.message:"Capture failed";g.textContent=T.length>120?`${T.slice(0,117)}…`:T,g.style.color="#fca5a5",window.setTimeout(()=>{g.textContent=t,g.style.color="#e2e8f0"},4500)},E=async A=>{if(!(i||s)){i=!0,b.disabled=!0,g.textContent="Clipping…",g.style.color="#e2e8f0",h.style.visibility="hidden",v.style.visibility="hidden";try{const T=await nr(A),M=await ut(T),R=document.documentElement.clientWidth,U=document.documentElement.clientHeight;p({blob:M,region:{x:A.left/R,y:A.top/U,w:A.width/R,h:A.height/U},viewport:{width:R,height:U},pixelSize:{width:T.width,height:T.height}})}catch(T){i=!1,b.disabled=!1,h.style.visibility="visible",v.style.visibility="visible",k(T),x()}}},I=A=>{const T=A??d;if(T!==null)try{h.releasePointerCapture(T)}catch{}d=null},L=A=>{if(!(!l||i)){if(l=!1,I(A==null?void 0:A.pointerId),w()){E({...c});return}x()}},$=A=>{i||A.target.closest(`.${Se}`)!==v&&(l=!0,u=!0,o=A.clientX,a=A.clientY,c={left:o,top:a,width:0,height:0},d=A.pointerId,h.setPointerCapture(A.pointerId),C())},D=A=>{if(!l||i)return;const T=Math.min(o,A.clientX),M=Math.min(a,A.clientY),R=Math.max(o,A.clientX),U=Math.max(a,A.clientY);c={left:T,top:M,width:R-T,height:U-M},C()},F=()=>{Xe(!1),document.removeEventListener("keydown",S),window.removeEventListener("pointerup",O,!0),window.removeEventListener("pointercancel",O,!0),h.removeEventListener("pointerdown",$),h.removeEventListener("pointermove",D),h.removeEventListener("pointerup",L),h.removeEventListener("pointercancel",L),I(),h.remove(),v.remove()},O=A=>L(A);b.addEventListener("click",()=>p(null)),Xe(!0),h.appendChild(f),h.appendChild(y),document.body.appendChild(h),document.body.appendChild(v),document.addEventListener("keydown",S),window.addEventListener("pointerup",O,!0),window.addEventListener("pointercancel",O,!0),h.addEventListener("pointerdown",$),h.addEventListener("pointermove",D),h.addEventListener("pointerup",L),h.addEventListener("pointercancel",L)})}function qe(){document.querySelectorAll(`.${Se}`).forEach(n=>n.remove()),Xe(!1)}const sn=["a[href]","button:not([disabled])",'input:not([type="hidden"]):not([disabled])',"select:not([disabled])","textarea:not([disabled])",'[role="button"]','[role="link"]','[role="tab"]','[role="menuitem"]','[role="checkbox"]','[role="radio"]',"label","h1","h2","h3","h4","h5","h6","img[alt]","[data-testid]","[aria-label]","[onclick]"].join(", "),on='[id]:not([id=""]), svg[id], polygon[id]',an="svg[id], polygon[id], svg[data-vanira-static-diagram], svg[data-vanira-static-diagram] polygon",sr=new Set(["root","app","__next"]);function St(n,e,t){const r=n.getScreenCTM(),s=n.ownerSVGElement;if(!r||!s)return[];const i=[];for(let o=0;o<n.points.length;o++){const a=n.points.getItem(o),l=s.createSVGPoint();l.x=a.x,l.y=a.y;const c=l.matrixTransform(r);i.push({x:c.x/e,y:c.y/t})}return i}function ir(n,e,t){if(n instanceof SVGPolygonElement){const r=St(n,e,t);return r.length>=2?r:void 0}if(n instanceof SVGSVGElement){const r=n.querySelector("polygon");if(!r)return;const s=St(r,e,t);return s.length>=2?s:void 0}}function ln(n,e=40){return n.elements.slice(0,e).map(t=>{var s;let r=`${t.css_selector} (${t.tag}) "${t.label.slice(0,48)}" center=(${t.center_x.toFixed(3)},${t.center_y.toFixed(3)}) bbox=(${t.x.toFixed(3)},${t.y.toFixed(3)},${t.width.toFixed(3)},${t.height.toFixed(3)})`;if((s=t.stroke_points)!=null&&s.length){const i=t.stroke_points.map(o=>[Number(o.x.toFixed(3)),Number(o.y.toFixed(3))]);r+=` stroke_points=${JSON.stringify(i)} close=true`}return r}).join(`
|
|
2
|
-
|
|
3
|
-
@keyframes vnr-screen-ripple {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
width: 28px;
|
|
38
|
-
|
|
39
|
-
margin-left: -2px;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
.vnr-screen-cursor.vnr-screen-cursor-flying {
|
|
45
|
-
animation: none;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
transform: translate(-50%, -50%);
|
|
75
|
-
font-family: Georgia, "Times New Roman", serif;
|
|
76
|
-
font-weight: 600;
|
|
77
|
-
line-height: 1;
|
|
78
|
-
text-shadow: 1px 1px 0 rgba(0,0,0,0.35);
|
|
79
|
-
white-space: nowrap;
|
|
80
|
-
pointer-events: none;
|
|
81
|
-
}
|
|
82
|
-
`,document.head.appendChild(n)}function N(n,e){const t=Number(n);return Number.isFinite(t)?t:e}function P(n,e=""){return typeof n=="string"?n:e}function q(n){if(n===!0||n===1)return!0;if(typeof n=="string"){const e=n.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"}return!1}function Lt(n){if(n===!1||n===0)return!0;if(typeof n=="string"){const e=n.trim().toLowerCase();return e==="false"||e==="0"||e==="no"}return!1}function W(n,e){return n>=0&&n<=1?n*e:n}function re(n,e){const t=window.innerWidth,r=window.innerHeight;return{px:W(n,t),py:W(e,r)}}function tt(n){const e=document.querySelector(n);if(!e)return null;const t=e.getBoundingClientRect();return{px:t.left+t.width/2,py:t.top+t.height/2}}function bn(n){const e=P(n.css_selector||n.selector);if(e){const s=tt(e);if(s)return s}const t=n.x??n.client_x,r=n.y??n.client_y;return t==null||r==null?null:re(N(t,NaN),N(r,NaN))}function Pt(n){if(Array.isArray(n))return n;if(typeof n=="string"){const e=n.trim();if(!e)return[];try{const r=JSON.parse(e);if(Array.isArray(r))return r.length>0&&Array.isArray(r[0])?[{points:r,close:!0}]:r}catch{}const t=e.split(/\s+/).map(r=>{const[s,i]=r.split(","),o=Number(s),a=Number(i);return Number.isFinite(o)&&Number.isFinite(a)?[o,a]:null}).filter(r=>r!=null);if(t.length>=2)return[{points:t,close:!0}]}return[]}function wn(n){if(Array.isArray(n))return n;if(typeof n=="string"){const e=n.trim();if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}return[]}function rt(n,e){const t=P(n,e).trim().toLowerCase();return!t||t==="#000"||t==="#000000"||t==="black"?"#ece6d9":P(n,e)}function cr(n,e){if(!n||typeof n!="object")return null;const t=n,r=P(t.text??t.label??t.annotation??(typeof t.annotations=="string"?t.annotations:"")).trim();if(!r)return null;let s=t.x??t.client_x,i=t.y??t.client_y;if((s==null||i==null)&&Array.isArray(t.points)&&t.points.length>0){const l=pt(t.points[0]);if(l){const c=window.innerWidth,u=window.innerHeight;s=l.px/c,i=l.py/u}}if(s==null||i==null)return null;const o=Number(s),a=Number(i);return!Number.isFinite(o)||!Number.isFinite(a)?null:{x:o,y:a,text:r,color:rt(t.color,e),font_size:t.font_size!=null?N(t.font_size,18):void 0}}function _n(n,e){if(!n||typeof n!="object")return null;const t=n;return t.text!=null||t.label!=null||t.annotation!=null||typeof t.annotations=="string"?cr(n,e):null}function xn(n){return Array.isArray(n)&&n.length>0&&Array.isArray(n[0])?{points:n,close:!0}:n}function Sn(n){return W(n,Math.min(window.innerWidth,window.innerHeight))}function Cn(n){if(n.length<2)return null;const e=window.innerWidth,t=window.innerHeight,r=n.map(c=>c.px),s=n.map(c=>c.py),i=(Math.min(...r)+Math.max(...r))/2,o=(Math.min(...s)+Math.max(...s))/2,a=Math.max(...n.map(c=>Math.hypot(c.px-i,c.py-o))),l=Math.min(e,t);return{cx:i/e,cy:o/t,r:a/l}}function kn(n,e,t,r){const s=P(n.kind||n.shape).toLowerCase(),i=s==="circle"||s==="ellipse"||n.r!=null||n.radius!=null||n.rx!=null||n.ry!=null;let o=n.cx??n.center_x??n.x,a=n.cy??n.center_y??n.y,l=n.r??n.radius;const c=n.rx,u=n.ry;if(Array.isArray(r)&&r.length>=3){const f=[];for(const v of r){const g=pt(v);g&&f.push(g)}const y=Cn(f);y&&(i||q(n.close)&&f.length>=8)&&(o=o??y.cx,a=a??y.cy,l=l??y.r)}if(o==null||a==null)return null;const d=Number(o),p=Number(a);if(!Number.isFinite(d)||!Number.isFinite(p))return null;const h={kind:s==="ellipse"||c!=null||u!=null?"ellipse":"circle",cx:d,cy:p,color:P(n.color,e),stroke_width:n.stroke_width!=null?N(n.stroke_width,t):t};return c!=null||u!=null?(h.rx=Number(c??u),h.ry=Number(u??c),h):l!=null&&Number.isFinite(Number(l))?(h.r=Number(l),h):null}function Mt(n,e,t){if(!n||typeof n!="object")return null;const r=n,s=P(r.path_d||r.path||r.d),i=P(r.color,e),o=r.stroke_width!=null?N(r.stroke_width,t):t;if(s)return{path_d:s,close:q(r.close),color:i,stroke_width:o,css_selector:P(r.css_selector)||void 0};const a=P(r.css_selector||r.selector),l=r.points,c=kn(r,e,t,l);if(c)return c;if(a&&!Array.isArray(l))return{css_selector:a,color:i,stroke_width:o};let u=l;if(!Array.isArray(u)){const d=r.from_x,p=r.from_y,h=r.to_x,f=r.to_y;d!=null&&p!=null&&h!=null&&f!=null&&(u=[[d,p],[h,f]])}if(Array.isArray(u)&&u.length>=2){const d=P(r.kind),p=q(r.close)||d==="triangle"||d==="polygon";return{points:u,close:p,color:i,stroke_width:o,css_selector:a||void 0}}return a?{css_selector:a,color:i,stroke_width:o}:null}function pt(n){if(Array.isArray(n)&&n.length>=2){const e=Number(n[0]),t=Number(n[1]);return!Number.isFinite(e)||!Number.isFinite(t)?null:re(e,t)}if(n&&typeof n=="object"&&"x"in n&&"y"in n){const e=Number(n.x),t=Number(n.y);return!Number.isFinite(e)||!Number.isFinite(t)?null:re(e,t)}return null}function En(n){const e=n.points;if(!Array.isArray(e))return[];const t=[];for(const r of e){const s=pt(r);s&&t.push(s)}return t}function le(n,e){return{class:"vnr-screen-ink-stroke",fill:"none",stroke:n,"stroke-width":String(e),"stroke-linecap":"round","stroke-linejoin":"round"}}function ce(n,e){for(const[t,r]of Object.entries(e))n.setAttribute(t,r)}function Tn(n,e){if(n.length===0)return"";const t=n.map((r,s)=>`${s===0?"M":"L"} ${r.px} ${r.py}`).join(" ");return e&&n.length>=3?`${t} Z`:t}function An(n){return`<svg class="vnr-screen-cursor" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
83
|
-
<path d="M4 4L4 19L9 14L13 20L15 19L11 13L17 13L4 4Z" fill="${n}" stroke="#fff" stroke-width="1.2"/>
|
|
84
|
-
</svg>`}class In{constructor(){_(this,"root",null);_(this,"inkSvg",null);_(this,"labelsLayer",null);_(this,"cursorEl",null);_(this,"cursorTimer",null);_(this,"lastCursorPoint",null);_(this,"flyFrameId",null);_(this,"userDrawActive",!1);_(this,"userDrawColor","#f97316");_(this,"userStrokeWidth",ae);_(this,"userDrawPath",null);_(this,"userDrawPoints",[]);_(this,"userDrawBound",!1);_(this,"userDrawLayer",null);_(this,"onUserPointerDown",e=>this.handleUserPointerDown(e));_(this,"onUserPointerMove",e=>this.handleUserPointerMove(e));_(this,"onUserPointerUp",e=>this.handleUserPointerUp(e))}ensureRoot(){var e;return gn(),(e=this.root)!=null&&e.isConnected?this.root:(this.root=document.createElement("div"),this.root.className="vnr-screen-overlay-root",this.root.setAttribute("aria-hidden","true"),document.body.appendChild(this.root),this.root)}clear(){this.disableUserDrawing(),this.cursorTimer&&(clearTimeout(this.cursorTimer),this.cursorTimer=null),this.root&&(this.root.remove(),this.root=null),this.inkSvg=null,this.cursorEl=null,this.labelsLayer=null}clearInk(){this.inkSvg&&(this.inkSvg.remove(),this.inkSvg=null),this.labelsLayer&&(this.labelsLayer.remove(),this.labelsLayer=null)}addTextLabels(e,t="#ece6d9"){var i;if(e.length===0)return 0;const r=this.ensureRoot();(i=this.labelsLayer)!=null&&i.isConnected||(this.labelsLayer=document.createElement("div"),this.labelsLayer.className="vnr-screen-labels-layer",r.appendChild(this.labelsLayer));const s=this.labelsLayer;for(const o of e){const a=re(o.x,o.y),l=document.createElement("div");l.className="vnr-screen-ink-label",l.textContent=o.text;const c=rt(o.color,t),u=o.font_size??20;l.style.cssText=`left:${a.px}px;top:${a.py}px;color:${c};font-size:${u}px;`,s.appendChild(l)}return e.length}hideCursor(){this.cancelFly(),this.cursorTimer&&(clearTimeout(this.cursorTimer),this.cursorTimer=null),this.cursorEl&&(this.cursorEl.remove(),this.cursorEl=null)}getLastCursorPoint(){return this.lastCursorPoint}cancelFly(){this.flyFrameId!=null&&(cancelAnimationFrame(this.flyFrameId),this.flyFrameId=null)}defaultFlyStart(){if(this.lastCursorPoint)return this.lastCursorPoint;const e=window.innerWidth,t=window.innerHeight;return{px:e*.82,py:t*.86}}placeCursorWrap(e,t,r,s){if(e.style.cssText=`position:absolute;left:${t.px}px;top:${t.py}px;`,e.innerHTML=An(r),s){const i=document.createElement("div");i.className="vnr-screen-cursor-label",i.style.background=r,i.textContent=s,e.appendChild(i)}}async flyCursorTo(e,t={}){this.cancelFly(),this.cursorTimer&&(clearTimeout(this.cursorTimer),this.cursorTimer=null);const r=t.from??this.defaultFlyStart(),s=P(t.color,"#f97316"),i=N(t.fly_duration_ms,680),o=this.ensureRoot();this.hideCursor();const a=document.createElement("div");this.placeCursorWrap(a,r,s);const l=a.querySelector(".vnr-screen-cursor");l&&l.classList.add("vnr-screen-cursor-flying"),o.appendChild(a),this.cursorEl=a;const c=Math.max(72,Math.abs(r.py-e.py)*.38),u={px:(r.px+e.px)/2,py:Math.min(r.py,e.py)-c};await new Promise(h=>{const f=performance.now(),y=v=>{const g=Math.min(1,(v-f)/i),b=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2,S=1-b,w=S*S*r.px+2*S*b*u.px+b*b*e.px,x=S*S*r.py+2*S*b*u.py+b*b*e.py;a.style.left=`${w}px`,a.style.top=`${x}px`;const C=e.px-w,k=e.py-x;if(l&&Math.hypot(C,k)>6){const E=Math.atan2(k,C)*180/Math.PI;l.style.transform=`rotate(${E-45}deg)`,l.style.transformOrigin="2px 2px"}g<1?this.flyFrameId=requestAnimationFrame(y):(a.style.left=`${e.px}px`,a.style.top=`${e.py}px`,this.flyFrameId=null,h())};this.flyFrameId=requestAnimationFrame(y)}),l&&l.classList.remove("vnr-screen-cursor-flying");const d=P(t.label);if(d){let h=a.querySelector(".vnr-screen-cursor-label");h||(h=document.createElement("div"),h.className="vnr-screen-cursor-label",a.appendChild(h)),h.style.background=s,h.textContent=d}this.lastCursorPoint=e;const p=N(t.duration_ms,0);return p>0&&(this.cursorTimer=setTimeout(()=>this.hideCursor(),p)),e}async outlineSelectors(e,t="#f97316",r={}){const s=e.map(i=>({css_selector:i,close:!0,color:t})).filter(i=>!!i.css_selector);return s.length===0?0:this.addStrokes(s,t,{animate:r.animate!==!1,duration_ms:r.duration_ms??600,gap_ms:r.gap_ms??60,stroke_width:r.stroke_width??ae})}syncInkSvgViewport(e){const t=window.innerWidth,r=window.innerHeight;e.setAttribute("width",String(t)),e.setAttribute("height",String(r)),e.setAttribute("viewBox",`0 0 ${t} ${r}`)}ensureInkSvg(){var r;const e=this.ensureRoot();if((r=this.inkSvg)!=null&&r.isConnected)return this.syncInkSvgViewport(this.inkSvg),this.inkSvg;const t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("class","vnr-screen-ink-svg"),t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("preserveAspectRatio","none"),this.syncInkSvgViewport(t),e.appendChild(t),this.inkSvg=t,t}createCircleElement(e,t,r){if(e.cx==null||e.cy==null)return null;const s=window.innerWidth,i=window.innerHeight,o=W(e.cx,s),a=W(e.cy,i),l="http://www.w3.org/2000/svg";if(e.kind==="ellipse"||e.rx!=null||e.ry!=null){const u=e.rx??e.r,d=e.ry??e.r;if(u==null||d==null)return null;const p=document.createElementNS(l,"ellipse");return p.setAttribute("cx",String(o)),p.setAttribute("cy",String(a)),p.setAttribute("rx",String(W(Number(u),s))),p.setAttribute("ry",String(W(Number(d),i))),ce(p,le(t,r)),p}if(e.r==null)return null;const c=document.createElementNS(l,"circle");return c.setAttribute("cx",String(o)),c.setAttribute("cy",String(a)),c.setAttribute("r",String(Sn(Number(e.r)))),ce(c,le(t,r)),c}createFreeformElement(e,t,r){const s=P(e.color,t),i=e.stroke_width!=null?N(e.stroke_width,r):r;if(e.kind==="circle"||e.kind==="ellipse"||e.r!=null||e.rx!=null||e.ry!=null)return this.createCircleElement(e,s,i);const a=document.createElementNS("http://www.w3.org/2000/svg","path"),l=P(e.path_d);if(l)return a.setAttribute("d",l),ce(a,le(s,i)),a;let c=e;if(e.css_selector){const d=Ct(e.css_selector,s);d&&(c={...e,points:d.points,close:d.close,color:d.color})}const u=En(c);return u.length<2?null:(a.setAttribute("d",Tn(u,q(c.close))),ce(a,le(s,i)),a)}async addStrokes(e,t="#f97316",r={}){const s=this.ensureInkSvg(),i=r.animate!==!1,o=r.duration_ms??He,a=r.gap_ms??At,l=r.stroke_width??ae;let c=0;for(const u of e){const d=this.createFreeformElement(u,t,l);d&&(s.appendChild(d),c+=1,i&&await et(d,o),i&&a>0&&await ht(a))}return c}async addInk(e,t,r){return this.addStrokes(e,t,r)}enableUserDrawing(e){const t=this.ensureRoot();if(this.userDrawActive=!0,this.userDrawColor=P(e==null?void 0:e.color,"#f97316"),this.userStrokeWidth=N(e==null?void 0:e.stroke_width,ae),e!=null&&e.region){const r=window.innerWidth,s=window.innerHeight,i=e.region,o=W(i.x,r),a=W(i.y,s),l=W(i.width,r),c=W(i.height,s),u=document.createElement("div");u.className="vnr-screen-user-draw-layer",u.style.cssText=`position:fixed;left:${o}px;top:${a}px;width:${l}px;height:${c}px;pointer-events:auto;cursor:crosshair;touch-action:none;z-index:1;`,t.appendChild(u),this.userDrawLayer=u,this.bindUserDrawEvents(u)}else t.classList.add("vnr-screen-overlay-interactive"),this.bindUserDrawEvents(t)}bindUserDrawEvents(e){this.userDrawBound||(e.addEventListener("pointerdown",this.onUserPointerDown),e.addEventListener("pointermove",this.onUserPointerMove),e.addEventListener("pointerup",this.onUserPointerUp),e.addEventListener("pointercancel",this.onUserPointerUp),this.userDrawBound=!0)}unbindUserDrawEvents(e){!e||!this.userDrawBound||(e.removeEventListener("pointerdown",this.onUserPointerDown),e.removeEventListener("pointermove",this.onUserPointerMove),e.removeEventListener("pointerup",this.onUserPointerUp),e.removeEventListener("pointercancel",this.onUserPointerUp),this.userDrawBound=!1)}disableUserDrawing(){this.userDrawActive=!1,this.userDrawPath=null,this.userDrawPoints=[],this.userDrawLayer?(this.unbindUserDrawEvents(this.userDrawLayer),this.userDrawLayer.remove(),this.userDrawLayer=null):this.root&&(this.unbindUserDrawEvents(this.root),this.root.classList.remove("vnr-screen-overlay-interactive"))}handleUserPointerDown(e){if(!this.userDrawActive||e.button!==0)return;e.preventDefault(),e.stopPropagation();const t=e.currentTarget??this.root;t==null||t.setPointerCapture(e.pointerId);const r=this.ensureInkSvg(),s=document.createElementNS("http://www.w3.org/2000/svg","path");ce(s,le(this.userDrawColor,this.userStrokeWidth)),this.userDrawPath=s,this.userDrawPoints=[`M ${e.clientX} ${e.clientY}`],s.setAttribute("d",this.userDrawPoints.join(" ")),r.appendChild(s)}handleUserPointerMove(e){!this.userDrawActive||!this.userDrawPath||(e.preventDefault(),this.userDrawPoints.push(`L ${e.clientX} ${e.clientY}`),this.userDrawPath.setAttribute("d",this.userDrawPoints.join(" ")))}async handleUserPointerUp(e){var r;if(!this.userDrawPath)return;e.preventDefault();const t=this.userDrawPath;this.userDrawPath=null,this.userDrawPoints=[];try{(r=e.currentTarget)==null||r.releasePointerCapture(e.pointerId)}catch{}await et(t,He)}showCursor(e,t="#f97316"){const r=e,s=bn(r);if(!s)return null;const i=P(e.color,t),o=P(e.label)||void 0;if(q(e.fly)||q(r.fly))return this.flyCursorTo(s,{color:i,label:o,fly_duration_ms:N(e.fly_duration_ms??r.fly_duration_ms,680),duration_ms:N(e.duration_ms,0)}),s;this.hideCursor();const l=this.ensureRoot(),c=document.createElement("div");this.placeCursorWrap(c,s,i,o),l.appendChild(c),this.cursorEl=c,this.lastCursorPoint=s;const u=N(e.duration_ms,2500);return u>0&&(this.cursorTimer=setTimeout(()=>this.hideCursor(),u)),s}showClickRipple(e,t,r="#f97316"){const s=this.ensureRoot(),i=document.createElement("div");i.className="vnr-screen-click-ripple",i.style.cssText=`left:${e}px;top:${t}px;color:${r};`,s.appendChild(i),setTimeout(()=>i.remove(),700)}async applyInkFromArgs(e,t){const r=P(e.color||t.color,"#f97316"),s=rt(e.label_color??t.label_color,"#ece6d9"),i=q(e.clear)||q(e.clear_before)||q(t.clear_before),o=!Lt(e.animate)&&!Lt(t.animate),a=N(e.duration_ms??t.duration_ms,He),l=N(e.gap_ms??t.gap_ms,At),c=N(e.stroke_width??t.stroke_width,ae),u=q(e.interactive)||q(e.user_draw)||q(t.interactive),d=e.interactive_region??t.interactive_region;let p;if(d&&typeof d=="object"){const b=d;p={x:N(b.x,0),y:N(b.y,0),width:N(b.width??b.w,1),height:N(b.height??b.h,1)}}const h=[];for(const b of wn(e.labels??t.labels)){const S=cr(b,s);S&&h.push(S)}let f=Pt(e.strokes??t.strokes);f.length===0&&(f=Pt(e.annotations??t.annotations));const y=[];for(const b of f){const S=xn(b),w=_n(S,s);if(w){h.push(w);continue}const x=Mt(S,r,c);x&&y.push(x)}if(y.length===0){const b=P(e.css_selector??e.selector??t.css_selector??t.selector);if(b){const S=Ct(b,r);S&&y.push({css_selector:b,...S,stroke_width:c})}}if(y.length===0){const b=Mt({kind:e.kind??e.shape??t.kind,cx:e.cx??e.center_x??t.cx,cy:e.cy??e.center_y??t.cy,r:e.r??e.radius??t.r,rx:e.rx??t.rx,ry:e.ry??t.ry,points:e.points??t.points,path_d:e.path_d??e.path??e.d??t.path_d??t.path,close:e.close??t.close,css_selector:e.css_selector??e.selector??t.css_selector??t.selector,from_x:e.from_x??t.from_x,from_y:e.from_y??t.from_y,to_x:e.to_x??t.to_x,to_y:e.to_y??t.to_y,color:r,stroke_width:c},r,c);b&&y.push(b)}i&&this.clearInk();let v=0;y.length>0&&(v=await this.addStrokes(y,r,{animate:o,duration_ms:a,gap_ms:l,stroke_width:c}));const g=this.addTextLabels(h,s);return u&&this.enableUserDrawing({color:r,stroke_width:c,region:p}),{strokes:v,labels:g}}}let se=null;function fe(){return se||(se=new In),se}function De(){se==null||se.clear()}function Ln(n,e){const t=document.elementsFromPoint(n,e);for(const r of t)if(r instanceof HTMLElement&&!r.closest(".vnr-screen-overlay-root"))return r;return null}function Pn(n){try{n.focus({preventScroll:!0})}catch{}const e=n.tagName.toLowerCase(),t=e==="input"?n.type.toLowerCase():"";if((e==="button"||e==="a"||["submit","button","checkbox","radio","reset"].includes(t))&&typeof n.click=="function"){n.click();return}const s={bubbles:!0,cancelable:!0,view:window,button:0,buttons:1};n.dispatchEvent(new MouseEvent("mousedown",s)),n.dispatchEvent(new MouseEvent("mouseup",s)),n.dispatchEvent(new MouseEvent("click",s))}const nt=new Map,st=new Map;function de(n,e=""){return typeof n=="string"?n:e}function Mn(n){nt.clear(),st.clear();for(const e of n.elements)e.element_id&&nt.set(e.element_id,e),st.set(e.css_selector,e)}function Nn(n){return nt.get(n.trim())}function Dn(n,e=48){return n.elements.slice(0,e).map(t=>{var o;const r=t.element_id??"?",s=t.label.slice(0,56).replace(/\s+/g," ");let i=`${r} ${t.kind} "${s}" center=(${t.center_x.toFixed(3)},${t.center_y.toFixed(3)}) sel=${t.css_selector}`;if((o=t.stroke_points)!=null&&o.length){const a=t.stroke_points.map(l=>[Number(l.x.toFixed(3)),Number(l.y.toFixed(3))]);i+=` stroke_points=${JSON.stringify(a)}`}return i}).join(`
|
|
85
|
-
`)}function Bn(n){if(n.length===0)return null;let e=0,t=0;for(const i of n)e+=i.x,t+=i.y;const r=e/n.length,s=t/n.length;return re(r,s)}function Ce(n,e={}){var o;const t=de(n.element_id??n.target??n.element??e.element_id??e.target).trim();if(t){const a=Nn(t);if(a){const l=(o=a.stroke_points)!=null&&o.length?Bn(a.stroke_points):null,c=l?null:tt(a.css_selector),u=l??c??re(a.center_x,a.center_y);return{element_id:a.element_id,css_selector:a.css_selector,point:u,label:de(n.label,a.label),kind:a.kind}}}const r=de(n.css_selector??n.selector??e.css_selector??e.selector).trim();if(r){const a=tt(r);if(a){const l=st.get(r);return{css_selector:r,point:a,label:de(n.label,(l==null?void 0:l.label)??""),element_id:l==null?void 0:l.element_id,kind:l==null?void 0:l.kind}}}const s=n.x??n.client_x??e.x,i=n.y??n.client_y??e.y;if(s!=null&&i!=null){const a=Number(s),l=Number(i);if(Number.isFinite(a)&&Number.isFinite(l))return{point:re(a,l),label:de(n.label)}}return null}function $n(n,e={}){const t=n.targets??n.element_ids??n.elements??e.targets??e.element_ids;if(Array.isArray(t)){const s=[];for(const i of t)if(typeof i=="string"){const o=Ce({element_id:i},e);o&&s.push(o)}else if(i&&typeof i=="object"){const o=Ce(i,e);o&&s.push(o)}if(s.length>0)return s}const r=Ce(n,e);return r?[r]:[]}function ve(n,e=""){return typeof n=="string"?n:e}function ie(n,e=!0){if(n==null)return e;if(n===!0||n===1)return!0;if(n===!1||n===0)return!1;const t=String(n).trim().toLowerCase();return t==="true"||t==="1"||t==="yes"?!0:t==="false"||t==="0"||t==="no"?!1:e}function Rn(n,e,t,r){const s=n.args??{},i=n.clientFields??{},o=ve(s.prompt??s.message??i.default_prompt).trim(),a=Number(s.max_elements??i.max_elements??64),l=ie(s.include_image??i.include_image,!1),c=Number(s.max_width??i.max_width??1280),u=ve(s.reason??i.reason,"page_scan");if(typeof document>"u"){t("Page scan is only available in browser environments");return}(async()=>{try{const d=lr({maxElements:Number.isFinite(a)?a:64});Mn(d);const p=Dn(d),f=`${o?`Page scanned. Context: ${o}`:"Visible page scanned — use element ids below for point_at and outline_targets."}
|
|
1
|
+
"use strict";var Ry=Object.defineProperty;var Py=(r,e,t)=>e in r?Ry(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var L=(r,e,t)=>Py(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vt=require("react");var dc=typeof document<"u"?document.currentScript:null;const Dy="https://api.vanira.io",_={Form:"vanira_form",Calendar:"vanira_calendar",Navigate:"vanira_navigate",Upload:"vanira_upload",Camera:"vanira_camera",HighlightElement:"vanira_highlight_element",ClickElement:"vanira_click_element",SelectOption:"vanira_select_option",SetDate:"vanira_set_date",TypeText:"vanira_type_text",WriteLatexText:"vanira_write_latex_text",EraseText:"vanira_erase_text",LiveVision:"vanira_live_vision",CloseLiveCamera:"vanira_close_live_camera",LiveScreen:"vanira_live_screen",CloseLiveScreen:"vanira_close_live_screen",ClipRegion:"vanira_clip_region",ScreenVision:"vanira_screen_vision",PointAt:"vanira_point_at",DrawOnScreen:"vanira_draw_on_screen",ClearScreenDraw:"vanira_clear_screen_draw",HighlightOnScreen:"vanira_highlight_on_screen",KycDocumentCapture:"vanira_kyc_document_capture",KycSelfieCapture:"vanira_kyc_selfie_capture",KycSignatureCapture:"vanira_kyc_signature_capture"},Ly=Object.values(_),Oy=new Set(Ly),Hy=new Set([_.Camera,_.LiveVision,_.LiveScreen]),Ny=new Set([_.Navigate,_.HighlightElement,_.ClickElement,_.SelectOption,_.SetDate,_.TypeText,_.WriteLatexText,_.EraseText,_.LiveVision,_.CloseLiveCamera,_.LiveScreen,_.CloseLiveScreen,_.ScreenVision,_.PointAt,_.DrawOnScreen,_.ClearScreenDraw,_.HighlightOnScreen]),Ky=new Set([_.TypeText,_.WriteLatexText,_.EraseText]);function Xn(r){return!!r&&Oy.has(r)}function Vy(r){return Xn(r)&&Ny.has(r)}function n0(r){return Xn(r)&&Ky.has(r)}function El(r){return Xn(r)&&Hy.has(r)}const zy=new Set([_.Form,_.Calendar]);function Ul(r){return Xn(r)&&zy.has(r)}function r0(r,e,t){return t!=null&&t.action_name?String(t.action_name):r===_.Calendar?"calendar_slot_selected":`user_submitted_${e||"collect_user_data"}`}function i0(r){return Xn(r)&&!El(r)&&!Ul(r)}const Gy=new Set([_.ScreenVision,_.PointAt,_.DrawOnScreen,_.ClearScreenDraw,_.HighlightOnScreen]);function qy(r){return Xn(r)&&Gy.has(r)}function Vp(r){if(typeof r=="string")try{return JSON.parse(r)}catch{return{}}return r&&typeof r=="object"?r:{}}const s0={type_on_whiteboard:_.TypeText,write_on_whiteboard:_.TypeText,write_on_white_board:_.TypeText,dom_typing_simulation:_.TypeText,write_latex_text:_.WriteLatexText,write_latex_on_board:_.WriteLatexText,latex_on_whiteboard:_.WriteLatexText,erase_text:_.EraseText,dom_erase:_.EraseText,open_live_camera:_.LiveVision,live_vision:_.LiveVision,close_live_camera:_.CloseLiveCamera,stop_live_camera:_.CloseLiveCamera,open_live_screen:_.LiveScreen,close_live_screen:_.CloseLiveScreen,screen_vision:_.ScreenVision,capture_screen_vision:_.ScreenVision,capture_screen:_.ScreenVision,tab_screenshot:_.ScreenVision,capture_tab:_.ScreenVision,capture_tab_screenshot:_.ScreenVision,screenshot_tab:_.ScreenVision,point_at:_.PointAt,point_at_screen:_.PointAt,draw_on_screen:_.DrawOnScreen,screen_draw:_.DrawOnScreen,clear_screen_draw:_.ClearScreenDraw,clear_screen_annotations:_.ClearScreenDraw,highlight_on_screen:_.HighlightOnScreen,highlight_element_on_screen:_.HighlightOnScreen,highlight_screen_element:_.HighlightOnScreen,kyc_document_capture:_.KycDocumentCapture,capture_id_document:_.KycDocumentCapture,document_capture:_.KycDocumentCapture,capture_kyc_document:_.KycDocumentCapture,kyc_selfie_capture:_.KycSelfieCapture,capture_selfie:_.KycSelfieCapture,selfie_capture:_.KycSelfieCapture,capture_kyc_selfie:_.KycSelfieCapture,kyc_signature_capture:_.KycSignatureCapture,capture_kyc_signature:_.KycSignatureCapture,signature_capture:_.KycSignatureCapture},a0={vanira_tab_screenshot:_.ScreenVision,vanira_document_capture:_.KycDocumentCapture,vanira_selfie_capture:_.KycSelfieCapture,vanira_signature_capture:_.KycSignatureCapture,vanira_kyc_signature:_.KycSignatureCapture};function Wy(r,e){const t=r.latex_text??(e==null?void 0:e.latex_text);return typeof t=="string"&&t.trim().length>0}function A0(r,e){const t=r.text_to_type??(e==null?void 0:e.text_to_type)??r.text??(e==null?void 0:e.text)??r.value??(e==null?void 0:e.value);return typeof t=="string"&&t.trim().length>0}function $y(r,e){const t=r.fields??(e==null?void 0:e.fields);return Array.isArray(t)?t.length>0:typeof t=="string"?t.split(",").map(n=>n.trim()).filter(Boolean).length>0:!1}function jy(r,e){const t=r==null?void 0:r.preset_id;if(typeof t=="string"){if(Xn(t))return t;const s=a0[t];if(s)return s}const i=Vp(e).preset_id;if(typeof i=="string"){if(Xn(i))return i;const s=a0[i];if(s)return s}}function Gd(r,e,t){const n=Vp(e);let i=jy(r,n);if(i===_.Form&&A0(n,r)&&!$y(n,r))return _.TypeText;if(i)return i;const s=String(t??"").trim().toLowerCase();if(s&&s0[s])return s0[s];if(Wy(n,r))return _.WriteLatexText;if(A0(n,r))return _.TypeText}const DA="vanira_latest_call_id",Fl="vanira_prospect_id";function LA(r){return`vanira_latest_call_id_${r}`}function OA(r){return`vanira_prospect_id_${r}`}function zp(r){return`vanira_call_meta_${r}`}function Tr(r,e){if(!r)return null;try{return r.getItem(e)}catch{return null}}function HA(r){if(typeof window>"u"||!r)return null;const e=[],t=Tr(window.localStorage,zp(r));if(t)try{const A=JSON.parse(t);A!=null&&A.callId&&e.push({callId:A.callId,prospectId:A.prospectId,updatedAt:A.updatedAt||0})}catch{}const n=(A,o,c)=>{A&&e.push({callId:A,prospectId:o||void 0,updatedAt:c})},i=Tr(window.localStorage,OA(r)),s=Tr(window.sessionStorage,OA(r)),a=Tr(window.localStorage,Fl);return n(Tr(window.localStorage,LA(r)),i||a,2),n(Tr(window.sessionStorage,LA(r)),s||a,1),n(Tr(window.localStorage,DA),a,0),n(Tr(window.sessionStorage,DA),a,0),e.length?(e.sort((A,o)=>o.updatedAt-A.updatedAt),e[0]):null}function Gp(r,e,t){var i,s,a,A,o,c,l,d,u;if(typeof window>"u"||!r||!e)return;const n={callId:e,prospectId:t,updatedAt:Date.now()};try{(i=window.localStorage)==null||i.setItem(zp(r),JSON.stringify(n)),(s=window.localStorage)==null||s.setItem(LA(r),e),(a=window.sessionStorage)==null||a.setItem(LA(r),e),t&&((A=window.localStorage)==null||A.setItem(OA(r),t),(o=window.sessionStorage)==null||o.setItem(OA(r),t)),(c=window.localStorage)==null||c.setItem(DA,e),(l=window.sessionStorage)==null||l.setItem(DA,e),t&&((d=window.localStorage)==null||d.setItem(Fl,t),(u=window.sessionStorage)==null||u.setItem(Fl,t))}catch{}}function Xy(r){var e;return!!((e=HA(r))!=null&&e.callId)}const Jy=new Set(["client_tool_call","clearAudio","client_tool_cancel"]);function qp(r){if(!r||typeof r!="object")return!1;const e=r.event;return typeof e=="string"&&Jy.has(e)}const uc=16*1024,Yy=256*1024;function hc(r,e){return(r==null?void 0:r.readyState)==="open"&&(e==null?void 0:e.readyState)==="open"}function Zy(r,e){return{control:(r==null?void 0:r.readyState)??"missing",mediaBytes:(e==null?void 0:e.readyState)??"missing"}}async function ew(r,e,t=8e3){if(hc(r,e))return!0;const n=Date.now()+t;for(;Date.now()<n;){if(hc(r,e))return!0;await new Promise(i=>setTimeout(i,50))}return hc(r,e)}async function o0(r){for(;r.bufferedAmount>Yy;)await new Promise(e=>setTimeout(e,10))}async function tw(r){const{bytes:e,filename:t,contentType:n,reason:i,message:s,callId:a,mediaBytesChannel:A,sendControlEvent:o,uploadId:c=crypto.randomUUID(),uploadKind:l="media"}=r,d=e.byteLength,u=d===0?0:Math.ceil(d/uc);o("client_media_upload_start",{data:{upload_id:c,call_id:a,reason:i,message:s,filename:t,content_type:n,size:d,chunk_count:u,upload_kind:l}});const h=new Uint8Array(e);for(let p=0;p<d;p+=uc){await o0(A);const g=Math.min(p+uc,d);A.send(h.subarray(p,g))}return await o0(A),o("client_media_upload_complete",{data:{upload_id:c,call_id:a,reason:i,message:s,chunk_count:u,upload_kind:l}}),{media_id:c,url:"",content_type:n}}async function nw(r){return typeof r.arrayBuffer=="function"?r.arrayBuffer():new Response(r).arrayBuffer()}let ii=null;const rw=4e3;function qd(r){if(typeof window>"u")return r||"/";const e=(r||"/").trim();if(!e)return"/";try{const t=new URL(e,window.location.origin);return t.origin!==window.location.origin?e:`${t.pathname}${t.search}${t.hash}`||"/"}catch{return e.startsWith("/")?e:`/${e}`}}function Wp(r,e){ii={targetRoute:qd(r),presetId:e==null?void 0:e.presetId,toolName:e==null?void 0:e.toolName,expiresAt:Date.now()+rw}}function iw(r){if(!ii)return null;if(Date.now()>ii.expiresAt)return ii=null,null;const e=qd(r),t=ii.targetRoute;if(!(e===t||e.startsWith(t.split("#")[0])||t.startsWith(e.split("#")[0])))return null;const i=ii;return ii=null,i}function Qs(){return typeof window>"u"?"/":`${window.location.pathname}${window.location.search}${window.location.hash}`||"/"}class $p{constructor(e){L(this,"active",!1);L(this,"initialSent",!1);L(this,"lastRoute","");L(this,"sendContext");L(this,"isReady");L(this,"cleanupFns",[]);L(this,"initialRetryTimer",null);L(this,"routePollTimer",null);L(this,"originalPushState",null);L(this,"originalReplaceState",null);this.sendContext=e.sendContext,this.isReady=e.isReady??(()=>!0)}start(){typeof window>"u"||this.active||(this.active=!0,this.initialSent=!1,this.lastRoute=Qs(),this.attachListeners(),this.scheduleInitialContextSend())}stop(){if(!(!this.active&&this.cleanupFns.length===0)){this.active=!1,this.initialSent=!1,this.initialRetryTimer!==null&&(clearTimeout(this.initialRetryTimer),this.initialRetryTimer=null),this.routePollTimer!==null&&(clearInterval(this.routePollTimer),this.routePollTimer=null);for(const e of this.cleanupFns)try{e()}catch{}this.cleanupFns.length=0,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null)}}onChannelReady(){this.scheduleInitialContextSend()}scheduleInitialContextSend(e=0){if(!(!this.active||this.initialSent)){if(this.isReady()){this.sendRouteContext("call_started"),this.initialSent=!0;return}e>=30||(this.initialRetryTimer=window.setTimeout(()=>this.scheduleInitialContextSend(e+1),100))}}attachListeners(){const e=(s,a=0)=>{const A=()=>{const o=Qs();o!==this.lastRoute&&this.handleRouteChange(o,s)};a>0?window.setTimeout(A,a):queueMicrotask(A)},t=()=>e("popstate"),n=()=>e("hashchange"),i=s=>{const a=s.detail;if((a==null?void 0:a.initiated_by)==="agent"){e("vanira_navigate_agent",120);return}e("vanira_navigate",120)};window.addEventListener("popstate",t),window.addEventListener("hashchange",n),window.addEventListener("vanira:navigate",i),this.cleanupFns.push(()=>window.removeEventListener("popstate",t),()=>window.removeEventListener("hashchange",n),()=>window.removeEventListener("vanira:navigate",i)),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history),history.pushState=(...s)=>{this.originalPushState(...s),e("pushState")},history.replaceState=(...s)=>{this.originalReplaceState(...s),e("replaceState")},this.routePollTimer=window.setInterval(()=>{if(!this.active)return;const s=Qs();s!==this.lastRoute&&this.handleRouteChange(s,"location_poll")},1e3)}handleRouteChange(e,t){if(!this.active)return;const n=this.lastRoute;if(n===e)return;if(this.lastRoute=e,!this.initialSent){this.scheduleInitialContextSend();return}!this.isReady()||iw(e)||this.sendRouteContext("route_changed",n,t,"user")}sendRouteContext(e,t,n,i="user"){const s=Qs();this.lastRoute=s;const a={ui_state:"page_navigation",navigation_led_by:i,current_route:s,current_page:s,user_action:e==="call_started"?"call_started_on_page":"user_navigated"};e==="call_started"?a.message=`User started the call while viewing ${s}.`:(a.previous_route=t??"",a.message=`User navigated from ${t||"(unknown)"} to ${s}.`,n&&(a.navigation_source=n));try{this.sendContext(a)}catch{}}}const dr=class dr{constructor(e){L(this,"serverUrl");L(this,"agentId");L(this,"callId");L(this,"prospectId");L(this,"apiKey");L(this,"backendUrl");L(this,"token");L(this,"onConnected");L(this,"onDisconnected");L(this,"onError");L(this,"onTranscription");L(this,"onLocalStream");L(this,"onRemoteTrack");L(this,"onClientToolCall");L(this,"onSessionStarted");L(this,"sessionStartedEmitted",!1);L(this,"pc",null);L(this,"dataChannel",null);L(this,"mediaBytesChannel",null);L(this,"audioElement",null);L(this,"localStream",null);L(this,"micMuted",!1);L(this,"connected",!1);L(this,"icePollInterval",null);L(this,"appliedRemoteCandidates",new Set);L(this,"iceServers");L(this,"callSessionLoaded",!1);L(this,"connectGeneration",0);L(this,"runtime");L(this,"sessionBehavior");L(this,"routeTracker",null);L(this,"_status","idle");L(this,"listeners",new Map);L(this,"liveVision");L(this,"liveVisionAutoStarted",!1);if(!e.agentId)throw new Error("agentId is required");const t=!!(e.apiKey||e.token),n=!!(e.serverUrl&&e.callId),i=dr.normalizeIceServers(e.iceServers);if(!t&&!n)throw new Error("apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create");this.agentId=e.agentId,this.sessionBehavior=e.sessionBehavior,this.serverUrl=(e.serverUrl||"").replace(/\/$/,""),this.apiKey=e.apiKey,this.token=e.token,this.backendUrl=(e.backendUrl||Dy).replace(/\/$/,""),i.length&&(this.iceServers=i),n&&(this.callSessionLoaded=!0);const s=typeof window<"u";this.prospectId=e.prospectId;const a=e.sessionBehavior==="continue";if(a&&s&&!e.callId){const o=HA(this.agentId);o&&(e.callId||(this.callId=o.callId),!this.prospectId&&o.prospectId&&(this.prospectId=o.prospectId))}if(!this.prospectId&&s)try{const o=HA(this.agentId);this.prospectId=(o==null?void 0:o.prospectId)||window.sessionStorage&&window.sessionStorage.getItem("vanira_prospect_id")||window.localStorage&&window.localStorage.getItem("vanira_prospect_id")||void 0}catch{}e.callId?this.callId=e.callId:a||(this.callId=void 0);const A=e.onSessionStarted;this.onSessionStarted=o=>{A==null||A(o),this.emit("session_started",o)},this.liveVision=e.liveVision,this.onConnected=()=>{var o;this._status="connected",(o=e.onConnected)==null||o.call(e),this.emit("connected"),this.maybeAutoStartLiveCamera()},this.onDisconnected=()=>{var o;this._status="disconnected",(o=e.onDisconnected)==null||o.call(e),this.emit("disconnected")},this.onError=o=>{var l;this._status="error";const c=typeof o=="string"?o:(o==null?void 0:o.message)||"Connection error";(l=e.onError)==null||l.call(e,o),this.emit("error",c)},this.onTranscription=(o,c)=>{var l;(l=e.onTranscription)==null||l.call(e,o,c),this.emit("transcription",{text:o,isFinal:c})},this.onLocalStream=e.onLocalStream||(()=>{}),this.onRemoteTrack=(o,c)=>{var l;(l=e.onRemoteTrack)==null||l.call(e,o,c),this.emit("track",{track:o,stream:c})},this.onClientToolCall=o=>{var d;(d=e.onClientToolCall)==null||d.call(e,o);const c=(o==null?void 0:o.data)||o,l={name:String(c.name||c.tool_name||""),arguments:c.arguments||c.args||{},tool_call_id:String(c.tool_call_id||c.call_id||""),execution_mode:c.execution_mode==="blocking"?"blocking":"fire_and_forget",client_fields:c.client_fields||{}};l.name&&l.tool_call_id&&this.emit("tool_call",l)},this.runtime=e.runtime,typeof window<"u"&&e.trackRouteContext!==!1&&(this.routeTracker=new $p({sendContext:o=>this.sendContextUpdate(o),isReady:()=>{var o;return((o=this.dataChannel)==null?void 0:o.readyState)==="open"}}))}async createCall(){return this.connect()}async connect(){var t;this._status="connecting";const e=++this.connectGeneration;if(await this.loadCallSession(),!this.isConnectCancelled(e)){if(!this.serverUrl)throw new Error("[VaniraClient] worker_url missing from /calls/create");if(!this.callId)throw new Error("[VaniraClient] call_id missing — must come from POST /calls/create");if(this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}try{this.appliedRemoteCandidates.clear(),this.stopRemoteIcePolling();const n=this.getIceServers();this.pc=new RTCPeerConnection({iceServers:n,iceTransportPolicy:"all"});let i;try{i=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:1}})}catch(d){if(d.name==="NotAllowedError"||d.name==="PermissionDeniedError"||(t=d.message)!=null&&t.includes("Permission denied")){const u=navigator.userAgent,h=/iPad|iPhone|iPod/.test(u)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;let p="Microphone access denied. Please allow microphone access in your browser settings.";h&&(u.includes("CriOS")?p="Microphone access blocked. Please enable it in iOS Settings > Chrome > Microphone, then reload the page.":u.includes("FxiOS")?p="Microphone access blocked. Please enable it in iOS Settings > Firefox > Microphone, then reload the page.":p="Microphone access blocked. Please enable it in iOS Settings > Safari > Microphone (or tap 'aA' > Website Settings > Allow Microphone).");const g=new Error(p);throw g.name=d.name,g}throw d}if(this.isConnectCancelled(e)){i.getTracks().forEach(d=>d.stop());return}if(this.localStream=i,!this.pc||this.isConnectCancelled(e)){i.getTracks().forEach(d=>d.stop());return}if(this.onLocalStream(i),i.getTracks().forEach(d=>{var u;(u=this.pc)==null||u.addTrack(d,i)}),!this.pc)throw new Error("RTCPeerConnection was closed unexpectedly");this.dataChannel=this.pc.createDataChannel("control"),this.dataChannel.onopen=()=>{var d;(d=this.routeTracker)==null||d.onChannelReady()},this.dataChannel.onmessage=d=>{if(typeof d.data=="string")try{this.handleControlEvent(JSON.parse(d.data))}catch{}else if(d.data instanceof ArrayBuffer)try{const u=new TextDecoder().decode(d.data);try{const h=JSON.parse(u);qp(h)&&this.handleControlEvent(h)}catch{}}catch{}else d.data instanceof Blob&&d.data.text().then(u=>{try{this.handleControlEvent(JSON.parse(u))}catch{}})},this.dataChannel.onerror=d=>{},this.mediaBytesChannel=this.pc.createDataChannel("media-bytes",{ordered:!0}),this.mediaBytesChannel.binaryType="arraybuffer",this.mediaBytesChannel.onopen=()=>{},this.mediaBytesChannel.onerror=d=>{},this.pc.ontrack=d=>{const u=d.track,h=d.streams[0];u.kind==="audio"?(this.audioElement=new Audio,this.audioElement.srcObject=h,this.audioElement.play().catch(p=>{}),this.audioElement.onended=()=>{this.sendEvent("playedStream"),typeof window<"u"&&window.dispatchEvent(new CustomEvent("vanira:agent-playback-ended"))},this.onRemoteTrack(u,h)):u.kind==="video"&&this.onRemoteTrack(u,h)};const s=()=>{var h,p,g,v,w,B,E,b,C,T,F;const d=((h=this.pc)==null?void 0:h.connectionState)==="connected"||((p=this.pc)==null?void 0:p.iceConnectionState)==="connected"||((g=this.pc)==null?void 0:g.iceConnectionState)==="completed",u=((v=this.pc)==null?void 0:v.connectionState)==="failed"||((w=this.pc)==null?void 0:w.iceConnectionState)==="failed"||((B=this.pc)==null?void 0:B.connectionState)==="closed"||((E=this.pc)==null?void 0:E.iceConnectionState)==="closed"||((b=this.pc)==null?void 0:b.connectionState)==="disconnected"||((C=this.pc)==null?void 0:C.iceConnectionState)==="disconnected";((T=this.pc)==null?void 0:T.connectionState)==="connected"&&this.stopRemoteIcePolling(),d&&!this.connected?(this.connected=!0,(F=this.routeTracker)==null||F.start(),this.onConnected()):u&&this.connected&&(this.connected=!1,this.liveVisionAutoStarted=!1,this.onDisconnected())};this.pc.onconnectionstatechange=s,this.pc.oniceconnectionstatechange=s;const a=this.getIceTrickleUrl();this.pc.onicecandidate=d=>{d.candidate&&fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidate:d.candidate.toJSON()})}).catch(u=>{})};const A=await this.pc.createOffer();if(this.isConnectCancelled(e)||(await this.pc.setLocalDescription(A),this.isConnectCancelled(e)))return;const o=this.serverUrl.includes("?")?this.serverUrl:`${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`,c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offer:this.pc.localDescription,agentId:this.agentId,callId:this.callId})});if(this.isConnectCancelled(e))return;if(!c.ok){const d=await c.json();throw new Error(d.error||`HTTP ${c.status}`)}const{answer:l}=await c.json();if(this.isConnectCancelled(e)||!this.pc||(await this.pc.setRemoteDescription(l),this.isConnectCancelled(e)))return;this.startRemoteIcePolling(a)}catch(n){if(this.isConnectCancelled(e))return;throw this.disconnect(),this.onError(n.message||n),n}}}createCallCacheKey(e,t){const n=this.apiKey?`key:${this.apiKey.slice(0,16)}`:`token:${(this.token||"").slice(-16)}`;return[this.backendUrl,this.agentId,e,t||"",this.prospectId||"",n].join("|")}async postCreateCall(e,t,n){var A,o,c;const i=await fetch(`${this.backendUrl}/calls/create`,{method:"POST",headers:e,body:JSON.stringify({agent_id:this.agentId,type:((A=this.runtime)==null?void 0:A.callType)||"web",mode:t,...(o=this.runtime)!=null&&o.runtimeName?{runtime:this.runtime.runtimeName}:{},prospect_id:this.prospectId,...n?{call_id:n}:{}})});if(!i.ok){const l=await i.json().catch(()=>({}));throw new Error(`[VaniraClient] createCall failed (${i.status}): ${((c=l==null?void 0:l.detail)==null?void 0:c.message)||(l==null?void 0:l.message)||i.statusText}`)}const s=await i.json();if(!s.call_id||!s.worker_url)throw new Error("[VaniraClient] /calls/create response missing call_id or worker_url");const a=dr.normalizeIceServers(s.ice_servers);if(!a.length)throw new Error("[VaniraClient] /calls/create response missing ice_servers");return{callId:s.call_id,prospectId:s.prospect_id||this.prospectId,serverUrl:s.worker_url.replace(/\/$/,""),iceServers:a}}applyCreateCallSession(e){if(this.callId=e.callId,this.prospectId=e.prospectId||this.prospectId,this.serverUrl=e.serverUrl,this.iceServers=e.iceServers,this.callSessionLoaded=!0,Gp(this.agentId,this.callId||"",this.prospectId),this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}}async loadCallSession(){if(this.callSessionLoaded)return;if(this.serverUrl&&this.callId){this.callSessionLoaded=!0;return}if(!this.apiKey&&!this.token)throw new Error("[VaniraClient] apiKey or token is required to create a call session");const e={"Content-Type":"application/json"};this.apiKey?e["X-API-Key"]=this.apiKey:this.token&&(e.Authorization=this.token.startsWith("Bearer ")?this.token:`Bearer ${this.token}`);const t=this.sessionBehavior==="continue"?this.callId:void 0,n=this.sessionBehavior==="continue"?"continue":"new",i=this.createCallCacheKey(n,t);let s=dr.inflightCreates.get(i);s||(s=this.postCreateCall(e,n,t),dr.inflightCreates.set(i,s),s.finally(()=>{dr.inflightCreates.get(i)===s&&dr.inflightCreates.delete(i)}));const a=await s;this.applyCreateCallSession(a)}getIceServers(){var e;if((e=this.iceServers)!=null&&e.length)return this.iceServers;throw new Error("[VaniraClient] ice_servers missing — pass iceServers from POST /calls/create")}static normalizeIceServers(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const i=n==null?void 0:n.urls,s=Array.isArray(i)?i.filter(Boolean):typeof i=="string"&&i.trim()?[i.trim()]:[];if(!s.length)continue;const a={urls:s.length===1?s[0]:s},A=n.username,o=n.credential;A&&(a.username=A),o&&(a.credential=o),t.push(a)}return t}getWorkerOrigin(){var e;if(!((e=this.serverUrl)!=null&&e.trim()))return"";try{return new URL(this.serverUrl).origin}catch{return this.serverUrl.replace(/\/webrtc.*$/,"").replace(/\/$/,"")}}getIceTrickleUrl(){try{const e=new URL(this.serverUrl);return e.pathname.endsWith("/webrtc")?e.pathname=`${e.pathname}/ice`:e.pathname="/webrtc/ice",e.toString()}catch{return`${this.getWorkerOrigin()}/webrtc/ice?agent_id=${this.agentId}&call_id=${this.callId}`}}startRemoteIcePolling(e){this.stopRemoteIcePolling(),this.icePollInterval=setInterval(async()=>{if(!this.pc){this.stopRemoteIcePolling();return}if(this.pc.connectionState==="connected"){this.stopRemoteIcePolling();return}try{const t=await fetch(e);if(!t.ok)return;const{candidates:n}=await t.json();for(const i of n||[]){const s=JSON.stringify(i);if(!this.appliedRemoteCandidates.has(s)){this.appliedRemoteCandidates.add(s);try{await this.pc.addIceCandidate(i)}catch{}}}}catch{}},150)}stopRemoteIcePolling(){this.icePollInterval!==null&&(clearInterval(this.icePollInterval),this.icePollInterval=null)}sendEvent(e,t={}){var n;if(((n=this.dataChannel)==null?void 0:n.readyState)==="open"){const i={event:e,...t};this.dataChannel.send(JSON.stringify(i))}}async sendEventWhenReady(e,t={},n=1e4){var s;const i=Date.now()+n;for(;Date.now()<i;){if(((s=this.dataChannel)==null?void 0:s.readyState)==="open")return this.sendEvent(e,t),!0;await new Promise(a=>setTimeout(a,50))}return!1}startLiveCamera(e={}){const t={...this.liveVision,...e};this.emit("tool_call",this.buildOpenLiveCameraToolCall(t))}buildOpenLiveCameraToolCall(e={}){const t=e.scope??"until_call_end";return{name:"open_live_camera",tool_call_id:`lv_${crypto.randomUUID()}`,execution_mode:"fire_and_forget",client_fields:{preset_id:_.LiveVision},arguments:{mode:"live",scope:t,target_fps:e.target_fps??1,max_fps:e.max_fps??3,max_width:e.max_width??640,reason:e.reason??"camera_capture",facing_mode:e.facing_mode??"environment",show_preview:e.show_preview??!0,...t==="timed"&&e.duration_sec?{duration_sec:e.duration_sec}:{}}}}maybeAutoStartLiveCamera(){const e=this.liveVision;!(e!=null&&e.enabled)||e.scope!=="full_call"||this.liveVisionAutoStarted||(this.liveVisionAutoStarted=!0,this.emit("tool_call",this.buildOpenLiveCameraToolCall(e)))}handleControlEvent(e){var t;switch(e.event){case"clearAudio":break;case"transcription":this.onTranscription(e.text,e.isFinal);break;case"mark":break;case"client_tool_cancel":{const i=(e.data||e).tool_call_id||e.tool_call_id;this.dispatchBoardAbort("Tool cancelled by server",i);break}case"client_tool_call":{const n=e.tool_call||e.data||e,i=(n==null?void 0:n.tool_call_id)||(n==null?void 0:n.call_id)||e.tool_call_id||"";i&&((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:i}}));const s=(n==null?void 0:n.arguments)||(n==null?void 0:n.args)||{},a=(n==null?void 0:n.client_fields)||{},A=(n==null?void 0:n.name)||(n==null?void 0:n.tool_name)||"",o=Gd(a,s,A);if(A==="end_call"){i&&this.sendToolResult(i,{status:"client_ack_end_call",message:"Ending call."}),window.setTimeout(()=>this.disconnect(),120);break}if(o){window.dispatchEvent(new CustomEvent("vanira:preset",{detail:{toolCall:n,client:this}})),this.onClientToolCall(n);break}this.onClientToolCall(n);break}}}disconnect(){var e;this.connectGeneration++,this.stopRemoteIcePolling(),this.appliedRemoteCandidates.clear(),this.audioElement&&(this.audioElement.pause(),this.audioElement.srcObject=null),this.dataChannel&&(this.dataChannel.close(),this.dataChannel=null),this.mediaBytesChannel&&(this.mediaBytesChannel.close(),this.mediaBytesChannel=null),this.pc&&(this.pc.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc.close(),this.pc=null),this.localStream&&(this.localStream.getTracks().forEach(t=>{try{t.stop()}catch{}}),this.localStream=null),this.connected=!1,(e=this.routeTracker)==null||e.stop(),this.callSessionLoaded=!1,this.sessionStartedEmitted=!1,this.serverUrl="",this.callId=void 0,this.micMuted=!1,this.iceServers=void 0,this.onDisconnected()}setMicrophoneMuted(e){var t,n;this.micMuted=e,(t=this.localStream)==null||t.getAudioTracks().forEach(i=>{i.enabled=!e}),(n=this.pc)==null||n.getSenders().forEach(i=>{var s;((s=i.track)==null?void 0:s.kind)==="audio"&&(i.track.enabled=!e)})}isMicrophoneMuted(){return this.micMuted}toggleMicrophoneMuted(){return this.setMicrophoneMuted(!this.micMuted),this.micMuted}isConnectCancelled(e){return e!==this.connectGeneration}dispatchBoardAbort(e,t){typeof window>"u"||window.dispatchEvent(new CustomEvent("vanira:board_abort",{detail:{reason:e,toolCallId:t}}))}sendToolResult(e,t){this.callId,this.sendEvent("client_tool_result",{call_id:this.callId,data:{tool_call_id:e,result:t},result:t})}sendToolAck(e){var t;((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:e}}))}sendContextUpdate(e){this.sendEvent("client_context_update",{data:{context:e}})}sendActionTrigger(e,t={}){this.sendEvent("client_action_trigger",{data:{action_name:e,data:t}})}triggerActionInterrupt(){this.sendEvent("action_interrupt")}sendMediaUpdate(e){if(!this.dataChannel||this.dataChannel.readyState!=="open")return!1;const t={event:"client_media_update",data:{media_id:e.media_id,media_url:e.media_url,content_type:e.content_type,reason:e.reason,message:e.message??""}};return this.dataChannel.send(JSON.stringify(t)),!0}async uploadMediaForToolResult(e,t="general"){return this._postMediaUpload(e,t)}async uploadMedia(e,t="general",n=""){return await ew(this.dataChannel,this.mediaBytesChannel)?this._uploadMediaViaDataChannel(e,t,n):(Zy(this.dataChannel,this.mediaBytesChannel),this._uploadMediaViaHTTP(e,t,n))}async uploadMediaFrame(e,t="camera_capture",n){const i=n&&!(e instanceof File)?new File([e],n,{type:e.type||"image/jpeg"}):e,{media_id:s,url:a,contentType:A}=await this._postMediaUpload(i,t,!0);if(!s||!a)throw new Error("Frame upload failed: server response missing media_id or url");return{media_id:s,url:a,content_type:A}}async _uploadBytesViaDataChannel(e,t,n,i,s){if(!this.callId||!this.mediaBytesChannel)throw new Error("Upload failed: call not ready for WebRTC media upload.");const a=s||(e instanceof File?e.name:i==="frame"?"frame.jpg":"upload.bin"),A=e.type||(i==="frame"?"image/jpeg":"application/octet-stream"),o=await nw(e);return tw({bytes:o,filename:a,contentType:A,reason:t,message:n,callId:this.callId,mediaBytesChannel:this.mediaBytesChannel,sendControlEvent:(c,l)=>this.sendEvent(c,l),uploadKind:i})}async _uploadMediaViaDataChannel(e,t,n){const i=await this._uploadBytesViaDataChannel(e,t,n,"media");return{media_id:i.media_id,url:i.url}}async _uploadMediaViaHTTP(e,t="general",n=""){const{media_id:i,url:s,contentType:a}=await this._postMediaUpload(e,t,!0);return this.sendMediaUpdate({media_id:i,media_url:s,content_type:a,reason:t,message:n}),{media_id:i,url:s}}async _postMediaUpload(e,t,n=!1){if(!this.serverUrl)throw new Error("Upload failed: serverUrl is not set. Connect the VaniraClient first.");if(!this.callId)throw new Error("Upload failed: callId is missing.");const i=this.getWorkerOrigin();if(!i)throw new Error("Upload failed: worker_url is not set. Connect the call before uploading media.");const s=`${i}/media/upload`,a=new FormData;a.append("file",e),a.append("call_id",this.callId),a.append("reason",t);const A=await fetch(s,{method:"POST",body:a});if(!A.ok){let u=`HTTP ${A.status}`;try{u=(await A.json()).error||u}catch{}throw new Error(`Upload failed: ${u}`)}const o=await A.json(),c=o.media_id,l=o.url,d=o.content_type||e.type;if(!c||!l)throw new Error("Upload failed: server response missing media_id or url");return n?{media_id:c,url:l,contentType:d}:{media_id:c,url:l,contentType:d}}get status(){return this._status}get isConnected(){return this._status==="connected"}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this}off(e,t){var n;return(n=this.listeners.get(e))==null||n.delete(t),this}emit(e,t){var n;(n=this.listeners.get(e))==null||n.forEach(i=>i(t))}async start(){return await this.connect(),{callId:this.callId||"",prospectId:this.prospectId||"",serverUrl:this.serverUrl||""}}stop(){this.disconnect(),this._status="disconnected"}sendToolError(e,t){this.sendToolResult(e,{status:"error",error:t})}updateContext(e){this.sendContextUpdate(e)}triggerInterrupt(e,t={}){this.triggerActionInterrupt(),this.sendActionTrigger(e,t)}interruptAudioOnly(){this.triggerActionInterrupt()}};L(dr,"inflightCreates",new Map);let NA=dr;function sw(r,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!=="default"&&!(n in r)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(r)}var aw=Object.defineProperty,Aw=(r,e,t)=>e in r?aw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c0=(r,e,t)=>Aw(r,typeof e!="symbol"?e+"":e,t);class xt{constructor(){c0(this,"_locking"),c0(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const t=new Promise(i=>e=()=>{this._locks-=1,i()}),n=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),n}}function tt(r,e){if(!r)throw new Error(e)}const ow=34028234663852886e22,cw=-34028234663852886e22,lw=4294967295,dw=2147483647,uw=-2147483648;function fA(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>dw||r<uw)throw new Error("invalid int 32: "+r)}function Il(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>lw||r<0)throw new Error("invalid uint 32: "+r)}function jp(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>ow||r<cw))throw new Error("invalid float 32: "+r)}const Xp=Symbol("@bufbuild/protobuf/enum-type");function hw(r){const e=r[Xp];return tt(e,"missing enum type on enum object"),e}function Jp(r,e,t,n){r[Xp]=Yp(e,t.map(i=>({no:i.no,name:i.name,localName:r[i.no]})))}function Yp(r,e,t){const n=Object.create(null),i=Object.create(null),s=[];for(const a of e){const A=Zp(a);s.push(A),n[a.name]=A,i[a.no]=A}return{typeName:r,values:s,findName(a){return n[a]},findNumber(a){return i[a]}}}function fw(r,e,t){const n={};for(const i of e){const s=Zp(i);n[s.localName]=s.no,n[s.no]=s.localName}return Jp(n,r,e),n}function Zp(r){return"localName"in r?r:Object.assign(Object.assign({},r),{localName:r.name})}class Wd{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType(),i=n.runtime.bin,s=i.makeReadOptions(t);return i.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const n=this.getType(),i=n.runtime.json,s=i.makeReadOptions(t);return i.readMessage(n,e,s,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(i){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(i instanceof Error?i.message:String(i)))}return this.fromJson(n,t)}toBinary(e){const t=this.getType(),n=t.runtime.bin,i=n.makeWriteOptions(e),s=i.writerFactory();return n.writeMessage(this,s,i),s.finish()}toJson(e){const t=this.getType(),n=t.runtime.json,i=n.makeWriteOptions(e);return n.writeMessage(this,i)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function pw(r,e,t,n){var i;const s=(i=n==null?void 0:n.localName)!==null&&i!==void 0?i:e.substring(e.lastIndexOf(".")+1),a={[s]:function(A){r.util.initFields(this),r.util.initPartial(A,this)}}[s];return Object.setPrototypeOf(a.prototype,new Wd),Object.assign(a,{runtime:r,typeName:e,fields:r.util.newFieldList(t),fromBinary(A,o){return new a().fromBinary(A,o)},fromJson(A,o){return new a().fromJson(A,o)},fromJsonString(A,o){return new a().fromJsonString(A,o)},equals(A,o){return r.util.equals(a,A,o)}}),a}function mw(){let r=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(r|=(i&127)<<n,!(i&128))return this.assertBounds(),[r,e]}let t=this.buf[this.pos++];if(r|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[r,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,!(i&128))return this.assertBounds(),[r,e]}throw new Error("invalid varint")}function fc(r,e,t){for(let s=0;s<28;s=s+7){const a=r>>>s,A=!(!(a>>>7)&&e==0),o=(A?a|128:a)&255;if(t.push(o),!A)return}const n=r>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?n|128:n)&255),!!i){for(let s=3;s<31;s=s+7){const a=e>>>s,A=!!(a>>>7),o=(A?a|128:a)&255;if(t.push(o),!A)return}t.push(e>>>31&1)}}const pA=4294967296;function l0(r){const e=r[0]==="-";e&&(r=r.slice(1));const t=1e6;let n=0,i=0;function s(a,A){const o=Number(r.slice(a,A));i*=t,n=n*t+o,n>=pA&&(i=i+(n/pA|0),n=n%pA)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?tm(n,i):$d(n,i)}function gw(r,e){let t=$d(r,e);const n=t.hi&2147483648;n&&(t=tm(t.lo,t.hi));const i=em(t.lo,t.hi);return n?"-"+i:i}function em(r,e){var t=vw(r,e);if(r=t.lo,e=t.hi,e<=2097151)return String(pA*e+r);const n=r&16777215,i=(r>>>24|e<<8)&16777215,s=e>>16&65535;let a=n+i*6777216+s*6710656,A=i+s*8147497,o=s*2;const c=1e7;return a>=c&&(A+=Math.floor(a/c),a%=c),A>=c&&(o+=Math.floor(A/c),A%=c),o.toString()+d0(A)+d0(a)}function vw(r,e){return{lo:r>>>0,hi:e>>>0}}function $d(r,e){return{lo:r|0,hi:e|0}}function tm(r,e){return e=~e,r?r=~r+1:e+=1,$d(r,e)}const d0=r=>{const e=String(r);return"0000000".slice(e.length)+e};function u0(r,e){if(r>=0){for(;r>127;)e.push(r&127|128),r=r>>>7;e.push(r)}else{for(let t=0;t<9;t++)e.push(r&127|128),r=r>>7;e.push(1)}}function yw(){let r=this.buf[this.pos++],e=r&127;if(!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<7,!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<14,!(r&128))return this.assertBounds(),e;if(r=this.buf[this.pos++],e|=(r&127)<<21,!(r&128))return this.assertBounds(),e;r=this.buf[this.pos++],e|=(r&15)<<28;for(let t=5;r&128&&t<10;t++)r=this.buf[this.pos++];if(r&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function ww(){const r=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof r.getBigInt64=="function"&&typeof r.getBigUint64=="function"&&typeof r.setBigInt64=="function"&&typeof r.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),a=BigInt("0"),A=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(o){const c=typeof o=="bigint"?o:BigInt(o);if(c>s||c<i)throw new Error("int64 invalid: ".concat(o));return c},uParse(o){const c=typeof o=="bigint"?o:BigInt(o);if(c>A||c<a)throw new Error("uint64 invalid: ".concat(o));return c},enc(o){return r.setBigInt64(0,this.parse(o),!0),{lo:r.getInt32(0,!0),hi:r.getInt32(4,!0)}},uEnc(o){return r.setBigInt64(0,this.uParse(o),!0),{lo:r.getInt32(0,!0),hi:r.getInt32(4,!0)}},dec(o,c){return r.setInt32(0,o,!0),r.setInt32(4,c,!0),r.getBigInt64(0,!0)},uDec(o,c){return r.setInt32(0,o,!0),r.setInt32(4,c,!0),r.getBigUint64(0,!0)}}}const t=i=>tt(/^-?[0-9]+$/.test(i),"int64 invalid: ".concat(i)),n=i=>tt(/^[0-9]+$/.test(i),"uint64 invalid: ".concat(i));return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),t(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),n(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),t(i),l0(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),n(i),l0(i)},dec(i,s){return gw(i,s)},uDec(i,s){return em(i,s)}}}const Ke=ww();var K;(function(r){r[r.DOUBLE=1]="DOUBLE",r[r.FLOAT=2]="FLOAT",r[r.INT64=3]="INT64",r[r.UINT64=4]="UINT64",r[r.INT32=5]="INT32",r[r.FIXED64=6]="FIXED64",r[r.FIXED32=7]="FIXED32",r[r.BOOL=8]="BOOL",r[r.STRING=9]="STRING",r[r.BYTES=12]="BYTES",r[r.UINT32=13]="UINT32",r[r.SFIXED32=15]="SFIXED32",r[r.SFIXED64=16]="SFIXED64",r[r.SINT32=17]="SINT32",r[r.SINT64=18]="SINT64"})(K||(K={}));var Gr;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING"})(Gr||(Gr={}));function xr(r,e,t){if(e===t)return!0;if(r==K.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}switch(r){case K.UINT64:case K.FIXED64:case K.INT64:case K.SFIXED64:case K.SINT64:return e==t}return!1}function rs(r,e){switch(r){case K.BOOL:return!1;case K.UINT64:case K.FIXED64:case K.INT64:case K.SFIXED64:case K.SINT64:return e==0?Ke.zero:"0";case K.DOUBLE:case K.FLOAT:return 0;case K.BYTES:return new Uint8Array(0);case K.STRING:return"";default:return 0}}function nm(r,e){switch(r){case K.BOOL:return e===!1;case K.STRING:return e==="";case K.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}function h0(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function bw(r){if(Array.isArray(r))return r}function Be(r,e,t){return(e=kw(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Bw(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,i,s,a,A=[],o=!0,c=!1;try{if(s=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;o=!1}else for(;!(o=(n=s.call(t)).done)&&(A.push(n.value),A.length!==e);o=!0);}catch(l){c=!0,i=l}finally{try{if(!o&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw i}}return A}}function Cw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ae(r,e){return bw(r)||Bw(r,e)||Tw(r,e)||Cw()}function Sw(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function kw(r){var e=Sw(r,"string");return typeof e=="symbol"?e:e+""}function Tw(r,e){if(r){if(typeof r=="string")return h0(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h0(r,e):void 0}}var at;(function(r){r[r.Varint=0]="Varint",r[r.Bit64=1]="Bit64",r[r.LengthDelimited=2]="LengthDelimited",r[r.StartGroup=3]="StartGroup",r[r.EndGroup=4]="EndGroup",r[r.Bit32=5]="Bit32"})(at||(at={}));class xw{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let t=new Uint8Array(e),n=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Il(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return fA(e),u0(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){jp(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Il(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){fA(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return fA(e),e=(e<<1^e>>31)>>>0,u0(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=Ke.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=Ke.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=Ke.enc(e);return fc(t.lo,t.hi,this.buf),this}sint64(e){let t=Ke.enc(e),n=t.hi>>31,i=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return fc(i,s,this.buf),this}uint64(e){let t=Ke.uEnc(e);return fc(t.lo,t.hi,this.buf),this}}class Ew{constructor(e,t){this.varint64=mw,this.uint32=yw,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case at.Varint:for(;this.buf[this.pos++]&128;);break;case at.Bit64:this.pos+=4;case at.Bit32:this.pos+=4;break;case at.LengthDelimited:let i=this.uint32();this.pos+=i;break;case at.StartGroup:for(;;){const s=this.tag(),a=Ae(s,2),A=a[0],o=a[1];if(o===at.EndGroup){if(t!==void 0&&A!==t)throw new Error("invalid end group tag");break}this.skip(o,A)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return Ke.dec(...this.varint64())}uint64(){return Ke.uDec(...this.varint64())}sint64(){let e=this.varint64(),t=Ae(e,2),n=t[0],i=t[1],s=-(n&1);return n=(n>>>1|(i&1)<<31)^s,i=i>>>1^s,Ke.dec(n,i)}bool(){let e=this.varint64(),t=Ae(e,2),n=t[0],i=t[1];return n!==0||i!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Ke.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Ke.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function Uw(r,e,t,n){let i;return{typeName:e,extendee:t,get field(){if(!i){const s=typeof n=="function"?n():n;s.name=e.split(".").pop(),s.jsonName="[".concat(e,"]"),i=r.util.newFieldList([s]).list()[0]}return i},runtime:r}}function rm(r){const e=r.field.localName,t=Object.create(null);return t[e]=Fw(r),[t,()=>t[e]]}function Fw(r){const e=r.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return rs(e.T,e.L);case"message":const t=e.T,n=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}function Iw(r,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=r.length-1;t>=0;--t)if(r[t].no==e.no)return[r[t]];return[]}return r.filter(t=>t.no===e.no)}let fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Co=[];for(let r=0;r<fr.length;r++)Co[fr[r].charCodeAt(0)]=r;Co[45]=fr.indexOf("+");Co[95]=fr.indexOf("/");const im={dec(r){let e=r.length*3/4;r[r.length-2]=="="?e-=2:r[r.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,i=0,s,a=0;for(let A=0;A<r.length;A++){if(s=Co[r.charCodeAt(A)],s===void 0)switch(r[A]){case"=":i=0;case`
|
|
3
|
+
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:a=s,i=1;break;case 1:t[n++]=a<<2|(s&48)>>4,a=s,i=2;break;case 2:t[n++]=(a&15)<<4|(s&60)>>2,a=s,i=3;break;case 3:t[n++]=(a&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,n)},enc(r){let e="",t=0,n,i=0;for(let s=0;s<r.length;s++)switch(n=r[s],t){case 0:e+=fr[n>>2],i=(n&3)<<4,t=1;break;case 1:e+=fr[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=fr[i|n>>6],e+=fr[n&63],t=0;break}return t&&(e+=fr[i],e+="=",t==1&&(e+="=")),e}};function Qw(r,e,t){am(e,r);const n=e.runtime.bin.makeReadOptions(t),i=Iw(r.getType().runtime.bin.listUnknownFields(r),e.field),s=rm(e),a=Ae(s,2),A=a[0],o=a[1];for(const c of i)e.runtime.bin.readField(A,n.readerFactory(c.data),e.field,c.wireType,n);return o()}function Mw(r,e,t,n){am(e,r);const i=e.runtime.bin.makeReadOptions(n),s=e.runtime.bin.makeWriteOptions(n);if(sm(r,e)){const c=r.getType().runtime.bin.listUnknownFields(r).filter(l=>l.no!=e.field.no);r.getType().runtime.bin.discardUnknownFields(r);for(const l of c)r.getType().runtime.bin.onUnknownField(r,l.no,l.wireType,l.data)}const a=s.writerFactory();let A=e.field;!A.opt&&!A.repeated&&(A.kind=="enum"||A.kind=="scalar")&&(A=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(A,t,a,s);const o=i.readerFactory(a.finish());for(;o.pos<o.len;){const c=o.tag(),l=Ae(c,2),d=l[0],u=l[1],h=o.skip(u,d);r.getType().runtime.bin.onUnknownField(r,d,u,h)}}function sm(r,e){const t=r.getType();return e.extendee.typeName===t.typeName&&!!t.runtime.bin.listUnknownFields(r).find(n=>n.no==e.field.no)}function am(r,e){tt(r.extendee.typeName==e.getType().typeName,"extension ".concat(r.typeName," can only be applied to message ").concat(r.extendee.typeName))}function Am(r,e){const t=r.localName;if(r.repeated)return e[t].length>0;if(r.oneof)return e[r.oneof.localName].case===t;switch(r.kind){case"enum":case"scalar":return r.opt||r.req?e[t]!==void 0:r.kind=="enum"?e[t]!==r.T.values[0].no:!nm(r.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function f0(r,e){const t=r.localName,n=!r.opt&&!r.req;if(r.repeated)e[t]=[];else if(r.oneof)e[r.oneof.localName]={case:void 0};else switch(r.kind){case"map":e[t]={};break;case"enum":e[t]=n?r.T.values[0].no:void 0;break;case"scalar":e[t]=n?rs(r.T,r.L):void 0;break;case"message":e[t]=void 0;break}}function pr(r,e){if(r===null||typeof r!="object"||!Object.getOwnPropertyNames(Wd.prototype).every(n=>n in r&&typeof r[n]=="function"))return!1;const t=r.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function om(r,e){return pr(e)||!r.fieldWrapper?e:r.fieldWrapper.wrapField(e)}K.DOUBLE,K.FLOAT,K.INT64,K.UINT64,K.INT32,K.UINT32,K.BOOL,K.STRING,K.BYTES;const p0={ignoreUnknownFields:!1},m0={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function _w(r){return r?Object.assign(Object.assign({},p0),r):p0}function Rw(r){return r?Object.assign(Object.assign({},m0),r):m0}const KA=Symbol(),mA=Symbol();function Pw(){return{makeReadOptions:_w,makeWriteOptions:Rw,readMessage(r,e,t,n){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(r.typeName," from JSON: ").concat(Vn(e)));n=n??new r;const i=new Map,s=t.typeRegistry;for(const A of Object.entries(e)){var a=Ae(A,2);const o=a[0],c=a[1],l=r.fields.findJsonName(o);if(l){if(l.oneof){if(c===null&&l.kind=="scalar")continue;const d=i.get(l.oneof);if(d!==void 0)throw new Error("cannot decode message ".concat(r.typeName,' from JSON: multiple keys for oneof "').concat(l.oneof.name,'" present: "').concat(d,'", "').concat(o,'"'));i.set(l.oneof,o)}g0(n,c,l,t,r)}else{let d=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const u=s.findExtension(o.substring(1,o.length-1));if(u&&u.extendee.typeName==r.typeName){d=!0;const h=rm(u),p=Ae(h,2),g=p[0],v=p[1];g0(g,c,u.field,t,u),Mw(n,u,v(),t)}}if(!d&&!t.ignoreUnknownFields)throw new Error("cannot decode message ".concat(r.typeName,' from JSON: key "').concat(o,'" is unknown'))}}return n},writeMessage(r,e){const t=r.getType(),n={};let i;try{for(i of t.fields.byNumber()){if(!Am(i,r)){if(i.req)throw"required field not set";if(!e.emitDefaultValues||!Lw(i))continue}const a=i.oneof?r[i.oneof.localName].value:r[i.localName],A=v0(i,a,e);A!==void 0&&(n[e.useProtoFieldName?i.name:i.jsonName]=A)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const a of t.runtime.bin.listUnknownFields(r)){const A=s.findExtensionFor(t.typeName,a.no);if(A&&sm(r,A)){const o=Qw(r,A,e),c=v0(A.field,o,e);c!==void 0&&(n[A.field.jsonName]=c)}}}catch(s){const a=i?"cannot encode field ".concat(t.typeName,".").concat(i.name," to JSON"):"cannot encode message ".concat(t.typeName," to JSON"),A=s instanceof Error?s.message:String(s);throw new Error(a+(A.length>0?": ".concat(A):""))}return n},readScalar(r,e,t){return Gs(r,e,t??Gr.BIGINT,!0)},writeScalar(r,e,t){if(e!==void 0&&(t||nm(r,e)))return gA(r,e)},debug:Vn}}function Vn(r){if(r===null)return"null";switch(typeof r){case"object":return Array.isArray(r)?"array":"object";case"string":return r.length>100?"string":'"'.concat(r.split('"').join('\\"'),'"');default:return String(r)}}function g0(r,e,t,n,i){let s=t.localName;if(t.repeated){if(tt(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error("cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Vn(e)));const A=r[s];for(const o of e){if(o===null)throw new Error("cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Vn(o)));switch(t.kind){case"message":A.push(t.T.fromJson(o,n));break;case"enum":const c=pc(t.T,o,n.ignoreUnknownFields,!0);c!==mA&&A.push(c);break;case"scalar":try{A.push(Gs(t.T,o,t.L,!0))}catch(l){let d="cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Vn(o));throw l instanceof Error&&l.message.length>0&&(d+=": ".concat(l.message)),new Error(d)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error("cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Vn(e)));const A=r[s];for(const o of Object.entries(e)){var a=Ae(o,2);const c=a[0],l=a[1];if(l===null)throw new Error("cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: map value null"));let d;try{d=Dw(t.K,c)}catch(u){let h="cannot decode map key for field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Vn(e));throw u instanceof Error&&u.message.length>0&&(h+=": ".concat(u.message)),new Error(h)}switch(t.V.kind){case"message":A[d]=t.V.T.fromJson(l,n);break;case"enum":const u=pc(t.V.T,l,n.ignoreUnknownFields,!0);u!==mA&&(A[d]=u);break;case"scalar":try{A[d]=Gs(t.V.T,l,Gr.BIGINT,!0)}catch(h){let p="cannot decode map value for field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Vn(e));throw h instanceof Error&&h.message.length>0&&(p+=": ".concat(h.message)),new Error(p)}break}}}else switch(t.oneof&&(r=r[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const A=t.T;if(e===null&&A.typeName!="google.protobuf.Value")return;let o=r[s];pr(o)?o.fromJson(e,n):(r[s]=o=A.fromJson(e,n),A.fieldWrapper&&!t.oneof&&(r[s]=A.fieldWrapper.unwrapField(o)));break;case"enum":const c=pc(t.T,e,n.ignoreUnknownFields,!1);switch(c){case KA:f0(t,r);break;case mA:break;default:r[s]=c;break}break;case"scalar":try{const l=Gs(t.T,e,t.L,!1);switch(l){case KA:f0(t,r);break;default:r[s]=l;break}}catch(l){let d="cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Vn(e));throw l instanceof Error&&l.message.length>0&&(d+=": ".concat(l.message)),new Error(d)}break}}function Dw(r,e){if(r===K.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Gs(r,e,Gr.BIGINT,!0).toString()}function Gs(r,e,t,n){if(e===null)return n?rs(r,t):KA;switch(r){case K.DOUBLE:case K.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const i=Number(e);if(Number.isNaN(i)||!Number.isFinite(i))break;return r==K.FLOAT&&jp(i),i;case K.INT32:case K.FIXED32:case K.SFIXED32:case K.SINT32:case K.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return r==K.UINT32||r==K.FIXED32?Il(s):fA(s),s;case K.INT64:case K.SFIXED64:case K.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=Ke.parse(e);return t?a.toString():a;case K.FIXED64:case K.UINT64:if(typeof e!="number"&&typeof e!="string")break;const A=Ke.uParse(e);return t?A.toString():A;case K.BOOL:if(typeof e!="boolean")break;return e;case K.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case K.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return im.dec(e)}throw new Error}function pc(r,e,t,n){if(e===null)return r.typeName=="google.protobuf.NullValue"?0:n?r.values[0].no:KA;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const i=r.findName(e);if(i!==void 0)return i.no;if(t)return mA;break}throw new Error("cannot decode enum ".concat(r.typeName," from JSON: ").concat(Vn(e)))}function Lw(r){return r.repeated||r.kind=="map"?!0:!(r.oneof||r.kind=="message"||r.opt||r.req)}function v0(r,e,t){if(r.kind=="map"){tt(typeof e=="object"&&e!=null);const a={},A=Object.entries(e);switch(r.V.kind){case"scalar":for(const c of A){var n=Ae(c,2);const l=n[0],d=n[1];a[l.toString()]=gA(r.V.T,d)}break;case"message":for(const c of A){var i=Ae(c,2);const l=i[0],d=i[1];a[l.toString()]=d.toJson(t)}break;case"enum":const o=r.V.T;for(const c of A){var s=Ae(c,2);const l=s[0],d=s[1];a[l.toString()]=mc(o,d,t.enumAsInteger)}break}return t.emitDefaultValues||A.length>0?a:void 0}if(r.repeated){tt(Array.isArray(e));const a=[];switch(r.kind){case"scalar":for(let A=0;A<e.length;A++)a.push(gA(r.T,e[A]));break;case"enum":for(let A=0;A<e.length;A++)a.push(mc(r.T,e[A],t.enumAsInteger));break;case"message":for(let A=0;A<e.length;A++)a.push(e[A].toJson(t));break}return t.emitDefaultValues||a.length>0?a:void 0}switch(r.kind){case"scalar":return gA(r.T,e);case"enum":return mc(r.T,e,t.enumAsInteger);case"message":return om(r.T,e).toJson(t)}}function mc(r,e,t){var n;if(tt(typeof e=="number"),r.typeName=="google.protobuf.NullValue")return null;if(t)return e;const i=r.findNumber(e);return(n=i==null?void 0:i.name)!==null&&n!==void 0?n:e}function gA(r,e){switch(r){case K.INT32:case K.SFIXED32:case K.SINT32:case K.FIXED32:case K.UINT32:return tt(typeof e=="number"),e;case K.FLOAT:case K.DOUBLE:return tt(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case K.STRING:return tt(typeof e=="string"),e;case K.BOOL:return tt(typeof e=="boolean"),e;case K.UINT64:case K.FIXED64:case K.INT64:case K.SFIXED64:case K.SINT64:return tt(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case K.BYTES:return tt(e instanceof Uint8Array),im.enc(e)}}const Ii=Symbol("@bufbuild/protobuf/unknown-fields"),y0={readUnknownFields:!0,readerFactory:r=>new Ew(r)},w0={writeUnknownFields:!0,writerFactory:()=>new xw};function Ow(r){return r?Object.assign(Object.assign({},y0),r):y0}function Hw(r){return r?Object.assign(Object.assign({},w0),r):w0}function Nw(){return{makeReadOptions:Ow,makeWriteOptions:Hw,listUnknownFields(r){var e;return(e=r[Ii])!==null&&e!==void 0?e:[]},discardUnknownFields(r){delete r[Ii]},writeUnknownFields(r,e){const n=r[Ii];if(n)for(const i of n)e.tag(i.no,i.wireType).raw(i.data)},onUnknownField(r,e,t,n){const i=r;Array.isArray(i[Ii])||(i[Ii]=[]),i[Ii].push({no:e,wireType:t,data:n})},readMessage(r,e,t,n,i){const s=r.getType(),a=i?e.len:e.pos+t;let A,o;for(;e.pos<a;){var c=e.tag(),l=Ae(c,2);if(A=l[0],o=l[1],i===!0&&o==at.EndGroup)break;const d=s.fields.find(A);if(!d){const u=e.skip(o,A);n.readUnknownFields&&this.onUnknownField(r,A,o,u);continue}b0(r,e,d,o,n)}if(i&&(o!=at.EndGroup||A!==t))throw new Error("invalid end group tag")},readField:b0,writeMessage(r,e,t){const n=r.getType();for(const i of n.fields.byNumber()){if(!Am(i,r)){if(i.req)throw new Error("cannot encode field ".concat(n.typeName,".").concat(i.name," to binary: required field not set"));continue}const s=i.oneof?r[i.oneof.localName].value:r[i.localName];B0(i,s,e,t)}return t.writeUnknownFields&&this.writeUnknownFields(r,e),e},writeField(r,e,t,n){e!==void 0&&B0(r,e,t,n)}}}function b0(r,e,t,n,i){let s=t.repeated,a=t.localName;switch(t.oneof&&(r=r[t.oneof.localName],r.case!=a&&delete r.value,r.case=a,a="value"),t.kind){case"scalar":case"enum":const A=t.kind=="enum"?K.INT32:t.T;let o=VA;if(t.kind=="scalar"&&t.L>0&&(o=Vw),s){let p=r[a];if(n==at.LengthDelimited&&A!=K.STRING&&A!=K.BYTES){let v=e.uint32()+e.pos;for(;e.pos<v;)p.push(o(e,A))}else p.push(o(e,A))}else r[a]=o(e,A);break;case"message":const c=t.T;s?r[a].push(vA(e,new c,i,t)):pr(r[a])?vA(e,r[a],i,t):(r[a]=vA(e,new c,i,t),c.fieldWrapper&&!t.oneof&&!t.repeated&&(r[a]=c.fieldWrapper.unwrapField(r[a])));break;case"map":let l=Kw(t,e,i),d=Ae(l,2),u=d[0],h=d[1];r[a][u]=h;break}}function vA(r,e,t,n){const i=e.getType().runtime.bin,s=n==null?void 0:n.delimited;return i.readMessage(e,r,s?n.no:r.uint32(),t,s),e}function Kw(r,e,t){const n=e.uint32(),i=e.pos+n;let s,a;for(;e.pos<i;){const A=e.tag();switch(Ae(A,1)[0]){case 1:s=VA(e,r.K);break;case 2:switch(r.V.kind){case"scalar":a=VA(e,r.V.T);break;case"enum":a=e.int32();break;case"message":a=vA(e,new r.V.T,t,void 0);break}break}}if(s===void 0&&(s=rs(r.K,Gr.BIGINT)),typeof s!="string"&&typeof s!="number"&&(s=s.toString()),a===void 0)switch(r.V.kind){case"scalar":a=rs(r.V.T,Gr.BIGINT);break;case"enum":a=r.V.T.values[0].no;break;case"message":a=new r.V.T;break}return[s,a]}function Vw(r,e){const t=VA(r,e);return typeof t=="bigint"?t.toString():t}function VA(r,e){switch(e){case K.STRING:return r.string();case K.BOOL:return r.bool();case K.DOUBLE:return r.double();case K.FLOAT:return r.float();case K.INT32:return r.int32();case K.INT64:return r.int64();case K.UINT64:return r.uint64();case K.FIXED64:return r.fixed64();case K.BYTES:return r.bytes();case K.FIXED32:return r.fixed32();case K.SFIXED32:return r.sfixed32();case K.SFIXED64:return r.sfixed64();case K.SINT64:return r.sint64();case K.UINT32:return r.uint32();case K.SINT32:return r.sint32()}}function B0(r,e,t,n){tt(e!==void 0);const i=r.repeated;switch(r.kind){case"scalar":case"enum":let a=r.kind=="enum"?K.INT32:r.T;if(i)if(tt(Array.isArray(e)),r.packed)Gw(t,a,r.no,e);else for(const A of e)qs(t,a,r.no,A);else qs(t,a,r.no,e);break;case"message":if(i){tt(Array.isArray(e));for(const A of e)C0(t,n,r,A)}else C0(t,n,r,e);break;case"map":tt(typeof e=="object"&&e!=null);for(const A of Object.entries(e)){var s=Ae(A,2);const o=s[0],c=s[1];zw(t,n,r,o,c)}break}}function zw(r,e,t,n,i){r.tag(t.no,at.LengthDelimited),r.fork();let s=n;switch(t.K){case K.INT32:case K.FIXED32:case K.UINT32:case K.SFIXED32:case K.SINT32:s=Number.parseInt(n);break;case K.BOOL:tt(n=="true"||n=="false"),s=n=="true";break}switch(qs(r,t.K,1,s),t.V.kind){case"scalar":qs(r,t.V.T,2,i);break;case"enum":qs(r,K.INT32,2,i);break;case"message":tt(i!==void 0),r.tag(2,at.LengthDelimited).bytes(i.toBinary(e));break}r.join()}function C0(r,e,t,n){const i=om(t.T,n);t.delimited?r.tag(t.no,at.StartGroup).raw(i.toBinary(e)).tag(t.no,at.EndGroup):r.tag(t.no,at.LengthDelimited).bytes(i.toBinary(e))}function qs(r,e,t,n){tt(n!==void 0);let i=cm(e),s=Ae(i,2),a=s[0],A=s[1];r.tag(t,a)[A](n)}function Gw(r,e,t,n){if(!n.length)return;r.tag(t,at.LengthDelimited).fork();let i=cm(e),s=Ae(i,2),a=s[1];for(let A=0;A<n.length;A++)r[a](n[A]);r.join()}function cm(r){let e=at.Varint;switch(r){case K.BYTES:case K.STRING:e=at.LengthDelimited;break;case K.DOUBLE:case K.FIXED64:case K.SFIXED64:e=at.Bit64;break;case K.FIXED32:case K.SFIXED32:case K.FLOAT:e=at.Bit32;break}const t=K[r].toLowerCase();return[e,t]}function qw(){return{setEnumType:Jp,initPartial(r,e){if(r===void 0)return;const t=e.getType();for(const i of t.fields.byMember()){const s=i.localName,a=e,A=r;if(A[s]!=null)switch(i.kind){case"oneof":const o=A[s].case;if(o===void 0)continue;const c=i.findField(o);let l=A[s].value;c&&c.kind=="message"&&!pr(l,c.T)?l=new c.T(l):c&&c.kind==="scalar"&&c.T===K.BYTES&&(l=ys(l)),a[s]={case:o,value:l};break;case"scalar":case"enum":let d=A[s];i.T===K.BYTES&&(d=i.repeated?d.map(ys):ys(d)),a[s]=d;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===K.BYTES)for(const p of Object.entries(A[s])){var n=Ae(p,2);const g=n[0],v=n[1];a[s][g]=ys(v)}else Object.assign(a[s],A[s]);break;case"message":const h=i.V.T;for(const p of Object.keys(A[s])){let g=A[s][p];h.fieldWrapper||(g=new h(g)),a[s][p]=g}break}break;case"message":const u=i.T;if(i.repeated)a[s]=A[s].map(h=>pr(h,u)?h:new u(h));else{const h=A[s];u.fieldWrapper?u.typeName==="google.protobuf.BytesValue"?a[s]=ys(h):a[s]=h:a[s]=pr(h,u)?h:new u(h)}break}}},equals(r,e,t){return e===t?!0:!e||!t?!1:r.fields.byMember().every(n=>{const i=e[n.localName],s=t[n.localName];if(n.repeated){if(i.length!==s.length)return!1;switch(n.kind){case"message":return i.every((a,A)=>n.T.equals(a,s[A]));case"scalar":return i.every((a,A)=>xr(n.T,a,s[A]));case"enum":return i.every((a,A)=>xr(K.INT32,a,s[A]))}throw new Error("repeated cannot contain ".concat(n.kind))}switch(n.kind){case"message":let a=i,A=s;return n.T.fieldWrapper&&(a!==void 0&&!pr(a)&&(a=n.T.fieldWrapper.wrapField(a)),A!==void 0&&!pr(A)&&(A=n.T.fieldWrapper.wrapField(A))),n.T.equals(a,A);case"enum":return xr(K.INT32,i,s);case"scalar":return xr(n.T,i,s);case"oneof":if(i.case!==s.case)return!1;const o=n.findField(i.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(i.value,s.value);case"enum":return xr(K.INT32,i.value,s.value);case"scalar":return xr(o.T,i.value,s.value)}throw new Error("oneof cannot contain ".concat(o.kind));case"map":const c=Object.keys(i).concat(Object.keys(s));switch(n.V.kind){case"message":const l=n.V.T;return c.every(u=>l.equals(i[u],s[u]));case"enum":return c.every(u=>xr(K.INT32,i[u],s[u]));case"scalar":const d=n.V.T;return c.every(u=>xr(d,i[u],s[u]))}break}})},clone(r){const e=r.getType(),t=new e,n=t;for(const s of e.fields.byMember()){const a=r[s.localName];let A;if(s.repeated)A=a.map(Qa);else if(s.kind=="map"){A=n[s.localName];for(const o of Object.entries(a)){var i=Ae(o,2);const c=i[0],l=i[1];A[c]=Qa(l)}}else s.kind=="oneof"?A=s.findField(a.case)?{case:a.case,value:Qa(a.value)}:{case:void 0}:A=Qa(a);n[s.localName]=A}for(const s of e.runtime.bin.listUnknownFields(r))e.runtime.bin.onUnknownField(n,s.no,s.wireType,s.data);return t}}}function Qa(r){if(r===void 0)return r;if(pr(r))return r.clone();if(r instanceof Uint8Array){const e=new Uint8Array(r.byteLength);return e.set(r),e}return r}function ys(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function Ww(r,e,t){return{syntax:r,json:Pw(),bin:Nw(),util:Object.assign(Object.assign({},qw()),{newFieldList:e,initFields:t}),makeMessageType(n,i,s){return pw(this,n,i,s)},makeEnum:fw,makeEnumType:Yp,getEnumType:hw,makeExtension(n,i,s){return Uw(this,n,i,s)}}}class $w{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const n of this.list())t[n.jsonName]=t[n.name]=n;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const n of this.list())t[n.no]=n;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function lm(r,e){const t=dm(r);return e?t:eb(Zw(t))}function jw(r){return lm(r,!1)}const Xw=dm;function dm(r){let e=!1;const t=[];for(let n=0;n<r.length;n++){let i=r.charAt(n);switch(i){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.push(i),e=!1;break;default:e&&(e=!1,i=i.toUpperCase()),t.push(i);break}}return t.join("")}const Jw=new Set(["constructor","toString","toJSON","valueOf"]),Yw=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),um=r=>"".concat(r,"$"),Zw=r=>Yw.has(r)?um(r):r,eb=r=>Jw.has(r)?um(r):r;class tb{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=jw(e)}addField(e){tt(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;t<this.fields.length;t++)this._lookup[this.fields[t].localName]=this.fields[t]}return this._lookup[e]}}function nb(r,e){var t,n,i,s,a,A;const o=[];let c;for(const l of typeof r=="function"?r():r){const d=l;if(d.localName=lm(l.name,l.oneof!==void 0),d.jsonName=(t=l.jsonName)!==null&&t!==void 0?t:Xw(l.name),d.repeated=(n=l.repeated)!==null&&n!==void 0?n:!1,l.kind=="scalar"&&(d.L=(i=l.L)!==null&&i!==void 0?i:Gr.BIGINT),d.delimited=(s=l.delimited)!==null&&s!==void 0?s:!1,d.req=(a=l.req)!==null&&a!==void 0?a:!1,d.opt=(A=l.opt)!==null&&A!==void 0?A:!1,l.packed===void 0&&(d.packed=l.kind=="enum"||l.kind=="scalar"&&l.T!=K.BYTES&&l.T!=K.STRING),l.oneof!==void 0){const u=typeof l.oneof=="string"?l.oneof:l.oneof.name;(!c||c.name!=u)&&(c=new tb(u)),d.oneof=c,c.addField(d)}o.push(d)}return o}const Q=Ww("proto3",r=>new $w(r,e=>nb(e)),r=>{for(const e of r.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,n=r;if(e.repeated){n[t]=[];continue}switch(e.kind){case"oneof":n[t]={case:void 0};break;case"enum":n[t]=0;break;case"map":n[t]={};break;case"scalar":n[t]=rs(e.T,e.L);break}}});class Wt extends Wd{constructor(e){super(),this.seconds=Ke.zero,this.nanos=0,Q.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(Q.json.debug(e)));const n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=Ke.parse(i/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(t<Date.parse("0001-01-01T00:00:00Z")||t>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let n="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?n="."+i.substring(0,3)+"Z":i.substring(6)==="000"?n="."+i.substring(0,6)+"Z":n="."+i+"Z"}return new Date(t).toISOString().replace(".000Z",n)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Wt.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Wt({seconds:Ke.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Wt().fromBinary(e,t)}static fromJson(e,t){return new Wt().fromJson(e,t)}static fromJsonString(e,t){return new Wt().fromJsonString(e,t)}static equals(e,t){return Q.util.equals(Wt,e,t)}}Wt.runtime=Q;Wt.typeName="google.protobuf.Timestamp";Wt.fields=Q.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const rb=Q.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Wt},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:ib,repeated:!0},{no:5,name:"events",kind:"message",T:ab,repeated:!0}]),ib=Q.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:sb,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),sb=Q.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Wt},{no:3,name:"value",kind:"scalar",T:2}]),ab=Q.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:Wt},{no:7,name:"normalized_end_timestamp",kind:"message",T:Wt,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),hm=Q.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),Tn=Q.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),ct=Q.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),jd=Q.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),Ms=Q.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),aa=Q.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),Qn=Q.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"},{no:15,name:"MEDIA_FAILURE"},{no:16,name:"AGENT_ERROR"}]),si=Q.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),Ab=Q.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),wt=Q.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),is=Q.makeEnum("livekit.PacketTrailerFeature",[{no:0,name:"PTF_USER_TIMESTAMP"},{no:1,name:"PTF_FRAME_ID"}]),So=Q.makeMessageType("livekit.Room",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:zA,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:xm}]),zA=Q.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),ob=Q.makeMessageType("livekit.ParticipantPermission",()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:Q.getEnumType(ct),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8},{no:13,name:"can_manage_agent_session",kind:"scalar",T:8}]),Bi=Q.makeMessageType("livekit.ParticipantInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:Q.getEnumType(Gi)},{no:4,name:"tracks",kind:"message",T:Ki,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:ob},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:Q.getEnumType(Aa)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:Q.getEnumType(Qn)},{no:18,name:"kind_details",kind:"enum",T:Q.getEnumType(cb),repeated:!0},{no:19,name:"data_tracks",kind:"message",T:ko,repeated:!0},{no:20,name:"client_protocol",kind:"scalar",T:5}]),Gi=Q.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),Aa=Q.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"},{no:7,name:"CONNECTOR"},{no:8,name:"BRIDGE"}]),cb=Q.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"},{no:2,name:"CONNECTOR_WHATSAPP"},{no:3,name:"CONNECTOR_TWILIO"},{no:4,name:"BRIDGE_RTSP"}]),De=Q.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),lb=Q.makeMessageType("livekit.SimulcastCodecInfo",()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"mid",kind:"scalar",T:9},{no:3,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:Hr,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:Q.getEnumType(fm)},{no:6,name:"sdp_cid",kind:"scalar",T:9}]),Ki=Q.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:Q.getEnumType(Tn)},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"simulcast",kind:"scalar",T:8},{no:8,name:"disable_dtx",kind:"scalar",T:8},{no:9,name:"source",kind:"enum",T:Q.getEnumType(ct)},{no:10,name:"layers",kind:"message",T:Hr,repeated:!0},{no:11,name:"mime_type",kind:"scalar",T:9},{no:12,name:"mid",kind:"scalar",T:9},{no:13,name:"codecs",kind:"message",T:lb,repeated:!0},{no:14,name:"stereo",kind:"scalar",T:8},{no:15,name:"disable_red",kind:"scalar",T:8},{no:16,name:"encryption",kind:"enum",T:Q.getEnumType(De)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:xm},{no:19,name:"audio_features",kind:"enum",T:Q.getEnumType(wt),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:Q.getEnumType(hm)},{no:21,name:"packet_trailer_features",kind:"enum",T:Q.getEnumType(is),repeated:!0}]),ko=Q.makeMessageType("livekit.DataTrackInfo",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13},{no:2,name:"sid",kind:"scalar",T:9},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"encryption",kind:"enum",T:Q.getEnumType(De)}]),db=Q.makeMessageType("livekit.DataTrackSubscriptionOptions",()=>[{no:1,name:"target_fps",kind:"scalar",T:13,opt:!0}]),Hr=Q.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:Q.getEnumType(jd)},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"ssrc",kind:"scalar",T:13},{no:6,name:"spatial_layer",kind:"scalar",T:5},{no:7,name:"rid",kind:"scalar",T:9},{no:8,name:"repair_ssrc",kind:"scalar",T:13}]),fm=Q.makeEnum("livekit.VideoLayer.Mode",[{no:0,name:"MODE_UNUSED"},{no:1,name:"ONE_SPATIAL_LAYER_PER_STREAM"},{no:2,name:"MULTIPLE_SPATIAL_LAYERS_PER_STREAM"},{no:3,name:"ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR"}]),Ft=Q.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:Q.getEnumType(Nr)},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:2,name:"user",kind:"message",T:Xd,oneof:"value"},{no:3,name:"speaker",kind:"message",T:ub,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:vm,oneof:"value"},{no:7,name:"transcription",kind:"message",T:hb,oneof:"value"},{no:8,name:"metrics",kind:"message",T:rb,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:GA,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:Jd,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:To,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:Yd,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:qA,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:WA,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:$A,oneof:"value"},{no:18,name:"encrypted_packet",kind:"message",T:pm,oneof:"value"},{no:16,name:"sequence",kind:"scalar",T:13},{no:17,name:"participant_sid",kind:"scalar",T:9}]),Nr=Q.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),pm=Q.makeMessageType("livekit.EncryptedPacket",()=>[{no:1,name:"encryption_type",kind:"enum",T:Q.getEnumType(De)},{no:2,name:"iv",kind:"scalar",T:12},{no:3,name:"key_index",kind:"scalar",T:13},{no:4,name:"encrypted_value",kind:"scalar",T:12}]),mm=Q.makeMessageType("livekit.EncryptedPacketPayload",()=>[{no:1,name:"user",kind:"message",T:Xd,oneof:"value"},{no:3,name:"chat_message",kind:"message",T:GA,oneof:"value"},{no:4,name:"rpc_request",kind:"message",T:Jd,oneof:"value"},{no:5,name:"rpc_ack",kind:"message",T:To,oneof:"value"},{no:6,name:"rpc_response",kind:"message",T:Yd,oneof:"value"},{no:7,name:"stream_header",kind:"message",T:qA,oneof:"value"},{no:8,name:"stream_chunk",kind:"message",T:WA,oneof:"value"},{no:9,name:"stream_trailer",kind:"message",T:$A,oneof:"value"}]),ub=Q.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:gm,repeated:!0}]),gm=Q.makeMessageType("livekit.SpeakerInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"level",kind:"scalar",T:2},{no:3,name:"active",kind:"scalar",T:8}]),Xd=Q.makeMessageType("livekit.UserPacket",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:5,name:"participant_identity",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:4,name:"topic",kind:"scalar",T:9,opt:!0},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),vm=Q.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),hb=Q.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:fb,repeated:!0}]),fb=Q.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),GA=Q.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),Jd=Q.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13},{no:6,name:"compressed_payload",kind:"scalar",T:12}]),To=Q.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),Yd=Q.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:ym,oneof:"value"},{no:4,name:"compressed_payload",kind:"scalar",T:12,oneof:"value"}]),ym=Q.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),wm=Q.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),bm=Q.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:Q.getEnumType(Bm)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"region",kind:"scalar",T:9},{no:5,name:"node_id",kind:"scalar",T:9},{no:6,name:"debug_info",kind:"scalar",T:9},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),Bm=Q.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),Cm=Q.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:Q.getEnumType(Sm)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"os",kind:"scalar",T:9},{no:5,name:"os_version",kind:"scalar",T:9},{no:6,name:"device_model",kind:"scalar",T:9},{no:7,name:"browser",kind:"scalar",T:9},{no:8,name:"browser_version",kind:"scalar",T:9},{no:9,name:"address",kind:"scalar",T:9},{no:10,name:"network",kind:"scalar",T:9},{no:11,name:"other_sdks",kind:"scalar",T:9},{no:12,name:"client_protocol",kind:"scalar",T:5},{no:13,name:"capabilities",kind:"enum",T:Q.getEnumType(km),repeated:!0}]),Sm=Q.makeEnum("livekit.ClientInfo.SDK",[{no:0,name:"UNKNOWN"},{no:1,name:"JS"},{no:2,name:"SWIFT"},{no:3,name:"ANDROID"},{no:4,name:"FLUTTER"},{no:5,name:"GO"},{no:6,name:"UNITY"},{no:7,name:"REACT_NATIVE"},{no:8,name:"RUST"},{no:9,name:"PYTHON"},{no:10,name:"CPP"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"},{no:13,name:"UNREAL"},{no:14,name:"ESP32"}]),km=Q.makeEnum("livekit.ClientInfo.Capability",[{no:0,name:"CAP_UNUSED"},{no:1,name:"CAP_PACKET_TRAILER"}]),Tm=Q.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:S0},{no:2,name:"screen",kind:"message",T:S0},{no:3,name:"resume_connection",kind:"enum",T:Q.getEnumType(aa)},{no:4,name:"disabled_codecs",kind:"message",T:pb},{no:5,name:"force_relay",kind:"enum",T:Q.getEnumType(aa)}]),S0=Q.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:Q.getEnumType(aa)}]),pb=Q.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:zA,repeated:!0},{no:2,name:"publish",kind:"message",T:zA,repeated:!0}]),xm=Q.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),Ql=Q.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),Em=Q.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:Q.getEnumType(Ql)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),Um=Q.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),qA=Q.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:Q.getEnumType(De)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:Em,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:Um,oneof:"content_header"}],{localName:"DataStream_Header"}),WA=Q.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),$A=Q.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),mb=Q.makeMessageType("livekit.SubscribedAudioCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"enabled",kind:"scalar",T:8}]),xn=Q.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),Ml=Q.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),gb=Q.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),vb=Q.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:qr,oneof:"message"},{no:2,name:"answer",kind:"message",T:qr,oneof:"message"},{no:3,name:"trickle",kind:"message",T:xo,oneof:"message"},{no:4,name:"add_track",kind:"message",T:oa,oneof:"message"},{no:5,name:"mute",kind:"message",T:Eo,oneof:"message"},{no:6,name:"subscription",kind:"message",T:Uo,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:Qm,oneof:"message"},{no:8,name:"leave",kind:"message",T:Fo,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:_m,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:Dm,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:au,oneof:"message"},{no:13,name:"simulate",kind:"message",T:Nn,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:iu,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:Hm,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:ru,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:Mm,oneof:"message"},{no:19,name:"publish_data_track_request",kind:"message",T:Zd,oneof:"message"},{no:20,name:"unpublish_data_track_request",kind:"message",T:tu,oneof:"message"},{no:21,name:"update_data_subscription",kind:"message",T:Fm,oneof:"message"}]),k0=Q.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:Bb,oneof:"message"},{no:2,name:"answer",kind:"message",T:qr,oneof:"message"},{no:3,name:"offer",kind:"message",T:qr,oneof:"message"},{no:4,name:"trickle",kind:"message",T:xo,oneof:"message"},{no:5,name:"update",kind:"message",T:kb,oneof:"message"},{no:6,name:"track_published",kind:"message",T:nu,oneof:"message"},{no:8,name:"leave",kind:"message",T:Fo,oneof:"message"},{no:9,name:"mute",kind:"message",T:Eo,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:Tb,oneof:"message"},{no:11,name:"room_update",kind:"message",T:xb,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:Ub,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:Ib,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:Mb,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:Rb,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:Sb,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:Cb,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:Db,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:Hb,oneof:"message"},{no:22,name:"request_response",kind:"message",T:Nb,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:Kb,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:Pb,oneof:"message"},{no:25,name:"media_sections_requirement",kind:"message",T:Gb,oneof:"message"},{no:26,name:"subscribed_audio_codec_update",kind:"message",T:_b,oneof:"message"},{no:27,name:"publish_data_track_response",kind:"message",T:eu,oneof:"message"},{no:28,name:"unpublish_data_track_response",kind:"message",T:yb,oneof:"message"},{no:29,name:"data_track_subscriber_handles",kind:"message",T:wb,oneof:"message"}]),_l=Q.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:Hr,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:Q.getEnumType(fm)}]),oa=Q.makeMessageType("livekit.AddTrackRequest",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:Q.getEnumType(Tn)},{no:4,name:"width",kind:"scalar",T:13},{no:5,name:"height",kind:"scalar",T:13},{no:6,name:"muted",kind:"scalar",T:8},{no:7,name:"disable_dtx",kind:"scalar",T:8},{no:8,name:"source",kind:"enum",T:Q.getEnumType(ct)},{no:9,name:"layers",kind:"message",T:Hr,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:_l,repeated:!0},{no:11,name:"sid",kind:"scalar",T:9},{no:12,name:"stereo",kind:"scalar",T:8},{no:13,name:"disable_red",kind:"scalar",T:8},{no:14,name:"encryption",kind:"enum",T:Q.getEnumType(De)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:Q.getEnumType(hm)},{no:17,name:"audio_features",kind:"enum",T:Q.getEnumType(wt),repeated:!0},{no:18,name:"packet_trailer_features",kind:"enum",T:Q.getEnumType(is),repeated:!0}]),Zd=Q.makeMessageType("livekit.PublishDataTrackRequest",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"encryption",kind:"enum",T:Q.getEnumType(De)}]),eu=Q.makeMessageType("livekit.PublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:ko}]),tu=Q.makeMessageType("livekit.UnpublishDataTrackRequest",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13}]),yb=Q.makeMessageType("livekit.UnpublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:ko}]),wb=Q.makeMessageType("livekit.DataTrackSubscriberHandles",()=>[{no:1,name:"sub_handles",kind:"map",K:13,V:{kind:"message",T:bb}}]),bb=Q.makeMessageType("livekit.DataTrackSubscriberHandles.PublishedDataTrack",()=>[{no:1,name:"publisher_identity",kind:"scalar",T:9},{no:2,name:"publisher_sid",kind:"scalar",T:9},{no:3,name:"track_sid",kind:"scalar",T:9}],{localName:"DataTrackSubscriberHandles_PublishedDataTrack"}),xo=Q.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:Q.getEnumType(xn)},{no:3,name:"final",kind:"scalar",T:8}]),Eo=Q.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),Bb=Q.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:So},{no:2,name:"participant",kind:"message",T:Bi},{no:3,name:"other_participants",kind:"message",T:Bi,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:Rm,repeated:!0},{no:6,name:"subscriber_primary",kind:"scalar",T:8},{no:7,name:"alternative_url",kind:"scalar",T:9},{no:8,name:"client_configuration",kind:"message",T:Tm},{no:9,name:"server_region",kind:"scalar",T:9},{no:10,name:"ping_timeout",kind:"scalar",T:5},{no:11,name:"ping_interval",kind:"scalar",T:5},{no:12,name:"server_info",kind:"message",T:bm},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:zA,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),Cb=Q.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:Rm,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:Tm},{no:3,name:"server_info",kind:"message",T:bm},{no:4,name:"last_message_seq",kind:"scalar",T:13}]),nu=Q.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:Ki}]),Sb=Q.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),qr=Q.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"id",kind:"scalar",T:13},{no:4,name:"mid_to_track_id",kind:"map",K:9,V:{kind:"scalar",T:9}}]),kb=Q.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:Bi,repeated:!0}]),Uo=Q.makeMessageType("livekit.UpdateSubscription",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"participant_tracks",kind:"message",T:wm,repeated:!0}]),Fm=Q.makeMessageType("livekit.UpdateDataSubscription",()=>[{no:1,name:"updates",kind:"message",T:Im,repeated:!0}]),Im=Q.makeMessageType("livekit.UpdateDataSubscription.Update",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"options",kind:"message",T:db}],{localName:"UpdateDataSubscription_Update"}),Qm=Q.makeMessageType("livekit.UpdateTrackSettings",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:3,name:"disabled",kind:"scalar",T:8},{no:4,name:"quality",kind:"enum",T:Q.getEnumType(jd)},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"fps",kind:"scalar",T:13},{no:8,name:"priority",kind:"scalar",T:13}]),ru=Q.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:Q.getEnumType(wt),repeated:!0}]),Mm=Q.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),Fo=Q.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:Q.getEnumType(Qn)},{no:3,name:"action",kind:"enum",T:Q.getEnumType(qi)},{no:4,name:"regions",kind:"message",T:Lb}]),qi=Q.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),_m=Q.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:Hr,repeated:!0}]),iu=Q.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),Rm=Q.makeMessageType("livekit.ICEServer",()=>[{no:1,name:"urls",kind:"scalar",T:9,repeated:!0},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"credential",kind:"scalar",T:9}]),Tb=Q.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:gm,repeated:!0}]),xb=Q.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:So}]),Eb=Q.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:Q.getEnumType(Ms)},{no:3,name:"score",kind:"scalar",T:2}]),Ub=Q.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:Eb,repeated:!0}]),Fb=Q.makeMessageType("livekit.StreamStateInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:Q.getEnumType(Ml)}]),Ib=Q.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:Fb,repeated:!0}]),su=Q.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:Q.getEnumType(jd)},{no:2,name:"enabled",kind:"scalar",T:8}]),Qb=Q.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:su,repeated:!0}]),Mb=Q.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:su,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:Qb,repeated:!0}]),_b=Q.makeMessageType("livekit.SubscribedAudioCodecUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_audio_codecs",kind:"message",T:mb,repeated:!0}]),Pm=Q.makeMessageType("livekit.TrackPermission",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"all_tracks",kind:"scalar",T:8},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"participant_identity",kind:"scalar",T:9}]),Dm=Q.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:Pm,repeated:!0}]),Rb=Q.makeMessageType("livekit.SubscriptionPermissionUpdate",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"allowed",kind:"scalar",T:8}]),Pb=Q.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:So},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:Bi},{no:4,name:"other_participants",kind:"message",T:Bi,repeated:!0}]),au=Q.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:qr},{no:2,name:"subscription",kind:"message",T:Uo},{no:3,name:"publish_tracks",kind:"message",T:nu,repeated:!0},{no:4,name:"data_channels",kind:"message",T:Om,repeated:!0},{no:5,name:"offer",kind:"message",T:qr},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0},{no:7,name:"datachannel_receive_states",kind:"message",T:Lm,repeated:!0},{no:8,name:"publish_data_tracks",kind:"message",T:eu,repeated:!0}]),Lm=Q.makeMessageType("livekit.DataChannelReceiveState",()=>[{no:1,name:"publisher_sid",kind:"scalar",T:9},{no:2,name:"last_seq",kind:"scalar",T:13}]),Om=Q.makeMessageType("livekit.DataChannelInfo",()=>[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:13},{no:3,name:"target",kind:"enum",T:Q.getEnumType(xn)}]),Nn=Q.makeMessageType("livekit.SimulateScenario",()=>[{no:1,name:"speaker_update",kind:"scalar",T:5,oneof:"scenario"},{no:2,name:"node_failure",kind:"scalar",T:8,oneof:"scenario"},{no:3,name:"migration",kind:"scalar",T:8,oneof:"scenario"},{no:4,name:"server_leave",kind:"scalar",T:8,oneof:"scenario"},{no:5,name:"switch_candidate_protocol",kind:"enum",T:Q.getEnumType(gb),oneof:"scenario"},{no:6,name:"subscriber_bandwidth",kind:"scalar",T:3,oneof:"scenario"},{no:7,name:"disconnect_signal_on_resume",kind:"scalar",T:8,oneof:"scenario"},{no:8,name:"disconnect_signal_on_resume_no_messages",kind:"scalar",T:8,oneof:"scenario"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),Hm=Q.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),Db=Q.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),Lb=Q.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:Ob,repeated:!0}]),Ob=Q.makeMessageType("livekit.RegionInfo",()=>[{no:1,name:"region",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9},{no:3,name:"distance",kind:"scalar",T:3}]),Hb=Q.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:Q.getEnumType(Ab)}]),Nb=Q.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:Q.getEnumType(Ai)},{no:3,name:"message",kind:"scalar",T:9},{no:4,name:"trickle",kind:"message",T:xo,oneof:"request"},{no:5,name:"add_track",kind:"message",T:oa,oneof:"request"},{no:6,name:"mute",kind:"message",T:Eo,oneof:"request"},{no:7,name:"update_metadata",kind:"message",T:iu,oneof:"request"},{no:8,name:"update_audio_track",kind:"message",T:ru,oneof:"request"},{no:9,name:"update_video_track",kind:"message",T:Mm,oneof:"request"},{no:10,name:"publish_data_track",kind:"message",T:Zd,oneof:"request"},{no:11,name:"unpublish_data_track",kind:"message",T:tu,oneof:"request"}]),Ai=Q.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"},{no:4,name:"QUEUED"},{no:5,name:"UNSUPPORTED_TYPE"},{no:6,name:"UNCLASSIFIED_ERROR"},{no:7,name:"INVALID_HANDLE"},{no:8,name:"INVALID_NAME"},{no:9,name:"DUPLICATE_HANDLE"},{no:10,name:"DUPLICATE_NAME"}]),Kb=Q.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Nm=Q.makeMessageType("livekit.ConnectionSettings",()=>[{no:1,name:"auto_subscribe",kind:"scalar",T:8},{no:2,name:"adaptive_stream",kind:"scalar",T:8},{no:3,name:"subscriber_allow_pause",kind:"scalar",T:8,opt:!0},{no:4,name:"disable_ice_lite",kind:"scalar",T:8},{no:5,name:"auto_subscribe_data_track",kind:"scalar",T:8,opt:!0}]),Vb=Q.makeMessageType("livekit.JoinRequest",()=>[{no:1,name:"client_info",kind:"message",T:Cm},{no:2,name:"connection_settings",kind:"message",T:Nm},{no:3,name:"metadata",kind:"scalar",T:9},{no:4,name:"participant_attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"add_track_requests",kind:"message",T:oa,repeated:!0},{no:6,name:"publisher_offer",kind:"message",T:qr},{no:7,name:"reconnect",kind:"scalar",T:8},{no:8,name:"reconnect_reason",kind:"enum",T:Q.getEnumType(si)},{no:9,name:"participant_sid",kind:"scalar",T:9},{no:10,name:"sync_state",kind:"message",T:au}]),zb=Q.makeMessageType("livekit.WrappedJoinRequest",()=>[{no:1,name:"compression",kind:"enum",T:Q.getEnumType(Rl)},{no:2,name:"join_request",kind:"scalar",T:12}]),Rl=Q.makeEnum("livekit.WrappedJoinRequest.Compression",[{no:0,name:"NONE"},{no:1,name:"GZIP"}]),Gb=Q.makeMessageType("livekit.MediaSectionsRequirement",()=>[{no:1,name:"num_audios",kind:"scalar",T:13},{no:2,name:"num_videos",kind:"scalar",T:13}]);function qb(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var yA={exports:{}},Wb=yA.exports,T0;function $b(){return T0||(T0=1,function(r){(function(e,t){r.exports?r.exports=t():e.log=t()})(Wb,function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],s={},a=null;function A(g,v){var w=g[v];if(typeof w.bind=="function")return w.bind(g);try{return Function.prototype.bind.call(w,g)}catch{return function(){return Function.prototype.apply.apply(w,[g,arguments])}}}function o(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function c(g){return g==="debug"&&(g="log"),typeof console===t?!1:g==="trace"&&n?o:console[g]!==void 0?A(console,g):console.log!==void 0?A(console,"log"):e}function l(){for(var g=this.getLevel(),v=0;v<i.length;v++){var w=i[v];this[w]=v<g?e:this.methodFactory(w,g,this.name)}if(this.log=this.debug,typeof console===t&&g<this.levels.SILENT)return"No console available for logging"}function d(g){return function(){typeof console!==t&&(l.call(this),this[g].apply(this,arguments))}}function u(g,v,w){return c(g)||d.apply(this,arguments)}function h(g,v){var w=this,B,E,b,C="loglevel";typeof g=="string"?C+=":"+g:typeof g=="symbol"&&(C=void 0);function T(O){var H=(i[O]||"silent").toUpperCase();if(!(typeof window===t||!C)){try{window.localStorage[C]=H;return}catch{}try{window.document.cookie=encodeURIComponent(C)+"="+H+";"}catch{}}}function F(){var O;if(!(typeof window===t||!C)){try{O=window.localStorage[C]}catch{}if(typeof O===t)try{var H=window.document.cookie,se=encodeURIComponent(C),ie=H.indexOf(se+"=");ie!==-1&&(O=/^([^;]+)/.exec(H.slice(ie+se.length+1))[1])}catch{}return w.levels[O]===void 0&&(O=void 0),O}}function R(){if(!(typeof window===t||!C)){try{window.localStorage.removeItem(C)}catch{}try{window.document.cookie=encodeURIComponent(C)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function M(O){var H=O;if(typeof H=="string"&&w.levels[H.toUpperCase()]!==void 0&&(H=w.levels[H.toUpperCase()]),typeof H=="number"&&H>=0&&H<=w.levels.SILENT)return H;throw new TypeError("log.setLevel() called with invalid level: "+O)}w.name=g,w.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},w.methodFactory=v||u,w.getLevel=function(){return b??E??B},w.setLevel=function(O,H){return b=M(O),H!==!1&&T(b),l.call(w)},w.setDefaultLevel=function(O){E=M(O),F()||w.setLevel(O,!1)},w.resetLevel=function(){b=null,R(),l.call(w)},w.enableAll=function(O){w.setLevel(w.levels.TRACE,O)},w.disableAll=function(O){w.setLevel(w.levels.SILENT,O)},w.rebuild=function(){if(a!==w&&(B=M(a.getLevel())),l.call(w),a===w)for(var O in s)s[O].rebuild()},B=M(a?a.getLevel():"WARN");var D=F();D!=null&&(b=M(D)),l.call(w)}a=new h,a.getLogger=function(v){if(typeof v!="symbol"&&typeof v!="string"||v==="")throw new TypeError("You must supply a name when creating a logger.");var w=s[v];return w||(w=s[v]=new h(v,a.methodFactory)),w};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return s},a.default=a,a})}(yA)),yA.exports}var Io=$b(),Pl;(function(r){r[r.trace=0]="trace",r[r.debug=1]="debug",r[r.info=2]="info",r[r.warn=3]="warn",r[r.error=4]="error",r[r.silent=5]="silent"})(Pl||(Pl={}));var Ct;(function(r){r.Default="livekit",r.Room="livekit-room",r.TokenSource="livekit-token-source",r.Participant="livekit-participant",r.Track="livekit-track",r.Publication="livekit-track-publication",r.Engine="livekit-engine",r.Signal="livekit-signal",r.PCManager="livekit-pc-manager",r.PCTransport="livekit-pc-transport",r.E2EE="lk-e2ee",r.DataTracks="livekit-data-tracks"})(Ct||(Ct={}));let me=Io.getLogger(Ct.Default);Object.values(Ct).map(r=>Io.getLogger(r));me.setDefaultLevel(Pl.info);function Xt(r,e){const t=Io.getLogger(r);return t.setDefaultLevel(me.getLevel()),e?jb(t,e):t}function jb(r,e){const t=i=>(s,a)=>{const A=e(),o=A||a?Object.assign(Object.assign({},A),a):void 0;r[i](s,o)},n=Object.create(r);return n.trace=t("trace"),n.debug=t("debug"),n.info=t("info"),n.warn=t("warn"),n.error=t("error"),n}const Xb=Io.getLogger(Ct.E2EE),ws=7e3,Jb=[0,300,2*2*300,3*3*300,4*4*300,ws,ws,ws,ws,ws];class Yb{constructor(e){this._retryDelays=e!==void 0?[...e]:Jb}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+Math.random()*1e3}}function Zb(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function k(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function A(l){try{c(n.next(l))}catch(d){a(d)}}function o(l){try{c(n.throw(l))}catch(d){a(d)}}function c(l){l.done?s(l.value):i(l.value).then(A,o)}c((n=n.apply(r,e||[])).next())})}function x0(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ss(r){return this instanceof ss?(this.v=r,this):new ss(r)}function e4(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),A("next"),A("throw"),A("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(h){return function(p){return Promise.resolve(p).then(h,d)}}function A(h,p){n[h]&&(i[h]=function(g){return new Promise(function(v,w){s.push([h,g,v,w])>1||o(h,g)})},p&&(i[h]=p(i[h])))}function o(h,p){try{c(n[h](p))}catch(g){u(s[0][3],g)}}function c(h){h.value instanceof ss?Promise.resolve(h.value.v).then(l,d):u(s[0][2],h)}function l(h){o("next",h)}function d(h){o("throw",h)}function u(h,p){h(p),s.shift(),s.length&&o(s[0][0],s[0][1])}}function t4(r){var e,t;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=r[i]?function(a){return(t=!t)?{value:ss(r[i](a)),done:!1}:s?s(a):a}:s}}function En(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof x0=="function"?x0(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=r[s]&&function(a){return new Promise(function(A,o){a=r[s](a),i(A,o,a.done,a.value)})}}function i(s,a,A,o){Promise.resolve(o).then(function(c){s({value:c,done:A})},a)}}var Ma={exports:{}},E0;function n4(){if(E0)return Ma.exports;E0=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(C,T,F){return Function.prototype.apply.call(C,T,F)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(C){return Object.getOwnPropertyNames(C).concat(Object.getOwnPropertySymbols(C))}:t=function(C){return Object.getOwnPropertyNames(C)};function n(b){}var i=Number.isNaN||function(C){return C!==C};function s(){s.init.call(this)}Ma.exports=s,Ma.exports.once=w,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function A(b){if(typeof b!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof b)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(b){if(typeof b!="number"||b<0||i(b))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+b+".");a=b}}),s.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},s.prototype.setMaxListeners=function(C){if(typeof C!="number"||C<0||i(C))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+C+".");return this._maxListeners=C,this};function o(b){return b._maxListeners===void 0?s.defaultMaxListeners:b._maxListeners}s.prototype.getMaxListeners=function(){return o(this)},s.prototype.emit=function(C){for(var T=[],F=1;F<arguments.length;F++)T.push(arguments[F]);var R=C==="error",M=this._events;if(M!==void 0)R=R&&M.error===void 0;else if(!R)return!1;if(R){var D;if(T.length>0&&(D=T[0]),D instanceof Error)throw D;var O=new Error("Unhandled error."+(D?" ("+D.message+")":""));throw O.context=D,O}var H=M[C];if(H===void 0)return!1;if(typeof H=="function")e(H,this,T);else for(var se=H.length,ie=p(H,se),F=0;F<se;++F)e(ie[F],this,T);return!0};function c(b,C,T,F){var R,M,D;if(A(T),M=b._events,M===void 0?(M=b._events=Object.create(null),b._eventsCount=0):(M.newListener!==void 0&&(b.emit("newListener",C,T.listener?T.listener:T),M=b._events),D=M[C]),D===void 0)D=M[C]=T,++b._eventsCount;else if(typeof D=="function"?D=M[C]=F?[T,D]:[D,T]:F?D.unshift(T):D.push(T),R=o(b),R>0&&D.length>R&&!D.warned){D.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+D.length+" "+String(C)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=b,O.type=C,O.count=D.length}return b}s.prototype.addListener=function(C,T){return c(this,C,T,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(C,T){return c(this,C,T,!0)};function l(){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 d(b,C,T){var F={fired:!1,wrapFn:void 0,target:b,type:C,listener:T},R=l.bind(F);return R.listener=T,F.wrapFn=R,R}s.prototype.once=function(C,T){return A(T),this.on(C,d(this,C,T)),this},s.prototype.prependOnceListener=function(C,T){return A(T),this.prependListener(C,d(this,C,T)),this},s.prototype.removeListener=function(C,T){var F,R,M,D,O;if(A(T),R=this._events,R===void 0)return this;if(F=R[C],F===void 0)return this;if(F===T||F.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete R[C],R.removeListener&&this.emit("removeListener",C,F.listener||T));else if(typeof F!="function"){for(M=-1,D=F.length-1;D>=0;D--)if(F[D]===T||F[D].listener===T){O=F[D].listener,M=D;break}if(M<0)return this;M===0?F.shift():g(F,M),F.length===1&&(R[C]=F[0]),R.removeListener!==void 0&&this.emit("removeListener",C,O||T)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(C){var T,F,R;if(F=this._events,F===void 0)return this;if(F.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):F[C]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete F[C]),this;if(arguments.length===0){var M=Object.keys(F),D;for(R=0;R<M.length;++R)D=M[R],D!=="removeListener"&&this.removeAllListeners(D);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=F[C],typeof T=="function")this.removeListener(C,T);else if(T!==void 0)for(R=T.length-1;R>=0;R--)this.removeListener(C,T[R]);return this};function u(b,C,T){var F=b._events;if(F===void 0)return[];var R=F[C];return R===void 0?[]:typeof R=="function"?T?[R.listener||R]:[R]:T?v(R):p(R,R.length)}s.prototype.listeners=function(C){return u(this,C,!0)},s.prototype.rawListeners=function(C){return u(this,C,!1)},s.listenerCount=function(b,C){return typeof b.listenerCount=="function"?b.listenerCount(C):h.call(b,C)},s.prototype.listenerCount=h;function h(b){var C=this._events;if(C!==void 0){var T=C[b];if(typeof T=="function")return 1;if(T!==void 0)return T.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function p(b,C){for(var T=new Array(C),F=0;F<C;++F)T[F]=b[F];return T}function g(b,C){for(;C+1<b.length;C++)b[C]=b[C+1];b.pop()}function v(b){for(var C=new Array(b.length),T=0;T<C.length;++T)C[T]=b[T].listener||b[T];return C}function w(b,C){return new Promise(function(T,F){function R(D){b.removeListener(C,M),F(D)}function M(){typeof b.removeListener=="function"&&b.removeListener("error",R),T([].slice.call(arguments))}E(b,C,M,{once:!0}),C!=="error"&&B(b,R,{once:!0})})}function B(b,C,T){typeof b.on=="function"&&E(b,"error",C,T)}function E(b,C,T,F){if(typeof b.on=="function")F.once?b.once(C,T):b.on(C,T);else if(typeof b.addEventListener=="function")b.addEventListener(C,function R(M){F.once&&b.removeEventListener(C,R),T(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof b)}return Ma.exports}var Yt=n4();let Km=!0,r4=!0;function _s(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseFloat(n[t],10)}function ki(r,e,t){if(!r.RTCPeerConnection)return;if(!Object.getOwnPropertyDescriptor(EventTarget.prototype,"addEventListener").writable){return}const i=r.RTCPeerConnection.prototype,s=i.addEventListener;i.addEventListener=function(A,o){if(A!==e)return s.apply(this,arguments);const c=l=>{const d=t(l);d&&(o.handleEvent?o.handleEvent(d):o(d))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),s.apply(this,[A,c])};const a=i.removeEventListener;i.removeEventListener=function(A,o){if(A!==e||!this._eventMap||!this._eventMap[e])return a.apply(this,arguments);if(!this._eventMap[e].has(o))return a.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[A,c])},Object.defineProperty(i,"on"+e,{get(){return this["_on"+e]},set(A){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),A&&this.addEventListener(e,this["_on"+e]=A)},enumerable:!0,configurable:!0})}function i4(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Km=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function s4(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(r4=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function Vm(){}function a4(r){const e={browser:null,version:null};if(typeof r>"u"||!r.navigator||!r.navigator.userAgent)return e.browser="Not a browser.",e;const t=r.navigator;if(t.userAgentData&&t.userAgentData.brands){const n=t.userAgentData.brands.find(i=>i.brand==="Chromium");if(n)return{browser:"chrome",version:parseInt(n.version,10)}}if(t.mozGetUserMedia)e.browser="firefox",e.version=parseInt(_s(t.userAgent,/Firefox\/(\d+)\./,1));else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection)e.browser="chrome",e.version=parseInt(_s(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2))||null;else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=parseInt(_s(t.userAgent,/AppleWebKit\/(\d+)\./,1)),e.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype,e._safariVersion=_s(t.userAgent,/Version\/(\d+(\.?\d+))/,1);else return e.browser="Not a supported browser.",e;return e}function U0(r){return Object.prototype.toString.call(r)==="[object Object]"}function zm(r){return U0(r)?Object.keys(r).reduce(function(e,t){const n=U0(r[t]),i=n?zm(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function Dl(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?Dl(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{Dl(r,r.get(i),t)})}))}function F0(r,e,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return r.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{r.forEach(A=>{A.type===n&&A.trackId===a.id&&Dl(r,A,i)})}),i}const I0=Vm;function Gm(r,e){const t=r&&r.navigator;if(!t.mediaDevices)return;const n=function(A){if(typeof A!="object"||A.mandatory||A.optional)return A;const o={};return Object.keys(A).forEach(c=>{if(c==="require"||c==="advanced"||c==="mediaSource")return;const l=typeof A[c]=="object"?A[c]:{ideal:A[c]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const d=function(u,h){return u?u+h.charAt(0).toUpperCase()+h.slice(1):h==="deviceId"?"sourceId":h};if(l.ideal!==void 0){o.optional=o.optional||[];let u={};typeof l.ideal=="number"?(u[d("min",c)]=l.ideal,o.optional.push(u),u={},u[d("max",c)]=l.ideal,o.optional.push(u)):(u[d("",c)]=l.ideal,o.optional.push(u))}l.exact!==void 0&&typeof l.exact!="number"?(o.mandatory=o.mandatory||{},o.mandatory[d("",c)]=l.exact):["min","max"].forEach(u=>{l[u]!==void 0&&(o.mandatory=o.mandatory||{},o.mandatory[d(u,c)]=l[u])})}),A.advanced&&(o.optional=(o.optional||[]).concat(A.advanced)),o},i=function(A,o){if(e.version>=61)return o(A);if(A=JSON.parse(JSON.stringify(A)),A&&typeof A.audio=="object"){const c=function(l,d,u){d in l&&!(u in l)&&(l[u]=l[d],delete l[d])};A=JSON.parse(JSON.stringify(A)),c(A.audio,"autoGainControl","googAutoGainControl"),c(A.audio,"noiseSuppression","googNoiseSuppression"),A.audio=n(A.audio)}if(A&&typeof A.video=="object"){let c=A.video.facingMode;c=c&&(typeof c=="object"?c:{ideal:c});const l=e.version<66;if(c&&(c.exact==="user"||c.exact==="environment"||c.ideal==="user"||c.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!l)){delete A.video.facingMode;let d;if(c.exact==="environment"||c.ideal==="environment"?d=["back","rear"]:(c.exact==="user"||c.ideal==="user")&&(d=["front"]),d)return t.mediaDevices.enumerateDevices().then(u=>{u=u.filter(p=>p.kind==="videoinput");let h=u.find(p=>d.some(g=>p.label.toLowerCase().includes(g)));return!h&&u.length&&d.includes("back")&&(h=u[u.length-1]),h&&(A.video.deviceId=c.exact?{exact:h.deviceId}:{ideal:h.deviceId}),A.video=n(A.video),I0("chrome: "+JSON.stringify(A)),o(A)})}A.video=n(A.video)}return I0("chrome: "+JSON.stringify(A)),o(A)},s=function(A){return e.version>=64?A:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[A.name]||A.name,message:A.message,constraint:A.constraint||A.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(A,o,c){i(A,l=>{t.webkitGetUserMedia(l,o,d=>{c&&c(s(d))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const A=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(o){return i(o,c=>A(c).then(l=>{if(c.audio&&!l.getAudioTracks().length||c.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(d=>{d.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(s(l))))}}}function qm(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function Wm(r,e){if(!(e.version>102))if(typeof r=="object"&&r.RTCPeerConnection&&!("ontrack"in r.RTCPeerConnection.prototype)){Object.defineProperty(r.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",s=>{let a;r.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(o=>o.track&&o.track.id===s.track.id):a={track:s.track};const A=new Event("track");A.track=s.track,A.receiver=a,A.transceiver={receiver:a},A.streams=[i.stream],this.dispatchEvent(A)}),i.stream.getTracks().forEach(s=>{let a;r.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(o=>o.track&&o.track.id===s.id):a={track:s};const A=new Event("track");A.track=s,A.receiver=a,A.transceiver={receiver:a},A.streams=[i.stream],this.dispatchEvent(A)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else ki(r,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function $m(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("getSenders"in r.RTCPeerConnection.prototype)&&"createDTMFSender"in r.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!r.RTCPeerConnection.prototype.getSenders){r.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(A,o){let c=i.apply(this,arguments);return c||(c=e(this,A),this._senders.push(c)),c};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(A){s.apply(this,arguments);const o=this._senders.indexOf(A);o!==-1&&this._senders.splice(o,1)}}const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],t.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],n.apply(this,[s]),s.getTracks().forEach(a=>{const A=this._senders.find(o=>o.track===a);A&&this._senders.splice(this._senders.indexOf(A),1)})}}else if(typeof r=="object"&&r.RTCPeerConnection&&"getSenders"in r.RTCPeerConnection.prototype&&"createDTMFSender"in r.RTCPeerConnection.prototype&&r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)){const e=r.RTCPeerConnection.prototype.getSenders;r.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n},Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function jm(r,e){if(e.version>=67||!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender&&r.RTCRtpReceiver))return;if(!("getStats"in r.RTCRtpSender.prototype)){const n=r.RTCPeerConnection.prototype.getSenders;n&&(r.RTCPeerConnection.prototype.getSenders=function(){const a=n.apply(this,[]);return a.forEach(A=>A._pc=this),a});const i=r.RTCPeerConnection.prototype.addTrack;i&&(r.RTCPeerConnection.prototype.addTrack=function(){const a=i.apply(this,arguments);return a._pc=this,a}),r.RTCRtpSender.prototype.getStats=function(){const a=this;return this._pc.getStats().then(A=>F0(A,a.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const n=r.RTCPeerConnection.prototype.getReceivers;n&&(r.RTCPeerConnection.prototype.getReceivers=function(){const s=n.apply(this,[]);return s.forEach(a=>a._pc=this),s}),ki(r,"track",i=>(i.receiver._pc=i.srcElement,i)),r.RTCRtpReceiver.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>F0(a,s.track,!1))}}if(!("getStats"in r.RTCRtpSender.prototype&&"getStats"in r.RTCRtpReceiver.prototype))return;const t=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof r.MediaStreamTrack){const i=arguments[0];let s,a,A;return this.getSenders().forEach(o=>{o.track===i&&(s?A=!0:s=o)}),this.getReceivers().forEach(o=>(o.track===i&&(a?A=!0:a=o),o.track===i)),A||s&&a?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):s?s.getStats():a?a.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Xm(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(a,A){if(!A)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const o=e.apply(this,arguments);return this._shimmedLocalStreams[A.id]?this._shimmedLocalStreams[A.id].indexOf(o)===-1&&this._shimmedLocalStreams[A.id].push(o):this._shimmedLocalStreams[A.id]=[A,o],o};const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(c=>{if(this.getSenders().find(d=>d.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const A=this.getSenders();t.apply(this,arguments);const o=this.getSenders().filter(c=>A.indexOf(c)===-1);this._shimmedLocalStreams[a.id]=[a].concat(o)};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],n.apply(this,arguments)};const i=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(A=>{const o=this._shimmedLocalStreams[A].indexOf(a);o!==-1&&this._shimmedLocalStreams[A].splice(o,1),this._shimmedLocalStreams[A].length===1&&delete this._shimmedLocalStreams[A]}),i.apply(this,arguments)}}function Jm(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Xm(r);const t=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(d=>this._reverseStreams[d.id])};const n=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(d=>{if(this.getSenders().find(h=>h.track===d))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const d=new r.MediaStream(l.getTracks());this._streams[l.id]=d,this._reverseStreams[d.id]=l,l=d}n.apply(this,[l])};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},r.RTCPeerConnection.prototype.addTrack=function(l,d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const u=[].slice.call(arguments,1);if(u.length!==1||!u[0].getTracks().find(g=>g===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(g=>g.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const p=this._streams[d.id];if(p)p.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const g=new r.MediaStream([l]);this._streams[d.id]=g,this._reverseStreams[g.id]=d,this.addStream(g)}return this.getSenders().find(g=>g.track===l)};function s(c,l){let d=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(u=>{const h=c._reverseStreams[u],p=c._streams[h.id];d=d.replace(new RegExp(p.id,"g"),h.id)}),new RTCSessionDescription({type:l.type,sdp:d})}function a(c,l){let d=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(u=>{const h=c._reverseStreams[u],p=c._streams[h.id];d=d.replace(new RegExp(h.id,"g"),p.id)}),new RTCSessionDescription({type:l.type,sdp:d})}["createOffer","createAnswer"].forEach(function(c){const l=r.RTCPeerConnection.prototype[c],d={[c](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?l.apply(this,[p=>{const g=s(this,p);u[0].apply(null,[g])},p=>{u[1]&&u[1].apply(null,p)},arguments[2]]):l.apply(this,arguments).then(p=>s(this,p))}};r.RTCPeerConnection.prototype[c]=d[c]});const A=r.RTCPeerConnection.prototype.setLocalDescription;r.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?A.apply(this,arguments):(arguments[0]=a(this,arguments[0]),A.apply(this,arguments))};const o=Object.getOwnPropertyDescriptor(r.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(r.RTCPeerConnection.prototype,"localDescription",{get(){const c=o.get.apply(this);return c.type===""?c:s(this,c)}}),r.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(l._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let u;Object.keys(this._streams).forEach(h=>{this._streams[h].getTracks().find(g=>l.track===g)&&(u=this._streams[h])}),u&&(u.getTracks().length===1?this.removeStream(this._reverseStreams[u.id]):u.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Ll(r,e){!r.RTCPeerConnection&&r.webkitRTCPeerConnection&&(r.RTCPeerConnection=r.webkitRTCPeerConnection),r.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=r.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};r.RTCPeerConnection.prototype[t]=i[t]})}function Ym(r,e){e.version>102||ki(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}var Q0=Object.freeze({__proto__:null,fixNegotiationNeeded:Ym,shimAddTrackRemoveTrack:Jm,shimAddTrackRemoveTrackWithNative:Xm,shimGetSendersWithDtmf:$m,shimGetUserMedia:Gm,shimMediaStream:qm,shimOnTrack:Wm,shimPeerConnection:Ll,shimSenderReceiverGetStats:jm});function Zm(r,e){const t=r&&r.navigator,n=r&&r.MediaStreamTrack;if(t.getUserMedia=function(i,s,a){t.mediaDevices.getUserMedia(i).then(s,a)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(a,A,o){A in a&&!(o in a)&&(a[o]=a[A],delete a[A])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)},n&&n.prototype.getSettings){const a=n.prototype.getSettings;n.prototype.getSettings=function(){const A=a.apply(this,arguments);return i(A,"mozAutoGainControl","autoGainControl"),i(A,"mozNoiseSuppression","noiseSuppression"),A}}if(n&&n.prototype.applyConstraints){const a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(A){return this.kind==="audio"&&typeof A=="object"&&(A=JSON.parse(JSON.stringify(A)),i(A,"autoGainControl","mozAutoGainControl"),i(A,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[A])}}}}function A4(r,e){r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||r.navigator.mediaDevices&&(r.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){const i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return n.video===!0?n.video={mediaSource:e}:n.video.mediaSource=e,r.navigator.mediaDevices.getUserMedia(n)})}function eg(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ol(r,e){typeof r!="object"||!(r.RTCPeerConnection||r.mozRTCPeerConnection)||(!r.RTCPeerConnection&&r.mozRTCPeerConnection&&(r.RTCPeerConnection=r.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=r.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};r.RTCPeerConnection.prototype[t]=i[t]}))}function tg(r,e){if(typeof r!="object"||!(r.RTCPeerConnection||r.mozRTCPeerConnection)||e.version>=151)return;const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const s=Array.prototype.slice.call(arguments),a=s[0],A=s[1],o=s[2];return this.signalingState==="closed"?Promise.resolve(new Map):n.apply(this,[a||null]).then(c=>{if(e.version<53&&!A)try{c.forEach(l=>{l.type=t[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;c.forEach((d,u)=>{c.set(u,Object.assign({},d,{type:t[d.type]||d.type}))})}return c}).then(A,o)}}function ng(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpSender.prototype)return;const e=r.RTCPeerConnection.prototype.getSenders;e&&(r.RTCPeerConnection.prototype.getSenders=function(){const i=e.apply(this,[]);return i.forEach(s=>s._pc=this),i});const t=r.RTCPeerConnection.prototype.addTrack;t&&(r.RTCPeerConnection.prototype.addTrack=function(){const i=t.apply(this,arguments);return i._pc=this,i}),r.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function rg(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpReceiver.prototype)return;const e=r.RTCPeerConnection.prototype.getReceivers;e&&(r.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n}),ki(r,"track",t=>(t.receiver._pc=t.srcElement,t)),r.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function ig(r){!r.RTCPeerConnection||"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(t){this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function sg(r){r.DataChannel&&!r.RTCDataChannel&&(r.RTCDataChannel=r.DataChannel)}function ag(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.addTransceiver;e&&(r.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let n=arguments[1]&&arguments[1].sendEncodings;n===void 0&&(n=[]),n=[...n];const i=n.length>0;i&&n.forEach(a=>{if("rid"in a&&!/^[a-z0-9]{0,16}$/i.test(a.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in a&&!(parseFloat(a.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in a&&!(parseFloat(a.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=e.apply(this,arguments);if(i){const a=s.sender,A=a.getParameters();(!("encodings"in A)||A.encodings.length===1&&Object.keys(A.encodings[0]).length===0)&&(A.encodings=n,a.sendEncodings=n,this.setParametersPromises.push(a.setParameters(A).then(()=>{delete a.sendEncodings}).catch(()=>{delete a.sendEncodings})))}return s})}function Ag(r){if(!(typeof r=="object"&&r.RTCRtpSender))return;const e=r.RTCRtpSender.prototype.getParameters;e&&(r.RTCRtpSender.prototype.getParameters=function(){const n=e.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function og(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function cg(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createAnswer;r.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var M0=Object.freeze({__proto__:null,shimAddTransceiver:ag,shimCreateAnswer:cg,shimCreateOffer:og,shimGetDisplayMedia:A4,shimGetParameters:Ag,shimGetStats:tg,shimGetUserMedia:Zm,shimOnTrack:eg,shimPeerConnection:Ol,shimRTCDataChannel:sg,shimReceiverGetStats:rg,shimRemoveStream:ig,shimSenderGetStats:ng});function lg(r){if(!(typeof r!="object"||!r.RTCPeerConnection)){if("getLocalStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in r.RTCPeerConnection.prototype)){const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(i=>e.call(this,i,n)),n.getVideoTracks().forEach(i=>e.call(this,i,n))},r.RTCPeerConnection.prototype.addTrack=function(n){for(var i=arguments.length,s=new Array(i>1?i-1:0),a=1;a<i;a++)s[a-1]=arguments[a];return s&&s.forEach(A=>{this._localStreams?this._localStreams.includes(A)||this._localStreams.push(A):this._localStreams=[A]}),e.apply(this,arguments)}}"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);const i=t.getTracks();this.getSenders().forEach(s=>{i.includes(s.track)&&this.removeTrack(s)})})}}function dg(r){if(!(typeof r!="object"||!r.RTCPeerConnection)&&("getRemoteStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in r.RTCPeerConnection.prototype))){Object.defineProperty(r.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(s=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(s)>=0)return;n._remoteStreams.push(s);const a=new Event("addstream");a.stream=s,n.dispatchEvent(a)})}),e.apply(n,arguments)}}}function ug(r){if(typeof r!="object"||!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype,t=e.createOffer,n=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(c,l){const d=arguments.length>=2?arguments[2]:arguments[0],u=t.apply(this,[d]);return l?(u.then(c,l),Promise.resolve()):u},e.createAnswer=function(c,l){const d=arguments.length>=2?arguments[2]:arguments[0],u=n.apply(this,[d]);return l?(u.then(c,l),Promise.resolve()):u};let A=function(o,c,l){const d=i.apply(this,[o]);return l?(d.then(c,l),Promise.resolve()):d};e.setLocalDescription=A,A=function(o,c,l){const d=s.apply(this,[o]);return l?(d.then(c,l),Promise.resolve()):d},e.setRemoteDescription=A,A=function(o,c,l){const d=a.apply(this,[o]);return l?(d.then(c,l),Promise.resolve()):d},e.addIceCandidate=A}function hg(r){const e=r&&r.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,n=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=i=>n(fg(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(n,i,s){e.mediaDevices.getUserMedia(n).then(i,s)}).bind(e))}function fg(r){return r&&r.video!==void 0?Object.assign({},r,{video:zm(r.video)}):r}function pg(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection;r.RTCPeerConnection=function(n,i){if(n&&n.iceServers){const s=[];for(let a=0;a<n.iceServers.length;a++){let A=n.iceServers[a];A.urls===void 0&&A.url?(A=JSON.parse(JSON.stringify(A)),A.urls=A.url,delete A.url,s.push(A)):s.push(n.iceServers[a])}n.iceServers=s}return new e(n,i)},r.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function mg(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function gg(r){const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const i=this.getTransceivers().find(a=>a.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio",{direction:"recvonly"}),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const s=this.getTransceivers().find(a=>a.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):n.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function vg(r){typeof r!="object"||r.AudioContext||(r.AudioContext=r.webkitAudioContext)}var _0=Object.freeze({__proto__:null,shimAudioContext:vg,shimCallbacksAPI:ug,shimConstraints:fg,shimCreateOfferLegacy:gg,shimGetUserMedia:hg,shimLocalStreamsAPI:lg,shimRTCIceServerUrls:pg,shimRemoteStreamsAPI:dg,shimTrackEventTransceiver:mg}),gc={exports:{}},R0;function o4(){return R0||(R0=1,function(r){const e={};e.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
|
|
4
|
+
`).map(n=>n.trim())},e.splitSections=function(t){return t.split(`
|
|
5
|
+
m=`).map((i,s)=>(s>0?"m="+i:i).trim()+`\r
|
|
6
|
+
`)},e.getDescription=function(t){const n=e.splitSections(t);return n&&n[0]},e.getMediaSections=function(t){const n=e.splitSections(t);return n.shift(),n},e.matchPrefix=function(t,n){return e.splitLines(t).filter(i=>i.indexOf(n)===0)},e.parseCandidate=function(t){let n;t.indexOf("a=candidate:")===0?n=t.substring(12).split(" "):n=t.substring(10).split(" ");const i={foundation:n[0],component:{1:"rtp",2:"rtcp"}[n[1]]||n[1],protocol:n[2].toLowerCase(),priority:parseInt(n[3],10),ip:n[4],address:n[4],port:parseInt(n[5],10),type:n[7]};for(let s=8;s<n.length;s+=2)switch(n[s]){case"raddr":i.relatedAddress=n[s+1];break;case"rport":i.relatedPort=parseInt(n[s+1],10);break;case"tcptype":i.tcpType=n[s+1];break;case"ufrag":i.ufrag=n[s+1],i.usernameFragment=n[s+1];break;default:i[n[s]]===void 0&&(i[n[s]]=n[s+1]);break}return i},e.writeCandidate=function(t){const n=[];n.push(t.foundation);const i=t.component;i==="rtp"?n.push(1):i==="rtcp"?n.push(2):n.push(i),n.push(t.protocol.toUpperCase()),n.push(t.priority),n.push(t.address||t.ip),n.push(t.port);const s=t.type;return n.push("typ"),n.push(s),s!=="host"&&t.relatedAddress&&t.relatedPort!==void 0&&(n.push("raddr"),n.push(t.relatedAddress),n.push("rport"),n.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(n.push("tcptype"),n.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(n.push("ufrag"),n.push(t.usernameFragment||t.ufrag)),"candidate:"+n.join(" ")},e.parseIceOptions=function(t){return t.substring(14).split(" ")},e.parseRtpMap=function(t){let n=t.substring(9).split(" ");const i={payloadType:parseInt(n.shift(),10)};return n=n[0].split("/"),i.name=n[0],i.clockRate=parseInt(n[1],10),i.channels=n.length===3?parseInt(n[2],10):1,i.numChannels=i.channels,i},e.writeRtpMap=function(t){let n=t.payloadType;t.preferredPayloadType!==void 0&&(n=t.preferredPayloadType);const i=t.channels||t.numChannels||1;return"a=rtpmap:"+n+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
|
|
7
|
+
`},e.parseExtmap=function(t){const n=t.substring(9).split(" ");return{id:parseInt(n[0],10),direction:n[0].indexOf("/")>0?n[0].split("/")[1]:"sendrecv",uri:n[1],attributes:n.slice(2).join(" ")}},e.writeExtmap=function(t){return"a=extmap:"+(t.id||t.preferredId)+(t.direction&&t.direction!=="sendrecv"?"/"+t.direction:"")+" "+t.uri+(t.attributes?" "+t.attributes:"")+`\r
|
|
8
|
+
`},e.parseFmtp=function(t){const n={};let i;const s=t.substring(t.indexOf(" ")+1).split(";");for(let a=0;a<s.length;a++)i=s[a].trim().split("="),n[i[0].trim()]=i[1];return n},e.writeFmtp=function(t){let n="",i=t.payloadType;if(t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.parameters&&Object.keys(t.parameters).length){const s=[];Object.keys(t.parameters).forEach(a=>{t.parameters[a]!==void 0?s.push(a+"="+t.parameters[a]):s.push(a)}),n+="a=fmtp:"+i+" "+s.join(";")+`\r
|
|
9
|
+
`}return n},e.parseRtcpFb=function(t){const n=t.substring(t.indexOf(" ")+1).split(" ");return{type:n.shift(),parameter:n.join(" ")}},e.writeRtcpFb=function(t){let n="",i=t.payloadType;return t.preferredPayloadType!==void 0&&(i=t.preferredPayloadType),t.rtcpFeedback&&t.rtcpFeedback.length&&t.rtcpFeedback.forEach(s=>{n+="a=rtcp-fb:"+i+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
|
|
10
|
+
`}),n},e.parseSsrcMedia=function(t){const n=t.indexOf(" "),i={ssrc:parseInt(t.substring(7,n),10)},s=t.indexOf(":",n);return s>-1?(i.attribute=t.substring(n+1,s),i.value=t.substring(s+1)):i.attribute=t.substring(n+1),i},e.parseSsrcGroup=function(t){const n=t.substring(13).split(" ");return{semantics:n.shift(),ssrcs:n.map(i=>parseInt(i,10))}},e.getMid=function(t){const n=e.matchPrefix(t,"a=mid:")[0];if(n)return n.substring(6)},e.parseFingerprint=function(t){const n=t.substring(14).split(" ");return{algorithm:n[0].toLowerCase(),value:n[1].toUpperCase()}},e.getDtlsParameters=function(t,n){return{role:"auto",fingerprints:e.matchPrefix(t+n,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(t,n){let i="a=setup:"+n+`\r
|
|
11
|
+
`;return t.fingerprints.forEach(s=>{i+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
|
|
12
|
+
`}),i},e.parseCryptoLine=function(t){const n=t.substring(9).split(" ");return{tag:parseInt(n[0],10),cryptoSuite:n[1],keyParams:n[2],sessionParams:n.slice(3)}},e.writeCryptoLine=function(t){return"a=crypto:"+t.tag+" "+t.cryptoSuite+" "+(typeof t.keyParams=="object"?e.writeCryptoKeyParams(t.keyParams):t.keyParams)+(t.sessionParams?" "+t.sessionParams.join(" "):"")+`\r
|
|
13
|
+
`},e.parseCryptoKeyParams=function(t){if(t.indexOf("inline:")!==0)return null;const n=t.substring(7).split("|");return{keyMethod:"inline",keySalt:n[0],lifeTime:n[1],mkiValue:n[2]?n[2].split(":")[0]:void 0,mkiLength:n[2]?n[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(t){return t.keyMethod+":"+t.keySalt+(t.lifeTime?"|"+t.lifeTime:"")+(t.mkiValue&&t.mkiLength?"|"+t.mkiValue+":"+t.mkiLength:"")},e.getCryptoParameters=function(t,n){return e.matchPrefix(t+n,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(t,n){const i=e.matchPrefix(t+n,"a=ice-ufrag:")[0],s=e.matchPrefix(t+n,"a=ice-pwd:")[0];return i&&s?{usernameFragment:i.substring(12),password:s.substring(10)}:null},e.writeIceParameters=function(t){let n="a=ice-ufrag:"+t.usernameFragment+`\r
|
|
14
|
+
a=ice-pwd:`+t.password+`\r
|
|
15
|
+
`;return t.iceLite&&(n+=`a=ice-lite\r
|
|
16
|
+
`),n},e.parseRtpParameters=function(t){const n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},s=e.splitLines(t)[0].split(" ");n.profile=s[2];for(let A=3;A<s.length;A++){const o=s[A],c=e.matchPrefix(t,"a=rtpmap:"+o+" ")[0];if(c){const l=e.parseRtpMap(c),d=e.matchPrefix(t,"a=fmtp:"+o+" ");switch(l.parameters=d.length?e.parseFmtp(d[0]):{},l.rtcpFeedback=e.matchPrefix(t,"a=rtcp-fb:"+o+" ").map(e.parseRtcpFb),n.codecs.push(l),l.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(l.name.toUpperCase());break}}}e.matchPrefix(t,"a=extmap:").forEach(A=>{n.headerExtensions.push(e.parseExtmap(A))});const a=e.matchPrefix(t,"a=rtcp-fb:* ").map(e.parseRtcpFb);return n.codecs.forEach(A=>{a.forEach(o=>{A.rtcpFeedback.find(l=>l.type===o.type&&l.parameter===o.parameter)||A.rtcpFeedback.push(o)})}),n},e.writeRtpDescription=function(t,n){let i="";i+="m="+t+" ",i+=n.codecs.length>0?"9":"0",i+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",i+=n.codecs.map(a=>a.preferredPayloadType!==void 0?a.preferredPayloadType:a.payloadType).join(" ")+`\r
|
|
17
|
+
`,i+=`c=IN IP4 0.0.0.0\r
|
|
18
|
+
`,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
19
|
+
`,n.codecs.forEach(a=>{i+=e.writeRtpMap(a),i+=e.writeFmtp(a),i+=e.writeRtcpFb(a)});let s=0;return n.codecs.forEach(a=>{a.maxptime>s&&(s=a.maxptime)}),s>0&&(i+="a=maxptime:"+s+`\r
|
|
20
|
+
`),n.headerExtensions&&n.headerExtensions.forEach(a=>{i+=e.writeExtmap(a)}),i},e.parseRtpEncodingParameters=function(t){const n=[],i=e.parseRtpParameters(t),s=i.fecMechanisms.indexOf("RED")!==-1,a=i.fecMechanisms.indexOf("ULPFEC")!==-1,A=e.matchPrefix(t,"a=ssrc:").map(u=>e.parseSsrcMedia(u)).filter(u=>u.attribute==="cname"),o=A.length>0&&A[0].ssrc;let c;const l=e.matchPrefix(t,"a=ssrc-group:FID").map(u=>u.substring(17).split(" ").map(p=>parseInt(p,10)));l.length>0&&l[0].length>1&&l[0][0]===o&&(c=l[0][1]),i.codecs.forEach(u=>{if(u.name.toUpperCase()==="RTX"&&u.parameters.apt){let h={ssrc:o,codecPayloadType:parseInt(u.parameters.apt,10)};o&&c&&(h.rtx={ssrc:c}),n.push(h),s&&(h=JSON.parse(JSON.stringify(h)),h.fec={ssrc:o,mechanism:a?"red+ulpfec":"red"},n.push(h))}}),n.length===0&&o&&n.push({ssrc:o});let d=e.matchPrefix(t,"b=");return d.length&&(d[0].indexOf("b=TIAS:")===0?d=parseInt(d[0].substring(7),10):d[0].indexOf("b=AS:")===0?d=parseInt(d[0].substring(5),10)*1e3*.95-50*40*8:d=void 0,n.forEach(u=>{u.maxBitrate=d})),n},e.parseRtcpParameters=function(t){const n={},i=e.matchPrefix(t,"a=ssrc:").map(A=>e.parseSsrcMedia(A)).filter(A=>A.attribute==="cname")[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);const s=e.matchPrefix(t,"a=rtcp-rsize");n.reducedSize=s.length>0,n.compound=s.length===0;const a=e.matchPrefix(t,"a=rtcp-mux");return n.mux=a.length>0,n},e.writeRtcpParameters=function(t){let n="";return t.reducedSize&&(n+=`a=rtcp-rsize\r
|
|
21
|
+
`),t.mux&&(n+=`a=rtcp-mux\r
|
|
22
|
+
`),t.ssrc!==void 0&&t.cname&&(n+="a=ssrc:"+t.ssrc+" cname:"+t.cname+`\r
|
|
23
|
+
`),n},e.parseMsid=function(t){let n;const i=e.matchPrefix(t,"a=msid:");if(i.length===1)return n=i[0].substring(7).split(" "),{stream:n[0],track:n[1]};const s=e.matchPrefix(t,"a=ssrc:").map(a=>e.parseSsrcMedia(a)).filter(a=>a.attribute==="msid");if(s.length>0)return n=s[0].value.split(" "),{stream:n[0],track:n[1]}},e.parseSctpDescription=function(t){const n=e.parseMLine(t),i=e.matchPrefix(t,"a=max-message-size:");let s;i.length>0&&(s=parseInt(i[0].substring(19),10)),isNaN(s)&&(s=65536);const a=e.matchPrefix(t,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substring(12),10),protocol:n.fmt,maxMessageSize:s};const A=e.matchPrefix(t,"a=sctpmap:");if(A.length>0){const o=A[0].substring(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:s}}},e.writeSctpDescription=function(t,n){let i=[];return t.protocol!=="DTLS/SCTP"?i=["m="+t.kind+" 9 "+t.protocol+" "+n.protocol+`\r
|
|
24
|
+
`,`c=IN IP4 0.0.0.0\r
|
|
25
|
+
`,"a=sctp-port:"+n.port+`\r
|
|
26
|
+
`]:i=["m="+t.kind+" 9 "+t.protocol+" "+n.port+`\r
|
|
27
|
+
`,`c=IN IP4 0.0.0.0\r
|
|
28
|
+
`,"a=sctpmap:"+n.port+" "+n.protocol+` 65535\r
|
|
29
|
+
`],n.maxMessageSize!==void 0&&i.push("a=max-message-size:"+n.maxMessageSize+`\r
|
|
30
|
+
`),i.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(t,n,i){let s;const a=n!==void 0?n:2;return t?s=t:s=e.generateSessionId(),`v=0\r
|
|
31
|
+
o=`+(i||"thisisadapterortc")+" "+s+" "+a+` IN IP4 127.0.0.1\r
|
|
32
|
+
s=-\r
|
|
33
|
+
t=0 0\r
|
|
34
|
+
`},e.getDirection=function(t,n){const i=e.splitLines(t);for(let s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substring(2)}return n?e.getDirection(n):"sendrecv"},e.getKind=function(t){return e.splitLines(t)[0].split(" ")[0].substring(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){const i=e.splitLines(t)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},e.parseOLine=function(t){const i=e.matchPrefix(t,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;const n=e.splitLines(t);for(let i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},r.exports=e}(gc)),gc.exports}var yg=o4(),Wi=qb(yg),c4=sw({__proto__:null,default:Wi},[yg]);function wA(r){if(!r.RTCIceCandidate||r.RTCIceCandidate&&"foundation"in r.RTCIceCandidate.prototype)return;const e=r.RTCIceCandidate;r.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&(n=JSON.parse(JSON.stringify(n)),n.candidate=n.candidate.substring(2)),n.candidate&&n.candidate.length){const i=new e(n),s=Wi.parseCandidate(n.candidate);for(const a in s)a in i||Object.defineProperty(i,a,{value:s[a]});return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new e(n)},r.RTCIceCandidate.prototype=e.prototype,ki(r,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new r.RTCIceCandidate(t.candidate),writable:"false"}),t))}function Hl(r){!r.RTCIceCandidate||r.RTCIceCandidate&&"relayProtocol"in r.RTCIceCandidate.prototype||ki(r,"icecandidate",e=>{if(e.candidate){const t=Wi.parseCandidate(e.candidate.candidate);t.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e})}function bA(r,e){if(!r.RTCPeerConnection)return;"sctp"in r.RTCPeerConnection.prototype||Object.defineProperty(r.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(A){if(!A||!A.sdp)return!1;const o=Wi.splitSections(A.sdp);return o.shift(),o.some(c=>{const l=Wi.parseMLine(c);return l&&l.kind==="application"&&l.protocol.indexOf("SCTP")!==-1})},n=function(A){const o=A.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(o===null||o.length<2)return-1;const c=parseInt(o[1],10);return c!==c?-1:c},i=function(A){let o=65536;return e.browser==="firefox"&&(e.version<57?A===-1?o=16384:o=2147483637:e.version<60?o=e.version===57?65535:65536:o=2147483637),o},s=function(A,o){let c=65536;e.browser==="firefox"&&e.version===57&&(c=65535);const l=Wi.matchPrefix(A.sdp,"a=max-message-size:");return l.length>0?c=parseInt(l[0].substring(19),10):e.browser==="firefox"&&o!==-1&&(c=2147483637),c},a=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76&&this.getConfiguration().sdpSemantics==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0}),t(arguments[0])){const o=n(arguments[0]),c=i(o),l=s(arguments[0],o);let d;c===0&&l===0?d=Number.POSITIVE_INFINITY:c===0||l===0?d=Math.max(c,l):d=Math.min(c,l);const u={};Object.defineProperty(u,"maxMessageSize",{get(){return d}}),this._sctp=u}return a.apply(this,arguments)}}function BA(r,e){if(!(r.RTCPeerConnection&&"createDataChannel"in r.RTCPeerConnection.prototype)||e.browser==="chrome"&&e.version>149||e.browser==="firefox"&&e.version>60)return;function t(i,s){const a=i.send;i.send=function(){const o=arguments[0],c=o.length||o.size||o.byteLength;if(i.readyState==="open"&&s.sctp&&c>s.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+s.sctp.maxMessageSize+" bytes)");return a.apply(i,arguments)}}const n=r.RTCPeerConnection.prototype.createDataChannel;r.RTCPeerConnection.prototype.createDataChannel=function(){const s=n.apply(this,arguments);return t(s,this),s},ki(r,"datachannel",i=>(t(i.channel,i.target),i))}function Nl(r){if(!r.RTCPeerConnection||"connectionState"in r.RTCPeerConnection.prototype)return;const e=r.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",i);s.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Kl(r,e){if(!r.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e._safariVersion>=13.1)return;const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
|
|
35
|
+
a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
|
|
36
|
+
`).filter(a=>a.trim()!=="a=extmap-allow-mixed").join(`
|
|
37
|
+
`);r.RTCSessionDescription&&i instanceof r.RTCSessionDescription?arguments[0]=new r.RTCSessionDescription({type:i.type,sdp:s}):i.sdp=s}return t.apply(this,arguments)}}function CA(r,e){if(!(r.RTCPeerConnection&&r.RTCPeerConnection.prototype))return;const t=r.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(r.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function SA(r,e){if(!(r.RTCPeerConnection&&r.RTCPeerConnection.prototype))return;const t=r.RTCPeerConnection.prototype.setLocalDescription;!t||t.length===0||(r.RTCPeerConnection.prototype.setLocalDescription=function(){let i=arguments[0]||{};if(typeof i!="object"||i.type&&i.sdp)return t.apply(this,arguments);if(i={type:i.type,sdp:i.sdp},!i.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":i.type="offer";break;default:i.type="answer";break}return i.sdp||i.type!=="offer"&&i.type!=="answer"?t.apply(this,[i]):(i.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(a=>t.apply(this,[a]))})}var l4=Object.freeze({__proto__:null,removeExtmapAllowMixed:Kl,shimAddIceCandidateNullOrEmpty:CA,shimConnectionState:Nl,shimMaxMessageSize:bA,shimParameterlessSetLocalDescription:SA,shimRTCIceCandidate:wA,shimRTCIceCandidateRelayProtocol:Hl,shimSendThrowTypeError:BA});function d4(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=r.window,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const n=Vm,i=a4(e),s={browserDetails:i,commonShim:l4,extractVersion:_s,disableLog:i4,disableWarnings:s4,sdp:c4};switch(i.browser){case"chrome":if(!Q0||!Ll||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),s;if(i.version===null)return n("Chrome shim can not determine version, not shimming."),s;n("adapter.js shimming chrome."),s.browserShim=Q0,CA(e,i),SA(e),Gm(e,i),qm(e),Ll(e,i),Wm(e,i),Jm(e,i),$m(e),jm(e,i),Ym(e,i),wA(e),Hl(e),Nl(e),bA(e,i),BA(e,i),Kl(e,i);break;case"firefox":if(!M0||!Ol||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),s;n("adapter.js shimming firefox."),s.browserShim=M0,CA(e,i),SA(e),Zm(e,i),Ol(e,i),tg(e,i),eg(e),ig(e),ng(e),rg(e),sg(e),ag(e),Ag(e),og(e),cg(e),wA(e),Nl(e),bA(e,i),BA(e,i);break;case"safari":if(!_0||!t.shimSafari)return n("Safari shim is not included in this adapter release."),s;n("adapter.js shimming safari."),s.browserShim=_0,CA(e,i),SA(e),pg(e),gg(e),ug(e),lg(e),dg(e),mg(e),hg(e),vg(e),wA(e),Hl(e),bA(e,i),BA(e,i),Kl(e,i);break;default:n("Unsupported browser!");break}return s}d4({window:typeof window>"u"?void 0:window});var Vl,wg;class Lt extends(wg=Promise){constructor(e){super(e)}catch(e){return super.catch(e)}static reject(e){return super.reject(e)}static all(e){return super.all(e)}static race(e){return super.race(e)}}Vl=Lt;Lt.resolve=r=>Reflect.get(wg,"resolve",Vl).call(Vl,r);const u4=/version\/(\d+(\.?_?\d+)+)/i;let vc;function Ht(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof navigator>"u")return;const t=navigator.userAgent.toLowerCase();if(vc===void 0||e){const n=h4.find(i=>i.test.test(t));vc=n==null?void 0:n.describe(t)}return vc}const h4=[{test:/firefox|iceweasel|fxios/i,describe(r){return{name:"Firefox",version:kA(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,r),os:r.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:yc(r)}}},{test:/chrom|crios|crmo/i,describe(r){return{name:"Chrome",version:kA(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,r),os:r.toLowerCase().includes("crios")?"iOS":void 0,osVersion:yc(r)}}},{test:/safari|applewebkit/i,describe(r){return{name:"Safari",version:kA(u4,r),os:r.includes("mobile/")?"iOS":"macOS",osVersion:yc(r)}}}];function kA(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;const n=e.match(r);return n&&n.length>=t&&n[t]||""}function yc(r){return r.includes("mac os")?kA(/\(.+?(\d+_\d+(:?_\d+)?)/,r,1).replace(/_/g,"."):void 0}var f4="2.20.0";const p4=f4,m4=17,bg=0,jA=1,g4=jA;class Sr extends Error{constructor(e,t,n){super(t||"an error has occurred"),this.name="LiveKitError",this.code=e,typeof(n==null?void 0:n.cause)<"u"&&(this.cause=n==null?void 0:n.cause)}}class wn extends Sr{}var Pe;(function(r){r[r.NotAllowed=0]="NotAllowed",r[r.ServerUnreachable=1]="ServerUnreachable",r[r.InternalError=2]="InternalError",r[r.Cancelled=3]="Cancelled",r[r.LeaveRequest=4]="LeaveRequest",r[r.Timeout=5]="Timeout",r[r.WebSocket=6]="WebSocket",r[r.ServiceNotFound=7]="ServiceNotFound"})(Pe||(Pe={}));class oe extends wn{constructor(e,t,n,i){super(1,e),this.name="ConnectionError",this.status=n,this.reason=t,this.context=i,this.reasonName=Pe[t]}static notAllowed(e,t,n){return new oe(e,Pe.NotAllowed,t,n)}static timeout(e){return new oe(e,Pe.Timeout)}static leaveRequest(e,t){return new oe(e,Pe.LeaveRequest,void 0,t)}static internal(e,t){return new oe(e,Pe.InternalError,void 0,t)}static cancelled(e){return new oe(e,Pe.Cancelled)}static serverUnreachable(e,t){return new oe(e,Pe.ServerUnreachable,t)}static websocket(e,t,n){return new oe(e,Pe.WebSocket,t,n)}static serviceNotFound(e,t){return new oe(e,Pe.ServiceNotFound,void 0,t)}}class Au extends Sr{constructor(e){super(21,e??"device is unsupported"),this.name="DeviceUnsupportedError"}}class mr extends Sr{constructor(e){super(20,e??"track is invalid"),this.name="TrackInvalidError"}}class v4 extends Sr{constructor(e){super(10,e??"unsupported server"),this.name="UnsupportedServer"}}class Xe extends Sr{constructor(e){super(12,e??"unexpected connection state"),this.name="UnexpectedConnectionState"}}class mi extends Sr{constructor(e){super(13,e??"unable to negotiate"),this.name="NegotiationError"}}class y4 extends Sr{constructor(e){super(14,e??"unable to publish data"),this.name="PublishDataError"}}class P0 extends Sr{constructor(e,t){super(15,e),this.name="PublishTrackError",this.status=t}}class D0 extends wn{constructor(e,t){super(15,e),this.name="SignalRequestError",this.reason=t,this.reasonName=typeof t=="string"?t:Ai[t]}}var Pt;(function(r){r[r.AlreadyOpened=0]="AlreadyOpened",r[r.AbnormalEnd=1]="AbnormalEnd",r[r.DecodeFailed=2]="DecodeFailed",r[r.LengthExceeded=3]="LengthExceeded",r[r.Incomplete=4]="Incomplete",r[r.HandlerAlreadyRegistered=7]="HandlerAlreadyRegistered",r[r.EncryptionTypeMismatch=8]="EncryptionTypeMismatch"})(Pt||(Pt={}));class dn extends wn{constructor(e,t){super(16,e),this.name="DataStreamError",this.reason=t,this.reasonName=Pt[t]}}class Qi extends Sr{constructor(e){super(18,e),this.name="SignalReconnectError"}}var XA;(function(r){r.PermissionDenied="PermissionDenied",r.NotFound="NotFound",r.DeviceInUse="DeviceInUse",r.Other="Other"})(XA||(XA={}));(function(r){function e(t){if(t&&"name"in t)return t.name==="NotFoundError"||t.name==="DevicesNotFoundError"?r.NotFound:t.name==="NotAllowedError"||t.name==="PermissionDeniedError"?r.PermissionDenied:t.name==="NotReadableError"||t.name==="TrackStartError"?r.DeviceInUse:r.Other}r.getFailure=e})(XA||(XA={}));class dt{}dt.setTimeout=function(){return setTimeout(...arguments)};dt.setInterval=function(){return setInterval(...arguments)};dt.clearTimeout=function(){return clearTimeout(...arguments)};dt.clearInterval=function(){return clearInterval(...arguments)};var V;(function(r){r.Connected="connected",r.Reconnecting="reconnecting",r.SignalReconnecting="signalReconnecting",r.Reconnected="reconnected",r.Disconnected="disconnected",r.ConnectionStateChanged="connectionStateChanged",r.Moved="moved",r.MediaDevicesChanged="mediaDevicesChanged",r.ParticipantConnected="participantConnected",r.ParticipantDisconnected="participantDisconnected",r.TrackPublished="trackPublished",r.TrackSubscribed="trackSubscribed",r.TrackSubscriptionFailed="trackSubscriptionFailed",r.TrackUnpublished="trackUnpublished",r.TrackUnsubscribed="trackUnsubscribed",r.TrackMuted="trackMuted",r.TrackUnmuted="trackUnmuted",r.LocalTrackPublished="localTrackPublished",r.LocalTrackUnpublished="localTrackUnpublished",r.LocalAudioSilenceDetected="localAudioSilenceDetected",r.ActiveSpeakersChanged="activeSpeakersChanged",r.ParticipantMetadataChanged="participantMetadataChanged",r.ParticipantNameChanged="participantNameChanged",r.ParticipantAttributesChanged="participantAttributesChanged",r.ParticipantActive="participantActive",r.RoomMetadataChanged="roomMetadataChanged",r.DataReceived="dataReceived",r.SipDTMFReceived="sipDTMFReceived",r.TranscriptionReceived="transcriptionReceived",r.ConnectionQualityChanged="connectionQualityChanged",r.TrackStreamStateChanged="trackStreamStateChanged",r.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",r.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",r.AudioPlaybackStatusChanged="audioPlaybackChanged",r.VideoPlaybackStatusChanged="videoPlaybackChanged",r.MediaDevicesError="mediaDevicesError",r.ParticipantPermissionsChanged="participantPermissionsChanged",r.SignalConnected="signalConnected",r.RecordingStatusChanged="recordingStatusChanged",r.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",r.EncryptionError="encryptionError",r.DCBufferStatusChanged="dcBufferStatusChanged",r.ActiveDeviceChanged="activeDeviceChanged",r.ChatMessage="chatMessage",r.LocalTrackSubscribed="localTrackSubscribed",r.MetricsReceived="metricsReceived",r.DataTrackPublished="dataTrackPublished",r.DataTrackUnpublished="dataTrackUnpublished",r.LocalDataTrackPublished="localDataTrackPublished",r.LocalDataTrackUnpublished="localDataTrackUnpublished"})(V||(V={}));var X;(function(r){r.TrackPublished="trackPublished",r.TrackSubscribed="trackSubscribed",r.TrackSubscriptionFailed="trackSubscriptionFailed",r.TrackUnpublished="trackUnpublished",r.TrackUnsubscribed="trackUnsubscribed",r.TrackMuted="trackMuted",r.TrackUnmuted="trackUnmuted",r.LocalTrackPublished="localTrackPublished",r.LocalTrackUnpublished="localTrackUnpublished",r.LocalTrackCpuConstrained="localTrackCpuConstrained",r.LocalSenderCreated="localSenderCreated",r.ParticipantMetadataChanged="participantMetadataChanged",r.ParticipantNameChanged="participantNameChanged",r.DataReceived="dataReceived",r.SipDTMFReceived="sipDTMFReceived",r.TranscriptionReceived="transcriptionReceived",r.IsSpeakingChanged="isSpeakingChanged",r.ConnectionQualityChanged="connectionQualityChanged",r.TrackStreamStateChanged="trackStreamStateChanged",r.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",r.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",r.TrackCpuConstrained="trackCpuConstrained",r.MediaDevicesError="mediaDevicesError",r.AudioStreamAcquired="audioStreamAcquired",r.ParticipantPermissionsChanged="participantPermissionsChanged",r.PCTrackAdded="pcTrackAdded",r.AttributesChanged="attributesChanged",r.LocalTrackSubscribed="localTrackSubscribed",r.ChatMessage="chatMessage",r.Active="active"})(X||(X={}));var G;(function(r){r.TransportsCreated="transportsCreated",r.Connected="connected",r.Disconnected="disconnected",r.Resuming="resuming",r.Resumed="resumed",r.Restarting="restarting",r.Restarted="restarted",r.SignalResumed="signalResumed",r.SignalRestarted="signalRestarted",r.Closing="closing",r.MediaTrackAdded="mediaTrackAdded",r.ActiveSpeakersUpdate="activeSpeakersUpdate",r.DataPacketReceived="dataPacketReceived",r.RTPVideoMapUpdate="rtpVideoMapUpdate",r.DCBufferStatusChanged="dcBufferStatusChanged",r.ParticipantUpdate="participantUpdate",r.RoomUpdate="roomUpdate",r.SpeakersChanged="speakersChanged",r.StreamStateChanged="streamStateChanged",r.ConnectionQualityUpdate="connectionQualityUpdate",r.SubscriptionError="subscriptionError",r.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",r.RemoteMute="remoteMute",r.SubscribedQualityUpdate="subscribedQualityUpdate",r.LocalTrackUnpublished="localTrackUnpublished",r.LocalTrackSubscribed="localTrackSubscribed",r.Offline="offline",r.SignalRequestResponse="signalRequestResponse",r.SignalConnected="signalConnected",r.RoomMoved="roomMoved",r.PublishDataTrackResponse="publishDataTrackResponse",r.UnPublishDataTrackResponse="unPublishDataTrackResponse",r.DataTrackSubscriberHandles="dataTrackSubscriberHandles",r.DataTrackPacketReceived="dataTrackPacketReceived",r.Joined="joined",r.TokenRefreshed="tokenRefreshed",r.ServerRegionsReported="serverRegionsReported"})(G||(G={}));var $;(function(r){r.Message="message",r.Muted="muted",r.Unmuted="unmuted",r.Restarted="restarted",r.Ended="ended",r.Subscribed="subscribed",r.Unsubscribed="unsubscribed",r.CpuConstrained="cpuConstrained",r.UpdateSettings="updateSettings",r.UpdateSubscription="updateSubscription",r.AudioPlaybackStarted="audioPlaybackStarted",r.AudioPlaybackFailed="audioPlaybackFailed",r.AudioSilenceDetected="audioSilenceDetected",r.VisibilityChanged="visibilityChanged",r.VideoDimensionsChanged="videoDimensionsChanged",r.VideoPlaybackStarted="videoPlaybackStarted",r.VideoPlaybackFailed="videoPlaybackFailed",r.ElementAttached="elementAttached",r.ElementDetached="elementDetached",r.UpstreamPaused="upstreamPaused",r.UpstreamResumed="upstreamResumed",r.SubscriptionPermissionChanged="subscriptionPermissionChanged",r.SubscriptionStatusChanged="subscriptionStatusChanged",r.SubscriptionFailed="subscriptionFailed",r.TrackProcessorUpdate="trackProcessorUpdate",r.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",r.TranscriptionReceived="transcriptionReceived",r.TimeSyncUpdate="timeSyncUpdate",r.PreConnectBufferFlushed="preConnectBufferFlushed"})($||($={}));function w4(r){return typeof r>"u"?r:typeof structuredClone=="function"?typeof r=="object"&&r!==null?structuredClone(Object.assign({},r)):structuredClone(r):JSON.parse(JSON.stringify(r))}class Me{constructor(e,t,n,i,s){if(typeof e=="object")this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else if(t!==void 0&&n!==void 0)this.width=e,this.height=t,this.aspectRatio=e/t,this.encoding={maxBitrate:n,maxFramerate:i,priority:s};else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate")}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const b4=["vp8","h264"],B4=["vp8","h264","vp9","av1","h265"];function Bg(r){return!!b4.find(e=>e===r)}const C4=Bg;var L0;(function(r){r[r.PREFER_REGRESSION=0]="PREFER_REGRESSION",r[r.SIMULCAST=1]="SIMULCAST",r[r.REGRESSION=2]="REGRESSION"})(L0||(L0={}));var zl;(function(r){r.telephone={maxBitrate:12e3},r.speech={maxBitrate:24e3},r.music={maxBitrate:48e3},r.musicStereo={maxBitrate:64e3},r.musicHighQuality={maxBitrate:96e3},r.musicHighQualityStereo={maxBitrate:128e3}})(zl||(zl={}));const ca={h90:new Me(160,90,9e4,20),h180:new Me(320,180,16e4,20),h216:new Me(384,216,18e4,20),h360:new Me(640,360,45e4,20),h540:new Me(960,540,8e5,25),h720:new Me(1280,720,17e5,30),h1080:new Me(1920,1080,3e6,30),h1440:new Me(2560,1440,5e6,30),h2160:new Me(3840,2160,8e6,30)},Gl={h120:new Me(160,120,7e4,20),h180:new Me(240,180,125e3,20),h240:new Me(320,240,14e4,20),h360:new Me(480,360,33e4,20),h480:new Me(640,480,5e5,20),h540:new Me(720,540,6e5,25),h720:new Me(960,720,13e5,30),h1080:new Me(1440,1080,23e5,30),h1440:new Me(1920,1440,38e5,30)},ou={h360fps3:new Me(640,360,2e5,3,"medium"),h360fps15:new Me(640,360,4e5,15,"medium"),h720fps5:new Me(1280,720,8e5,5,"medium"),h720fps15:new Me(1280,720,15e5,15,"medium"),h720fps30:new Me(1280,720,2e6,30,"medium"),h1080fps15:new Me(1920,1080,25e5,15,"medium"),h1080fps30:new Me(1920,1080,5e6,30,"medium"),original:new Me(0,0,7e6,30,"medium")};function Cg(r,e,t){var n,i,s,a;const A=Tg(r??{}),o=A.optionsWithoutProcessor,c=A.audioProcessor,l=A.videoProcessor,d=e==null?void 0:e.processor,u=t==null?void 0:t.processor,h=o??{};return h.audio===!0&&(h.audio={}),h.video===!0&&(h.video={}),h.audio&&(ql(h.audio,e),(n=(s=h.audio).deviceId)!==null&&n!==void 0||(s.deviceId={ideal:"default"}),(c||d)&&(h.audio.processor=c??d)),h.video&&(ql(h.video,t),(i=(a=h.video).deviceId)!==null&&i!==void 0||(a.deviceId={ideal:"default"}),(l||u)&&(h.video.processor=l??u)),h}function ql(r,e){return Object.keys(e).forEach(t=>{r[t]===void 0&&(r[t]=e[t])}),r}function cu(r){var e,t,n,i;const s={};if(r.video)if(typeof r.video=="object"){const a={},A=a,o=r.video;Object.keys(o).forEach(c=>{switch(c){case"resolution":ql(A,o.resolution);break;default:A[c]=o[c]}}),s.video=a,(e=(n=s.video).deviceId)!==null&&e!==void 0||(n.deviceId={ideal:"default"})}else s.video=r.video?{deviceId:{ideal:"default"}}:!1;else s.video=!1;return r.audio?typeof r.audio=="object"?(s.audio=r.audio,(t=(i=s.audio).deviceId)!==null&&t!==void 0||(i.deviceId={ideal:"default"})):s.audio={deviceId:{ideal:"default"}}:s.audio=!1,s}function Sg(r){return k(this,arguments,void 0,function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return function*(){const n=kg();if(n){const i=n.createAnalyser();i.fftSize=2048;const s=i.frequencyBinCount,a=new Uint8Array(s);n.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(i),yield Qt(t),i.getByteTimeDomainData(a);const o=a.some(c=>c!==128&&c!==0);return n.close(),!o}return!1}()})}function kg(){var r;const e=typeof window<"u"&&(window.AudioContext||window.webkitAudioContext);if(e){const t=new e({latencyHint:"interactive"});if(t.state==="suspended"&&typeof window<"u"&&(!((r=window.document)===null||r===void 0)&&r.body)){const n=()=>k(this,void 0,void 0,function*(){var i;try{t.state==="suspended"&&(yield t.resume())}catch{}finally{(i=window.document.body)===null||i===void 0||i.removeEventListener("click",n)}});t.addEventListener("statechange",()=>{var i;t.state==="closed"&&((i=window.document.body)===null||i===void 0||i.removeEventListener("click",n))}),window.document.body.addEventListener("click",n)}return t}}function S4(r){return r==="audioinput"?N.Source.Microphone:r==="videoinput"?N.Source.Camera:N.Source.Unknown}function Wl(r){return r===N.Source.Microphone?"audioinput":r===N.Source.Camera?"videoinput":void 0}function k4(r){var e,t;let n=(e=r.video)!==null&&e!==void 0?e:!0;return r.resolution&&r.resolution.width>0&&r.resolution.height>0&&(n=typeof n=="boolean"?{}:n,Si()?n=Object.assign(Object.assign({},n),{width:{max:r.resolution.width},height:{max:r.resolution.height},frameRate:r.resolution.frameRate}):n=Object.assign(Object.assign({},n),{width:{ideal:r.resolution.width},height:{ideal:r.resolution.height},frameRate:r.resolution.frameRate})),{audio:(t=r.audio)!==null&&t!==void 0?t:!1,video:n,controller:r.controller,selfBrowserSurface:r.selfBrowserSurface,surfaceSwitching:r.surfaceSwitching,systemAudio:r.systemAudio,preferCurrentTab:r.preferCurrentTab}}function Ws(r){return r.split("/")[1].toLowerCase()}function T4(r){const e=[];return r.forEach(t=>{t.track!==void 0&&e.push(new nu({cid:t.track.mediaStreamID,track:t.trackInfo}))}),e}function we(r){return"mediaStreamTrack"in r?{trackID:r.sid,source:r.source,muted:r.isMuted,enabled:r.mediaStreamTrack.enabled,kind:r.kind,streamID:r.mediaStreamID,streamTrackID:r.mediaStreamTrack.id}:{trackID:r.trackSid,enabled:r.isEnabled,muted:r.isMuted,trackInfo:Object.assign({mimeType:r.mimeType,name:r.trackName,encrypted:r.isEncrypted,kind:r.kind,source:r.source},r.track?we(r.track):{})}}function x4(){return typeof RTCRtpReceiver<"u"&&typeof RTCRtpReceiver.prototype.getSynchronizationSources=="function"}function E4(r,e){var t;r===void 0&&(r={}),e===void 0&&(e={});const n=[...Object.keys(e),...Object.keys(r)],i={};for(const s of n)r[s]!==e[s]&&(i[s]=(t=e[s])!==null&&t!==void 0?t:"");return i}function Tg(r){const e=Object.assign({},r);let t,n;return typeof e.audio=="object"&&e.audio.processor&&(t=e.audio.processor,e.audio=Object.assign(Object.assign({},e.audio),{processor:void 0})),typeof e.video=="object"&&e.video.processor&&(n=e.video.processor,e.video=Object.assign(Object.assign({},e.video),{processor:void 0})),{audioProcessor:t,videoProcessor:n,optionsWithoutProcessor:w4(e)}}function U4(r){switch(r){case ct.CAMERA:return N.Source.Camera;case ct.MICROPHONE:return N.Source.Microphone;case ct.SCREEN_SHARE:return N.Source.ScreenShare;case ct.SCREEN_SHARE_AUDIO:return N.Source.ScreenShareAudio;default:return N.Source.Unknown}}function O0(r,e){return r.width*r.height<e.width*e.height}function F4(r,e){var t;return(t=r.layers)===null||t===void 0?void 0:t.find(n=>n.quality===e)}const I4=5e3,bs=[];var sn;(function(r){r[r.LOW=0]="LOW",r[r.MEDIUM=1]="MEDIUM",r[r.HIGH=2]="HIGH"})(sn||(sn={}));class N extends Yt.EventEmitter{get streamState(){return this._streamState}setStreamState(e){this._streamState=e}constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var i;super(),this.attachedElements=[],this.isMuted=!1,this._streamState=N.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=me,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),I4):this.handleAppVisibilityChanged()},this.log=Xt((i=n.loggerName)!==null&&i!==void 0?i:Ct.Track),this.loggerContextCb=n.loggerContextCb,this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=N.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),we(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let t="audio";this.kind===N.Kind.Video&&(t="video"),this.attachedElements.length===0&&this.kind===N.Kind.Video&&this.addAppVisibilityListener(),e||(t==="audio"&&(bs.forEach(s=>{s.parentElement===null&&!e&&(e=s)}),e&&bs.splice(bs.indexOf(e),1)),e||(e=document.createElement(t))),this.attachedElements.includes(e)||this.attachedElements.push(e),Vi(this.mediaStreamTrack,e);const n=e.srcObject.getTracks(),i=n.some(s=>s.kind==="audio");return e.play().then(()=>{this.emit(i?$.AudioPlaybackStarted:$.VideoPlaybackStarted)}).catch(s=>{s.name==="NotAllowedError"?this.emit(i?$.AudioPlaybackFailed:$.VideoPlaybackFailed,s):s.name==="AbortError"?me.debug("".concat(i?"audio":"video"," playback aborted, likely due to new play request")):me.warn("could not playback ".concat(i?"audio":"video"),s),i&&e&&n.some(a=>a.kind==="video")&&s.name==="NotAllowedError"&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit($.ElementAttached,e),e}detach(e){try{if(e){$i(this.mediaStreamTrack,e);const n=this.attachedElements.indexOf(e);return n>=0&&(this.attachedElements.splice(n,1),this.recycleElement(e),this.emit($.ElementDetached,e)),e}const t=[];return this.attachedElements.forEach(n=>{$i(this.mediaStreamTrack,n),t.push(n),this.recycleElement(n),this.emit($.ElementDetached,n)}),this.attachedElements=[],t}finally{this.attachedElements.length===0&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=Xt(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),bs.forEach(n=>{n.parentElement||(t=!1)}),t&&bs.push(e)}}handleAppVisibilityChanged(){return k(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===N.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){$t()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){$t()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function Vi(r,e){let t;e.srcObject instanceof MediaStream?t=e.srcObject:t=new MediaStream;let n;r.kind==="audio"?n=t.getAudioTracks():n=t.getVideoTracks(),n.includes(r)||(n.forEach(i=>{t.removeTrack(i)}),t.addTrack(r)),(!Si()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=t.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==t&&(e.srcObject=t,(Si()||Ci())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=t,e.play().catch(()=>{})},0))}function $i(r,e){if(e.srcObject instanceof MediaStream){const t=e.srcObject;t.removeTrack(r),t.getTracks().length>0?e.srcObject=t:e.srcObject=null}}(function(r){let e;(function(c){c.Audio="audio",c.Video="video",c.Unknown="unknown"})(e=r.Kind||(r.Kind={}));let t;(function(c){c.Camera="camera",c.Microphone="microphone",c.ScreenShare="screen_share",c.ScreenShareAudio="screen_share_audio",c.Unknown="unknown"})(t=r.Source||(r.Source={}));let n;(function(c){c.Active="active",c.Paused="paused",c.Unknown="unknown"})(n=r.StreamState||(r.StreamState={}));function i(c){switch(c){case e.Audio:return Tn.AUDIO;case e.Video:return Tn.VIDEO;default:return Tn.DATA}}r.kindToProto=i;function s(c){switch(c){case Tn.AUDIO:return e.Audio;case Tn.VIDEO:return e.Video;default:return e.Unknown}}r.kindFromProto=s;function a(c){switch(c){case t.Camera:return ct.CAMERA;case t.Microphone:return ct.MICROPHONE;case t.ScreenShare:return ct.SCREEN_SHARE;case t.ScreenShareAudio:return ct.SCREEN_SHARE_AUDIO;default:return ct.UNKNOWN}}r.sourceToProto=a;function A(c){switch(c){case ct.CAMERA:return t.Camera;case ct.MICROPHONE:return t.Microphone;case ct.SCREEN_SHARE:return t.ScreenShare;case ct.SCREEN_SHARE_AUDIO:return t.ScreenShareAudio;default:return t.Unknown}}r.sourceFromProto=A;function o(c){switch(c){case Ml.ACTIVE:return n.Active;case Ml.PAUSED:return n.Paused;default:return n.Unknown}}r.streamStateFromProto=o})(N||(N={}));const Q4="|",H0="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function M4(r){const e=r.split(Q4);return e.length>1?[e[0],r.substr(e[0].length+1)]:[r,""]}function Qt(r){return new Lt(e=>dt.setTimeout(e,r))}function $l(){return"addTransceiver"in RTCPeerConnection.prototype}function jl(){return"addTrack"in RTCPeerConnection.prototype}function _4(){if(!("getCapabilities"in RTCRtpSender)||Si()||Ci())return!1;const r=RTCRtpSender.getCapabilities("video");let e=!1;if(r){for(const t of r.codecs)if(t.mimeType.toLowerCase()==="video/av1"){e=!0;break}}return e}function R4(){if(!("getCapabilities"in RTCRtpSender)||Ci())return!1;if(Si()){const t=Ht();if(t!=null&&t.version&&Jn(t.version,"16")<0||(t==null?void 0:t.os)==="iOS"&&(t!=null&&t.osVersion)&&Jn(t.osVersion,"16")<0)return!1}const r=RTCRtpSender.getCapabilities("video");let e=!1;if(r){for(const t of r.codecs)if(t.mimeType.toLowerCase()==="video/vp9"){e=!0;break}}return e}function Un(r){return r==="av1"||r==="vp9"}function Xl(r){return!document||la()?!1:(r||(r=document.createElement("audio")),"setSinkId"in r)}function P4(){return typeof RTCPeerConnection>"u"?!1:$l()||jl()}function Ci(){var r;return((r=Ht())===null||r===void 0?void 0:r.name)==="Firefox"}function D4(){const r=Ht();return!!r&&r.name==="Chrome"&&r.os!=="iOS"}function Jl(){return typeof window<"u"&&typeof window.RTCRtpScriptTransform<"u"&&!D4()}function Si(){var r;return((r=Ht())===null||r===void 0?void 0:r.name)==="Safari"}function la(){const r=Ht();return(r==null?void 0:r.name)==="Safari"||(r==null?void 0:r.os)==="iOS"}function L4(){const r=Ht();return(r==null?void 0:r.name)==="Safari"&&r.version.startsWith("17.")||(r==null?void 0:r.os)==="iOS"&&!!(r!=null&&r.osVersion)&&Jn(r.osVersion,"17")>=0}function O4(r){return r||(r=Ht()),(r==null?void 0:r.name)==="Safari"&&Jn(r.version,"18.3")>0||(r==null?void 0:r.os)==="iOS"&&!!(r!=null&&r.osVersion)&&Jn(r.osVersion,"18.3")>0}function xg(){var r,e;return $t()?(e=(r=navigator.userAgentData)===null||r===void 0?void 0:r.mobile)!==null&&e!==void 0?e:/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent):!1}function H4(){const r=Ht(),e="17.2";if(r)return r.name!=="Safari"&&r.os!=="iOS"||r.os==="iOS"&&r.osVersion&&Jn(r.osVersion,e)>=0?!0:r.name==="Safari"&&Jn(r.version,e)>=0}function $t(){return typeof document<"u"}function Rn(){return navigator.product=="ReactNative"}function as(r){return r.hostname.endsWith(".livekit.cloud")||r.hostname.endsWith(".livekit.run")}function wc(r){return as(r)?r.hostname.split(".")[0]:null}function Eg(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function Ug(){if(!Rn())return;let r=Eg();if(r)return r.platform}function N0(){if($t())return window.devicePixelRatio;if(Rn()){let r=Eg();if(r)return r.devicePixelRatio}return 1}function Jn(r,e){const t=r.split("."),n=e.split("."),i=Math.min(t.length,n.length);for(let s=0;s<i;++s){const a=parseInt(t[s],10),A=parseInt(n[s],10);if(a>A)return 1;if(a<A)return-1;if(s===i-1&&a===A)return 0}return r===""&&e!==""?-1:e===""?1:t.length==n.length?0:t.length<n.length?-1:1}function N4(r){for(const e of r)e.target.handleResize(e)}function K4(r){for(const e of r)e.target.handleVisibilityChanged(e)}let bc=null;const K0=()=>(bc||(bc=new ResizeObserver(N4)),bc);let Bc=null;const V0=()=>(Bc||(Bc=new IntersectionObserver(K4,{root:null,rootMargin:"0px"})),Bc);function V4(r){var e;const t=new Cm({capabilities:r,sdk:Sm.JS,protocol:m4,clientProtocol:g4,version:p4});return Rn()&&(t.os=(e=Ug())!==null&&e!==void 0?e:""),t}function z0(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:16,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const i=document.createElement("canvas");i.width=r,i.height=e;const s=i.getContext("2d");s==null||s.fillRect(0,0,i.width,i.height),n&&s&&(s.beginPath(),s.arc(r/2,e/2,50,0,Math.PI*2,!0),s.closePath(),s.fillStyle="grey",s.fill());const A=i.captureStream().getTracks(),o=Ae(A,1),c=o[0];if(!c)throw Error("Could not get empty media stream video track");return c.enabled=t,c}let Bs;function Cc(){if(!Bs){const t=new AudioContext,n=t.createOscillator(),i=t.createGain();i.gain.setValueAtTime(0,0);const s=t.createMediaStreamDestination();n.connect(i),i.connect(s),n.start();var r=s.stream.getAudioTracks(),e=Ae(r,1);if(Bs=e[0],!Bs)throw Error("Could not get empty media stream audio track");Bs.enabled=!1}return Bs.clone()}class Bt{get isResolved(){return this._isResolved}constructor(e,t){this._isResolved=!1,this.onFinally=t,this.promise=new Promise((n,i)=>k(this,void 0,void 0,function*(){this.resolve=n,this.reject=i,e&&(yield e(n,i))})).finally(()=>{var n;this._isResolved=!0,(n=this.onFinally)===null||n===void 0||n.call(this)})}}function z4(r){return B4.includes(r)}function gi(r){if(typeof r=="string"||typeof r=="number")return r;if(Array.isArray(r))return r[0];if(r.exact!==void 0)return Array.isArray(r.exact)?r.exact[0]:r.exact;if(r.ideal!==void 0)return Array.isArray(r.ideal)?r.ideal[0]:r.ideal;throw Error("could not unwrap constraint")}function G4(r){return r.startsWith("http")?r.replace(/^(http)/,"ws"):r}function da(r){return r.startsWith("ws")?r.replace(/^(ws)/,"http"):r}function q4(r,e){return r.segments.map(t=>{let n=t.id,i=t.text,s=t.language,a=t.startTime,A=t.endTime,o=t.final;var c;const l=(c=e.get(n))!==null&&c!==void 0?c:Date.now(),d=Date.now();return o?e.delete(n):e.set(n,l),{id:n,text:i,startTime:Number.parseInt(a.toString()),endTime:Number.parseInt(A.toString()),final:o,language:s,firstReceivedTime:l,lastReceivedTime:d}})}function W4(r){const e=r.id,t=r.timestamp,n=r.message,i=r.editTimestamp;return{id:e,timestamp:Number.parseInt(t.toString()),editTimestamp:i?Number.parseInt(i.toString()):void 0,message:n}}function G0(r){switch(r.reason){case Pe.LeaveRequest:return r.context;case Pe.Cancelled:return Qn.CLIENT_INITIATED;case Pe.NotAllowed:return Qn.USER_REJECTED;case Pe.ServerUnreachable:return Qn.JOIN_FAILURE;default:return Qn.UNKNOWN_REASON}}function TA(r){return r!==void 0?Number(r):void 0}function ai(r){return r!==void 0?BigInt(r):void 0}function ji(r){return!!r&&!(r instanceof MediaStreamTrack)&&r.isLocal}function $n(r){return!!r&&r.kind==N.Kind.Audio}function wr(r){return!!r&&r.kind==N.Kind.Video}function Ln(r){return ji(r)&&wr(r)}function or(r){return ji(r)&&$n(r)}function Yl(r){return!!r&&!r.isLocal}function $4(r){return!!r&&!r.isLocal}function Sc(r){return Yl(r)&&wr(r)}function j4(r){return r.isLocal}function X4(r,e){const t=[];let n=new TextEncoder().encode(r);for(;n.length>e;){let i=e;for(;i>0;){const s=n[i];if(s!==void 0&&(s&192)!==128)break;i--}t.push(n.slice(0,i)),n=n.slice(i)}return n.length>0&&t.push(n),t}function J4(r){var e;const t=r.get("Cache-Control");if(t){const n=(e=t.match(/(?:^|[,\s])max-age=(\d+)/))===null||e===void 0?void 0:e[1];if(n)return parseInt(n,10)}}function Fg(){return typeof CompressionStream<"u"}function Y4(){return Fg()&&!Ci()}function Z4(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const n=e2(r,e);return t?n:lu(n,"v1")}function e2(r,e){const t=new URL(G4(r));return e.forEach((n,i)=>{t.searchParams.set(i,n)}),lu(t,"rtc")}function t2(r){const e=new URL(da(r));return lu(e,"validate")}function Ig(r){return r.endsWith("/")?r:"".concat(r,"/")}function lu(r,e){return r.pathname="".concat(Ig(r.pathname)).concat(e),r}function q0(r){if(typeof r=="string")return k0.fromJson(JSON.parse(r),{ignoreUnknownFields:!0});if(r instanceof ArrayBuffer)return k0.fromBinary(new Uint8Array(r));throw new Error("could not decode websocket message: ".concat(typeof r))}function n2(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Unknown reason";if(!(r instanceof AbortSignal))return e;const t=r.reason;switch(typeof t){case"string":return t;case"object":return t instanceof Error?t.message:e;default:return"toString"in t?t.toString():e}}const r2=10,Cs="lk_e2ee",i2="LKFrameEncryptionKey",s2={sharedKey:!1,ratchetSalt:i2,ratchetWindowSize:8,failureTolerance:r2,keyringSize:16,keySize:128};var Kr;(function(r){r.SetKey="setKey",r.RatchetRequest="ratchetRequest",r.KeyRatcheted="keyRatcheted"})(Kr||(Kr={}));var W0;(function(r){r.KeyRatcheted="keyRatcheted"})(W0||(W0={}));var Pr;(function(r){r.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",r.EncryptionError="encryptionError"})(Pr||(Pr={}));var $0;(function(r){r.Error="cryptorError"})($0||($0={}));function a2(){return du()||A2()}function A2(){return typeof window<"u"&&typeof window.RTCRtpScriptTransform<"u"}function du(){return typeof window<"u"&&typeof window.RTCRtpSender<"u"&&typeof window.RTCRtpSender.prototype.createEncodedStreams<"u"}function o2(r){var e,t,n,i,s;if(((e=r.value)===null||e===void 0?void 0:e.case)!=="sipDtmf"&&((t=r.value)===null||t===void 0?void 0:t.case)!=="metrics"&&((n=r.value)===null||n===void 0?void 0:n.case)!=="speaker"&&((i=r.value)===null||i===void 0?void 0:i.case)!=="transcription"&&((s=r.value)===null||s===void 0?void 0:s.case)!=="encryptedPacket")return new mm({value:r.value})}class aF extends Yt.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.latestManuallySetKeyIndex=0,this.onKeyRatcheted=(t,n,i)=>{me.debug("key ratcheted event received",{ratchetResult:t,participantId:n,keyIndex:i})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},s2),e),this.on(Kr.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(e,t,n){const i={key:e,participantIdentity:t,keyIndex:n};if(!this.options.sharedKey&&!t)throw new Error("participant identity needs to be passed for encryption key if sharedKey option is false");this.keyInfoMap.set("".concat(t??"shared","-").concat(n??0),i),n!==void 0&&(this.latestManuallySetKeyIndex=n),this.emit(Kr.SetKey,i,n!==void 0)}getKeys(){return Array.from(this.keyInfoMap.values())}getLatestManuallySetKeyIndex(){return this.latestManuallySetKeyIndex}getOptions(){return this.options}ratchetKey(e,t){this.emit(Kr.RatchetRequest,e,t)}}var j0;(function(r){r[r.InvalidKey=0]="InvalidKey",r[r.MissingKey=1]="MissingKey",r[r.InternalError=2]="InternalError"})(j0||(j0={}));function ua(){return Jl()}function ha(r){return!!(r!=null&&r.worker)&&(du()||ua())}function JA(r){return!!(r!=null&&r.timestamp||r!=null&&r.frameId)}function c2(r){const e=[];return r!=null&&r.timestamp&&e.push(is.PTF_USER_TIMESTAMP),r!=null&&r.frameId&&e.push(is.PTF_FRAME_ID),e}function l2(r){if(!r||r.length===0)return;const e={};return r.includes(is.PTF_USER_TIMESTAMP)&&(e.timestamp=!0),r.includes(is.PTF_FRAME_ID)&&(e.frameId=!0),e.timestamp||e.frameId?e:void 0}function uu(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:50,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n,i;let s;const a=(n=t.isImmediate)!==null&&n!==void 0?n:!1,A=(i=t.callback)!==null&&i!==void 0?i:!1,o=t.maxWait;let c=Date.now(),l=[];function d(){if(o!==void 0){const h=Date.now()-c;if(h+e>=o)return o-h}return e}const u=function(){for(var h=arguments.length,p=new Array(h),g=0;g<h;g++)p[g]=arguments[g];const v=this;return new Promise((w,B)=>{const E=function(){if(s=void 0,c=Date.now(),!a){const C=r.apply(v,p);A&&A(C),l.forEach(T=>{let F=T.resolve;return F(C)}),l=[]}},b=a&&s===void 0;if(s!==void 0&&dt.clearTimeout(s),s=dt.setTimeout(E,d()),b){const C=r.apply(v,p);return A&&A(C),w(C)}l.push({resolve:w,reject:B})})};return u.cancel=function(h){s!==void 0&&dt.clearTimeout(s),l.forEach(p=>{let g=p.reject;return g(h)}),l=[]},u}const hu=2e3;function Qo(r,e){if(!e)return 0;let t,n;return"bytesReceived"in r?(t=r.bytesReceived,n=e.bytesReceived):"bytesSent"in r&&(t=r.bytesSent,n=e.bytesSent),t===void 0||n===void 0||r.timestamp===void 0||e.timestamp===void 0?0:(t-n)*8*1e3/(r.timestamp-e.timestamp)}class Qg extends N{constructor(e,t,n,i,s){super(e,n,s),this.sid=t,this.receiver=i}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?$.Muted:$.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const t=n=>{n.track===this._mediaStreamTrack&&(e.removeEventListener("removetrack",t),this.receiver&&"playoutDelayHint"in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit($.Ended,this))};e.addEventListener("removetrack",t)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return k(this,void 0,void 0,function*(){var e;return!((e=this.receiver)===null||e===void 0)&&e.getStats?yield this.receiver.getStats():void 0})}setPlayoutDelay(e){this.receiver?"playoutDelayHint"in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn("Playout delay not supported in this browser"):this.log.warn("Cannot set playout delay, track already ended")}getPlayoutDelay(){if(this.receiver){if("playoutDelayHint"in this.receiver)return this.receiver.playoutDelayHint;this.log.warn("Playout delay not supported in this browser")}else this.log.warn("Cannot get playout delay, track already ended");return 0}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval(()=>this.monitorReceiver(),hu)),x4()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var t;this.timeSyncHandle=requestAnimationFrame(()=>e());const n=(t=this.receiver)===null||t===void 0?void 0:t.getSynchronizationSources()[0];if(n){const i=n.timestamp,s=n.rtpTimestamp;s&&this.rtpTimestamp!==s&&(this.emit($.TimeSyncUpdate,{timestamp:i,rtpTimestamp:s}),this.rtpTimestamp=s)}};e()}}const kc=100;class fu extends Qg{constructor(e,t,n,i,s){super(e,t,N.Kind.Video,n,s),this.elementInfos=[],this.monitorReceiver=()=>k(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const a=yield this.getReceiverStats();a&&this.prevStats&&this.receiver&&(this._currentBitrate=Qo(a,this.prevStats)),this.prevStats=a}),this.debouncedHandleResize=uu(()=>{this.updateDimensions()},kc),this.adaptiveStreamSettings=i}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}lookupFrameMetadata(e){let t=e.rtpTimestamp;var n;return(n=this.frameMetadataExtractor)===null||n===void 0?void 0:n.lookupMetadata(t)}setStreamState(e){super.setStreamState(e),this.log.debug("setStreamState",e),this.isAdaptiveStream&&e===N.StreamState.Active&&this.updateVisibility()}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(t=>{e?$i(this._mediaStreamTrack,t):Vi(this._mediaStreamTrack,t)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&this.elementInfos.find(t=>t.element===e)===void 0){const t=new d2(e);this.observeElementInfo(t)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&this.elementInfos.find(t=>t===e)===void 0?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):this.log.warn("visibility resize observer not triggered",this.logContext)}stopObservingElementInfo(e){if(!this.isAdaptiveStream){this.log.warn("stopObservingElementInfo ignored",this.logContext);return}const t=this.elementInfos.filter(n=>n===e);for(const n of t)n.stopObserving();this.elementInfos=this.elementInfos.filter(n=>n!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){if(e)return this.stopObservingElement(e),super.detach(e);const t=super.detach();for(const n of t)this.stopObservingElement(n);return t}getDecoderImplementation(){var e;return(e=this.prevStats)===null||e===void 0?void 0:e.decoderImplementation}getReceiverStats(){return k(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t,n="",i=new Map;return e.forEach(s=>{s.type==="inbound-rtp"?(n=s.codecId,t={type:"video",streamId:s.id,framesDecoded:s.framesDecoded,framesDropped:s.framesDropped,framesReceived:s.framesReceived,packetsReceived:s.packetsReceived,packetsLost:s.packetsLost,frameWidth:s.frameWidth,frameHeight:s.frameHeight,pliCount:s.pliCount,firCount:s.firCount,nackCount:s.nackCount,jitter:s.jitter,timestamp:s.timestamp,bytesReceived:s.bytesReceived,decoderImplementation:s.decoderImplementation}):s.type==="codec"&&i.set(s.id,s)}),t&&n!==""&&i.get(n)&&(t.mimeType=i.get(n).mimeType),t})}stopObservingElement(e){const t=this.elementInfos.filter(n=>n.element===e);for(const n of t)this.stopObservingElementInfo(n)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return k(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(e){var t,n;const i=this.elementInfos.reduce((o,c)=>Math.max(o,c.visibilityChangedAt||0),0),s=!((n=(t=this.adaptiveStreamSettings)===null||t===void 0?void 0:t.pauseVideoInBackground)!==null&&n!==void 0)||n?this.isInBackground:!1,a=this.elementInfos.some(o=>o.pictureInPicture),A=this.elementInfos.some(o=>o.visible)&&!s||a;if(!(this.lastVisible===A&&!e)){if(!A&&Date.now()-i<kc){dt.setTimeout(()=>{this.updateVisibility()},kc);return}this.lastVisible=A,this.emit($.VisibilityChanged,A,this)}}updateDimensions(){var e,t;let n=0,i=0;const s=this.getPixelDensity();for(const a of this.elementInfos){const A=a.width()*s,o=a.height()*s;A+o>n+i&&(n=A,i=o)}((e=this.lastDimensions)===null||e===void 0?void 0:e.width)===n&&((t=this.lastDimensions)===null||t===void 0?void 0:t.height)===i||(this.lastDimensions={width:n,height:i},this.emit($.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const t=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pixelDensity;return t==="screen"?N0():t||(N0()>2?2:1)}}class d2{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,t){this.onVisibilityChanged=n=>{var i;const s=n.target,a=n.isIntersecting;s===this.element&&(this.isIntersecting=a,this.isPiP=Ss(this.element),this.visibilityChangedAt=Date.now(),(i=this.handleVisibilityChanged)===null||i===void 0||i.call(this))},this.onEnterPiP=()=>{var n,i;(i=(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window)===null||i===void 0||i.addEventListener("pagehide",this.onLeavePiP),queueMicrotask(()=>{requestAnimationFrame(()=>{var s;this.isPiP=Ss(this.element),(s=this.handleVisibilityChanged)===null||s===void 0||s.call(this)})})},this.onLeavePiP=()=>{var n;this.isPiP=Ss(this.element),(n=this.handleVisibilityChanged)===null||n===void 0||n.call(this)},this.element=e,this.isIntersecting=t??Zl(e),this.isPiP=$t()&&Ss(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,t,n;this.isIntersecting=Zl(this.element),this.isPiP=Ss(this.element),this.element.handleResize=()=>{var i;(i=this.handleResize)===null||i===void 0||i.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,V0().observe(this.element),K0().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP),(e=window.documentPictureInPicture)===null||e===void 0||e.addEventListener("enter",this.onEnterPiP),(n=(t=window.documentPictureInPicture)===null||t===void 0?void 0:t.window)===null||n===void 0||n.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,t,n,i,s;(e=V0())===null||e===void 0||e.unobserve(this.element),(t=K0())===null||t===void 0||t.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),(n=window.documentPictureInPicture)===null||n===void 0||n.removeEventListener("enter",this.onEnterPiP),(s=(i=window.documentPictureInPicture)===null||i===void 0?void 0:i.window)===null||s===void 0||s.removeEventListener("pagehide",this.onLeavePiP)}}function Ss(r){var e,t;return document.pictureInPictureElement===r?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?Zl(r,(t=window.documentPictureInPicture)===null||t===void 0?void 0:t.window):!1}function Zl(r,e){const t=e||window;let n=r.offsetTop,i=r.offsetLeft;const s=r.offsetWidth,a=r.offsetHeight,A=r,o=A.hidden,c=getComputedStyle(r),l=c.display;for(;r.offsetParent;)r=r.offsetParent,n+=r.offsetTop,i+=r.offsetLeft;return n<t.pageYOffset+t.innerHeight&&i<t.pageXOffset+t.innerWidth&&n+a>t.pageYOffset&&i+s>t.pageXOffset&&!o&&l!=="none"}class u2 extends Yt.EventEmitter{constructor(e,t){super(),this.decryptDataRequests=new Map,this.encryptDataRequests=new Map,this.onWorkerMessage=n=>{var i,s;const a=n.data,A=a.kind,o=a.data;switch(A){case"error":if(me.error(o.error.message),o.uuid){const d=this.decryptDataRequests.get(o.uuid);if(d!=null&&d.reject){d.reject(o.error);break}const u=this.encryptDataRequests.get(o.uuid);if(u!=null&&u.reject){u.reject(o.error);break}}this.emit(Pr.EncryptionError,o.error,o.participantIdentity);break;case"initAck":o.enabled&&this.keyProvider.getKeys().forEach(d=>{this.postKey(d,!1)});break;case"enable":if(o.enabled&&this.keyProvider.getKeys().forEach(d=>{this.postKey(d,!1)}),this.encryptionEnabled!==o.enabled&&o.participantIdentity===((i=this.room)===null||i===void 0?void 0:i.localParticipant.identity))this.emit(Pr.ParticipantEncryptionStatusChanged,o.enabled,this.room.localParticipant),this.encryptionEnabled=o.enabled;else if(o.participantIdentity){const d=(s=this.room)===null||s===void 0?void 0:s.getParticipantByIdentity(o.participantIdentity);if(!d)throw TypeError("couldn't set encryption status, participant not found".concat(o.participantIdentity));this.emit(Pr.ParticipantEncryptionStatusChanged,o.enabled,d)}break;case"ratchetKey":this.keyProvider.emit(Kr.KeyRatcheted,o.ratchetResult,o.participantIdentity,o.keyIndex);break;case"decryptDataResponse":const c=this.decryptDataRequests.get(o.uuid);c!=null&&c.resolve&&c.resolve(o);break;case"encryptDataResponse":const l=this.encryptDataRequests.get(o.uuid);l!=null&&l.resolve&&l.resolve(o);break;case"packetTrailerMetadata":this.handleFrameMetadata(o.trackId,o.rtpTimestamp,o.ssrc,o.metadata);break}},this.onWorkerError=n=>{me.error("e2ee worker encountered an error:",{error:n.error}),this.emit(Pr.EncryptionError,n.error,void 0)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1,this.dataChannelEncryptionEnabled=t}get isEnabled(){return this.encryptionEnabled}get isDataChannelEncryptionEnabled(){return this.isEnabled&&this.dataChannelEncryptionEnabled}setup(e){if(!a2())throw new Au("tried to setup end-to-end encryption on an unsupported browser");if(me.info("setting up e2ee"),e!==this.room){this.room=e,this.setupEventListeners(e,this.keyProvider);const t={kind:"init",data:{keyProviderOptions:this.keyProvider.getOptions(),loglevel:Xb.getLevel()}};this.worker&&(me.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(t))}}setParticipantCryptorEnabled(e,t){me.debug("set e2ee to ".concat(e," for participant ").concat(t)),this.postEnable(e,t)}setSifTrailer(e){!e||e.length===0?me.warn("ignoring server sent trailer as it's empty"):this.postSifTrailer(e)}handleFrameMetadata(e,t,n,i){if(this.room){for(const s of[this.room.localParticipant,...this.room.remoteParticipants.values()])for(const a of s.trackPublications.values())if(a.track&&a.track.mediaStreamID===e&&a.track instanceof fu&&a.track.frameMetadataExtractor){a.track.frameMetadataExtractor.storeMetadata(t,n,i);return}}}setupEngine(e){e.on(G.RTPVideoMapUpdate,t=>{this.postRTPMap(t)})}setupEventListeners(e,t){e.on(V.TrackPublished,(n,i)=>this.setParticipantCryptorEnabled(n.trackInfo.encryption!==De.NONE,i.identity)),e.on(V.ConnectionStateChanged,n=>{n===Ee.Connected&&e.remoteParticipants.forEach(i=>{i.trackPublications.forEach(s=>{this.setParticipantCryptorEnabled(s.trackInfo.encryption!==De.NONE,i.identity)})})}).on(V.TrackUnsubscribed,(n,i,s)=>{var a;const A={kind:"removeTransform",data:{participantIdentity:s.identity,trackId:n.mediaStreamID}};(a=this.worker)===null||a===void 0||a.postMessage(A)}).on(V.TrackSubscribed,(n,i,s)=>{this.setupE2EEReceiver(n,s.identity,i.trackInfo)}).on(V.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");const n=t.getLatestManuallySetKeyIndex();t.getKeys().forEach(i=>{var s;this.postKey(i,n===((s=i.keyIndex)!==null&&s!==void 0?s:0))}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(X.LocalSenderCreated,(n,i)=>k(this,void 0,void 0,function*(){this.setupE2EESender(i,n)})),e.localParticipant.on(X.LocalTrackPublished,n=>{if(!wr(n.track)||!la())return;const i={kind:"updateCodec",data:{trackId:n.track.mediaStreamID,codec:Ws(n.trackInfo.codecs[0].mimeType),participantIdentity:this.room.localParticipant.identity,hasPacketTrailer:!1}};this.worker.postMessage(i)}),t.on(Kr.SetKey,(n,i)=>this.postKey(n,i??!0)).on(Kr.RatchetRequest,(n,i)=>this.postRatchetRequest(n,i))}encryptData(e){return k(this,void 0,void 0,function*(){if(!this.worker)throw Error("could not encrypt data, worker is missing");const t=crypto.randomUUID(),n={kind:"encryptDataRequest",data:{uuid:t,payload:e,participantIdentity:this.room.localParticipant.identity}},i=new Bt;return i.onFinally=()=>{this.encryptDataRequests.delete(t)},this.encryptDataRequests.set(t,i),this.worker.postMessage(n),i.promise})}handleEncryptedData(e,t,n,i){if(!this.worker)throw Error("could not handle encrypted data, worker is missing");const s=crypto.randomUUID(),a={kind:"decryptDataRequest",data:{uuid:s,payload:e,iv:t,participantIdentity:n,keyIndex:i}},A=new Bt;return A.onFinally=()=>{this.decryptDataRequests.delete(s)},this.decryptDataRequests.set(s,A),this.worker.postMessage(a),A.promise}postRatchetRequest(e,t){if(!this.worker)throw Error("could not ratchet key, worker is missing");const n={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:t}};this.worker.postMessage(n)}postKey(e,t){let n=e.key,i=e.participantIdentity,s=e.keyIndex;var a;if(!this.worker)throw Error("could not set key, worker is missing");const A={kind:"setKey",data:{participantIdentity:i,isPublisher:i===((a=this.room)===null||a===void 0?void 0:a.localParticipant.identity),key:n,keyIndex:s,updateCurrentKeyIndex:t}};this.worker.postMessage(A)}postEnable(e,t){if(this.worker){const n={kind:"enable",data:{enabled:e,participantIdentity:t}};this.worker.postMessage(n)}else throw new ReferenceError("failed to enable e2ee, worker is not ready")}postRTPMap(e){var t;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(!((t=this.room)===null||t===void 0)&&t.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const n={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(n)}postSifTrailer(e){if(!this.worker)throw Error("could not post SIF trailer, worker is missing");const t={kind:"setSifTrailer",data:{trailer:e}};this.worker.postMessage(t)}setupE2EEReceiver(e,t,n){if(!e.receiver)return;if(!(n!=null&&n.mimeType)||n.mimeType==="")throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");const i=e.kind==="video"&&!!n.packetTrailerFeatures&&n.packetTrailerFeatures.length>0;this.handleReceiver(e.receiver,e.mediaStreamID,t,e.kind==="video"?Ws(n.mimeType):void 0,i)}setupE2EESender(e,t){var n,i,s;if(!ji(e)||!t){t||me.warn("early return because sender is not ready");return}this.handleSender(t,e.mediaStreamID,void 0,wr(e)?(i=(n=e.publishOptions)===null||n===void 0?void 0:n.frameMetadata)!==null&&i!==void 0?i:(s=e.publishOptions)===null||s===void 0?void 0:s.packetTrailer:void 0)}handleReceiver(e,t,n,i,s){return k(this,void 0,void 0,function*(){if(this.worker){if(Jl()){const a={kind:"decode",participantIdentity:n,trackId:t,codec:i,hasPacketTrailer:s};e.transform=new RTCRtpScriptTransform(this.worker,a)}else{if(Cs in e&&i){const c={kind:"updateCodec",data:{trackId:t,codec:i,participantIdentity:n,hasPacketTrailer:s}};this.worker.postMessage(c);return}let a=e.writableStream,A=e.readableStream;if(!a||!A){const c=e.createEncodedStreams();e.writableStream=c.writable,a=c.writable,e.readableStream=c.readable,A=c.readable}const o={kind:"decode",data:{readableStream:A,writableStream:a,trackId:t,codec:i,participantIdentity:n,isReuse:Cs in e,hasPacketTrailer:s}};this.worker.postMessage(o,[A,a])}e[Cs]=!0}})}handleSender(e,t,n,i){var s;if(!(Cs in e||!this.worker)){if(!(!((s=this.room)===null||s===void 0)&&s.localParticipant.identity)||this.room.localParticipant.identity==="")throw TypeError("local identity needs to be known in order to set up encrypted sender");if(Jl()){me.info("initialize script transform");const a={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:t,codec:n,hasPacketTrailer:JA(i),packetTrailer:i};e.transform=new RTCRtpScriptTransform(this.worker,a)}else{me.info("initialize encoded streams");const a=e.createEncodedStreams(),A={kind:"encode",data:{readableStream:a.readable,writableStream:a.writable,codec:n,trackId:t,participantIdentity:this.room.localParticipant.identity,isReuse:!1,hasPacketTrailer:JA(i),packetTrailer:i}};this.worker.postMessage(A,[a.readable,a.writable])}e[Cs]=!0}}}const h2=300;class f2{constructor(){this.metadataMap=new Map,this.activeSsrc=0}storeMetadata(e,t,n){for(this.activeSsrc!==0&&this.activeSsrc!==t&&this.metadataMap.clear(),this.activeSsrc=t;this.metadataMap.size>=h2;){const i=this.metadataMap.keys().next().value;this.metadataMap.delete(i)}this.metadataMap.set(e,n)}lookupMetadata(e){return this.metadataMap.get(e)}dispose(){this.metadataMap.clear(),this.activeSsrc=0}}class p2{constructor(e){this.extractors=new Map,this.workerPipelines=new Map,this.onWorkerMessage=t=>{const n=t.data;if(n.kind==="metadata"){const i=this.extractors.get(n.data.trackId);i&&i.storeMetadata(n.data.rtpTimestamp,n.data.ssrc,n.data.metadata)}},this.onWorkerError=t=>{me.error("frame metadata worker encountered an error:",{error:t.error})},this.worker=e==null?void 0:e.worker}setup(e){e!==this.room&&(this.room=e,this.worker&&(this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage({kind:"init"})),e.on(V.TrackSubscribed,(t,n,i)=>{t.kind==="video"&&this.setupReceiver(t,n.trackInfo)}).on(V.TrackUnsubscribed,t=>{this.teardownTrack(t)}).on(V.Disconnected,()=>{this.cleanup()}))}setupReceiver(e,t){var n,i,s;const a=e.receiver;if(!a)return;if(!(!!(t!=null&&t.packetTrailerFeatures)&&t.packetTrailerFeatures.length>0)){!((n=this.room)===null||n===void 0)&&n.hasE2EESetup||this.setupPassthroughReceiver(a,e.mediaStreamID);return}if(!ha(this.worker?{worker:this.worker}:void 0)&&!(!((i=this.room)===null||i===void 0)&&i.hasE2EESetup)){me.warn("frame metadata transform not supported; skipping extraction");return}const o=new f2,c=e.mediaStreamID;this.extractors.set(c,o),e.frameMetadataExtractor=o,!(!((s=this.room)===null||s===void 0)&&s.hasE2EESetup)&&this.setupWorkerReceiver(a,c,!0)}setupPassthroughReceiver(e,t){if(ua()){"transform"in e&&(e.transform=null);return}if(this.worker&&ha({worker:this.worker})&&!this.workerPipelines.has(e)){this.setupWorkerReceiver(e,t,!1);return}this.worker&&this.workerPipelines.has(e)&&this.setupWorkerReceiver(e,t,!1)}setupWorkerReceiver(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;const i=this.worker;if(!i)return;if(ua()){e.transform=new RTCRtpScriptTransform(i,{kind:"decode",trackId:t});return}const s=this.workerPipelines.get(e);if(s){const o={kind:"updateTrackId",data:{oldTrackId:s,newTrackId:t,hasPacketTrailer:n}};i.postMessage(o),this.workerPipelines.set(e,t);return}if(!("createEncodedStreams"in e)){me.warn("createEncodedStreams not supported");return}let a;try{a=e.createEncodedStreams()}catch(o){me.warn("failed to create encoded streams",{error:o});return}const A={kind:"decode",data:{readableStream:a.readable,writableStream:a.writable,trackId:t,hasPacketTrailer:n}};i.postMessage(A,[a.readable,a.writable]),this.workerPipelines.set(e,t)}teardownTrack(e){const t=e.mediaStreamID,n=this.extractors.get(t);n&&(n.dispose(),this.extractors.delete(t)),e instanceof fu&&(e.frameMetadataExtractor=void 0)}cleanup(){var e;for(const t of this.extractors.values())t.dispose();this.extractors.clear(),this.workerPipelines.clear(),(e=this.worker)===null||e===void 0||e.terminate()}}const m2=500,g2=15e3;class Xi{constructor(){this.failedConnectionAttempts=new Map,this.backOffPromises=new Map}static getInstance(){return this._instance||(this._instance=new Xi),this._instance}addFailedConnectionAttempt(e){var t;const n=new URL(e),i=wc(n);if(!i)return;let s=(t=this.failedConnectionAttempts.get(i))!==null&&t!==void 0?t:0;this.failedConnectionAttempts.set(i,s+1),this.backOffPromises.set(i,Qt(Math.min(m2*Math.pow(2,s),g2)))}getBackOffPromise(e){const t=new URL(e),n=t&&wc(t);return n&&this.backOffPromises.get(n)||Promise.resolve()}resetFailedConnectionAttempts(e){const t=new URL(e),n=t&&wc(t);n&&(this.failedConnectionAttempts.set(n,0),this.backOffPromises.set(n,Promise.resolve()))}resetAll(){this.backOffPromises.clear(),this.failedConnectionAttempts.clear()}}Xi._instance=null;const Tc="default";class bt{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new bt),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return k(this,arguments,void 0,function(t){var n=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var s;if(((s=bt.userMediaPromiseMap)===null||s===void 0?void 0:s.size)>0){me.debug("awaiting getUserMedia promise");try{t?yield bt.userMediaPromiseMap.get(t):yield Promise.all(bt.userMediaPromiseMap.values())}catch{me.warn("error waiting for media permissons")}}let a=yield navigator.mediaDevices.enumerateDevices();if(i&&!(Si()&&n.hasDeviceInUse(t))&&(a.filter(o=>o.kind===t).length===0||a.some(o=>{const c=o.label==="",l=t?o.kind===t:!0;return c&&l}))){const o={video:t!=="audioinput"&&t!=="audiooutput",audio:t!=="videoinput"&&{deviceId:{ideal:"default"}}},c=yield navigator.mediaDevices.getUserMedia(o);a=yield navigator.mediaDevices.enumerateDevices(),c.getTracks().forEach(l=>{l.stop()})}return n._previousDevices=a,t&&(a=a.filter(A=>A.kind===t)),a}()})}normalizeDeviceId(e,t,n){return k(this,void 0,void 0,function*(){if(t!==Tc)return t;const i=yield this.getDevices(e),s=i.find(A=>A.deviceId===Tc);if(!s){me.warn("could not reliably determine default device");return}const a=i.find(A=>A.deviceId!==Tc&&A.groupId===(n??s.groupId));if(!a){me.warn("could not reliably determine default device");return}return a==null?void 0:a.deviceId})}hasDeviceInUse(e){return e?bt.userMediaPromiseMap.has(e):bt.userMediaPromiseMap.size>0}}bt.mediaDeviceKinds=["audioinput","audiooutput","videoinput"];bt.userMediaPromiseMap=new Map;const pu=65535,Mg=4294967295;class Mn{static u16(e){return new Mn(e,pu)}static u32(e){return new Mn(e,Mg)}constructor(e,t){if(this.value=e,e<0)throw new Error("WrapAroundUnsignedInt: cannot faithfully represent an integer smaller than 0");if(t>Number.MAX_SAFE_INTEGER)throw new Error("WrapAroundUnsignedInt: cannot faithfully represent an integer bigger than MAX_SAFE_INTEGER.");this.maxSize=t,this.clamp()}clamp(){for(;this.value>this.maxSize;)this.value-=this.maxSize+1;for(;this.value<0;)this.value+=this.maxSize+1}clone(){return new Mn(this.value,this.maxSize)}update(e){this.value=e(this.value),this.clamp()}increment(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this.update(t=>t+e)}decrement(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this.update(t=>t-e)}getThenIncrement(){const e=this.value;return this.increment(),new Mn(e,this.maxSize)}isBefore(e){const t=this.value>>>0,i=(e.value>>>0)-t>>>0;return i!==0&&i<this.maxSize+1}}class Ji{static fromRtpTicks(e){return new Ji(e,9e4)}static rtpRandom(){const e=Math.round(Math.random()*Mg);return Ji.fromRtpTicks(e)}constructor(e,t){this.timestamp=Mn.u32(e),this.rateInHz=t}asTicks(){return this.timestamp.value}clone(){return new Ji(this.timestamp.value,this.rateInHz)}wrappingAdd(e){this.timestamp.increment(e)}isBefore(e){return this.timestamp.isBefore(e.timestamp)}}class oi{constructor(e,t,n){this.epoch=t,this.base=n,this.previous=n.clone(),this.rateInHz=e}static startingNow(e,t){return new oi(t,new Date,e)}static startingAtTime(e,t,n){return new oi(n,e,t)}static rtpStartingNow(e){return oi.startingNow(e,9e4)}static rtpStartingAtTime(e,t){return oi.startingAtTime(e,t,9e4)}now(){return this.at(new Date)}at(e){let t=e.getTime()-this.epoch.getTime(),n=oi.durationInMsToTicks(t,this.rateInHz),i=this.base.clone();return i.wrappingAdd(n),i.isBefore(this.previous)&&(i=this.previous),this.previous=i.clone(),i.clone()}static durationInMsToTicks(e,t){let i=(e*1e6*t+5e8)/1e9;return Math.round(i)}}function mu(r){if(r instanceof DataView)return r;if(r instanceof ArrayBuffer)return new DataView(r);if(r instanceof Uint8Array)return new DataView(r.buffer,r.byteOffset,r.byteLength);throw new Error("Error coercing ".concat(r," to DataView - input was not DataView, ArrayBuffer, or Uint8Array."))}var vi;(function(r){r[r.Reserved=0]="Reserved",r[r.TooLarge=1]="TooLarge"})(vi||(vi={}));class As extends wn{constructor(e,t){super(19,e),this.name="DataTrackHandleError",this.reason=t,this.reasonName=vi[t]}isReason(e){return this.reason===e}static tooLarge(){return new As("Value too large to be a valid track handle",vi.TooLarge)}static reserved(e){return new As("0x".concat(e.toString(16)," is a reserved value."),vi.Reserved)}}const v2={fromNumber(r){if(r===0)throw As.reserved(r);if(r>pu)throw As.tooLarge();return r}};class y2{constructor(){this.value=0}get(){return this.value+=1,this.value>pu?null:this.value}reset(){this.value=0}}const YA={from(r){return{sid:r.sid,pubHandle:r.pubHandle,name:r.name,usesE2ee:r.encryption!==De.NONE}},toProtobuf(r){return new ko({sid:r.sid,pubHandle:r.pubHandle,name:r.name,encryption:r.usesE2ee?De.GCM:De.NONE})}};var $s;(function(r){r[r.WAITING=0]="WAITING",r[r.RUNNING=1]="RUNNING",r[r.COMPLETED=2]="COMPLETED"})($s||($s={}));class w2{constructor(){this.pendingTasks=new Map,this.taskMutex=new xt,this.nextTaskIndex=0}run(e){return k(this,void 0,void 0,function*(){const t={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:$s.WAITING};this.pendingTasks.set(t.id,t);const n=yield this.taskMutex.lock();try{return t.executedAt=Date.now(),t.status=$s.RUNNING,yield e()}finally{t.status=$s.COMPLETED,this.pendingTasks.delete(t.id),n()}})}flush(){return k(this,void 0,void 0,function*(){return this.run(()=>k(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}class b2{get readyState(){return this.ws.readyState}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var n,i;if(!((n=t.signal)===null||n===void 0)&&n.aborted)throw new DOMException("This operation was aborted","AbortError");this.url=e;const s=new WebSocket(e,(i=t.protocols)!==null&&i!==void 0?i:[]);s.binaryType="arraybuffer",this.ws=s;const a=function(){let A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=A.closeCode,c=A.reason;return s.close(o,c)};this.opened=new Lt((A,o)=>{const c=()=>{o(oe.websocket("Encountered websocket error during connection establishment"))};s.onopen=()=>{A({readable:new ReadableStream({start(l){s.onmessage=d=>{let u=d.data;return l.enqueue(u)},s.onerror=d=>l.error(d)},cancel:a}),writable:new WritableStream({write(l){s.send(l)},abort(){s.close()},close:a}),protocol:s.protocol,extensions:s.extensions}),s.removeEventListener("error",c)},s.addEventListener("error",c)}),this.closed=new Lt((A,o)=>{const c=()=>k(this,void 0,void 0,function*(){const l=new Lt(u=>{s.readyState!==WebSocket.CLOSED&&s.addEventListener("close",h=>{u(h)},{once:!0})}),d=yield Lt.race([Qt(250),l]);d?A(d):o(oe.websocket("Encountered unspecified websocket error without a timely close event"))});s.onclose=l=>{let d=l.code,u=l.reason;A({closeCode:d,reason:u}),s.removeEventListener("error",c)},s.addEventListener("error",c)}),t.signal&&(t.signal.onabort=()=>s.close()),this.close=a}}const B2=["syncState","trickle","offer","answer","simulate","leave"];function C2(r){const e=B2.indexOf(r.case)>=0;return me.trace("request allowed to bypass queue:",{canPass:e,req:r}),e}var Re;(function(r){r[r.CONNECTING=0]="CONNECTING",r[r.CONNECTED=1]="CONNECTED",r[r.RECONNECTING=2]="RECONNECTING",r[r.DISCONNECTING=3]="DISCONNECTING",r[r.DISCONNECTED=4]="DISCONNECTED"})(Re||(Re={}));const S2=250;class gu{get currentState(){return this.state}get isDisconnected(){return this.state===Re.DISCONNECTING||this.state===Re.DISCONNECTED}get isEstablishingConnection(){return this.state===Re.CONNECTING||this.state===Re.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var n;this.rtt=0,this.state=Re.DISCONNECTED,this.log=me,this._requestId=0,this.useV0SignalPath=!1,this.resetCallbacks=()=>{this.onAnswer=void 0,this.onLeave=void 0,this.onLocalTrackPublished=void 0,this.onLocalTrackUnpublished=void 0,this.onNegotiateRequested=void 0,this.onOffer=void 0,this.onRemoteMuteChanged=void 0,this.onSubscribedQualityUpdate=void 0,this.onTokenRefresh=void 0,this.onTrickle=void 0,this.onClose=void 0,this.onMediaSectionsRequirement=void 0},this.loggerContextCb=t.loggerContextCb,this.log=Xt((n=t.loggerName)!==null&&n!==void 0?n:Ct.Signal,()=>this.logContext),this.useJSON=e,this.requestQueue=new w2,this.queuedRequests=[],this.closingLock=new xt,this.connectionLock=new xt,this.state=Re.DISCONNECTED}get logContext(){var e,t;return(t=(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this))!==null&&t!==void 0?t:{}}join(e,t,n,i){return k(this,arguments,void 0,function(s,a,A,o){var c=this;let l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,d=arguments.length>5?arguments[5]:void 0;return function*(){return c.state=Re.CONNECTING,c.options=A,yield c.connect(s,a,A,o,l,d)}()})}reconnect(e,t,n,i){return k(this,void 0,void 0,function*(){if(!this.options){this.log.warn("attempted to reconnect without signal options being set, ignoring");return}return this.state=Re.RECONNECTING,this.clearPingInterval(),yield this.connect(e,t,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:n,reconnectReason:i}),void 0,this.useV0SignalPath)})}connect(e,t,n,i){return k(this,arguments,void 0,function(s,a,A,o){var c=this;let l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,d=arguments.length>5?arguments[5]:void 0;return function*(){const u=yield c.connectionLock.lock();c.connectOptions=A,c.useV0SignalPath=l;const h=V4(A.clientInfoCapabilities),p=l?k2(a,h,A):yield T2(a,h,A,d),g=Z4(s,p,l).toString(),v=t2(g).toString();return new Promise((w,B)=>k(c,void 0,void 0,function*(){var E,b;try{let C=!1;const T=O=>k(this,void 0,void 0,function*(){if(C)return;C=!0;const H=O instanceof Event?O.currentTarget:O,se=n2(H,"Abort handler called");this.streamWriter&&!this.isDisconnected?this.sendLeave().then(()=>this.close(se)).catch(ie=>{this.log.error(ie),this.close()}):this.close(),F(),B(oe.cancelled(se))});o==null||o.addEventListener("abort",T);const F=()=>{clearTimeout(R),o==null||o.removeEventListener("abort",T)},R=setTimeout(()=>{T(oe.timeout("room connection has timed out (signal)"))},A.websocketTimeout),M=(O,H)=>{this.handleSignalConnected(O,R,H)},D=new URL(g);if(D.searchParams.has("access_token")&&D.searchParams.set("access_token","<redacted>"),this.ws){const O=performance.now();yield this.close(!1),this.log.debug("closed previous ws connection in ".concat(performance.now()-O,"ms"))}this.log.info("signal connecting to ".concat(D),{reconnect:A.reconnect,reconnectReason:A.reconnectReason}),this.ws=new b2(g);try{this.ws.closed.then(ue=>{var Ce;this.isEstablishingConnection&&B(oe.internal("Websocket got closed during a (re)connection attempt: ".concat(ue.reason))),ue.closeCode!==1e3&&(this.log.warn("websocket closed",{reason:ue.reason,code:ue.closeCode,wasClean:ue.closeCode===1e3,state:this.state}),this.state===Re.CONNECTED&&this.handleOnClose((Ce=ue.reason)!==null&&Ce!==void 0?Ce:"Unexpected WS error"))}).catch(ue=>{this.isEstablishingConnection&&B(oe.internal("Websocket error during a (re)connection attempt: ".concat(ue)))});const O=yield this.ws.opened.catch(ue=>k(this,void 0,void 0,function*(){if(this.state!==Re.CONNECTED){this.state=Re.DISCONNECTED,clearTimeout(R);const Ce=yield this.handleConnectionError(ue,v);B(Ce);return}this.handleWSError(ue),B(ue)}));if(clearTimeout(R),!O)return;const H=O.readable.getReader();this.streamWriter=O.writable.getWriter();const se=yield H.read();if(H.releaseLock(),!se.value)throw oe.internal("no message received as first message");const ie=q0(se.value),Z=this.validateFirstMessage(ie,(E=A.reconnect)!==null&&E!==void 0?E:!1);if(!Z.isValid){B(Z.error);return}((b=ie.message)===null||b===void 0?void 0:b.case)==="join"&&(this.pingTimeoutDuration=ie.message.value.pingTimeout,this.pingIntervalDuration=ie.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&this.log.debug("ping config",{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration}),this.onJoined&&this.onJoined(ie.message.value));const ee=Z.shouldProcessFirstMessage?ie:void 0;M(O,ee),w(Z.response)}catch(O){B(O)}finally{F()}}finally{u()}}))}()})}startReadingLoop(e,t){return k(this,void 0,void 0,function*(){for(t&&this.handleSignalResponse(t);;){this.signalLatency&&(yield Qt(this.signalLatency));const n=yield e.read(),i=n.done,s=n.value;if(i)break;const a=q0(s);this.handleSignalResponse(a)}})}close(){return k(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Close method called on signal client";return function*(){if([Re.DISCONNECTING||Re.DISCONNECTED].includes(e.state)){e.log.debug("ignoring signal close as it's already in disconnecting state");return}const i=yield e.closingLock.lock();try{if(e.clearPingInterval(),t&&(e.state=Re.DISCONNECTING),e.ws){e.ws.close({closeCode:1e3,reason:n});const s=e.ws.closed;e.ws=void 0,e.streamWriter=void 0,yield Promise.race([s,Qt(S2)])}}catch(s){e.log.debug("websocket error while closing",{error:s})}finally{t&&(e.state=Re.DISCONNECTED),i()}}()})}sendOffer(e,t){this.log.debug("sending offer",{offerSdp:e.sdp}),this.sendRequest({case:"offer",value:ci(e,t)})}sendAnswer(e,t){return this.log.debug("sending answer",{answerSdp:e.sdp}),this.sendRequest({case:"answer",value:ci(e,t)})}sendIceCandidate(e,t){return this.log.debug("sending ice candidate",{candidate:e}),this.sendRequest({case:"trickle",value:new xo({candidateInit:JSON.stringify(e),target:t})})}sendMuteTrack(e,t){return this.sendRequest({case:"mute",value:new Eo({sid:e,muted:t})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,t){return k(this,arguments,void 0,function(n,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){const A=s.getNextRequestId();return yield s.sendRequest({case:"updateMetadata",value:new iu({requestId:A,metadata:n,name:i,attributes:a})}),A}()})}sendUpdateTrackSettings(e){this.sendRequest({case:"trackSetting",value:e})}sendUpdateSubscription(e){return this.sendRequest({case:"subscription",value:e})}sendSyncState(e){return this.sendRequest({case:"syncState",value:e})}sendUpdateVideoLayers(e,t){return this.sendRequest({case:"updateLayers",value:new _m({trackSid:e,layers:t})})}sendUpdateSubscriptionPermissions(e,t){return this.sendRequest({case:"subscriptionPermission",value:new Dm({allParticipants:e,trackPermissions:t})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:Ke.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new Hm({timestamp:Ke.parse(Date.now()),rtt:Ke.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,t){return this.sendRequest({case:"updateAudioTrack",value:new ru({trackSid:e,features:t})})}sendLeave(){return this.sendRequest({case:"leave",value:new Fo({reason:Qn.CLIENT_INITIATED,action:qi.DISCONNECT})})}sendPublishDataTrackRequest(e,t,n){return this.sendRequest({case:"publishDataTrackRequest",value:new Zd({pubHandle:e,name:t,encryption:n?De.GCM:De.NONE})})}sendUnPublishDataTrackRequest(e){return this.sendRequest({case:"unpublishDataTrackRequest",value:new tu({pubHandle:e})})}sendUpdateDataSubscription(e,t){return this.sendRequest({case:"updateDataSubscription",value:new Fm({updates:[new Im({trackSid:e,subscribe:t})]})})}sendRequest(e){return k(this,arguments,void 0,function(t){var n=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return function*(){if(!i&&!C2(t)&&n.state===Re.RECONNECTING){n.queuedRequests.push(()=>k(n,void 0,void 0,function*(){yield this.sendRequest(t,!0)}));return}if(i||(yield n.requestQueue.flush()),n.signalLatency&&(yield Qt(n.signalLatency)),n.isDisconnected){n.log.debug("skipping signal request (type: ".concat(t.case,") - SignalClient disconnected"));return}if(!n.streamWriter){n.log.error("cannot send signal request before connected, type: ".concat(t==null?void 0:t.case));return}const a=new vb({message:t});try{n.useJSON?yield n.streamWriter.write(a.toJsonString()):yield n.streamWriter.write(a.toBinary().buffer)}catch(A){n.log.error("error sending signal message",{error:A})}}()})}handleSignalResponse(e){var t,n;const i=e.message;if(i==null){this.log.debug("received unsupported message");return}let s=!1;if(i.case==="answer"){const a=X0(i.value);this.onAnswer&&this.onAnswer(a,i.value.id,i.value.midToTrackId)}else if(i.case==="offer"){const a=X0(i.value);this.onOffer&&this.onOffer(a,i.value.id,i.value.midToTrackId)}else if(i.case==="trickle"){const a=JSON.parse(i.value.candidateInit);this.onTrickle&&this.onTrickle(a,i.value.target)}else i.case==="update"?this.onParticipantUpdate&&this.onParticipantUpdate((t=i.value.participants)!==null&&t!==void 0?t:[]):i.case==="trackPublished"?this.onLocalTrackPublished&&this.onLocalTrackPublished(i.value):i.case==="speakersChanged"?this.onSpeakersChanged&&this.onSpeakersChanged((n=i.value.speakers)!==null&&n!==void 0?n:[]):i.case==="leave"?this.onLeave&&this.onLeave(i.value):i.case==="mute"?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(i.value.sid,i.value.muted):i.case==="roomUpdate"?this.onRoomUpdate&&i.value.room&&this.onRoomUpdate(i.value.room):i.case==="connectionQuality"?this.onConnectionQuality&&this.onConnectionQuality(i.value):i.case==="streamStateUpdate"?this.onStreamStateUpdate&&this.onStreamStateUpdate(i.value):i.case==="subscribedQualityUpdate"?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(i.value):i.case==="subscriptionPermissionUpdate"?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(i.value):i.case==="refreshToken"?this.onTokenRefresh&&this.onTokenRefresh(i.value):i.case==="trackUnpublished"?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(i.value):i.case==="subscriptionResponse"?this.onSubscriptionError&&this.onSubscriptionError(i.value):i.case==="pong"||(i.case==="pongResp"?(this.rtt=Date.now()-Number.parseInt(i.value.lastPingTimestamp.toString()),this.resetPingTimeout(),s=!0):i.case==="requestResponse"?this.onRequestResponse&&this.onRequestResponse(i.value):i.case==="trackSubscribed"?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(i.value.trackSid):i.case==="roomMoved"?(this.onTokenRefresh&&this.onTokenRefresh(i.value.token),this.onRoomMoved&&this.onRoomMoved(i.value)):i.case==="mediaSectionsRequirement"?this.onMediaSectionsRequirement&&this.onMediaSectionsRequirement(i.value):i.case==="publishDataTrackResponse"?this.onPublishDataTrackResponse&&this.onPublishDataTrackResponse(i.value):i.case==="unpublishDataTrackResponse"?this.onUnPublishDataTrackResponse&&this.onUnPublishDataTrackResponse(i.value):i.case==="dataTrackSubscriberHandles"?this.onDataTrackSubscriberHandles&&this.onDataTrackSubscriberHandles(i.value):this.log.debug("unsupported message",{msgCase:i.case}));s||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return k(this,void 0,void 0,function*(){if(this.state===Re.DISCONNECTED)return;const t=this.onClose;yield this.close(void 0,e),this.log.info("websocket connection closed: ".concat(e),{reason:e}),t&&t(e)})}handleWSError(e){this.log.error("websocket error",{error:e})}resetPingTimeout(){if(this.clearPingTimeout(),!this.pingTimeoutDuration){this.log.warn("ping timeout duration not set");return}this.pingTimeout=dt.setTimeout(()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-this.pingTimeoutDuration*1e3).toUTCString())),this.handleOnClose("ping timeout")},this.pingTimeoutDuration*1e3)}clearPingTimeout(){this.pingTimeout&&dt.clearTimeout(this.pingTimeout)}startPingInterval(){if(this.clearPingInterval(),this.resetPingTimeout(),!this.pingIntervalDuration){this.log.warn("ping interval duration not set");return}this.log.debug("start ping interval"),this.pingInterval=dt.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval"),this.clearPingTimeout(),this.pingInterval&&dt.clearInterval(this.pingInterval)}handleSignalConnected(e,t,n){this.state=Re.CONNECTED,this.log.info("signal connected"),clearTimeout(t),this.startPingInterval(),this.startReadingLoop(e.readable.getReader(),n)}validateFirstMessage(e,t){var n,i,s,a,A;return((n=e.message)===null||n===void 0?void 0:n.case)==="join"?{isValid:!0,response:e.message.value}:this.state===Re.RECONNECTING&&((i=e.message)===null||i===void 0?void 0:i.case)!=="leave"?((s=e.message)===null||s===void 0?void 0:s.case)==="reconnect"?{isValid:!0,response:e.message.value}:(this.log.debug("declaring signal reconnected without reconnect response received"),{isValid:!0,response:void 0,shouldProcessFirstMessage:!0}):this.isEstablishingConnection&&((a=e.message)===null||a===void 0?void 0:a.case)==="leave"?{isValid:!1,error:oe.leaveRequest("Received leave request while trying to (re)connect",e.message.value.reason)}:t?{isValid:!1,error:oe.internal("Unexpected first message")}:{isValid:!1,error:oe.internal("did not receive join response, got ".concat((A=e.message)===null||A===void 0?void 0:A.case," instead"))}}handleConnectionError(e,t){return k(this,void 0,void 0,function*(){try{const n=yield fetch(t);switch(n.status){case 404:const i=yield n.text();return i.includes("requested room does not exist")?oe.notAllowed(i,n.status):oe.serviceNotFound("v1 RTC path not found. Consider upgrading your LiveKit server version","v0-rtc");case 401:case 403:const s=yield n.text();return oe.notAllowed(s,n.status);default:break}return e instanceof oe?e:oe.internal("Encountered unknown websocket error during connection: ".concat(e),{status:n.status,statusText:n.statusText})}catch(n){return n instanceof oe?n:oe.serverUnreachable(n instanceof Error?n.message:"server was not reachable")}})}}function X0(r){const e={type:"offer",sdp:r.sdp};switch(r.type){case"answer":case"offer":case"pranswer":case"rollback":e.type=r.type;break}return e}function ci(r,e){return new qr({sdp:r.sdp,type:r.type,id:e})}function k2(r,e,t){var n;const i=new URLSearchParams;return i.set("access_token",r),t.reconnect&&(i.set("reconnect","1"),t.sid&&i.set("sid",t.sid)),i.set("auto_subscribe",t.autoSubscribe?"1":"0"),i.set("sdk",Rn()?"reactnative":"js"),i.set("version",e.version),i.set("protocol",e.protocol.toString()),i.set("client_protocol",e.clientProtocol.toString()),e.deviceModel&&i.set("device_model",e.deviceModel),e.os&&i.set("os",e.os),e.osVersion&&i.set("os_version",e.osVersion),e.browser&&i.set("browser",e.browser),e.browserVersion&&i.set("browser_version",e.browserVersion),t.adaptiveStream&&i.set("adaptive_stream","1"),t.reconnectReason&&i.set("reconnect_reason",t.reconnectReason.toString()),!((n=navigator.connection)===null||n===void 0)&&n.type&&i.set("network",navigator.connection.type),i}function T2(r,e,t,n){return k(this,void 0,void 0,function*(){const i=new URLSearchParams;i.set("access_token",r);const s=new Vb({clientInfo:e,connectionSettings:new Nm({autoSubscribe:!!t.autoSubscribe,adaptiveStream:!!t.adaptiveStream}),reconnect:!!t.reconnect,participantSid:t.sid?t.sid:void 0,publisherOffer:n});t.reconnectReason&&(s.reconnectReason=t.reconnectReason);const a=s.toBinary();let A,o;if(Fg()){const u=new CompressionStream("gzip"),h=u.writable.getWriter();h.write(new Uint8Array(a)),h.close();const p=[],g=u.readable.getReader();for(;;){const E=yield g.read(),b=E.done,C=E.value;if(b)break;p.push(C)}const v=p.reduce((E,b)=>E+b.length,0),w=new Uint8Array(v);let B=0;for(const E of p)w.set(E,B),B+=E.length;A=w,o=Rl.GZIP}else A=a,o=Rl.NONE;const l=new zb({joinRequest:A,compression:o}).toBinary(),d=u=>{const h=Array.from(u,p=>String.fromCodePoint(p)).join("");return btoa(h)};return i.set("join_request",d(l).replace(/\+/g,"-").replace(/\//g,"_")),i})}class J0{constructor(){this.buffer=[],this._totalSize=0}push(e){this.buffer.push(e),this._totalSize+=e.data.byteLength}pop(){const e=this.buffer.shift();return e&&(this._totalSize-=e.data.byteLength),e}getAll(){return this.buffer.slice()}popToSequence(e){for(;this.buffer.length>0&&this.buffer[0].sequence<=e;)this.pop()}alignBufferedAmount(e){for(;this.buffer.length>0;){const t=this.buffer[0];if(this._totalSize-t.data.byteLength<=e)break;this.pop()}}get length(){return this.buffer.length}}class x2{constructor(e){this._map=new Map,this._lastCleanup=0,this.ttl=e}set(e,t){const n=Date.now();n-this._lastCleanup>this.ttl/2&&this.cleanup();const i=n+this.ttl;return this._map.set(e,{value:t,expiresAt:i}),this}get(e){const t=this._map.get(e);if(t){if(t.expiresAt<Date.now()){this._map.delete(e);return}return t.value}}has(e){const t=this._map.get(e);return t?t.expiresAt<Date.now()?(this._map.delete(e),!1):!0:!1}delete(e){return this._map.delete(e)}clear(){this._map.clear()}cleanup(){const e=Date.now();for(const n of this._map.entries()){var t=Ae(n,2);const i=t[0];t[1].expiresAt<e&&this._map.delete(i)}this._lastCleanup=e}get size(){return this.cleanup(),this._map.size}forEach(e){this.cleanup();for(const n of this._map.entries()){var t=Ae(n,2);const i=t[0],s=t[1];s.expiresAt>=Date.now()&&e(s.value,i,this.asValueMap())}}map(e){this.cleanup();const t=[],n=this.asValueMap();for(const s of n.entries()){var i=Ae(s,2);const a=i[0],A=i[1];t.push(e(A,a,n))}return t}asValueMap(){const e=new Map;for(const n of this._map.entries()){var t=Ae(n,2);const i=t[0],s=t[1];s.expiresAt>=Date.now()&&e.set(i,s.value)}return e}}var bn={},xc={},Ec={exports:{}},Y0;function vu(){if(Y0)return Ec.exports;Y0=1;var r=Ec.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" network-cost %d":"%v",t}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return e.attribute!=null&&(t+=" %s",e.value!=null&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":"",t}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};return Object.keys(r).forEach(function(e){var t=r[e];t.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})}),Ec.exports}var Z0;function E2(){return Z0||(Z0=1,function(r){var e=function(A){return String(Number(A))===A?Number(A):A},t=function(A,o,c,l){if(l&&!c)o[l]=e(A[1]);else for(var d=0;d<c.length;d+=1)A[d+1]!=null&&(o[c[d]]=e(A[d+1]))},n=function(A,o,c){var l=A.name&&A.names;A.push&&!o[A.push]?o[A.push]=[]:l&&!o[A.name]&&(o[A.name]={});var d=A.push?{}:l?o[A.name]:o;t(c.match(A.reg),d,A.names,A.name),A.push&&o[A.push].push(d)},i=vu(),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);r.parse=function(A){var o={},c=[],l=o;return A.split(/(\r\n|\r|\n)/).filter(s).forEach(function(d){var u=d[0],h=d.slice(2);u==="m"&&(c.push({rtp:[],fmtp:[]}),l=c[c.length-1]);for(var p=0;p<(i[u]||[]).length;p+=1){var g=i[u][p];if(g.reg.test(h))return n(g,l,h)}}),o.media=c,o};var a=function(A,o){var c=o.split(/=(.+)/,2);return c.length===2?A[c[0]]=e(c[1]):c.length===1&&o.length>1&&(A[c[0]]=void 0),A};r.parseParams=function(A){return A.split(/;\s?/).reduce(a,{})},r.parseFmtpConfig=r.parseParams,r.parsePayloads=function(A){return A.toString().split(" ").map(Number)},r.parseRemoteCandidates=function(A){for(var o=[],c=A.split(" ").map(e),l=0;l<c.length;l+=3)o.push({component:c[l],ip:c[l+1],port:c[l+2]});return o},r.parseImageAttributes=function(A){return A.split(" ").map(function(o){return o.substring(1,o.length-1).split(",").reduce(a,{})})},r.parseSimulcastStreamList=function(A){return A.split(";").map(function(o){return o.split(",").map(function(c){var l,d=!1;return c[0]!=="~"?l=e(c):(l=e(c.substring(1,c.length)),d=!0),{scid:l,paused:d}})})}}(xc)),xc}var Uc,eh;function U2(){if(eh)return Uc;eh=1;var r=vu(),e=/%[sdv%]/g,t=function(a){var A=1,o=arguments,c=o.length;return a.replace(e,function(l){if(A>=c)return l;var d=o[A];switch(A+=1,l){case"%%":return"%";case"%s":return String(d);case"%d":return Number(d);case"%v":return""}})},n=function(a,A,o){var c=A.format instanceof Function?A.format(A.push?o:o[A.name]):A.format,l=[a+"="+c];if(A.names)for(var d=0;d<A.names.length;d+=1){var u=A.names[d];A.name?l.push(o[A.name][u]):l.push(o[A.names[d]])}else l.push(o[A.name]);return t.apply(null,l)},i=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];return Uc=function(a,A){A=A||{},a.version==null&&(a.version=0),a.name==null&&(a.name=" "),a.media.forEach(function(d){d.payloads==null&&(d.payloads="")});var o=A.outerOrder||i,c=A.innerOrder||s,l=[];return o.forEach(function(d){r[d].forEach(function(u){u.name in a&&a[u.name]!=null?l.push(n(d,u,a)):u.push in a&&a[u.push]!=null&&a[u.push].forEach(function(h){l.push(n(d,u,h))})})}),a.media.forEach(function(d){l.push(n("m",r.m[0],d)),c.forEach(function(u){r[u].forEach(function(h){h.name in d&&d[h.name]!=null?l.push(n(u,h,d)):h.push in d&&d[h.push]!=null&&d[h.push].forEach(function(p){l.push(n(u,h,p))})})})}),l.join(`\r
|
|
38
|
+
`)+`\r
|
|
39
|
+
`},Uc}var th;function F2(){if(th)return bn;th=1;var r=E2(),e=U2(),t=vu();return bn.grammar=t,bn.write=e,bn.parse=r.parse,bn.parseParams=r.parseParams,bn.parseFmtpConfig=r.parseFmtpConfig,bn.parsePayloads=r.parsePayloads,bn.parseRemoteCandidates=r.parseRemoteCandidates,bn.parseImageAttributes=r.parseImageAttributes,bn.parseSimulcastStreamList=r.parseSimulcastStreamList,bn}var cn=F2();const I2=.7,Q2=20,Dr={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",OfferAnswered:"offerAnswered",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class nh extends Yt.EventEmitter{get pc(){return this._pc||(this._pc=this.createPC()),this._pc}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var n;super(),this.log=me,this.ddExtID=0,this.latestOfferId=0,this.latestAcknowledgedOfferId=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=uu(i=>k(this,void 0,void 0,function*(){this.emit(Dr.NegotiationStarted);try{yield this.createAndSendOffer()}catch(s){if(i)i(s);else throw s}}),Q2),this.close=()=>{this._pc&&(this.pendingInitialOffer=void 0,this._pc.close(),this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.ondatachannel=null,this._pc.onnegotiationneeded=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ondatachannel=null,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc=null)},this.log=Xt((n=t.loggerName)!==null&&n!==void 0?n:Ct.PCTransport),this.loggerOptions=t,this.config=e,this._pc=this.createPC(),this.offerLock=new xt}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=t=>{var n;t.candidate&&((n=this.onIceCandidate)===null||n===void 0||n.call(this,t.candidate))},e.onicecandidateerror=t=>{var n;(n=this.onIceCandidateError)===null||n===void 0||n.call(this,t)},e.oniceconnectionstatechange=()=>{var t;(t=this.onIceConnectionStateChange)===null||t===void 0||t.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var t;(t=this.onSignalingStatechange)===null||t===void 0||t.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var t;(t=this.onConnectionStateChange)===null||t===void 0||t.call(this,e.connectionState)},e.ondatachannel=t=>{var n;(n=this.onDataChannel)===null||n===void 0||n.call(this,t)},e.ontrack=t=>{var n;(n=this.onTrack)===null||n===void 0||n.call(this,t)},e}get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions).loggerContextCb)===null||t===void 0?void 0:t.call(e))}get isICEConnected(){return this._pc!==null&&(this.pc.iceConnectionState==="connected"||this.pc.iceConnectionState==="completed")}addIceCandidate(e){return k(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e,t){return k(this,void 0,void 0,function*(){var n,i;if(e.type==="answer"&&this.latestOfferId>0&&t>0&&t!==this.latestOfferId)return this.log.warn("ignoring answer for old offer",Object.assign(Object.assign({},this.logContext),{offerId:t,latestOfferId:this.latestOfferId})),!1;let s;if(e.type==="offer"){let a=M2(e),A=a.stereoMids,o=a.nackMids;this.remoteStereoMids=A,this.remoteNackMids=o}else if(e.type==="answer"){if(this.pendingInitialOffer&&this._pc){const A=this.pendingInitialOffer;this.pendingInitialOffer=void 0;const o=cn.parse((n=A.sdp)!==null&&n!==void 0?n:"");o.media.forEach(c=>{_a(c)}),this.log.debug("setting pending initial offer before processing answer",this.logContext),yield this.setMungedSDP(A,cn.write(o))}const a=cn.parse((i=e.sdp)!==null&&i!==void 0?i:"");a.media.forEach(A=>{const o=yu(A.mid);A.type==="audio"&&this.trackBitrates.some(c=>{if(!c.transceiver||o!=c.transceiver.mid)return!1;let l=0;if(A.rtp.some(u=>u.codec.toUpperCase()===c.codec.toUpperCase()?(l=u.payload,!0):!1),l===0)return!0;let d=!1;for(const u of A.fmtp)if(u.payload===l){u.config=u.config.split(";").filter(h=>!h.includes("maxaveragebitrate")).join(";"),c.maxbr>0&&(u.config+=";maxaveragebitrate=".concat(c.maxbr*1e3)),d=!0;break}return d||c.maxbr>0&&A.fmtp.push({payload:l,config:"maxaveragebitrate=".concat(c.maxbr*1e3)}),!0})}),s=cn.write(a)}return yield this.setMungedSDP(e,s,!0),this.pendingCandidates.forEach(a=>{this.pc.addIceCandidate(a)}),this.pendingCandidates=[],this.restartingIce=!1,e.type==="answer"&&(this.latestAcknowledgedOfferId=t,this.emit(Dr.OfferAnswered,t)),this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(Dr.NegotiationComplete),e.sdp&&cn.parse(e.sdp).media.forEach(A=>{A.type==="video"&&this.emit(Dr.RTPVideoPayloadTypes,A.rtp)})),!0})}createInitialOffer(){return k(this,void 0,void 0,function*(){var e;const t=yield this.offerLock.lock();try{if(this.pc.signalingState!=="stable"){this.log.warn("signaling state is not stable, cannot create initial offer",this.logContext);return}const n=this.latestOfferId+1;this.latestOfferId=n;const i=yield this.pc.createOffer();this.pendingInitialOffer={sdp:i.sdp,type:i.type};const s=cn.parse((e=i.sdp)!==null&&e!==void 0?e:"");return s.media.forEach(a=>{_a(a)}),i.sdp=cn.write(s),{offer:i,offerId:n}}finally{t()}})}createAndSendOffer(e){return k(this,void 0,void 0,function*(){var t;const n=yield this.offerLock.lock();try{if(this.onOffer===void 0)return;if(e!=null&&e.iceRestart&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&(this._pc.signalingState==="have-local-offer"||this.pendingInitialOffer)){const A=this._pc.remoteDescription;if(e!=null&&e.iceRestart&&A)yield this._pc.setRemoteDescription(A);else{this.renegotiate=!0,this.log.debug("requesting renegotiation",Object.assign({},this.logContext));return}}else if(!this._pc||this._pc.signalingState==="closed"){this.log.warn("could not createOffer with closed peer connection",this.logContext);return}this.log.debug("starting to negotiate",this.logContext);const i=this.latestOfferId+1;this.latestOfferId=i;const s=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:s.sdp},this.logContext));const a=cn.parse((t=s.sdp)!==null&&t!==void 0?t:"");if(a.media.forEach(A=>{_a(A),A.type==="audio"?rh(A,["all"],[]):A.type==="video"&&this.trackBitrates.some(o=>{if(!A.msid||!o.cid||!A.msid.includes(o.cid))return!1;let c=0;if(A.rtp.some(d=>d.codec.toUpperCase()===o.codec.toUpperCase()?(c=d.payload,!0):!1),c===0||(Un(o.codec)&&!Si()&&this.ensureVideoDDExtensionForSVC(A,a),!Un(o.codec)))return!0;const l=Math.round(o.maxbr*I2);for(const d of A.fmtp)if(d.payload===c){d.config.includes("x-google-start-bitrate")||(d.config+=";x-google-start-bitrate=".concat(l));break}return!0})}),this.latestOfferId>i){this.log.warn("latestOfferId mismatch",Object.assign(Object.assign({},this.logContext),{latestOfferId:this.latestOfferId,offerId:i}));return}yield this.setMungedSDP(s,cn.write(a)),this.onOffer(s,this.latestOfferId)}finally{n()}})}createAndSetAnswer(){return k(this,void 0,void 0,function*(){var e;const t=yield this.pc.createAnswer(),n=cn.parse((e=t.sdp)!==null&&e!==void 0?e:"");return n.media.forEach(i=>{_a(i),i.type==="audio"&&rh(i,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(t,cn.write(n)),t})}createDataChannel(e,t){return this.pc.createDataChannel(e,t)}addTransceiver(e,t){return this.pc.addTransceiver(e,t)}addTransceiverOfKind(e,t){return this.pc.addTransceiver(e,t)}addTrack(e){if(!this._pc)throw new Xe("PC closed, cannot add track");return this._pc.addTrack(e)}setTrackCodecBitrate(e){this.trackBitrates.push(e)}setConfiguration(e){var t;if(!this._pc)throw new Xe("PC closed, cannot configure");return(t=this._pc)===null||t===void 0?void 0:t.setConfiguration(e)}canRemoveTrack(){var e;return!!(!((e=this._pc)===null||e===void 0)&&e.removeTrack)}removeTrack(e){var t;return(t=this._pc)===null||t===void 0?void 0:t.removeTrack(e)}getConnectionState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.connectionState)!==null&&t!==void 0?t:"closed"}getICEConnectionState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.iceConnectionState)!==null&&t!==void 0?t:"closed"}getSignallingState(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.signalingState)!==null&&t!==void 0?t:"closed"}getTransceivers(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.getTransceivers())!==null&&t!==void 0?t:[]}getSenders(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.getSenders())!==null&&t!==void 0?t:[]}getLocalDescription(){var e;return(e=this._pc)===null||e===void 0?void 0:e.localDescription}getRemoteDescription(){var e;return(e=this.pc)===null||e===void 0?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getMaxMessageSize(){var e,t;return(t=(e=this._pc)===null||e===void 0?void 0:e.sctp)===null||t===void 0?void 0:t.maxMessageSize}getConnectedAddress(){return k(this,void 0,void 0,function*(){var e;if(!this._pc)return;let t="";const n=new Map,i=new Map;if((yield this._pc.getStats()).forEach(A=>{switch(A.type){case"transport":t=A.selectedCandidatePairId;break;case"candidate-pair":t===""&&A.selected&&(t=A.id),n.set(A.id,A);break;case"remote-candidate":i.set(A.id,"".concat(A.address,":").concat(A.port));break}}),t==="")return;const a=(e=n.get(t))===null||e===void 0?void 0:e.remoteCandidateId;if(a!==void 0)return i.get(a)})}setMungedSDP(e,t,n){return k(this,void 0,void 0,function*(){var i,s;const a=e.sdp;if(t){e.sdp=t;try{this.log.debug("setting munged ".concat(n?"remote":"local"," description"),this.logContext),n?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(A){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:A,mungedSdp:t,originalSdp:a})),e.sdp=a}}try{n?yield(i=this._pc)===null||i===void 0?void 0:i.setRemoteDescription(e):yield(s=this._pc)===null||s===void 0?void 0:s.setLocalDescription(e)}catch(A){let o="unknown error";A instanceof Error?o=A.message:typeof A=="string"&&(o=A);const c={error:o,sdp:e.sdp};throw t&&t!==a&&(c.mungedSdp=t),!n&&this.pc.remoteDescription&&(c.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:c})),new mi(o)}})}ensureVideoDDExtensionForSVC(e,t){var n,i;if(!((n=e.ext)===null||n===void 0?void 0:n.some(a=>a.uri===H0))){if(this.ddExtID===0){let a=0;t.media.forEach(A=>{var o;(o=A.ext)===null||o===void 0||o.forEach(c=>{c.value>a&&(a=c.value)})}),this.ddExtID=a+1}(i=e.ext)===null||i===void 0||i.push({value:this.ddExtID,uri:H0})}}}function rh(r,e,t){const n=yu(r.mid);let i=0;r.rtp.some(s=>s.codec==="opus"?(i=s.payload,!0):!1),i>0&&(r.rtcpFb||(r.rtcpFb=[]),t.includes(n)&&!r.rtcpFb.some(s=>s.payload===i&&s.type==="nack")&&r.rtcpFb.push({payload:i,type:"nack"}),(e.includes(n)||e.length===1&&e[0]==="all")&&r.fmtp.some(s=>s.payload===i?(s.config.includes("stereo=1")||(s.config+=";stereo=1"),!0):!1))}function M2(r){var e;const t=[],n=[],i=cn.parse((e=r.sdp)!==null&&e!==void 0?e:"");let s=0;return i.media.forEach(a=>{var A;const o=yu(a.mid);a.type==="audio"&&(a.rtp.some(c=>c.codec==="opus"?(s=c.payload,!0):!1),!((A=a.rtcpFb)===null||A===void 0)&&A.some(c=>c.payload===s&&c.type==="nack")&&n.push(o),a.fmtp.some(c=>c.payload===s?(c.config.includes("sprop-stereo=1")&&t.push(o),!0):!1))}),{stereoMids:t,nackMids:n}}function _a(r){if(r.connection){const e=r.connection.ip.indexOf(":")>=0;(r.connection.version===4&&e||r.connection.version===6&&!e)&&(r.connection.ip="0.0.0.0",r.connection.version=4)}}function yu(r){return typeof r=="number"?r.toFixed(0):r}const ed="vp8",_2={audioPreset:zl.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:ou.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:ed,backupCodec:!0,preConnectBuffer:!1},_g={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},Rg={deviceId:{ideal:"default"},resolution:ca.h720.resolution},R2={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new Yb,disconnectOnPageLeave:!0,webAudioMix:!1,singlePeerConnection:!0},wu={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var Je;(function(r){r[r.NEW=0]="NEW",r[r.CONNECTING=1]="CONNECTING",r[r.CONNECTED=2]="CONNECTED",r[r.FAILED=3]="FAILED",r[r.CLOSING=4]="CLOSING",r[r.CLOSED=5]="CLOSED"})(Je||(Je={}));class ih{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}get mode(){return this._mode}constructor(e,t,n){var i;this.peerConnectionTimeout=wu.peerConnectionTimeout,this.log=me,this.updateState=()=>{var s,a;const A=this.state,o=this.requiredTransports.map(c=>c.getConnectionState());o.every(c=>c==="connected")?this.state=Je.CONNECTED:o.some(c=>c==="failed")?this.state=Je.FAILED:o.some(c=>c==="connecting")?this.state=Je.CONNECTING:o.every(c=>c==="closed")?this.state=Je.CLOSED:o.some(c=>c==="closed")?this.state=Je.CLOSING:o.every(c=>c==="new")&&(this.state=Je.NEW),A!==this.state&&(this.log.debug("pc state change: from ".concat(Je[A]," to ").concat(Je[this.state]),this.logContext),(s=this.onStateChange)===null||s===void 0||s.call(this,this.state,this.publisher.getConnectionState(),(a=this.subscriber)===null||a===void 0?void 0:a.getConnectionState()))},this.log=Xt((i=t.loggerName)!==null&&i!==void 0?i:Ct.PCManager),this.loggerOptions=t,this.isPublisherConnectionRequired=e!=="subscriber-primary",this.isSubscriberConnectionRequired=e==="subscriber-primary",this.publisher=new nh(n,t),this._mode=e,e!=="publisher-only"&&(this.subscriber=new nh(n,t),this.subscriber.onConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.subscriber.onIceCandidate=s=>{var a;(a=this.onIceCandidate)===null||a===void 0||a.call(this,s,xn.SUBSCRIBER)},this.subscriber.onDataChannel=s=>{var a;(a=this.onDataChannel)===null||a===void 0||a.call(this,s)},this.subscriber.onTrack=s=>{var a;(a=this.onTrack)===null||a===void 0||a.call(this,s)}),this.publisher.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=s=>{var a;(a=this.onIceCandidate)===null||a===void 0||a.call(this,s,xn.PUBLISHER)},this.publisher.onTrack=s=>{var a;(a=this.onTrack)===null||a===void 0||a.call(this,s)},this.publisher.onOffer=(s,a)=>{var A;(A=this.onPublisherOffer)===null||A===void 0||A.call(this,s,a)},this.state=Je.NEW,this.connectionLock=new xt,this.remoteOfferLock=new xt}get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions).loggerContextCb)===null||t===void 0?void 0:t.call(e))}requirePublisher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isPublisherConnectionRequired=e,this.updateState()}createAndSendPublisherOffer(e){return this.publisher.createAndSendOffer(e)}setPublisherAnswer(e,t){return this.publisher.setRemoteDescription(e,t)}removeTrack(e){return this.publisher.removeTrack(e)}close(){return k(this,void 0,void 0,function*(){var e;if(this.publisher&&this.publisher.getSignallingState()!=="closed"){const t=this.publisher;for(const n of t.getSenders())try{t.canRemoveTrack()&&t.removeTrack(n)}catch(i){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:i}))}}yield Promise.all([this.publisher.close(),(e=this.subscriber)===null||e===void 0?void 0:e.close()]),this.updateState()})}triggerIceRestart(){return k(this,void 0,void 0,function*(){this.subscriber&&(this.subscriber.restartingIce=!0),this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,t){return k(this,void 0,void 0,function*(){var n;t===xn.PUBLISHER?yield this.publisher.addIceCandidate(e):yield(n=this.subscriber)===null||n===void 0?void 0:n.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e,t){return k(this,void 0,void 0,function*(){var n,i,s;this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:(n=this.subscriber)===null||n===void 0?void 0:n.getSignallingState().toString()}));const a=yield this.remoteOfferLock.lock();try{return(yield(i=this.subscriber)===null||i===void 0?void 0:i.setRemoteDescription(e,t))?yield(s=this.subscriber)===null||s===void 0?void 0:s.createAndSetAnswer():void 0}finally{a()}})}updateConfiguration(e,t){var n;this.publisher.setConfiguration(e),(n=this.subscriber)===null||n===void 0||n.setConfiguration(e),t&&this.triggerIceRestart()}ensurePCTransportConnection(e,t){return k(this,void 0,void 0,function*(){var n;const i=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&this.publisher.getConnectionState()!=="connected"&&this.publisher.getConnectionState()!=="connecting"&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all((n=this.requiredTransports)===null||n===void 0?void 0:n.map(s=>this.ensureTransportConnected(s,e,t)))}finally{i()}})}negotiate(e){return k(this,void 0,void 0,function*(){return new Lt((t,n)=>{const i=this.publisher.latestOfferId;if(this.publisher.latestAcknowledgedOfferId>i){this.log.debug("negotiation already handled in more recent acknowledged offer",this.logContext),t();return}let s=!1;const a=()=>{s||(s=!0,clearTimeout(c),this.publisher.off(Dr.OfferAnswered,A),e.signal.removeEventListener("abort",o))},A=l=>{l>i&&(a(),t())},o=()=>{a(),n(new mi("negotiation aborted"))},c=setTimeout(()=>{a(),n(new mi("negotiation timed out"))},this.peerConnectionTimeout);e.signal.addEventListener("abort",o),this.publisher.on(Dr.OfferAnswered,A),this.publisher.negotiate(l=>{a(),l instanceof Error?n(l):n(new Error(String(l)))})})})}addPublisherTransceiver(e,t){return this.publisher.addTransceiver(e,t)}addPublisherTransceiverOfKind(e,t){return this.publisher.addTransceiverOfKind(e,t)}getMidForReceiver(e){const n=(this.subscriber?this.subscriber.getTransceivers():this.publisher.getTransceivers()).find(i=>i.receiver===e);return n==null?void 0:n.mid}getMaxPublisherMessageSize(){return this.publisher.getMaxMessageSize()}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,t){return this.publisher.createDataChannel(e,t)}getConnectedAddress(e){return e===xn.PUBLISHER?this.publisher.getConnectedAddress():e===xn.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){const e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&this.subscriber&&e.push(this.subscriber),e}ensureTransportConnected(e,t){return k(this,arguments,void 0,function(n,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return function*(){if(n.getConnectionState()!=="connected")return new Promise((o,c)=>k(s,void 0,void 0,function*(){const l=()=>{this.log.warn("abort transport connection",this.logContext),dt.clearTimeout(d),c(oe.cancelled("room connection has been cancelled"))};i!=null&&i.signal.aborted&&l(),i==null||i.signal.addEventListener("abort",l);const d=dt.setTimeout(()=>{i==null||i.signal.removeEventListener("abort",l),c(oe.internal("could not establish pc connection"))},a);for(;this.state!==Je.CONNECTED;)if(yield Qt(50),i!=null&&i.signal.aborted){c(oe.cancelled("room connection has been cancelled"));return}dt.clearTimeout(d),i==null||i.signal.removeEventListener("abort",l),o()}))}()})}}const bu=typeof MediaRecorder<"u";class P2{constructor(){throw new Error("MediaRecorder is not available in this environment")}}const D2=bu?MediaRecorder:P2;class L2 extends D2{constructor(e,t){if(!bu)throw new Error("MediaRecorder is not available in this environment");super(new MediaStream([e.mediaStreamTrack]),t);let n,i;const s=()=>i===void 0,a=()=>{this.removeEventListener("dataavailable",n),this.removeEventListener("stop",a),this.removeEventListener("error",A),i==null||i.close(),i=void 0},A=o=>{i==null||i.error(o),this.removeEventListener("dataavailable",n),this.removeEventListener("stop",a),this.removeEventListener("error",A),i=void 0};this.byteStream=new ReadableStream({start:o=>{i=o,n=c=>k(this,void 0,void 0,function*(){let l;if(c.data.arrayBuffer){const d=yield c.data.arrayBuffer();l=new Uint8Array(d)}else if(c.data.byteArray)l=c.data.byteArray;else throw new Error("no data available!");s()||o.enqueue(l)}),this.addEventListener("dataavailable",n)},cancel:()=>{a()}}),this.addEventListener("stop",a),this.addEventListener("error",A)}}function O2(){return bu}const H2=1e3,N2=1e4;class Pg extends N{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}get hasPreConnectBuffer(){return!!this.localTrackRecorder}constructor(e,t,n){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,s=arguments.length>4?arguments[4]:void 0;super(e,t,s),this.manuallyStopped=!1,this.pendingDeviceChange=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext)),this.debouncedTrackMuteHandler=uu(()=>k(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>k(this,void 0,void 0,function*(){this.debouncedTrackMuteHandler.cancel("unmute"),yield this.resumeUpstream()}),this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),this.emit($.Ended,this)},this.reacquireTrack=!1,this.providedByUser=i,this.muteLock=new xt,this.pauseUpstreamLock=new xt,this.trackChangeLock=new xt,this.trackChangeLock.lock().then(a=>k(this,void 0,void 0,function*(){try{yield this.setMediaStreamTrack(e,!0)}finally{a()}})),this._constraints=e.getConstraints(),n&&(this._constraints=n)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==N.Kind.Video)return;const e=this._mediaStreamTrack.getSettings(),t=e.width,n=e.height;if(t&&n)return{width:t,height:n}}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,t;return(t=(e=this.processor)===null||e===void 0?void 0:e.processedTrack)!==null&&t!==void 0?t:this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,t,n){return k(this,void 0,void 0,function*(){var i;if(e===this._mediaStreamTrack&&!t)return;this._mediaStreamTrack&&(this.attachedElements.forEach(a=>{$i(this._mediaStreamTrack,a)}),this.debouncedTrackMuteHandler.cancel("new-track"),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent)),this.mediaStream=new MediaStream([e]),e&&(e.addEventListener("ended",this.handleEnded),e.addEventListener("mute",this.handleTrackMuteEvent),e.addEventListener("unmute",this.handleTrackUnmuteEvent),this._constraints=e.getConstraints());let s;if(this.processor&&e){if(this.log.debug("restarting processor",this.logContext),this.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(Vi(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement,localTrack:this}),s=this.processor.processedTrack}this.sender&&((i=this.sender.transport)===null||i===void 0?void 0:i.state)!=="closed"&&(yield this.sender.replaceTrack(s??e)),!this.providedByUser&&this._mediaStreamTrack!==e&&this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=n?!0:!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(a=>{Vi(s??e,a)}))})}waitForDimensions(){return k(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:H2;return function*(){var n;if(e.kind===N.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((n=Ht())===null||n===void 0?void 0:n.os)==="iOS"&&(yield Qt(10));const i=Date.now();for(;Date.now()-i<t;){const s=e.dimensions;if(s)return s;yield Qt(50)}throw new mr("unable to get track dimensions after timeout")}()})}setDeviceId(e){return k(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===gi(e)?!0:(this._constraints.deviceId=e,this.isMuted?(this.pendingDeviceChange=!0,!0):(yield this.restartTrack(),gi(e)===this._mediaStreamTrack.getSettings().deviceId))})}getDeviceId(){return k(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){if(e.source===N.Source.ScreenShare)return;const n=e._mediaStreamTrack.getSettings(),i=n.deviceId,s=n.groupId,a=e.kind===N.Kind.Audio?"audioinput":"videoinput";return t?bt.getInstance().normalizeDeviceId(a,i,s):i}()})}mute(){return k(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return k(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,t){return k(this,void 0,void 0,function*(){const n=yield this.trackChangeLock.lock();try{if(!this.sender)throw new mr("unable to replace an unpublished track");let i,s;typeof t=="boolean"?i=t:t!==void 0&&(i=t.userProvidedTrack,s=t.stopProcessor),this.providedByUser=i??!0,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),s&&this.processor&&(yield this.internalStopProcessor())}finally{n()}return yield this.onSenderTrackSwapped(),this})}onSenderTrackSwapped(){return k(this,void 0,void 0,function*(){})}restart(e,t){return k(this,void 0,void 0,function*(){this.manuallyStopped=!1;const n=yield this.trackChangeLock.lock();try{e||(e=this._constraints);const i=e,s=i.deviceId,a=i.facingMode,A=Zb(e,["deviceId","facingMode"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const o={audio:!1,video:!1};this.kind===N.Kind.Video?o.video=s||a?{deviceId:s,facingMode:a}:!0:o.audio=s?Object.assign({deviceId:s},A):!0,this.attachedElements.forEach(d=>{$i(this.mediaStreamTrack,d)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const l=(yield navigator.mediaDevices.getUserMedia(o)).getTracks()[0];return this.kind===N.Kind.Video&&(yield l.applyConstraints(A)),l.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(l,!1,t),this._constraints=e,this.pendingDeviceChange=!1,this.emit($.Restarted,this),this.manuallyStopped&&(this.log.warn("track was stopped during a restart, stopping restarted track",this.logContext),this.stop()),this}finally{n()}})}setTrackMuted(e){this.log.debug("setting ".concat(this.kind," track ").concat(e?"muted":"unmuted"),this.logContext),!(this.isMuted===e&&this._mediaStreamTrack.enabled!==e)&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?$.Muted:$.Unmuted,this))}get needsReAcquisition(){return this._mediaStreamTrack.readyState!=="live"||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return k(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),xg()&&(this.log.debug("visibility changed, is in Background: ".concat(this.isInBackground),this.logContext),!this.isInBackground&&this.needsReAcquisition&&!this.isUserProvided&&!this.isMuted&&(this.log.debug("track needs to be reacquired, restarting ".concat(this.source),this.logContext),yield this.restart(),this.reacquireTrack=!1))})}stop(){var e;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),(e=this.processor)===null||e===void 0||e.destroy(),this.processor=void 0}pauseUpstream(){return k(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!0)return;if(!this.sender){this.log.warn("unable to pause upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!0,this.emit($.UpstreamPaused,this);const n=Ht();if((n==null?void 0:n.name)==="Safari"&&Jn(n.version,"12.0")<0)throw new Au("pauseUpstream is not supported on Safari < 12.");((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(null))}finally{t()}})}resumeUpstream(){return k(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!1)return;if(!this.sender){this.log.warn("unable to resume upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!1,this.emit($.UpstreamResumed,this),((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{t()}})}getRTCStatsReport(){return k(this,void 0,void 0,function*(){var e;return!((e=this.sender)===null||e===void 0)&&e.getStats?yield this.sender.getStats():void 0})}setProcessor(e){return k(this,arguments,void 0,function(t){var n=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var s;const a=yield n.trackChangeLock.lock();try{n.log.debug("setting up processor",n.logContext);const A=document.createElement(n.kind),o={kind:n.kind,track:n._mediaStreamTrack,element:A,audioContext:n.audioContext,localTrack:n};if(yield t.init(o),n.log.debug("processor initialized",n.logContext),n.processor&&(yield n.internalStopProcessor()),n.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");if(Vi(n._mediaStreamTrack,A),A.muted=!0,A.play().catch(c=>{c instanceof DOMException&&c.name==="AbortError"?(n.log.warn("failed to play processor element, retrying",Object.assign(Object.assign({},n.logContext),{error:c})),setTimeout(()=>{A.play().catch(l=>{n.log.error("failed to play processor element",Object.assign(Object.assign({},n.logContext),{err:l}))})},100)):n.log.error("failed to play processor element",Object.assign(Object.assign({},n.logContext),{error:c}))}),n.processor=t,n.processorElement=A,n.processor.processedTrack){for(const c of n.attachedElements)c!==n.processorElement&&i&&($i(n._mediaStreamTrack,c),Vi(n.processor.processedTrack,c));yield(s=n.sender)===null||s===void 0?void 0:s.replaceTrack(n.processor.processedTrack)}n.emit($.TrackProcessorUpdate,n.processor)}finally{a()}yield n.onSenderTrackSwapped()}()})}getProcessor(){return this.processor}stopProcessor(){return k(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){const n=yield e.trackChangeLock.lock();try{yield e.internalStopProcessor(t)}finally{n()}yield e.onSenderTrackSwapped()}()})}internalStopProcessor(){return k(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var n,i;e.processor&&(e.log.debug("stopping processor",e.logContext),(n=e.processor.processedTrack)===null||n===void 0||n.stop(),yield e.processor.destroy(),e.processor=void 0,t||((i=e.processorElement)===null||i===void 0||i.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit($.TrackProcessorUpdate))}()})}startPreConnectBuffer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!O2()){this.log.warn("MediaRecorder is not available, cannot start preconnect buffer",this.logContext);return}if(this.localTrackRecorder){this.log.warn("preconnect buffer already started");return}else{let t="audio/webm;codecs=opus";MediaRecorder.isTypeSupported(t)||(t="video/mp4"),this.localTrackRecorder=new L2(this,{mimeType:t})}this.localTrackRecorder.start(e),this.autoStopPreConnectBuffer=setTimeout(()=>{this.log.warn("preconnect buffer timed out, stopping recording automatically",this.logContext),this.stopPreConnectBuffer()},N2)}stopPreConnectBuffer(){clearTimeout(this.autoStopPreConnectBuffer),this.localTrackRecorder&&(this.localTrackRecorder.stop(),this.localTrackRecorder=void 0)}getPreConnectBuffer(){var e;return(e=this.localTrackRecorder)===null||e===void 0?void 0:e.byteStream}getPreConnectBufferMimeType(){var e;return(e=this.localTrackRecorder)===null||e===void 0?void 0:e.mimeType}}class ZA extends Pg{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;super(e,N.Kind.Audio,t,n,s),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>k(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let a;try{a=yield this.getSenderStats()}catch(A){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:A}));return}a&&this.prevStats&&(this._currentBitrate=Qo(a,this.prevStats)),this.prevStats=a}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit($.AudioTrackFeatureUpdate,this,wt.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit($.AudioTrackFeatureUpdate,this,wt.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=i,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return k(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===N.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug("stopping mic track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return k(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source===N.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState==="ended"||this.pendingDeviceChange)&&!this.isUserProvided&&(this.log.debug("reacquiring mic track",this.logContext),yield this.restart(void 0,!0)),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{t()}})}restartTrack(e){return k(this,void 0,void 0,function*(){let t;if(e){const n=cu({audio:e});typeof n.audio!="boolean"&&(t=n.audio)}yield this.restart(t)})}restart(e,t){const n=Object.create(null,{restart:{get:()=>super.restart}});return k(this,void 0,void 0,function*(){const i=yield n.restart.call(this,e,t);return this.checkForSilence(),i})}startMonitor(){$t()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},hu)))}setProcessor(e){return k(this,void 0,void 0,function*(){var t;const n=yield this.trackChangeLock.lock();try{if(!Rn()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.internalStopProcessor());const i={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext,localTrack:this};this.log.debug("setting up audio processor ".concat(e.name),this.logContext),yield e.init(i),this.processor=e,this.processor.processedTrack&&(yield(t=this.sender)===null||t===void 0?void 0:t.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener("enable-lk-krisp-noise-filter",this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener("disable-lk-krisp-noise-filter",this.handleKrispNoiseFilterDisable)),this.emit($.TrackProcessorUpdate,this.processor)}finally{n()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return k(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return;const t=yield this.sender.getStats();let n;return t.forEach(i=>{i.type==="outbound-rtp"&&(n={type:"audio",streamId:i.id,packetsSent:i.packetsSent,packetsLost:i.packetsLost,bytesSent:i.bytesSent,timestamp:i.timestamp,roundTripTime:i.roundTripTime,jitter:i.jitter})}),n})}checkForSilence(){return k(this,void 0,void 0,function*(){const e=yield Sg(this);return e&&(this.isMuted||this.log.debug("silence detected on local audio track",this.logContext),this.emit($.AudioSilenceDetected)),e})}}function K2(r,e,t){switch(r.kind){case"audio":return new ZA(r,e,!1,void 0,t);case"video":return new to(r,e,!1,t);default:throw new mr("unsupported track type: ".concat(r.kind))}}const V2=Object.values(ca),z2=Object.values(Gl),G2=Object.values(ou),q2=[ca.h180,ca.h360],W2=[Gl.h180,Gl.h360],$2=r=>[{scaleResolutionDownBy:2,fps:r.encoding.maxFramerate}].map(t=>{var n,i;return new Me(Math.floor(r.width/t.scaleResolutionDownBy),Math.floor(r.height/t.scaleResolutionDownBy),Math.max(15e4,Math.floor(r.encoding.maxBitrate/(Math.pow(t.scaleResolutionDownBy,2)*(((n=r.encoding.maxFramerate)!==null&&n!==void 0?n:30)/((i=t.fps)!==null&&i!==void 0?i:30))))),t.fps,r.encoding.priority)}),td=["q","h","f"];function eo(r,e,t,n){var i,s;let a=n==null?void 0:n.videoEncoding;r&&(a=n==null?void 0:n.screenShareEncoding);const A=n==null?void 0:n.simulcast,o=n==null?void 0:n.scalabilityMode,c=n==null?void 0:n.videoCodec;if(!a&&!A&&!o||!e||!t)return[{}];a||(a=j2(r,e,t,c),me.debug("using video encoding",a));const l=a.maxFramerate,d=new Me(e,t,a.maxBitrate,a.maxFramerate,a.priority);if(o&&Un(c)){const v=new Lg(o),w=[];if(v.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(o));const B=Ht();if(la()||Rn()||(B==null?void 0:B.name)==="Chrome"&&Jn(B==null?void 0:B.version,"113")<0){const E=v.suffix=="h"?2:3,b=O4(B);for(let C=0;C<v.spatial;C+=1)w.push({rid:td[2-C],maxBitrate:a.maxBitrate/Math.pow(E,C),maxFramerate:d.encoding.maxFramerate,scaleResolutionDownBy:b?Math.pow(2,C):void 0});w[0].scalabilityMode=o}else w.push({maxBitrate:a.maxBitrate,maxFramerate:d.encoding.maxFramerate,scalabilityMode:o});return d.encoding.priority&&(w[0].priority=d.encoding.priority,w[0].networkPriority=d.encoding.priority),me.debug("using svc encoding",{encodings:w}),w}if(!A)return[a];let u;r?u=(i=ah(n==null?void 0:n.screenShareSimulcastLayers))!==null&&i!==void 0?i:sh(r,d):u=(s=ah(n==null?void 0:n.videoSimulcastLayers))!==null&&s!==void 0?s:sh(r,d);let h;if(u.length>0){const v=u[0];if(u.length>1){var p=u,g=Ae(p,2);h=g[1]}const w=Math.max(e,t);if(w>=960&&h)return Fc(e,t,[v,h,d],l);if(w>=480)return Fc(e,t,[v,d],l)}return Fc(e,t,[d])}function Dg(r,e,t){var n,i,s,a;if(!t.backupCodec||t.backupCodec===!0||t.backupCodec.codec===t.videoCodec)return;e!==t.backupCodec.codec&&me.warn("requested a different codec than specified as backup",{serverRequested:e,backup:t.backupCodec.codec}),t.videoCodec=e,t.videoEncoding=t.backupCodec.encoding;const A=r.mediaStreamTrack.getSettings(),o=(n=A.width)!==null&&n!==void 0?n:(i=r.dimensions)===null||i===void 0?void 0:i.width,c=(s=A.height)!==null&&s!==void 0?s:(a=r.dimensions)===null||a===void 0?void 0:a.height;return r.source===N.Source.ScreenShare&&t.simulcast&&(t.simulcast=!1),eo(r.source===N.Source.ScreenShare,o,c,t)}function j2(r,e,t,n){const i=X2(r,e,t);let s=i[0].encoding;const a=Math.max(e,t);for(let A=0;A<i.length;A+=1){const o=i[A];if(s=o.encoding,o.width>=a)break}if(n)switch(n){case"av1":case"h265":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.7;break;case"vp9":s=Object.assign({},s),s.maxBitrate=s.maxBitrate*.85;break}return s}function X2(r,e,t){if(r)return G2;const n=e>t?e/t:t/e;return Math.abs(n-16/9)<Math.abs(n-4/3)?V2:z2}function sh(r,e){if(r)return $2(e);const t=e.width,n=e.height,i=t>n?t/n:n/t;return Math.abs(i-16/9)<Math.abs(i-4/3)?q2:W2}function Fc(r,e,t,n){const i=[];if(t.forEach((s,a)=>{if(a>=td.length)return;const A=Math.min(r,e),c={rid:td[a],scaleResolutionDownBy:Math.max(1,A/Math.min(s.width,s.height)),maxBitrate:s.encoding.maxBitrate},l=n&&s.encoding.maxFramerate?Math.min(n,s.encoding.maxFramerate):s.encoding.maxFramerate;l&&(c.maxFramerate=l);const d=Ht(),u=(d==null?void 0:d.name)==="Firefox"&&d.os!=="iOS"||a===0;s.encoding.priority&&u&&(c.priority=s.encoding.priority,c.networkPriority=s.encoding.priority),i.push(c)}),Rn()&&Ug()==="ios"){let s;i.forEach(A=>{s?A.maxFramerate&&A.maxFramerate>s&&(s=A.maxFramerate):s=A.maxFramerate});let a=!0;i.forEach(A=>{var o;A.maxFramerate!=s&&(a&&(a=!1,me.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),me.info('Setting framerate of encoding "'.concat((o=A.rid)!==null&&o!==void 0?o:"",'" to ').concat(s)),A.maxFramerate=s)})}return i}function ah(r){if(r)return r.slice().sort((e,t)=>{const n=e.encoding,i=t.encoding;return n.maxBitrate>i.maxBitrate?1:n.maxBitrate<i.maxBitrate?-1:n.maxBitrate===i.maxBitrate&&n.maxFramerate&&i.maxFramerate?n.maxFramerate>i.maxFramerate?1:-1:0})}class Lg{constructor(e){const t=e.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);if(!t)throw new Error("invalid scalability mode");if(this.spatial=parseInt(t[1]),this.temporal=parseInt(t[2]),t.length>3)switch(t[3]){case"h":case"_KEY":case"_KEY_SHIFT":this.suffix=t[3]}}toString(){var e;return"L".concat(this.spatial,"T").concat(this.temporal).concat((e=this.suffix)!==null&&e!==void 0?e:"")}}function J2(r){return r.source===N.Source.ScreenShare||r.constraints.height&&gi(r.constraints.height)>=1080?"maintain-resolution":"balanced"}const Y2=5e3;class to extends Pg{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3?arguments[3]:void 0;super(e,N.Kind.Video,t,n,i),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.isCpuConstrained=!1,this.optimizeForPerformance=!1,this.monitorSender=()=>k(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let s;try{s=yield this.getSenderStats()}catch(o){this.log.error("could not get video sender stats",Object.assign(Object.assign({},this.logContext),{error:o}));return}const a=new Map(s.map(o=>[o.rid,o])),A=s.some(o=>o.qualityLimitationReason==="cpu");if(A!==this.isCpuConstrained&&(this.isCpuConstrained=A,this.isCpuConstrained&&this.emit($.CpuConstrained)),this.prevStats){let o=0;a.forEach((c,l)=>{var d;const u=(d=this.prevStats)===null||d===void 0?void 0:d.get(l);o+=Qo(c,u)}),this._currentBitrate=o}this.prevStats=a}),this.senderLock=new xt}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!$t())return;const n=(t=this.sender)===null||t===void 0?void 0:t.getParameters();n&&(this.encodings=n.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},hu))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return k(this,void 0,void 0,function*(){var t,n,i,s,a;yield e.pauseUpstream.call(this);try{for(var A=!0,o=En(this.simulcastCodecs.values()),c;c=yield o.next(),t=c.done,!t;A=!0)s=c.value,A=!1,yield(a=s.sender)===null||a===void 0?void 0:a.replaceTrack(null)}catch(l){n={error:l}}finally{try{!A&&!t&&(i=o.return)&&(yield i.call(o))}finally{if(n)throw n.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return k(this,void 0,void 0,function*(){var t,n,i,s,a;yield e.resumeUpstream.call(this);try{for(var A=!0,o=En(this.simulcastCodecs.values()),c;c=yield o.next(),t=c.done,!t;A=!0){s=c.value,A=!1;const l=s;yield(a=l.sender)===null||a===void 0?void 0:a.replaceTrack(l.mediaStreamTrack)}}catch(l){n={error:l}}finally{try{!A&&!t&&(i=o.return)&&(yield i.call(o))}finally{if(n)throw n.error}}})}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return k(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===N.Source.Camera&&!this.isUserProvided&&(this.log.debug("stopping camera track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return k(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source===N.Source.Camera&&!this.isUserProvided&&(this.log.debug("reacquiring camera track",this.logContext),yield this.restart(void 0,!0)),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{t()}})}setTrackMuted(e){super.setTrackMuted(e);for(const t of this.simulcastCodecs.values())t.mediaStreamTrack.enabled=!e}getSenderStats(){return k(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return[];const t=[],n=yield this.sender.getStats();return n.forEach(i=>{var s;if(i.type==="outbound-rtp"){const a={type:"video",streamId:i.id,frameHeight:i.frameHeight,frameWidth:i.frameWidth,framesPerSecond:i.framesPerSecond,framesSent:i.framesSent,firCount:i.firCount,pliCount:i.pliCount,nackCount:i.nackCount,packetsSent:i.packetsSent,bytesSent:i.bytesSent,qualityLimitationReason:i.qualityLimitationReason,qualityLimitationDurations:i.qualityLimitationDurations,qualityLimitationResolutionChanges:i.qualityLimitationResolutionChanges,rid:(s=i.rid)!==null&&s!==void 0?s:i.id,retransmittedPacketsSent:i.retransmittedPacketsSent,targetBitrate:i.targetBitrate,timestamp:i.timestamp},A=n.get(i.remoteId);A&&(a.jitter=A.jitter,a.packetsLost=A.packetsLost,a.roundTripTime=A.roundTripTime),t.push(a)}}),t.sort((i,s)=>{var a,A;return((a=s.frameWidth)!==null&&a!==void 0?a:0)-((A=i.frameWidth)!==null&&A!==void 0?A:0)}),t})}setPublishingQuality(e){const t=[];for(let n=sn.LOW;n<=sn.HIGH;n+=1)t.push(new su({quality:n,enabled:n<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(Un(this.codec),t)}restartTrack(e){return k(this,void 0,void 0,function*(){var t,n,i,s,a;let A;if(e){const d=cu({video:e});typeof d.video!="boolean"&&(A=d.video)}yield this.restart(A),this.isCpuConstrained=!1;try{for(var o=!0,c=En(this.simulcastCodecs.values()),l;l=yield c.next(),t=l.done,!t;o=!0){s=l.value,o=!1;const d=s;d.sender&&((a=d.sender.transport)===null||a===void 0?void 0:a.state)!=="closed"&&(d.mediaStreamTrack=this.mediaStreamTrack.clone(),yield d.sender.replaceTrack(d.mediaStreamTrack))}}catch(d){n={error:d}}finally{try{!o&&!t&&(i=c.return)&&(yield i.call(c))}finally{if(n)throw n.error}}yield this.onSenderTrackSwapped()})}onSenderTrackSwapped(){return k(this,void 0,void 0,function*(){yield this.refreshSenderEncodings()})}refreshSenderEncodings(){return k(this,void 0,void 0,function*(){var e;if(!this.sender||!this.publishOptions||this.optimizeForPerformance)return;const t=yield this.senderLock.lock();try{let i;try{i=yield this.waitForDimensions()}catch(A){this.log.warn("could not determine new track dimensions, skipping encoding recompute",Object.assign(Object.assign({},this.logContext),{error:A}));return}if(this.lastEncodedDimensions&&this.lastEncodedDimensions.width===i.width&&this.lastEncodedDimensions.height===i.height)return;const s=this.source===N.Source.ScreenShare,a=eo(s,i.width,i.height,Object.assign({},this.publishOptions));yield this.applyEncodingsToSender(this.sender,a),this.encodings=a,this.lastEncodedDimensions=i;for(const A of this.simulcastCodecs){var n=Ae(A,2);const o=n[0],c=n[1];if(!c.sender||((e=c.sender.transport)===null||e===void 0?void 0:e.state)==="closed"||!Bg(o))continue;const l=Object.assign({},this.publishOptions),d=Dg(this,o,l);d&&(yield this.applyEncodingsToSender(c.sender,d),c.encodings=d)}}catch(i){this.log.warn("failed to apply recomputed encodings",Object.assign(Object.assign({},this.logContext),{error:i}))}finally{t()}})}applyEncodingsToSender(e,t){return k(this,void 0,void 0,function*(){const n=e.getParameters();!n.encodings||n.encodings.length!==t.length||(n.encodings.forEach((i,s)=>{if(i.active===!1)return;const a=t[s];a.scaleResolutionDownBy!==void 0&&(i.scaleResolutionDownBy=a.scaleResolutionDownBy),a.maxBitrate!==void 0&&(i.maxBitrate=a.maxBitrate),a.maxFramerate!==void 0&&(i.maxFramerate=a.maxFramerate),a.priority!==void 0&&(i.priority=a.priority,i.networkPriority=a.priority)}),this.log.debug("updating sender encodings after track restart",Object.assign(Object.assign({},this.logContext),{encodings:n.encodings})),yield e.setParameters(n))})}setProcessor(e){const t=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return k(this,arguments,void 0,function(n){var i=this;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var a,A,o,c,l,d;if(yield t.setProcessor.call(i,n,s),!((l=i.processor)===null||l===void 0)&&l.processedTrack)try{for(var u=!0,h=En(i.simulcastCodecs.values()),p;p=yield h.next(),a=p.done,!a;u=!0)c=p.value,u=!1,yield(d=c.sender)===null||d===void 0?void 0:d.replaceTrack(i.processor.processedTrack)}catch(g){A={error:g}}finally{try{!u&&!a&&(o=h.return)&&(yield o.call(h))}finally{if(A)throw A.error}}}()})}setDegradationPreference(e){return k(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug("setting degradationPreference to ".concat(e),this.logContext);const t=this.sender.getParameters();t.degradationPreference=e,this.sender.setParameters(t)}catch(t){this.log.warn("failed to set degradationPreference",Object.assign({error:t},this.logContext))}})}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e)){this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);return}const n={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,n),n}setSimulcastTrackSender(e,t){const n=this.simulcastCodecs.get(e);n&&(n.sender=t,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},Y2))}setPublishingCodecs(e){return k(this,void 0,void 0,function*(){var t,n,i,s,a,A,o;if(this.log.debug("setting publishing codecs",Object.assign(Object.assign({},this.logContext),{codecs:e,currentCodec:this.codec})),!this.codec&&e.length>0)return yield this.setPublishingLayers(Un(e[0].codec),e[0].qualities),[];this.subscribedCodecs=e;const c=[];try{for(t=!0,n=En(e);i=yield n.next(),s=i.done,!s;t=!0){o=i.value,t=!1;const l=o;if(!this.codec||this.codec===l.codec)yield this.setPublishingLayers(Un(l.codec),l.qualities);else{const d=this.simulcastCodecs.get(l.codec);if(this.log.debug("try setPublishingCodec for ".concat(l.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:d})),!d||!d.sender){for(const u of l.qualities)if(u.enabled){c.push(l.codec);break}}else d.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(l.codec),this.logContext),yield Ah(d.sender,d.encodings,l.qualities,this.senderLock,Un(l.codec),this.log,this.logContext))}}}catch(l){a={error:l}}finally{try{!t&&!s&&(A=n.return)&&(yield A.call(n))}finally{if(a)throw a.error}}return c})}setPublishingLayers(e,t){return k(this,void 0,void 0,function*(){if(this.optimizeForPerformance){this.log.info("skipping setPublishingLayers due to optimized publishing performance",Object.assign(Object.assign({},this.logContext),{qualities:t}));return}this.log.debug("setting publishing layers",Object.assign(Object.assign({},this.logContext),{qualities:t})),!(!this.sender||!this.encodings)&&(yield Ah(this.sender,this.encodings,t,this.senderLock,e,this.log,this.logContext))})}prioritizePerformance(){return k(this,void 0,void 0,function*(){if(!this.sender)throw new Error("sender not found");const e=yield this.senderLock.lock();try{this.optimizeForPerformance=!0;const t=this.sender.getParameters();t.encodings=t.encodings.map((n,i)=>{var s;return Object.assign(Object.assign({},n),{active:i===0,scaleResolutionDownBy:Math.max(1,Math.ceil(((s=this.mediaStreamTrack.getSettings().height)!==null&&s!==void 0?s:360)/360)),scalabilityMode:i===0&&Un(this.codec)?"L1T3":void 0,maxFramerate:i===0?15:0,maxBitrate:i===0?n.maxBitrate:0})}),this.log.debug("setting performance optimised encodings",Object.assign(Object.assign({},this.logContext),{encodings:t.encodings})),this.encodings=t.encodings,yield this.sender.setParameters(t)}catch(t){this.log.error("failed to set performance optimised encodings",Object.assign(Object.assign({},this.logContext),{error:t})),this.optimizeForPerformance=!1}finally{e()}})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return k(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),xg()&&this.isInBackground&&this.source===N.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function Ah(r,e,t,n,i,s,a){return k(this,void 0,void 0,function*(){const A=yield n.lock();s.debug("setPublishingLayersForSender",Object.assign(Object.assign({},a),{sender:r,qualities:t,senderEncodings:e}));try{const o=r.getParameters(),c=o.encodings;if(!c)return;if(c.length!==e.length){s.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},a),{encodings:c,senderEncodings:e}));return}let l=!1;!1&&c[0].scalabilityMode||(i&&t.some(h=>h.enabled)&&t.forEach(h=>h.enabled=!0),c.forEach((u,h)=>{var p;let g=(p=u.rid)!==null&&p!==void 0?p:"";g===""&&(g="q");const v=Og(g),w=t.find(B=>B.quality===v);w&&u.active!==w.enabled&&(l=!0,u.active=w.enabled,s.debug("setting layer ".concat(w.quality," to ").concat(u.active?"enabled":"disabled"),a),Ci()&&(w.enabled?(u.scaleResolutionDownBy=e[h].scaleResolutionDownBy,u.maxBitrate=e[h].maxBitrate,u.maxFrameRate=e[h].maxFrameRate):(u.scaleResolutionDownBy=4,u.maxBitrate=10,u.maxFrameRate=2)))})),l&&(o.encodings=c,s.debug("setting encodings",Object.assign(Object.assign({},a),{encodings:o.encodings})),yield r.setParameters(o))}finally{A()}})}function Og(r){switch(r){case"f":return sn.HIGH;case"h":return sn.MEDIUM;case"q":return sn.LOW;default:return sn.HIGH}}function oh(r,e,t,n){if(!t)return[new Hr({quality:sn.HIGH,width:r,height:e,bitrate:0,ssrc:0})];if(n){const i=t[0].scalabilityMode,s=new Lg(i),a=[],A=s.suffix=="h"?1.5:2,o=s.suffix=="h"?2:3;for(let c=0;c<s.spatial;c+=1)a.push(new Hr({quality:Math.min(sn.HIGH,s.spatial-1)-c,width:Math.ceil(r/Math.pow(A,c)),height:Math.ceil(e/Math.pow(A,c)),bitrate:t[0].maxBitrate?Math.ceil(t[0].maxBitrate/Math.pow(o,c)):0,ssrc:0}));return a}return t.map(i=>{var s,a,A;const o=(s=i.scaleResolutionDownBy)!==null&&s!==void 0?s:1;let c=Og((a=i.rid)!==null&&a!==void 0?a:"");return new Hr({quality:c,width:Math.ceil(r/o),height:Math.ceil(e/o),bitrate:(A=i.maxBitrate)!==null&&A!==void 0?A:0,ssrc:0})})}const ch="_lossy",lh="_reliable",dh="_data_track",Z2=2*1e3,Ic="leave-reconnect",eB=3e4,tB=8*1024,nB=256*1024,rB=3,iB=3;var ln;(function(r){r[r.New=0]="New",r[r.Connected=1]="Connected",r[r.Disconnected=2]="Disconnected",r[r.Reconnecting=3]="Reconnecting",r[r.Closed=4]="Closed"})(ln||(ln={}));var ge;(function(r){r[r.RELIABLE=0]="RELIABLE",r[r.LOSSY=1]="LOSSY",r[r.DATA_TRACK_LOSSY=2]="DATA_TRACK_LOSSY"})(ge||(ge={}));const uh=64e3;class sB extends Yt.EventEmitter{get isClosed(){return this._isClosed}get isNewlyCreated(){return this._isNewlyCreated}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var t;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=wu.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.latestRemoteOfferId=0,this.subscriberPrimary=!1,this.pcState=ln.New,this._isClosed=!0,this._isNewlyCreated=!0,this.pendingTrackResolvers={},this.reconnectAttempts=0,this.reconnectStart=0,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.shouldFailNext=!1,this.shouldFailOnV1Path=!1,this.log=me,this.reliableDataSequence=1,this.reliableMessageBuffer=new J0,this.reliableReceivedState=new x2(eB),this.lossyDataStatCurrentBytes=0,this.lossyDataStatByterate=0,this.lossyDataDropCount=0,this.midToTrackId={},this.isWaitingForNetworkReconnect=!1,this.bufferStatusLowClosingFuture=new Bt,this.handleDataChannel=n=>k(this,[n],void 0,function(i){var s=this;let a=i.channel;return function*(){if(!a)return;let A;if(a.label===lh)s.reliableDCSub=a,A=s.handleDataMessage;else if(a.label===ch)s.lossyDCSub=a,A=s.handleDataMessage;else if(a.label===dh)s.dataTrackDCSub=a,A=s.handleDataTrackMessage;else return;s.log.debug("on data channel ".concat(a.id,", ").concat(a.label)),a.onmessage=A}()}),this.handleDataMessage=n=>k(this,void 0,void 0,function*(){var i,s,a,A,o;const c=yield this.dataProcessLock.lock();try{let l;if(n.data instanceof ArrayBuffer)l=n.data;else if(n.data instanceof Blob)l=yield n.data.arrayBuffer();else{this.log.error("unsupported data type",{data:n.data});return}const d=Ft.fromBinary(new Uint8Array(l));if(d.sequence>0&&d.participantSid!==""){const u=this.reliableReceivedState.get(d.participantSid);if(u&&d.sequence<=u)return;this.reliableReceivedState.set(d.participantSid,d.sequence)}if(((i=d.value)===null||i===void 0?void 0:i.case)==="speaker")this.emit(G.ActiveSpeakersUpdate,d.value.value.speakers);else if(((s=d.value)===null||s===void 0?void 0:s.case)==="encryptedPacket"){if(!this.e2eeManager){this.log.error("Received encrypted packet but E2EE not set up");return}const u=yield(a=this.e2eeManager)===null||a===void 0?void 0:a.handleEncryptedData(d.value.value.encryptedValue,d.value.value.iv,d.participantIdentity,d.value.value.keyIndex),h=mm.fromBinary(u.payload),p=new Ft({value:h.value,participantIdentity:d.participantIdentity,participantSid:d.participantSid});((A=p.value)===null||A===void 0?void 0:A.case)==="user"&&hh(p,p.value.value),this.emit(G.DataPacketReceived,p,d.value.value.encryptionType)}else((o=d.value)===null||o===void 0?void 0:o.case)==="user"&&hh(d,d.value.value),this.emit(G.DataPacketReceived,d,De.NONE)}finally{c()}}),this.handleDataTrackMessage=n=>k(this,void 0,void 0,function*(){let i;if(n.data instanceof ArrayBuffer)i=n.data;else if(n.data instanceof Blob)i=yield n.data.arrayBuffer();else{this.log.error("unsupported data type",{data:n.data});return}this.emit("dataTrackPacketReceived",new Uint8Array(i))}),this.handleDataError=n=>{if(this._isClosed)return;const s=n.currentTarget.maxRetransmits===0?"lossy":"reliable";if(typeof RTCErrorEvent<"u"&&n instanceof RTCErrorEvent&&n.error){const a=n.error;this.log.error("DataChannel error on ".concat(s,": ").concat(a.message),{error:a,errorDetail:a.errorDetail,sctpCauseCode:a.sctpCauseCode})}else this.log.error("Unknown DataChannel error on ".concat(s),{event:n})},this.handleDataChannelClose=n=>()=>{var i;!this._isClosed&&((i=this.pcManager)===null||i===void 0?void 0:i.publisher.getConnectionState())==="connected"&&this.log.error("publisher data channel '".concat(ge[n],"' closed unexpectedly"),this.logContext)},this.handleBufferedAmountLow=n=>{this.updateAndEmitDCBufferStatus(n)},this.handleDisconnect=(n,i)=>{if(this._isClosed)return;this.log.warn("".concat(n," disconnected")),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());const s=o=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(o,"ms. giving up")),this.emit(G.Disconnected),this.close()},a=Date.now()-this.reconnectStart;let A=this.getNextRetryDelay({elapsedMs:a,retryCount:this.reconnectAttempts});if(A===null){s(a);return}n===Ic&&(A=0),this.log.debug("reconnecting in ".concat(A,"ms")),this.clearReconnectTimeout(),this.token&&this.emit(G.TokenRefreshed,this.token),this.reconnectTimeout=dt.setTimeout(()=>this.attemptReconnect(i).finally(()=>this.reconnectTimeout=void 0),A)},this.waitForRestarted=()=>new Promise((n,i)=>{this.pcState===ln.Connected&&n();const s=()=>{this.off(G.Disconnected,a),n()},a=()=>{this.off(G.Restarted,s),i()};this.once(G.Restarted,s),this.once(G.Disconnected,a)}),this.updateAndEmitDCBufferStatus=n=>{if(n===ge.RELIABLE){const s=this.dataChannelForKind(n);s&&this.reliableMessageBuffer.alignBufferedAmount(s.bufferedAmount)}const i=this.isBufferStatusLow(n);typeof i<"u"&&i!==this.dcBufferStatus.get(n)&&(this.dcBufferStatus.set(n,i),this.emit(G.DCBufferStatusChanged,i,n))},this.isBufferStatusLow=n=>{const i=this.dataChannelForKind(n);if(i)return i.bufferedAmount<=i.bufferedAmountLowThreshold},this.onRtpMapAvailable=n=>{const i=new Map;n.forEach(s=>{const a=s.codec.toLowerCase();z4(a)&&i.set(s.payload,a)}),this.emit(G.RTPVideoMapUpdate,i)},this.handleBrowserOnLine=()=>k(this,void 0,void 0,function*(){!this.url||!(yield fetch(da(this.url),{method:"HEAD"}).then(i=>i.ok).catch(()=>!1))||(this.log.info("detected network reconnected"),(this.client.currentState===Re.RECONNECTING||this.isWaitingForNetworkReconnect&&this.client.currentState===Re.CONNECTED)&&(this.clearReconnectTimeout(),this.attemptReconnect(si.RR_SIGNAL_DISCONNECTED),this.isWaitingForNetworkReconnect=!1))}),this.handleBrowserOffline=()=>k(this,void 0,void 0,function*(){if(this.url)try{yield Promise.race([fetch(da(this.url),{method:"HEAD"}),Qt(4e3).then(()=>Promise.reject())])}catch{window.navigator.onLine===!1&&(this.log.info("detected network interruption"),this.isWaitingForNetworkReconnect=!0)}}),this.log=Xt((t=e.loggerName)!==null&&t!==void 0?t:Ct.Engine,()=>this.logContext),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new gu(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.closingLock=new xt,this.dataProcessLock=new xt,this.dcBufferStatus=new Map([[ge.RELIABLE,!0],[ge.LOSSY,!0],[ge.DATA_TRACK_LOSSY,!0]]),this.client.onParticipantUpdate=n=>this.emit(G.ParticipantUpdate,n),this.client.onConnectionQuality=n=>this.emit(G.ConnectionQualityUpdate,n),this.client.onRoomUpdate=n=>this.emit(G.RoomUpdate,n),this.client.onSubscriptionError=n=>this.emit(G.SubscriptionError,n),this.client.onSubscriptionPermissionUpdate=n=>this.emit(G.SubscriptionPermissionUpdate,n),this.client.onSpeakersChanged=n=>this.emit(G.SpeakersChanged,n),this.client.onStreamStateUpdate=n=>this.emit(G.StreamStateChanged,n),this.client.onRequestResponse=n=>this.emit(G.SignalRequestResponse,n),this.client.onParticipantUpdate=n=>this.emit(G.ParticipantUpdate,n),this.client.onJoined=n=>this.emit(G.Joined,n),this.on(G.Closing,()=>{var n,i;(i=(n=this.bufferStatusLowClosingFuture).reject)===null||i===void 0||i.call(n,new Xe("engine closed"))}),this.bufferStatusLowClosingFuture.promise.catch(()=>{})}get logContext(){var e,t,n,i,s,a;return{room:(t=(e=this.latestJoinResponse)===null||e===void 0?void 0:e.room)===null||t===void 0?void 0:t.name,roomID:(i=(n=this.latestJoinResponse)===null||n===void 0?void 0:n.room)===null||i===void 0?void 0:i.sid,participant:(a=(s=this.latestJoinResponse)===null||s===void 0?void 0:s.participant)===null||a===void 0?void 0:a.identity,participantID:this.participantSid}}join(e,t,n,i){return k(this,arguments,void 0,function(s,a,A,o){var c=this;let l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;return function*(){var d,u,h;c._isNewlyCreated=!1,c.url=s,c.token=a,c.signalOpts=A,c.maxJoinAttempts=A.maxRetries;try{c.joinAttempts+=1,c.setupSignalClientCallbacks();const p=!l&&Y4();let g;if(p){c.pcManager||(yield c.configure(),c.applyInitialPublisherLayout());const B=yield(d=c.pcManager)===null||d===void 0?void 0:d.publisher.createInitialOffer();B&&(g=ci(B.offer,B.offerId))}if(o!=null&&o.aborted)throw oe.cancelled("Connection aborted");if(!l&&c.shouldFailOnV1Path)throw c.shouldFailOnV1Path=!1,oe.serviceNotFound("Simulated v1 path failure","v0-rtc");const v=yield c.client.join(s,a,A,o,l,g);c._isClosed=!1,c.latestJoinResponse=v,c.participantSid=(u=v.participant)===null||u===void 0?void 0:u.sid,c.subscriberPrimary=v.subscriberPrimary,p?(h=c.pcManager)===null||h===void 0||h.updateConfiguration(c.makeRTCConfiguration(v)):(c.pcManager||(yield c.configure(v,!l),l||c.applyInitialPublisherLayout()),(!c.subscriberPrimary||v.fastPublish)&&c.negotiate().catch(B=>{c.log.error(B)})),c.registerOnLineListener(),c.clientConfiguration=v.clientConfiguration,c.emit(G.SignalConnected,v);let w=v.serverInfo;return w||(w={version:v.serverVersion,region:v.serverRegion}),c.log.info("connected to Livekit Server ".concat(Object.entries(w).map(B=>{let E=Ae(B,2),b=E[0],C=E[1];return"".concat(b,": ").concat(C)}).join(", "))),{joinResponse:v,serverInfo:w}}catch(p){if(p instanceof oe){if(p.reason===Pe.ServerUnreachable){if(c.log.warn("Couldn't connect to server, attempt ".concat(c.joinAttempts," of ").concat(c.maxJoinAttempts)),c.joinAttempts<c.maxJoinAttempts)return c.join(s,a,A,o,l)}else if(p.reason===Pe.ServiceNotFound)return c.log.warn("Initial connection failed: ".concat(p.message," – Retrying")),c.pcManager&&(c.pcManager.onStateChange=void 0,yield c.cleanupPeerConnections()),c.join(s,a,A,o,!0)}throw p}}()})}close(){return k(this,void 0,void 0,function*(){const e=yield this.closingLock.lock();if(this.isClosed){e();return}try{this._isClosed=!0,this.joinAttempts=0,this.emit(G.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),this.cleanupLossyDataStats(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return k(this,void 0,void 0,function*(){var e;const t=n=>{n&&(n.onbufferedamountlow=null,n.onclose=null,n.onclosing=null,n.onerror=null,n.onmessage=null,n.onopen=null,n.close())};t(this.lossyDC),t(this.lossyDCSub),t(this.reliableDC),t(this.reliableDCSub),t(this.dataTrackDC),t(this.dataTrackDCSub),yield(e=this.pcManager)===null||e===void 0?void 0:e.close(),this.pcManager=void 0,this.lossyDC=void 0,this.lossyDCSub=void 0,this.reliableDC=void 0,this.reliableDCSub=void 0,this.dataTrackDC=void 0,this.dataTrackDCSub=void 0,this.reliableMessageBuffer=new J0,this.reliableDataSequence=1,this.reliableReceivedState.clear()})}cleanupLossyDataStats(){this.lossyDataStatByterate=0,this.lossyDataStatCurrentBytes=0,this.lossyDataStatInterval&&(clearInterval(this.lossyDataStatInterval),this.lossyDataStatInterval=void 0),this.lossyDataDropCount=0}cleanupClient(){return k(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks();for(const e of Object.keys(this.pendingTrackResolvers))this.pendingTrackResolvers[e].reject();this.pendingTrackResolvers={}})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new mr("a track with the same ID has already been published");return new Promise((t,n)=>{const i=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],n(oe.timeout("publication of local track timed out, no response from server"))},1e4);this.pendingTrackResolvers[e.cid]={resolve:s=>{clearTimeout(i),t(s)},reject:()=>{clearTimeout(i),n(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)})}removeTrack(e){if(e.track&&this.pendingTrackResolvers[e.track.id]){const t=this.pendingTrackResolvers[e.track.id].reject;t&&t(),delete this.pendingTrackResolvers[e.track.id]}try{return this.pcManager.removeTrack(e),!0}catch(t){this.log.warn("failed to remove track",{error:t})}return!1}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){var e;return(e=this.reliableDCSub)===null||e===void 0?void 0:e.readyState}getConnectedServerAddress(){return k(this,void 0,void 0,function*(){var e;return(e=this.pcManager)===null||e===void 0?void 0:e.getConnectedAddress()})}setRegionStrategy(e){this.regionStrategy=e}configure(e,t){return k(this,void 0,void 0,function*(){var n;if(!(this.pcManager&&this.pcManager.currentState!==Je.NEW)){if(e){this.participantSid=(n=e.participant)===null||n===void 0?void 0:n.sid;const i=this.makeRTCConfiguration(e);this.pcManager=new ih(t?"publisher-only":e.subscriberPrimary?"subscriber-primary":"publisher-primary",this.loggerOptions,i)}else{const i=this.makeRTCConfiguration();this.pcManager=new ih("publisher-only",this.loggerOptions,i)}this.emit(G.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(i,s)=>{this.client.sendIceCandidate(i,s)},this.pcManager.onPublisherOffer=(i,s)=>{this.client.sendOffer(i,s)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(i,s,a)=>k(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(i)),["closed","disconnected","failed"].includes(s)&&(this.publisherConnectionPromise=void 0),i===Je.CONNECTED){const c=this.pcState===ln.New;this.pcState=ln.Connected,c&&this.emit(G.Connected,this.latestJoinResponse)}else i===Je.FAILED&&(this.pcState===ln.Connected||this.pcState===ln.Reconnecting)&&(this.pcState=ln.Disconnected,this.handleDisconnect("peerconnection failed",a==="failed"?si.RR_SUBSCRIBER_FAILED:si.RR_PUBLISHER_FAILED));const A=this.client.isDisconnected||this.client.currentState===Re.RECONNECTING,o=[Je.FAILED,Je.CLOSING,Je.CLOSED].includes(i);A&&o&&!this._isClosed&&this.emit(G.Offline)}),this.pcManager.onTrack=i=>{i.streams.length!==0&&this.emit(G.MediaTrackAdded,i.track,i.streams[0],i.receiver)}}})}setupSignalClientCallbacks(){this.client.onAnswer=(e,t,n)=>k(this,void 0,void 0,function*(){this.pcManager&&(this.log.debug("received server answer",{RTCSdpType:e.type,sdp:e.sdp,midToTrackId:n}),this.midToTrackId=n,yield this.pcManager.setPublisherAnswer(e,t))}),this.client.onTrickle=(e,t)=>{this.pcManager&&(this.log.debug("got ICE candidate from peer",{candidate:e,target:t}),this.pcManager.addIceCandidate(e,t))},this.client.onOffer=(e,t,n)=>k(this,void 0,void 0,function*(){if(this.latestRemoteOfferId=t,!this.pcManager)return;this.midToTrackId=n;const i=yield this.pcManager.createSubscriberAnswerFromOffer(e,t);i&&this.client.sendAnswer(i,t)}),this.client.onLocalTrackPublished=e=>{var t;if(this.log.debug("received trackPublishedResponse",{cid:e.cid,track:(t=e.track)===null||t===void 0?void 0:t.sid}),!this.pendingTrackResolvers[e.cid]){this.log.error("missing track resolver for ".concat(e.cid),{cid:e.cid});return}const n=this.pendingTrackResolvers[e.cid].resolve;delete this.pendingTrackResolvers[e.cid],n(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(G.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(G.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{this.token=e,this.emit(G.TokenRefreshed,e)},this.client.onRemoteMuteChanged=(e,t)=>{this.emit(G.RemoteMute,e,t)},this.client.onSubscribedQualityUpdate=e=>{this.emit(G.SubscribedQualityUpdate,e)},this.client.onRoomMoved=e=>{var t;this.participantSid=(t=e.participant)===null||t===void 0?void 0:t.sid,this.latestJoinResponse&&(this.latestJoinResponse.room=e.room),this.emit(G.RoomMoved,e)},this.client.onMediaSectionsRequirement=e=>{this.addMediaSections(e.numAudios,e.numVideos),this.negotiate()},this.client.onPublishDataTrackResponse=e=>{this.emit(G.PublishDataTrackResponse,e)},this.client.onUnPublishDataTrackResponse=e=>{this.emit(G.UnPublishDataTrackResponse,e)},this.client.onDataTrackSubscriberHandles=e=>{this.emit(G.DataTrackSubscriberHandles,e)},this.client.onClose=()=>{this.handleDisconnect("signal",si.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.info("client leave request received (action=".concat(e==null?void 0:e.action,")"),{reason:e==null?void 0:e.reason}),e.regions&&(this.log.debug("updating regions"),this.emit(G.ServerRegionsReported,e.regions)),e.action){case qi.DISCONNECT:this.emit(G.Disconnected,e==null?void 0:e.reason),this.close();break;case qi.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(Ic);break;case qi.RESUME:this.handleDisconnect(Ic)}}}makeRTCConfiguration(e){var t;const n=Object.assign({},this.rtcConfig);if((((t=this.signalOpts)===null||t===void 0?void 0:t.e2eeEnabled)||this.frameMetadataWorker&&!ua())&&du()&&(this.log.debug("E2EE - setting up transports with insertable streams"),n.encodedInsertableStreams=!0),n.sdpSemantics="unified-plan",n.continualGatheringPolicy="gather_continually",!e)return n;if(e.iceServers&&!n.iceServers){const s=[];e.iceServers.forEach(a=>{const A={urls:a.urls};a.username&&(A.username=a.username),a.credential&&(A.credential=a.credential),s.push(A)}),n.iceServers=s}return e.clientConfiguration&&e.clientConfiguration.forceRelay===aa.ENABLED&&(n.iceTransportPolicy="relay"),n}applyInitialPublisherLayout(){this.createDataChannels(),Rn()||this.addMediaSections(rB,iB)}addMediaSections(e,t){var n,i;const s={direction:"recvonly"};for(let a=0;a<e;a++)(n=this.pcManager)===null||n===void 0||n.addPublisherTransceiverOfKind("audio",s);for(let a=0;a<t;a++)(i=this.pcManager)===null||i===void 0||i.addPublisherTransceiverOfKind("video",s)}createDataChannels(){this.pcManager&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null,this.lossyDC.onclose=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null,this.reliableDC.onclose=null),this.dataTrackDC&&(this.dataTrackDC.onmessage=null,this.dataTrackDC.onerror=null,this.dataTrackDC.onclose=null),this.lossyDC=this.pcManager.createPublisherDataChannel(ch,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(lh,{ordered:!0}),this.dataTrackDC=this.pcManager.createPublisherDataChannel(dh,{ordered:!1,maxRetransmits:0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.dataTrackDC.onmessage=this.handleDataTrackMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError,this.dataTrackDC.onerror=this.handleDataError,this.lossyDC.onclose=this.handleDataChannelClose(ge.LOSSY),this.reliableDC.onclose=this.handleDataChannelClose(ge.RELIABLE),this.dataTrackDC.onclose=this.handleDataChannelClose(ge.DATA_TRACK_LOSSY),this.lossyDC.bufferedAmountLowThreshold=65535,this.reliableDC.bufferedAmountLowThreshold=65535,this.dataTrackDC.bufferedAmountLowThreshold=65535,this.lossyDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(ge.LOSSY),this.reliableDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(ge.RELIABLE),this.dataTrackDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(ge.DATA_TRACK_LOSSY),this.cleanupLossyDataStats(),this.lossyDataStatInterval=setInterval(()=>{this.lossyDataStatByterate=this.lossyDataStatCurrentBytes,this.lossyDataStatCurrentBytes=0;const e=this.dataChannelForKind(ge.LOSSY);if(e){const t=this.lossyDataStatByterate/10;e.bufferedAmountLowThreshold=Math.min(Math.max(t,tB),nB)}},1e3))}createSender(e,t,n){return k(this,void 0,void 0,function*(){let i;if($l())i=yield this.createTransceiverRTCRtpSender(e,t,n);else if(jl())this.log.warn("using add-track fallback"),i=yield this.createRTCRtpSender(e.mediaStreamTrack);else throw new Xe("Required webRTC APIs not supported on this device");return this.setupFrameMetadataSender(i,t),i})}createSimulcastSender(e,t,n,i){return k(this,void 0,void 0,function*(){let s;if($l())s=yield this.createSimulcastTransceiverSender(e,t,n,i);else if(jl())this.log.debug("using add-track fallback"),s=yield this.createRTCRtpSender(e.mediaStreamTrack);else throw new Xe("Cannot stream on this device");return s&&this.setupFrameMetadataSender(s,n),s})}get frameMetadataWorker(){var e,t;return(t=(e=this.options.frameMetadata)!==null&&e!==void 0?e:this.options.packetTrailer)===null||t===void 0?void 0:t.worker}setupFrameMetadataSender(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var n,i,s;const a=this.frameMetadataWorker;if(!a||!((n=this.signalOpts)===null||n===void 0)&&n.e2eeEnabled)return;const A=(i=t.frameMetadata)!==null&&i!==void 0?i:t.packetTrailer,o=JA(A);if(ua()){o&&(e.transform=new RTCRtpScriptTransform(a,{kind:"encode",packetTrailer:A}));return}if(!ha((s=this.options.frameMetadata)!==null&&s!==void 0?s:this.options.packetTrailer)||!("createEncodedStreams"in e)){o&&this.log.warn("frame metadata transform not supported; skipping write",this.logContext);return}const c=e.createEncodedStreams(),l=c.readable,d=c.writable;o?a.postMessage({kind:"encode",data:{readableStream:l,writableStream:d,packetTrailer:A}},[l,d]):l.pipeTo(d)}createTransceiverRTCRtpSender(e,t,n){return k(this,void 0,void 0,function*(){if(!this.pcManager)throw new Xe("publisher is closed");const i=[];e.mediaStream&&i.push(e.mediaStream),wr(e)&&(e.codec=t.videoCodec);const s={direction:"sendonly",streams:i};return n&&(s.sendEncodings=n),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,s)).sender})}createSimulcastTransceiverSender(e,t,n,i){return k(this,void 0,void 0,function*(){if(!this.pcManager)throw new Xe("publisher is closed");const s={direction:"sendonly"};i&&(s.sendEncodings=i);const a=yield this.pcManager.addPublisherTransceiver(t.mediaStreamTrack,s);if(n.videoCodec)return e.setSimulcastTrackSender(n.videoCodec,a.sender),a.sender})}createRTCRtpSender(e){return k(this,void 0,void 0,function*(){if(!this.pcManager)throw new Xe("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return k(this,void 0,void 0,function*(){var t,n,i;if(!this._isClosed){if(this.attemptingReconnect){this.log.warn("already attempting reconnect, returning early");return}(((t=this.clientConfiguration)===null||t===void 0?void 0:t.resumeConnection)===aa.DISABLED||((i=(n=this.pcManager)===null||n===void 0?void 0:n.currentState)!==null&&i!==void 0?i:Je.NEW)===Je.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(s){this.reconnectAttempts+=1;let a=!0;s instanceof Xe?(this.log.debug("received unrecoverable error",{error:s}),a=!1):s instanceof Qi||(this.fullReconnectOnNext=!0),a?this.handleDisconnect("reconnect",si.RR_UNKNOWN):(this.log.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up")),this.emit(G.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(t){this.log.warn("encountered error in reconnect policy",{error:t})}return null}restartConnection(e){return k(this,void 0,void 0,function*(){var t,n,i;try{if(!this.url||!this.token)throw new Xe("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts)),this.emit(G.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let s;try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present"),new Qi;s=(yield this.join(e??this.url,this.token,this.signalOpts,void 0,!this.options.singlePeerConnection)).joinResponse}catch(a){throw a instanceof oe&&a.reason===Pe.NotAllowed?new Xe("could not reconnect, token might be expired"):new Qi}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(G.SignalRestarted,s),yield this.waitForPCReconnected(),this.client.currentState!==Re.CONNECTED)throw new Qi("Signal connection got severed during reconnect");(t=this.regionStrategy)===null||t===void 0||t.resetAttempts(),this.emit(G.Restarted)}catch(s){const a=yield(n=this.regionStrategy)===null||n===void 0?void 0:n.getNextUrl();if(a){yield this.restartConnection(a);return}else throw(i=this.regionStrategy)===null||i===void 0||i.resetAttempts(),s}})}resumeConnection(e){return k(this,void 0,void 0,function*(){var t;if(!this.url||!this.token)throw new Xe("could not reconnect, url or token not saved");if(!this.pcManager)throw new Xe("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts)),this.emit(G.Resuming);let n;try{this.setupSignalClientCallbacks(),n=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(i){let s="";throw i instanceof Error&&(s=i.message,this.log.error(i.message,{error:i})),i instanceof oe&&i.reason===Pe.NotAllowed?new Xe("could not reconnect, token might be expired"):i instanceof oe&&i.reason===Pe.LeaveRequest?i:new Qi(s)}if(this.emit(G.SignalResumed),n){const i=this.makeRTCConfiguration(n);this.pcManager.updateConfiguration(i),this.latestJoinResponse&&(this.latestJoinResponse.serverInfo=n.serverInfo)}else this.log.warn("Did not receive reconnect response");if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(yield this.pcManager.triggerIceRestart(),yield this.waitForPCReconnected(),this.client.currentState!==Re.CONNECTED)throw new Qi("Signal connection got severed during reconnect");this.client.setReconnected(),((t=this.reliableDC)===null||t===void 0?void 0:t.readyState)==="open"&&this.reliableDC.id===null&&this.createDataChannels(),n!=null&&n.lastMessageSeq&&this.resendReliableMessagesForResume(n.lastMessageSeq),this.emit(G.Resumed)})}waitForPCInitialConnection(e,t){return k(this,void 0,void 0,function*(){if(!this.pcManager)throw new Xe("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(t,e)})}waitForPCReconnected(){return k(this,void 0,void 0,function*(){this.pcState=ln.Reconnecting,this.log.debug("waiting for peer connection to reconnect");try{if(yield Qt(Z2),!this.pcManager)throw new Xe("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=ln.Connected}catch(e){throw this.pcState=ln.Disconnected,oe.internal("could not establish PC connection, ".concat(e.message))}})}publishRpcAck(e,t){return k(this,void 0,void 0,function*(){const n=new Ft({destinationIdentities:[e],kind:Nr.RELIABLE,value:{case:"rpcAck",value:new To({requestId:t})}});yield this.sendDataPacket(n,ge.RELIABLE)})}sendDataPacket(e,t){return k(this,void 0,void 0,function*(){var n,i;if(yield this.ensurePublisherConnected(t),this.e2eeManager&&this.e2eeManager.isDataChannelEncryptionEnabled){const A=o2(e);if(A){const o=yield this.e2eeManager.encryptData(A.toBinary());e.value={case:"encryptedPacket",value:new pm({encryptedValue:o.payload,iv:o.iv,keyIndex:o.keyIndex})}}}t===ge.RELIABLE&&(e.sequence=this.reliableDataSequence,this.reliableDataSequence+=1);const s=e.toBinary(),a=Math.min((i=(n=this.pcManager)===null||n===void 0?void 0:n.getMaxPublisherMessageSize())!==null&&i!==void 0?i:uh,uh);if(typeof a<"u"&&a!==0&&s.byteLength>a)throw new y4("cannot publish data packet larger than ".concat(a," bytes (got ").concat(s.byteLength,")"));switch(t){case ge.LOSSY:case ge.DATA_TRACK_LOSSY:return this.sendLossyBytes(s,t);case ge.RELIABLE:const A=this.dataChannelForKind(t);if(A){if(yield this.waitForBufferStatusLow(t),this.reliableMessageBuffer.push({data:s,sequence:e.sequence}),this.attemptingReconnect)return;A.send(s)}this.updateAndEmitDCBufferStatus(t);break}})}sendLossyBytes(e,t){return k(this,arguments,void 0,function(n,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"drop";return function*(){yield s.ensurePublisherConnected(i);const A=s.dataChannelForKind(i);if(A){if(!s.isBufferStatusLow(i))switch(a){case"wait":yield s.waitForBufferStatusLow(i);break;case"drop":s.lossyDataDropCount+=1,s.lossyDataDropCount%100===0&&s.log.warn("dropping lossy data channel messages, total dropped: ".concat(s.lossyDataDropCount));return}if(s.lossyDataStatCurrentBytes+=n.byteLength,s.attemptingReconnect)return;A.send(n)}s.updateAndEmitDCBufferStatus(i)}()})}resendReliableMessagesForResume(e){return k(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(ge.RELIABLE);const t=this.dataChannelForKind(ge.RELIABLE);t&&(this.reliableMessageBuffer.popToSequence(e),this.reliableMessageBuffer.getAll().forEach(n=>{t.send(n.data)})),this.updateAndEmitDCBufferStatus(ge.RELIABLE)})}waitForBufferStatusLow(e){return k(this,void 0,void 0,function*(){return new Lt((t,n)=>k(this,void 0,void 0,function*(){if(this.isClosed&&n(new Xe("engine closed")),this.isBufferStatusLow(e))t();else{const i=this.dataChannelForKind(e);if(!i){n(new Xe("DataChannel not found, kind: ".concat(e)));return}this.bufferStatusLowClosingFuture.promise.catch(s=>n(s)),i.addEventListener("bufferedamountlow",()=>t(),{once:!0})}}))})}ensureDataTransportConnected(e){return k(this,arguments,void 0,function(t){var n=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return function*(){var s;if(!n.pcManager)throw new Xe("PC manager is closed");const a=i?n.pcManager.subscriber:n.pcManager.publisher,A=i?"Subscriber":"Publisher";if(!a)throw oe.internal("".concat(A," connection not set"));let o=!1;!i&&!n.dataChannelForKind(t,i)&&(n.createDataChannels(),o=!0),!o&&!i&&!n.pcManager.publisher.isICEConnected&&n.pcManager.publisher.getICEConnectionState()!=="checking"&&(o=!0),o&&n.negotiate().catch(d=>{n.log.error(d)});const c=n.dataChannelForKind(t,i);if((c==null?void 0:c.readyState)==="open")return;const l=new Date().getTime()+n.peerConnectionTimeout;for(;new Date().getTime()<l;){if(a.isICEConnected&&((s=n.dataChannelForKind(t,i))===null||s===void 0?void 0:s.readyState)==="open")return;yield Qt(50)}throw oe.internal("could not establish ".concat(A," connection, state: ").concat(a.getICEConnectionState()))}()})}ensurePublisherConnected(e){return k(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!(!this.pcManager||![Je.CONNECTING,Je.CONNECTED].includes(this.pcManager.currentState)||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return k(this,void 0,void 0,function*(){return new Lt((e,t)=>k(this,void 0,void 0,function*(){if(!this.pcManager){t(new mi("PC manager is closed"));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&!this.dataTrackDC&&this.createDataChannels();const n=new AbortController,i=()=>{n.abort(),this.log.debug("engine disconnected while negotiation was ongoing"),e()};this.isClosed&&t(new mi("cannot negotiate on closed engine")),this.on(G.Closing,i),this.on(G.Restarting,i),this.pcManager.publisher.off(Dr.RTPVideoPayloadTypes,this.onRtpMapAvailable),this.pcManager.publisher.once(Dr.RTPVideoPayloadTypes,this.onRtpMapAvailable);try{yield this.pcManager.negotiate(n),e()}catch(s){if(n.signal.aborted){e();return}s instanceof mi&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",si.RR_UNKNOWN),s instanceof Error?t(s):t(new Error(String(s)))}finally{this.off(G.Closing,i),this.off(G.Restarting,i)}}))})}dataChannelForKind(e,t){switch(e){case ge.RELIABLE:return t?this.reliableDCSub:this.reliableDC;case ge.LOSSY:return t?this.lossyDCSub:this.lossyDC;case ge.DATA_TRACK_LOSSY:return t?this.dataTrackDCSub:this.dataTrackDC}}sendSyncState(e,t,n){var i,s,a,A;if(!this.pcManager){this.log.warn("sync state cannot be sent without peer connection setup");return}const o=this.pcManager.publisher.getLocalDescription(),c=this.pcManager.publisher.getRemoteDescription(),l=(i=this.pcManager.subscriber)===null||i===void 0?void 0:i.getRemoteDescription(),d=(s=this.pcManager.subscriber)===null||s===void 0?void 0:s.getLocalDescription(),u=(A=(a=this.signalOpts)===null||a===void 0?void 0:a.autoSubscribe)!==null&&A!==void 0?A:!0,h=new Array,p=new Array;e.forEach(g=>{g.isDesired!==u&&h.push(g.trackSid),g.isEnabled||p.push(g.trackSid)}),this.client.sendSyncState(new au({answer:this.pcManager.mode==="publisher-only"?c?ci({sdp:c.sdp,type:c.type}):void 0:d?ci({sdp:d.sdp,type:d.type}):void 0,offer:this.pcManager.mode==="publisher-only"?o?ci({sdp:o.sdp,type:o.type}):void 0:l?ci({sdp:l.sdp,type:l.type}):void 0,subscription:new Uo({trackSids:h,subscribe:!u,participantTracks:[]}),publishTracks:T4(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:p,datachannelReceiveStates:this.reliableReceivedState.map((g,v)=>new Lm({publisherSid:v,lastSeq:g})),publishDataTracks:n.map(g=>new eu({info:YA.toProtobuf(g)}))}))}failNext(){this.shouldFailNext=!0}failNextV1Path(){this.shouldFailOnV1Path=!0}dataChannelsInfo(){const e=[],t=(n,i)=>{(n==null?void 0:n.id)!==void 0&&n.id!==null&&e.push(new Om({label:n.label,id:n.id,target:i}))};return t(this.dataChannelForKind(ge.LOSSY),xn.PUBLISHER),t(this.dataChannelForKind(ge.RELIABLE),xn.PUBLISHER),t(this.dataChannelForKind(ge.LOSSY,!0),xn.SUBSCRIBER),t(this.dataChannelForKind(ge.RELIABLE,!0),xn.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&dt.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){$t()&&(window.addEventListener("online",this.handleBrowserOnLine),window.addEventListener("offline",this.handleBrowserOffline))}deregisterOnLineListener(){$t()&&(window.removeEventListener("online",this.handleBrowserOnLine),window.removeEventListener("offline",this.handleBrowserOffline))}getTrackIdForReceiver(e){var t;const n=(t=this.pcManager)===null||t===void 0?void 0:t.getMidForReceiver(e);if(n){const i=Object.entries(this.midToTrackId).find(s=>Ae(s,1)[0]===n);if(i)return i[1]}}}function hh(r,e){const t=r.participantIdentity?r.participantIdentity:e.participantIdentity;r.participantIdentity=t,e.participantIdentity=t;const n=r.destinationIdentities.length!==0?r.destinationIdentities:e.destinationIdentities;r.destinationIdentities=n,e.destinationIdentities=n}const nd=5e3,aB=3e4;class Te{static fetchRegionSettings(e,t,n){return k(this,void 0,void 0,function*(){const i=yield Te.fetchLock.lock();try{const s=yield fetch("".concat(AB(e),"/regions"),{headers:{authorization:"Bearer ".concat(t)},signal:n});if(s.ok){const a=J4(s.headers),A=a?a*1e3:nd;return{regionSettings:yield s.json(),updatedAtInMs:Date.now(),maxAgeInMs:A}}else throw s.status===401?oe.notAllowed("Could not fetch region settings: ".concat(s.statusText),s.status):oe.internal("Could not fetch region settings: ".concat(s.statusText))}catch(s){throw s instanceof oe?s:n!=null&&n.aborted?oe.cancelled("Region fetching was aborted"):oe.serverUnreachable("Could not fetch region settings, ".concat(s instanceof Error?"".concat(s.name,": ").concat(s.message):s))}finally{i()}})}static scheduleRefetch(e,t,n){return k(this,void 0,void 0,function*(){const i=Te.settingsTimeouts.get(e.hostname);clearTimeout(i),Te.settingsTimeouts.set(e.hostname,setTimeout(()=>k(this,void 0,void 0,function*(){try{const s=yield Te.fetchRegionSettings(e,t);Te.updateCachedRegionSettings(e,t,s)}catch(s){if(s instanceof oe&&s.reason===Pe.NotAllowed){me.debug("token is not valid, cancelling auto region refresh");return}me.debug("auto refetching of region settings failed",{error:s}),Te.scheduleRefetch(e,t,n)}}),n))})}static updateCachedRegionSettings(e,t,n){Te.cache.set(e.hostname,n),Te.scheduleRefetch(e,t,n.maxAgeInMs)}static stopRefetch(e){const t=Te.settingsTimeouts.get(e);t&&(clearTimeout(t),Te.settingsTimeouts.delete(e))}static scheduleCleanup(e){let t=Te.connectionTrackers.get(e);t&&(t.cleanupTimeout&&clearTimeout(t.cleanupTimeout),t.cleanupTimeout=setTimeout(()=>{const n=Te.connectionTrackers.get(e);n&&n.connectionCount===0&&(me.debug("stopping region refetch after disconnect delay",{hostname:e}),Te.stopRefetch(e)),n&&(n.cleanupTimeout=void 0)},aB))}static cancelCleanup(e){const t=Te.connectionTrackers.get(e);t!=null&&t.cleanupTimeout&&(clearTimeout(t.cleanupTimeout),t.cleanupTimeout=void 0)}notifyConnected(){const e=this.serverUrl.hostname;let t=Te.connectionTrackers.get(e);t||(t={connectionCount:0},Te.connectionTrackers.set(e,t)),t.connectionCount++,Te.cancelCleanup(e)}notifyDisconnected(){const e=this.serverUrl.hostname,t=Te.connectionTrackers.get(e);t&&(t.connectionCount=Math.max(0,t.connectionCount-1),t.connectionCount===0&&Te.scheduleCleanup(e))}constructor(e,t){this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=t}updateToken(e){var t;this.token=e;const n=this.getServerUrl(),i=Te.cache.get(n.hostname);Te.scheduleRefetch(this.serverUrl,this.token,(t=i==null?void 0:i.maxAgeInMs)!==null&&t!==void 0?t:nd)}isCloud(){return as(this.serverUrl)}getServerUrl(){return this.serverUrl}fetchRegionSettings(e){return k(this,void 0,void 0,function*(){return Te.fetchRegionSettings(this.serverUrl,this.token,e)})}getNextBestRegionUrl(e){return k(this,void 0,void 0,function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");let t=Te.cache.get(this.serverUrl.hostname);(!t||Date.now()-t.updatedAtInMs>t.maxAgeInMs)&&(t=yield this.fetchRegionSettings(e),Te.updateCachedRegionSettings(this.serverUrl,this.token,t));const n=t.regionSettings.regions.filter(i=>!this.attemptedRegions.find(s=>s.url===i.url));if(n.length>0){const i=n[0];return this.attemptedRegions.push(i),me.debug("next region: ".concat(i.region)),i.url}else return null})}resetAttempts(){this.attemptedRegions=[]}setServerReportedRegions(e){Te.updateCachedRegionSettings(this.serverUrl,this.token,e)}}Te.cache=new Map;Te.settingsTimeouts=new Map;Te.connectionTrackers=new Map;Te.fetchLock=new xt;function AB(r){return"".concat(r.protocol.replace("ws","http"),"//").concat(r.host,"/settings")}class Hg{get info(){return this._info}validateBytesReceived(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(!(typeof this.totalByteSize!="number"||this.totalByteSize===0)){if(e&&this.bytesReceived<this.totalByteSize)throw new dn("Not enough chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, only received ").concat(this.bytesReceived," bytes"),Pt.Incomplete);if(this.bytesReceived>this.totalByteSize)throw new dn("Extra chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, received ").concat(this.bytesReceived," bytes"),Pt.LengthExceeded)}}constructor(e,t,n){this.reader=t,this.totalByteSize=n,this._info=e,this.bytesReceived=0}}class oB extends Hg{handleChunkReceived(e){var t;this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const n=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)===null||t===void 0||t.call(this,n)}[Symbol.asyncIterator](){const e=this.reader.getReader();e.closed.catch(()=>{});const t=()=>{e.releaseLock(),this.signal=void 0};return{next:()=>k(this,void 0,void 0,function*(){try{const n=this.signal;if(n!=null&&n.aborted)throw n.reason;const i=yield new Promise((s,a)=>{if(n){const A=()=>a(n.reason);n.addEventListener("abort",A,{once:!0}),e.read().then(s,a).finally(()=>{n.removeEventListener("abort",A)})}else e.read().then(s,a)});return i.done?(this.validateBytesReceived(!0),{done:!0,value:void 0}):(this.handleChunkReceived(i.value),{done:!1,value:i.value.content})}catch(n){throw t(),n}}),return(){return k(this,void 0,void 0,function*(){return t(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return k(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function*(){var n,i,s,a;let A=new Set;const o=t.signal?e.withAbortSignal(t.signal):e;try{for(var c=!0,l=En(o),d;d=yield l.next(),n=d.done,!n;c=!0){a=d.value,c=!1;const u=a;A.add(u)}}catch(u){i={error:u}}finally{try{!c&&!n&&(s=l.return)&&(yield s.call(l))}finally{if(i)throw i.error}}return Array.from(A)}()})}}class cB extends Hg{constructor(e,t,n){super(e,t,n),this.receivedChunks=new Map}handleChunkReceived(e){var t;const n=TA(e.chunkIndex),i=this.receivedChunks.get(n);if(i&&i.version>e.version)return;this.receivedChunks.set(n,e),this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const s=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(t=this.onProgress)===null||t===void 0||t.call(this,s)}[Symbol.asyncIterator](){const e=this.reader.getReader();e.closed.catch(()=>{});const t=new TextDecoder("utf-8",{fatal:!0}),n=this.signal,i=()=>{e.releaseLock(),this.signal=void 0};return{next:()=>k(this,void 0,void 0,function*(){try{if(n!=null&&n.aborted)throw n.reason;const s=yield new Promise((a,A)=>{if(n){const o=()=>A(n.reason);n.addEventListener("abort",o,{once:!0}),e.read().then(a,A).finally(()=>{n.removeEventListener("abort",o)})}else e.read().then(a,A)});if(s.done)return this.validateBytesReceived(!0),{done:!0,value:void 0};{this.handleChunkReceived(s.value);let a;try{a=t.decode(s.value.content)}catch(A){throw new dn("Cannot decode datastream chunk ".concat(s.value.chunkIndex," as text: ").concat(A),Pt.DecodeFailed)}return{done:!1,value:a}}}catch(s){throw i(),s}}),return(){return k(this,void 0,void 0,function*(){return i(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return k(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function*(){var n,i,s,a;let A="";const o=t.signal?e.withAbortSignal(t.signal):e;try{for(var c=!0,l=En(o),d;d=yield l.next(),n=d.done,!n;c=!0)a=d.value,c=!1,A+=a}catch(u){i={error:u}}finally{try{!c&&!n&&(s=l.return)&&(yield s.call(l))}finally{if(i)throw i.error}}return A}()})}}class lB{constructor(){this.log=me,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map,this.isConnected=!1,this.bufferedPackets=[]}setConnected(e){this.isConnected=e,e&&this.flushBufferedPackets()}flushBufferedPackets(){const e=this.bufferedPackets;this.bufferedPackets=[];for(const t of e){const n=t.packet,i=t.encryptionType;this.handleDataStreamPacket(n,i)}}registerTextStreamHandler(e,t){if(this.textStreamHandlers.has(e))throw new dn('A text stream handler for topic "'.concat(e,'" has already been set.'),Pt.HandlerAlreadyRegistered);this.textStreamHandlers.set(e,t)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,t){if(this.byteStreamHandlers.has(e))throw new dn('A byte stream handler for topic "'.concat(e,'" has already been set.'),Pt.HandlerAlreadyRegistered);this.byteStreamHandlers.set(e,t)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}clearControllers(){this.byteStreamControllers.clear(),this.textStreamControllers.clear(),this.bufferedPackets=[]}validateParticipantHasNoActiveDataStreams(e){const t=Array.from(this.textStreamControllers.entries()).filter(a=>a[1].sendingParticipantIdentity===e),n=Array.from(this.byteStreamControllers.entries()).filter(a=>a[1].sendingParticipantIdentity===e);if(t.length>0||n.length>0){const a=new dn("Participant ".concat(e," unexpectedly disconnected in the middle of sending data"),Pt.AbnormalEnd);for(const A of n){var i=Ae(A,2);const o=i[0];i[1].controller.error(a),this.byteStreamControllers.delete(o)}for(const A of t){var s=Ae(A,2);const o=s[0];s[1].controller.error(a),this.textStreamControllers.delete(o)}}}handleDataStreamPacket(e,t){if(!this.isConnected){this.bufferedPackets.push({packet:e,encryptionType:t});return}switch(e.value.case){case"streamHeader":return this.handleStreamHeader(e.value.value,e.participantIdentity,t);case"streamChunk":return this.handleStreamChunk(e.value.value,t);case"streamTrailer":return this.handleStreamTrailer(e.value.value,t);default:throw new Error('DataPacket of value "'.concat(e.value.case,'" is not data stream related!'))}}handleStreamHeader(e,t,n){var i;if(e.contentHeader.case==="byteHeader"){const s=this.byteStreamHandlers.get(e.topic);if(!s){this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);return}let a;const A={id:e.streamId,name:(i=e.contentHeader.value.name)!==null&&i!==void 0?i:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:TA(e.timestamp),attributes:e.attributes,encryptionType:n},o=new ReadableStream({start:c=>{if(a=c,this.textStreamControllers.has(e.streamId))throw new dn("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),Pt.AlreadyOpened);this.byteStreamControllers.set(e.streamId,{info:A,controller:a,startTime:Date.now(),sendingParticipantIdentity:t})}});s(new oB(A,o,TA(e.totalLength)),{identity:t})}else if(e.contentHeader.case==="textHeader"){const s=this.textStreamHandlers.get(e.topic);if(!s){this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);return}let a;const A={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes,encryptionType:n,attachedStreamIds:e.contentHeader.value.attachedStreamIds},o=new ReadableStream({start:c=>{if(a=c,this.textStreamControllers.has(e.streamId))throw new dn("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),Pt.AlreadyOpened);this.textStreamControllers.set(e.streamId,{info:A,controller:a,startTime:Date.now(),sendingParticipantIdentity:t})}});s(new cB(A,o,TA(e.totalLength)),{identity:t})}}handleStreamChunk(e,t){const n=this.byteStreamControllers.get(e.streamId);n&&(n.info.encryptionType!==t?(n.controller.error(new dn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(n.info.encryptionType),Pt.EncryptionTypeMismatch)),this.byteStreamControllers.delete(e.streamId)):e.content.length>0&&n.controller.enqueue(e));const i=this.textStreamControllers.get(e.streamId);i&&(i.info.encryptionType!==t?(i.controller.error(new dn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(i.info.encryptionType),Pt.EncryptionTypeMismatch)),this.textStreamControllers.delete(e.streamId)):e.content.length>0&&i.controller.enqueue(e))}handleStreamTrailer(e,t){const n=this.textStreamControllers.get(e.streamId);n&&(n.info.encryptionType!==t?n.controller.error(new dn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(n.info.encryptionType),Pt.EncryptionTypeMismatch)):(n.info.attributes=Object.assign(Object.assign({},n.info.attributes),e.attributes),n.controller.close(),this.textStreamControllers.delete(e.streamId)));const i=this.byteStreamControllers.get(e.streamId);i&&(i.info.encryptionType!==t?i.controller.error(new dn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(i.info.encryptionType),Pt.EncryptionTypeMismatch)):(i.info.attributes=Object.assign(Object.assign({},i.info.attributes),e.attributes),i.controller.close()),this.byteStreamControllers.delete(e.streamId))}}class Ng{constructor(e,t,n){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=n,this.info=t}write(e){return this.defaultWriter.write(e)}close(){return k(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),(e=this.onClose)===null||e===void 0||e.call(this)})}}class dB extends Ng{}class uB extends Ng{}const fh=15e3;class hB{constructor(e,t){this.engine=e,this.log=t}setupEngine(e){this.engine=e}sendText(e,t){return k(this,void 0,void 0,function*(){var n;const i=crypto.randomUUID(),a=new TextEncoder().encode(e).byteLength,A=(n=t==null?void 0:t.attachments)===null||n===void 0?void 0:n.map(()=>crypto.randomUUID()),o=new Array(A?A.length+1:1).fill(0),c=(d,u)=>{var h;o[u]=d;const p=o.reduce((g,v)=>g+v,0);(h=t==null?void 0:t.onProgress)===null||h===void 0||h.call(t,p)},l=yield this.streamText({streamId:i,totalSize:a,destinationIdentities:t==null?void 0:t.destinationIdentities,topic:t==null?void 0:t.topic,attachedStreamIds:A,attributes:t==null?void 0:t.attributes});return yield l.write(e),c(1,0),yield l.close(),t!=null&&t.attachments&&A&&(yield Promise.all(t.attachments.map((d,u)=>k(this,void 0,void 0,function*(){return this._sendFile(A[u],d,{topic:t.topic,mimeType:d.type,onProgress:h=>{c(h,u+1)}})})))),l.info})}streamText(e){return k(this,void 0,void 0,function*(){var t,n,i;const s=(t=e==null?void 0:e.streamId)!==null&&t!==void 0?t:crypto.randomUUID(),a={id:s,mimeType:"text/plain",timestamp:Date.now(),topic:(n=e==null?void 0:e.topic)!==null&&n!==void 0?n:"",size:e==null?void 0:e.totalSize,attributes:e==null?void 0:e.attributes,encryptionType:!((i=this.engine.e2eeManager)===null||i===void 0)&&i.isDataChannelEncryptionEnabled?De.GCM:De.NONE,attachedStreamIds:e==null?void 0:e.attachedStreamIds},A=new qA({streamId:s,mimeType:a.mimeType,topic:a.topic,timestamp:ai(a.timestamp),totalLength:ai(a.size),attributes:a.attributes,contentHeader:{case:"textHeader",value:new Em({version:e==null?void 0:e.version,attachedStreamIds:a.attachedStreamIds,replyToStreamId:e==null?void 0:e.replyToStreamId,operationType:(e==null?void 0:e.type)==="update"?Ql.UPDATE:Ql.CREATE})}}),o=e==null?void 0:e.destinationIdentities,c=new Ft({destinationIdentities:o,value:{case:"streamHeader",value:A}});yield this.engine.sendDataPacket(c,ge.RELIABLE);let l=0;const d=this.engine,u=new WritableStream({write(g){return k(this,void 0,void 0,function*(){for(const v of X4(g,fh)){const w=new WA({content:v,streamId:s,chunkIndex:ai(l)}),B=new Ft({destinationIdentities:o,value:{case:"streamChunk",value:w}});yield d.sendDataPacket(B,ge.RELIABLE),l+=1}})},close(){return k(this,void 0,void 0,function*(){const g=new $A({streamId:s}),v=new Ft({destinationIdentities:o,value:{case:"streamTrailer",value:g}});yield d.sendDataPacket(v,ge.RELIABLE)})},abort(g){}});let h=()=>k(this,void 0,void 0,function*(){yield p.close()});d.once(G.Closing,h);const p=new dB(u,a,()=>this.engine.off(G.Closing,h));return p})}sendFile(e,t){return k(this,void 0,void 0,function*(){const n=crypto.randomUUID();return yield this._sendFile(n,e,t),{id:n}})}_sendFile(e,t,n){return k(this,void 0,void 0,function*(){var i;const s=yield this.streamBytes({streamId:e,totalSize:t.size,name:t.name,mimeType:(i=n==null?void 0:n.mimeType)!==null&&i!==void 0?i:t.type,topic:n==null?void 0:n.topic,destinationIdentities:n==null?void 0:n.destinationIdentities}),a=t.stream().getReader();for(;;){const A=yield a.read(),o=A.done,c=A.value;if(o)break;yield s.write(c)}return yield s.close(),s.info})}streamBytes(e){return k(this,void 0,void 0,function*(){var t,n,i,s,a;const A=(t=e==null?void 0:e.streamId)!==null&&t!==void 0?t:crypto.randomUUID(),o=e==null?void 0:e.destinationIdentities,c={id:A,mimeType:(n=e==null?void 0:e.mimeType)!==null&&n!==void 0?n:"application/octet-stream",topic:(i=e==null?void 0:e.topic)!==null&&i!==void 0?i:"",timestamp:Date.now(),attributes:e==null?void 0:e.attributes,size:e==null?void 0:e.totalSize,name:(s=e==null?void 0:e.name)!==null&&s!==void 0?s:"unknown",encryptionType:!((a=this.engine.e2eeManager)===null||a===void 0)&&a.isDataChannelEncryptionEnabled?De.GCM:De.NONE},l=new qA({totalLength:ai(c.size),mimeType:c.mimeType,streamId:A,topic:c.topic,timestamp:ai(Date.now()),attributes:c.attributes,contentHeader:{case:"byteHeader",value:new Um({name:c.name})}}),d=new Ft({destinationIdentities:o,value:{case:"streamHeader",value:l}});yield this.engine.sendDataPacket(d,ge.RELIABLE);let u=0;const h=new xt,p=this.engine,g=this.log,v=new WritableStream({write(B){return k(this,void 0,void 0,function*(){const E=yield h.lock();let b=0;try{for(;b<B.byteLength;){const C=B.slice(b,b+fh),T=new Ft({destinationIdentities:o,value:{case:"streamChunk",value:new WA({content:C,streamId:A,chunkIndex:ai(u)})}});yield p.sendDataPacket(T,ge.RELIABLE),u+=1,b+=C.byteLength}}finally{E()}})},close(){return k(this,void 0,void 0,function*(){const B=new $A({streamId:A}),E=new Ft({destinationIdentities:o,value:{case:"streamTrailer",value:B}});yield p.sendDataPacket(E,ge.RELIABLE)})},abort(B){g.error("Sink error:",B)}});return new uB(v,c)})}}function Kg(r){if(r.length===0)return new AbortController().signal;if(r.length===1)return r[0];for(const i of r)if(i.aborted)return i;const e=new AbortController,t=Array(r.length),n=()=>{for(const i of t)i()};return r.forEach((i,s)=>{const a=()=>{e.abort(i.reason),n()};i.addEventListener("abort",a),t[s]=()=>i.removeEventListener("abort",a)}),e.signal}function Vg(r){const e=new AbortController;return setTimeout(()=>{e.abort(new DOMException("signal timed out after ".concat(r," ms"),"TimeoutError"))},r),e.signal}const nt=1,ir=2,ph=4,fB=8,mh=0,gh=12,vh=5,pB=7,yh=3,mB=3,wh=2,bh=1,Bh=0,Ch=3,Ra=2,Sh=2,gB=1,vB=0;var cr;(function(r){r[r.TooShort=0]="TooShort",r[r.HeaderOverrun=1]="HeaderOverrun",r[r.MissingExtWords=2]="MissingExtWords",r[r.UnsupportedVersion=3]="UnsupportedVersion",r[r.InvalidHandle=4]="InvalidHandle",r[r.MalformedExt=5]="MalformedExt"})(cr||(cr={}));class Dt extends wn{constructor(e,t,n){super(19,e,n),this.name="DataTrackDeserializeError",this.reason=t,this.reasonName=cr[t]}static tooShort(){return new Dt("Too short to contain a valid header",cr.TooShort)}static headerOverrun(){return new Dt("Header exceeds total packet length",cr.HeaderOverrun)}static missingExtWords(){return new Dt("Extension word indicator is missing",cr.MissingExtWords)}static unsupportedVersion(e){return new Dt("Unsupported version ".concat(e),cr.UnsupportedVersion)}static invalidHandle(e){return new Dt("invalid track handle: ".concat(e.message),cr.InvalidHandle,{cause:e})}static malformedExt(e){return new Dt("Extension with tag ".concat(e," is malformed"),cr.MalformedExt)}}var js;(function(r){r[r.TooSmallForHeader=0]="TooSmallForHeader",r[r.TooSmallForPayload=1]="TooSmallForPayload"})(js||(js={}));class fa extends wn{constructor(e,t,n){super(19,e,n),this.name="DataTrackSerializeError",this.reason=t,this.reasonName=js[t]}static tooSmallForHeader(){return new fa("Buffer cannot fit header",js.TooSmallForHeader)}static tooSmallForPayload(){return new fa("Buffer cannot fit payload",js.TooSmallForPayload)}}class Mo{toBinary(){const e=this.toBinaryLengthBytes(),t=new ArrayBuffer(e),n=new DataView(t),i=this.toBinaryInto(n);if(e!==i)throw new Error("".concat(this.constructor.name,".toBinary: written bytes (").concat(i," bytes) not equal to allocated array buffer length (").concat(e," bytes)."));return new Uint8Array(t)}}var os;(function(r){r[r.UserTimestamp=2]="UserTimestamp",r[r.E2ee=1]="E2ee"})(os||(os={}));class zg extends Mo{}class Fn extends zg{constructor(e){super(),this.timestamp=e}toBinaryLengthBytes(){return nt+nt+Fn.lengthBytes}toBinaryInto(e){let t=0;e.setUint8(t,Fn.tag),t+=nt,e.setUint8(t,Fn.lengthBytes),t+=nt,e.setBigUint64(t,this.timestamp),t+=fB;const n=this.toBinaryLengthBytes();if(t!==n)throw new Error("DataTrackUserTimestampExtension.toBinaryInto: Wrote ".concat(t," bytes but expected length was ").concat(n," bytes"));return t}toJSON(){return{tag:Fn.tag,lengthBytes:Fn.lengthBytes,timestamp:this.timestamp}}}Fn.tag=os.UserTimestamp;Fn.lengthBytes=8;class In extends zg{constructor(e,t){super(),this.keyIndex=e,this.iv=t}toBinaryLengthBytes(){return nt+nt+In.lengthBytes}toBinaryInto(e){let t=0;e.setUint8(t,In.tag),t+=nt,e.setUint8(t,In.lengthBytes),t+=nt,e.setUint8(t,this.keyIndex),t+=nt;for(let i=0;i<this.iv.length;i+=1)e.setUint8(t,this.iv[i]),t+=nt;const n=this.toBinaryLengthBytes();if(t!==n)throw new Error("DataTrackE2eeExtension.toBinaryInto: Wrote ".concat(t," bytes but expected length was ").concat(n," bytes"));return t}toJSON(){return{tag:In.tag,lengthBytes:In.lengthBytes,keyIndex:this.keyIndex,iv:this.iv}}}In.tag=os.E2ee;In.lengthBytes=13;class Yi extends Mo{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.userTimestamp=e.userTimestamp,this.e2ee=e.e2ee}toBinaryLengthBytes(){let e=0;return this.userTimestamp&&(e+=this.userTimestamp.toBinaryLengthBytes()),this.e2ee&&(e+=this.e2ee.toBinaryLengthBytes()),e}toBinaryInto(e){let t=0;if(this.e2ee){const i=this.e2ee.toBinaryInto(e);t+=i}if(this.userTimestamp){const i=this.userTimestamp.toBinaryInto(new DataView(e.buffer,e.byteOffset+t));t+=i}const n=this.toBinaryLengthBytes();if(t!==n)throw new Error("DataTrackExtensions.toBinaryInto: Wrote ".concat(t," bytes but expected length was ").concat(n," bytes"));return t}static fromBinary(e){const t=mu(e);let n,i,s=0;for(;t.byteLength-s>=nt+nt;){const a=t.getUint8(s);s+=nt;const A=t.getUint8(s);if(s+=nt,a!==vB)switch(a){case os.UserTimestamp:if(t.byteLength-s<Fn.lengthBytes)throw Dt.malformedExt(a);n=new Fn(t.getBigUint64(s)),s+=A;break;case os.E2ee:if(t.byteLength-s<In.lengthBytes)throw Dt.malformedExt(a);const o=t.getUint8(s),c=new Uint8Array(12);for(let l=0;l<c.length;l+=1){let d=s;d+=nt,d+=l*nt,c[l]=t.getUint8(d)}i=new In(o,c),s+=A;break;default:if(t.byteLength-s<A)throw Dt.malformedExt(a);s+=A;break}}return[new Yi({userTimestamp:n,e2ee:i}),t.byteLength]}toJSON(){var e,t,n,i;return{userTimestamp:(t=(e=this.userTimestamp)===null||e===void 0?void 0:e.toJSON())!==null&&t!==void 0?t:null,e2ee:(i=(n=this.e2ee)===null||n===void 0?void 0:n.toJSON())!==null&&i!==void 0?i:null}}}const Gg={from(r){return{payload:r.payload,extensions:new Yi({userTimestamp:r.userTimestamp?new Fn(r.userTimestamp):void 0})}},lossyIntoFrame(r){var e;return{payload:r.payload,userTimestamp:(e=r.extensions.userTimestamp)===null||e===void 0?void 0:e.timestamp}}},qg=Symbol.for("lk.track"),Wg=Symbol.for("lk.data-track");class $g{constructor(e,t,n){this.trackSymbol=qg,this.isLocal=!1,this.typeSymbol=Wg,this.info=e,this.manager=t,this.publisherIdentity=n.publisherIdentity}subscribe(e){try{const t=this.manager.openSubscriptionStream(this.info.sid,e==null?void 0:e.signal,e==null?void 0:e.bufferSize),n=Ae(t,2),i=n[0];return n[1].catch(()=>{}),i}catch(t){throw t}}setPipelineOptions(e){this.manager.setPipelineOptions(this.info.sid,e)}}class pa extends Mo{constructor(e){var t;super(),this.marker=e.marker,this.trackHandle=e.trackHandle,this.sequence=e.sequence,this.frameNumber=e.frameNumber,this.timestamp=e.timestamp,this.extensions=(t=e.extensions)!==null&&t!==void 0?t:new Yi}extensionsMetrics(){const e=this.extensions.toBinaryLengthBytes(),t=Math.ceil((Ra+e)/4),n=t*4-Ra-e;return{lengthBytes:e,lengthWords:t,paddingLengthBytes:n}}toBinaryLengthBytes(){const e=this.extensionsMetrics(),t=e.lengthBytes,n=e.paddingLengthBytes;let i=gh;return t>0&&(i+=Ra+t+n),i}toBinaryInto(e){if(e.byteLength<this.toBinaryLengthBytes())throw fa.tooSmallForHeader();let t=mh<<vh,n;switch(this.marker){case Ne.Inter:n=Bh;break;case Ne.Final:n=bh;break;case Ne.Start:n=wh;break;case Ne.Single:n=Ch;break}t|=n<<yh;const i=this.extensionsMetrics(),s=i.lengthBytes,a=i.lengthWords,A=i.paddingLengthBytes;s>0&&(t|=1<<Sh);let o=0;if(e.setUint8(o,t),o+=nt,e.setUint8(o,0),o+=nt,e.setUint16(o,this.trackHandle),o+=ir,e.setUint16(o,this.sequence.value),o+=ir,e.setUint16(o,this.frameNumber.value),o+=ir,e.setUint32(o,this.timestamp.asTicks()),o+=ph,s>0){const l=a-1;e.setUint16(o,l),o+=ir;const d=this.extensions.toBinaryInto(new DataView(e.buffer,e.byteOffset+o));o+=d;for(let u=0;u<A;u+=1)e.setUint8(o,0),o+=nt}const c=this.toBinaryLengthBytes();if(o!==c)throw new Error("DataTrackPacketHeader.toBinaryInto: Wrote ".concat(o," bytes but expected length was ").concat(c," bytes"));return c}static fromBinary(e){const t=mu(e);if(t.byteLength<gh)throw Dt.tooShort();let n=0;const i=t.getUint8(n);n+=nt;const s=i>>vh&pB;if(s>mh)throw Dt.unsupportedVersion(s);let a;switch(i>>yh&mB){case wh:a=Ne.Start;break;case bh:a=Ne.Final;break;case Ch:a=Ne.Single;break;case Bh:default:a=Ne.Inter;break}const A=(i>>Sh&gB)>0;n+=nt;let o;try{o=v2.fromNumber(t.getUint16(n))}catch(h){throw h instanceof As&&(h.isReason(vi.Reserved)||h.isReason(vi.TooLarge))?Dt.invalidHandle(h):h}n+=ir;const c=Mn.u16(t.getUint16(n));n+=ir;const l=Mn.u16(t.getUint16(n));n+=ir;const d=Ji.fromRtpTicks(t.getUint32(n));n+=ph;let u=new Yi;if(A){if(t.byteLength-n<ir)throw Dt.missingExtWords();let h=t.getUint16(n);n+=ir;let g=4*(h+1)-Ra;if(n+g>t.byteLength)throw Dt.headerOverrun();let v=new DataView(t.buffer,t.byteOffset+n,g);const w=Yi.fromBinary(v),B=Ae(w,2),E=B[0],b=B[1];u=E,n+=b}return[new pa({marker:a,trackHandle:o,sequence:c,frameNumber:l,timestamp:d,extensions:u}),n]}toJSON(){return{marker:this.marker,trackHandle:this.trackHandle,sequence:this.sequence.value,frameNumber:this.frameNumber.value,timestamp:this.timestamp.asTicks(),extensions:this.extensions.toJSON()}}}var Ne;(function(r){r[r.Start=0]="Start",r[r.Inter=1]="Inter",r[r.Final=2]="Final",r[r.Single=3]="Single"})(Ne||(Ne={}));class _o extends Mo{constructor(e,t){super(),this.header=e,this.payload=t}toBinaryLengthBytes(){return this.header.toBinaryLengthBytes()+this.payload.byteLength}toBinaryInto(e){let t=0;const n=this.header.toBinaryInto(e);if(t+=n,e.byteLength-t<this.payload.byteLength)throw fa.tooSmallForPayload();for(let s=0;s<this.payload.length;s+=1)e.setUint8(t,this.payload[s]),t+=nt;const i=this.toBinaryLengthBytes();if(t!==i)throw new Error("DataTrackPacket.toBinaryInto: Wrote ".concat(t," bytes but expected length was ").concat(i," bytes"));return i}static fromBinary(e){const t=mu(e),n=pa.fromBinary(t),i=Ae(n,2),s=i[0],a=i[1],A=t.buffer.slice(t.byteOffset+a,t.byteOffset+t.byteLength);return[new _o(s,new Uint8Array(A)),t.byteLength]}toJSON(){return{header:this.header.toJSON(),payload:this.payload}}}const Qc=Xt(Ct.DataTracks);class Gn extends wn{constructor(e,t,n,i){super(19,"Frame ".concat(n," dropped: ").concat(e),i),this.name="DataTrackDepacketizerDropError",this.reason=t,this.reasonName=li[t],this.frameNumber=n}static interrupted(e,t){return new Gn("Interrupted by the start of a new frame ".concat(t),li.Interrupted,e)}static unknownFrame(e){return new Gn("Initial packet was never received.",li.UnknownFrame,e)}static bufferFull(e){return new Gn("Reorder buffer is full.",li.BufferFull,e)}static incomplete(e,t,n){return new Gn("Not all packets received before final packet. Received ".concat(t," packets, expected ").concat(n," packets."),li.Incomplete,e)}}var li;(function(r){r[r.Interrupted=0]="Interrupted",r[r.UnknownFrame=1]="UnknownFrame",r[r.BufferFull=2]="BufferFull",r[r.Incomplete=3]="Incomplete"})(li||(li={}));class Ro{constructor(){this.partials=new Map}push(e,t){switch(e.header.marker){case Ne.Single:return this.frameFromSingle(e,t);case Ne.Start:return this.beginPartial(e,t);case Ne.Inter:case Ne.Final:return this.pushToPartial(e)}}reset(){this.partials.clear()}peekOldestPartialFrameNumber(){const e=this.partials.keys().next();return e.done?null:e.value}frameFromSingle(e,t){var n;if(e.header.marker!==Ne.Single)throw new Error("Depacketizer.frameFromSingle: packet.header.marker was not FrameMarker.Single, found ".concat(e.header.marker,"."));const i=(n=t==null?void 0:t.maxPartialFrames)!==null&&n!==void 0?n:1;if(this.partials.size>=i){const s=this.peekOldestPartialFrameNumber();if(typeof s!="number")throw new Error("Depacketizer.frameFromSingle: no oldest frame number found, but partials.size is ".concat(this.partials.size,"."));if(this.partials.delete(s),t!=null&&t.throwOnInterruption)throw Gn.interrupted(s,e.header.frameNumber.value);Qc.warn("Data track frame ".concat(s," was interrupted by single-packet frame ").concat(e.header.frameNumber.value,", dropping."))}return{payload:e.payload,extensions:e.header.extensions}}beginPartial(e,t){var n;if(e.header.marker!==Ne.Start)throw new Error("Depacketizer.beginPartial: packet.header.marker was not FrameMarker.Start, found ".concat(e.header.marker,"."));const i=e.header.sequence,s=e.header.frameNumber.value,a={startSequence:i,extensions:e.header.extensions,payloads:new Map([[i.value,e.payload]])},A=(n=t==null?void 0:t.maxPartialFrames)!==null&&n!==void 0?n:1;for(;this.partials.size>=A;){const o=this.peekOldestPartialFrameNumber();if(typeof o!="number")break;if(this.partials.delete(o),t!=null&&t.throwOnInterruption)throw Gn.interrupted(o,s);Qc.warn("Data track partials full (max ".concat(A,"), evicted oldest frame ").concat(o," to make room for new frame ").concat(s,"."))}return this.partials.set(s,a),null}pushToPartial(e){if(e.header.marker!==Ne.Inter&&e.header.marker!==Ne.Final)throw new Error("Depacketizer.pushToPartial: packet.header.marker was not FrameMarker.Inter or FrameMarker.Final, found ".concat(e.header.marker,"."));const t=e.header.frameNumber.value,n=this.partials.get(t);if(!n)throw this.partials.delete(t),Gn.unknownFrame(t);if(n.payloads.size>=Ro.MAX_BUFFER_PACKETS)throw this.partials.delete(t),Gn.bufferFull(t);return n.payloads.has(e.header.sequence.value)&&Qc.warn("Data track frame ".concat(t," received duplicate packet for sequence ").concat(e.header.sequence.value,", so replacing with newly received packet.")),n.payloads.set(e.header.sequence.value,e.payload),e.header.marker===Ne.Final?this.finalize(t,n,e.header.sequence.value):null}finalize(e,t,n){const i=t.payloads.size;let s=0;for(const c of t.payloads.values())s+=c.length;const a=new Uint8Array(s);let A=t.startSequence.clone(),o=0;for(;;){const c=t.payloads.get(A.value);if(!c)break;t.payloads.delete(A.value);const l=a.length-o;if(c.length>l)throw new Error("Depacketizer.finalize: Expected at least ".concat(c.length," more bytes left in the payload buffer, only got ").concat(l," bytes."));if(a.set(c,o),o+=c.length,A.value!=n){A.increment();continue}return this.partials.delete(e),{payload:a,extensions:t.extensions}}throw this.partials.delete(e),Gn.incomplete(e,i,n-t.startSequence.value+1)}}Ro.MAX_BUFFER_PACKETS=128;var di;(function(r){r[r.Unpublished=0]="Unpublished",r[r.Timeout=1]="Timeout",r[r.Disconnected=2]="Disconnected",r[r.Cancelled=4]="Cancelled"})(di||(di={}));class Gt extends wn{constructor(e,t,n){super(22,e,n),this.name="DataTrackSubscribeError",this.reason=t,this.reasonName=di[t]}static unpublished(){return new Gt("The track has been unpublished and is no longer available",di.Unpublished)}static timeout(){return new Gt("Request to subscribe to data track timed-out",di.Timeout)}static disconnected(){return new Gt("Cannot subscribe to data track when disconnected",di.Disconnected)}static cancelled(){return new Gt("Subscription to data track cancelled by caller",di.Cancelled)}}const Mc=Xt(Ct.DataTracks);class yB{constructor(e){var t,n;const i=e.e2eeManager!==null;if(e.info.usesE2ee!==i)throw new Error("IncomingDataTrackPipeline: DataTrackInfo.usesE2ee must match presence of decryptionProvider");const s=new Ro;this.publisherIdentity=e.publisherIdentity,this.e2eeManager=(t=e.e2eeManager)!==null&&t!==void 0?t:null,this.depacketizer=s,this.options=(n=e.pipelineOptions)!==null&&n!==void 0?n:{}}updateE2eeManager(e){this.e2eeManager=e}setOptions(e){this.options=e}processPacket(e){return k(this,void 0,void 0,function*(){const t=this.depacketize(e);if(!t)return null;const n=yield this.decryptIfNeeded(t);return n||null})}depacketize(e){let t;try{t=this.depacketizer.push(e,{throwOnInterruption:!1,maxPartialFrames:this.options.maxPartialFrames})}catch(n){return Mc.warn("Data frame depacketize error: ".concat(n)),null}return t}decryptIfNeeded(e){return k(this,void 0,void 0,function*(){var t,n;const i=this.e2eeManager;if(!i)return e;const s=(n=(t=e.extensions)===null||t===void 0?void 0:t.e2ee)!==null&&n!==void 0?n:null;if(!s)return Mc.error("Missing E2EE meta"),null;let a;try{a=yield i.handleEncryptedData(e.payload,s.iv,this.publisherIdentity,s.keyIndex)}catch(A){return Mc.error("Error decrypting packet: ".concat(A)),null}return e.payload=a.payload,e})}}const St=Xt(Ct.DataTracks),wB=1e4,bB=16;class BB extends Yt.EventEmitter{constructor(e){var t;super(),this.descriptors=new Map,this.subscriptionHandles=new Map,this.e2eeManager=(t=e==null?void 0:e.e2eeManager)!==null&&t!==void 0?t:null}updateE2eeManager(e){this.e2eeManager=e;for(const t of this.descriptors.values())t.subscription.type==="active"&&t.subscription.pipeline.updateE2eeManager(e)}setPipelineOptions(e,t){const n=this.descriptors.get(e);if(!n){St.warn("Unknown track ".concat(e,", cannot set pipeline options."));return}n.pipelineOptions=t,n.subscription.type==="active"&&n.subscription.pipeline.setOptions(t)}openSubscriptionStream(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bB,i=null;const s=new Bt,a=()=>{t==null||t.removeEventListener("abort",o)},A=()=>{if(a(),!i){St.warn("ReadableStream subscribed to ".concat(e," was not started."));return}const l=this.descriptors.get(e);if(!l){St.warn("Unknown track ".concat(e,", skipping cancel..."));return}if(l.subscription.type!=="active"){St.warn("Subscription for track ".concat(e," is not active, skipping cancel..."));return}l.subscription.streamControllers.delete(i),l.subscription.streamControllers.size===0&&this.unSubscribeRequest(l.info.sid)},o=()=>{var l;if(!i)return;const d=this.descriptors.get(e);(d==null?void 0:d.subscription.type)==="active"&&d.subscription.streamControllers.delete(i),i.error(Gt.cancelled()),(l=s.reject)===null||l===void 0||l.call(s,Gt.cancelled()),A()};return[new ReadableStream({start:l=>{i=l,this.subscribeRequest(e,t).then(()=>k(this,void 0,void 0,function*(){var d,u,h;const p=this.descriptors.get(e);if(!p){St.error("Unknown track ".concat(e));const g=Gt.disconnected();l.error(g),(d=s.reject)===null||d===void 0||d.call(s,g);return}if(p.subscription.type!=="active"){St.error("Subscription for track ".concat(e," is not active"));const g=Gt.disconnected();l.error(g),(u=s.reject)===null||u===void 0||u.call(s,g);return}if(t!=null&&t.aborted){o();return}t==null||t.addEventListener("abort",o),p.subscription.streamControllers.set(l,a),(h=s.resolve)===null||h===void 0||h.call(s)})).catch(d=>{var u;l.error(d),(u=s.reject)===null||u===void 0||u.call(s,d)})},cancel:()=>{A()}},new CountQueuingStrategy({highWaterMark:n})),s.promise]}subscribeRequest(e,t){return k(this,void 0,void 0,function*(){const n=this.descriptors.get(e);if(!n)throw new Error("Cannot subscribe to unknown track");const i=(s,a,A)=>k(this,void 0,void 0,function*(){if(s.subscription.type==="active")return;if(s.subscription.type!=="pending")throw new Error("Descriptor for track ".concat(e," is not pending, found ").concat(s.subscription.type));const o=Kg([a,A].filter(d=>typeof d<"u")),c=new Bt;s.subscription.completionFuture.promise.then(()=>{var d;return(d=c.resolve)===null||d===void 0?void 0:d.call(c)}).catch(d=>{var u;return(u=c.reject)===null||u===void 0?void 0:u.call(c,d)});const l=()=>{var d;if(s.subscription.type==="pending"){if(s.subscription.pendingRequestCount-=1,A!=null&&A.aborted){s.subscription.cancel();return}if(s.subscription.pendingRequestCount<=0){s.subscription.cancel();return}(d=c.reject)===null||d===void 0||d.call(c,Gt.cancelled())}};o.aborted&&l(),o.addEventListener("abort",l),yield c.promise,o.removeEventListener("abort",l)});switch(n.subscription.type){case"none":{n.subscription={type:"pending",completionFuture:new Bt,pendingRequestCount:1,cancel:()=>{var a,A;const o=n.subscription;n.subscription={type:"none"},this.emit("sfuUpdateSubscription",{sid:e,subscribe:!1}),o.type==="pending"&&((A=(a=o.completionFuture).reject)===null||A===void 0||A.call(a,s.aborted?Gt.timeout():Gt.cancelled()))}},this.emit("sfuUpdateSubscription",{sid:e,subscribe:!0});const s=Vg(wB);yield i(n,t,s);return}case"pending":{n.subscription.pendingRequestCount+=1,yield i(n,t);return}case"active":return}})}querySubscribed(){return k(this,void 0,void 0,function*(){return Array.from(this.descriptors.values()).filter(t=>t.subscription.type==="active").map(t=>[t.info,t.publisherIdentity])})}unSubscribeRequest(e){var t;const n=this.descriptors.get(e);if(!n)throw new Error("Cannot subscribe to unknown track");if(n.subscription.type!=="active"){St.warn("Unexpected descriptor state in unSubscribeRequest, expected active, found ".concat((t=n.subscription)===null||t===void 0?void 0:t.type));return}this.closeStreamControllers(n.subscription.streamControllers,e);const i=n.subscription;n.subscription={type:"none"},this.subscriptionHandles.delete(i.subcriptionHandle),this.emit("sfuUpdateSubscription",{sid:e,subscribe:!1})}closeStreamControllers(e,t){for(const i of e){var n=Ae(i,2);const s=n[0],a=n[1];a();try{s.close()}catch(A){St.warn("Failed to close readable stream for track ".concat(t,": ").concat(A))}}}receiveSfuPublicationUpdates(e){return k(this,void 0,void 0,function*(){if(e.size===0)return;const t=new Map;for(const s of e.entries()){var n=Ae(s,2);const a=n[0],A=n[1],o=new Set;for(const c of A)o.add(c.sid),!this.descriptors.has(c.sid)&&(yield this.handleTrackPublished(a,c));t.set(a,o)}for(const s of t.entries()){var i=Ae(s,2);const a=i[0],A=i[1];let c=Array.from(this.descriptors.entries()).filter(l=>{let d=Ae(l,2);return d[0],d[1].publisherIdentity===a}).map(l=>Ae(l,1)[0]).filter(l=>!A.has(l));for(const l of c)this.handleTrackUnpublished(l)}})}queryPublications(){return k(this,void 0,void 0,function*(){return Array.from(this.descriptors.values()).map(e=>e.info)})}handleTrackPublished(e,t){return k(this,void 0,void 0,function*(){if(this.descriptors.has(t.sid)){St.error("Existing descriptor for track ".concat(t.sid));return}let n={info:t,publisherIdentity:e,subscription:{type:"none"},pipelineOptions:{}};this.descriptors.set(n.info.sid,n);const i=new $g(n.info,this,{publisherIdentity:e});this.emit("trackPublished",{track:i})})}handleTrackUnpublished(e){const t=this.descriptors.get(e);if(!t){St.error("Unknown track ".concat(e));return}this.descriptors.delete(e),t.subscription.type==="active"&&(this.closeStreamControllers(t.subscription.streamControllers,e),this.subscriptionHandles.delete(t.subscription.subcriptionHandle)),this.emit("trackUnpublished",{sid:e,publisherIdentity:t.publisherIdentity})}receivedSfuSubscriberHandles(e){for(const n of e.entries()){var t=Ae(n,2);const i=t[0],s=t[1];this.registerSubscriberHandle(i,s)}}registerSubscriberHandle(e,t){var n,i;const s=this.descriptors.get(t);if(!s){St.error("Unknown track ".concat(t));return}switch(s.subscription.type){case"none":{St.warn("No subscription for ".concat(t));return}case"active":{s.subscription.subcriptionHandle=e,this.subscriptionHandles.set(e,t);return}case"pending":{const a=new yB({info:s.info,publisherIdentity:s.publisherIdentity,e2eeManager:this.e2eeManager,pipelineOptions:s.pipelineOptions}),A=s.subscription;s.subscription={type:"active",subcriptionHandle:e,pipeline:a,streamControllers:new Map},this.subscriptionHandles.set(e,t),(i=(n=A.completionFuture).resolve)===null||i===void 0||i.call(n)}}}packetReceived(e){return k(this,void 0,void 0,function*(){let t;try{var n=_o.fromBinary(e),i=Ae(n,1);t=i[0]}catch(o){St.error("Failed to deserialize packet: ".concat(o));return}const s=this.subscriptionHandles.get(t.header.trackHandle);if(!s){St.warn("Unknown subscriber handle ".concat(t.header.trackHandle));return}const a=this.descriptors.get(s);if(!a){St.error("Missing descriptor for track ".concat(s));return}if(a.subscription.type!=="active"){St.warn("Received packet for track ".concat(s," without active subscription"));return}const A=yield a.subscription.pipeline.processPacket(t);if(A)for(const o of a.subscription.streamControllers.keys()){if(o.desiredSize!==null&&o.desiredSize<=0){St.warn("Cannot send frame to subscribers: readable stream is full (desiredSize is ".concat(o.desiredSize,"). To increase this threshold, set a higher 'options.highWaterMark' when calling .subscribe()."));continue}const c=Gg.lossyIntoFrame(A);o.enqueue(c)}})}resendSubscriptionUpdates(){for(const t of this.descriptors){var e=Ae(t,2);const n=e[0];e[1].subscription.type!=="none"&&this.emit("sfuUpdateSubscription",{sid:n,subscribe:!0})}}handleRemoteParticipantDisconnected(e){var t,n;for(const i of this.descriptors.values())if(i.publisherIdentity===e)switch(i.subscription.type){case"none":break;case"pending":(n=(t=i.subscription.completionFuture).reject)===null||n===void 0||n.call(t,Gt.disconnected());break;case"active":this.unSubscribeRequest(i.info.sid);break}}reset(){var e,t;for(const n of this.descriptors.values())this.emit("trackUnpublished",{sid:n.info.sid,publisherIdentity:n.publisherIdentity}),n.subscription.type==="pending"&&((t=(e=n.subscription.completionFuture).reject)===null||t===void 0||t.call(e,Gt.disconnected())),n.subscription.type==="active"&&this.closeStreamControllers(n.subscription.streamControllers,n.info.sid);this.descriptors.clear(),this.subscriptionHandles.clear()}}class Po extends wn{constructor(e,t,n){super(19,e,n),this.name="DataTrackPacketizerError",this.reason=t,this.reasonName=no[t]}static mtuTooShort(){return new Po("MTU is too short to send frame",no.MtuTooShort)}}var no;(function(r){r[r.MtuTooShort=0]="MtuTooShort"})(no||(no={}));class Bu{constructor(e,t){this.sequence=Mn.u16(0),this.frameNumber=Mn.u16(0),this.clock=oi.rtpStartingNow(Ji.rtpRandom()),this.handle=e,this.mtuSizeBytes=t}static computeFrameMarker(e,t){return t<=1?Ne.Single:e===0?Ne.Start:e===t-1?Ne.Final:Ne.Inter}*packetize(e,t){var n;const i=this.frameNumber.getThenIncrement(),s={marker:Ne.Inter,trackHandle:this.handle,sequence:Mn.u16(0),frameNumber:i,timestamp:(n=t==null?void 0:t.now)!==null&&n!==void 0?n:this.clock.now(),extensions:e.extensions},a=new pa(s).toBinaryLengthBytes();if(a>=this.mtuSizeBytes)throw Po.mtuTooShort();const A=this.mtuSizeBytes-a,o=Math.ceil(e.payload.byteLength/A);for(let l=0,d=0;d<e.payload.byteLength;c=[l+1,d+A],l=c[0],d=c[1],c){var c;const u=this.sequence.getThenIncrement(),h=new pa(Object.assign(Object.assign({},s),{marker:Bu.computeFrameMarker(l,o),sequence:u})),p=Math.min(A,e.payload.byteLength-d),g=new Uint8Array(e.payload.buffer,e.payload.byteOffset+d,p);yield new _o(h,g)}}}var Cn;(function(r){r[r.NotAllowed=0]="NotAllowed",r[r.DuplicateName=1]="DuplicateName",r[r.Timeout=2]="Timeout",r[r.LimitReached=3]="LimitReached",r[r.Disconnected=4]="Disconnected",r[r.Cancelled=5]="Cancelled",r[r.InvalidName=6]="InvalidName",r[r.Unknown=7]="Unknown"})(Cn||(Cn={}));class pt extends wn{constructor(e,t,n){super(21,e,n),this.name="DataTrackPublishError",this.reason=t,this.reasonName=Cn[t],this.rawMessage=n==null?void 0:n.rawMessage}static notAllowed(e){return new pt("Data track publishing unauthorized",Cn.NotAllowed,{rawMessage:e})}static duplicateName(e){return new pt("Track name already taken",Cn.DuplicateName,{rawMessage:e})}static invalidName(e){return new pt("Track name is invalid",Cn.InvalidName,{rawMessage:e})}static timeout(){return new pt("Publish data track timed-out. Does the LiveKit server support data tracks?",Cn.Timeout)}static limitReached(e){return new pt("Data track publication limit reached",Cn.LimitReached,{rawMessage:e})}static unknown(e,t){return new pt("Received RequestResponse for publishDataTrack, but reason was unrecognised (".concat(e,", ").concat(t,")"),Cn.Unknown)}static disconnected(){return new pt("Room disconnected",Cn.Disconnected)}static cancelled(){return new pt("Publish data track cancelled by caller",Cn.Cancelled)}}var Xs;(function(r){r[r.TrackUnpublished=0]="TrackUnpublished",r[r.Dropped=1]="Dropped"})(Xs||(Xs={}));class Lr extends wn{constructor(e,t,n){super(22,e,n),this.name="DataTrackPushFrameError",this.reason=t,this.reasonName=Xs[t]}static trackUnpublished(){return new Lr("Track is no longer published",Xs.TrackUnpublished)}static dropped(e){return new Lr("Frame was dropped",Xs.Dropped,{cause:e})}}var Js;(function(r){r[r.Packetizer=0]="Packetizer",r[r.Encryption=1]="Encryption"})(Js||(Js={}));class ma extends wn{constructor(e,t,n){super(21,e,n),this.name="DataTrackOutgoingPipelineError",this.reason=t,this.reasonName=Js[t]}static packetizer(e){return new ma("Error packetizing frame",Js.Packetizer,{cause:e})}static encryption(e){return new ma("Error encrypting frame",Js.Encryption,{cause:e})}}class Do{constructor(e,t){this.trackSymbol=qg,this.isLocal=!0,this.typeSymbol=Wg,this.handle=null,this.log=me,this.flushedFuture=new Bt,this.isFlushed=!0,this.handleManagerReset=()=>{var n,i;(i=(n=this.flushedFuture).resolve)===null||i===void 0||i.call(n),this.manager.off("packetsFlushedChange",this.handleManagerPacketsFlushedChange),this.manager.off("reset",this.handleManagerReset)},this.handleManagerPacketsFlushedChange=n=>{var i,s;this.isFlushed=n.isFlushed,n.isFlushed&&((s=(i=this.flushedFuture).resolve)===null||s===void 0||s.call(i),this.flushedFuture=new Bt)},this.options=e,this.manager=t,this.log=Xt(Ct.DataTracks),this.manager.on("packetsFlushedChange",this.handleManagerPacketsFlushedChange),this.manager.on("reset",this.handleManagerReset)}static withExplicitHandle(e,t,n){const i=new Do(e,t);return i.handle=n,i}get info(){const e=this.descriptor;if((e==null?void 0:e.type)==="active")return e.info}get descriptor(){return this.handle?this.manager.getDescriptor(this.handle):null}publish(e){return k(this,void 0,void 0,function*(){try{this.handle=yield this.manager.publishRequest(this.options,e)}catch(t){throw t}})}isPublished(){var e;return((e=this.descriptor)===null||e===void 0?void 0:e.type)==="active"&&this.descriptor.publishState!=="unpublished"}tryPush(e){if(!this.handle)throw Lr.trackUnpublished();const t=Gg.from(e);try{return this.manager.tryProcessAndSend(this.handle,t)}catch(n){throw n}}flush(){return k(this,void 0,void 0,function*(){if(!this.isFlushed)return this.flushedFuture.promise})}unpublish(){return k(this,void 0,void 0,function*(){if(!this.handle){me.warn('Data track "'.concat(this.options.name,'" is not published, so unpublishing has no effect.'));return}try{yield this.manager.unpublishRequest(this.handle)}catch(e){throw e}})}}class Lo{constructor(e){this.e2eeManager=e.e2eeManager,this.packetizer=new Bu(e.info.pubHandle,Lo.TRANSPORT_MTU_BYTES)}updateE2eeManager(e){this.e2eeManager=e}processFrame(e){return e4(this,arguments,function*(){const n=yield ss(this.encryptIfNeeded(e));try{yield ss(yield*t4(En(this.packetizer.packetize(n))))}catch(i){throw i instanceof Po?ma.packetizer(i):i}})}encryptIfNeeded(e){return k(this,void 0,void 0,function*(){if(!this.e2eeManager)return e;let t;try{t=yield this.e2eeManager.encryptData(e.payload)}catch(n){throw ma.encryption(n)}return e.payload=t.payload,e.extensions.e2ee=new In(t.keyIndex,t.iv),e})}}Lo.TRANSPORT_MTU_BYTES=16e3;const On=Xt(Ct.DataTracks),kh={pending(){return{type:"pending",completionFuture:new Bt}},active(r,e){return{type:"active",info:r,publishState:"published",pipeline:new Lo({info:r,e2eeManager:e}),unpublishingFuture:new Bt}}},CB=1e4;class Cu extends Yt.EventEmitter{constructor(e){var t;super(),this.handleAllocator=new y2,this.descriptors=new Map,this.inFlightPacketCounter=new Map,this.e2eeManager=(t=e==null?void 0:e.e2eeManager)!==null&&t!==void 0?t:null}static withDescriptors(e){const t=new Cu;return t.descriptors=e,t}updateE2eeManager(e){this.e2eeManager=e;for(const t of this.descriptors.values())t.type==="active"&&t.pipeline.updateE2eeManager(e)}getDescriptor(e){var t;return(t=this.descriptors.get(e))!==null&&t!==void 0?t:null}tryProcessAndSend(e,t){return k(this,void 0,void 0,function*(){var n,i,s,a,A;const o=this.getDescriptor(e);if((o==null?void 0:o.type)!=="active"||o.publishState==="unpublished")throw Lr.trackUnpublished();if(o.publishState==="republishing")throw Lr.dropped("Data track republishing");try{try{for(var c=!0,l=En(o.pipeline.processFrame(t)),d;d=yield l.next(),n=d.done,!n;c=!0){a=d.value,c=!1;const u=a,h=(A=this.inFlightPacketCounter.get(e))!==null&&A!==void 0?A:0;this.inFlightPacketCounter.set(e,h+1),h===0&&this.emit("packetsFlushedChange",{handle:e,isFlushed:!1}),this.emit("packetAvailable",{handle:e,bytes:u.toBinary()})}}catch(u){i={error:u}}finally{try{!c&&!n&&(s=l.return)&&(yield s.call(l))}finally{if(i)throw i.error}}}catch(u){throw Lr.dropped(u)}})}handlePacketSendComplete(e){var t;let i=((t=this.inFlightPacketCounter.get(e))!==null&&t!==void 0?t:0)-1;i<0&&(On.warn("OutgoingDataTrackManager.handlePacketSendComplete: inFlightPacketCounter was decremented below 0 (got ".concat(this.inFlightPacketCounter," - resetting to 0. Were more packets send than were emitted?")),i=0),this.inFlightPacketCounter.set(e,i),i===0&&this.emit("packetsFlushedChange",{handle:e,isFlushed:!0})}publishRequest(e,t){return k(this,void 0,void 0,function*(){const n=this.handleAllocator.get();if(!n)throw pt.limitReached();const i=Vg(CB),s=t?Kg([t,i]):i;if(this.descriptors.has(n))throw new Error("Descriptor for handle already exists");const a=kh.pending();this.descriptors.set(n,a);const A=()=>{var o,c;const l=this.descriptors.get(n);if(!l){On.warn("No descriptor for ".concat(n));return}this.descriptors.delete(n),this.emit("sfuUnpublishRequest",{handle:n}),l.type==="pending"&&((c=(o=l.completionFuture).reject)===null||c===void 0||c.call(o,i.aborted?pt.timeout():pt.cancelled()))};return s.aborted?(A(),a.completionFuture.promise.then(()=>n)):(s.addEventListener("abort",A),this.emit("sfuPublishRequest",{handle:n,name:e.name,usesE2ee:this.e2eeManager!==null}),yield a.completionFuture.promise,s.removeEventListener("abort",A),this.emit("trackPublished",{track:Do.withExplicitHandle(e,this,n)}),n)})}queryPublished(){return Array.from(this.descriptors.values()).filter(t=>t.type==="active").map(t=>t.info)}unpublishRequest(e){return k(this,void 0,void 0,function*(){const t=this.descriptors.get(e);if(!t){On.warn("No descriptor for ".concat(e));return}if(t.type!=="active"){On.warn("Track ".concat(e," not active"));return}this.emit("sfuUnpublishRequest",{handle:e}),yield t.unpublishingFuture.promise,this.inFlightPacketCounter.delete(e),this.emit("trackUnpublished",{sid:t.info.sid})})}receivedSfuPublishResponse(e,t){var n,i,s,a;const A=this.descriptors.get(e);if(!A){On.warn("No descriptor for ".concat(e));return}switch(this.descriptors.delete(e),A.type){case"pending":{if(t.type==="ok"){const o=t.data,c=o.usesE2ee?this.e2eeManager:null;this.descriptors.set(o.pubHandle,kh.active(o,c)),(i=(n=A.completionFuture).resolve)===null||i===void 0||i.call(n)}else(a=(s=A.completionFuture).reject)===null||a===void 0||a.call(s,t.error);return}case"active":{if(A.publishState!=="republishing"){On.warn("Track ".concat(e," already active"));return}if(t.type==="error"){On.warn("Republish failed for track ".concat(e));return}On.debug("Track ".concat(e," republished")),A.info.sid=t.data.sid,A.publishState="published",this.descriptors.set(A.info.pubHandle,A)}}}receivedSfuUnpublishResponse(e){var t,n;const i=this.descriptors.get(e);if(!i){On.warn("No descriptor for ".concat(e));return}if(this.descriptors.delete(e),i.type!=="active"){On.warn("Track ".concat(e," not active"));return}i.publishState="unpublished",(n=(t=i.unpublishingFuture).resolve)===null||n===void 0||n.call(t)}sfuWillRepublishTracks(){var e,t;for(const i of this.descriptors.entries()){var n=Ae(i,2);const s=n[0],a=n[1];switch(a.type){case"pending":this.descriptors.delete(s),(t=(e=a.completionFuture).reject)===null||t===void 0||t.call(e,pt.disconnected());break;case"active":a.publishState="republishing",this.emit("sfuPublishRequest",{handle:a.info.pubHandle,name:a.info.name,usesE2ee:a.info.usesE2ee})}}}reset(){return k(this,void 0,void 0,function*(){var e,t,n,i;this.handleAllocator.reset();for(const s of this.descriptors.values())switch(s.type){case"pending":(t=(e=s.completionFuture).reject)===null||t===void 0||t.call(e,pt.disconnected());break;case"active":(i=(n=s.unpublishingFuture).resolve)===null||i===void 0||i.call(n),yield this.unpublishRequest(s.info.pubHandle);break}this.descriptors.clear(),this.inFlightPacketCounter.clear(),this.emit("reset")})}}class Ie extends Error{constructor(e,t,n,i){super(t),this.code=e,this.message=Th(t,Ie.MAX_MESSAGE_BYTES),this.data=n?Th(n,Ie.MAX_DATA_BYTES):void 0,typeof(i==null?void 0:i.cause)<"u"&&(this.cause=i==null?void 0:i.cause)}static fromProto(e){return new Ie(e.code,e.message,e.data)}toProto(){return new ym({code:this.code,message:this.message,data:this.data})}static builtIn(e,t,n){return new Ie(Ie.ErrorCode[e],Ie.ErrorMessage[e],t,n)}}Ie.MAX_MESSAGE_BYTES=256;Ie.MAX_DATA_BYTES=15360;Ie.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404};Ie.ErrorMessage={APPLICATION_ERROR:"Application error in method handler",CONNECTION_TIMEOUT:"Connection timeout",RESPONSE_TIMEOUT:"Response timeout",RECIPIENT_DISCONNECTED:"Recipient disconnected",RESPONSE_PAYLOAD_TOO_LARGE:"Response payload too large",SEND_FAILED:"Failed to send",UNSUPPORTED_METHOD:"Method not supported at destination",RECIPIENT_NOT_FOUND:"Recipient not found",REQUEST_PAYLOAD_TOO_LARGE:"Request payload too large",UNSUPPORTED_SERVER:"RPC not supported by server",UNSUPPORTED_VERSION:"Unsupported RPC version"};const jg=15360,Xg="lk.rpc_request",Jg="lk.rpc_response";var kt;(function(r){r.RPC_REQUEST_ID="lk.rpc_request_id",r.RPC_REQUEST_METHOD="lk.rpc_request_method",r.RPC_REQUEST_RESPONSE_TIMEOUT_MS="lk.rpc_request_response_timeout_ms",r.RPC_REQUEST_VERSION="lk.rpc_request_version"})(kt||(kt={}));const SB=1,Yg=2;function Su(r){return new TextEncoder().encode(r).length}function Th(r,e){if(Su(r)<=e)return r;let t=0,n=r.length;const i=new TextEncoder;for(;t<n;){const s=Math.floor((t+n+1)/2);i.encode(r.slice(0,s)).length<=e?t=s:n=s-1}return r.slice(0,t)}class kB extends Yt.EventEmitter{constructor(e,t,n,i){super(),this.pendingAcks=new Map,this.pendingResponses=new Map,this.log=e,this.outgoingDataStreamManager=t,this.getRemoteParticipantClientProtocol=n,this.getServerVersion=i}performRpc(e){return k(this,arguments,void 0,function(t){var n=this;let i=t.destinationIdentity,s=t.method,a=t.payload,A=t.responseTimeout,o=A===void 0?15e3:A;return function*(){const d=n.getRemoteParticipantClientProtocol(i);if(Su(a)>jg&&d<jA)throw Ie.builtIn("REQUEST_PAYLOAD_TOO_LARGE");const h=n.getServerVersion();if(h&&Jn(h,"1.8.0")<0)throw Ie.builtIn("UNSUPPORTED_SERVER");const p=Math.max(o,8e3),g=crypto.randomUUID(),v=new Bt;let w=null;const B=setTimeout(()=>{var b;n.pendingAcks.delete(g),(b=v.reject)===null||b===void 0||b.call(v,Ie.builtIn("CONNECTION_TIMEOUT")),n.pendingResponses.delete(g),w!==null&&clearTimeout(w)},7e3);n.pendingAcks.set(g,{resolve:()=>{clearTimeout(B)},participantIdentity:i}),n.pendingResponses.set(g,{completionFuture:v,participantIdentity:i}),yield n.publishRpcRequest(i,g,s,a,p,d),w=setTimeout(()=>{var b;n.pendingResponses.delete(g),(b=v.reject)===null||b===void 0||b.call(v,Ie.builtIn("RESPONSE_TIMEOUT"))},o);const E=v.promise.finally(()=>{clearTimeout(w),n.pendingAcks.has(g)&&(n.log.warn("RPC response received before ack",g),n.pendingAcks.delete(g),clearTimeout(B))});return[g,E]}()})}publishRpcRequest(e,t,n,i,s,a){return k(this,void 0,void 0,function*(){if(a>=jA){const A=yield this.outgoingDataStreamManager.streamText({topic:Xg,destinationIdentities:[e],attributes:{[kt.RPC_REQUEST_ID]:t,[kt.RPC_REQUEST_METHOD]:n,[kt.RPC_REQUEST_RESPONSE_TIMEOUT_MS]:"".concat(s),[kt.RPC_REQUEST_VERSION]:"".concat(Yg)}});yield A.write(i),yield A.close();return}this.emit("sendDataPacket",{packet:new Ft({destinationIdentities:[e],kind:Nr.RELIABLE,value:{case:"rpcRequest",value:new Jd({id:t,method:n,payload:i,responseTimeoutMs:s,version:SB})}})})})}handleIncomingDataStream(e,t,n){return k(this,void 0,void 0,function*(){const i=n[kt.RPC_REQUEST_ID];if(!i){this.log.warn("RPC data stream malformed: ".concat(kt.RPC_REQUEST_ID," not set."));return}const s=this.pendingResponses.get(i);if(s&&s.participantIdentity!==t){this.log.warn("RPC response stream for ".concat(i," arrived from unexpected sender ").concat(t,", expected ").concat(s.participantIdentity,". Ignoring."));return}let a;try{a=yield e.readAll()}catch(A){this.log.warn("Error reading RPC response payload: ".concat(A)),this.handleIncomingRpcResponseFailure(i,Ie.builtIn("APPLICATION_ERROR","Error reading RPC response payload",{cause:A}));return}this.handleIncomingRpcResponseSuccess(i,a)})}handleIncomingRpcResponseSuccess(e,t){var n,i;const s=this.pendingResponses.get(e);s?((i=(n=s.completionFuture).resolve)===null||i===void 0||i.call(n,t),this.pendingResponses.delete(e)):this.log.error("Response received for unexpected RPC request",e)}handleIncomingRpcResponseFailure(e,t){var n,i;const s=this.pendingResponses.get(e);s?((i=(n=s.completionFuture).reject)===null||i===void 0||i.call(n,t),this.pendingResponses.delete(e)):this.log.error("Response received for unexpected RPC request",e)}handleIncomingRpcAck(e){const t=this.pendingAcks.get(e);t?(t.resolve(),this.pendingAcks.delete(e)):this.log.error("Ack received for unexpected RPC request: ".concat(e))}handleParticipantDisconnected(e){var t;for(const a of this.pendingAcks){var n=Ae(a,2);const A=n[0];n[1].participantIdentity===e&&this.pendingAcks.delete(A)}for(const a of this.pendingResponses){var i=Ae(a,2);const A=i[0];var s=i[1];const o=s.participantIdentity,c=s.completionFuture;o===e&&((t=c.reject)===null||t===void 0||t.call(c,Ie.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(A))}}}class TB extends Yt.EventEmitter{constructor(e,t,n){super(),this.rpcHandlers=new Map,this.log=e,this.outgoingDataStreamManager=t,this.getRemoteParticipantClientProtocol=n}registerRpcMethod(e,t){if(this.rpcHandlers.has(e))throw Error("RPC handler already registered for method ".concat(e,", unregisterRpcMethod before trying to register again"));this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}handleIncomingRpcRequest(e,t){return k(this,void 0,void 0,function*(){var n;if(this.publishRpcAck(e,t.id),t.version!==1){this.publishRpcResponsePacket(e,t.id,null,Ie.builtIn("UNSUPPORTED_VERSION"));return}const i=this.rpcHandlers.get(t.method);if(!i){this.publishRpcResponsePacket(e,t.id,null,Ie.builtIn("UNSUPPORTED_METHOD"));return}let s;try{s=yield i({requestId:t.id,callerIdentity:e,payload:t.payload,responseTimeout:t.responseTimeoutMs})}catch(a){let A;a instanceof Ie?A=a:(this.log.warn("Uncaught error returned by RPC handler for ".concat(t.method,". Returning APPLICATION_ERROR instead."),a),A=Ie.builtIn("APPLICATION_ERROR","Uncaught error: ".concat((n=a==null?void 0:a.message)!==null&&n!==void 0?n:a),{cause:a})),this.publishRpcResponsePacket(e,t.id,null,A);return}yield this.publishRpcResponse(e,t.id,s??"")})}handleIncomingDataStream(e,t,n){return k(this,void 0,void 0,function*(){const i=n[kt.RPC_REQUEST_ID],s=n[kt.RPC_REQUEST_METHOD],a=parseInt(n[kt.RPC_REQUEST_RESPONSE_TIMEOUT_MS],10),A=parseInt(n[kt.RPC_REQUEST_VERSION],10);if(!i||!s||Number.isNaN(a)||Number.isNaN(A)){this.log.warn("RPC data stream malformed: ".concat(kt.RPC_REQUEST_ID," / ").concat(kt.RPC_REQUEST_METHOD," / ").concat(kt.RPC_REQUEST_RESPONSE_TIMEOUT_MS," / ").concat(kt.RPC_REQUEST_VERSION," not set.")),this.publishRpcResponsePacket(t,i,null,Ie.builtIn("APPLICATION_ERROR","RPC data stream malformed"));return}if(this.publishRpcAck(t,i),A!==Yg){this.publishRpcResponsePacket(t,i,null,Ie.builtIn("UNSUPPORTED_VERSION"));return}let o;try{o=yield e.readAll()}catch(d){this.log.warn("Error reading RPC request payload: ".concat(d)),this.publishRpcResponsePacket(t,i,null,Ie.builtIn("APPLICATION_ERROR","Error reading RPC request payload",{cause:d}));return}const c=this.rpcHandlers.get(s);if(!c){this.publishRpcResponsePacket(t,i,null,Ie.builtIn("UNSUPPORTED_METHOD"));return}let l;try{l=yield c({requestId:i,callerIdentity:t,payload:o,responseTimeout:a})}catch(d){let u;d instanceof Ie?u=d:(this.log.warn("Uncaught error returned by RPC handler for ".concat(s,". Returning APPLICATION_ERROR instead."),d),u=Ie.builtIn("APPLICATION_ERROR")),this.publishRpcResponsePacket(t,i,null,u);return}yield this.publishRpcResponse(t,i,l??"")})}publishRpcAck(e,t){this.emit("sendDataPacket",{packet:new Ft({destinationIdentities:[e],kind:Nr.RELIABLE,value:{case:"rpcAck",value:new To({requestId:t})}})})}publishRpcResponsePacket(e,t,n,i){this.emit("sendDataPacket",{packet:new Ft({destinationIdentities:[e],kind:Nr.RELIABLE,value:{case:"rpcResponse",value:new Yd({requestId:t,value:i?{case:"error",value:i.toProto()}:{case:"payload",value:n??""}})}})})}publishRpcResponse(e,t,n){return k(this,void 0,void 0,function*(){if(this.getRemoteParticipantClientProtocol(e)>=jA){const a=yield this.outgoingDataStreamManager.streamText({topic:Jg,destinationIdentities:[e],attributes:{[kt.RPC_REQUEST_ID]:t}});yield a.write(n),yield a.close();return}if(Su(n)>jg){this.log.warn("RPC Response payload too large for request ".concat(t,". To send larger responses, consider updating the sending client.")),this.publishRpcResponsePacket(e,t,null,Ie.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"));return}this.publishRpcResponsePacket(e,t,n,null)})}}class xB extends Qg{constructor(e,t,n,i,s,a){super(e,t,N.Kind.Audio,n,a),this.monitorReceiver=()=>k(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const A=yield this.getReceiverStats();A&&this.prevStats&&this.receiver&&(this._currentBitrate=Qo(A,this.prevStats)),this.prevStats=A}),this.audioContext=i,this.webAudioPluginNodes=[],s&&(this.sinkId=s.deviceId)}setVolume(e){var t;for(const n of this.attachedElements)this.audioContext?(t=this.gainNode)===null||t===void 0||t.gain.setTargetAtTime(e,0,.1):n.volume=e;Rn()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(Rn())return 1;let e=0;return this.attachedElements.forEach(t=>{t.volume>e&&(e=t.volume)}),e}setSinkId(e){return k(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(t=>{if(Xl(t))return t.setSinkId(e)}))})}attach(e){const t=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&Xl(e)&&e.setSinkId(this.sinkId).catch(n=>{this.log.error("Failed to set sink id on remote audio track",n,this.logContext)}),this.audioContext&&t&&(this.log.debug("using audio context mapping",this.logContext),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),this.elementVolume&&this.setVolume(this.elementVolume),e}detach(e){let t;return e?(t=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(t=super.detach(),this.disconnectWebAudio()),t}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(e,t){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(t.srcObject);let n=this.sourceNode;this.webAudioPluginNodes.forEach(i=>{n.connect(i),n=i}),this.gainNode=e.createGain(),n.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),e.state!=="running"&&e.resume().then(()=>{e.state!=="running"&&this.emit($.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(i=>{this.emit($.AudioPlaybackFailed,i)})}disconnectWebAudio(){var e,t;(e=this.gainNode)===null||e===void 0||e.disconnect(),(t=this.sourceNode)===null||t===void 0||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return k(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t;return e.forEach(n=>{n.type==="inbound-rtp"&&(t={type:"audio",streamId:n.id,timestamp:n.timestamp,jitter:n.jitter,bytesReceived:n.bytesReceived,concealedSamples:n.concealedSamples,concealmentEvents:n.concealmentEvents,silentConcealedSamples:n.silentConcealedSamples,silentConcealmentEvents:n.silentConcealmentEvents,totalAudioEnergy:n.totalAudioEnergy,totalSamplesDuration:n.totalSamplesDuration})}),t})}}class ur extends Yt.EventEmitter{constructor(e,t,n,i){var s;super(),this.metadataMuted=!1,this.encryption=De.NONE,this.log=me,this.handleMuted=()=>{this.emit($.Muted)},this.handleUnmuted=()=>{this.emit($.Unmuted)},this.log=Xt((s=i==null?void 0:i.loggerName)!==null&&s!==void 0?s:Ct.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=t,this.trackName=n,this.source=N.Source.Unknown}setTrack(e){this.track&&(this.track.off($.Muted,this.handleMuted),this.track.off($.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on($.Muted,this.handleMuted),e.on($.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),we(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==De.NONE}get audioTrack(){if($n(this.track))return this.track}get videoTrack(){if(wr(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=N.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===N.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.encryption=e.encryption,this.trackInfo=e,this.log.debug("update publication info",Object.assign(Object.assign({},this.logContext),{info:e}))}}(function(r){(function(e){e.Desired="desired",e.Subscribed="subscribed",e.Unsubscribed="unsubscribed"})(r.SubscriptionStatus||(r.SubscriptionStatus={})),function(e){e.Allowed="allowed",e.NotAllowed="not_allowed"}(r.PermissionStatus||(r.PermissionStatus={}))})(ur||(ur={}));class rd extends ur{get isUpstreamPaused(){var e;return(e=this.track)===null||e===void 0?void 0:e.isUpstreamPaused}constructor(e,t,n,i){super(e,t.sid,t.name,i),this.track=void 0,this.handleTrackEnded=()=>{this.emit($.Ended)},this.handleCpuConstrained=()=>{this.track&&wr(this.track)&&this.emit($.CpuConstrained,this.track)},this.updateInfo(t),this.setTrack(n)}setTrack(e){this.track&&(this.track.off($.Ended,this.handleTrackEnded),this.track.off($.CpuConstrained,this.handleCpuConstrained)),super.setTrack(e),e&&(e.on($.Ended,this.handleTrackEnded),e.on($.CpuConstrained,this.handleCpuConstrained))}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return k(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.mute()})}unmute(){return k(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.unmute()})}pauseUpstream(){return k(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.pauseUpstream()})}resumeUpstream(){return k(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if($n(this.track)){const t=this.track.getSourceTrackSettings(),n=new Set;return t.autoGainControl&&n.add(wt.TF_AUTO_GAIN_CONTROL),t.echoCancellation&&n.add(wt.TF_ECHO_CANCELLATION),t.noiseSuppression&&n.add(wt.TF_NOISE_SUPPRESSION),t.channelCount&&t.channelCount>1&&n.add(wt.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||n.add(wt.TF_NO_DTX),this.track.enhancedNoiseCancellation&&n.add(wt.TF_ENHANCED_NOISE_CANCELLATION),Array.from(n.values())}else return[]}}function Oo(r,e){return k(this,void 0,void 0,function*(){r??(r={});let t=!1;const n=Tg(r),i=n.audioProcessor,s=n.videoProcessor,a=n.optionsWithoutProcessor;let A=a.audio,o=a.video;if(i&&typeof a.audio=="object"&&(a.audio.processor=i),s&&typeof a.video=="object"&&(a.video.processor=s),r.audio&&typeof a.audio=="object"&&typeof a.audio.deviceId=="string"){const u=a.audio.deviceId;a.audio.deviceId={exact:u},t=!0,A=Object.assign(Object.assign({},a.audio),{deviceId:{ideal:u}})}if(a.video&&typeof a.video=="object"&&typeof a.video.deviceId=="string"){const u=a.video.deviceId;a.video.deviceId={exact:u},t=!0,o=Object.assign(Object.assign({},a.video),{deviceId:{ideal:u}})}a.audio===!0?a.audio={deviceId:"default"}:typeof a.audio=="object"&&a.audio!==null&&(a.audio=Object.assign(Object.assign({},a.audio),{deviceId:a.audio.deviceId||"default"})),a.video===!0?a.video={deviceId:"default"}:typeof a.video=="object"&&!a.video.deviceId&&(a.video.deviceId="default");const c=Cg(a,_g,Rg),l=cu(c),d=navigator.mediaDevices.getUserMedia(l);a.audio&&(bt.userMediaPromiseMap.set("audioinput",d),d.catch(()=>bt.userMediaPromiseMap.delete("audioinput"))),a.video&&(bt.userMediaPromiseMap.set("videoinput",d),d.catch(()=>bt.userMediaPromiseMap.delete("videoinput")));try{const u=yield d;return yield Promise.all(u.getTracks().map(h=>k(this,void 0,void 0,function*(){const p=h.kind==="audio";let g;const v=p?l.audio:l.video;typeof v!="boolean"&&(g=v);const w=h.getSettings().deviceId;g!=null&&g.deviceId&&gi(g.deviceId)!==w?g.deviceId=w:g||(g={deviceId:w});const B=K2(h,g,e);return B.kind===N.Kind.Video?B.source=N.Source.Camera:B.kind===N.Kind.Audio&&(B.source=N.Source.Microphone),B.mediaStream=u,$n(B)&&i?yield B.setProcessor(i):wr(B)&&s&&(yield B.setProcessor(s)),B})))}catch(u){if(!t)throw u;return Oo(Object.assign(Object.assign({},r),{audio:A,video:o}),e)}})}function EB(r){return k(this,void 0,void 0,function*(){return(yield Oo({audio:!1,video:!0}))[0]})}function UB(r){return k(this,void 0,void 0,function*(){return(yield Oo({audio:!0,video:!1}))[0]})}var Rr;(function(r){r.Excellent="excellent",r.Good="good",r.Poor="poor",r.Lost="lost",r.Unknown="unknown"})(Rr||(Rr={}));function FB(r){switch(r){case Ms.EXCELLENT:return Rr.Excellent;case Ms.GOOD:return Rr.Good;case Ms.POOR:return Rr.Poor;case Ms.LOST:return Rr.Lost;default:return Rr.Unknown}}class Zg extends Yt.EventEmitter{get logContext(){var e,t;return Object.assign({},(t=(e=this.loggerOptions)===null||e===void 0?void 0:e.loggerContextCb)===null||t===void 0?void 0:t.call(e))}get isEncrypted(){return this.trackPublications.size>0&&Array.from(this.trackPublications.values()).every(e=>e.isEncrypted)}get isAgent(){var e;return((e=this.permissions)===null||e===void 0?void 0:e.agent)||this.kind===Aa.AGENT}get isActive(){var e;return((e=this.participantInfo)===null||e===void 0?void 0:e.state)===Gi.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,t,n,i,s,a){let A=arguments.length>6&&arguments[6]!==void 0?arguments[6]:Aa.STANDARD;var o;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=Rr.Unknown,this.log=me,this.loggerOptions=a,this.log=Xt((o=a==null?void 0:a.loggerName)!==null&&o!==void 0?o:Ct.Participant,()=>this.logContext),this.setMaxListeners(100),this.sid=e,this.identity=t,this.name=n,this.metadata=i,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=A,this._attributes=s??{}}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(e){for(const n of this.trackPublications){var t=Ae(n,2);const i=t[1];if(i.source===e)return i}}getTrackPublicationByName(e){for(const n of this.trackPublications){var t=Ae(n,2);const i=t[1];if(i.trackName===e)return i}}waitUntilActive(){return this.isActive?Promise.resolve():this.activeFuture?this.activeFuture.promise:(this.activeFuture=new Bt,this.once(X.Active,()=>{var e,t;(t=(e=this.activeFuture)===null||e===void 0?void 0:e.resolve)===null||t===void 0||t.call(e),this.activeFuture=void 0}),this.activeFuture.promise)}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const t=this.getTrackPublication(N.Source.Camera);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const t=this.getTrackPublication(N.Source.Microphone);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(N.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(Number.parseInt(this.participantInfo.joinedAt.toString())*1e3):new Date}updateInfo(e){var t;return this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version?!1:(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.state===Gi.ACTIVE&&((t=this.participantInfo)===null||t===void 0?void 0:t.state)!==Gi.ACTIVE&&this.emit(X.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){const t=this.metadata!==e,n=this.metadata;this.metadata=e,t&&this.emit(X.ParticipantMetadataChanged,n)}_setName(e){const t=this.name!==e;this.name=e,t&&this.emit(X.ParticipantNameChanged,e)}_setAttributes(e){const t=E4(this.attributes,e);this._attributes=e,Object.keys(t).length>0&&this.emit(X.AttributesChanged,t)}setPermissions(e){var t,n,i,s,a,A;const o=this.permissions,c=e.canPublish!==((t=this.permissions)===null||t===void 0?void 0:t.canPublish)||e.canSubscribe!==((n=this.permissions)===null||n===void 0?void 0:n.canSubscribe)||e.canPublishData!==((i=this.permissions)===null||i===void 0?void 0:i.canPublishData)||e.hidden!==((s=this.permissions)===null||s===void 0?void 0:s.hidden)||e.recorder!==((a=this.permissions)===null||a===void 0?void 0:a.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((l,d)=>{var u;return l!==((u=this.permissions)===null||u===void 0?void 0:u.canPublishSources[d])})||e.canSubscribeMetrics!==((A=this.permissions)===null||A===void 0?void 0:A.canSubscribeMetrics);return this.permissions=e,c&&this.emit(X.ParticipantPermissionsChanged,o),c}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(X.IsSpeakingChanged,e))}setConnectionQuality(e){const t=this._connectionQuality;this._connectionQuality=FB(e),t!==this._connectionQuality&&this.emit(X.ConnectionQualityChanged,this._connectionQuality)}setDisconnected(){var e,t;this.activeFuture&&((t=(e=this.activeFuture).reject)===null||t===void 0||t.call(e,new Error("Participant disconnected")),this.activeFuture=void 0)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(t=>$n(t.track)&&t.track.setAudioContext(e))}addTrackPublication(e){e.on($.Muted,()=>{this.emit(X.TrackMuted,e)}),e.on($.Unmuted,()=>{this.emit(X.TrackUnmuted,e)});const t=e;switch(t.track&&(t.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case N.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case N.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function IB(r){var e,t,n;if(!r.participantSid&&!r.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new Pm({participantIdentity:(e=r.participantIdentity)!==null&&e!==void 0?e:"",participantSid:(t=r.participantSid)!==null&&t!==void 0?t:"",allTracks:(n=r.allowAll)!==null&&n!==void 0?n:!1,trackSids:r.allowedTrackSids||[]})}class QB extends Zg{constructor(e,t,n,i,s,a,A,o){super(e,t,void 0,void 0,void 0,{loggerName:i.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=De.NONE,this.e2eeStateMutex=new xt,this.enabledPublishVideoCodecs=[],this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Bt)},this.handleReconnected=()=>{var c,l;(l=(c=this.reconnectFuture)===null||c===void 0?void 0:c.resolve)===null||l===void 0||l.call(c),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleClosing=()=>{var c,l,d,u,h,p;this.reconnectFuture&&(this.reconnectFuture.promise.catch(g=>this.log.warn(g.message)),(l=(c=this.reconnectFuture)===null||c===void 0?void 0:c.reject)===null||l===void 0||l.call(c,new Error("Got disconnected during reconnection attempt")),this.reconnectFuture=void 0),this.signalConnectedFuture&&((u=(d=this.signalConnectedFuture).reject)===null||u===void 0||u.call(d,new Error("Got disconnected without signal connected")),this.signalConnectedFuture=void 0),(p=(h=this.activeAgentFuture)===null||h===void 0?void 0:h.reject)===null||p===void 0||p.call(h,new Error("Got disconnected without active agent present")),this.activeAgentFuture=void 0,this.firstActiveAgent=void 0},this.handleSignalConnected=c=>{var l,d;c.participant&&this.updateInfo(c.participant),this.signalConnectedFuture||(this.signalConnectedFuture=new Bt),(d=(l=this.signalConnectedFuture).resolve)===null||d===void 0||d.call(l)},this.handleSignalRequestResponse=c=>{const l=c.requestId,d=c.reason,u=c.message,h=this.pendingSignalRequests.get(l);switch(h&&(d!==Ai.OK&&h.reject(new D0(u,d)),this.pendingSignalRequests.delete(l)),c.request.case){case"publishDataTrack":{let p;switch(c.reason){case Ai.NOT_ALLOWED:p=pt.notAllowed(c.message);break;case Ai.DUPLICATE_NAME:p=pt.duplicateName(c.message);break;case Ai.INVALID_NAME:p=pt.invalidName(c.message);break;case Ai.LIMIT_EXCEEDED:p=pt.limitReached(c.message);break;default:p=pt.unknown(c.reason,c.message);break}this.roomOutgoingDataTrackManager.receivedSfuPublishResponse(c.request.value.pubHandle,{type:"error",error:p});break}}},this.updateTrackSubscriptionPermissions=()=>{this.log.debug("updating track subscription permissions",{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions}),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map(c=>IB(c)))},this.onTrackUnmuted=c=>{this.onTrackMuted(c,c.isUpstreamPaused)},this.onTrackMuted=(c,l)=>{if(l===void 0&&(l=!0),!c.sid){this.log.error("could not update mute status for unpublished track",we(c));return}this.engine.updateMuteStatus(c.sid,l)},this.onTrackUpstreamPaused=c=>{this.log.debug("upstream paused",we(c)),this.onTrackMuted(c,!0)},this.onTrackUpstreamResumed=c=>{this.log.debug("upstream resumed",we(c)),this.onTrackMuted(c,c.isMuted)},this.onTrackFeatureUpdate=c=>{const l=this.audioTrackPublications.get(c.sid);if(!l){this.log.warn("Could not update local audio track settings, missing publication for track ".concat(c.sid));return}this.engine.client.sendUpdateLocalAudioTrack(l.trackSid,l.getTrackFeatures())},this.onTrackCpuConstrained=(c,l)=>{this.log.debug("track cpu constrained",we(l)),this.emit(X.LocalTrackCpuConstrained,c,l)},this.handleSubscribedQualityUpdate=c=>k(this,void 0,void 0,function*(){var l,d,u,h,p;if(!(!((p=this.roomOptions)===null||p===void 0)&&p.dynacast))return;const g=this.videoTrackPublications.get(c.trackSid);if(!g){this.log.warn("received subscribed quality update for unknown track",{trackSid:c.trackSid});return}if(!g.videoTrack)return;const v=yield g.videoTrack.setPublishingCodecs(c.subscribedCodecs);try{for(var w=!0,B=En(v),E;E=yield B.next(),l=E.done,!l;w=!0){h=E.value,w=!1;const b=h;C4(b)&&(this.log.debug("publish ".concat(b," for ").concat(g.videoTrack.sid),we(g)),yield this.publishAdditionalCodecForTrack(g.videoTrack,b,g.options))}}catch(b){d={error:b}}finally{try{!w&&!l&&(u=B.return)&&(yield u.call(B))}finally{if(d)throw d.error}}}),this.handleLocalTrackUnpublished=c=>{const l=this.trackPublications.get(c.trackSid);if(!l){this.log.warn("received unpublished event for unknown track",{trackSid:c.trackSid});return}this.unpublishTrack(l.track)},this.handleTrackEnded=c=>k(this,void 0,void 0,function*(){if(c.source===N.Source.ScreenShare||c.source===N.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",we(c)),this.unpublishTrack(c);else if(c.isUserProvided)yield c.mute();else if(or(c)||Ln(c))try{if($t())try{const l=yield navigator==null?void 0:navigator.permissions.query({name:c.source===N.Source.Camera?"camera":"microphone"});if(l&&l.state==="denied")throw this.log.warn("user has revoked access to ".concat(c.source),we(c)),l.onchange=()=>{l.state!=="denied"&&(c.isMuted||c.restartTrack(),l.onchange=null)},new Error("GetUserMedia Permission denied")}catch{}c.isMuted||(this.log.debug("track ended, attempting to use a different device",we(c)),or(c)?yield c.restartTrack({deviceId:"default"}):yield c.restartTrack())}catch{this.log.warn("could not restart track, muting instead",we(c)),yield c.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=n,this.roomOptions=i,this.setupEngine(n),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.roomOutgoingDataStreamManager=s,this.roomOutgoingDataTrackManager=a,this.rpcClientManager=A,this.rpcServerManager=o}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==De.NONE}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setupEngine(e){var t;this.engine=e,this.engine.on(G.RemoteMute,(n,i)=>{const s=this.trackPublications.get(n);!s||!s.track||(i?s.mute():s.unmute())}),!((t=this.signalConnectedFuture)===null||t===void 0)&&t.isResolved&&(this.signalConnectedFuture=void 0),this.engine.on(G.Connected,this.handleReconnected).on(G.SignalConnected,this.handleSignalConnected).on(G.SignalRestarted,this.handleReconnected).on(G.SignalResumed,this.handleReconnected).on(G.Restarting,this.handleReconnecting).on(G.Resuming,this.handleReconnecting).on(G.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(G.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(G.Closing,this.handleClosing).on(G.SignalRequestResponse,this.handleSignalRequestResponse)}setMetadata(e){return k(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return k(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return k(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return k(this,arguments,void 0,function(t){var n=this;let i=t.metadata,s=t.name,a=t.attributes;return function*(){return new Lt((A,o)=>k(n,void 0,void 0,function*(){var c,l;try{let d=!1;const u=yield this.engine.client.sendUpdateLocalMetadata((c=i??this.metadata)!==null&&c!==void 0?c:"",(l=s??this.name)!==null&&l!==void 0?l:"",a),h=performance.now();for(this.pendingSignalRequests.set(u,{resolve:A,reject:p=>{o(p),d=!0},values:{name:s,metadata:i,attributes:a}});performance.now()-h<5e3&&!d;){if((!s||this.name===s)&&(!i||this.metadata===i)&&(!a||Object.entries(a).every(p=>{let g=Ae(p,2),v=g[0],w=g[1];return this.attributes[v]===w||w===""&&!this.attributes[v]}))){this.pendingSignalRequests.delete(u),A();return}yield Qt(50)}o(new D0("Request to update local metadata timed out","TimeoutError"))}catch(d){d instanceof Error?o(d):o(new Error(String(d)))}}))}()})}setCameraEnabled(e,t,n){return this.setTrackEnabled(N.Source.Camera,e,t,n)}setMicrophoneEnabled(e,t,n){return this.setTrackEnabled(N.Source.Microphone,e,t,n)}setScreenShareEnabled(e,t,n){return this.setTrackEnabled(N.Source.ScreenShare,e,t,n)}setE2EEEnabled(e){return k(this,void 0,void 0,function*(){const t=yield this.e2eeStateMutex.lock();try{if(this.encryptionType=e?De.GCM:De.NONE,yield Promise.all(this.pendingPublishPromises.values()),this.trackPublications.size===0||Array.from(this.trackPublications.values()).every(n=>n.isEncrypted===e))return;yield this.republishAllTracks(void 0,!1)}finally{t()}})}setTrackEnabled(e,t,n,i){return k(this,void 0,void 0,function*(){var s,a;this.log.debug("setTrackEnabled",{source:e,enabled:t}),this.republishPromise&&(yield this.republishPromise);let A=this.getTrackPublication(e);if(t)if(A)yield A.unmute();else{let d;if(this.pendingPublishing.has(e)){const u=yield this.waitForPendingPublicationOfSource(e);return u||this.log.info("waiting for pending publication promise timed out",{source:e}),yield u==null?void 0:u.unmute(),u}this.pendingPublishing.add(e);try{switch(e){case N.Source.Camera:d=yield this.createTracks({video:(s=n)!==null&&s!==void 0?s:!0});break;case N.Source.Microphone:d=yield this.createTracks({audio:(a=n)!==null&&a!==void 0?a:!0});break;case N.Source.ScreenShare:d=yield this.createScreenTracks(Object.assign({},n));break;default:throw new mr(e)}}catch(u){throw d==null||d.forEach(h=>{h.stop()}),u instanceof Error&&this.emit(X.MediaDevicesError,u,Wl(e)),this.pendingPublishing.delete(e),u}for(const u of d){const h=Object.assign(Object.assign({},this.roomOptions.publishDefaults),n);e===N.Source.Microphone&&$n(u)&&h.preConnectBuffer&&(this.log.info("starting preconnect buffer for microphone"),u.startPreConnectBuffer())}try{const u=[];for(const p of d)this.log.info("publishing track",we(p)),u.push(this.publishTrack(p,i));const h=yield Promise.all(u);var o=Ae(h,1);A=o[0]}catch(u){throw d==null||d.forEach(h=>{h.stop()}),u}finally{this.pendingPublishing.delete(e)}}else if(!(A!=null&&A.track)&&this.pendingPublishing.has(e)&&(A=yield this.waitForPendingPublicationOfSource(e),A||this.log.info("waiting for pending publication promise timed out",{source:e})),A&&A.track)if(e===N.Source.ScreenShare){const d=[this.unpublishTrack(A.track)],u=this.getTrackPublication(N.Source.ScreenShareAudio);u&&u.track&&d.push(this.unpublishTrack(u.track));var c=yield Promise.all(d),l=Ae(c,1);A=l[0]}else yield A.mute();return A})}enableCameraAndMicrophone(){return k(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(N.Source.Camera)||this.pendingPublishing.has(N.Source.Microphone))){this.pendingPublishing.add(N.Source.Camera),this.pendingPublishing.add(N.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(t=>this.publishTrack(t)))}finally{this.pendingPublishing.delete(N.Source.Camera),this.pendingPublishing.delete(N.Source.Microphone)}}})}createTracks(e){return k(this,void 0,void 0,function*(){var t,n;e??(e={});const i=Cg(e,(t=this.roomOptions)===null||t===void 0?void 0:t.audioCaptureDefaults,(n=this.roomOptions)===null||n===void 0?void 0:n.videoCaptureDefaults);try{return(yield Oo(i,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(A=>($n(A)&&(this.microphoneError=void 0,A.setAudioContext(this.audioContext),A.source=N.Source.Microphone,this.emit(X.AudioStreamAcquired)),wr(A)&&(this.cameraError=void 0,A.source=N.Source.Camera),A))}catch(s){throw s instanceof Error&&(e.audio&&(this.microphoneError=s),e.video&&(this.cameraError=s)),s}})}createScreenTracks(e){return k(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new Au("getDisplayMedia not supported");e.resolution===void 0&&!L4()&&(e.resolution=ou.h1080fps30.resolution);const t=k4(e),n=yield navigator.mediaDevices.getDisplayMedia(t),i=n.getVideoTracks();if(i.length===0)throw new mr("no video track found");const s=new to(i[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});s.source=N.Source.ScreenShare,e.contentHint&&(s.mediaStreamTrack.contentHint=e.contentHint);const a=[s];if(n.getAudioTracks().length>0){this.emit(X.AudioStreamAcquired);const A=new ZA(n.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});A.source=N.Source.ScreenShareAudio,a.push(A)}return a})}publishTrack(e,t){return k(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,t)})}waitForNextEngineRestart(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:15e3;return new Promise((t,n)=>{const i=()=>{clearTimeout(A),this.engine.off(G.Restarted,s),this.engine.off(G.Closing,a)},s=()=>{i(),t()},a=()=>{i(),n(new Error("engine closed before restart completed"))},A=setTimeout(()=>{i(),n(new Error("timed out waiting for engine restart"))},e);this.engine.once(G.Restarted,s),this.engine.once(G.Closing,a)})}publishOrRepublishTrack(e,t){return k(this,arguments,void 0,function(n,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,A=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;return function*(){var o,c,l,d;or(n)&&n.setAudioContext(s.audioContext),yield(o=s.reconnectFuture)===null||o===void 0?void 0:o.promise,s.republishPromise&&!a&&(yield s.republishPromise),ji(n)&&s.pendingPublishPromises.has(n)&&(yield s.pendingPublishPromises.get(n));let u;if(n instanceof MediaStreamTrack)u=n.getConstraints();else{u=n.constraints;let B;switch(n.source){case N.Source.Microphone:B="audioinput";break;case N.Source.Camera:B="videoinput"}B&&s.activeDeviceMap.has(B)&&(u=Object.assign(Object.assign({},u),{deviceId:s.activeDeviceMap.get(B)}))}if(n instanceof MediaStreamTrack)switch(n.kind){case"audio":n=new ZA(n,u,!0,s.audioContext,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;case"video":n=new to(n,u,!0,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;default:throw new mr("unsupported MediaStreamTrack kind ".concat(n.kind))}else n.updateLoggerOptions({loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});let h;if(s.trackPublications.forEach(B=>{B.track&&B.track===n&&(h=B)}),h)return s.log.warn("track has already been published, skipping",we(h)),h;const p=Object.assign(Object.assign({},s.roomOptions.publishDefaults),i),g="channelCount"in n.mediaStreamTrack.getSettings()&&n.mediaStreamTrack.getSettings().channelCount===2||n.mediaStreamTrack.getConstraints().channelCount===2,v=(c=p.forceStereo)!==null&&c!==void 0?c:g;v&&(p.dtx===void 0&&s.log.debug("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",we(n)),p.red===void 0&&s.log.debug("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(l=p.dtx)!==null&&l!==void 0||(p.dtx=!1),(d=p.red)!==null&&d!==void 0||(p.red=!1)),!H4()&&s.roomOptions.e2ee&&(s.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2"),p.simulcast=!1),p.source&&(n.source=p.source);const w=new Promise((B,E)=>k(s,void 0,void 0,function*(){try{if(this.engine.client.currentState!==Re.CONNECTED){this.log.debug("deferring track publication until signal is connected",{track:we(n)});let b=!1;const C=setTimeout(()=>{b=!0,n.stop(),E(new P0("publishing rejected as engine not connected within timeout",408))},15e3);if(yield this.waitUntilEngineConnected(),clearTimeout(C),b)return;const T=yield this.publish(n,p,v);B(T)}else try{const b=yield this.publish(n,p,v);B(b)}catch(b){E(b)}}catch(b){E(b)}}));s.pendingPublishPromises.set(n,w);try{return yield w}catch(B){if(!A&&B instanceof mi)return s.log.warn("negotiation due to track publish failed, retrying after reconnect",{error:B}),s.pendingPublishPromises.delete(n),yield s.waitForNextEngineRestart(),yield s.publishOrRepublishTrack(n,i,a,!0);throw B}finally{s.pendingPublishPromises.delete(n)}}()})}waitUntilEngineConnected(){return this.signalConnectedFuture||(this.signalConnectedFuture=new Bt),this.signalConnectedFuture.promise}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",we(e)),!1;const t=this.permissions,n=t.canPublish,i=t.canPublishSources;return n&&(i.length===0||i.map(s=>U4(s)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",we(e)),!1)}publish(e,t,n){return k(this,void 0,void 0,function*(){var i,s,a,A,o,c,l,d,u,h;if(!this.hasPermissionsToPublish(e))throw new P0("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(D=>ji(e)&&D.source===e.source)&&e.source!==N.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),we(e)),t.stopMicTrackOnMute&&$n(e)&&(e.stopOnMute=!0),e.source===N.Source.ScreenShare&&Ci()&&(t.simulcast=!1),t.videoCodec==="av1"&&!_4()&&(t.videoCodec=void 0),t.videoCodec==="vp9"&&!R4()&&(t.videoCodec=void 0),t.videoCodec===void 0&&(t.videoCodec=ed),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(D=>t.videoCodec===Ws(D.mime))||(t.videoCodec=Ws(this.enabledPublishVideoCodecs[0].mime)));const g=t.videoCodec;e.on($.Muted,this.onTrackMuted),e.on($.Unmuted,this.onTrackUnmuted),e.on($.Ended,this.handleTrackEnded),e.on($.UpstreamPaused,this.onTrackUpstreamPaused),e.on($.UpstreamResumed,this.onTrackUpstreamResumed),e.on($.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const v=[],w=!(!((i=t.dtx)!==null&&i!==void 0)||i),B=e.getSourceTrackSettings();B.autoGainControl&&v.push(wt.TF_AUTO_GAIN_CONTROL),B.echoCancellation&&v.push(wt.TF_ECHO_CANCELLATION),B.noiseSuppression&&v.push(wt.TF_NOISE_SUPPRESSION),B.channelCount&&B.channelCount>1&&v.push(wt.TF_STEREO),w&&v.push(wt.TF_NO_DTX),or(e)&&e.hasPreConnectBuffer&&v.push(wt.TF_PRECONNECT_BUFFER);const E=this.normalizeRequestedFrameMetadataOptions(e,t),b=new oa({cid:e.mediaStreamTrack.id,name:t.name,type:N.kindToProto(e.kind),muted:e.isMuted,source:N.sourceToProto(e.source),disableDtx:w,encryption:this.encryptionType,stereo:n,disableRed:this.isE2EEEnabled||!(!((s=t.red)!==null&&s!==void 0)||s),stream:t==null?void 0:t.stream,backupCodecPolicy:t==null?void 0:t.backupCodecPolicy,audioFeatures:v,packetTrailerFeatures:E});let C;if(e.kind===N.Kind.Video){let D;try{D=yield e.waitForDimensions()}catch{const H=(A=(a=this.roomOptions.videoCaptureDefaults)===null||a===void 0?void 0:a.resolution)!==null&&A!==void 0?A:ca.h720.resolution;D={width:H.width,height:H.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign({},we(e)),{dims:D}))}b.width=D.width,b.height=D.height,Ln(e)&&(Un(g)&&(e.source===N.Source.ScreenShare&&(t.scalabilityMode="L1T3","contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint="motion",this.log.debug("forcing contentHint to motion for screenshare with SVC codecs",we(e)))),t.scalabilityMode=(o=t.scalabilityMode)!==null&&o!==void 0?o:"L3T3_KEY"),b.simulcastCodecs=[new _l({codec:g,cid:e.mediaStreamTrack.id})],t.backupCodec===!0&&(t.backupCodec={codec:ed}),t.backupCodec&&g!==t.backupCodec.codec&&b.encryption===De.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),b.simulcastCodecs.push(new _l({codec:t.backupCodec.codec,cid:""})))),C=eo(e.source===N.Source.ScreenShare,b.width,b.height,t),b.layers=oh(b.width,b.height,C,Un(t.videoCodec))}else e.kind===N.Kind.Audio&&(C=[{maxBitrate:(c=t.audioPreset)===null||c===void 0?void 0:c.maxBitrate,priority:(d=(l=t.audioPreset)===null||l===void 0?void 0:l.priority)!==null&&d!==void 0?d:"high",networkPriority:(h=(u=t.audioPreset)===null||u===void 0?void 0:u.priority)!==null&&h!==void 0?h:"high"}]);if(!this.engine||this.engine.isClosed)throw new Xe("cannot publish track when not connected");const T=()=>k(this,void 0,void 0,function*(){var D,O,H;if(!this.engine.pcManager)throw new Xe("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,t,C),Ln(e)&&(e.publishOptions=t),this.emit(X.LocalSenderCreated,e.sender,e),Ln(e)&&((D=t.degradationPreference)!==null&&D!==void 0||(t.degradationPreference=J2(e)),e.setDegradationPreference(t.degradationPreference)),C)if(Ci()&&e.kind===N.Kind.Audio){let se;for(const ie of this.engine.pcManager.publisher.getTransceivers())if(ie.sender===e.sender){se=ie;break}se&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:se,codec:"opus",maxbr:!((O=C[0])===null||O===void 0)&&O.maxBitrate?C[0].maxBitrate/1e3:0})}else e.codec&&Un(e.codec)&&(!((H=C[0])===null||H===void 0)&&H.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:b.cid,codec:e.codec,maxbr:C[0].maxBitrate/1e3});yield this.engine.negotiate()});let F;const R=new Promise((D,O)=>k(this,void 0,void 0,function*(){var H;try{F=yield this.engine.addTrack(b),D(F)}catch(se){if(e.sender&&(!((H=this.engine.pcManager)===null||H===void 0)&&H.publisher)){try{this.engine.pcManager.publisher.removeTrack(e.sender)}catch(ie){this.log.error(ie)}yield this.engine.negotiate().catch(ie=>{this.log.error("failed to negotiate after removing track due to failed add track request",Object.assign(Object.assign({},we(e)),{error:ie}))})}O(se)}}));if(this.enabledPublishVideoCodecs.length>0&&E.length===0)F=(yield Promise.all([R,T()]))[0];else{F=yield R;let D;if(F.codecs.forEach(O=>{D===void 0&&(D=O.mimeType)}),D&&e.kind===N.Kind.Video){const O=Ws(D);O!==g&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign({},we(e)),{codec:O})),t.videoCodec=O,C=eo(e.source===N.Source.ScreenShare,b.width,b.height,t))}yield T()}const M=new rd(e.kind,F,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(M.on($.CpuConstrained,D=>this.onTrackCpuConstrained(D,M)),M.options=t,e.sid=F.sid,Ln(e)&&(e.publishOptions=t,b.width&&b.height&&(e.lastEncodedDimensions={width:b.width,height:b.height})),this.log.debug("publishing ".concat(e.kind," with encodings"),{encodings:C,trackInfo:F}),Ln(e)?e.startMonitor(this.engine.client):or(e)&&e.startMonitor(),this.addTrackPublication(M),this.emit(X.LocalTrackPublished,M),or(e)&&F.audioFeatures.includes(wt.TF_PRECONNECT_BUFFER)){const D=e.getPreConnectBuffer(),O=e.getPreConnectBufferMimeType();this.on(X.LocalTrackSubscribed,H=>{if(H.trackSid===F.sid){if(!e.hasPreConnectBuffer){this.log.warn("subscribe event came to late, buffer already closed");return}this.log.debug("finished recording preconnect buffer",we(e)),e.stopPreConnectBuffer()}}),D&&new Promise((se,ie)=>k(this,void 0,void 0,function*(){var Z,ee,ue,Ce,Ue,Ge;try{this.log.debug("waiting for agent",we(e));const $e=setTimeout(()=>{ie(new Error("agent not active within 10 seconds"))},1e4),en=yield this.waitUntilActiveAgentPresent();clearTimeout($e),this.log.debug("sending preconnect buffer",we(e));const Mt=yield this.streamBytes({name:"preconnect-buffer",mimeType:O,topic:"lk.agent.pre-connect-audio-buffer",destinationIdentities:[en.identity],attributes:{trackId:M.trackSid,sampleRate:String((Ue=B.sampleRate)!==null&&Ue!==void 0?Ue:"48000"),channels:String((Ge=B.channelCount)!==null&&Ge!==void 0?Ge:"1")}});try{for(var qe=!0,We=En(D),gt;gt=yield We.next(),Z=gt.done,!Z;qe=!0){Ce=gt.value,qe=!1;const vt=Ce;yield Mt.write(vt)}}catch(vt){ee={error:vt}}finally{try{!qe&&!Z&&(ue=We.return)&&(yield ue.call(We))}finally{if(ee)throw ee.error}}yield Mt.close(),se()}catch($e){ie($e)}})).then(()=>{this.log.debug("preconnect buffer sent successfully",we(e))}).catch(se=>{this.log.error("error sending preconnect buffer",Object.assign(Object.assign({},we(e)),{error:se}))})}return M})}canPublishFrameMetadata(){var e;return!!(this.roomOptions.e2ee||this.roomOptions.encryption||ha((e=this.roomOptions.frameMetadata)!==null&&e!==void 0?e:this.roomOptions.packetTrailer))}normalizeRequestedFrameMetadataOptions(e,t){var n;const i=(n=t.frameMetadata)!==null&&n!==void 0?n:t.packetTrailer;if(e.kind!==N.Kind.Video||!JA(i))return t.frameMetadata=void 0,t.packetTrailer=void 0,[];if(!this.canPublishFrameMetadata())return this.log.warn("frame metadata transform not supported; not advertising features",Object.assign(Object.assign({},this.logContext),we(e))),t.frameMetadata=void 0,t.packetTrailer=void 0,[];const s=c2(i),a=l2(s);return t.frameMetadata=a,t.packetTrailer=a,s}get isLocal(){return!0}publishAdditionalCodecForTrack(e,t,n){return k(this,void 0,void 0,function*(){var i;if(this.encryptionType!==De.NONE)return;let s;if(this.trackPublications.forEach(p=>{p.track&&p.track===e&&(s=p)}),!s)throw new mr("track is not published");if(!Ln(e))throw new mr("track is not a video track");const a=Object.assign(Object.assign({},(i=this.roomOptions)===null||i===void 0?void 0:i.publishDefaults),n),A=Dg(e,t,a);if(!A){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",we(e));return}const o=e.addSimulcastTrack(t,A);if(!o)return;const c=this.normalizeRequestedFrameMetadataOptions(e,a),l=new oa({cid:o.mediaStreamTrack.id,type:N.kindToProto(e.kind),muted:e.isMuted,source:N.sourceToProto(e.source),sid:e.sid,packetTrailerFeatures:c,simulcastCodecs:[{codec:a.videoCodec,cid:o.mediaStreamTrack.id}]});if(l.layers=oh(l.width,l.height,A),!this.engine||this.engine.isClosed)throw new Xe("cannot publish track when not connected");const d=()=>k(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,o,a,A),yield this.engine.negotiate()}),h=(yield Promise.all([this.engine.addTrack(l),d()]))[0];this.log.debug("published ".concat(t," for track ").concat(e.sid),{encodings:A,trackInfo:h})})}unpublishTrack(e,t){return k(this,void 0,void 0,function*(){var n,i;if(ji(e)){const l=this.pendingPublishPromises.get(e);l&&(this.log.debug("awaiting publish promise before attempting to unpublish",we(e)),yield l)}const s=this.getPublicationForTrack(e),a=s?we(s):void 0;if(this.log.info("unpublishing track",a),!s||!s.track){this.log.warn("track was not unpublished because no publication was found",a);return}e=s.track,e.off($.Muted,this.onTrackMuted),e.off($.Unmuted,this.onTrackUnmuted),e.off($.Ended,this.handleTrackEnded),e.off($.UpstreamPaused,this.onTrackUpstreamPaused),e.off($.UpstreamResumed,this.onTrackUpstreamResumed),e.off($.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),t===void 0&&(t=(i=(n=this.roomOptions)===null||n===void 0?void 0:n.stopLocalTrackOnUnpublish)!==null&&i!==void 0?i:!0),t?e.stop():e.stopMonitor();let A=!1;const o=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<Je.FAILED&&o)try{for(const l of this.engine.pcManager.publisher.getTransceivers())l.sender===o&&(l.direction="inactive",A=!0);try{A=this.engine.removeTrack(o)}catch(l){this.log.warn(l),A=!0}if(Ln(e)){for(const l of e.simulcastCodecs){var c=Ae(l,2);const d=c[1];if(d.sender){try{A=this.engine.removeTrack(d.sender)}catch(u){this.log.warn(u),A=!0}d.sender=void 0}}e.simulcastCodecs.clear()}}catch(l){this.log.warn("failed to unpublish track",Object.assign(Object.assign({},a),{error:l}))}switch(this.trackPublications.delete(s.trackSid),s.kind){case N.Kind.Audio:this.audioTrackPublications.delete(s.trackSid);break;case N.Kind.Video:this.videoTrackPublications.delete(s.trackSid);break}return this.emit(X.LocalTrackUnpublished,s),s.setTrack(void 0),A&&(yield this.engine.negotiate()),s})}unpublishTracks(e){return k(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>this.unpublishTrack(n)))).filter(n=>!!n)})}republishAllTracks(e){return k(this,arguments,void 0,function(t){var n=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){n.republishPromise&&(yield n.republishPromise),n.republishPromise=new Lt((s,a)=>k(n,void 0,void 0,function*(){try{const A=[];this.trackPublications.forEach(o=>{o.track&&(t&&(o.options=Object.assign(Object.assign({},o.options),t)),A.push(o))}),yield Promise.all(A.map(o=>k(this,void 0,void 0,function*(){const c=o.track;yield this.unpublishTrack(c,!1),i&&!c.isMuted&&c.source!==N.Source.ScreenShare&&c.source!==N.Source.ScreenShareAudio&&(or(c)||Ln(c))&&!c.isUserProvided&&(this.log.debug("restarting existing track",{track:o.trackSid}),yield c.restartTrack()),yield this.publishOrRepublishTrack(c,o.options,!0)}))),s()}catch(A){A instanceof Error?a(A):a(new Error(String(A)))}finally{this.republishPromise=void 0}})),yield n.republishPromise}()})}publishData(e){return k(this,arguments,void 0,function(t){var n=this;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){const s=i.reliable?ge.RELIABLE:ge.LOSSY,a=i.reliable?Nr.RELIABLE:Nr.LOSSY,A=i.destinationIdentities,o=i.topic;let c=new Xd({participantIdentity:n.identity,payload:t,destinationIdentities:A,topic:o});const l=new Ft({kind:a,value:{case:"user",value:c}});yield n.engine.sendDataPacket(l,s)}()})}publishDtmf(e,t){return k(this,void 0,void 0,function*(){const n=new Ft({kind:Nr.RELIABLE,value:{case:"sipDtmf",value:new vm({code:e,digit:t})}});yield this.engine.sendDataPacket(n,ge.RELIABLE)})}sendChatMessage(e,t){return k(this,void 0,void 0,function*(){const n={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:t==null?void 0:t.attachments},i=new Ft({value:{case:"chatMessage",value:new GA(Object.assign(Object.assign({},n),{timestamp:Ke.parse(n.timestamp)}))}});return yield this.engine.sendDataPacket(i,ge.RELIABLE),this.emit(X.ChatMessage,n),n})}editChatMessage(e,t){return k(this,void 0,void 0,function*(){const n=Object.assign(Object.assign({},t),{message:e,editTimestamp:Date.now()}),i=new Ft({value:{case:"chatMessage",value:new GA(Object.assign(Object.assign({},n),{timestamp:Ke.parse(n.timestamp),editTimestamp:Ke.parse(n.editTimestamp)}))}});return yield this.engine.sendDataPacket(i,ge.RELIABLE),this.emit(X.ChatMessage,n),n})}sendText(e,t){return k(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendText(e,t)})}streamText(e){return k(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamText(e)})}sendFile(e,t){return k(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendFile(e,t)})}streamBytes(e){return k(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamBytes(e)})}performRpc(e){return this.rpcClientManager.performRpc(e).then(t=>{let n=Ae(t,2);return n[0],n[1]})}registerRpcMethod(e,t){this.rpcServerManager.registerRpcMethod(e,t)}unregisterRpcMethod(e){this.rpcServerManager.unregisterRpcMethod(e)}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(t=>t.mime.split("/")[0].toLowerCase()==="video")}updateInfo(e){return super.updateInfo(e)?(e.tracks.forEach(t=>{var n,i;const s=this.trackPublications.get(t.sid);if(s){const a=s.isMuted||((i=(n=s.track)===null||n===void 0?void 0:n.isUpstreamPaused)!==null&&i!==void 0?i:!1);a!==t.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign({},we(s)),{mutedOnServer:a})),this.engine.client.sendMuteTrack(t.sid,a))}}),!0):!1}setActiveAgent(e){var t,n,i,s;this.firstActiveAgent=e,e&&!this.firstActiveAgent&&(this.firstActiveAgent=e),e?(n=(t=this.activeAgentFuture)===null||t===void 0?void 0:t.resolve)===null||n===void 0||n.call(t,e):(s=(i=this.activeAgentFuture)===null||i===void 0?void 0:i.reject)===null||s===void 0||s.call(i,new Error("Agent disconnected")),this.activeAgentFuture=void 0}waitUntilActiveAgentPresent(){return this.firstActiveAgent?Promise.resolve(this.firstActiveAgent):(this.activeAgentFuture||(this.activeAgentFuture=new Bt),this.activeAgentFuture.promise)}getPublicationForTrack(e){let t;return this.trackPublications.forEach(n=>{const i=n.track;i&&(e instanceof MediaStreamTrack?(or(i)||Ln(i))&&i.mediaStreamTrack===e&&(t=n):e===i&&(t=n))}),t}waitForPendingPublicationOfSource(e){return k(this,void 0,void 0,function*(){const n=Date.now();for(;Date.now()<n+1e4;){const i=Array.from(this.pendingPublishPromises.entries()).find(s=>Ae(s,1)[0].source===e);if(i)return i[1];yield Qt(20)}})}publishDataTrack(e){return k(this,void 0,void 0,function*(){const t=new Do(e,this.roomOutgoingDataTrackManager);return yield t.publish(),t})}}class xh extends DOMException{constructor(e,t){super(e,"AbortError"),this.reason=t}}class MB extends Map{constructor(){super(...arguments),this.pending=new Map}set(e,t){var n,i;super.set(e,t);const s=(n=this.pending)===null||n===void 0?void 0:n.get(e);if(s){for(const a of s)a.isResolved||(i=a.resolve)===null||i===void 0||i.call(a,t);this.pending.delete(e)}return this}get[Symbol.toStringTag](){return"DeferrableMap"}getDeferred(e,t){return k(this,void 0,void 0,function*(){const n=this.get(e);if(typeof n<"u")return n;if(t!=null&&t.aborted)throw new xh("The operation was aborted.",t.reason);const i=new Bt(void 0,()=>{const a=this.pending.get(e);if(!a)return;const A=a.indexOf(i);A!==-1&&a.splice(A,1),a.length===0&&this.pending.delete(e)}),s=this.pending.get(e);if(s?s.push(i):this.pending.set(e,[i]),t){const a=()=>{var A;i.isResolved||(A=i.reject)===null||A===void 0||A.call(i,new xh("The operation was aborted.",t.reason))};t.addEventListener("abort",a,{once:!0}),i.promise.finally(()=>{t.removeEventListener("abort",a)})}return i.promise})}}class _B extends ur{constructor(e,t,n,i){super(e,t.sid,t.name,i),this.track=void 0,this.allowed=!0,this.requestedDisabled=void 0,this.visible=!0,this.handleEnded=s=>{this.setTrack(void 0),this.emit($.Ended,s)},this.handleVisibilityChange=s=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(s),this.logContext),this.visible=s,this.emitTrackUpdate()},this.handleVideoDimensionsChange=s=>{this.log.debug("adaptivestream video dimensions ".concat(s.width,"x").concat(s.height),this.logContext),this.videoDimensionsAdaptiveStream=s,this.emitTrackUpdate()},this.subscribed=n,this.updateInfo(t)}setSubscribed(e){const t=this.subscriptionStatus,n=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const i=new Uo({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new wm({participantSid:"",trackSids:[this.trackSid]})]});this.emit($.UpdateSubscription,i),this.emitSubscriptionUpdateIfChanged(t),this.emitPermissionUpdateIfChanged(n)}get subscriptionStatus(){return this.subscribed===!1?ur.SubscriptionStatus.Unsubscribed:super.isSubscribed?ur.SubscriptionStatus.Subscribed:ur.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?ur.PermissionStatus.Allowed:ur.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return this.requestedDisabled!==void 0?!this.requestedDisabled:this.isAdaptiveStream?this.visible:!0}get isLocal(){return!1}setEnabled(e){!this.isManualOperationAllowed()||this.requestedDisabled===!e||(this.requestedDisabled=!e,this.emitTrackUpdate())}setVideoQuality(e){!this.isManualOperationAllowed()||this.requestedMaxQuality===e||(this.requestedMaxQuality=e,this.requestedVideoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var t,n;this.isManualOperationAllowed()&&(((t=this.requestedVideoDimensions)===null||t===void 0?void 0:t.width)===e.width&&((n=this.requestedVideoDimensions)===null||n===void 0?void 0:n.height)===e.height||(Sc(this.track)&&(this.requestedVideoDimensions=e),this.requestedMaxQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&Sc(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){var e;return(e=this.requestedMaxQuality)!==null&&e!==void 0?e:sn.HIGH}setTrack(e){const t=this.subscriptionStatus,n=this.permissionStatus,i=this.track;i!==e&&(i&&(i.off($.VideoDimensionsChanged,this.handleVideoDimensionsChange),i.off($.VisibilityChanged,this.handleVisibilityChange),i.off($.Ended,this.handleEnded),i.detach(),i.stopMonitor(),this.emit($.Unsubscribed,i)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on($.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on($.VisibilityChanged,this.handleVisibilityChange),e.on($.Ended,this.handleEnded),this.emit($.Subscribed,e)),this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(t))}setAllowed(e){const t=this.subscriptionStatus,n=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(t)}setSubscriptionError(e){this.emit($.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);const t=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):t!==e.muted&&this.emit(e.muted?$.Muted:$.Unmuted)}emitSubscriptionUpdateIfChanged(e){const t=this.subscriptionStatus;e!==t&&this.emit($.SubscriptionStatusChanged,t,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit($.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.isDesired?!0:(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return Sc(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new Qm({trackSids:[this.trackSid],disabled:!this.isEnabled,fps:this.fps});if(this.kind===N.Kind.Video){let t=this.requestedVideoDimensions;if(this.videoDimensionsAdaptiveStream!==void 0)if(t)O0(this.videoDimensionsAdaptiveStream,t)&&(this.log.debug("using adaptive stream dimensions instead of requested",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),t=this.videoDimensionsAdaptiveStream);else if(this.requestedMaxQuality!==void 0&&this.trackInfo){const n=F4(this.trackInfo,this.requestedMaxQuality);n&&O0(this.videoDimensionsAdaptiveStream,n)&&(this.log.debug("using adaptive stream dimensions instead of max quality layer",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),t=this.videoDimensionsAdaptiveStream)}else this.log.debug("using adaptive stream dimensions",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),t=this.videoDimensionsAdaptiveStream;t?(e.width=Math.ceil(t.width),e.height=Math.ceil(t.height)):this.requestedMaxQuality!==void 0?(this.log.debug("using requested max quality",Object.assign(Object.assign({},this.logContext),{quality:this.requestedMaxQuality})),e.quality=this.requestedMaxQuality):(this.log.debug("using default quality",Object.assign(Object.assign({},this.logContext),{quality:sn.HIGH})),e.quality=sn.HIGH)}this.emit($.UpdateSettings,e)}}class ro extends Zg{static fromParticipantInfo(e,t,n,i){return new ro(e,t.sid,t.identity,t.name,t.metadata,t.attributes,n,t.kind,t.dataTracks.map(s=>{const a=YA.from(s);return new $g(a,i,{publisherIdentity:t.identity})}),t.clientProtocol)}get logContext(){return Object.assign(Object.assign({},super.logContext),{remoteParticipantID:this.sid,remoteParticipant:this.identity})}constructor(e,t,n,i,s,a,A){let o=arguments.length>7&&arguments[7]!==void 0?arguments[7]:Aa.STANDARD,c=arguments.length>8&&arguments[8]!==void 0?arguments[8]:[],l=arguments.length>9&&arguments[9]!==void 0?arguments[9]:bg;super(t,n||"",i,s,a,A,o),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.dataTracks=new MB(c.map(d=>[d.info.name,d])),this.volumeMap=new Map,this.clientProtocol=l}addTrackPublication(e){super.addTrackPublication(e),e.on($.UpdateSettings,t=>{this.log.debug("send update settings",Object.assign(Object.assign(Object.assign({},this.logContext),we(e)),{settings:t})),this.signalClient.sendUpdateTrackSettings(t)}),e.on($.UpdateSubscription,t=>{t.participantTracks.forEach(n=>{n.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(t)}),e.on($.SubscriptionPermissionChanged,t=>{this.emit(X.TrackSubscriptionPermissionChanged,e,t)}),e.on($.SubscriptionStatusChanged,t=>{this.emit(X.TrackSubscriptionStatusChanged,e,t)}),e.on($.Subscribed,t=>{this.emit(X.TrackSubscribed,t,e)}),e.on($.Unsubscribed,t=>{this.emit(X.TrackUnsubscribed,t,e)}),e.on($.SubscriptionFailed,t=>{this.emit(X.TrackSubscriptionFailed,e.trackSid,t)})}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setVolume(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:N.Source.Microphone;this.volumeMap.set(t,e);const n=this.getTrackPublication(t);n&&n.track&&n.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:N.Source.Microphone;const t=this.getTrackPublication(e);return t&&t.track?t.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,t,n,i,s,a){let A=this.getTrackPublicationBySid(t);if(A||t.startsWith("TR")||this.trackPublications.forEach(l=>{!A&&e.kind===l.kind.toString()&&(A=l)}),!A){if(a===0){this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:t})),this.emit(X.TrackSubscriptionFailed,t);return}a===void 0&&(a=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,t,n,i,s,a-1)},150);return}if(e.readyState==="ended"){this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),we(A))),this.emit(X.TrackSubscriptionFailed,t);return}const o=e.kind==="video";let c;return o?c=new fu(e,t,i,s):c=new xB(e,t,i,this.audioContext,this.audioOutput),c.source=A.source,c.isMuted=A.isMuted,c.setMediaStream(n),c.start(),A.setTrack(c),this.volumeMap.has(A.source)&&Yl(c)&&$n(c)&&c.setVolume(this.volumeMap.get(A.source)),A}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const t=new Map,n=new Map;return e.tracks.forEach(i=>{var s,a;let A=this.getTrackPublicationBySid(i.sid);if(A)A.updateInfo(i);else{const o=N.kindFromProto(i.type);if(!o)return;A=new _B(o,i,(s=this.signalClient.connectOptions)===null||s===void 0?void 0:s.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:(a=this.loggerOptions)===null||a===void 0?void 0:a.loggerName}),A.updateInfo(i),n.set(i.sid,A);const c=Array.from(this.trackPublications.values()).find(l=>l.source===(A==null?void 0:A.source));c&&A.source!==N.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(A.source),Object.assign(Object.assign({},this.logContext),{oldTrack:we(c),newTrack:we(A)})),this.addTrackPublication(A)}t.set(i.sid,A)}),this.trackPublications.forEach(i=>{t.has(i.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),we(i))),this.unpublishTrack(i.trackSid,!0))}),n.forEach(i=>{this.emit(X.TrackPublished,i)}),!0}unpublishTrack(e,t){const n=this.trackPublications.get(e);if(!n)return;const i=n.track;switch(i&&(i.stop(),n.setTrack(void 0)),this.trackPublications.delete(e),n.kind){case N.Kind.Audio:this.audioTrackPublications.delete(e);break;case N.Kind.Video:this.videoTrackPublications.delete(e);break}t&&this.emit(X.TrackUnpublished,n)}setAudioOutput(e){return k(this,void 0,void 0,function*(){this.audioOutput=e;const t=[];this.audioTrackPublications.forEach(n=>{var i;$n(n.track)&&Yl(n.track)&&t.push(n.track.setSinkId((i=e.deviceId)!==null&&i!==void 0?i:"default"))}),yield Promise.all(t)})}addRemoteDataTrack(e){this.dataTracks.set(e.info.name,e)}removeRemoteDataTrack(e){for(const n of this.dataTracks.entries()){var t=Ae(n,2);const i=t[0],s=t[1];e===s.info.sid&&this.dataTracks.delete(i)}}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:n})),super.emit(e,...n)}}var Ee;(function(r){r.Disconnected="disconnected",r.Connecting="connecting",r.Connected="connected",r.Reconnecting="reconnecting",r.SignalReconnecting="signalReconnecting"})(Ee||(Ee={}));const RB=4*1e3;class cs extends Yt.EventEmitter{get hasE2EESetup(){return this.e2eeManager!==void 0}constructor(e){var t,n,i,s,a,A,o;if(super(),t=this,this.state=Ee.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.e2eeStateMutex=new xt,this.isVideoPlaybackBlocked=!1,this.log=me,this.bufferedEvents=[],this.isResuming=!1,this.connect=(c,l,d)=>k(this,void 0,void 0,function*(){var u;if(!P4())throw Rn()?Error("WebRTC isn't detected, have you called registerGlobals?"):Error("LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.");const h=yield this.disconnectLock.lock();if(this.state===Ee.Connected)return this.log.info("already connected to room ".concat(this.name)),h(),Promise.resolve();if(this.connectFuture)return h(),this.connectFuture.promise;this.setAndEmitConnectionState(Ee.Connecting),((u=this.regionUrlProvider)===null||u===void 0?void 0:u.getServerUrl().toString())!==Ig(c)&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),as(new URL(c))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new Te(c,l):this.regionUrlProvider.updateToken(l),this.regionUrlProvider.fetchRegionSettings().then(v=>{var w;(w=this.regionUrlProvider)===null||w===void 0||w.setServerReportedRegions(v)}).catch(v=>{this.log.warn("could not fetch region settings",{error:v})}));const p=(v,w,B)=>k(this,void 0,void 0,function*(){var E,b;this.abortController&&this.abortController.abort();const C=new AbortController;this.abortController=C,h==null||h();try{if(yield Xi.getInstance().getBackOffPromise(c),C.signal.aborted)throw oe.cancelled("Connection attempt aborted");yield this.attemptConnection(B??c,l,d,C),this.abortController=void 0,v()}catch(T){if(this.regionUrlProvider&&T instanceof oe&&T.reason!==Pe.Cancelled&&T.reason!==Pe.NotAllowed){let F=null;try{this.log.debug("Fetching next region"),F=yield this.regionUrlProvider.getNextBestRegionUrl((E=this.abortController)===null||E===void 0?void 0:E.signal)}catch(R){if(R instanceof oe&&(R.status===401||R.reason===Pe.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),w(R);return}}[Pe.InternalError,Pe.ServerUnreachable,Pe.Timeout].includes(T.reason)&&(this.log.debug("Adding failed connection attempt to back off"),Xi.getInstance().addFailedConnectionAttempt(c)),F&&!(!((b=this.abortController)===null||b===void 0)&&b.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(T.message,". Retrying with another region: ").concat(F)),this.recreateEngine(!0),yield p(v,w,F)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,G0(T)),w(T))}else{let F=Qn.UNKNOWN_REASON;T instanceof oe&&(F=G0(T)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,F),w(T)}}}),g=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Bt((v,w)=>{p(v,w,g)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(c,l,d,u,h,p)=>k(this,void 0,void 0,function*(){var g;const v=yield d.join(c,l,{autoSubscribe:u.autoSubscribe,adaptiveStream:typeof h.adaptiveStream=="object"?!0:h.adaptiveStream,clientInfoCapabilities:ha((g=h.frameMetadata)!==null&&g!==void 0?g:h.packetTrailer)||this.e2eeManager?[km.CAP_PACKET_TRAILER]:void 0,maxRetries:u.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:u.websocketTimeout},p.signal,!h.singlePeerConnection),w=v.joinResponse,B=v.serverInfo;if(this.serverInfo=B,!B.version)throw new v4("unknown server version");return B.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version"),h.dynacast=!1),w}),this.applyJoinResponse=c=>{const l=c.participant;if(this.localParticipant.sid=l.sid,this.localParticipant.identity=l.identity,this.localParticipant.setEnabledPublishCodecs(c.enabledPublishCodecs),this.e2eeManager)try{this.e2eeManager.setSifTrailer(c.sifTrailer)}catch(d){this.log.error(d instanceof Error?d.message:"Could not set SifTrailer",{error:d})}this.handleParticipantUpdates([l,...c.otherParticipants]),c.room&&this.handleRoomUpdate(c.room)},this.attemptConnection=(c,l,d,u)=>k(this,void 0,void 0,function*(){var h,p;this.state===Ee.Reconnecting||this.isResuming||!((h=this.engine)===null||h===void 0)&&h.pendingReconnect?(this.log.info("Reconnection attempt replaced by new connection attempt"),this.recreateEngine(!0)):this.maybeCreateEngine(),!((p=this.regionUrlProvider)===null||p===void 0)&&p.isCloud()&&this.engine.setRegionStrategy(this.createRegionStrategy()),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},wu),d),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const g=yield this.connectSignal(c,l,this.engine,this.connOptions,this.options,u);this.applyJoinResponse(g),this.setupLocalParticipantEvents(),this.emit(V.SignalConnected)}catch(g){yield this.engine.close(),this.recreateEngine();const v=u.signal.aborted?oe.cancelled("Signal connection aborted"):oe.serverUnreachable("could not establish signal connection");throw g instanceof Error&&(v.message="".concat(v.message,": ").concat(g.message)),g instanceof oe&&(v.reason=g.reason,v.status=g.status),this.log.debug("error trying to establish signal connection",{error:g}),v}if(u.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),oe.cancelled("Connection attempt aborted");try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,u)}catch(g){throw yield this.engine.close(),this.recreateEngine(),g}$t()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),$t()&&window.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(Ee.Connected),this.emit(V.Connected),Xi.getInstance().resetFailedConnectionAttempts(c),this.registerConnectionReconcile(),this.regionUrlProvider&&this.regionUrlProvider.notifyConnected()}),this.disconnect=function(){for(var c=arguments.length,l=new Array(c),d=0;d<c;d++)l[d]=arguments[d];return k(t,[...l],void 0,function(){var u=this;let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var p,g,v;const w=yield u.disconnectLock.lock();try{if(u.state===Ee.Disconnected){u.log.debug("already disconnected");return}if(u.log.info("disconnect from room"),u.state===Ee.Connecting||u.state===Ee.Reconnecting||u.isResuming){const B="Abort connection attempt due to user initiated disconnect";u.log.warn(B),(p=u.abortController)===null||p===void 0||p.abort(B),(v=(g=u.connectFuture)===null||g===void 0?void 0:g.reject)===null||v===void 0||v.call(g,oe.cancelled("Client initiated disconnect")),u.connectFuture=void 0}u.engine&&(u.engine.client.isDisconnected||(yield u.engine.client.sendLeave()),yield u.engine.close()),u.handleDisconnect(h,Qn.CLIENT_INITIATED),u.engine=void 0}finally{w()}}()})},this.onPageLeave=()=>k(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting"),yield this.disconnect()}),this.startAudio=()=>k(this,void 0,void 0,function*(){const c=[],l=Ht();if(l&&l.os==="iOS"){const d="livekit-dummy-audio-el";let u=document.getElementById(d);if(!u){u=document.createElement("audio"),u.id=d,u.autoplay=!0,u.hidden=!0;const h=Cc();h.enabled=!0;const p=new MediaStream([h]);u.srcObject=p,document.addEventListener("visibilitychange",()=>{u&&(u.srcObject=document.hidden?null:p,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status"),this.startAudio()))}),document.body.append(u),this.once(V.Disconnected,()=>{u==null||u.remove(),u=null})}c.push(u)}this.remoteParticipants.forEach(d=>{d.audioTrackPublications.forEach(u=>{u.track&&u.track.attachedElements.forEach(h=>{c.push(h)})})});try{yield Promise.all([this.acquireAudioContext(),...c.map(d=>(d.muted=!1,d.play()))]),this.handleAudioPlaybackStarted()}catch(d){throw this.handleAudioPlaybackFailed(d),d}}),this.startVideo=()=>k(this,void 0,void 0,function*(){const c=[];for(const l of this.remoteParticipants.values())l.videoTrackPublications.forEach(d=>{var u;(u=d.track)===null||u===void 0||u.attachedElements.forEach(h=>{c.includes(h)||c.push(h)})});yield Promise.all(c.map(l=>l.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(l=>{l.name==="NotAllowedError"?this.handleVideoPlaybackFailed():this.log.warn("Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler")})}),this.handleRestarting=()=>{this.clearConnectionReconcile(),this.isResuming=!1;for(const c of this.remoteParticipants.values())this.handleParticipantDisconnected(c.identity,c);this.setAndEmitConnectionState(Ee.Reconnecting)&&this.emit(V.Reconnecting)},this.handleRestarted=()=>{this.outgoingDataTrackManager.sfuWillRepublishTracks(),this.incomingDataTrackManager.resendSubscriptionUpdates()},this.handleSignalRestarted=c=>k(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(c.serverRegion),{region:c.serverRegion}),this.bufferedEvents=[],this.applyJoinResponse(c);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(l){this.log.error("error trying to re-publish tracks after reconnection",{error:l})}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",{region:c.serverRegion})}catch{return}this.setAndEmitConnectionState(Ee.Connected),this.emit(V.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=c=>{var l;for(const u of c){if(u.identity===this.localParticipant.identity){this.localParticipant.updateInfo(u);continue}u.identity===""&&(u.identity=(l=this.sidToIdentity.get(u.sid))!==null&&l!==void 0?l:"");let h=this.remoteParticipants.get(u.identity);u.state===Gi.DISCONNECTED?this.handleParticipantDisconnected(u.identity,h):this.getOrCreateParticipant(u.identity,u)}const d=new Map(c.filter(u=>u.identity!==this.localParticipant.identity).map(u=>[u.identity,u.dataTracks.map(h=>YA.from(h))]));this.incomingDataTrackManager.receiveSfuPublicationUpdates(d)},this.handleActiveSpeakersUpdate=c=>{const l=[],d={};c.forEach(u=>{if(d[u.sid]=!0,u.sid===this.localParticipant.sid)this.localParticipant.audioLevel=u.level,this.localParticipant.setIsSpeaking(!0),l.push(this.localParticipant);else{const h=this.getRemoteParticipantBySid(u.sid);h&&(h.audioLevel=u.level,h.setIsSpeaking(!0),l.push(h))}}),d[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(u=>{d[u.sid]||(u.audioLevel=0,u.setIsSpeaking(!1))}),this.activeSpeakers=l,this.emitWhenConnected(V.ActiveSpeakersChanged,l)},this.handleSpeakersChanged=c=>{const l=new Map;this.activeSpeakers.forEach(u=>{const h=this.remoteParticipants.get(u.identity);h&&h.sid!==u.sid||l.set(u.sid,u)}),c.forEach(u=>{let h=this.getRemoteParticipantBySid(u.sid);u.sid===this.localParticipant.sid&&(h=this.localParticipant),h&&(h.audioLevel=u.level,h.setIsSpeaking(u.active),u.active?l.set(u.sid,h):l.delete(u.sid))});const d=Array.from(l.values());d.sort((u,h)=>h.audioLevel-u.audioLevel),this.activeSpeakers=d,this.emitWhenConnected(V.ActiveSpeakersChanged,d)},this.handleStreamStateUpdate=c=>{c.streamStates.forEach(l=>{const d=this.getRemoteParticipantBySid(l.participantSid);if(!d)return;const u=d.getTrackPublicationBySid(l.trackSid);if(!u||!u.track)return;const h=N.streamStateFromProto(l.state);u.track.setStreamState(h),h!==u.track.streamState&&(d.emit(X.TrackStreamStateChanged,u,u.track.streamState),this.emitWhenConnected(V.TrackStreamStateChanged,u,u.track.streamState,d))})},this.handleSubscriptionPermissionUpdate=c=>{const l=this.getRemoteParticipantBySid(c.participantSid);if(!l)return;const d=l.getTrackPublicationBySid(c.trackSid);d&&d.setAllowed(c.allowed)},this.handleSubscriptionError=c=>{const l=Array.from(this.remoteParticipants.values()).find(u=>u.trackPublications.has(c.trackSid));if(!l)return;const d=l.getTrackPublicationBySid(c.trackSid);d&&d.setSubscriptionError(c.err)},this.handleDataPacket=(c,l)=>{const d=this.remoteParticipants.get(c.participantIdentity);if(c.value.case==="user")this.handleUserPacket(d,c.value.value,c.kind,l);else if(c.value.case==="transcription")this.handleTranscription(d,c.value.value);else if(c.value.case==="sipDtmf")this.handleSipDtmf(d,c.value.value);else if(c.value.case==="chatMessage")this.handleChatMessage(d,c.value.value);else if(c.value.case==="metrics")this.handleMetrics(c.value.value,d);else if(c.value.case==="streamHeader"||c.value.case==="streamChunk"||c.value.case==="streamTrailer")this.handleDataStream(c,l);else if(c.value.case==="rpcRequest"){const u=c.value.value;this.rpcServerManager.handleIncomingRpcRequest(c.participantIdentity,u)}else if(c.value.case==="rpcResponse"){const u=c.value.value;switch(u.value.case){case"payload":this.rpcClientManager.handleIncomingRpcResponseSuccess(u.requestId,u.value.value);break;case"error":this.rpcClientManager.handleIncomingRpcResponseFailure(u.requestId,Ie.fromProto(u.value.value));break;default:this.log.warn("Unknown rpcResponse.value.case: ".concat(u.value.case),this.logContext);break}}else c.value.case==="rpcAck"&&this.rpcClientManager.handleIncomingRpcAck(c.value.value.requestId)},this.handleUserPacket=(c,l,d,u)=>{this.emit(V.DataReceived,l.payload,c,d,l.topic,u),c==null||c.emit(X.DataReceived,l.payload,d,u)},this.handleSipDtmf=(c,l)=>{this.emit(V.SipDTMFReceived,l,c),c==null||c.emit(X.SipDTMFReceived,l)},this.handleTranscription=(c,l)=>{const d=l.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(l.transcribedParticipantIdentity),u=d==null?void 0:d.trackPublications.get(l.trackId),h=q4(l,this.transcriptionReceivedTimes);u==null||u.emit($.TranscriptionReceived,h),d==null||d.emit(X.TranscriptionReceived,h,u),this.emit(V.TranscriptionReceived,h,d,u)},this.handleChatMessage=(c,l)=>{const d=W4(l);this.emit(V.ChatMessage,d,c)},this.handleMetrics=(c,l)=>{this.emit(V.MetricsReceived,c,l)},this.handleDataStream=(c,l)=>{this.incomingDataStreamManager.handleDataStreamPacket(c,l)},this.bufferedSegments=new Map,this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(V.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=c=>{this.log.warn("could not playback audio",{error:c}),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(V.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(V.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(V.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>k(this,void 0,void 0,function*(){var c;((c=Ht())===null||c===void 0?void 0:c.os)!=="iOS"&&(yield this.selectDefaultDevices()),this.emit(V.MediaDevicesChanged)}),this.handleRoomUpdate=c=>{const l=this.roomInfo;this.roomInfo=c,l&&l.metadata!==c.metadata&&this.emitWhenConnected(V.RoomMetadataChanged,c.metadata),(l==null?void 0:l.activeRecording)!==c.activeRecording&&this.emitWhenConnected(V.RecordingStatusChanged,c.activeRecording)},this.handleConnectionQualityUpdate=c=>{c.updates.forEach(l=>{if(l.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(l.quality);return}const d=this.getRemoteParticipantBySid(l.participantSid);d&&d.setConnectionQuality(l.quality)})},this.getRemoteParticipantClientProtocol=c=>{var l,d;return(d=(l=this.remoteParticipants.get(c))===null||l===void 0?void 0:l.clientProtocol)!==null&&d!==void 0?d:bg},this.onLocalParticipantMetadataChanged=c=>{this.emit(V.ParticipantMetadataChanged,c,this.localParticipant)},this.onLocalParticipantNameChanged=c=>{this.emit(V.ParticipantNameChanged,c,this.localParticipant)},this.onLocalAttributesChanged=c=>{this.emit(V.ParticipantAttributesChanged,c,this.localParticipant)},this.onLocalTrackMuted=c=>{this.emit(V.TrackMuted,c,this.localParticipant)},this.onLocalTrackUnmuted=c=>{this.emit(V.TrackUnmuted,c,this.localParticipant)},this.onTrackProcessorUpdate=c=>{var l;(l=c==null?void 0:c.onPublish)===null||l===void 0||l.call(c,this)},this.onLocalTrackPublished=c=>k(this,void 0,void 0,function*(){var l,d,u,h,p,g;(l=c.track)===null||l===void 0||l.on($.TrackProcessorUpdate,this.onTrackProcessorUpdate),(d=c.track)===null||d===void 0||d.on($.Restarted,this.onLocalTrackRestarted),(p=(h=(u=c.track)===null||u===void 0?void 0:u.getProcessor())===null||h===void 0?void 0:h.onPublish)===null||p===void 0||p.call(h,this),this.emit(V.LocalTrackPublished,c,this.localParticipant),or(c.track)&&(yield c.track.checkForSilence())&&this.emit(V.LocalAudioSilenceDetected,c);const v=yield(g=c.track)===null||g===void 0?void 0:g.getDeviceId(!1),w=Wl(c.source);w&&v&&v!==this.localParticipant.activeDeviceMap.get(w)&&(this.localParticipant.activeDeviceMap.set(w,v),this.emit(V.ActiveDeviceChanged,w,v))}),this.onLocalTrackUnpublished=c=>{var l,d;(l=c.track)===null||l===void 0||l.off($.TrackProcessorUpdate,this.onTrackProcessorUpdate),(d=c.track)===null||d===void 0||d.off($.Restarted,this.onLocalTrackRestarted),this.emit(V.LocalTrackUnpublished,c,this.localParticipant)},this.onLocalTrackRestarted=c=>k(this,void 0,void 0,function*(){const l=yield c.getDeviceId(!1),d=Wl(c.source);d&&l&&l!==this.localParticipant.activeDeviceMap.get(d)&&(this.log.debug("local track restarted, setting ".concat(d," ").concat(l," active")),this.localParticipant.activeDeviceMap.set(d,l),this.emit(V.ActiveDeviceChanged,d,l))}),this.onLocalConnectionQualityChanged=c=>{this.emit(V.ConnectionQualityChanged,c,this.localParticipant)},this.onMediaDevicesError=(c,l)=>{this.emit(V.MediaDevicesError,c,l)},this.onLocalParticipantPermissionsChanged=c=>{this.emit(V.ParticipantPermissionsChanged,c,this.localParticipant)},this.onLocalChatMessageSent=c=>{this.emit(V.ChatMessage,c,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},R2),e),this.log=Xt((n=this.options.loggerName)!==null&&n!==void 0?n:Ct.Room,()=>this.logContext),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},_g),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},Rg),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},_2),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.incomingDataStreamManager=new lB,this.outgoingDataStreamManager=new hB(this.engine,this.log),this.incomingDataTrackManager=new BB({e2eeManager:this.e2eeManager}),this.incomingDataTrackManager.on("sfuUpdateSubscription",c=>{this.engine.client.sendUpdateDataSubscription(c.sid,c.subscribe)}).on("trackPublished",c=>{var l;c.track.publisherIdentity!==this.localParticipant.identity&&(this.emit(V.DataTrackPublished,c.track),(l=this.remoteParticipants.get(c.track.publisherIdentity))===null||l===void 0||l.addRemoteDataTrack(c.track))}).on("trackUnpublished",c=>{var l;c.publisherIdentity!==this.localParticipant.identity&&(this.emit(V.DataTrackUnpublished,c.sid),(l=this.remoteParticipants.get(c.publisherIdentity))===null||l===void 0||l.removeRemoteDataTrack(c.sid))}),this.outgoingDataTrackManager=new Cu({e2eeManager:this.e2eeManager}),this.outgoingDataTrackManager.on("sfuPublishRequest",c=>{this.engine.client.sendPublishDataTrackRequest(c.handle,c.name,c.usesE2ee)}).on("sfuUnpublishRequest",c=>{this.engine.client.sendUnPublishDataTrackRequest(c.handle)}).on("trackPublished",c=>{this.emit(V.LocalDataTrackPublished,c.track)}).on("trackUnpublished",c=>{this.emit(V.LocalDataTrackUnpublished,c.sid)}).on("packetAvailable",c=>{let l=c.handle,d=c.bytes;this.engine.sendLossyBytes(d,ge.DATA_TRACK_LOSSY,"wait").finally(()=>this.outgoingDataTrackManager.handlePacketSendComplete(l))}),this.registerRpcDataStreamHandler(),this.rpcClientManager=new kB(this.log,this.outgoingDataStreamManager,this.getRemoteParticipantClientProtocol,()=>{var c,l;return(l=(c=this.engine.latestJoinResponse)===null||c===void 0?void 0:c.serverInfo)===null||l===void 0?void 0:l.version}),this.rpcClientManager.on("sendDataPacket",c=>{let l=c.packet;var d;(d=this.engine)===null||d===void 0||d.sendDataPacket(l,ge.RELIABLE)}),this.rpcServerManager=new TB(this.log,this.outgoingDataStreamManager,this.getRemoteParticipantClientProtocol),this.rpcServerManager.on("sendDataPacket",c=>{let l=c.packet;var d;(d=this.engine)===null||d===void 0||d.sendDataPacket(l,ge.RELIABLE)}),this.disconnectLock=new xt,this.localParticipant=new QB("","",this.engine,this.options,this.outgoingDataStreamManager,this.outgoingDataTrackManager,this.rpcClientManager,this.rpcServerManager),this.setupFrameMetadata(),(this.options.e2ee||this.options.encryption)&&this.setupE2EE(),this.engine.e2eeManager=this.e2eeManager,this.incomingDataTrackManager.updateE2eeManager((i=this.e2eeManager)!==null&&i!==void 0?i:null),this.outgoingDataTrackManager.updateE2eeManager((s=this.e2eeManager)!==null&&s!==void 0?s:null),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",gi(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",gi(this.options.audioCaptureDefaults.deviceId)),!((a=this.options.audioOutput)===null||a===void 0)&&a.deviceId&&this.switchActiveDevice("audiooutput",gi(this.options.audioOutput.deviceId)).catch(c=>this.log.warn("Could not set audio output: ".concat(c.message))),$t()){const c=new AbortController;let l;if(cs.cleanupRegistry){const d=new WeakRef(this);l=()=>{const u=d.deref();u&&u.handleDeviceChange()},cs.cleanupRegistry.register(this,()=>{c.abort()})}else l=this.handleDeviceChange;(o=(A=navigator.mediaDevices)===null||A===void 0?void 0:A.addEventListener)===null||o===void 0||o.call(A,"devicechange",l,{signal:c.signal})}}registerTextStreamHandler(e,t){return this.incomingDataStreamManager.registerTextStreamHandler(e,t)}unregisterTextStreamHandler(e){return this.incomingDataStreamManager.unregisterTextStreamHandler(e)}registerByteStreamHandler(e,t){return this.incomingDataStreamManager.registerByteStreamHandler(e,t)}unregisterByteStreamHandler(e){return this.incomingDataStreamManager.unregisterByteStreamHandler(e)}registerRpcMethod(e,t){this.rpcServerManager.registerRpcMethod(e,t)}unregisterRpcMethod(e){this.rpcServerManager.unregisterRpcMethod(e)}setE2EEEnabled(e){return k(this,void 0,void 0,function*(){const t=yield this.e2eeStateMutex.lock();try{if(this.e2eeManager)this.isE2EEEnabled!==e&&(yield this.localParticipant.setE2EEEnabled(e),this.localParticipant.identity!==""&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity));else throw Error("e2ee not configured, please set e2ee settings within the room options")}finally{t()}})}setupE2EE(){var e,t;const n=!!this.options.encryption,i=this.options.encryption||this.options.e2ee;i&&("e2eeManager"in i?(this.e2eeManager=i.e2eeManager,this.e2eeManager.isDataChannelEncryptionEnabled=n):this.e2eeManager=new u2(i,n),this.e2eeManager.on(Pr.ParticipantEncryptionStatusChanged,(s,a)=>{j4(a)&&(this.isE2EEEnabled=s),this.emit(V.ParticipantEncryptionStatusChanged,s,a)}),this.e2eeManager.on(Pr.EncryptionError,(s,a)=>{const A=a?this.getParticipantByIdentity(a):void 0;this.emit(V.EncryptionError,s,A)}),(e=this.e2eeManager)===null||e===void 0||e.setup(this),(t=this.e2eeManager)===null||t===void 0||t.setupEngine(this.engine))}setupFrameMetadata(){var e;const t=(e=this.options.frameMetadata)!==null&&e!==void 0?e:this.options.packetTrailer;this.frameMetadataManager=new p2(t),this.frameMetadataManager.setup(this)}get logContext(){var e,t,n;return{room:this.name,roomID:(e=this.roomInfo)===null||e===void 0?void 0:e.sid,participant:(t=this.localParticipant)===null||t===void 0?void 0:t.identity,participantID:(n=this.localParticipant)===null||n===void 0?void 0:n.sid}}get isRecording(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.activeRecording)!==null&&t!==void 0?t:!1}getSid(){return this.state===Ee.Disconnected?Lt.resolve(""):this.roomInfo&&this.roomInfo.sid!==""?Lt.resolve(this.roomInfo.sid):new Lt((e,t)=>{const n=i=>{i.sid!==""&&(this.engine.off(G.RoomUpdate,n),e(i.sid))};this.engine.on(G.RoomUpdate,n),this.once(V.Disconnected,()=>{this.engine.off(G.RoomUpdate,n),t(new Xe("Room disconnected before room server id was available"))})})}get name(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.name)!==null&&t!==void 0?t:""}get metadata(){var e;return(e=this.roomInfo)===null||e===void 0?void 0:e.metadata}get numParticipants(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.numParticipants)!==null&&t!==void 0?t:0}get numPublishers(){var e,t;return(t=(e=this.roomInfo)===null||e===void 0?void 0:e.numPublishers)!==null&&t!==void 0?t:0}maybeCreateEngine(){this.engine&&(this.engine.isNewlyCreated||!this.engine.isClosed)||(this.engine=new sB(this.options),this.engine.e2eeManager=this.e2eeManager,this.engine.on(G.ParticipantUpdate,this.handleParticipantUpdates).on(G.RoomUpdate,this.handleRoomUpdate).on(G.SpeakersChanged,this.handleSpeakersChanged).on(G.StreamStateChanged,this.handleStreamStateUpdate).on(G.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(G.SubscriptionError,this.handleSubscriptionError).on(G.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(G.MediaTrackAdded,(e,t,n)=>{this.onTrackAdded(e,t,n)}).on(G.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(G.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(G.DataPacketReceived,this.handleDataPacket).on(G.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.debug("Resuming signal connection"),this.setAndEmitConnectionState(Ee.SignalReconnecting)&&this.emit(V.SignalReconnecting)}).on(G.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.debug("Resumed signal connection"),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(Ee.Connected)&&this.emit(V.Reconnected)}).on(G.SignalResumed,()=>{this.bufferedEvents=[],(this.state===Ee.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(G.Restarting,this.handleRestarting).on(G.Restarted,this.handleRestarted).on(G.SignalRestarted,this.handleSignalRestarted).on(G.Offline,()=>{this.setAndEmitConnectionState(Ee.Reconnecting)&&this.emit(V.Reconnecting)}).on(G.DCBufferStatusChanged,(e,t)=>{this.emit(V.DCBufferStatusChanged,e,t)}).on(G.LocalTrackSubscribed,e=>{this.handleLocalTrackSubscribed(e)}).on(G.RoomMoved,e=>{this.log.debug("room moved",e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((t,n)=>{this.handleParticipantDisconnected(n,t)}),this.emit(V.Moved,e.room.name),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}).on(G.PublishDataTrackResponse,e=>{if(!e.info){this.log.warn("received PublishDataTrackResponse, but event.info was ".concat(e.info,", so skipping."));return}this.outgoingDataTrackManager.receivedSfuPublishResponse(e.info.pubHandle,{type:"ok",data:{sid:e.info.sid,pubHandle:e.info.pubHandle,name:e.info.name,usesE2ee:e.info.encryption!==De.NONE}})}).on(G.UnPublishDataTrackResponse,e=>{if(!e.info){this.log.warn("received UnPublishDataTrackResponse, but event.info was ".concat(e.info,", so skipping."));return}this.outgoingDataTrackManager.receivedSfuUnpublishResponse(e.info.pubHandle)}).on(G.DataTrackSubscriberHandles,e=>{const t=new Map(Object.entries(e.subHandles).map(n=>{let i=Ae(n,2),s=i[0],a=i[1];return[parseInt(s,10),a.trackSid]}));this.incomingDataTrackManager.receivedSfuSubscriberHandles(t)}).on(G.DataTrackPacketReceived,e=>{try{this.incomingDataTrackManager.packetReceived(e)}catch(t){throw t}}).on(G.Joined,e=>{const t=new Map(e.otherParticipants.map(n=>[n.identity,n.dataTracks.map(i=>YA.from(i))]));this.incomingDataTrackManager.receiveSfuPublicationUpdates(t)}).on(G.TokenRefreshed,e=>{var t;(t=this.regionUrlProvider)===null||t===void 0||t.updateToken(e)}).on(G.ServerRegionsReported,e=>{var t;(t=this.regionUrlProvider)===null||t===void 0||t.setServerReportedRegions({regionSettings:e,updatedAtInMs:Date.now(),maxAgeInMs:nd})}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine),this.outgoingDataStreamManager&&this.outgoingDataStreamManager.setupEngine(this.engine))}createRegionStrategy(){return{getNextUrl:e=>k(this,void 0,void 0,function*(){return this.regionUrlProvider?this.regionUrlProvider.getNextBestRegionUrl(e):null}),resetAttempts:()=>{var e;return(e=this.regionUrlProvider)===null||e===void 0?void 0:e.resetAttempts()}}}static getLocalDevices(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return bt.getInstance().getDevices(e,t)}prepareConnection(e,t){return k(this,void 0,void 0,function*(){if(this.state===Ee.Disconnected){this.log.debug("prepareConnection to ".concat(e));try{if(as(new URL(e))&&t){this.regionUrlProvider=new Te(e,t);const n=yield this.regionUrlProvider.getNextBestRegionUrl();n&&this.state===Ee.Disconnected&&(this.regionUrl=n,yield fetch(da(n),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(n)))}else yield fetch(da(e),{method:"HEAD"})}catch(n){this.log.warn("could not prepare connection",{error:n})}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,t){return k(this,void 0,void 0,function*(){let n=()=>k(this,void 0,void 0,function*(){}),i;switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"fail-on-v1-path":this.engine.failNextV1Path();break;case"speaker":i=new Nn({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":i=new Nn({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":i=new Nn({scenario:{case:"serverLeave",value:!0}});break;case"migration":i=new Nn({scenario:{case:"migration",value:!0}});break;case"resume-reconnect":this.engine.failNext(),yield this.engine.client.handleOnClose("simulate resume-disconnect");break;case"disconnect-signal-on-resume":n=()=>k(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),i=new Nn({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":n=()=>k(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),i=new Nn({scenario:{case:"disconnectSignalOnResumeNoMessages",value:!0}});break;case"full-reconnect":this.engine.fullReconnectOnNext=!0,yield this.engine.client.handleOnClose("simulate full-reconnect");break;case"force-tcp":case"force-tls":i=new Nn({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),n=()=>k(this,void 0,void 0,function*(){const s=this.engine.client.onLeave;s&&s(new Fo({reason:Qn.CLIENT_INITIATED,action:qi.RECONNECT}))});break;case"subscriber-bandwidth":if(t===void 0||typeof t!="number")throw new Error("subscriber-bandwidth requires a number as argument");i=new Nn({scenario:{case:"subscriberBandwidth",value:ai(t)}});break;case"leave-full-reconnect":i=new Nn({scenario:{case:"leaveRequestFullReconnect",value:!0}})}i&&(yield this.engine.client.sendSimulateScenario(i),yield n())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,t){return k(this,arguments,void 0,function(n,i){var s=this;let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return function*(){var A,o,c,l,d,u,h;let p=!0,g=!1;const v=a?{exact:i}:i;if(n==="audioinput"){g=s.localParticipant.audioTrackPublications.size===0;const w=(A=s.getActiveDevice(n))!==null&&A!==void 0?A:s.options.audioCaptureDefaults.deviceId;s.options.audioCaptureDefaults.deviceId=v;const B=Array.from(s.localParticipant.audioTrackPublications.values()).filter(b=>b.source===N.Source.Microphone);try{p=(yield Promise.all(B.map(b=>{var C;return(C=b.audioTrack)===null||C===void 0?void 0:C.setDeviceId(v)}))).every(b=>b===!0)}catch(b){throw s.options.audioCaptureDefaults.deviceId=w,b}const E=B.some(b=>{var C,T;return(T=(C=b.track)===null||C===void 0?void 0:C.isMuted)!==null&&T!==void 0?T:!1});p&&E&&(g=!0)}else if(n==="videoinput"){g=s.localParticipant.videoTrackPublications.size===0;const w=(o=s.getActiveDevice(n))!==null&&o!==void 0?o:s.options.videoCaptureDefaults.deviceId;s.options.videoCaptureDefaults.deviceId=v;const B=Array.from(s.localParticipant.videoTrackPublications.values()).filter(b=>b.source===N.Source.Camera);try{p=(yield Promise.all(B.map(b=>{var C;return(C=b.videoTrack)===null||C===void 0?void 0:C.setDeviceId(v)}))).every(b=>b===!0)}catch(b){throw s.options.videoCaptureDefaults.deviceId=w,b}const E=B.some(b=>{var C,T;return(T=(C=b.track)===null||C===void 0?void 0:C.isMuted)!==null&&T!==void 0?T:!1});p&&E&&(g=!0)}else if(n==="audiooutput"){if(g=!0,!Xl()&&!s.options.webAudioMix||s.options.webAudioMix&&s.audioContext&&!("setSinkId"in s.audioContext))throw new Error("cannot switch audio output, the current browser does not support it");s.options.webAudioMix&&(i=(c=yield bt.getInstance().normalizeDeviceId("audiooutput",i))!==null&&c!==void 0?c:""),(l=(h=s.options).audioOutput)!==null&&l!==void 0||(h.audioOutput={});const w=(d=s.getActiveDevice(n))!==null&&d!==void 0?d:s.options.audioOutput.deviceId;s.options.audioOutput.deviceId=i;try{s.options.webAudioMix&&((u=s.audioContext)===null||u===void 0||u.setSinkId(i)),yield Promise.all(Array.from(s.remoteParticipants.values()).map(B=>B.setAudioOutput({deviceId:i})))}catch(B){throw s.options.audioOutput.deviceId=w,B}}return g&&(s.localParticipant.activeDeviceMap.set(n,i),s.emit(V.ActiveDeviceChanged,n,i)),p}()})}setupLocalParticipantEvents(){this.localParticipant.on(X.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(X.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(X.AttributesChanged,this.onLocalAttributesChanged).on(X.TrackMuted,this.onLocalTrackMuted).on(X.TrackUnmuted,this.onLocalTrackUnmuted).on(X.LocalTrackPublished,this.onLocalTrackPublished).on(X.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(X.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(X.MediaDevicesError,this.onMediaDevicesError).on(X.AudioStreamAcquired,this.startAudio).on(X.ChatMessage,this.onLocalChatMessageSent).on(X.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(e){const t=this.engine;e&&t&&!t.client.isDisconnected?t.client.sendLeave().finally(()=>t.close()):t==null||t.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,t,n){if(this.state===Ee.Connecting||this.state===Ee.Reconnecting){const d=()=>{this.log.debug("deferring on track for later",{mediaTrackId:e.id,mediaStreamId:t.id,tracksInStream:t.getTracks().map(h=>h.id)}),this.onTrackAdded(e,t,n),u()},u=()=>{this.off(V.Reconnected,d),this.off(V.Connected,d),this.off(V.Disconnected,u)};this.once(V.Reconnected,d),this.once(V.Connected,d),this.once(V.Disconnected,u);return}if(this.state===Ee.Disconnected){this.log.warn("skipping incoming track after Room disconnected");return}if(e.readyState==="ended"){this.log.debug("skipping incoming track as it already ended");return}const i=M4(t.id),s=i[0];let a=i[1],A=e.id;if(a&&a.startsWith("TR")&&(A=a),s===this.localParticipant.sid){this.log.warn("tried to create RemoteParticipant for local participant");return}const o=Array.from(this.remoteParticipants.values()).find(d=>d.sid===s);if(!o){s.startsWith("PA")&&this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(s));return}if(!A.startsWith("TR")){const d=this.engine.getTrackIdForReceiver(n);if(!d){this.log.error("Tried to add a track whose 'sid' could not be found for a participant, that's not present. Sid: ".concat(s));return}A=d}A.startsWith("TR")||this.log.warn("Tried to add a track whose 'sid' could not be determined for a participant, that's not present. Sid: ".concat(s,", streamId: ").concat(a,", trackId: ").concat(A),{remoteParticipantID:s,streamId:a,trackId:A});let c;this.options.adaptiveStream&&(typeof this.options.adaptiveStream=="object"?c=this.options.adaptiveStream:c={});const l=o.addSubscribedMediaTrack(e,A,t,n,c);l!=null&&l.isEncrypted&&!this.e2eeManager&&this.emit(V.EncryptionError,new Error("Encrypted ".concat(l.source," track received from participant ").concat(o.sid,", but room does not have encryption enabled!")))}handleLocalTrackSubscribed(e){const t=()=>this.localParticipant.getTrackPublications().find(o=>o.trackSid===e),n=t();if(n){this.emitLocalTrackSubscribed(n);return}this.log.debug("deferring LocalTrackSubscribed, publication not yet available",{subscribedSid:e});const i=1e4;let s;const a=o=>{o.trackSid===e&&(A(),this.emitLocalTrackSubscribed(o))},A=()=>{clearTimeout(s),this.localParticipant.off(X.LocalTrackPublished,a),this.off(V.Disconnected,A)};this.localParticipant.on(X.LocalTrackPublished,a),this.once(V.Disconnected,A),s=setTimeout(()=>{A();const o=t();o?this.emitLocalTrackSubscribed(o):this.log.warn("could not find local track publication for LocalTrackSubscribed event after timeout",{subscribedSid:e})},i)}emitLocalTrackSubscribed(e){this.localParticipant.emit(X.LocalTrackSubscribed,e),this.emitWhenConnected(V.LocalTrackSubscribed,e,this.localParticipant)}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1?arguments[1]:void 0;var n,i;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.incomingDataStreamManager.clearControllers(),this.incomingDataTrackManager.reset(),this.outgoingDataTrackManager.reset(),this.state!==Ee.Disconnected){this.regionUrl=void 0,this.regionUrlProvider&&this.regionUrlProvider.notifyDisconnected();try{this.remoteParticipants.forEach(s=>{s.trackPublications.forEach(a=>{s.unpublishTrack(a.trackSid)})}),this.localParticipant.trackPublications.forEach(s=>{var a,A,o;s.track&&this.localParticipant.unpublishTrack(s.track,e),e?((a=s.track)===null||a===void 0||a.detach(),(A=s.track)===null||A===void 0||A.stop()):(o=s.track)===null||o===void 0||o.stopMonitor()}),this.localParticipant.off(X.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(X.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(X.AttributesChanged,this.onLocalAttributesChanged).off(X.TrackMuted,this.onLocalTrackMuted).off(X.TrackUnmuted,this.onLocalTrackUnmuted).off(X.LocalTrackPublished,this.onLocalTrackPublished).off(X.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(X.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(X.MediaDevicesError,this.onMediaDevicesError).off(X.AudioStreamAcquired,this.startAudio).off(X.ChatMessage,this.onLocalChatMessageSent).off(X.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.trackPublications.clear(),this.localParticipant.videoTrackPublications.clear(),this.localParticipant.audioTrackPublications.clear(),this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.activeSpeakers=[],this.audioContext&&typeof this.options.webAudioMix=="boolean"&&(this.audioContext.close(),this.audioContext=void 0),$t()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),(i=(n=navigator.mediaDevices)===null||n===void 0?void 0:n.removeEventListener)===null||i===void 0||i.call(n,"devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(Ee.Disconnected),this.emit(V.Disconnected,t)}}}handleParticipantDisconnected(e,t){this.remoteParticipants.delete(e),t&&(this.incomingDataStreamManager.validateParticipantHasNoActiveDataStreams(e),this.incomingDataTrackManager.handleRemoteParticipantDisconnected(e),t.trackPublications.forEach(n=>{t.unpublishTrack(n.trackSid,!0)}),this.emit(V.ParticipantDisconnected,t),t.setDisconnected(),this.rpcClientManager.handleParticipantDisconnected(t.identity))}selectDefaultDevices(){return k(this,void 0,void 0,function*(){var e,t,n;const i=bt.getInstance().previousDevices,s=yield bt.getInstance().getDevices(void 0,!1),a=Ht();if((a==null?void 0:a.name)==="Chrome"&&a.os!=="iOS")for(let o of s){const c=i.find(l=>l.deviceId===o.deviceId);c&&c.label!==""&&c.kind===o.kind&&c.label!==o.label&&this.getActiveDevice(o.kind)==="default"&&this.emit(V.ActiveDeviceChanged,o.kind,o.deviceId)}const A=["audiooutput","audioinput","videoinput"];for(let o of A){const c=S4(o),l=this.localParticipant.getTrackPublication(c);if(l&&(!((e=l.track)===null||e===void 0)&&e.isUserProvided))continue;const d=s.filter(h=>h.kind===o),u=this.getActiveDevice(o);if(u===((t=i.filter(h=>h.kind===o)[0])===null||t===void 0?void 0:t.deviceId)&&d.length>0&&((n=d[0])===null||n===void 0?void 0:n.deviceId)!==u){yield this.switchActiveDevice(o,d[0].deviceId);continue}o==="audioinput"&&!la()||o==="videoinput"||d.length>0&&!d.find(h=>h.deviceId===this.getActiveDevice(o))&&(o!=="audiooutput"||!la())&&(yield this.switchActiveDevice(o,d[0].deviceId))}})}acquireAudioContext(){return k(this,void 0,void 0,function*(){var e,t;if(typeof this.options.webAudioMix!="boolean"&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:(!this.audioContext||this.audioContext.state==="closed")&&(this.audioContext=(e=kg())!==null&&e!==void 0?e:void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(i=>i.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&this.audioContext.state==="suspended")try{yield Promise.race([this.audioContext.resume(),Qt(200)])}catch(i){this.log.warn("Could not resume audio context",{error:i})}const n=((t=this.audioContext)===null||t===void 0?void 0:t.state)==="running";n!==this.canPlaybackAudio&&(this.audioEnabled=n,this.emit(V.AudioPlaybackStatusChanged,n))})}createParticipant(e,t){var n;let i;return t?i=ro.fromParticipantInfo(this.engine.client,t,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName},this.incomingDataTrackManager):i=new ro(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&i.setAudioContext(this.audioContext),!((n=this.options.audioOutput)===null||n===void 0)&&n.deviceId&&i.setAudioOutput(this.options.audioOutput).catch(s=>this.log.warn("Could not set audio output: ".concat(s.message))),i}getOrCreateParticipant(e,t){if(this.remoteParticipants.has(e)){const i=this.remoteParticipants.get(e);return t&&i.updateInfo(t)&&this.sidToIdentity.set(t.sid,t.identity),i}const n=this.createParticipant(e,t);return this.remoteParticipants.set(e,n),this.sidToIdentity.set(t.sid,t.identity),this.emitWhenConnected(V.ParticipantConnected,n),n.on(X.TrackPublished,i=>{this.emitWhenConnected(V.TrackPublished,i,n)}).on(X.TrackSubscribed,(i,s)=>{i.kind===N.Kind.Audio?(i.on($.AudioPlaybackStarted,this.handleAudioPlaybackStarted),i.on($.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):i.kind===N.Kind.Video&&(i.on($.VideoPlaybackFailed,this.handleVideoPlaybackFailed),i.on($.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emitWhenConnected(V.TrackSubscribed,i,s,n)}).on(X.TrackUnpublished,i=>{this.emit(V.TrackUnpublished,i,n)}).on(X.TrackUnsubscribed,(i,s)=>{this.emit(V.TrackUnsubscribed,i,s,n)}).on(X.TrackMuted,i=>{this.emitWhenConnected(V.TrackMuted,i,n)}).on(X.TrackUnmuted,i=>{this.emitWhenConnected(V.TrackUnmuted,i,n)}).on(X.ParticipantMetadataChanged,i=>{this.emitWhenConnected(V.ParticipantMetadataChanged,i,n)}).on(X.ParticipantNameChanged,i=>{this.emitWhenConnected(V.ParticipantNameChanged,i,n)}).on(X.AttributesChanged,i=>{this.emitWhenConnected(V.ParticipantAttributesChanged,i,n)}).on(X.ConnectionQualityChanged,i=>{this.emitWhenConnected(V.ConnectionQualityChanged,i,n)}).on(X.ParticipantPermissionsChanged,i=>{this.emitWhenConnected(V.ParticipantPermissionsChanged,i,n)}).on(X.TrackSubscriptionStatusChanged,(i,s)=>{this.emitWhenConnected(V.TrackSubscriptionStatusChanged,i,s,n)}).on(X.TrackSubscriptionFailed,(i,s)=>{this.emit(V.TrackSubscriptionFailed,i,n,s)}).on(X.TrackSubscriptionPermissionChanged,(i,s)=>{this.emitWhenConnected(V.TrackSubscriptionPermissionChanged,i,s,n)}).on(X.Active,()=>{this.emitWhenConnected(V.ParticipantActive,n),n.kind===Aa.AGENT&&this.localParticipant.setActiveAgent(n)}),t&&n.updateInfo(t),n}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((i,s)=>(i.push(...s.getTrackPublications()),i),[]),t=this.localParticipant.getTrackPublications(),n=this.outgoingDataTrackManager.queryPublished();this.engine.sendSyncState(e,t,n)}updateSubscriptions(){for(const e of this.remoteParticipants.values())for(const t of e.videoTrackPublications.values())t.isSubscribed&&$4(t)&&t.emitTrackUpdate()}getRemoteParticipantBySid(e){const t=this.sidToIdentity.get(e);if(t)return this.remoteParticipants.get(t)}registerRpcDataStreamHandler(){this.incomingDataStreamManager.registerTextStreamHandler(Xg,(e,t)=>k(this,[e,t],void 0,function(n,i){var s=this;let a=i.identity;return function*(){var A;const o=(A=n.info.attributes)!==null&&A!==void 0?A:{};yield s.rpcServerManager.handleIncomingDataStream(n,a,o)}()})),this.incomingDataStreamManager.registerTextStreamHandler(Jg,(e,t)=>k(this,[e,t],void 0,function(n,i){var s=this;let a=i.identity;return function*(){var A;const o=(A=n.info.attributes)!==null&&A!==void 0?A:{};yield s.rpcClientManager.handleIncomingDataStream(n,a,o)}()}))}registerConnectionReconcile(){this.clearConnectionReconcile();let e=0;this.connectionReconcileInterval=dt.setInterval(()=>{!this.engine||this.engine.isClosed||!this.engine.verifyTransport()?(e++,this.log.warn("detected connection state mismatch",{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnectedOrConnecting:this.engine.verifyTransport()}:void 0}),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,Qn.STATE_MISMATCH))):e=0},RB)}clearConnectionReconcile(){this.connectionReconcileInterval&&dt.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.log.info("connection state changed: ".concat(this.state," -> ").concat(e)),this.state=e,this.incomingDataStreamManager.setConnected(e===Ee.Connected),this.emit(V.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let t=Ae(e,2),n=t[0],i=t[1];this.emit(n,...i)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(this.state===Ee.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,n]);else if(this.state===Ee.Connected)return this.emit(e,...n);return!1}simulateParticipants(e){return k(this,void 0,void 0,function*(){var t,n,i,s;const a=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),A=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new So({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:Ke.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new Bi({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(V.SignalConnected),this.emit(V.Connected),this.setAndEmitConnectionState(Ee.Connected),a.video){const o=new rd(N.Kind.Video,new Ki({source:ct.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:Tn.AUDIO,name:"video-dummy"}),new to(a.useRealTracks&&(!((t=window.navigator.mediaDevices)===null||t===void 0)&&t.getUserMedia)?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:z0(160*((n=A.aspectRatios[0])!==null&&n!==void 0?n:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(o),this.localParticipant.emit(X.LocalTrackPublished,o)}if(a.audio){const o=new rd(N.Kind.Audio,new Ki({source:ct.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:Tn.AUDIO}),new ZA(a.useRealTracks&&(!((i=navigator.mediaDevices)===null||i===void 0)&&i.getUserMedia)?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Cc(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(o),this.localParticipant.emit(X.LocalTrackPublished,o)}for(let o=0;o<A.count-1;o+=1){let c=new Bi({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(o),state:Gi.ACTIVE,tracks:[],joinedAt:Ke.parse(Date.now())});const l=this.getOrCreateParticipant(c.identity,c);if(A.video){const d=z0(160*((s=A.aspectRatios[o%A.aspectRatios.length])!==null&&s!==void 0?s:1),160,!1,!0),u=new Ki({source:ct.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:Tn.AUDIO});l.addSubscribedMediaTrack(d,u.sid,new MediaStream([d]),new RTCRtpReceiver),c.tracks=[...c.tracks,u]}if(A.audio){const d=Cc(),u=new Ki({source:ct.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:Tn.AUDIO});l.addSubscribedMediaTrack(d,u.sid,new MediaStream([d]),new RTCRtpReceiver),c.tracks=[...c.tracks,u]}l.updateInfo(c)}})}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(e!==V.ActiveSpeakersChanged&&e!==V.TranscriptionReceived){const s=e1(n).filter(a=>a!==void 0);(e===V.TrackSubscribed||e===V.TrackUnsubscribed)&&this.log.trace("subscribe trace: ".concat(e),{event:e,args:s}),this.log.debug("room event ".concat(e),{event:e,args:s})}return super.emit(e,...n)}}cs.cleanupRegistry=typeof FinalizationRegistry<"u"&&typeof WeakRef<"u"&&new FinalizationRegistry(r=>{r()});function e1(r){return r.map(e=>{if(e)return Array.isArray(e)?e1(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var Sn;(function(r){r[r.IDLE=0]="IDLE",r[r.RUNNING=1]="RUNNING",r[r.SKIPPED=2]="SKIPPED",r[r.SUCCESS=3]="SUCCESS",r[r.FAILED=4]="FAILED"})(Sn||(Sn={}));class Jr extends Yt.EventEmitter{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=Sn.IDLE,this.logs=[],this.options={},this.url=e,this.token=t,this.name=this.constructor.name,this.room=new cs(n.roomOptions),this.connectOptions=n.connectOptions,this.options=n}run(e){return k(this,void 0,void 0,function*(){if(this.status!==Sn.IDLE)throw Error("check is running already");this.setStatus(Sn.RUNNING);try{yield this.perform()}catch(t){t instanceof Error&&(this.options.errorsAsWarnings?this.appendWarning(t.message):this.appendError(t.message))}return yield this.disconnect(),yield new Promise(t=>setTimeout(t,500)),this.status!==Sn.SKIPPED&&this.setStatus(this.isSuccess()?Sn.SUCCESS:Sn.FAILED),e&&e(),this.getInfo()})}isSuccess(){return!this.logs.some(e=>e.level==="error")}connect(e){return k(this,void 0,void 0,function*(){return this.room.state===Ee.Connected?this.room:(e||(e=this.url),yield this.room.connect(e,this.token,this.connectOptions),this.room)})}disconnect(){return k(this,void 0,void 0,function*(){this.room&&this.room.state!==Ee.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(Sn.SKIPPED)}switchProtocol(e){return k(this,void 0,void 0,function*(){let t=!1,n=!1;if(this.room.on(V.Reconnecting,()=>{t=!0}),this.room.once(V.Reconnected,()=>{n=!0}),this.room.simulateScenario("force-".concat(e)),yield new Promise(s=>setTimeout(s,1e3)),!t)return;const i=Date.now()+1e4;for(;Date.now()<i;){if(n)return;yield Qt(100)}throw new Error("Could not reconnect using ".concat(e," protocol after 10 seconds"))})}appendMessage(e){this.logs.push({level:"info",message:e}),this.emit("update",this.getInfo())}appendWarning(e){this.logs.push({level:"warning",message:e}),this.emit("update",this.getInfo())}appendError(e){this.logs.push({level:"error",message:e}),this.emit("update",this.getInfo())}setStatus(e){this.status=e,this.emit("update",this.getInfo())}get engine(){var e;return(e=this.room)===null||e===void 0?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class PB extends Jr{get description(){return"Cloud regions"}perform(){return k(this,void 0,void 0,function*(){const e=new Te(this.url,this.token);if(!e.isCloud()){this.skip();return}const t=[],n=new Set;for(let s=0;s<3;s++){const a=yield e.getNextBestRegionUrl();if(!a)break;if(n.has(a))continue;n.add(a);const A=yield this.checkCloudRegion(a);this.appendMessage("".concat(A.region," RTT: ").concat(A.rtt,"ms, duration: ").concat(A.duration,"ms")),t.push(A)}t.sort((s,a)=>(s.duration-a.duration)*.5+(s.rtt-a.rtt)*.5);const i=t[0];this.bestStats=i,this.appendMessage("best Cloud region: ".concat(i.region))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkCloudRegion(e){return k(this,void 0,void 0,function*(){var t,n;yield this.connect(e),this.options.protocol==="tcp"&&(yield this.switchProtocol("tcp"));const i=(t=this.room.serverInfo)===null||t===void 0?void 0:t.region;if(!i)throw new Error("Region not found");const s=yield this.room.localParticipant.streamText({topic:"test"}),a=1e3,o=1e6/a,c="A".repeat(a),l=Date.now();for(let p=0;p<o;p++)yield s.write(c);yield s.close();const d=Date.now(),u=yield(n=this.room.engine.pcManager)===null||n===void 0?void 0:n.publisher.getStats(),h={region:i,rtt:1e4,duration:d-l};return u==null||u.forEach(p=>{p.type==="candidate-pair"&&p.nominated&&(h.rtt=p.currentRoundTripTime*1e3)}),yield this.disconnect(),h})}}const _c=1e4;class DB extends Jr{get description(){return"Connection via UDP vs TCP"}perform(){return k(this,void 0,void 0,function*(){const e=yield this.checkConnectionProtocol("udp"),t=yield this.checkConnectionProtocol("tcp");this.bestStats=e,e.qualityLimitationDurations.bandwidth-t.qualityLimitationDurations.bandwidth>.5||(e.packetsLost-t.packetsLost)/e.packetsSent>.01?(this.appendMessage("best connection quality via tcp"),this.bestStats=t):this.appendMessage("best connection quality via udp");const n=this.bestStats;this.appendMessage("upstream bitrate: ".concat((n.bitrateTotal/n.count/1e3/1e3).toFixed(2)," mbps")),this.appendMessage("RTT: ".concat((n.rttTotal/n.count*1e3).toFixed(2)," ms")),this.appendMessage("jitter: ".concat((n.jitterTotal/n.count*1e3).toFixed(2)," ms")),n.packetsLost>0&&this.appendWarning("packets lost: ".concat((n.packetsLost/n.packetsSent*100).toFixed(2),"%")),n.qualityLimitationDurations.bandwidth>1&&this.appendWarning("bandwidth limited ".concat((n.qualityLimitationDurations.bandwidth/(_c/1e3)*100).toFixed(2),"%")),n.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((n.qualityLimitationDurations.cpu/(_c/1e3)*100).toFixed(2),"%"))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkConnectionProtocol(e){return k(this,void 0,void 0,function*(){yield this.connect(),e==="tcp"?yield this.switchProtocol("tcp"):yield this.switchProtocol("udp");const t=document.createElement("canvas");t.width=1280,t.height=720;const n=t.getContext("2d");if(!n)throw new Error("Could not get canvas context");let i=0;const s=()=>{i=(i+1)%360,n.fillStyle="hsl(".concat(i,", 100%, 50%)"),n.fillRect(0,0,t.width,t.height),requestAnimationFrame(s)};s();const A=t.captureStream(30).getVideoTracks()[0],c=(yield this.room.localParticipant.publishTrack(A,{simulcast:!1,degradationPreference:"maintain-resolution",videoEncoding:{maxBitrate:2e6}})).track,l={protocol:e,packetsLost:0,packetsSent:0,qualityLimitationDurations:{},rttTotal:0,jitterTotal:0,bitrateTotal:0,count:0},d=setInterval(()=>k(this,void 0,void 0,function*(){const u=yield c.getRTCStatsReport();u==null||u.forEach(h=>{h.type==="outbound-rtp"?(l.packetsSent=h.packetsSent,l.qualityLimitationDurations=h.qualityLimitationDurations,l.bitrateTotal+=h.targetBitrate,l.count++):h.type==="remote-inbound-rtp"&&(l.packetsLost=h.packetsLost,l.rttTotal+=h.roundTripTime,l.jitterTotal+=h.jitter)})}),1e3);return yield new Promise(u=>setTimeout(u,_c)),clearInterval(d),A.stop(),t.remove(),yield this.disconnect(),l})}}class LB extends Jr{get description(){return"Can publish audio"}perform(){return k(this,void 0,void 0,function*(){var e;const t=yield this.connect(),n=yield UB();if(yield Sg(n,1e3))throw new Error("unable to detect audio from microphone");this.appendMessage("detected audio from microphone"),t.localParticipant.publishTrack(n),yield new Promise(A=>setTimeout(A,3e3));const s=yield(e=n.sender)===null||e===void 0?void 0:e.getStats();if(!s)throw new Error("Could not get RTCStats");let a=0;if(s.forEach(A=>{A.type==="outbound-rtp"&&(A.kind==="audio"||!A.kind&&A.mediaType==="audio")&&(a=A.packetsSent)}),a===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(a," audio packets"))})}}class OB extends Jr{get description(){return"Can publish video"}perform(){return k(this,void 0,void 0,function*(){var e;const t=yield this.connect(),n=yield EB();yield this.checkForVideo(n.mediaStreamTrack),t.localParticipant.publishTrack(n),yield new Promise(a=>setTimeout(a,5e3));const i=yield(e=n.sender)===null||e===void 0?void 0:e.getStats();if(!i)throw new Error("Could not get RTCStats");let s=0;if(i.forEach(a=>{a.type==="outbound-rtp"&&(a.kind==="video"||!a.kind&&a.mediaType==="video")&&(s+=a.packetsSent)}),s===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(s," video packets"))})}checkForVideo(e){return k(this,void 0,void 0,function*(){const t=new MediaStream;t.addTrack(e.clone());const n=document.createElement("video");n.srcObject=t,n.muted=!0,n.autoplay=!0,n.playsInline=!0,n.setAttribute("playsinline","true"),document.body.appendChild(n),yield new Promise(i=>{n.onplay=()=>{setTimeout(()=>{var s,a,A,o;const c=document.createElement("canvas"),l=e.getSettings(),d=(a=(s=l.width)!==null&&s!==void 0?s:n.videoWidth)!==null&&a!==void 0?a:1280,u=(o=(A=l.height)!==null&&A!==void 0?A:n.videoHeight)!==null&&o!==void 0?o:720;c.width=d,c.height=u;const h=c.getContext("2d");h.drawImage(n,0,0);const g=h.getImageData(0,0,c.width,c.height).data;let v=!0;for(let w=0;w<g.length;w+=4)if(g[w]!==0||g[w+1]!==0||g[w+2]!==0){v=!1;break}v?this.appendError("camera appears to be producing only black frames"):this.appendMessage("received video frames"),i()},1e3)},n.play()}),t.getTracks().forEach(i=>i.stop()),n.remove()})}}class HB extends Jr{get description(){return"Resuming connection after interruption"}perform(){return k(this,void 0,void 0,function*(){var e;const t=yield this.connect();let n=!1,i=!1,s;const a=new Promise(c=>{setTimeout(c,5e3),s=c}),A=()=>{n=!0};t.on(V.SignalReconnecting,A).on(V.Reconnecting,A).on(V.Reconnected,()=>{i=!0,s(!0)}),(e=t.engine.client.ws)===null||e===void 0||e.close();const o=t.engine.client.onClose;if(o&&o(""),yield a,n){if(!i||t.state!==Ee.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}else throw new Error("Did not attempt to reconnect")})}}class NB extends Jr{get description(){return"Can connect via TURN"}perform(){return k(this,void 0,void 0,function*(){var e,t,n;as(new URL(this.url))&&(this.appendMessage("Using region specific url"),this.url=(e=yield new Te(this.url,this.token).getNextBestRegionUrl())!==null&&e!==void 0?e:this.url);const i=new gu,s=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0);let a=!1,A=!1,o=!1;for(let c of s.iceServers)for(let l of c.urls)l.startsWith("turn:")?(A=!0,o=!0):l.startsWith("turns:")&&(A=!0,o=!0,a=!0),l.startsWith("stun:")&&(o=!0);o?A&&!a&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield i.close(),!((n=(t=this.connectOptions)===null||t===void 0?void 0:t.rtcConfig)===null||n===void 0)&&n.iceServers||A?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise(c=>setTimeout(c,0)))})}}class KB extends Jr{get description(){return"Establishing WebRTC connection"}perform(){return k(this,void 0,void 0,function*(){let e=!1,t=!1;this.room.on(V.SignalConnected,()=>{var n;const i=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(s,a)=>{if(s.candidate){const A=new RTCIceCandidate(s);let o="".concat(A.protocol," ").concat(A.address,":").concat(A.port," ").concat(A.type);A.address&&(VB(A.address)?o+=" (private)":A.protocol==="tcp"&&A.tcpType==="passive"?(e=!0,o+=" (passive)"):A.protocol==="udp"&&(t=!0)),this.appendMessage(o)}i&&i(s,a)},!((n=this.room.engine.pcManager)===null||n===void 0)&&n.subscriber&&(this.room.engine.pcManager.subscriber.onIceCandidateError=s=>{s instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(s.errorCode," ").concat(s.errorText," ").concat(s.url))})});try{yield this.connect(),me.info("now the room is connected")}catch(n){throw this.appendWarning("ports need to be open on firewall in order to connect."),n}e||this.appendWarning("Server is not configured for ICE/TCP"),t||this.appendWarning("No public IPv4 UDP candidates were found. Your server is likely not configured correctly")})}}function VB(r){const e=r.split(".");if(e.length===4){if(e[0]==="10")return!0;if(e[0]==="192"&&e[1]==="168")return!0;if(e[0]==="172"){const t=parseInt(e[1],10);if(t>=16&&t<=31)return!0}}return!1}class zB extends Jr{get description(){return"Connecting to signal connection via WebSocket"}perform(){return k(this,void 0,void 0,function*(){var e,t,n;(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let i=new gu,s;try{s=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0)}catch(a){if(as(new URL(this.url))){this.appendMessage("Initial connection failed with error ".concat(a.message,". Retrying with region fallback"));const o=yield new Te(this.url,this.token).getNextBestRegionUrl();o&&(s=yield i.join(o,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0),this.appendMessage("Fallback to region worked. To avoid initial connections failing, ensure you're calling room.prepareConnection() ahead of time"))}}s?(this.appendMessage("Connected to server, version ".concat(s.serverVersion,".")),((e=s.serverInfo)===null||e===void 0?void 0:e.edition)===Bm.Cloud&&(!((t=s.serverInfo)===null||t===void 0)&&t.region)&&this.appendMessage("LiveKit Cloud: ".concat((n=s.serverInfo)===null||n===void 0?void 0:n.region))):this.appendError("Websocket connection could not be established"),yield i.close()})}}class AF extends Yt.EventEmitter{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.options={},this.checkResults=new Map,this.url=e,this.token=t,this.options=n}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:Sn.IDLE,name:"",description:""}),e}updateCheck(e,t){this.checkResults.set(e,t),this.emit("checkUpdate",e,t)}isSuccess(){return Array.from(this.checkResults.values()).every(e=>e.status!==Sn.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return k(this,void 0,void 0,function*(){const t=this.getNextCheckId(),n=new e(this.url,this.token,this.options),i=a=>{this.updateCheck(t,a)};n.on("update",i);const s=yield n.run();return n.off("update",i),s})}checkWebsocket(){return k(this,void 0,void 0,function*(){return this.createAndRunCheck(zB)})}checkWebRTC(){return k(this,void 0,void 0,function*(){return this.createAndRunCheck(KB)})}checkTURN(){return k(this,void 0,void 0,function*(){return this.createAndRunCheck(NB)})}checkReconnect(){return k(this,void 0,void 0,function*(){return this.createAndRunCheck(HB)})}checkPublishAudio(){return k(this,void 0,void 0,function*(){return this.createAndRunCheck(LB)})}checkPublishVideo(){return k(this,void 0,void 0,function*(){return this.createAndRunCheck(OB)})}checkConnectionProtocol(){return k(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(DB);if(e.data&&"protocol"in e.data){const t=e.data;this.options.protocol=t.protocol}return e})}checkCloudRegion(){return k(this,void 0,void 0,function*(){return this.createAndRunCheck(PB)})}}new TextEncoder;new TextDecoder;class Nt extends Error{constructor(e,t){var n;super(e,t),Be(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,(n=Error.captureStackTrace)===null||n===void 0||n.call(Error,this,this.constructor)}}Be(Nt,"code","ERR_JOSE_GENERIC");class GB extends Nt{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:i,payload:t}}),Be(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),Be(this,"claim",void 0),Be(this,"reason",void 0),Be(this,"payload",void 0),this.claim=n,this.reason=i,this.payload=t}}Be(GB,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class qB extends Nt{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"unspecified",i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:i,payload:t}}),Be(this,"code","ERR_JWT_EXPIRED"),Be(this,"claim",void 0),Be(this,"reason",void 0),Be(this,"payload",void 0),this.claim=n,this.reason=i,this.payload=t}}Be(qB,"code","ERR_JWT_EXPIRED");class WB extends Nt{constructor(){super(...arguments),Be(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}Be(WB,"code","ERR_JOSE_ALG_NOT_ALLOWED");class $B extends Nt{constructor(){super(...arguments),Be(this,"code","ERR_JOSE_NOT_SUPPORTED")}}Be($B,"code","ERR_JOSE_NOT_SUPPORTED");class jB extends Nt{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"decryption operation failed",t=arguments.length>1?arguments[1]:void 0;super(e,t),Be(this,"code","ERR_JWE_DECRYPTION_FAILED")}}Be(jB,"code","ERR_JWE_DECRYPTION_FAILED");class XB extends Nt{constructor(){super(...arguments),Be(this,"code","ERR_JWE_INVALID")}}Be(XB,"code","ERR_JWE_INVALID");class JB extends Nt{constructor(){super(...arguments),Be(this,"code","ERR_JWS_INVALID")}}Be(JB,"code","ERR_JWS_INVALID");class YB extends Nt{constructor(){super(...arguments),Be(this,"code","ERR_JWT_INVALID")}}Be(YB,"code","ERR_JWT_INVALID");class ZB extends Nt{constructor(){super(...arguments),Be(this,"code","ERR_JWK_INVALID")}}Be(ZB,"code","ERR_JWK_INVALID");class eC extends Nt{constructor(){super(...arguments),Be(this,"code","ERR_JWKS_INVALID")}}Be(eC,"code","ERR_JWKS_INVALID");class tC extends Nt{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"no applicable key found in the JSON Web Key Set",t=arguments.length>1?arguments[1]:void 0;super(e,t),Be(this,"code","ERR_JWKS_NO_MATCHING_KEY")}}Be(tC,"code","ERR_JWKS_NO_MATCHING_KEY");class nC extends Nt{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"multiple matching keys found in the JSON Web Key Set",t=arguments.length>1?arguments[1]:void 0;super(e,t),Be(this,Symbol.asyncIterator,void 0),Be(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}}Be(nC,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class rC extends Nt{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"request timed out",t=arguments.length>1?arguments[1]:void 0;super(e,t),Be(this,"code","ERR_JWKS_TIMEOUT")}}Be(rC,"code","ERR_JWKS_TIMEOUT");class iC extends Nt{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"signature verification failed",t=arguments.length>1?arguments[1]:void 0;super(e,t),Be(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}Be(iC,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const sC="core-bridge-";function aC(r){return r.replace(/\/$/,"")}function AC(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`call-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}class oC{constructor(e){L(this,"serverUrl");L(this,"agentId");L(this,"callId");L(this,"authToken");L(this,"continuedCallId");L(this,"bridgePrefix");L(this,"onConnected");L(this,"onDisconnected");L(this,"onError");L(this,"room",null);L(this,"audioElements",[]);L(this,"connected",!1);L(this,"disconnecting",!1);if(!e.serverUrl)throw new Error("serverUrl is required");if(!e.agentId)throw new Error("agentId is required");this.serverUrl=aC(e.serverUrl),this.agentId=e.agentId,this.callId=e.callId??AC(),this.authToken=e.token,this.continuedCallId=e.continuedCallId,this.bridgePrefix=e.bridgeIdentityPrefix??sC,this.onConnected=e.onConnected,this.onDisconnected=e.onDisconnected,this.onError=e.onError}get isConnected(){return this.connected}reportError(e){var t;(t=this.onError)==null||t.call(this,e)}cleanupAudioElements(){for(const e of this.audioElements)try{e.pause(),e.srcObject=null,e.remove()}catch{}this.audioElements=[]}attachRemoteAudio(e){if(e.kind!==N.Kind.Audio)return;const t=e.attach();t.autoplay=!0,t.setAttribute("playsinline","true"),t.style.display="none",document.body.appendChild(t),t.play().catch(()=>{}),this.audioElements.push(t)}handleBridgeParticipant(e){e.identity.startsWith(this.bridgePrefix)&&e.trackPublications.forEach(t=>{t.track&&this.attachRemoteAudio(t.track)})}wireRoomEvents(e){e.on(V.TrackSubscribed,(t,n,i)=>{i.identity.startsWith(this.bridgePrefix)&&this.attachRemoteAudio(t)}),e.on(V.Disconnected,()=>{var t;this.connected=!1,this.cleanupAudioElements(),this.disconnecting||(t=this.onDisconnected)==null||t.call(this)})}async fetchLiveKitToken(){const e=new URLSearchParams({agent_id:this.agentId,call_id:this.callId});this.authToken&&e.set("token",this.authToken),this.continuedCallId&&e.set("continued_call_id",this.continuedCallId);const t=await fetch(`${this.serverUrl}/livekit/token?${e.toString()}`);if(!t.ok){const n=await t.text().catch(()=>"");throw new Error(`GET /livekit/token failed (${t.status})${n?`: ${n}`:""}`)}return t.json()}async connect(){var e;if(this.connected||this.room)throw new Error("LiveKitVoiceClient is already connected");this.disconnecting=!1;try{const t=await this.fetchLiveKitToken();t.call_id&&(this.callId=t.call_id);const n=new cs({adaptiveStream:!0,dynacast:!0});this.room=n,this.wireRoomEvents(n),await n.connect(t.url,t.token,{autoSubscribe:!0}),await n.localParticipant.setMicrophoneEnabled(!0);for(const i of n.remoteParticipants.values())this.handleBridgeParticipant(i);return this.connected=!0,(e=this.onConnected)==null||e.call(this,{roomName:t.room_name,identity:t.identity,callId:this.callId}),t}catch(t){if(this.cleanupAudioElements(),this.room)try{this.room.disconnect()}catch{}throw this.room=null,this.connected=!1,this.reportError(t),t}}disconnect(){var t;this.disconnecting=!0,this.connected=!1,this.cleanupAudioElements();const e=this.room;if(this.room=null,e)try{e.disconnect()}catch(n){this.reportError(n)}this.disconnecting=!1,(t=this.onDisconnected)==null||t.call(this)}}class It{constructor(e,t,n,i){this.left=e,this.top=t,this.width=n,this.height=i}add(e,t,n,i){return new It(this.left+e,this.top+t,this.width+n,this.height+i)}static fromClientRect(e,t){return new It(t.left+e.windowBounds.left,t.top+e.windowBounds.top,t.width,t.height)}static fromDOMRectList(e,t){const n=Array.from(t);let i=n.find(s=>s.width!==0);return i||(i=n.find(s=>s.height!==0)),!i&&n.length>0&&(i=n[0]),i?new It(i.left+e.windowBounds.left,i.top+e.windowBounds.top,i.width,i.height):It.EMPTY}}It.EMPTY=new It(0,0,0,0);const Ho=(r,e)=>It.fromClientRect(r,e.getBoundingClientRect()),cC=r=>{const e=r.body,t=r.documentElement;if(!e||!t)throw new Error("Unable to get document size");const n=Math.max(Math.max(e.scrollWidth,t.scrollWidth),Math.max(e.offsetWidth,t.offsetWidth),Math.max(e.clientWidth,t.clientWidth)),i=Math.max(Math.max(e.scrollHeight,t.scrollHeight),Math.max(e.offsetHeight,t.offsetHeight),Math.max(e.clientHeight,t.clientHeight));return new It(0,0,n,i)};var No=function(r){for(var e=[],t=0,n=r.length;t<n;){var i=r.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var s=r.charCodeAt(t++);(s&64512)===56320?e.push(((i&1023)<<10)+(s&1023)+65536):(e.push(i),t--)}else e.push(i)}return e},st=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,r);var t=r.length;if(!t)return"";for(var n=[],i=-1,s="";++i<t;){var a=r[i];a<=65535?n.push(a):(a-=65536,n.push((a>>10)+55296,a%1024+56320)),(i+1===t||n.length>16384)&&(s+=String.fromCharCode.apply(String,n),n.length=0)}return s},Eh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lC=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Pa=0;Pa<Eh.length;Pa++)lC[Eh.charCodeAt(Pa)]=Pa;var Uh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Da=0;Da<Uh.length;Da++)Rs[Uh.charCodeAt(Da)]=Da;var dC=function(r){var e=r.length*.75,t=r.length,n,i=0,s,a,A,o;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);var c=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&typeof Uint8Array.prototype.slice<"u"?new ArrayBuffer(e):new Array(e),l=Array.isArray(c)?c:new Uint8Array(c);for(n=0;n<t;n+=4)s=Rs[r.charCodeAt(n)],a=Rs[r.charCodeAt(n+1)],A=Rs[r.charCodeAt(n+2)],o=Rs[r.charCodeAt(n+3)],l[i++]=s<<2|a>>4,l[i++]=(a&15)<<4|A>>2,l[i++]=(A&3)<<6|o&63;return c},uC=function(r){for(var e=r.length,t=[],n=0;n<e;n+=2)t.push(r[n+1]<<8|r[n]);return t},hC=function(r){for(var e=r.length,t=[],n=0;n<e;n+=4)t.push(r[n+3]<<24|r[n+2]<<16|r[n+1]<<8|r[n]);return t},yi=5,ku=11,Rc=2,fC=ku-yi,t1=65536>>yi,pC=1<<yi,Pc=pC-1,mC=1024>>yi,gC=t1+mC,vC=gC,yC=32,wC=vC+yC,bC=65536>>ku,BC=1<<fC,CC=BC-1,Fh=function(r,e,t){return r.slice?r.slice(e,t):new Uint16Array(Array.prototype.slice.call(r,e,t))},SC=function(r,e,t){return r.slice?r.slice(e,t):new Uint32Array(Array.prototype.slice.call(r,e,t))},kC=function(r,e){var t=dC(r),n=Array.isArray(t)?hC(t):new Uint32Array(t),i=Array.isArray(t)?uC(t):new Uint16Array(t),s=24,a=Fh(i,s/2,n[4]/2),A=n[5]===2?Fh(i,(s+n[4])/2):SC(n,Math.ceil((s+n[4])/4));return new TC(n[0],n[1],n[2],n[3],a,A)},TC=function(){function r(e,t,n,i,s,a){this.initialValue=e,this.errorValue=t,this.highStart=n,this.highValueIndex=i,this.index=s,this.data=a}return r.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>yi],t=(t<<Rc)+(e&Pc),this.data[t];if(e<=65535)return t=this.index[t1+(e-55296>>yi)],t=(t<<Rc)+(e&Pc),this.data[t];if(e<this.highStart)return t=wC-bC+(e>>ku),t=this.index[t],t+=e>>yi&CC,t=this.index[t],t=(t<<Rc)+(e&Pc),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},r}(),Ih="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xC=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var La=0;La<Ih.length;La++)xC[Ih.charCodeAt(La)]=La;var EC="KwAAAAAAAAAACA4AUD0AADAgAAACAAAAAAAIABAAGABAAEgAUABYAGAAaABgAGgAYgBqAF8AZwBgAGgAcQB5AHUAfQCFAI0AlQCdAKIAqgCyALoAYABoAGAAaABgAGgAwgDKAGAAaADGAM4A0wDbAOEA6QDxAPkAAQEJAQ8BFwF1AH0AHAEkASwBNAE6AUIBQQFJAVEBWQFhAWgBcAF4ATAAgAGGAY4BlQGXAZ8BpwGvAbUBvQHFAc0B0wHbAeMB6wHxAfkBAQIJAvEBEQIZAiECKQIxAjgCQAJGAk4CVgJeAmQCbAJ0AnwCgQKJApECmQKgAqgCsAK4ArwCxAIwAMwC0wLbAjAA4wLrAvMC+AIAAwcDDwMwABcDHQMlAy0DNQN1AD0DQQNJA0kDSQNRA1EDVwNZA1kDdQB1AGEDdQBpA20DdQN1AHsDdQCBA4kDkQN1AHUAmQOhA3UAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AKYDrgN1AHUAtgO+A8YDzgPWAxcD3gPjA+sD8wN1AHUA+wMDBAkEdQANBBUEHQQlBCoEFwMyBDgEYABABBcDSARQBFgEYARoBDAAcAQzAXgEgASIBJAEdQCXBHUAnwSnBK4EtgS6BMIEyAR1AHUAdQB1AHUAdQCVANAEYABgAGAAYABgAGAAYABgANgEYADcBOQEYADsBPQE/AQEBQwFFAUcBSQFLAU0BWQEPAVEBUsFUwVbBWAAYgVgAGoFcgV6BYIFigWRBWAAmQWfBaYFYABgAGAAYABgAKoFYACxBbAFuQW6BcEFwQXHBcEFwQXPBdMF2wXjBeoF8gX6BQIGCgYSBhoGIgYqBjIGOgZgAD4GRgZMBmAAUwZaBmAAYABgAGAAYABgAGAAYABgAGAAYABgAGIGYABpBnAGYABgAGAAYABgAGAAYABgAGAAYAB4Bn8GhQZgAGAAYAB1AHcDFQSLBmAAYABgAJMGdQA9A3UAmwajBqsGqwaVALMGuwbDBjAAywbSBtIG1QbSBtIG0gbSBtIG0gbdBuMG6wbzBvsGAwcLBxMHAwcbByMHJwcsBywHMQcsB9IGOAdAB0gHTgfSBkgHVgfSBtIG0gbSBtIG0gbSBtIG0gbSBiwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdgAGAALAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdbB2MHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB2kH0gZwB64EdQB1AHUAdQB1AHUAdQB1AHUHfQdgAIUHjQd1AHUAlQedB2AAYAClB6sHYACzB7YHvgfGB3UAzgfWBzMB3gfmB1EB7gf1B/0HlQENAQUIDQh1ABUIHQglCBcDLQg1CD0IRQhNCEEDUwh1AHUAdQBbCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIcAh3CHoIMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIgggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAALAcsBywHLAcsBywHLAcsBywHLAcsB4oILAcsB44I0gaWCJ4Ipgh1AHUAqgiyCHUAdQB1AHUAdQB1AHUAdQB1AHUAtwh8AXUAvwh1AMUIyQjRCNkI4AjoCHUAdQB1AO4I9gj+CAYJDgkTCS0HGwkjCYIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiAAIAAAAFAAYABgAGIAXwBgAHEAdQBFAJUAogCyAKAAYABgAEIA4ABGANMA4QDxAMEBDwE1AFwBLAE6AQEBUQF4QkhCmEKoQrhCgAHIQsAB0MLAAcABwAHAAeDC6ABoAHDCwMMAAcABwAHAAdDDGMMAAcAB6MM4wwjDWMNow3jDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEjDqABWw6bDqABpg6gAaABoAHcDvwOPA+gAaABfA/8DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DpcPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB9cPKwkyCToJMAB1AHUAdQBCCUoJTQl1AFUJXAljCWcJawkwADAAMAAwAHMJdQB2CX4JdQCECYoJjgmWCXUAngkwAGAAYABxAHUApgn3A64JtAl1ALkJdQDACTAAMAAwADAAdQB1AHUAdQB1AHUAdQB1AHUAowYNBMUIMAAwADAAMADICcsJ0wnZCRUE4QkwAOkJ8An4CTAAMAB1AAAKvwh1AAgKDwoXCh8KdQAwACcKLgp1ADYKqAmICT4KRgowADAAdQB1AE4KMAB1AFYKdQBeCnUAZQowADAAMAAwADAAMAAwADAAMAAVBHUAbQowADAAdQC5CXUKMAAwAHwBxAijBogEMgF9CoQKiASMCpQKmgqIBKIKqgquCogEDQG2Cr4KxgrLCjAAMADTCtsKCgHjCusK8Qr5CgELMAAwADAAMAB1AIsECQsRC3UANAEZCzAAMAAwADAAMAB1ACELKQswAHUANAExCzkLdQBBC0kLMABRC1kLMAAwADAAMAAwADAAdQBhCzAAMAAwAGAAYABpC3ELdwt/CzAAMACHC4sLkwubC58Lpwt1AK4Ltgt1APsDMAAwADAAMAAwADAAMAAwAL4LwwvLC9IL1wvdCzAAMADlC+kL8Qv5C/8LSQswADAAMAAwADAAMAAwADAAMAAHDDAAMAAwADAAMAAODBYMHgx1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1ACYMMAAwADAAdQB1AHUALgx1AHUAdQB1AHUAdQA2DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AD4MdQBGDHUAdQB1AHUAdQB1AEkMdQB1AHUAdQB1AFAMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQBYDHUAdQB1AF8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUA+wMVBGcMMAAwAHwBbwx1AHcMfwyHDI8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAYABgAJcMMAAwADAAdQB1AJ8MlQClDDAAMACtDCwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB7UMLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AA0EMAC9DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAsBywHLAcsBywHLAcsBywHLQcwAMEMyAwsBywHLAcsBywHLAcsBywHLAcsBywHzAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1ANQM2QzhDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMABgAGAAYABgAGAAYABgAOkMYADxDGAA+AwADQYNYABhCWAAYAAODTAAMAAwADAAFg1gAGAAHg37AzAAMAAwADAAYABgACYNYAAsDTQNPA1gAEMNPg1LDWAAYABgAGAAYABgAGAAYABgAGAAUg1aDYsGVglhDV0NcQBnDW0NdQ15DWAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAlQCBDZUAiA2PDZcNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAnw2nDTAAMAAwADAAMAAwAHUArw23DTAAMAAwADAAMAAwADAAMAAwADAAMAB1AL8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQDHDTAAYABgAM8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA1w11ANwNMAAwAD0B5A0wADAAMAAwADAAMADsDfQN/A0EDgwOFA4wABsOMAAwADAAMAAwADAAMAAwANIG0gbSBtIG0gbSBtIG0gYjDigOwQUuDsEFMw7SBjoO0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGQg5KDlIOVg7SBtIGXg5lDm0OdQ7SBtIGfQ6EDooOjQ6UDtIGmg6hDtIG0gaoDqwO0ga0DrwO0gZgAGAAYADEDmAAYAAkBtIGzA5gANIOYADaDokO0gbSBt8O5w7SBu8O0gb1DvwO0gZgAGAAxA7SBtIG0gbSBtIGYABgAGAAYAAED2AAsAUMD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHJA8sBywHLAcsBywHLAccDywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywPLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAc0D9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHPA/SBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gYUD0QPlQCVAJUAMAAwADAAMACVAJUAlQCVAJUAlQCVAEwPMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA//8EAAQABAAEAAQABAAEAAQABAANAAMAAQABAAIABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQACgATABcAHgAbABoAHgAXABYAEgAeABsAGAAPABgAHABLAEsASwBLAEsASwBLAEsASwBLABgAGAAeAB4AHgATAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAGwASAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWAA0AEQAeAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAFAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJABYAGgAbABsAGwAeAB0AHQAeAE8AFwAeAA0AHgAeABoAGwBPAE8ADgBQAB0AHQAdAE8ATwAXAE8ATwBPABYAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwBWAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsABAAbABsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEAA0ADQBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABABQACsAKwArACsAKwArACsAKwAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUAAaABoAUABQAFAAUABQAEwAHgAbAFAAHgAEACsAKwAEAAQABAArAFAAUABQAFAAUABQACsAKwArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQACsAUABQACsAKwAEACsABAAEAAQABAAEACsAKwArACsABAAEACsAKwAEAAQABAArACsAKwAEACsAKwArACsAKwArACsAUABQAFAAUAArAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAAQABABQAFAAUAAEAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAArACsAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AGwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAKwArACsAKwArAAQABAAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAAQAUAArAFAAUABQAFAAUABQACsAKwArAFAAUABQACsAUABQAFAAUAArACsAKwBQAFAAKwBQACsAUABQACsAKwArAFAAUAArACsAKwBQAFAAUAArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAArACsAKwAEAAQABAArAAQABAAEAAQAKwArAFAAKwArACsAKwArACsABAArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAHgAeAB4AHgAeAB4AGwAeACsAKwArACsAKwAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAUABQAFAAKwArACsAKwArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwAOAFAAUABQAFAAUABQAFAAHgBQAAQABAAEAA4AUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAKwArAAQAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAKwArACsAKwArACsAUAArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAXABcAFwAXABcACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAXAArAFwAXABcAFwAXABcAFwAXABcAFwAKgBcAFwAKgAqACoAKgAqACoAKgAqACoAXAArACsAXABcAFwAXABcACsAXAArACoAKgAqACoAKgAqACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwBcAFwAXABcAFAADgAOAA4ADgAeAA4ADgAJAA4ADgANAAkAEwATABMAEwATAAkAHgATAB4AHgAeAAQABAAeAB4AHgAeAB4AHgBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAADQAEAB4ABAAeAAQAFgARABYAEQAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAAQABAAEAAQADQAEAAQAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAA0ADQAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeACsAHgAeAA4ADgANAA4AHgAeAB4AHgAeAAkACQArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgBcAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4AHgAeAB4AXABcAFwAXABcAFwAKgAqACoAKgBcAFwAXABcACoAKgAqAFwAKgAqACoAXABcACoAKgAqACoAKgAqACoAXABcAFwAKgAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwAKgBLAEsASwBLAEsASwBLAEsASwBLACoAKgAqACoAKgAqAFAAUABQAFAAUABQACsAUAArACsAKwArACsAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAKwBQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsABAAEAAQAHgANAB4AHgAeAB4AHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUAArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWABEAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAANAA0AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUAArAAQABAArACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAA0ADQAVAFwADQAeAA0AGwBcACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwAeAB4AEwATAA0ADQAOAB4AEwATAB4ABAAEAAQACQArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAHgArACsAKwATABMASwBLAEsASwBLAEsASwBLAEsASwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAXABcAFwAXABcACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXAArACsAKwAqACoAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsAHgAeAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKwArAAQASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACoAKgAqACoAKgAqACoAXAAqACoAKgAqACoAKgArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABABQAFAAUABQAFAAUABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgANAA0ADQANAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwAeAB4AHgAeAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArAA0ADQANAA0ADQBLAEsASwBLAEsASwBLAEsASwBLACsAKwArAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUAAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAAQAUABQAFAAUABQAFAABABQAFAABAAEAAQAUAArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQACsAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQACsAKwAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQACsAHgAeAB4AHgAeAB4AHgAOAB4AKwANAA0ADQANAA0ADQANAAkADQANAA0ACAAEAAsABAAEAA0ACQANAA0ADAAdAB0AHgAXABcAFgAXABcAFwAWABcAHQAdAB4AHgAUABQAFAANAAEAAQAEAAQABAAEAAQACQAaABoAGgAaABoAGgAaABoAHgAXABcAHQAVABUAHgAeAB4AHgAeAB4AGAAWABEAFQAVABUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ADQAeAA0ADQANAA0AHgANAA0ADQAHAB4AHgAeAB4AKwAEAAQABAAEAAQABAAEAAQABAAEAFAAUAArACsATwBQAFAAUABQAFAAHgAeAB4AFgARAE8AUABPAE8ATwBPAFAAUABQAFAAUAAeAB4AHgAWABEAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArABsAGwAbABsAGwAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGgAbABsAGwAbABoAGwAbABoAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAFAAGgAeAB0AHgBQAB4AGgAeAB4AHgAeAB4AHgAeAB4AHgBPAB4AUAAbAB4AHgBQAFAAUABQAFAAHgAeAB4AHQAdAB4AUAAeAFAAHgBQAB4AUABPAFAAUAAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgBQAFAAUABQAE8ATwBQAFAAUABQAFAATwBQAFAATwBQAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAUABQAFAATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABPAB4AHgArACsAKwArAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAdAB4AHgAeAB0AHQAeAB4AHQAeAB4AHgAdAB4AHQAbABsAHgAdAB4AHgAeAB4AHQAeAB4AHQAdAB0AHQAeAB4AHQAeAB0AHgAdAB0AHQAdAB0AHQAeAB0AHgAeAB4AHgAeAB0AHQAdAB0AHgAeAB4AHgAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB0AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAdAB0AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHQAdAB0AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHQAdAB4AHgAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AJQAlAB0AHQAlAB4AJQAlACUAIAAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAeAB0AJQAdAB0AHgAdAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAdAB0AHQAdACUAHgAlACUAJQAdACUAJQAdAB0AHQAlACUAHQAdACUAHQAdACUAJQAlAB4AHQAeAB4AHgAeAB0AHQAlAB0AHQAdAB0AHQAdACUAJQAlACUAJQAdACUAJQAgACUAHQAdACUAJQAlACUAJQAlACUAJQAeAB4AHgAlACUAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AFwAXABcAFwAXABcAHgATABMAJQAeAB4AHgAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARABYAEQAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANAA0AHgANAB4ADQANAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwAlACUAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACsAKwArACsAKwArACsAKwArACsAKwArAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBPAE8ATwBPAE8ATwBPAE8AJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeAAQAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUABQAAQAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAUABQAFAAUABQAAQABAAEACsABAAEACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAKwBQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAA0ADQANAA0ADQANAA0ADQAeACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAArACsAKwArAFAAUABQAFAAUAANAA0ADQANAA0ADQAUACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQANAA0ADQANAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAANACsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAB4AHgAeAB4AHgArACsAKwArACsAKwAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANAFAABAAEAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAEAAQABAAEAB4ABAAEAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsABAAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLAA0ADQArAB4ABABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUAAeAFAAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAAEAAQADgANAA0AEwATAB4AHgAeAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAFAAUABQAFAABAAEACsAKwAEAA0ADQAeAFAAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcAFwADQANAA0AKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQAKwAEAAQAKwArAAQABAAEAAQAUAAEAFAABAAEAA0ADQANACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABABQAA4AUAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANAFAADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAaABoAGgAaAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAJAAkACQAJAAkACQAJABYAEQArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AHgAeACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAARwBHABUARwAJACsAKwArACsAKwArACsAKwArACsAKwAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAKwArACsAKwArACsAKwArACsAKwArACsAKwBRAFEAUQBRACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAHgAEAAQADQAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAeAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQAHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAKwArAFAAKwArAFAAUAArACsAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAHgAeAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeACsAKwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4ABAAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAHgAeAA0ADQANAA0AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArAAQABAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwBQAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArABsAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAB4AHgAeAB4ABAAEAAQABAAEAAQABABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArABYAFgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAGgBQAFAAUAAaAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUAArACsAKwArACsAKwBQACsAKwArACsAUAArAFAAKwBQACsAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUAArAFAAKwBQACsAUAArAFAAUAArAFAAKwArAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAKwBQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeACUAJQAlAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAHgAlACUAJQAlACUAIAAgACAAJQAlACAAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACEAIQAhACEAIQAlACUAIAAgACUAJQAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAlACUAJQAlACAAIAAgACUAIAAgACAAJQAlACUAJQAlACUAJQAgACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAlAB4AJQAeACUAJQAlACUAJQAgACUAJQAlACUAHgAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACAAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABcAFwAXABUAFQAVAB4AHgAeAB4AJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAgACUAJQAgACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAIAAgACUAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACAAIAAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACAAIAAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAA==",Qh=50,UC=1,n1=2,r1=3,FC=4,IC=5,Mh=7,i1=8,_h=9,Or=10,id=11,Rh=12,sd=13,QC=14,Ps=15,ad=16,Oa=17,ks=18,MC=19,Ph=20,Ad=21,Ts=22,Dc=23,Mi=24,nn=25,Ds=26,Ls=27,_i=28,_C=29,ui=30,RC=31,Ha=32,Na=33,od=34,cd=35,ld=36,ga=37,dd=38,xA=39,EA=40,Lc=41,s1=42,PC=43,DC=[9001,65288],a1="!",Se="×",Ka="÷",ud=kC(EC),sr=[ui,ld],hd=[UC,n1,r1,IC],A1=[Or,i1],Dh=[Ls,Ds],LC=hd.concat(A1),Lh=[dd,xA,EA,od,cd],OC=[Ps,sd],HC=function(r,e){e===void 0&&(e="strict");var t=[],n=[],i=[];return r.forEach(function(s,a){var A=ud.get(s);if(A>Qh?(i.push(!0),A-=Qh):i.push(!1),["normal","auto","loose"].indexOf(e)!==-1&&[8208,8211,12316,12448].indexOf(s)!==-1)return n.push(a),t.push(ad);if(A===FC||A===id){if(a===0)return n.push(a),t.push(ui);var o=t[a-1];return LC.indexOf(o)===-1?(n.push(n[a-1]),t.push(o)):(n.push(a),t.push(ui))}if(n.push(a),A===RC)return t.push(e==="strict"?Ad:ga);if(A===s1||A===_C)return t.push(ui);if(A===PC)return s>=131072&&s<=196605||s>=196608&&s<=262141?t.push(ga):t.push(ui);t.push(A)}),[n,t,i]},Oc=function(r,e,t,n){var i=n[t];if(Array.isArray(r)?r.indexOf(i)!==-1:r===i)for(var s=t;s<=n.length;){s++;var a=n[s];if(a===e)return!0;if(a!==Or)break}if(i===Or)for(var s=t;s>0;){s--;var A=n[s];if(Array.isArray(r)?r.indexOf(A)!==-1:r===A)for(var o=t;o<=n.length;){o++;var a=n[o];if(a===e)return!0;if(a!==Or)break}if(A!==Or)break}return!1},Oh=function(r,e){for(var t=r;t>=0;){var n=e[t];if(n===Or)t--;else return n}return 0},NC=function(r,e,t,n,i){if(t[n]===0)return Se;var s=n-1;if(Array.isArray(i)&&i[s]===!0)return Se;var a=s-1,A=s+1,o=e[s],c=a>=0?e[a]:0,l=e[A];if(o===n1&&l===r1)return Se;if(hd.indexOf(o)!==-1)return a1;if(hd.indexOf(l)!==-1||A1.indexOf(l)!==-1)return Se;if(Oh(s,e)===i1)return Ka;if(ud.get(r[s])===id||(o===Ha||o===Na)&&ud.get(r[A])===id||o===Mh||l===Mh||o===_h||[Or,sd,Ps].indexOf(o)===-1&&l===_h||[Oa,ks,MC,Mi,_i].indexOf(l)!==-1||Oh(s,e)===Ts||Oc(Dc,Ts,s,e)||Oc([Oa,ks],Ad,s,e)||Oc(Rh,Rh,s,e))return Se;if(o===Or)return Ka;if(o===Dc||l===Dc)return Se;if(l===ad||o===ad)return Ka;if([sd,Ps,Ad].indexOf(l)!==-1||o===QC||c===ld&&OC.indexOf(o)!==-1||o===_i&&l===ld||l===Ph||sr.indexOf(l)!==-1&&o===nn||sr.indexOf(o)!==-1&&l===nn||o===Ls&&[ga,Ha,Na].indexOf(l)!==-1||[ga,Ha,Na].indexOf(o)!==-1&&l===Ds||sr.indexOf(o)!==-1&&Dh.indexOf(l)!==-1||Dh.indexOf(o)!==-1&&sr.indexOf(l)!==-1||[Ls,Ds].indexOf(o)!==-1&&(l===nn||[Ts,Ps].indexOf(l)!==-1&&e[A+1]===nn)||[Ts,Ps].indexOf(o)!==-1&&l===nn||o===nn&&[nn,_i,Mi].indexOf(l)!==-1)return Se;if([nn,_i,Mi,Oa,ks].indexOf(l)!==-1)for(var d=s;d>=0;){var u=e[d];if(u===nn)return Se;if([_i,Mi].indexOf(u)!==-1)d--;else break}if([Ls,Ds].indexOf(l)!==-1)for(var d=[Oa,ks].indexOf(o)!==-1?a:s;d>=0;){var u=e[d];if(u===nn)return Se;if([_i,Mi].indexOf(u)!==-1)d--;else break}if(dd===o&&[dd,xA,od,cd].indexOf(l)!==-1||[xA,od].indexOf(o)!==-1&&[xA,EA].indexOf(l)!==-1||[EA,cd].indexOf(o)!==-1&&l===EA||Lh.indexOf(o)!==-1&&[Ph,Ds].indexOf(l)!==-1||Lh.indexOf(l)!==-1&&o===Ls||sr.indexOf(o)!==-1&&sr.indexOf(l)!==-1||o===Mi&&sr.indexOf(l)!==-1||sr.concat(nn).indexOf(o)!==-1&&l===Ts&&DC.indexOf(r[A])===-1||sr.concat(nn).indexOf(l)!==-1&&o===ks)return Se;if(o===Lc&&l===Lc){for(var h=t[s],p=1;h>0&&(h--,e[h]===Lc);)p++;if(p%2!==0)return Se}return o===Ha&&l===Na?Se:Ka},KC=function(r,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=HC(r,e.lineBreak),n=t[0],i=t[1],s=t[2];(e.wordBreak==="break-all"||e.wordBreak==="break-word")&&(i=i.map(function(A){return[nn,ui,s1].indexOf(A)!==-1?ga:A}));var a=e.wordBreak==="keep-all"?s.map(function(A,o){return A&&r[o]>=19968&&r[o]<=40959}):void 0;return[n,i,a]},VC=function(){function r(e,t,n,i){this.codePoints=e,this.required=t===a1,this.start=n,this.end=i}return r.prototype.slice=function(){return st.apply(void 0,this.codePoints.slice(this.start,this.end))},r}(),zC=function(r,e){var t=No(r),n=KC(t,e),i=n[0],s=n[1],a=n[2],A=t.length,o=0,c=0;return{next:function(){if(c>=A)return{done:!0,value:null};for(var l=Se;c<A&&(l=NC(t,s,i,++c,a))===Se;);if(l!==Se||c===A){var d=new VC(t,l,o,c);return o=c,{value:d,done:!1}}return{done:!0,value:null}}}};const GC=1,qC=2,ds=4,Hh=8,io=10,Nh=47,Ys=92,WC=9,$C=32,Va=34,xs=61,jC=35,XC=36,JC=37,za=39,Ga=40,Es=41,YC=95,qt=45,ZC=33,e5=60,t5=62,n5=64,r5=91,i5=93,s5=61,a5=123,qa=63,A5=125,Kh=124,o5=126,c5=128,Vh=65533,Hc=42,hi=43,l5=44,d5=58,u5=59,va=46,h5=0,f5=8,p5=11,m5=14,g5=31,v5=127,Hn=-1,o1=48,c1=97,l1=101,y5=102,w5=117,b5=122,d1=65,u1=69,h1=70,B5=85,C5=90,Ut=r=>r>=o1&&r<=57,S5=r=>r>=55296&&r<=57343,Ri=r=>Ut(r)||r>=d1&&r<=h1||r>=c1&&r<=y5,k5=r=>r>=c1&&r<=b5,T5=r=>r>=d1&&r<=C5,x5=r=>k5(r)||T5(r),E5=r=>r>=c5,Wa=r=>r===io||r===WC||r===$C,so=r=>x5(r)||E5(r)||r===YC,zh=r=>so(r)||Ut(r)||r===qt,U5=r=>r>=h5&&r<=f5||r===p5||r>=m5&&r<=g5||r===v5,Mr=(r,e)=>r!==Ys?!1:e!==io,$a=(r,e,t)=>r===qt?so(e)||Mr(e,t):so(r)?!0:!!(r===Ys&&Mr(r,e)),Nc=(r,e,t)=>r===hi||r===qt?Ut(e)?!0:e===va&&Ut(t):Ut(r===va?e:r),F5=r=>{let e=0,t=1;(r[e]===hi||r[e]===qt)&&(r[e]===qt&&(t=-1),e++);const n=[];for(;Ut(r[e]);)n.push(r[e++]);const i=n.length?parseInt(st(...n),10):0;r[e]===va&&e++;const s=[];for(;Ut(r[e]);)s.push(r[e++]);const a=s.length,A=a?parseInt(st(...s),10):0;(r[e]===u1||r[e]===l1)&&e++;let o=1;(r[e]===hi||r[e]===qt)&&(r[e]===qt&&(o=-1),e++);const c=[];for(;Ut(r[e]);)c.push(r[e++]);const l=c.length?parseInt(st(...c),10):0;return t*(i+A*Math.pow(10,-a))*Math.pow(10,o*l)},I5={type:2},Q5={type:3},M5={type:4},_5={type:13},R5={type:8},P5={type:21},D5={type:9},L5={type:10},O5={type:11},H5={type:12},N5={type:14},ja={type:23},K5={type:1},V5={type:25},z5={type:24},G5={type:26},q5={type:27},W5={type:28},$5={type:29},j5={type:31},fd={type:32};class f1{constructor(){this._value=[]}write(e){this._value=this._value.concat(No(e))}read(){const e=[];let t=this.consumeToken();for(;t!==fd;)e.push(t),t=this.consumeToken();return e}consumeToken(){const e=this.consumeCodePoint();switch(e){case Va:return this.consumeStringToken(Va);case jC:const t=this.peekCodePoint(0),n=this.peekCodePoint(1),i=this.peekCodePoint(2);if(zh(t)||Mr(n,i)){const h=$a(t,n,i)?qC:GC;return{type:5,value:this.consumeName(),flags:h}}break;case XC:if(this.peekCodePoint(0)===xs)return this.consumeCodePoint(),_5;break;case za:return this.consumeStringToken(za);case Ga:return I5;case Es:return Q5;case Hc:if(this.peekCodePoint(0)===xs)return this.consumeCodePoint(),N5;break;case hi:if(Nc(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case l5:return M5;case qt:const s=e,a=this.peekCodePoint(0),A=this.peekCodePoint(1);if(Nc(s,a,A))return this.reconsumeCodePoint(e),this.consumeNumericToken();if($a(s,a,A))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(a===qt&&A===t5)return this.consumeCodePoint(),this.consumeCodePoint(),z5;break;case va:if(Nc(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Nh:if(this.peekCodePoint(0)===Hc)for(this.consumeCodePoint();;){let h=this.consumeCodePoint();if(h===Hc&&(h=this.consumeCodePoint(),h===Nh))return this.consumeToken();if(h===Hn)return this.consumeToken()}break;case d5:return G5;case u5:return q5;case e5:if(this.peekCodePoint(0)===ZC&&this.peekCodePoint(1)===qt&&this.peekCodePoint(2)===qt)return this.consumeCodePoint(),this.consumeCodePoint(),V5;break;case n5:const o=this.peekCodePoint(0),c=this.peekCodePoint(1),l=this.peekCodePoint(2);if($a(o,c,l))return{type:7,value:this.consumeName()};break;case r5:return W5;case Ys:if(Mr(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case i5:return $5;case s5:if(this.peekCodePoint(0)===xs)return this.consumeCodePoint(),R5;break;case a5:return O5;case A5:return H5;case w5:case B5:const d=this.peekCodePoint(0),u=this.peekCodePoint(1);return d===hi&&(Ri(u)||u===qa)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case Kh:if(this.peekCodePoint(0)===xs)return this.consumeCodePoint(),D5;if(this.peekCodePoint(0)===Kh)return this.consumeCodePoint(),P5;break;case o5:if(this.peekCodePoint(0)===xs)return this.consumeCodePoint(),L5;break;case Hn:return fd}return Wa(e)?(this.consumeWhiteSpace(),j5):Ut(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):so(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:st(e)}}consumeCodePoint(){const e=this._value.shift();return typeof e>"u"?-1:e}reconsumeCodePoint(e){this._value.unshift(e)}peekCodePoint(e){return e>=this._value.length?-1:this._value[e]}consumeUnicodeRangeToken(){const e=[];let t=this.consumeCodePoint();for(;Ri(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();let n=!1;for(;t===qa&&e.length<6;)e.push(t),t=this.consumeCodePoint(),n=!0;if(n){const s=parseInt(st(...e.map(A=>A===qa?o1:A)),16),a=parseInt(st(...e.map(A=>A===qa?h1:A)),16);return{type:30,start:s,end:a}}const i=parseInt(st(...e),16);if(this.peekCodePoint(0)===qt&&Ri(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();const s=[];for(;Ri(t)&&s.length<6;)s.push(t),t=this.consumeCodePoint();const a=parseInt(st(...s),16);return{type:30,start:i,end:a}}else return{type:30,start:i,end:i}}consumeIdentLikeToken(){const e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===Ga?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===Ga?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}}consumeUrlToken(){const e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Hn)return{type:22,value:""};const t=this.peekCodePoint(0);if(t===za||t===Va){const n=this.consumeStringToken(this.consumeCodePoint());return n.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Hn||this.peekCodePoint(0)===Es)?(this.consumeCodePoint(),{type:22,value:n.value}):(this.consumeBadUrlRemnants(),ja)}for(;;){const n=this.consumeCodePoint();if(n===Hn||n===Es)return{type:22,value:st(...e)};if(Wa(n))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Hn||this.peekCodePoint(0)===Es?(this.consumeCodePoint(),{type:22,value:st(...e)}):(this.consumeBadUrlRemnants(),ja);if(n===Va||n===za||n===Ga||U5(n))return this.consumeBadUrlRemnants(),ja;if(n===Ys)if(Mr(n,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),ja;else e.push(n)}}consumeWhiteSpace(){for(;Wa(this.peekCodePoint(0));)this.consumeCodePoint()}consumeBadUrlRemnants(){for(;;){const e=this.consumeCodePoint();if(e===Es||e===Hn)return;Mr(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}}consumeStringSlice(e){let n="";for(;e>0;){const i=Math.min(5e4,e);n+=st(...this._value.splice(0,i)),e-=i}return this._value.shift(),n}consumeStringToken(e){let t="",n=0;do{const i=this._value[n];if(i===Hn||i===void 0||i===e)return t+=this.consumeStringSlice(n),{type:0,value:t};if(i===io)return this._value.splice(0,n),K5;if(i===Ys){const s=this._value[n+1];s!==Hn&&s!==void 0&&(s===io?(t+=this.consumeStringSlice(n),n=-1,this._value.shift()):Mr(i,s)&&(t+=this.consumeStringSlice(n),t+=st(this.consumeEscapedCodePoint()),n=-1))}n++}while(!0)}consumeNumber(){const e=[];let t=ds,n=this.peekCodePoint(0);for((n===hi||n===qt)&&e.push(this.consumeCodePoint());Ut(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);let i=this.peekCodePoint(1);if(n===va&&Ut(i))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=Hh;Ut(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0),i=this.peekCodePoint(1);const s=this.peekCodePoint(2);if((n===u1||n===l1)&&((i===hi||i===qt)&&Ut(s)||Ut(i)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=Hh;Ut(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[F5(e),t]}consumeNumericToken(){const[e,t]=this.consumeNumber(),n=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if($a(n,i,s)){const a=this.consumeName();return{type:15,number:e,flags:t,unit:a}}return n===JC?(this.consumeCodePoint(),{type:16,number:e,flags:t}):{type:17,number:e,flags:t}}consumeEscapedCodePoint(){const e=this.consumeCodePoint();if(Ri(e)){let t=st(e);for(;Ri(this.peekCodePoint(0))&&t.length<6;)t+=st(this.consumeCodePoint());Wa(this.peekCodePoint(0))&&this.consumeCodePoint();const n=parseInt(t,16);return n===0||S5(n)||n>1114111?Vh:n}return e===Hn?Vh:e}consumeName(){let e="";for(;;){const t=this.consumeCodePoint();if(zh(t))e+=st(t);else if(Mr(t,this.peekCodePoint(0)))e+=st(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}}}let p1=class UA{constructor(e){this._tokens=e}static create(e){const t=new f1;return t.write(e),new UA(t.read())}static parseValue(e){return UA.create(e).parseComponentValue()}static parseValues(e){return UA.create(e).parseComponentValues()}parseComponentValue(){let e=this.consumeToken();for(;e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);const t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")}parseComponentValues(){const e=[];for(;;){const t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}}consumeComponentValue(){const e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e}consumeSimpleBlock(e){const t={type:e,values:[]};let n=this.consumeToken();for(;;){if(n.type===32||J5(n,e))return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue()),n=this.consumeToken()}}consumeFunction(e){const t={name:e.value,values:[],type:18};for(;;){const n=this.consumeToken();if(n.type===32||n.type===3)return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue())}}consumeToken(){const e=this._tokens.shift();return typeof e>"u"?fd:e}reconsumeToken(e){this._tokens.unshift(e)}};const Yn=r=>r.type===15,lt=r=>r.type===17,ve=r=>r.type===20,X5=r=>r.type===0,ya=(r,e)=>ve(r)&&r.value===e,Ko=r=>r.type!==31,Et=r=>r.type!==31&&r.type!==4,Pn=r=>{const e=[];let t=[];return r.forEach(n=>{if(n.type===4){if(t.length===0)throw new Error("Error parsing function args, zero tokens for arg");e.push(t),t=[];return}n.type!==31&&t.push(n)}),t.length&&e.push(t),e},J5=(r,e)=>e===11&&r.type===12||e===28&&r.type===29?!0:e===2&&r.type===3,rt=(r,e,t)=>Math.min(Math.max(r,e),t),Jt=(r,e)=>[r[0]*e[0]+r[1]*e[1]+r[2]*e[2],r[3]*e[0]+r[4]*e[1]+r[5]*e[2],r[6]*e[0]+r[7]*e[1]+r[8]*e[2]],Yr=r=>Jt([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],r),pd=r=>Jt([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],r),Ti=r=>r.map(e=>{const t=e<0?-1:1,n=Math.abs(e);return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),md=r=>r.map(e=>{const t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),Y5=r=>{const[e,t,n]=Ti(Yr([r[0],r[1],r[2]]));return[e,t,n,r[3]]},Z5=r=>{const[e,t,n]=Yr([r[0],r[1],r[2]]);return[rt(Math.round(e*255),0,255),rt(Math.round(t*255),0,255),rt(Math.round(n*255),0,255),r[3]]},Wr=r=>r.type===17||r.type===15,Qe=r=>r.type===16||Wr(r),e3=r=>r.type===18&&r.name==="calc",t3=(r,e=0)=>{const t=n=>{let i="";for(const s of n)if(s.type!==31){if(s.type===18)if(s.name==="calc"){const a=t(s.values);if(a===null)return null;i+=`(${a})`}else return null;else if(s.type===17)i+=s.number.toString();else if(s.type===15)s.unit==="px"?i+=s.number.toString():s.unit==="rem"||s.unit==="em"?i+=(s.number*16).toString():i+=s.number.toString();else if(s.type===16)i+=(s.number/100*e).toString();else if(s.type===6){const a=s.value;a==="+"||a==="-"||a==="*"||a==="/"?i+=` ${a} `:a==="("?i+="(":a===")"&&(i+=")")}}return i};try{const n=t(r.values);if(n===null||n.trim()==="")return null;const i=new Function("return "+n)();if(typeof i=="number"&&!isNaN(i))return{type:17,number:i,flags:ds}}catch{return null}return null},m1=r=>r.length>1?[r[0],r[1]]:[r[0]],ut={type:17,number:0,flags:ds},fi={type:16,number:50,flags:ds},qn={type:16,number:100,flags:ds},Os=(r,e,t)=>{const[n,i]=r;return[fe(n,e),fe(typeof i<"u"?i:n,t)]},fe=(r,e)=>{if(r.type===16)return r.number/100*e;if(Yn(r))switch(r.unit){case"rem":case"em":return 16*r.number;case"px":default:return r.number}return r.number},g1="deg",v1="grad",y1="rad",w1="turn",us={name:"angle",parse:(r,e)=>{if(e.type===15)switch(e.unit){case g1:return Math.PI*e.number/180;case v1:return Math.PI/200*e.number;case y1:return e.number;case w1:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},b1=r=>r.type===15&&(r.unit===g1||r.unit===v1||r.unit===y1||r.unit===w1),B1=r=>{switch(r.filter(ve).map(t=>t.value).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[ut,ut];case"to top":case"bottom":return fn(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[ut,qn];case"to right":case"left":return fn(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[qn,qn];case"to bottom":case"top":return fn(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[qn,ut];case"to left":case"right":return fn(270)}return 0},fn=r=>Math.PI*r/180,Vr=r=>(255&r)===0,Oe=r=>{const e=255&r,t=255&r>>8,n=255&r>>16,i=255&r>>24;return e<255?`rgba(${i},${n},${t},${e/255})`:`rgb(${i},${n},${t})`},_n=(r,e,t,n)=>(r<<24|e<<16|t<<8|Math.round(n*255)<<0)>>>0,_r=(r,e)=>{if(r.type===17)return r.number;if(r.type===16){const t=e===3?1:255;return e===3?r.number/100*t:Math.round(r.number/100*t)}return 0},xi=r=>(r[0].type===20?r[0].value:"unknown")==="from",n3=r=>_n(rt(Math.round(r[0]*255),0,255),rt(Math.round(r[1]*255),0,255),rt(Math.round(r[2]*255),0,255),rt(r[3],0,1)),Tu=([r,e,t,n])=>{const i=Ti([r,e,t]);return _n(rt(Math.round(i[0]*255),0,255),rt(Math.round(i[1]*255),0,255),rt(Math.round(i[2]*255),0,255),n)},xa=r=>{const e=Yr([r[0],r[1],r[2]]);return Tu([e[0],e[1],e[2],r[3]])},r3=(r,e)=>{if(xi(e.filter(Et)))throw new Error("Relative color not supported for lab()");const[t,n,i,s]=Vo(e),a=Ti(Yr(qo([t,n,i])));return _n(rt(Math.round(a[0]*255),0,255),rt(Math.round(a[1]*255),0,255),rt(Math.round(a[2]*255),0,255),s)},i3=(r,e)=>{if(xi(e.filter(Et)))throw new Error("Relative color not supported for oklab()");const[t,n,i,s]=Vo(e),a=Ti(Yr(Go([t,n,i])));return _n(rt(Math.round(a[0]*255),0,255),rt(Math.round(a[1]*255),0,255),rt(Math.round(a[2]*255),0,255),s)},s3=(r,e)=>{if(xi(e.filter(Et)))throw new Error("Relative color not supported for oklch()");const[t,n,i,s]=k1(e),a=Ti(Yr(Go(zo([t,n,i]))));return _n(rt(Math.round(a[0]*255),0,255),rt(Math.round(a[1]*255),0,255),rt(Math.round(a[2]*255),0,255),s)},a3=(r,e)=>{if(xi(e.filter(Et)))throw new Error("Relative color not supported for lch()");const[t,n,i,s]=S1(e),a=Ti(Yr(qo(zo([t,n,i]))));return _n(rt(Math.round(a[0]*255),0,255),rt(Math.round(a[1]*255),0,255),rt(Math.round(a[2]*255),0,255),s)},C1=(r,e)=>{const t=e.filter(Et),[n,i,s,a]=t,A=(n.type===17?fn(n.number):us.parse(r,n))/(Math.PI*2),o=Qe(i)?i.number/100:0,c=Qe(s)?s.number/100:0,l=typeof a<"u"&&Qe(a)?fe(a,1):1;return[A,o,c,l]},Gh=(r,e)=>{if(xi(e))throw new Error("Relative color not supported for hsl()");const[t,n,i,s]=C1(r,e),a=x1([t,n,i]);return _n(a[0]*255,a[1]*255,a[2]*255,n===0?1:s)},S1=r=>{const e=r.filter(Et),t=Qe(e[0])?e[0].number:0,n=Qe(e[1])?e[1].number:0,i=lt(e[2])||Yn(e[2])?e[2].number:0,s=typeof e[4]<"u"&&Qe(e[4])?fe(e[4],1):1;return[t,n,i,s]},Vo=r=>{const e=r.filter(Et),t=e[0].type===16?e[0].number/100:lt(e[0])?e[0].number:0,n=e[1].type===16?e[1].number/100:lt(e[1])?e[1].number:0,i=lt(e[2])||Yn(e[2])?e[2].number:0,s=typeof e[4]<"u"&&Qe(e[4])?fe(e[4],1):1;return[t,n,i,s]},k1=r=>{const e=r.filter(Et),t=e[0].type===16?e[0].number/100:lt(e[0])?e[0].number:0,n=e[1].type===16?e[1].number/100:lt(e[1])?e[1].number:0,i=lt(e[2])||Yn(e[2])?e[2].number:0,s=typeof e[4]<"u"&&Qe(e[4])?fe(e[4],1):1;return[t,n,i,s]},T1=r=>Jt([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],r),xu=r=>Jt([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],r),Kc=(r,e,t)=>(t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-r)*t*6+r:t<1/2?e:t<2/3?(e-r)*6*(2/3-t)+r:r),x1=([r,e,t])=>{if(e===0)return[t*255,t*255,t*255];const n=t<=.5?t*(e+1):t+e-t*e,i=t*2-n,s=Kc(i,n,r+1/3),a=Kc(i,n,r),A=Kc(i,n,r-1/3);return[s,a,A]},zo=([r,e,t])=>(e<0&&(e=0),isNaN(t)&&(t=0),[r,e*Math.cos(t*Math.PI/180),e*Math.sin(t*Math.PI/180)]),Go=r=>{const e=Jt([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],r),t=e.map(n=>n**3);return Jt([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],t)},qo=r=>{const e=(r[0]+16)/116,t=r[1]/500+e,n=e-r[2]/200,i=24389/27,s=24/116,a=[(t>s?t**3:(116*t-16)/i)*.3457/.3585,r[0]>8?e**3:r[0]/i,(n>s?n**3:(116*n-16)/i)*(1-.3457-.3585)/.3585];return xu([a[0],a[1],a[2]])},A3=(r,e)=>{const t=e.filter(Et);if(t.length===3){const[n,i,s]=t.map(_r),a=md([n/255,i/255,s/255]),[A,o,c]=pd([a[0],a[1],a[2]]);return[A,o,c,1]}if(t.length===4){const[n,i,s,a]=t.map(_r),A=md([n/255,i/255,s/255]),[o,c,l]=pd([A[0],A[1],A[2]]);return[o,c,l,a]}return[0,0,0,1]},o3=(r,e)=>{const[t,n,i,s]=C1(r,e),a=md(x1([t,n,i])),[A,o,c]=pd([a[0],a[1],a[2]]);return[A,o,c,s]},c3=(r,e)=>{const[t,n,i,s]=Vo(e),[a,A,o]=qo([t,n,i]);return[a,A,o,s]},l3=(r,e)=>{const[t,n,i,s]=S1(e),[a,A,o]=qo(zo([t,n,i]));return[a,A,o,s]},d3=(r,e)=>{const[t,n,i,s]=k1(e),[a,A,o]=Go(zo([t,n,i]));return[a,A,o,s]},u3=(r,e)=>{const[t,n,i,s]=Vo(e),[a,A,o]=Go([t,n,i]);return[a,A,o,s]},h3=r=>xu([r[0],r[1],r[2]]),qh=r=>r,f3=r=>{const[e,t,n]=T1([r[0],r[2],r[3]]);return[e,t,n,r[3]]},Wh=r=>xa([r[0],r[1],r[2],r[3]]),p3=r=>{const e=h3([r[0],r[1],r[2]]);return xa([e[0],e[1],e[2],r[3]])},m3=r=>Jt([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],r),g3=r=>Jt([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],r),v3=r=>r.map(e=>{const t=e<0?-1:1;return e*t<=.04045?e/12.92:t*((e+.055)/1.055)**2.4||0}),y3=r=>Ti(r),w3=r=>{const e=v3([r[0],r[1],r[2]]);return m3([e[0],e[1],e[2]])},b3=r=>{const[e,t,n]=y3(g3([r[0],r[1],r[2]]));return[e,t,n,r[3]]},B3=r=>{const e=w3([r[0],r[1],r[2]]);return xa([e[0],e[1],e[2],r[3]])},C3=r=>Jt([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],r),S3=r=>Jt([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],r),k3=r=>{const e=r.map(t=>{const n=t<0?-1:1,i=Math.abs(t);return n*i**2.19921875});return[e[0],e[1],e[2]]},T3=r=>{const e=r.map(t=>{const n=t<0?-1:1,i=Math.abs(t);return n*i**.4547069271758437});return[e[0],e[1],e[2]]},x3=r=>{const[e,t,n]=T3(C3([r[0],r[1],r[2]]));return[e,t,n,r[3]]},E3=r=>{const e=Yr(S3(k3([r[0],r[1],r[2]])));return Tu([e[0],e[1],e[2],r[3]])},U3=r=>Jt([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],r),F3=r=>Jt([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],r),I3=r=>r.map(e=>e<16/512?e/16:e**1.8),Q3=r=>r.map(e=>e>1/512?e**(1/1.8):e*16),M3=r=>{const e=I3([r[0],r[1],r[2]]);return xu(U3([e[0],e[1],e[2]]))},_3=r=>{const[e,t,n]=Q3(F3(T1([r[0],r[1],r[2]])));return[e,t,n,r[3]]},R3=r=>{const e=M3([r[0],r[1],r[2]]);return xa([e[0],e[1],e[2],r[3]])},ao=1.09929682680944,E1=.018053968510807,P3=r=>r.map(function(e){return e<E1*4.5?e/4.5:Math.pow((e+ao-1)/ao,1/.45)}),D3=r=>r.map(function(e){return e>=E1?ao*Math.pow(e,.45)-(ao-1):4.5*e}),L3=r=>Jt([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],r),O3=r=>Jt([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],r),H3=r=>{const e=P3([r[0],r[1],r[2]]);return L3([e[0],e[1],e[2]])},N3=r=>{const[e,t,n]=D3(O3([r[0],r[1],r[2]]));return[e,t,n,r[3]]},K3=r=>{const e=H3([r[0],r[1],r[2]]);return xa([e[0],e[1],e[2],r[3]])},zr={name:"color",parse:(r,e)=>{if(e.type===18){const t=q3[e.name];if(typeof t>"u")throw new Error(`Attempting to parse an unsupported color function "${e.name}"`);return t(r,e.values)}if(e.type===5){const[t,n,i,s]=U1(e);return _n(t,n,i,s)}if(e.type===20){const t=jn[e.value.toUpperCase()];if(typeof t<"u")return t}return jn.TRANSPARENT}},U1=r=>{if(r.value.length===3){const e=r.value.substring(0,1),t=r.value.substring(1,2),n=r.value.substring(2,3);return[parseInt(e+e,16),parseInt(t+t,16),parseInt(n+n,16),1]}if(r.value.length===4){const e=r.value.substring(0,1),t=r.value.substring(1,2),n=r.value.substring(2,3),i=r.value.substring(3,4);return[parseInt(e+e,16),parseInt(t+t,16),parseInt(n+n,16),parseInt(i+i,16)/255]}if(r.value.length===6){const e=r.value.substring(0,2),t=r.value.substring(2,4),n=r.value.substring(4,6);return[parseInt(e,16),parseInt(t,16),parseInt(n,16),1]}if(r.value.length===8){const e=r.value.substring(0,2),t=r.value.substring(2,4),n=r.value.substring(4,6),i=r.value.substring(6,8);return[parseInt(e,16),parseInt(t,16),parseInt(n,16),parseInt(i,16)/255]}return[0,0,0,1]},$h=(r,e)=>{const t=e.filter(Et);if(xi(t))throw new Error("Relative color not supported for rgb()");if(t.length===3){const[n,i,s]=t.map(_r);return _n(n,i,s,1)}if(t.length===4){const[n,i,s,a]=t.map(_r);return _n(n,i,s,a)}if(t.length===5&&t[3].type===6&&t[3].value==="/"){const n=_r(t[0],0),i=_r(t[1],1),s=_r(t[2],2),a=_r(t[4],3);return _n(n,i,s,a)}return 0},V3=(r,e)=>{const t=e.filter(Et),n=t[0].type===20?t[0].value:"unknown";if(!xi(t)){const s=n,a=jh[s];if(typeof a>"u")throw new Error(`Attempting to parse an unsupported color space "${s}" for color() function`);const A=lt(t[1])?t[1].number:0,o=lt(t[2])?t[2].number:0,c=lt(t[3])?t[3].number:0,l=t.length>4&&t[4].type===6&&t[4].value==="/"&<(t[5])?t[5].number:1;return a([A,o,c,l])}else{const s=(B,E)=>{if(lt(E))return E.number;const b=T=>T==="r"||T==="x"?0:T==="g"||T==="y"?1:2;if(ve(E)){const T=b(E.value);return B[T]}const C=T=>{const F=T.filter(Et);let R="(";for(const M of F)R+=M.type===18&&M.name==="calc"?C(M.values):lt(M)?M.number:M.type===6||ve(M)?M.value:"";return R+=")",R};if(E.type===18){const T=E.values.filter(Et);if(E.name==="calc"){const F=C(T).replace(/r|x/,B[0].toString()).replace(/g|y/,B[1].toString()).replace(/b|z/,B[2].toString());return new Function("return "+F)()}}return null},a=t[1].type===18?t[1].name:ve(t[1])||t[1].type===5?"rgb":"unknown",A=ve(t[2])?t[2].value:"unknown";let o=t[1].type===18?t[1].values:ve(t[1])?[t[1]]:[];if(ve(t[1])){if(typeof jn[t[1].value.toUpperCase()]>"u")throw new Error("Attempting to use unknown color in relative color 'from'");{const E=Zi(r,t[1].value),b=255&E,C=255&E>>8,T=255&E>>16;o=[{type:17,number:255&E>>24,flags:1},{type:17,number:T,flags:1},{type:17,number:C,flags:1},{type:17,number:b>1?b/255:b,flags:1}]}}else if(t[1].type===5){const[B,E,b,C]=U1(t[1]);o=[{type:17,number:B,flags:1},{type:17,number:E,flags:1},{type:17,number:b,flags:1},{type:17,number:C>1?C/255:C,flags:1}]}if(o.length===0)throw new Error("Attempting to use unknown color in relative color 'from'");if(A==="unknown")throw new Error("Attempting to use unknown colorspace in relative color 'to'");const c=z3[a],l=G3[A],d=jh[A];if(typeof c>"u")throw new Error(`Attempting to parse an unsupported color space "${a}" for color() function`);if(typeof l>"u")throw new Error(`Attempting to parse an unsupported color space "${A}" for color() function`);const u=c(r,o),h=l(u),p=s(h,t[3]),g=s(h,t[4]),v=s(h,t[5]),w=t.length>6&&t[6].type===6&&t[6].value==="/"&<(t[7])?t[7].number:1;if(p===null||g===null||v===null)throw new Error("Invalid relative color in color() function");return d([p,g,v,w])}},jh={srgb:n3,"srgb-linear":Tu,"display-p3":B3,"a98-rgb":E3,"prophoto-rgb":R3,xyz:Wh,"xyz-d50":p3,"xyz-d65":Wh,rec2020:K3},z3={rgb:A3,hsl:o3,lab:c3,lch:l3,oklab:u3,oklch:d3},G3={srgb:Y5,"srgb-linear":Z5,"display-p3":b3,"a98-rgb":x3,"prophoto-rgb":_3,xyz:qh,"xyz-d50":f3,"xyz-d65":qh,rec2020:N3},q3={hsl:Gh,hsla:Gh,rgb:$h,rgba:$h,lch:a3,oklch:s3,oklab:i3,lab:r3,color:V3},Zi=(r,e)=>zr.parse(r,p1.create(e).parseComponentValue()),jn={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},W3={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:(r,e)=>e.map(t=>{if(ve(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})},$3={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Wo=(r,e)=>{const t=zr.parse(r,e[0]),n=e[1];return n&&Qe(n)?{color:t,stop:n}:{color:t,stop:null}},Xh=(r,e)=>{const t=r[0],n=r[r.length-1];t.stop===null&&(t.stop=ut),n.stop===null&&(n.stop=qn);const i=[];let s=0;for(let A=0;A<r.length;A++){const o=r[A].stop;if(o!==null){const c=fe(o,e);c>s?i.push(c):i.push(s),s=c}else i.push(null)}let a=null;for(let A=0;A<i.length;A++){const o=i[A];if(o===null)a===null&&(a=A);else if(a!==null){const c=A-a,l=i[a-1],d=(o-l)/(c+1);for(let u=1;u<=c;u++)i[a+u-1]=d*u;a=null}}return r.map(({color:A},o)=>({color:A,stop:Math.max(Math.min(1,i[o]/e),0)}))},j3=(r,e,t)=>{const n=e/2,i=t/2,s=fe(r[0],e)-n,a=i-fe(r[1],t);return(Math.atan2(a,s)+Math.PI*2)%(Math.PI*2)},X3=(r,e,t)=>{const n=typeof r=="number"?r:j3(r,e,t),i=Math.abs(e*Math.sin(n))+Math.abs(t*Math.cos(n)),s=e/2,a=t/2,A=i/2,o=Math.sin(n-Math.PI/2)*A,c=Math.cos(n-Math.PI/2)*A;return[i,s-c,s+c,a-o,a+o]},Bn=(r,e)=>Math.sqrt(r*r+e*e),Jh=(r,e,t,n,i)=>[[0,0],[0,e],[r,0],[r,e]].reduce((a,A)=>{const[o,c]=A,l=Bn(t-o,n-c);return(i?l<a.optimumDistance:l>a.optimumDistance)?{optimumCorner:A,optimumDistance:l}:a},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner,J3=(r,e,t,n,i)=>{let s=0,a=0;switch(r.size){case 0:r.shape===0?s=a=Math.min(Math.abs(e),Math.abs(e-n),Math.abs(t),Math.abs(t-i)):r.shape===1&&(s=Math.min(Math.abs(e),Math.abs(e-n)),a=Math.min(Math.abs(t),Math.abs(t-i)));break;case 2:if(r.shape===0)s=a=Math.min(Bn(e,t),Bn(e,t-i),Bn(e-n,t),Bn(e-n,t-i));else if(r.shape===1){const A=Math.min(Math.abs(t),Math.abs(t-i))/Math.min(Math.abs(e),Math.abs(e-n)),[o,c]=Jh(n,i,e,t,!0);s=Bn(o-e,(c-t)/A),a=A*s}break;case 1:r.shape===0?s=a=Math.max(Math.abs(e),Math.abs(e-n),Math.abs(t),Math.abs(t-i)):r.shape===1&&(s=Math.max(Math.abs(e),Math.abs(e-n)),a=Math.max(Math.abs(t),Math.abs(t-i)));break;case 3:if(r.shape===0)s=a=Math.max(Bn(e,t),Bn(e,t-i),Bn(e-n,t),Bn(e-n,t-i));else if(r.shape===1){const A=Math.max(Math.abs(t),Math.abs(t-i))/Math.max(Math.abs(e),Math.abs(e-n)),[o,c]=Jh(n,i,e,t,!1);s=Bn(o-e,(c-t)/A),a=A*s}break}return Array.isArray(r.size)&&(s=fe(r.size[0],n),a=r.size.length===2?fe(r.size[1],i):s),[s,a]},Y3=(r,e)=>{let t=fn(180);const n=[];return Pn(e).forEach((i,s)=>{if(s===0){const A=i[0];if(A.type===20&&A.value==="to"){t=B1(i);return}else if(b1(A)){t=us.parse(r,A);return}}const a=Wo(r,i);n.push(a)}),{angle:t,stops:n,type:1}},Xa=(r,e)=>{let t=fn(180);const n=[];return Pn(e).forEach((i,s)=>{if(s===0){const A=i[0];if(A.type===20&&["top","left","right","bottom"].indexOf(A.value)!==-1){t=B1(i);return}else if(b1(A)){t=(us.parse(r,A)+fn(270))%fn(360);return}}const a=Wo(r,i);n.push(a)}),{angle:t,stops:n,type:1}},Z3=(r,e)=>{const t=fn(180),n=[];let i=1;const s=0,a=3,A=[];return Pn(e).forEach((o,c)=>{const l=o[0];if(c===0){if(ve(l)&&l.value==="linear"){i=1;return}else if(ve(l)&&l.value==="radial"){i=2;return}}if(l.type===18){if(l.name==="from"){const d=zr.parse(r,l.values[0]);n.push({stop:ut,color:d})}else if(l.name==="to"){const d=zr.parse(r,l.values[0]);n.push({stop:qn,color:d})}else if(l.name==="color-stop"){const d=l.values.filter(Et);if(d.length===2){const u=zr.parse(r,d[1]),h=d[0];lt(h)&&n.push({stop:{type:16,number:h.number*100,flags:h.flags},color:u})}}}}),i===1?{angle:(t+fn(180))%fn(360),stops:n,type:i}:{size:a,shape:s,stops:n,position:A,type:i}},F1="closest-side",I1="farthest-side",Q1="closest-corner",M1="farthest-corner",_1="circle",R1="ellipse",P1="cover",D1="contain",eS=(r,e)=>{let t=0,n=3;const i=[],s=[];return Pn(e).forEach((a,A)=>{let o=!0;if(A===0){let c=!1;o=a.reduce((l,d)=>{if(c)if(ve(d))switch(d.value){case"center":return s.push(fi),l;case"top":case"left":return s.push(ut),l;case"right":case"bottom":return s.push(qn),l}else(Qe(d)||Wr(d))&&s.push(d);else if(ve(d))switch(d.value){case _1:return t=0,!1;case R1:return t=1,!1;case"at":return c=!0,!1;case F1:return n=0,!1;case P1:case I1:return n=1,!1;case D1:case Q1:return n=2,!1;case M1:return n=3,!1}else if(Wr(d)||Qe(d))return Array.isArray(n)||(n=[]),n.push(d),!1;return l},o)}if(o){const c=Wo(r,a);i.push(c)}}),{size:n,shape:t,stops:i,position:s,type:2}},Ja=(r,e)=>{let t=0,n=3;const i=[],s=[];return Pn(e).forEach((a,A)=>{let o=!0;if(A===0?o=a.reduce((c,l)=>{if(ve(l))switch(l.value){case"center":return s.push(fi),!1;case"top":case"left":return s.push(ut),!1;case"right":case"bottom":return s.push(qn),!1}else if(Qe(l)||Wr(l))return s.push(l),!1;return c},o):A===1&&(o=a.reduce((c,l)=>{if(ve(l))switch(l.value){case _1:return t=0,!1;case R1:return t=1,!1;case D1:case F1:return n=0,!1;case I1:return n=1,!1;case Q1:return n=2,!1;case P1:case M1:return n=3,!1}else if(Wr(l)||Qe(l))return Array.isArray(n)||(n=[]),n.push(l),!1;return c},o)),o){const c=Wo(r,a);i.push(c)}}),{size:n,shape:t,stops:i,position:s,type:2}},tS=r=>r.type===1,nS=r=>r.type===2,Eu={name:"image",parse:(r,e)=>{if(e.type===22){const t={url:e.value,type:0};return r.cache.addImage(e.value),t}if(e.type===18){const t=L1[e.name];if(typeof t>"u")throw new Error(`Attempting to parse an unsupported image function "${e.name}"`);return t(r,e.values)}throw new Error(`Unsupported image type ${e.type}`)}};function rS(r){return!(r.type===20&&r.value==="none")&&(r.type!==18||!!L1[r.name])}const L1={"linear-gradient":Y3,"-moz-linear-gradient":Xa,"-ms-linear-gradient":Xa,"-o-linear-gradient":Xa,"-webkit-linear-gradient":Xa,"radial-gradient":eS,"-moz-radial-gradient":Ja,"-ms-radial-gradient":Ja,"-o-radial-gradient":Ja,"-webkit-radial-gradient":Ja,"-webkit-gradient":Z3},iS={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>{if(e.length===0)return[];const t=e[0];return t.type===20&&t.value==="none"?[]:e.filter(n=>Et(n)&&rS(n)).map(n=>Eu.parse(r,n))}},sS={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:(r,e)=>e.map(t=>{if(ve(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})},aS={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:(r,e)=>Pn(e).map(t=>t.map(n=>e3(n)?t3(n,0):Qe(n)?n:null).filter(n=>n!==null)).map(m1)},AS={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:(r,e)=>Pn(e).map(t=>t.filter(ve).map(n=>n.value).join(" ")).map(oS)},oS=r=>{switch(r){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}};var es;(function(r){r.AUTO="auto",r.CONTAIN="contain",r.COVER="cover"})(es||(es={}));const cS={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:(r,e)=>Pn(e).map(t=>t.filter(lS))},lS=r=>ve(r)||Qe(r),$o=r=>({name:`border-${r}-color`,initialValue:"transparent",prefix:!1,type:3,format:"color"}),dS=$o("top"),uS=$o("right"),hS=$o("bottom"),fS=$o("left"),jo=r=>({name:`border-radius-${r}`,initialValue:"0 0",prefix:!1,type:1,parse:(e,t)=>m1(t.filter(Qe))}),pS=jo("top-left"),mS=jo("top-right"),gS=jo("bottom-right"),vS=jo("bottom-left"),Xo=r=>({name:`border-${r}-style`,initialValue:"solid",prefix:!1,type:2,parse:(e,t)=>{switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}),yS=Xo("top"),wS=Xo("right"),bS=Xo("bottom"),BS=Xo("left"),Jo=r=>({name:`border-${r}-width`,initialValue:"0",type:0,prefix:!1,parse:(e,t)=>Yn(t)?t.number:0}),CS=Jo("top"),SS=Jo("right"),kS=Jo("bottom"),TS=Jo("left"),gd={type:0},vd=r=>{const[e]=r;return e?ve(e)?e.value==="farthest-side"?"farthest-side":"closest-side":Qe(e)?e:"closest-side":"closest-side"},O1=r=>{let e=null,t=null;for(const n of r)if(ve(n))switch(n.value){case"left":e=ut;break;case"right":e=qn;break;case"top":t=ut;break;case"bottom":t=qn;break;case"center":e===null?e=fi:t===null&&(t=fi);break}else Qe(n)&&(e===null?e=n:t===null&&(t=n));return{cx:e??fi,cy:t??fi}},xS=r=>{const e=[];for(const a of r)if(a.type!==31){if(ve(a)&&a.value==="round")break;Qe(a)&&e.push(a)}const t=e[0]??ut,n=e[1]??t,i=e[2]??t,s=e[3]??n;return{type:1,top:t,right:n,bottom:i,left:s}},ES=r=>{const e=r.filter(Ko),t=e.findIndex(s=>ya(s,"at")),n=t===-1?e:e.slice(0,t),i=t===-1?[]:e.slice(t+1);return{type:2,radius:vd(n),...O1(i)}},US=r=>{const e=r.filter(Ko),t=e.findIndex(s=>ya(s,"at")),n=t===-1?e:e.slice(0,t),i=t===-1?[]:e.slice(t+1);return{type:3,rx:vd(n.slice(0,1)),ry:vd(n.slice(1,2)),...O1(i)}},FS=r=>{const e=Pn(r),t=[];for(const n of e){if(n.length===1&&ve(n[0]))continue;const i=n.filter(Qe);i.length>=2&&t.push([i[0],i[1]])}return{type:4,points:t}},IS=r=>{const e=r.find(t=>t.type===0);return e?{type:5,d:e.value}:gd},QS={name:"clip-path",initialValue:"none",prefix:!1,type:0,parse:(r,e)=>{if(ve(e)&&e.value==="none")return gd;if(e.type===18)switch(e.name){case"inset":return xS(e.values);case"circle":return ES(e.values);case"ellipse":return US(e.values);case"polygon":return FS(e.values);case"path":return IS(e.values)}return gd}},MS={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},_S={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"rtl":return 1;case"ltr":default:return 0}}},RS={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:(r,e)=>e.filter(ve).reduce((t,n)=>t|PS(n.value),0)},PS=r=>{switch(r){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},DS={name:"float",initialValue:"none",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},LS={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:(r,e)=>e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0};var Ao;(function(r){r.NORMAL="normal",r.STRICT="strict"})(Ao||(Ao={}));const OS={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"strict":return Ao.STRICT;case"normal":default:return Ao.NORMAL}}},HS={name:"line-height",initialValue:"normal",prefix:!1,type:4},Yh=(r,e)=>ve(r)&&r.value==="normal"?1.2*e:r.type===17?e*r.number:Qe(r)?fe(r,e):e,NS={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:(r,e)=>e.type===20&&e.value==="none"?null:Eu.parse(r,e)},KS={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"inside":return 0;case"outside":default:return 1}}},yd={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 52;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},Yo=r=>({name:`margin-${r}`,initialValue:"0",prefix:!1,type:4}),VS=Yo("top"),zS=Yo("right"),GS=Yo("bottom"),qS=Yo("left"),WS={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:(r,e)=>e.filter(ve).map(t=>{switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})},$S={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"break-word":return"break-word";case"normal":default:return"normal"}}},Zo=r=>({name:`padding-${r}`,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}),jS=Zo("top"),XS=Zo("right"),JS=Zo("bottom"),YS=Zo("left"),ZS={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},e6={name:"position",initialValue:"static",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},t6={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>e.length===1&&ya(e[0],"none")?[]:Pn(e).map(t=>{const n={color:jn.TRANSPARENT,offsetX:ut,offsetY:ut,blur:ut};let i=0;for(let s=0;s<t.length;s++){const a=t[s];Wr(a)?(i===0?n.offsetX=a:i===1?n.offsetY=a:n.blur=a,i++):n.color=zr.parse(r,a)}return n})},n6={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},r6={name:"transform",initialValue:"none",prefix:!0,type:0,parse:(r,e)=>{if(e.type===20&&e.value==="none")return null;if(e.type===18){const t=A6[e.name];if(typeof t>"u")throw new Error(`Attempting to parse an unsupported transform function "${e.name}"`);return t(r,e.values)}return null}},i6=(r,e)=>{const t=e.filter(n=>n.type===17).map(n=>n.number);return t.length===6?t:null},s6=(r,e)=>{const t=e.filter(c=>c.type===17).map(c=>c.number),[n,i,{},{},s,a,{},{},{},{},{},{},A,o]=t;return t.length===16?[n,i,s,a,A,o]:null},a6=(r,e)=>{if(e.length!==1)return null;const t=e[0];let n=0;if(t.type===17&&t.number===0)n=0;else if(t.type===15)n=us.parse(r,t);else return null;const i=Math.cos(n),s=Math.sin(n);return[i,s,-s,i,0,0]},A6={matrix:i6,matrix3d:s6,rotate:a6},Zh={type:16,number:50,flags:ds},o6=[Zh,Zh],c6={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:(r,e)=>{const t=e.filter(Qe);return t.length!==2?o6:[t[0],t[1]]}},l6={name:"rotate",initialValue:"none",prefix:!1,type:0,parse:(r,e)=>e.type===20&&e.value==="none"?null:e.type===17&&e.number===0?0:e.type===15?us.parse(r,e)*180/Math.PI:null},d6={name:"visible",initialValue:"none",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}};var Zs;(function(r){r.NORMAL="normal",r.BREAK_ALL="break-all",r.KEEP_ALL="keep-all"})(Zs||(Zs={}));const u6={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"break-all":return Zs.BREAK_ALL;case"keep-all":return Zs.KEEP_ALL;case"normal":default:return Zs.NORMAL}}},Kn=r=>r!==0,h6=r=>r===3||r===4,f6={name:"writing-mode",initialValue:"horizontal-tb",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"vertical-rl":return 1;case"vertical-lr":return 2;case"sideways-rl":return 3;case"sideways-lr":return 4;case"horizontal-tb":default:return 0}}},p6={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:(r,e)=>{if(e.type===20)return{auto:!0,order:0};if(lt(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},H1={name:"time",parse:(r,e)=>{if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},m6={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:(r,e)=>lt(e)?e.number:1},g6={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},v6={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:(r,e)=>e.filter(ve).map(t=>{switch(t.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(t=>t!==0)},y6={name:"text-decoration-style",initialValue:"solid",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"double":return 1;case"dotted":return 2;case"dashed":return 3;case"wavy":return 4;case"solid":default:return 0}}},w6={name:"text-decoration-thickness",initialValue:"auto",prefix:!1,type:0,parse:(r,e)=>{if(ve(e))switch(e.value){case"auto":return"auto";case"from-font":return"from-font"}return Yn(e)?e.number:"auto"}},b6={name:"text-underline-offset",initialValue:"auto",prefix:!1,type:0,parse:(r,e)=>ve(e)&&e.value==="auto"?"auto":Yn(e)?e.number:"auto"},B6={name:"font-family",initialValue:"",prefix:!1,type:1,parse:(r,e)=>{const t=[],n=[];return e.forEach(i=>{switch(i.type){case 20:case 0:t.push(i.value);break;case 17:t.push(i.number.toString());break;case 4:n.push(t.join(" ")),t.length=0;break}}),t.length&&n.push(t.join(" ")),n.map(i=>i.indexOf(" ")===-1?i:`'${i}'`)}},C6={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},S6={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:(r,e)=>{if(lt(e))return e.number;if(ve(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},k6={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>e.filter(ve).map(t=>t.value)},T6={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},Ye=(r,e)=>(r&e)!==0,x6={name:"content",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>{if(e.length===0)return[];const t=e[0];return t.type===20&&t.value==="none"?[]:e}},E6={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:(r,e)=>{if(e.length===0)return null;const t=e[0];if(t.type===20&&t.value==="none")return null;const n=[],i=e.filter(Ko);for(let s=0;s<i.length;s++){const a=i[s],A=i[s+1];if(a.type===20){const o=A&<(A)?A.number:1;n.push({counter:a.value,increment:o})}}return n}},U6={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:(r,e)=>{if(e.length===0)return[];const t=[],n=e.filter(Ko);for(let i=0;i<n.length;i++){const s=n[i],a=n[i+1];if(ve(s)&&s.value!=="none"){const A=a&<(a)?a.number:0;t.push({counter:s.value,reset:A})}}return t}},F6={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:(r,e)=>e.filter(Yn).map(t=>H1.parse(r,t))},I6={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:(r,e)=>{if(e.length===0)return null;const t=e[0];if(t.type===20&&t.value==="none")return null;const n=[],i=e.filter(X5);if(i.length%2!==0)return null;for(let s=0;s<i.length;s+=2){const a=i[s].value,A=i[s+1].value;n.push({open:a,close:A})}return n}},ef=(r,e,t)=>{if(!r)return"";const n=r[Math.min(e,r.length-1)];return n?t?n.open:n.close:""},Q6={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>e.length===1&&ya(e[0],"none")?[]:Pn(e).map(t=>{const n={color:255,offsetX:ut,offsetY:ut,blur:ut,spread:ut,inset:!1};let i=0;for(let s=0;s<t.length;s++){const a=t[s];ya(a,"inset")?n.inset=!0:Wr(a)?(i===0?n.offsetX=a:i===1?n.offsetY=a:i===2?n.blur=a:n.spread=a,i++):n.color=zr.parse(r,a)}return n})},M6={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:(r,e)=>{const t=[0,1,2],n=[];return e.filter(ve).forEach(i=>{switch(i.value){case"stroke":n.push(1);break;case"fill":n.push(0);break;case"markers":n.push(2);break}}),t.forEach(i=>{n.indexOf(i)===-1&&n.push(i)}),n}},_6={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},R6={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:(r,e)=>Yn(e)?e.number:0},P6={name:"-webkit-line-clamp",initialValue:"none",prefix:!0,type:0,parse:(r,e)=>e.type===20&&e.value==="none"?0:e.type===17?Math.max(0,Math.floor(e.number)):0},D6={name:"objectFit",initialValue:"fill",prefix:!1,type:1,parse:(r,e)=>e.filter(ve).reduce((t,n)=>t|L6(n.value),0)},L6=r=>{switch(r){case"contain":return 2;case"cover":return 4;case"none":return 8;case"scale-down":return 16}return 0},O6={name:"text-overflow",initialValue:"clip",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"ellipsis":return 1;case"clip":default:return 0}}};var an;(function(r){r[r.AUTO=0]="AUTO",r[r.CRISP_EDGES=1]="CRISP_EDGES",r[r.PIXELATED=2]="PIXELATED",r[r.SMOOTH=3]="SMOOTH"})(an||(an={}));const H6={name:"image-rendering",initialValue:"auto",prefix:!1,type:2,parse:(r,e)=>{switch(e.toLowerCase()){case"crisp-edges":case"-webkit-crisp-edges":case"-moz-crisp-edges":return an.CRISP_EDGES;case"pixelated":case"-webkit-optimize-contrast":return an.PIXELATED;case"smooth":case"high-quality":return an.SMOOTH;case"auto":default:return an.AUTO}}};class N6{constructor(e,t){this.animationDuration=J(e,F6,t.animationDuration),this.backgroundClip=J(e,W3,t.backgroundClip),this.backgroundColor=J(e,$3,t.backgroundColor),this.backgroundImage=J(e,iS,t.backgroundImage),this.backgroundOrigin=J(e,sS,t.backgroundOrigin),this.backgroundPosition=J(e,aS,t.backgroundPosition),this.backgroundRepeat=J(e,AS,t.backgroundRepeat),this.backgroundSize=J(e,cS,t.backgroundSize),this.borderTopColor=J(e,dS,t.borderTopColor),this.borderRightColor=J(e,uS,t.borderRightColor),this.borderBottomColor=J(e,hS,t.borderBottomColor),this.borderLeftColor=J(e,fS,t.borderLeftColor),this.borderTopLeftRadius=J(e,pS,t.borderTopLeftRadius),this.borderTopRightRadius=J(e,mS,t.borderTopRightRadius),this.borderBottomRightRadius=J(e,gS,t.borderBottomRightRadius),this.borderBottomLeftRadius=J(e,vS,t.borderBottomLeftRadius),this.borderTopStyle=J(e,yS,t.borderTopStyle),this.borderRightStyle=J(e,wS,t.borderRightStyle),this.borderBottomStyle=J(e,bS,t.borderBottomStyle),this.borderLeftStyle=J(e,BS,t.borderLeftStyle),this.borderTopWidth=J(e,CS,t.borderTopWidth),this.borderRightWidth=J(e,SS,t.borderRightWidth),this.borderBottomWidth=J(e,kS,t.borderBottomWidth),this.borderLeftWidth=J(e,TS,t.borderLeftWidth),this.boxShadow=J(e,Q6,t.boxShadow),this.clipPath=J(e,QS,t.clipPath),this.color=J(e,MS,t.color),this.direction=J(e,_S,t.direction),this.display=J(e,RS,t.display),this.float=J(e,DS,t.cssFloat),this.fontFamily=J(e,B6,t.fontFamily),this.fontSize=J(e,C6,t.fontSize),this.fontStyle=J(e,T6,t.fontStyle),this.fontVariant=J(e,k6,t.fontVariant),this.fontWeight=J(e,S6,t.fontWeight),this.letterSpacing=J(e,LS,t.letterSpacing),this.lineBreak=J(e,OS,t.lineBreak),this.lineHeight=J(e,HS,t.lineHeight),this.listStyleImage=J(e,NS,t.listStyleImage),this.listStylePosition=J(e,KS,t.listStylePosition),this.listStyleType=J(e,yd,t.listStyleType),this.marginTop=J(e,VS,t.marginTop),this.marginRight=J(e,zS,t.marginRight),this.marginBottom=J(e,GS,t.marginBottom),this.marginLeft=J(e,qS,t.marginLeft),this.opacity=J(e,m6,t.opacity);const n=J(e,WS,t.overflow);this.overflowX=n[0],this.overflowY=n[n.length>1?1:0],this.overflowWrap=J(e,$S,t.overflowWrap),this.paddingTop=J(e,jS,t.paddingTop),this.paddingRight=J(e,XS,t.paddingRight),this.paddingBottom=J(e,JS,t.paddingBottom),this.paddingLeft=J(e,YS,t.paddingLeft),this.paintOrder=J(e,M6,t.paintOrder),this.position=J(e,e6,t.position),this.textAlign=J(e,ZS,t.textAlign),this.textDecorationColor=J(e,g6,t.textDecorationColor??t.color),this.textDecorationLine=J(e,v6,t.textDecorationLine??t.textDecoration),this.textDecorationStyle=J(e,y6,t.textDecorationStyle),this.textDecorationThickness=J(e,w6,t.textDecorationThickness),this.textUnderlineOffset=J(e,b6,t.textUnderlineOffset),this.textShadow=J(e,t6,t.textShadow),this.textTransform=J(e,n6,t.textTransform),this.textOverflow=J(e,O6,t.textOverflow),this.transform=J(e,r6,t.transform),this.transformOrigin=J(e,c6,t.transformOrigin),this.rotate=J(e,l6,t.rotate),this.visibility=J(e,d6,t.visibility),this.webkitTextStrokeColor=J(e,_6,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=J(e,R6,t.webkitTextStrokeWidth),this.webkitLineClamp=J(e,P6,t.webkitLineClamp),this.wordBreak=J(e,u6,t.wordBreak),this.writingMode=J(e,f6,t.writingMode),this.zIndex=J(e,p6,t.zIndex),this.objectFit=J(e,D6,t.objectFit),this.imageRendering=J(e,H6,t.imageRendering)}isVisible(){return this.display>0&&this.opacity>0&&this.visibility===0}isTransparent(){return Vr(this.backgroundColor)}isTransformed(){return this.transform!==null||this.rotate!==null}isPositioned(){return this.position!==0}isPositionedWithZIndex(){return this.isPositioned()&&!this.zIndex.auto}isFloating(){return this.float!==0}isInlineLevel(){return Ye(this.display,4)||Ye(this.display,33554432)||Ye(this.display,268435456)||Ye(this.display,536870912)||Ye(this.display,67108864)||Ye(this.display,134217728)}}class K6{constructor(e,t){this.content=J(e,x6,t.content),this.quotes=J(e,I6,t.quotes)}}class tf{constructor(e,t){this.counterIncrement=J(e,E6,t.counterIncrement),this.counterReset=J(e,U6,t.counterReset)}}const J=(r,e,t)=>{const n=new f1,i=t!==null&&typeof t<"u"?t.toString():e.initialValue;n.write(i);const s=new p1(n.read());switch(e.type){case 2:const a=s.parseComponentValue();return e.parse(r,ve(a)?a.value:e.initialValue);case 0:return e.parse(r,s.parseComponentValue());case 1:return e.parse(r,s.parseComponentValues());case 4:return s.parseComponentValue();case 3:switch(e.format){case"angle":return us.parse(r,s.parseComponentValue());case"color":return zr.parse(r,s.parseComponentValue());case"image":return Eu.parse(r,s.parseComponentValue());case"length":const A=s.parseComponentValue();return Wr(A)?A:ut;case"length-percentage":const o=s.parseComponentValue();return Qe(o)?o:ut;case"time":return H1.parse(r,s.parseComponentValue())}break}},lr=r=>r.nodeType===Node.ELEMENT_NODE,N1=r=>r.nodeType===Node.TEXT_NODE,zi=r=>typeof r.className=="object",wa=r=>lr(r)&&typeof r.style<"u"&&!zi(r),V6=r=>r.tagName==="LI",z6=r=>r.tagName==="OL",nf=r=>!zi(r)&&r.tagName.indexOf("-")>0,G6="data-html2canvas-debug",q6=r=>{if(typeof r.getAttribute!="function")return 0;switch(r.getAttribute(G6)){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},wd=(r,e)=>{const t=q6(r);return t===1||e===t};class rf{static normalizeElement(e,t){const n={};return wa(e)&&(t.animationDuration.some(i=>i>0)&&(n.animationDuration=e.style.animationDuration,e.style.animationDuration="0s"),t.transform!==null&&(n.transform=e.style.transform,e.style.transform="translate(0, 0)"),t.rotate!==null&&(n.rotate=e.style.rotate,e.style.rotate="0deg",n.transform===void 0&&(n.transform=e.style.transform,e.style.transform="translate(0, 0)"))),n}static restoreElement(e,t){wa(e)&&(t.animationDuration!==void 0&&(e.style.animationDuration=t.animationDuration),t.transform!==void 0&&(e.style.transform=t.transform),t.rotate!==void 0&&(e.style.rotate=t.rotate))}}class Zn{constructor(e,t,n={}){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,wd(t,3),this.styles=new N6(e,e.config.window.getComputedStyle(t,null)),n.normalizeDom!==!1&&wa(t)&&(this.originalStyles=rf.normalizeElement(t,this.styles),this.originalElement=t),this.bounds=Ho(this.context,t),wd(t,4)&&(this.flags|=16)}restore(){this.originalStyles&&this.originalElement&&(rf.restoreElement(this.originalElement,this.originalStyles),this.originalStyles=void 0,this.originalElement=void 0)}restoreTree(){this.restore();for(const e of this.elements)e.restoreTree()}}var W6="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",sf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Ya=0;Ya<sf.length;Ya++)Hs[sf.charCodeAt(Ya)]=Ya;var $6=function(r){var e=r.length*.75,t=r.length,n,i=0,s,a,A,o;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);var c=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&typeof Uint8Array.prototype.slice<"u"?new ArrayBuffer(e):new Array(e),l=Array.isArray(c)?c:new Uint8Array(c);for(n=0;n<t;n+=4)s=Hs[r.charCodeAt(n)],a=Hs[r.charCodeAt(n+1)],A=Hs[r.charCodeAt(n+2)],o=Hs[r.charCodeAt(n+3)],l[i++]=s<<2|a>>4,l[i++]=(a&15)<<4|A>>2,l[i++]=(A&3)<<6|o&63;return c},j6=function(r){for(var e=r.length,t=[],n=0;n<e;n+=2)t.push(r[n+1]<<8|r[n]);return t},X6=function(r){for(var e=r.length,t=[],n=0;n<e;n+=4)t.push(r[n+3]<<24|r[n+2]<<16|r[n+1]<<8|r[n]);return t},wi=5,Uu=11,Vc=2,J6=Uu-wi,K1=65536>>wi,Y6=1<<wi,zc=Y6-1,Z6=1024>>wi,ek=K1+Z6,tk=ek,nk=32,rk=tk+nk,ik=65536>>Uu,sk=1<<J6,ak=sk-1,af=function(r,e,t){return r.slice?r.slice(e,t):new Uint16Array(Array.prototype.slice.call(r,e,t))},Ak=function(r,e,t){return r.slice?r.slice(e,t):new Uint32Array(Array.prototype.slice.call(r,e,t))},ok=function(r,e){var t=$6(r),n=Array.isArray(t)?X6(t):new Uint32Array(t),i=Array.isArray(t)?j6(t):new Uint16Array(t),s=24,a=af(i,s/2,n[4]/2),A=n[5]===2?af(i,(s+n[4])/2):Ak(n,Math.ceil((s+n[4])/4));return new ck(n[0],n[1],n[2],n[3],a,A)},ck=function(){function r(e,t,n,i,s,a){this.initialValue=e,this.errorValue=t,this.highStart=n,this.highValueIndex=i,this.index=s,this.data=a}return r.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>wi],t=(t<<Vc)+(e&zc),this.data[t];if(e<=65535)return t=this.index[K1+(e-55296>>wi)],t=(t<<Vc)+(e&zc),this.data[t];if(e<this.highStart)return t=rk-ik+(e>>Uu),t=this.index[t],t+=e>>wi&ak,t=this.index[t],t=(t<<Vc)+(e&zc),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},r}(),Af="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lk=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Za=0;Za<Af.length;Za++)lk[Af.charCodeAt(Za)]=Za;var dk=1,Gc=2,qc=3,of=4,cf=5,uk=7,lf=8,Wc=9,$c=10,df=11,uf=12,hf=13,ff=14,jc=15,hk=function(r){for(var e=[],t=0,n=r.length;t<n;){var i=r.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var s=r.charCodeAt(t++);(s&64512)===56320?e.push(((i&1023)<<10)+(s&1023)+65536):(e.push(i),t--)}else e.push(i)}return e},fk=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,r);var t=r.length;if(!t)return"";for(var n=[],i=-1,s="";++i<t;){var a=r[i];a<=65535?n.push(a):(a-=65536,n.push((a>>10)+55296,a%1024+56320)),(i+1===t||n.length>16384)&&(s+=String.fromCharCode.apply(String,n),n.length=0)}return s},pk=ok(W6),un="×",Xc="÷",mk=function(r){return pk.get(r)},gk=function(r,e,t){var n=t-2,i=e[n],s=e[t-1],a=e[t];if(s===Gc&&a===qc)return un;if(s===Gc||s===qc||s===of||a===Gc||a===qc||a===of)return Xc;if(s===lf&&[lf,Wc,df,uf].indexOf(a)!==-1||(s===df||s===Wc)&&(a===Wc||a===$c)||(s===uf||s===$c)&&a===$c||a===hf||a===cf||a===uk||s===dk)return un;if(s===hf&&a===ff){for(;i===cf;)i=e[--n];if(i===ff)return un}if(s===jc&&a===jc){for(var A=0;i===jc;)A++,i=e[--n];if(A%2===0)return un}return Xc},vk=function(r){var e=hk(r),t=e.length,n=0,i=0,s=e.map(mk);return{next:function(){if(n>=t)return{done:!0,value:null};for(var a=un;n<t&&(a=gk(e,s,++n))===un;);if(a!==un||n===t){var A=fk.apply(null,e.slice(i,n));return i=n,{value:A,done:!1}}return{done:!0,value:null}}}},yk=function(r){for(var e=vk(r),t=[],n;!(n=e.next()).done;)n.value&&t.push(n.value.slice());return t};const wk=r=>{if(r.createRange){const t=r.createRange();if(t.getBoundingClientRect){const n=r.createElement("boundtest");n.style.height="123px",n.style.display="block",r.body.appendChild(n),t.selectNode(n);const i=t.getBoundingClientRect(),s=Math.round(i.height);if(r.body.removeChild(n),s===123)return!0}}return!1},bk=r=>{const e=r.createElement("boundtest");e.style.width="50px",e.style.display="block",e.style.fontSize="12px",e.style.letterSpacing="0px",e.style.wordSpacing="0px",r.body.appendChild(e);const t=r.createRange();e.innerHTML=typeof"".repeat=="function"?"👨".repeat(10):"";const n=e.firstChild,i=No(n.data).map(o=>st(o));let s=0,a={};const A=i.every((o,c)=>{t.setStart(n,s),t.setEnd(n,s+o.length);const l=t.getBoundingClientRect();s+=o.length;const d=l.x>a.x||l.y>a.y;return a=l,c===0?!0:d});return r.body.removeChild(e),A},Bk=()=>typeof new Image().crossOrigin<"u",Ck=()=>typeof new XMLHttpRequest().responseType=="string",Sk=r=>{const e=new Image,t=r.createElement("canvas"),n=t.getContext("2d");if(!n)return!1;e.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{n.drawImage(e,0,0),t.toDataURL()}catch{return!1}return!0},pf=r=>r[0]===0&&r[1]===255&&r[2]===0&&r[3]===255,kk=r=>{const e=r.createElement("canvas"),t=100;e.width=t,e.height=t;const n=e.getContext("2d");if(!n)return Promise.reject(!1);n.fillStyle="rgb(0, 255, 0)",n.fillRect(0,0,t,t);const i=new Image,s=e.toDataURL();i.src=s;const a=bd(t,t,0,0,i);return n.fillStyle="red",n.fillRect(0,0,t,t),mf(a).then(A=>{n.drawImage(A,0,0);const o=n.getImageData(0,0,t,t).data;n.fillStyle="red",n.fillRect(0,0,t,t);const c=r.createElement("div");return c.style.backgroundImage=`url(${s})`,c.style.height=`${t}px`,pf(o)?mf(bd(t,t,0,0,c)):Promise.reject(!1)}).then(A=>(n.drawImage(A,0,0),pf(n.getImageData(0,0,t,t).data))).catch(()=>!1)},bd=(r,e,t,n,i)=>{const s="http://www.w3.org/2000/svg",a=document.createElementNS(s,"svg"),A=document.createElementNS(s,"foreignObject");return a.setAttributeNS(null,"width",r.toString()),a.setAttributeNS(null,"height",e.toString()),A.setAttributeNS(null,"width","100%"),A.setAttributeNS(null,"height","100%"),A.setAttributeNS(null,"x",t.toString()),A.setAttributeNS(null,"y",n.toString()),A.setAttributeNS(null,"externalResourcesRequired","true"),a.appendChild(A),A.appendChild(i),a},mf=r=>new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=t,n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(r))}`}),Tt={get SUPPORT_RANGE_BOUNDS(){const r=wk(document);return Object.defineProperty(Tt,"SUPPORT_RANGE_BOUNDS",{value:r}),r},get SUPPORT_WORD_BREAKING(){const r=Tt.SUPPORT_RANGE_BOUNDS&&bk(document);return Object.defineProperty(Tt,"SUPPORT_WORD_BREAKING",{value:r}),r},get SUPPORT_SVG_DRAWING(){const r=Sk(document);return Object.defineProperty(Tt,"SUPPORT_SVG_DRAWING",{value:r}),r},get SUPPORT_FOREIGNOBJECT_DRAWING(){const r=typeof Array.from=="function"&&typeof window.fetch=="function"?kk(document):Promise.resolve(!1);return Object.defineProperty(Tt,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:r}),r},get SUPPORT_CORS_IMAGES(){const r=Bk();return Object.defineProperty(Tt,"SUPPORT_CORS_IMAGES",{value:r}),r},get SUPPORT_RESPONSE_TYPE(){const r=Ck();return Object.defineProperty(Tt,"SUPPORT_RESPONSE_TYPE",{value:r}),r},get SUPPORT_CORS_XHR(){const r="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Tt,"SUPPORT_CORS_XHR",{value:r}),r},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){const r=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(Tt,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:r}),r}};class bi{constructor(e,t){this.text=e,this.bounds=t}}const Tk=(r,e,t,n)=>{const i=Uk(e,t),s=[];let a=0;return i.forEach(A=>{if(t.textDecorationLine.length||A.trim().length>0)if(Tt.SUPPORT_RANGE_BOUNDS){const o=gf(n,a,A.length).getClientRects();if(o.length>1){const c=ts(A);let l=0;c.forEach(d=>{s.push(new bi(d,It.fromDOMRectList(r,gf(n,l+a,d.length).getClientRects()))),l+=d.length})}else s.push(new bi(A,It.fromDOMRectList(r,o)))}else{const o=n.splitText(A.length);s.push(new bi(A,xk(r,n))),n=o}else Tt.SUPPORT_RANGE_BOUNDS||(n=n.splitText(A.length));a+=A.length}),s},xk=(r,e)=>{const t=e.ownerDocument;if(t){const n=t.createElement("html2canvaswrapper");n.appendChild(e.cloneNode(!0));const i=e.parentNode;if(i){i.replaceChild(n,e);const s=Ho(r,n);return n.firstChild&&i.replaceChild(n.firstChild,n),s}}return It.EMPTY},gf=(r,e,t)=>{const n=r.ownerDocument;if(!n)throw new Error("Node has no owner document");const i=n.createRange();return i.setStart(r,e),i.setEnd(r,e+t),i},ts=r=>{if(Tt.SUPPORT_NATIVE_TEXT_SEGMENTATION){const e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(r)).map(t=>t.segment)}return yk(r)},Ek=(r,e)=>{if(Tt.SUPPORT_NATIVE_TEXT_SEGMENTATION){const t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(r)).map(n=>n.segment)}return Ik(r,e)},Uk=(r,e)=>Kn(e.writingMode)||e.letterSpacing!==0?ts(r):Ek(r,e),Fk=[32,160,4961,65792,65793,4153,4241],Ik=(r,e)=>{const t=zC(r,{lineBreak:e.lineBreak,wordBreak:e.overflowWrap==="break-word"?"break-word":e.wordBreak}),n=[];let i;for(;!(i=t.next()).done;)if(i.value){const s=i.value.slice(),a=No(s);let A="";a.forEach(o=>{Fk.indexOf(o)===-1?A+=st(o):(A.length&&n.push(A),n.push(st(o)),A="")}),A.length&&n.push(A)}return n};class Qk{constructor(e,t,n){this.text=Mk(t.data,n.textTransform),this.text.length!==t.data.length&&(t.data=this.text),this.textBounds=Tk(e,this.text,n,t)}}const Mk=(r,e)=>{switch(e){case 1:return r.toLowerCase();case 3:return r.replace(_k,Rk);case 2:return r.toUpperCase();default:return r}},_k=/(^|\s|:|-|\(|\))([a-z])/g,Rk=(r,e,t)=>r.length>0?e+t.toUpperCase():r;class V1 extends Zn{constructor(e,t){super(e,t),this.src=t.currentSrc||t.src,this.intrinsicWidth=t.naturalWidth,this.intrinsicHeight=t.naturalHeight,this.context.cache.addImage(this.src)}}class z1 extends Zn{constructor(e,t){super(e,t),this.canvas=t,this.intrinsicWidth=t.width,this.intrinsicHeight=t.height}}class G1 extends Zn{constructor(e,t){super(e,t);const n=new XMLSerializer,i=Ho(e,t);t.setAttribute("width",`${i.width}px`),t.setAttribute("height",`${i.height}px`),this.svg=`data:image/svg+xml,${encodeURIComponent(n.serializeToString(t))}`,this.intrinsicWidth=t.width.baseVal.value,this.intrinsicHeight=t.height.baseVal.value,this.context.cache.addImage(this.svg)}}class q1 extends Zn{constructor(e,t){super(e,t),this.value=t.value}}class Bd extends Zn{constructor(e,t){super(e,t),this.start=t.start,this.reversed=typeof t.reversed=="boolean"&&t.reversed===!0}}const Pk=[{type:15,flags:0,unit:"px",number:3}],Dk=[{type:16,flags:0,number:50}],Lk=r=>r.width>r.height?new It(r.left+(r.width-r.height)/2,r.top,r.height,r.height):r.width<r.height?new It(r.left,r.top+(r.height-r.width)/2,r.width,r.width):r,Ok=r=>{const e=r.type===Nk?new Array(r.value.length+1).join("•"):r.value;return e.length===0?r.placeholder||"":e},Hk=r=>r.value.length===0&&!!r.placeholder,oo="checkbox",co="radio",Nk="password",vf=707406591,Kk=1970632191;class ea extends Zn{constructor(e,t){switch(super(e,t),this.type=t.type.toLowerCase(),this.checked=t.checked,this.value=Ok(t),this.isPlaceholder=Hk(t),(this.type===oo||this.type===co)&&(this.styles.backgroundColor=3739148031,this.styles.borderTopColor=this.styles.borderRightColor=this.styles.borderBottomColor=this.styles.borderLeftColor=2779096575,this.styles.borderTopWidth=this.styles.borderRightWidth=this.styles.borderBottomWidth=this.styles.borderLeftWidth=1,this.styles.borderTopStyle=this.styles.borderRightStyle=this.styles.borderBottomStyle=this.styles.borderLeftStyle=1,this.styles.backgroundClip=[0],this.styles.backgroundOrigin=[0],this.bounds=Lk(this.bounds)),this.type){case oo:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=Pk;break;case co:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=Dk;break}}}class W1 extends Zn{constructor(e,t){super(e,t);const n=t.options[t.selectedIndex||0];this.value=n&&n.text||""}}class $1 extends Zn{constructor(e,t){super(e,t),this.value=t.value}}class j1 extends Zn{constructor(e,t,n){super(e,t),this.src=t.src,this.width=parseInt(t.width,10)||0,this.height=parseInt(t.height,10)||0,this.backgroundColor=this.styles.backgroundColor,this.parseTreeFn=n;try{if(t.contentWindow&&t.contentWindow.document&&t.contentWindow.document.documentElement&&this.parseTreeFn){this.tree=this.parseTreeFn(e,t.contentWindow.document.documentElement);const i=t.contentWindow.document.documentElement?Zi(e,getComputedStyle(t.contentWindow.document.documentElement).backgroundColor):jn.TRANSPARENT,s=t.contentWindow.document.body?Zi(e,getComputedStyle(t.contentWindow.document.body).backgroundColor):jn.TRANSPARENT;this.backgroundColor=Vr(i)?Vr(s)?this.styles.backgroundColor:s:i}}catch{}}}const Vk=["OL","UL","MENU"],FA=(r,e,t,n)=>{for(let i=e.firstChild,s;i;i=s)if(s=i.nextSibling,N1(i)&&i.data.length>0)t.textNodes.push(new Qk(r,i,t.styles));else if(lr(i))if(Ns(i)&&i.assignedNodes)i.assignedNodes().forEach(a=>FA(r,a,t,n));else{const a=X1(r,i);a.styles.isVisible()&&(zk(i,a,n)?a.flags|=4:Gk(a.styles)&&(a.flags|=2),Vk.indexOf(i.tagName)!==-1&&(a.flags|=8),t.elements.push(a),i.slot,i.shadowRoot?FA(r,i.shadowRoot,a,n):!lo(i)&&!Y1(i)&&!uo(i)&&FA(r,i,a,n))}},X1=(r,e)=>Cd(e)?new V1(r,e):Z1(e)?new z1(r,e):Y1(e)?new G1(r,e):V6(e)?new q1(r,e):z6(e)?new Bd(r,e):qk(e)?new ea(r,e):uo(e)?new W1(r,e):lo(e)?new $1(r,e):ev(e)?new j1(r,e,J1):new Zn(r,e),J1=(r,e)=>{const t=X1(r,e);return t.flags|=4,FA(r,e,t,t),t},zk=(r,e,t)=>e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||Fu(r)&&t.styles.isTransparent(),Gk=r=>r.isPositioned()||r.isFloating()?!0:Ye(r.display,268435456)||Ye(r.display,33554432)||Ye(r.display,536870912)||Ye(r.display,134217728),qk=r=>r.tagName==="INPUT",Wk=r=>r.tagName==="HTML",Y1=r=>r.tagName==="svg",Fu=r=>r.tagName==="BODY",Z1=r=>r.tagName==="CANVAS",yf=r=>r.tagName==="VIDEO",Cd=r=>r.tagName==="IMG",ev=r=>r.tagName==="IFRAME",Jc=r=>r.tagName==="STYLE",wf=r=>r.tagName==="SCRIPT",lo=r=>r.tagName==="TEXTAREA",uo=r=>r.tagName==="SELECT",Ns=r=>r.tagName==="SLOT";class $k{constructor(){this.counters={}}getCounterValue(e){const t=this.counters[e];return t&&t.length?t[t.length-1]:1}getCounterValues(e){const t=this.counters[e];return t||[]}pop(e){e.forEach(t=>this.counters[t].pop())}parse(e){const t=e.counterIncrement,n=e.counterReset;let i=!0;t!==null&&t.forEach(a=>{const A=this.counters[a.counter];A&&a.increment!==0&&(i=!1,A.length||A.push(1),A[Math.max(0,A.length-1)]+=a.increment)});const s=[];return i&&n.forEach(a=>{let A=this.counters[a.counter];s.push(a.counter),A||(A=this.counters[a.counter]=[]),A.push(a.reset)}),s}}const bf={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Bf={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},jk={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Xk={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Pi=(r,e,t,n,i,s)=>r<e||r>t?ba(r,i,s.length>0):n.integers.reduce((a,A,o)=>{for(;r>=A;)r-=A,a+=n.values[o];return a},"")+s,tv=(r,e,t,n)=>{let i="";do t||r--,i=n(r)+i,r/=e;while(r*e>=e);return i},it=(r,e,t,n,i)=>{const s=t-e+1;return(r<0?"-":"")+(tv(Math.abs(r),s,n,a=>st(Math.floor(a%s)+e))+i)},ei=(r,e,t=". ")=>{const n=e.length;return tv(Math.abs(r),n,!1,i=>e[Math.floor(i%n)])+t},Hi=1,Fr=2,Ir=4,Ks=8,ar=(r,e,t,n,i,s)=>{if(r<-9999||r>9999)return ba(r,4,i.length>0);let a=Math.abs(r),A=i;if(a===0)return e[0]+A;for(let o=0;a>0&&o<=4;o++){const c=a%10;c===0&&Ye(s,Hi)&&A!==""?A=e[c]+A:c>1||c===1&&o===0||c===1&&o===1&&Ye(s,Fr)||c===1&&o===1&&Ye(s,Ir)&&r>100||c===1&&o>1&&Ye(s,Ks)?A=e[c]+(o>0?t[o-1]:"")+A:c===1&&o>0&&(A=t[o-1]+A),a=Math.floor(a/10)}return(r<0?n:"")+A},Cf="十百千萬",Sf="拾佰仟萬",kf="マイナス",Yc="마이너스",ba=(r,e,t)=>{const n=t?". ":"",i=t?"、":"",s=t?", ":"",a=t?" ":"";switch(e){case 0:return"•"+a;case 1:return"◦"+a;case 2:return"◾"+a;case 5:const A=it(r,48,57,!0,n);return A.length<4?`0${A}`:A;case 4:return ei(r,"〇一二三四五六七八九",i);case 6:return Pi(r,1,3999,bf,3,n).toLowerCase();case 7:return Pi(r,1,3999,bf,3,n);case 8:return it(r,945,969,!1,n);case 9:return it(r,97,122,!1,n);case 10:return it(r,65,90,!1,n);case 11:return it(r,1632,1641,!0,n);case 12:case 49:return Pi(r,1,9999,Bf,3,n);case 35:return Pi(r,1,9999,Bf,3,n).toLowerCase();case 13:return it(r,2534,2543,!0,n);case 14:case 30:return it(r,6112,6121,!0,n);case 15:return ei(r,"子丑寅卯辰巳午未申酉戌亥",i);case 16:return ei(r,"甲乙丙丁戊己庚辛壬癸",i);case 17:case 48:return ar(r,"零一二三四五六七八九",Cf,"負",i,Fr|Ir|Ks);case 47:return ar(r,"零壹貳參肆伍陸柒捌玖",Sf,"負",i,Hi|Fr|Ir|Ks);case 42:return ar(r,"零一二三四五六七八九",Cf,"负",i,Fr|Ir|Ks);case 41:return ar(r,"零壹贰叁肆伍陆柒捌玖",Sf,"负",i,Hi|Fr|Ir|Ks);case 26:return ar(r,"〇一二三四五六七八九","十百千万",kf,i,0);case 25:return ar(r,"零壱弐参四伍六七八九","拾百千万",kf,i,Hi|Fr|Ir);case 31:return ar(r,"영일이삼사오육칠팔구","십백천만",Yc,s,Hi|Fr|Ir);case 33:return ar(r,"零一二三四五六七八九","十百千萬",Yc,s,0);case 32:return ar(r,"零壹貳參四五六七八九","拾百千",Yc,s,Hi|Fr|Ir);case 18:return it(r,2406,2415,!0,n);case 20:return Pi(r,1,19999,Xk,3,n);case 21:return it(r,2790,2799,!0,n);case 22:return it(r,2662,2671,!0,n);case 52:return Pi(r,1,10999,jk,3,n);case 23:return ei(r,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return ei(r,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return it(r,3302,3311,!0,n);case 28:return ei(r,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",i);case 29:return ei(r,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",i);case 34:return it(r,3792,3801,!0,n);case 37:return it(r,6160,6169,!0,n);case 38:return it(r,4160,4169,!0,n);case 39:return it(r,2918,2927,!0,n);case 40:return it(r,1776,1785,!0,n);case 43:return it(r,3046,3055,!0,n);case 44:return it(r,3174,3183,!0,n);case 45:return it(r,3664,3673,!0,n);case 46:return it(r,3872,3881,!0,n);case 3:default:return it(r,48,57,!0,n)}},Sd="data-html2canvas-ignore",Jk=r=>{let e=r;for(;e;){if(e.parentNode&&e.parentNode.host)return e.parentNode;const t=e.getRootNode();if(t&&t!==e.ownerDocument&&t.host)return t;e=e.parentNode}return null};class Tf{constructor(e,t,n){if(this.context=e,this.options=n,this.scrolledElements=[],this.referenceElement=t,this.counters=new $k,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");if(!this.options.iframeContainer){const i=Jk(t);i&&(this.options.iframeContainer=i)}this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}toIFrame(e,t){var u,h;const n=Yk(e,t,this.options.iframeContainer);if(!n.contentWindow)throw new Error("Unable to find iframe window");const i=e.defaultView.pageXOffset,s=e.defaultView.pageYOffset,a=n.contentWindow,A=a.document,o=tT(n).then(async()=>{this.scrolledElements.forEach(sT),a&&(a.scrollTo(t.left,t.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(a.scrollY!==t.top||a.scrollX!==t.left)&&(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(a.scrollX-t.left,a.scrollY-t.top,0,0)));const p=this.options.onclone,g=this.clonedReferenceElement;if(typeof g>"u")throw new Error(`Error finding the ${this.referenceElement.nodeName} in the cloned document`);return A.fonts&&A.fonts.ready&&await A.fonts.ready,/(AppleWebKit)/g.test(navigator.userAgent)&&await eT(A),typeof p=="function"?Promise.resolve().then(()=>p(A,g)).then(()=>n):n}),c=e.baseURI;A.open();const l=rT(document.doctype)+"<html></html>";try{const p=(u=this.referenceElement.ownerDocument)==null?void 0:u.defaultView,g=p&&p.trustedTypes;let v=(h=g==null?void 0:g.getPolicy)==null?void 0:h.call(g,"html2canvas-pro");!v&&g&&(v=g.createPolicy("html2canvas-pro",{createHTML:w=>w})),v?A.write(v.createHTML(l)):A.write(l)}catch{A.write(l)}iT(this.referenceElement.ownerDocument,i,s),A.close();const d=A.adoptNode(this.documentElement);return lT(d,c),A.replaceChild(d,A.documentElement),o}createElementClone(e){if(wd(e,2),Z1(e))return this.createCanvasClone(e);if(yf(e))return this.createVideoClone(e);if(Jc(e))return this.createStyleClone(e);const t=e.cloneNode(!1);return Cd(t)&&(Cd(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager")),nf(t)&&!zi(t)?this.createCustomElementClone(t):t}createCustomElementClone(e){const t=document.createElement("div");if(t.className=e.className,Zc(e.style,t),e.shadowRoot)try{t.attachShadow({mode:"open"})}catch(n){this.context.logger.error("Failed to attach shadow root to custom element clone:",n)}return t}createStyleClone(e){try{const n=e.sheet;if(n&&n.cssRules){const i=[].slice.call(n.cssRules,0).reduce((a,A)=>A&&typeof A.cssText=="string"?a+A.cssText:a,""),s=e.cloneNode(!1);return s.textContent=i,this.options.cspNonce&&(s.nonce=this.options.cspNonce),s}}catch(n){if(this.context.logger.error("Unable to access cssRules property",n),n.name!=="SecurityError")throw n}const t=e.cloneNode(!1);return this.options.cspNonce&&(t.nonce=this.options.cspNonce),t}createCanvasClone(e){if(this.options.inlineImages&&e.ownerDocument){const n=e.ownerDocument.createElement("img");try{return n.src=e.toDataURL(),n}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}const t=e.cloneNode(!1);try{t.width=e.width,t.height=e.height;const n=e.getContext("2d"),i=t.getContext("2d",{willReadFrequently:!0});if(i)if(!this.options.allowTaint&&n)i.putImageData(n.getImageData(0,0,e.width,e.height),0,0);else{const s=e.getContext("webgl2")??e.getContext("webgl");if(s){const a=s.getContextAttributes();(a==null?void 0:a.preserveDrawingBuffer)===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}i.drawImage(e,0,0)}return t}catch{this.context.logger.info("Unable to clone canvas as it is tainted",e)}return t}createVideoClone(e){const t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;const n=t.getContext("2d");try{return n&&(n.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||n.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info("Unable to clone video as it is tainted",e)}const i=e.ownerDocument.createElement("canvas");return i.width=e.offsetWidth,i.height=e.offsetHeight,i}appendChildNode(e,t,n){(!lr(t)||!wf(t)&&!t.hasAttribute(Sd)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(t)))&&(!this.options.copyStyles||!lr(t)||!Jc(t))&&e.appendChild(this.cloneNode(t,n))}shouldCloneChild(e){return!lr(e)||!wf(e)&&!e.hasAttribute(Sd)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(e))}shouldCloneStyleElement(e){return!this.options.copyStyles||!lr(e)||!Jc(e)}safeAppendClonedChild(e,t,n){this.shouldCloneChild(t)&&this.shouldCloneStyleElement(t)&&e.appendChild(this.cloneNode(t,n))}cloneAssignedNodes(e,t,n){e.forEach(i=>{this.safeAppendClonedChild(t,i,n)})}cloneSlotFallbackContent(e,t,n){for(let i=e.firstChild;i;i=i.nextSibling)this.safeAppendClonedChild(t,i,n)}cloneSlotElement(e,t,n){if(!Ns(e))return;const i=e;if(typeof i.assignedNodes!="function"){this.context.logger.warn("HTMLSlotElement.assignedNodes is not available",e),this.cloneSlotFallbackContent(e,t,n);return}const s=i.assignedNodes();if(!s||!Array.isArray(s)){this.context.logger.warn("assignedNodes() did not return a valid array",e),this.cloneSlotFallbackContent(e,t,n);return}s.length>0?this.cloneAssignedNodes(s,t,n):this.cloneSlotFallbackContent(e,t,n)}cloneShadowDOMChildren(e,t,n){for(let i=e.firstChild;i;i=i.nextSibling)lr(i)&&Ns(i)?this.cloneSlotElement(i,t,n):this.safeAppendClonedChild(t,i,n)}cloneLightDOMChildren(e,t,n){for(let i=e.firstChild;i;i=i.nextSibling)this.appendChildNode(t,i,n)}cloneSlotElementAsLightDOM(e,t,n){if(!Ns(e))return;const i=e;if(typeof i.assignedNodes!="function"){for(let a=e.firstChild;a;a=a.nextSibling)this.appendChildNode(t,a,n);return}const s=i.assignedNodes();if(s&&Array.isArray(s)&&s.length>0)s.forEach(a=>this.appendChildNode(t,a,n));else for(let a=e.firstChild;a;a=a.nextSibling)this.appendChildNode(t,a,n)}cloneShadowDOMAsLightDOM(e,t,n){for(let i=e.firstChild;i;i=i.nextSibling)lr(i)&&Ns(i)?this.cloneSlotElementAsLightDOM(i,t,n):this.appendChildNode(t,i,n)}cloneChildNodes(e,t,n){e.shadowRoot&&t.shadowRoot?(this.cloneShadowDOMChildren(e.shadowRoot,t.shadowRoot,n),this.cloneLightDOMChildren(e,t,n)):e.shadowRoot&&!t.shadowRoot?this.cloneShadowDOMAsLightDOM(e.shadowRoot,t,n):this.cloneLightDOMChildren(e,t,n)}cloneNode(e,t){if(N1(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);const n=e.ownerDocument.defaultView;if(n&&lr(e)&&(wa(e)||zi(e))){const i=this.createElementClone(e);i.style.transitionProperty="none";const s=n.getComputedStyle(e),a=n.getComputedStyle(e,":before"),A=n.getComputedStyle(e,":after");this.referenceElement===e&&wa(i)&&(this.clonedReferenceElement=i),Fu(i)&&oT(i,this.options.cspNonce);const o=this.counters.parse(new tf(this.context,s)),c=this.resolvePseudoContent(e,i,a,ta.BEFORE);nf(e)&&(t=!0),yf(e)||this.cloneChildNodes(e,i,t),c&&i.insertBefore(c,i.firstChild);const l=this.resolvePseudoContent(e,i,A,ta.AFTER);return l&&i.appendChild(l),this.counters.pop(o),(s&&(this.options.copyStyles||zi(e))&&!ev(e)||t)&&Zc(s,i),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([i,e.scrollLeft,e.scrollTop]),(lo(e)||uo(e))&&(lo(i)||uo(i))&&(i.value=e.value),i}return e.cloneNode(!1)}resolvePseudoContent(e,t,n,i){if(!n)return;const s=n.content,a=t.ownerDocument;if(!a||!s||s==="none"||s==="-moz-alt-content"||n.display==="none")return;this.counters.parse(new tf(this.context,n));const A=new K6(this.context,n),o=a.createElement("html2canvaspseudoelement");Zc(n,o),A.content.forEach(l=>{if(l.type===0)o.appendChild(a.createTextNode(l.value));else if(l.type===22){const d=a.createElement("img");d.src=l.value,d.style.opacity="1",o.appendChild(d)}else if(l.type===18){if(l.name==="attr"){const d=l.values.filter(ve);d.length&&o.appendChild(a.createTextNode(e.getAttribute(d[0].value)||""))}else if(l.name==="counter"){const[d,u]=l.values.filter(Et);if(d&&ve(d)){const h=this.counters.getCounterValue(d.value),p=u&&ve(u)?yd.parse(this.context,u.value):3;o.appendChild(a.createTextNode(ba(h,p,!1)))}}else if(l.name==="counters"){const[d,u,h]=l.values.filter(Et);if(d&&ve(d)){const p=this.counters.getCounterValues(d.value),g=h&&ve(h)?yd.parse(this.context,h.value):3,v=u&&u.type===0?u.value:"",w=p.map(B=>ba(B,g,!1)).join(v);o.appendChild(a.createTextNode(w))}}}else if(l.type===20)switch(l.value){case"open-quote":o.appendChild(a.createTextNode(ef(A.quotes,this.quoteDepth++,!0)));break;case"close-quote":o.appendChild(a.createTextNode(ef(A.quotes,--this.quoteDepth,!1)));break;default:o.appendChild(a.createTextNode(l.value))}}),o.className=`${kd} ${Td}`;const c=i===ta.BEFORE?` ${kd}`:` ${Td}`;return zi(t)?t.className.baseValue+=c:t.className+=c,o}static destroy(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1}}var ta;(function(r){r[r.BEFORE=0]="BEFORE",r[r.AFTER=1]="AFTER"})(ta||(ta={}));const Yk=(r,e,t)=>{const n=r.createElement("iframe");return n.className="html2canvas-container",n.style.visibility="hidden",n.style.position="fixed",n.style.left="-10000px",n.style.top="0px",n.style.border="0",n.width=e.width.toString(),n.height=e.height.toString(),n.scrolling="no",n.setAttribute(Sd,"true"),(t||r.body).appendChild(n),n},Zk=r=>new Promise(e=>{if(r.complete){e();return}if(!r.src){e();return}r.onload=e,r.onerror=e}),eT=r=>Promise.all([].slice.call(r.images,0).map(Zk)),tT=r=>new Promise((e,t)=>{const n=r.contentWindow;if(!n)return t("No window assigned for iframe");const i=n.document;n.onload=r.onload=()=>{n.onload=r.onload=null;const s=setInterval(()=>{i.body.childNodes.length>0&&i.readyState==="complete"&&(clearInterval(s),e(r))},50)}}),nT=["all","d","content"],Zc=(r,e)=>{for(let t=r.length-1;t>=0;t--){const n=r.item(t);nT.indexOf(n)===-1&&!n.startsWith("--")&&e.style.setProperty(n,r.getPropertyValue(n))}return e},rT=r=>{let e="";return r&&(e+="<!DOCTYPE ",r.name&&(e+=r.name),r.internalSubset&&(e+=" "+r.internalSubset.replace(/"/g,""").replace(/>/g,">")),r.publicId?(e+=' PUBLIC "'+r.publicId.replace(/"/g,""")+'"',r.systemId&&(e+=' "'+r.systemId.replace(/"/g,""")+'"')):r.systemId&&(e+=' SYSTEM "'+r.systemId.replace(/"/g,""")+'"'),e+=">"),e},iT=(r,e,t)=>{r&&r.defaultView&&(e!==r.defaultView.pageXOffset||t!==r.defaultView.pageYOffset)&&r.defaultView.scrollTo(e,t)},sT=([r,e,t])=>{r.scrollLeft=e,r.scrollTop=t},aT=":before",AT=":after",kd="___html2canvas___pseudoelement_before",Td="___html2canvas___pseudoelement_after",xf=`{
|
|
40
|
+
content: "" !important;
|
|
41
|
+
display: none !important;
|
|
42
|
+
}`,oT=(r,e)=>{cT(r,`.${kd}${aT}${xf}
|
|
43
|
+
.${Td}${AT}${xf}`,e)},cT=(r,e,t)=>{const n=r.ownerDocument;if(n){const i=n.createElement("style");i.textContent=e,t&&(i.nonce=t),r.appendChild(i)}},lT=(r,e)=>{const t=r.ownerDocument.createElement("base");t.href=e;const n=r.getElementsByTagName("head").item(0);n==null||n.insertBefore(t,(n==null?void 0:n.firstChild)??null)};class Y{constructor(e,t){this.type=0,this.x=e,this.y=t}add(e,t){return new Y(this.x+e,this.y+t)}}const Di=(r,e,t)=>new Y(r.x+(e.x-r.x)*t,r.y+(e.y-r.y)*t);class gr{constructor(e,t,n,i){this.type=1,this.start=e,this.startControl=t,this.endControl=n,this.end=i}subdivide(e,t){const n=Di(this.start,this.startControl,e),i=Di(this.startControl,this.endControl,e),s=Di(this.endControl,this.end,e),a=Di(n,i,e),A=Di(i,s,e),o=Di(a,A,e);return t?new gr(this.start,n,a,o):new gr(o,A,s,this.end)}add(e,t){return new gr(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))}reverse(){return new gr(this.end,this.endControl,this.startControl,this.start)}}const jt=r=>r.type===1;class dT{constructor(e){const t=e.styles,n=e.bounds;let[i,s]=Os(t.borderTopLeftRadius,n.width,n.height),[a,A]=Os(t.borderTopRightRadius,n.width,n.height),[o,c]=Os(t.borderBottomRightRadius,n.width,n.height),[l,d]=Os(t.borderBottomLeftRadius,n.width,n.height);const u=[];u.push((i+a)/n.width),u.push((l+o)/n.width),u.push((s+d)/n.height),u.push((A+c)/n.height);const h=Math.max(...u);h>1&&(i/=h,s/=h,a/=h,A/=h,o/=h,c/=h,l/=h,d/=h);const p=n.width-a,g=n.height-c,v=n.width-o,w=n.height-d,B=t.borderTopWidth,E=t.borderRightWidth,b=t.borderBottomWidth,C=t.borderLeftWidth,T=fe(t.paddingTop,e.bounds.width),F=fe(t.paddingRight,e.bounds.width),R=fe(t.paddingBottom,e.bounds.width),M=fe(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=i>0||s>0?He(n.left+C/3,n.top+B/3,i-C/3,s-B/3,Fe.TOP_LEFT):new Y(n.left+C/3,n.top+B/3),this.topRightBorderDoubleOuterBox=i>0||s>0?He(n.left+p,n.top+B/3,a-E/3,A-B/3,Fe.TOP_RIGHT):new Y(n.left+n.width-E/3,n.top+B/3),this.bottomRightBorderDoubleOuterBox=o>0||c>0?He(n.left+v,n.top+g,o-E/3,c-b/3,Fe.BOTTOM_RIGHT):new Y(n.left+n.width-E/3,n.top+n.height-b/3),this.bottomLeftBorderDoubleOuterBox=l>0||d>0?He(n.left+C/3,n.top+w,l-C/3,d-b/3,Fe.BOTTOM_LEFT):new Y(n.left+C/3,n.top+n.height-b/3),this.topLeftBorderDoubleInnerBox=i>0||s>0?He(n.left+C*2/3,n.top+B*2/3,i-C*2/3,s-B*2/3,Fe.TOP_LEFT):new Y(n.left+C*2/3,n.top+B*2/3),this.topRightBorderDoubleInnerBox=i>0||s>0?He(n.left+p,n.top+B*2/3,a-E*2/3,A-B*2/3,Fe.TOP_RIGHT):new Y(n.left+n.width-E*2/3,n.top+B*2/3),this.bottomRightBorderDoubleInnerBox=o>0||c>0?He(n.left+v,n.top+g,o-E*2/3,c-b*2/3,Fe.BOTTOM_RIGHT):new Y(n.left+n.width-E*2/3,n.top+n.height-b*2/3),this.bottomLeftBorderDoubleInnerBox=l>0||d>0?He(n.left+C*2/3,n.top+w,l-C*2/3,d-b*2/3,Fe.BOTTOM_LEFT):new Y(n.left+C*2/3,n.top+n.height-b*2/3),this.topLeftBorderStroke=i>0||s>0?He(n.left+C/2,n.top+B/2,i-C/2,s-B/2,Fe.TOP_LEFT):new Y(n.left+C/2,n.top+B/2),this.topRightBorderStroke=i>0||s>0?He(n.left+p,n.top+B/2,a-E/2,A-B/2,Fe.TOP_RIGHT):new Y(n.left+n.width-E/2,n.top+B/2),this.bottomRightBorderStroke=o>0||c>0?He(n.left+v,n.top+g,o-E/2,c-b/2,Fe.BOTTOM_RIGHT):new Y(n.left+n.width-E/2,n.top+n.height-b/2),this.bottomLeftBorderStroke=l>0||d>0?He(n.left+C/2,n.top+w,l-C/2,d-b/2,Fe.BOTTOM_LEFT):new Y(n.left+C/2,n.top+n.height-b/2),this.topLeftBorderBox=i>0||s>0?He(n.left,n.top,i,s,Fe.TOP_LEFT):new Y(n.left,n.top),this.topRightBorderBox=a>0||A>0?He(n.left+p,n.top,a,A,Fe.TOP_RIGHT):new Y(n.left+n.width,n.top),this.bottomRightBorderBox=o>0||c>0?He(n.left+v,n.top+g,o,c,Fe.BOTTOM_RIGHT):new Y(n.left+n.width,n.top+n.height),this.bottomLeftBorderBox=l>0||d>0?He(n.left,n.top+w,l,d,Fe.BOTTOM_LEFT):new Y(n.left,n.top+n.height),this.topLeftPaddingBox=i>0||s>0?He(n.left+C,n.top+B,Math.max(0,i-C),Math.max(0,s-B),Fe.TOP_LEFT):new Y(n.left+C,n.top+B),this.topRightPaddingBox=a>0||A>0?He(n.left+Math.min(p,n.width-E),n.top+B,p>n.width+E?0:Math.max(0,a-E),Math.max(0,A-B),Fe.TOP_RIGHT):new Y(n.left+n.width-E,n.top+B),this.bottomRightPaddingBox=o>0||c>0?He(n.left+Math.min(v,n.width-C),n.top+Math.min(g,n.height-b),Math.max(0,o-E),Math.max(0,c-b),Fe.BOTTOM_RIGHT):new Y(n.left+n.width-E,n.top+n.height-b),this.bottomLeftPaddingBox=l>0||d>0?He(n.left+C,n.top+Math.min(w,n.height-b),Math.max(0,l-C),Math.max(0,d-b),Fe.BOTTOM_LEFT):new Y(n.left+C,n.top+n.height-b),this.topLeftContentBox=i>0||s>0?He(n.left+C+M,n.top+B+T,Math.max(0,i-(C+M)),Math.max(0,s-(B+T)),Fe.TOP_LEFT):new Y(n.left+C+M,n.top+B+T),this.topRightContentBox=a>0||A>0?He(n.left+Math.min(p,n.width+C+M),n.top+B+T,p>n.width+C+M?0:a-C+M,A-(B+T),Fe.TOP_RIGHT):new Y(n.left+n.width-(E+F),n.top+B+T),this.bottomRightContentBox=o>0||c>0?He(n.left+Math.min(v,n.width-(C+M)),n.top+Math.min(g,n.height+B+T),Math.max(0,o-(E+F)),c-(b+R),Fe.BOTTOM_RIGHT):new Y(n.left+n.width-(E+F),n.top+n.height-(b+R)),this.bottomLeftContentBox=l>0||d>0?He(n.left+C+M,n.top+w,Math.max(0,l-(C+M)),d-(b+R),Fe.BOTTOM_LEFT):new Y(n.left+C+M,n.top+n.height-(b+R))}}var Fe;(function(r){r[r.TOP_LEFT=0]="TOP_LEFT",r[r.TOP_RIGHT=1]="TOP_RIGHT",r[r.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",r[r.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(Fe||(Fe={}));const He=(r,e,t,n,i)=>{const s=4*((Math.sqrt(2)-1)/3),a=t*s,A=n*s,o=r+t,c=e+n;switch(i){case Fe.TOP_LEFT:return new gr(new Y(r,c),new Y(r,c-A),new Y(o-a,e),new Y(o,e));case Fe.TOP_RIGHT:return new gr(new Y(r,e),new Y(r+a,e),new Y(o,c-A),new Y(o,c));case Fe.BOTTOM_RIGHT:return new gr(new Y(o,e),new Y(o,e+A),new Y(r+a,c),new Y(r,c));case Fe.BOTTOM_LEFT:default:return new gr(new Y(o,c),new Y(o-a,c),new Y(r,e+A),new Y(r,e))}},ho=r=>[r.topLeftBorderBox,r.topRightBorderBox,r.bottomRightBorderBox,r.bottomLeftBorderBox],uT=r=>[r.topLeftContentBox,r.topRightContentBox,r.bottomRightContentBox,r.bottomLeftContentBox],fo=r=>[r.topLeftPaddingBox,r.topRightPaddingBox,r.bottomRightPaddingBox,r.bottomLeftPaddingBox];class Ef{constructor(e,t,n){this.offsetX=e,this.offsetY=t,this.matrix=n,this.type=0,this.target=6}}class eA{constructor(e,t){this.path=e,this.target=t,this.type=1}}class hT{constructor(e){this.opacity=e,this.type=2,this.target=6}}class Us{constructor(e){this.applyClip=e,this.type=3,this.target=6}}const fT=r=>r.type===0,nv=r=>r.type===1,pT=r=>r.type===2,mT=r=>r.type===3,Uf=(r,e)=>r.length===e.length?r.some((t,n)=>t===e[n]):!1,gT=(r,e,t,n,i)=>r.map((s,a)=>{switch(a){case 0:return s.add(e,t);case 1:return s.add(e+n,t);case 2:return s.add(e+n,t+i);case 3:return s.add(e,t+i)}return s});class rv{constructor(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}}class iv{constructor(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new dT(this.container),this.container.styles.opacity<1&&this.effects.push(new hT(this.container.styles.opacity)),this.container.styles.rotate!==null){const n=this.container.styles.transformOrigin,i=this.container.bounds.left+fe(n[0],this.container.bounds.width),s=this.container.bounds.top+fe(n[1],this.container.bounds.height),A=this.container.styles.rotate*Math.PI/180,o=Math.cos(A),c=Math.sin(A),l=[o,c,-c,o,0,0];this.effects.push(new Ef(i,s,l))}if(this.container.styles.transform!==null){const n=this.container.styles.transformOrigin,i=this.container.bounds.left+fe(n[0],this.container.bounds.width),s=this.container.bounds.top+fe(n[1],this.container.bounds.height),a=this.container.styles.transform;this.effects.push(new Ef(i,s,a))}if(this.container.styles.overflowX!==0){const n=ho(this.curves),i=fo(this.curves);Uf(n,i)?this.effects.push(new eA(n,6)):(this.effects.push(new eA(n,2)),this.effects.push(new eA(i,4)))}if(this.container.styles.clipPath.type!==0){const n=vT(this.container.styles.clipPath,this.container.bounds);n&&this.effects.push(n)}}getEffects(e){let t=[2,3].indexOf(this.container.styles.position)===-1,n=this.parent;const i=this.effects.slice(0);for(;n;){const s=n.effects.filter(a=>!nv(a));if(t||n.container.styles.position!==0||!n.parent){if(t=[2,3].indexOf(n.container.styles.position)===-1,n.container.styles.overflowX!==0){const a=ho(n.curves),A=fo(n.curves);Uf(a,A)||i.unshift(new eA(A,6))}i.unshift(...s)}else i.unshift(...s);n=n.parent}return i.filter(s=>Ye(s.target,e))}}const Ff=(r,e,t,n,i)=>r==="closest-side"?Math.min(e-t,n-e):r==="farthest-side"?Math.max(e-t,n-e):fe(r,i),vT=(r,e)=>{const{left:t,top:n,width:i,height:s}=e;switch(r.type){case 1:{const a=fe(r.left,i),A=fe(r.top,s),o=t+a,c=n+A,l=Math.max(0,i-a-fe(r.right,i)),d=Math.max(0,s-A-fe(r.bottom,s));return new Us(u=>{u.beginPath(),u.rect(o,c,l,d),u.clip()})}case 2:{const a=t+fe(r.cx,i),A=n+fe(r.cy,s);let o;return r.radius==="closest-side"?o=Math.min(a-t,A-n,t+i-a,n+s-A):r.radius==="farthest-side"?o=Math.max(a-t,A-n,t+i-a,n+s-A):o=fe(r.radius,Math.sqrt(i*i+s*s)/Math.SQRT2),new Us(c=>{c.beginPath(),c.arc(a,A,Math.max(0,o),0,Math.PI*2),c.clip()})}case 3:{const a=t+fe(r.cx,i),A=n+fe(r.cy,s),o=Ff(r.rx,a,t,t+i,i),c=Ff(r.ry,A,n,n+s,s);return new Us(l=>{l.beginPath(),l.ellipse(a,A,Math.max(0,o),Math.max(0,c),0,0,Math.PI*2),l.clip()})}case 4:{const a=r.points.map(([A,o])=>[t+fe(A,i),n+fe(o,s)]);return new Us(A=>{if(A.beginPath(),a.length>0){A.moveTo(a[0][0],a[0][1]);for(let o=1;o<a.length;o++)A.lineTo(a[o][0],a[o][1]);A.closePath()}A.clip()})}case 5:{const{d:a}=r;return new Us(A=>{try{const o=A.getTransform();A.translate(t,n),A.clip(new Path2D(a)),A.setTransform(o)}catch{}})}case 0:return null;default:return null}},xd=(r,e,t,n)=>{r.container.elements.forEach(i=>{const s=Ye(i.flags,4),a=Ye(i.flags,2),A=new iv(i,r);Ye(i.styles.display,2048)&&n.push(A);const o=Ye(i.flags,8)?[]:n;if(s||a){const c=s||i.styles.isPositioned()?t:e,l=new rv(A);if(i.styles.isPositioned()||i.styles.opacity<1||i.styles.isTransformed()){const d=i.styles.zIndex.order;if(d<0){let u=0;c.negativeZIndex.some((h,p)=>d>h.element.container.styles.zIndex.order?(u=p,!1):u>0),c.negativeZIndex.splice(u,0,l)}else if(d>0){let u=0;c.positiveZIndex.some((h,p)=>d>=h.element.container.styles.zIndex.order?(u=p+1,!1):u>0),c.positiveZIndex.splice(u,0,l)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(l)}else i.styles.isFloating()?c.nonPositionedFloats.push(l):c.nonPositionedInlineLevel.push(l);xd(A,l,s?l:t,o)}else i.styles.isInlineLevel()?e.inlineLevel.push(A):e.nonInlineLevel.push(A),xd(A,e,t,o);Ye(i.flags,8)&&sv(i,o)})},sv=(r,e)=>{let t=r instanceof Bd?r.start:1;const n=r instanceof Bd?r.reversed:!1;for(let i=0;i<e.length;i++){const s=e[i];s.container instanceof q1&&typeof s.container.value=="number"&&s.container.value!==0&&(t=s.container.value),s.listValue=ba(t,s.container.styles.listStyleType,!0),t+=n?-1:1}},yT=r=>{const e=new iv(r,null),t=new rv(e),n=[];return xd(e,t,t,n),sv(e.container,n),t},av=r=>{const e=r.bounds,t=r.styles;return e.add(t.borderLeftWidth,t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth),-(t.borderTopWidth+t.borderBottomWidth))},na=r=>{const e=r.styles,t=r.bounds,n=fe(e.paddingLeft,t.width),i=fe(e.paddingRight,t.width),s=fe(e.paddingTop,t.width),a=fe(e.paddingBottom,t.width);return t.add(n+e.borderLeftWidth,s+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+n+i),-(e.borderTopWidth+e.borderBottomWidth+s+a))},wT=(r,e)=>r===0?e.bounds:r===2?na(e):av(e),bT=(r,e)=>r===0?e.bounds:r===2?na(e):av(e),el=(r,e,t)=>{const n=wT(Ni(r.styles.backgroundOrigin,e),r),i=bT(Ni(r.styles.backgroundClip,e),r),s=BT(Ni(r.styles.backgroundSize,e),t,n);let[a,A]=s;const o=Os(Ni(r.styles.backgroundPosition,e),n.width-a,n.height-A),c=CT(Ni(r.styles.backgroundRepeat,e),o,s,n,i),l=Math.round(n.left+o[0]),d=Math.round(n.top+o[1]);return a=Math.max(1,a),A=Math.max(1,A),[c,l,d,a,A]},Li=r=>ve(r)&&r.value===es.AUTO,tA=r=>typeof r=="number",BT=(r,[e,t,n],i)=>{const[s,a]=r;if(!s)return[0,0];if(Qe(s)&&a&&Qe(a))return[fe(s,i.width),fe(a,i.height)];const A=tA(n);if(ve(s)&&(s.value===es.CONTAIN||s.value===es.COVER))return tA(n)?i.width/i.height<n!=(s.value===es.COVER)?[i.width,i.width/n]:[i.height*n,i.height]:[i.width,i.height];const o=tA(e),c=tA(t),l=o||c;if(Li(s)&&(!a||Li(a))){if(o&&c)return[e,t];if(!A&&!l)return[i.width,i.height];if(l&&A){const g=o?e:t*n,v=c?t:e/n;return[g,v]}const h=o?e:i.width,p=c?t:i.height;return[h,p]}if(A){let h=0,p=0;return Qe(s)?h=fe(s,i.width):Qe(a)&&(p=fe(a,i.height)),Li(s)?h=p*n:(!a||Li(a))&&(p=h/n),[h,p]}let d=null,u=null;if(Qe(s)?d=fe(s,i.width):a&&Qe(a)&&(u=fe(a,i.height)),d!==null&&(!a||Li(a))&&(u=o&&c?d/e*t:i.height),u!==null&&Li(s)&&(d=o&&c?u/t*e:i.width),d!==null&&u!==null)return[d,u];throw new Error("Unable to calculate background-size for element")},Ni=(r,e)=>{const t=r[e];return typeof t>"u"?r[0]:t},CT=(r,[e,t],[n,i],s,a)=>{switch(r){case 2:return[new Y(Math.round(s.left),Math.round(s.top+t)),new Y(Math.round(s.left+s.width),Math.round(s.top+t)),new Y(Math.round(s.left+s.width),Math.round(i+s.top+t)),new Y(Math.round(s.left),Math.round(i+s.top+t))];case 3:return[new Y(Math.round(s.left+e),Math.round(s.top)),new Y(Math.round(s.left+e+n),Math.round(s.top)),new Y(Math.round(s.left+e+n),Math.round(s.height+s.top)),new Y(Math.round(s.left+e),Math.round(s.height+s.top))];case 1:return[new Y(Math.round(s.left+e),Math.round(s.top+t)),new Y(Math.round(s.left+e+n),Math.round(s.top+t)),new Y(Math.round(s.left+e+n),Math.round(s.top+t+i)),new Y(Math.round(s.left+e),Math.round(s.top+t+i))];default:return[new Y(Math.round(a.left),Math.round(a.top)),new Y(Math.round(a.left+a.width),Math.round(a.top)),new Y(Math.round(a.left+a.width),Math.round(a.height+a.top)),new Y(Math.round(a.left),Math.round(a.height+a.top))]}},ST="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",If="Hidden Text";class kT{constructor(e){this._data={},this._document=e}parseMetrics(e,t){const n=this._document.createElement("div"),i=this._document.createElement("img"),s=this._document.createElement("span"),a=this._document.body;n.style.visibility="hidden",n.style.fontFamily=e,n.style.fontSize=t,n.style.margin="0",n.style.padding="0",n.style.whiteSpace="nowrap",a.appendChild(n),i.src=ST,i.width=1,i.height=1,i.style.margin="0",i.style.padding="0",i.style.verticalAlign="baseline",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(If)),n.appendChild(s),n.appendChild(i);const A=i.offsetTop-s.offsetTop+2;n.removeChild(s),n.appendChild(this._document.createTextNode(If)),n.style.lineHeight="normal",i.style.verticalAlign="super";const o=i.offsetTop-n.offsetTop+2;return a.removeChild(n),{baseline:A,middle:o}}getMetrics(e,t){const n=`${e} ${t}`;return typeof this._data[n]>"u"&&(this._data[n]=this.parseMetrics(e,t)),this._data[n]}}class Av{constructor(e,t){this.context=e,this.options=t}}class TT{constructor(e){this.ctx=e.ctx,this.context=e.context,this.canvas=e.canvas}async renderBackgroundImage(e){let t=e.styles.backgroundImage.length-1;for(const n of e.styles.backgroundImage.slice(0).reverse())n.type===0?await this.renderBackgroundURLImage(e,n,t):tS(n)?this.renderLinearGradient(e,n,t):nS(n)&&this.renderRadialGradient(e,n,t),t--}async renderBackgroundURLImage(e,t,n){let i;const s=t.url;try{i=await this.context.cache.match(s)}catch{this.context.logger.error(`Error loading background-image ${s}`)}if(i){const a=isNaN(i.width)||i.width===0?1:i.width,A=isNaN(i.height)||i.height===0?1:i.height,[o,c,l,d,u]=el(e,n,[a,A,a/A]),h=this.ctx.createPattern(this.resizeImage(i,d,u,e.styles.imageRendering),"repeat");this.renderRepeat(o,h,c,l)}}renderLinearGradient(e,t,n){const[i,s,a,A,o]=el(e,n,[null,null,null]),[c,l,d,u,h]=X3(t.angle,A,o),g=(this.canvas.ownerDocument??document).createElement("canvas");g.width=A,g.height=o;const v=g.getContext("2d"),w=v.createLinearGradient(l,u,d,h);if(Xh(t.stops,c||1).forEach(B=>w.addColorStop(B.stop,Oe(B.color))),v.fillStyle=w,v.fillRect(0,0,A,o),A>0&&o>0){const B=this.ctx.createPattern(g,"repeat");this.renderRepeat(i,B,s,a)}}renderRadialGradient(e,t,n){const[i,s,a,A,o]=el(e,n,[null,null,null]),c=t.position.length===0?[fi]:t.position,l=fe(c[0],A),d=fe(c[c.length-1],o);let[u,h]=J3(t,l,d,A,o);if((u===0||h===0)&&(u=Math.max(u,.01),h=Math.max(h,.01)),u>0&&h>0){const p=this.ctx.createRadialGradient(s+l,a+d,0,s+l,a+d,u);if(Xh(t.stops,u*2).forEach(g=>p.addColorStop(g.stop,Oe(g.color))),this.path(i),this.ctx.fillStyle=p,u!==h){const g=e.bounds.left+.5*e.bounds.width,v=e.bounds.top+.5*e.bounds.height,w=h/u,B=1/w;this.ctx.save(),this.ctx.translate(g,v),this.ctx.transform(1,0,0,w,0,0),this.ctx.translate(-g,-v),this.ctx.fillRect(s,B*(a-v)+v,A,o*B),this.ctx.restore()}else this.ctx.fill()}}renderRepeat(e,t,n,i){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(n,i),this.ctx.fill(),this.ctx.translate(-n,-i)}resizeImage(e,t,n,i){const a=(this.canvas.ownerDocument??document).createElement("canvas");a.width=Math.max(1,t),a.height=Math.max(1,n);const A=a.getContext("2d");return i===an.PIXELATED||i===an.CRISP_EDGES?(this.context.logger.debug("Disabling image smoothing for background image due to CSS image-rendering"),A.imageSmoothingEnabled=!1):i===an.SMOOTH?(this.context.logger.debug("Enabling image smoothing for background image due to CSS image-rendering: smooth"),A.imageSmoothingEnabled=!0):A.imageSmoothingEnabled=this.ctx.imageSmoothingEnabled,this.ctx.imageSmoothingQuality&&(A.imageSmoothingQuality=this.ctx.imageSmoothingQuality),A.drawImage(e,0,0,e.width,e.height,0,0,t,n),a}path(e){this.ctx.beginPath(),this.formatPath(e),this.ctx.closePath()}formatPath(e){e.forEach((t,n)=>{const i=jt(t)?t.start:t;n===0?this.ctx.moveTo(i.x,i.y):this.ctx.lineTo(i.x,i.y),jt(t)&&this.ctx.bezierCurveTo(t.startControl.x,t.startControl.y,t.endControl.x,t.endControl.y,t.end.x,t.end.y)})}}const Qf=(r,e)=>{switch(e){case 0:return pn(r.topLeftBorderBox,r.topLeftPaddingBox,r.topRightBorderBox,r.topRightPaddingBox);case 1:return pn(r.topRightBorderBox,r.topRightPaddingBox,r.bottomRightBorderBox,r.bottomRightPaddingBox);case 2:return pn(r.bottomRightBorderBox,r.bottomRightPaddingBox,r.bottomLeftBorderBox,r.bottomLeftPaddingBox);case 3:default:return pn(r.bottomLeftBorderBox,r.bottomLeftPaddingBox,r.topLeftBorderBox,r.topLeftPaddingBox)}},xT=(r,e)=>{switch(e){case 0:return pn(r.topLeftBorderBox,r.topLeftBorderDoubleOuterBox,r.topRightBorderBox,r.topRightBorderDoubleOuterBox);case 1:return pn(r.topRightBorderBox,r.topRightBorderDoubleOuterBox,r.bottomRightBorderBox,r.bottomRightBorderDoubleOuterBox);case 2:return pn(r.bottomRightBorderBox,r.bottomRightBorderDoubleOuterBox,r.bottomLeftBorderBox,r.bottomLeftBorderDoubleOuterBox);case 3:default:return pn(r.bottomLeftBorderBox,r.bottomLeftBorderDoubleOuterBox,r.topLeftBorderBox,r.topLeftBorderDoubleOuterBox)}},ET=(r,e)=>{switch(e){case 0:return pn(r.topLeftBorderDoubleInnerBox,r.topLeftPaddingBox,r.topRightBorderDoubleInnerBox,r.topRightPaddingBox);case 1:return pn(r.topRightBorderDoubleInnerBox,r.topRightPaddingBox,r.bottomRightBorderDoubleInnerBox,r.bottomRightPaddingBox);case 2:return pn(r.bottomRightBorderDoubleInnerBox,r.bottomRightPaddingBox,r.bottomLeftBorderDoubleInnerBox,r.bottomLeftPaddingBox);case 3:default:return pn(r.bottomLeftBorderDoubleInnerBox,r.bottomLeftPaddingBox,r.topLeftBorderDoubleInnerBox,r.topLeftPaddingBox)}},UT=(r,e)=>{switch(e){case 0:return nA(r.topLeftBorderStroke,r.topRightBorderStroke);case 1:return nA(r.topRightBorderStroke,r.bottomRightBorderStroke);case 2:return nA(r.bottomRightBorderStroke,r.bottomLeftBorderStroke);case 3:default:return nA(r.bottomLeftBorderStroke,r.topLeftBorderStroke)}},nA=(r,e)=>{const t=[];return jt(r)?t.push(r.subdivide(.5,!1)):t.push(r),jt(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},pn=(r,e,t,n)=>{const i=[];return jt(r)?i.push(r.subdivide(.5,!1)):i.push(r),jt(t)?i.push(t.subdivide(.5,!0)):i.push(t),jt(n)?i.push(n.subdivide(.5,!0).reverse()):i.push(n),jt(e)?i.push(e.subdivide(.5,!1).reverse()):i.push(e),i};class FT{constructor(e,t){this.ctx=e.ctx,this.pathCallbacks=t}async renderSolidBorder(e,t,n){this.pathCallbacks.path(Qf(n,t)),this.ctx.fillStyle=Oe(e),this.ctx.fill()}async renderDoubleBorder(e,t,n,i){if(t<3){await this.renderSolidBorder(e,n,i);return}const s=xT(i,n);this.pathCallbacks.path(s),this.ctx.fillStyle=Oe(e),this.ctx.fill();const a=ET(i,n);this.pathCallbacks.path(a),this.ctx.fill()}async renderDashedDottedBorder(e,t,n,i,s){this.ctx.save();const a=UT(i,n),A=Qf(i,n);s===2&&(this.pathCallbacks.path(A),this.ctx.clip());let o,c,l,d;jt(A[0])?(o=A[0].start.x,c=A[0].start.y):(o=A[0].x,c=A[0].y),jt(A[1])?(l=A[1].end.x,d=A[1].end.y):(l=A[1].x,d=A[1].y);let u;n===0||n===2?u=Math.abs(o-l):u=Math.abs(c-d),this.ctx.beginPath(),s===3?this.pathCallbacks.formatPath(a):this.pathCallbacks.formatPath(A.slice(0,2));let h=t<3?t*3:t*2,p=t<3?t*2:t;s===3&&(h=t,p=t);let g=!0;if(u<=h*2)g=!1;else if(u<=h*2+p){const v=u/(2*h+p);h*=v,p*=v}else{const v=Math.floor((u+p)/(h+p)),w=(u-v*h)/(v-1),B=(u-(v+1)*h)/v;p=B<=0||Math.abs(p-w)<Math.abs(p-B)?w:B}if(g&&(s===3?this.ctx.setLineDash([0,h+p]):this.ctx.setLineDash([h,p])),s===3?(this.ctx.lineCap="round",this.ctx.lineWidth=t):this.ctx.lineWidth=t*2+1.1,this.ctx.strokeStyle=Oe(e),this.ctx.stroke(),this.ctx.setLineDash([]),s===2){if(jt(A[0])){const v=A[3],w=A[0];this.ctx.beginPath(),this.pathCallbacks.formatPath([new Y(v.end.x,v.end.y),new Y(w.start.x,w.start.y)]),this.ctx.stroke()}if(jt(A[1])){const v=A[1],w=A[2];this.ctx.beginPath(),this.pathCallbacks.formatPath([new Y(v.end.x,v.end.y),new Y(w.start.x,w.start.y)]),this.ctx.stroke()}}this.ctx.restore()}}class IT{constructor(e,t){this.activeEffects=[],this.ctx=e.ctx,this.pathCallback=t}applyEffects(e){for(;this.activeEffects.length;)this.popEffect();e.forEach(t=>this.applyEffect(t))}applyEffect(e){this.ctx.save(),pT(e)?this.ctx.globalAlpha=e.opacity:fT(e)?(this.ctx.translate(e.offsetX,e.offsetY),this.ctx.transform(e.matrix[0],e.matrix[1],e.matrix[2],e.matrix[3],e.matrix[4],e.matrix[5]),this.ctx.translate(-e.offsetX,-e.offsetY)):nv(e)?(this.pathCallback.path(e.path),this.ctx.clip()):mT(e)&&e.applyClip(this.ctx),this.activeEffects.push(e)}popEffect(){this.activeEffects.pop(),this.ctx.restore()}getActiveEffectCount(){return this.activeEffects.length}hasActiveEffects(){return this.activeEffects.length>0}}const QT=["-apple-system","system-ui"],MT=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,tl=r=>MT.test(r),_T=()=>{if(typeof navigator>"u")return null;const r=navigator.userAgent,e=/iPhone|iPad|iPod/.test(r),t=/Macintosh/.test(r)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>1;if(!e&&!t)return null;const n=[/(?:iPhone|CPU(?:\siPhone)?)\sOS\s(\d+)[\._](\d+)/,/Version\/(\d+)\.(\d+)/];for(const i of n){const s=r.match(i);if(s&&s[1])return parseInt(s[1],10)}return null},RT=r=>{const e=_T();return e!==null&&e>=15&&e<17?r.map(t=>QT.indexOf(t)!==-1?'-apple-system, "Helvetica Neue", Arial, sans-serif':t):r};class PT{constructor(e){this.ctx=e.ctx,this.options=e.options}iterateLettersWithLetterSpacing(e,t,n,i,s){if(Kn(i)){this.iterateVerticalGlyphs(e,t,n,i,s);return}const a=ts(e.text),A=e.bounds.top+n;let o=e.bounds.left;for(const c of a){if(tl(c)){const l=this.ctx.textBaseline;this.ctx.textBaseline="ideographic",s(c,o,A),this.ctx.textBaseline=l}else s(c,o,A);o+=this.ctx.measureText(c).width+t}}iterateVerticalGlyphs(e,t,n,i,s){const a=ts(e.text);let A=e.bounds.top;for(const o of a){if(h6(i)||!tl(o)&&o.trim().length>0)this.ctx.save(),this.ctx.translate(e.bounds.left+n,A),this.ctx.rotate(i===4?-Math.PI/2:Math.PI/2),s(o,0,0),this.ctx.restore();else{const c=this.ctx.textBaseline;tl(o)&&(this.ctx.textBaseline="ideographic"),s(o,e.bounds.left,A+n),this.ctx.textBaseline=c}A+=this.ctx.measureText(o).width+t}}renderTextWithLetterSpacing(e,t,n,i=0){t===0&&!Kn(i)?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+n):this.iterateLettersWithLetterSpacing(e,t,n,i,(s,a,A)=>{this.ctx.fillText(s,a,A)})}renderTextBoundWithPaintOrder(e,t,n){n.forEach(i=>{switch(i){case 0:this.ctx.fillStyle=Oe(t.color),this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode);break;case 1:t.webkitTextStrokeWidth&&e.text.trim().length&&(this.ctx.strokeStyle=Oe(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",t.letterSpacing===0&&!Kn(t.writingMode)?this.ctx.strokeText(e.text,e.bounds.left,e.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode,(s,a,A)=>this.ctx.strokeText(s,a,A)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter");break}})}renderTextDecoration(e,t){this.ctx.fillStyle=Oe(t.textDecorationColor||t.color);let n=1;typeof t.textDecorationThickness=="number"?n=t.textDecorationThickness:t.textDecorationThickness==="from-font"&&(n=Math.max(1,Math.floor(t.fontSize.number*.05)));let i=0;typeof t.textUnderlineOffset=="number"&&(i=t.textUnderlineOffset);const s=t.textDecorationStyle;t.textDecorationLine.forEach(a=>{let A=0;switch(a){case 1:A=e.top+e.height-n+i;break;case 2:A=e.top;break;case 3:A=e.top+(e.height/2-n/2);break;default:return}this.drawDecorationLine(e.left,A,e.width,n,s)})}drawDecorationLine(e,t,n,i,s){switch(s){case 0:this.ctx.fillRect(e,t,n,i);break;case 1:const a=Math.max(1,i);this.ctx.fillRect(e,t,n,i),this.ctx.fillRect(e,t+i+a,n,i);break;case 2:this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash([i,i*2]),this.ctx.lineWidth=i,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(e,t+i/2),this.ctx.lineTo(e+n,t+i/2),this.ctx.stroke(),this.ctx.restore();break;case 3:this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash([i*3,i*2]),this.ctx.lineWidth=i,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(e,t+i/2),this.ctx.lineTo(e+n,t+i/2),this.ctx.stroke(),this.ctx.restore();break;case 4:this.ctx.save(),this.ctx.beginPath(),this.ctx.lineWidth=i,this.ctx.strokeStyle=this.ctx.fillStyle;const A=i*2,o=i*4;let c=e;for(this.ctx.moveTo(c,t+i/2);c<e+n;){const l=Math.min(c+o/2,e+n);if(this.ctx.quadraticCurveTo(c+o/4,t+i/2-A,l,t+i/2),c=l,c<e+n){const d=Math.min(c+o/2,e+n);this.ctx.quadraticCurveTo(c+o/4,t+i/2+A,d,t+i/2),c=d}}this.ctx.stroke(),this.ctx.restore();break;default:this.ctx.fillRect(e,t,n,i)}}truncateTextWithEllipsis(e,t,n){const i="…",s=this.ctx.measureText(i).width,a=ts(e);if(n===0){const A=l=>this.ctx.measureText(a.slice(0,l).join("")).width+s<=t;let o=0,c=a.length;for(;o<c;){const l=o+c+1>>1;A(l)?o=l:c=l-1}return a.slice(0,o).join("")+i}else{let A=s;const o=[];for(const c of a){const l=this.ctx.measureText(c).width;if(A+l>t)break;o.push(c),A+=l+n}return o.join("")+i}}createFontStyle(e){const t=e.fontVariant.filter(s=>s==="normal"||s==="small-caps").join(""),n=RT(e.fontFamily).join(", "),i=Yn(e.fontSize)?`${e.fontSize.number}${e.fontSize.unit}`:`${e.fontSize.number}px`;return[[e.fontStyle,t,e.fontWeight,i,n].join(" "),n,i]}async renderTextNode(e,t,n){const[i]=this.createFontStyle(t);this.ctx.font=i,this.ctx.direction=t.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic";const s=t.paintOrder,a=t.fontSize.number*1.5;if(t.webkitLineClamp>0&&(t.display&2)!==0&&t.overflowY===1&&e.textBounds.length>0){const d=[];let u=[],h=e.textBounds[0].bounds.top;e.textBounds.forEach(g=>{Math.abs(g.bounds.top-h)>=a*.5?(u.length>0&&d.push(u),u=[g],h=g.bounds.top):u.push(g)}),u.length>0&&d.push(u);const p=t.webkitLineClamp;if(d.length>p){for(let v=0;v<p-1;v++)d[v].forEach(w=>{this.renderTextBoundWithPaintOrder(w,t,s)});const g=d[p-1];if(g&&g.length>0&&n){const v=g.map(C=>C.text).join(""),w=g[0],B=n.width-(w.bounds.left-n.left),E=this.truncateTextWithEllipsis(v,B,t.letterSpacing),b=new bi(E,w.bounds);s.forEach(C=>{switch(C){case 0:this.ctx.fillStyle=Oe(t.color),t.letterSpacing===0&&!Kn(t.writingMode)?this.ctx.fillText(E,w.bounds.left,w.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(b,t.letterSpacing,t.fontSize.number,t.writingMode,(T,F,R)=>this.ctx.fillText(T,F,R));break;case 1:t.webkitTextStrokeWidth&&E.trim().length&&(this.ctx.strokeStyle=Oe(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",t.letterSpacing===0&&!Kn(t.writingMode)?this.ctx.strokeText(E,w.bounds.left,w.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(b,t.letterSpacing,t.fontSize.number,t.writingMode,(T,F,R)=>this.ctx.strokeText(T,F,R)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter");break}})}return}}const o=t.textOverflow===1&&n&&t.overflowX===1&&e.textBounds.length>0;let c=!1,l="";if(o){const d=e.textBounds[0].bounds.top;if(e.textBounds.every(h=>Math.abs(h.bounds.top-d)<a*.5)){let h=e.textBounds.map(v=>v.text).join("");h=h.replace(/\s+/g," ").trim();const p=this.ctx.measureText(h).width,g=n.width;p>g&&(c=!0,l=this.truncateTextWithEllipsis(h,g,t.letterSpacing))}}if(c){const d=e.textBounds[0],u=new bi(l,d.bounds);s.forEach(h=>{switch(h){case 0:{this.ctx.fillStyle=Oe(t.color),t.letterSpacing===0&&!Kn(t.writingMode)?this.ctx.fillText(l,d.bounds.left,d.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(u,t.letterSpacing,t.fontSize.number,t.writingMode,(g,v,w)=>this.ctx.fillText(g,v,w));const p=t.textShadow;p.length&&l.trim().length&&(p.slice(0).reverse().forEach(g=>{this.ctx.shadowColor=Oe(g.color),this.ctx.shadowOffsetX=g.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=g.offsetY.number*this.options.scale,this.ctx.shadowBlur=g.blur.number,t.letterSpacing===0&&!Kn(t.writingMode)?this.ctx.fillText(l,d.bounds.left,d.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(u,t.letterSpacing,t.fontSize.number,t.writingMode,(v,w,B)=>this.ctx.fillText(v,w,B))}),this.ctx.shadowColor="",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0);break}case 1:t.webkitTextStrokeWidth&&l.trim().length&&(this.ctx.strokeStyle=Oe(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",t.letterSpacing===0&&!Kn(t.writingMode)?this.ctx.strokeText(l,d.bounds.left,d.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(u,t.letterSpacing,t.fontSize.number,t.writingMode,(p,g,v)=>this.ctx.strokeText(p,g,v)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter");break}});return}e.textBounds.forEach(d=>{s.forEach(u=>{switch(u){case 0:{this.ctx.fillStyle=Oe(t.color),this.renderTextWithLetterSpacing(d,t.letterSpacing,t.fontSize.number,t.writingMode);const h=t.textShadow;h.length&&d.text.trim().length&&(h.slice(0).reverse().forEach(p=>{this.ctx.shadowColor=Oe(p.color),this.ctx.shadowOffsetX=p.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=p.offsetY.number*this.options.scale,this.ctx.shadowBlur=p.blur.number,this.renderTextWithLetterSpacing(d,t.letterSpacing,t.fontSize.number,t.writingMode)}),this.ctx.shadowColor="",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0),t.textDecorationLine.length&&this.renderTextDecoration(d.bounds,t);break}case 1:{if(t.webkitTextStrokeWidth&&d.text.trim().length){this.ctx.strokeStyle=Oe(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round";const h=t.fontSize.number;t.letterSpacing===0&&!Kn(t.writingMode)?this.ctx.strokeText(d.text,d.bounds.left,d.bounds.top+h):this.iterateLettersWithLetterSpacing(d,t.letterSpacing,h,t.writingMode,(p,g,v)=>this.ctx.strokeText(p,g,v)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter"}break}}})})}}const DT=1e4;class Iu extends Av{constructor(e,t){super(e,t),this.canvas=t.canvas?t.canvas:document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),t.canvas||(this.canvas.width=Math.floor(t.width*t.scale),this.canvas.height=Math.floor(t.height*t.scale),this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`),this.fontMetrics=new kT(document),this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-t.x,-t.y),this.ctx.textBaseline="bottom",t.imageSmoothing!==void 0&&(this.ctx.imageSmoothingEnabled=t.imageSmoothing),t.imageSmoothingQuality&&(this.ctx.imageSmoothingQuality=t.imageSmoothingQuality),this.backgroundRenderer=new TT({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:t.width,height:t.height,scale:t.scale}}),this.borderRenderer=new FT({ctx:this.ctx},{path:n=>this.path(n),formatPath:n=>this.formatPath(n)}),this.effectsRenderer=new IT({ctx:this.ctx},{path:n=>this.path(n)}),this.textRenderer=new PT({ctx:this.ctx,context:this.context,options:{scale:t.scale}}),this.context.logger.debug(`Canvas renderer initialized (${t.width}x${t.height}) with scale ${t.scale}`)}async renderStack(e){e.element.container.styles.isVisible()&&await this.renderStackContent(e)}async renderNode(e){Ye(e.container.flags,16),e.container.styles.isVisible()&&(await this.renderNodeBackgroundAndBorders(e),await this.renderNodeContent(e))}renderReplacedElement(e,t,n){const i=n.naturalWidth||e.intrinsicWidth,s=n.naturalHeight||e.intrinsicHeight;if(n&&i>0&&s>0){const a=na(e),A=fo(t);this.path(A),this.ctx.save(),this.ctx.clip();let o=0,c=0,l=i,d=s,u=a.left,h=a.top,p=a.width,g=a.height;const{objectFit:v}=e.styles,w=p/g,B=l/d;if(v===2)B>w?(g=p/B,h+=(a.height-g)/2):(p=g*B,u+=(a.width-p)/2);else if(v===4)B>w?(l=d*w,o+=(i-l)/2):(d=l/w,c+=(s-d)/2);else if(v===8)l>p?(o+=(l-p)/2,l=p):(u+=(p-l)/2,p=l),d>g?(c+=(d-g)/2,d=g):(h+=(g-d)/2,g=d);else if(v===16){const E=B>w?p:g*B,b=l>p?l:p;E<b?B>w?(g=p/B,h+=(a.height-g)/2):(p=g*B,u+=(a.width-p)/2):(l>p?(o+=(l-p)/2,l=p):(u+=(p-l)/2,p=l),d>g?(c+=(d-g)/2,d=g):(h+=(g-d)/2,g=d))}this.ctx.drawImage(n,o,c,l,d,u,h,p,g),this.ctx.restore()}}async renderNodeContent(e){this.effectsRenderer.applyEffects(e.getEffects(4));const t=e.container,n=e.curves,i=t.styles,s=na(t);for(const a of t.textNodes)await this.textRenderer.renderTextNode(a,i,s);if(t instanceof V1)try{const a=await this.context.cache.match(t.src),A=this.ctx.imageSmoothingEnabled;i.imageRendering===an.PIXELATED||i.imageRendering===an.CRISP_EDGES?(this.context.logger.debug(`Disabling image smoothing for ${t.src} due to CSS image-rendering: ${i.imageRendering===an.PIXELATED?"pixelated":"crisp-edges"}`),this.ctx.imageSmoothingEnabled=!1):i.imageRendering===an.SMOOTH&&(this.context.logger.debug(`Enabling image smoothing for ${t.src} due to CSS image-rendering: smooth`),this.ctx.imageSmoothingEnabled=!0),this.renderReplacedElement(t,n,a),this.ctx.imageSmoothingEnabled=A}catch{this.context.logger.error(`Error loading image ${t.src}`)}if(t instanceof z1&&this.renderReplacedElement(t,n,t.canvas),t instanceof G1)try{const a=await this.context.cache.match(t.svg);this.renderReplacedElement(t,n,a)}catch{this.context.logger.error(`Error loading svg ${t.svg.substring(0,255)}`)}if(t instanceof j1&&t.tree){const A=await new Iu(this.context,{scale:this.options.scale,backgroundColor:t.backgroundColor,x:0,y:0,width:t.width,height:t.height}).render(t.tree);t.width&&t.height&&this.ctx.drawImage(A,0,0,t.width,t.height,t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height)}if(t instanceof ea){const a=Math.min(t.bounds.width,t.bounds.height);t.type===oo?t.checked&&(this.ctx.save(),this.path([new Y(t.bounds.left+a*.39363,t.bounds.top+a*.79),new Y(t.bounds.left+a*.16,t.bounds.top+a*.5549),new Y(t.bounds.left+a*.27347,t.bounds.top+a*.44071),new Y(t.bounds.left+a*.39694,t.bounds.top+a*.5649),new Y(t.bounds.left+a*.72983,t.bounds.top+a*.23),new Y(t.bounds.left+a*.84,t.bounds.top+a*.34085),new Y(t.bounds.left+a*.39363,t.bounds.top+a*.79)]),this.ctx.fillStyle=Oe(vf),this.ctx.fill(),this.ctx.restore()):t.type===co&&t.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(t.bounds.left+a/2,t.bounds.top+a/2,a/4,0,Math.PI*2,!0),this.ctx.fillStyle=Oe(vf),this.ctx.fill(),this.ctx.restore())}if(LT(t)&&t.value.length){const[a,A,o]=this.textRenderer.createFontStyle(i),{baseline:c}=this.fontMetrics.getMetrics(A,o);this.ctx.font=a;const l=t instanceof ea&&t.isPlaceholder;this.ctx.fillStyle=Oe(l?Kk:i.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=HT(t.styles.textAlign);const d=na(t);let u=0;switch(t.styles.textAlign){case 1:u+=d.width/2;break;case 2:u+=d.width;break}let h=0;if(t instanceof ea){const g=fe(i.fontSize,0);h=(d.height-g)/2}const p=d.add(u,h,0,0);this.ctx.save(),this.path([new Y(d.left,d.top),new Y(d.left+d.width,d.top),new Y(d.left+d.width,d.top+d.height),new Y(d.left,d.top+d.height)]),this.ctx.clip(),this.textRenderer.renderTextWithLetterSpacing(new bi(t.value,p),i.letterSpacing,c,i.writingMode),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(Ye(t.styles.display,2048)){if(t.styles.listStyleImage!==null){const a=t.styles.listStyleImage;if(a.type===0){let A;const o=a.url;try{A=await this.context.cache.match(o),this.ctx.drawImage(A,t.bounds.left-(A.width+10),t.bounds.top)}catch{this.context.logger.error(`Error loading list-style-image ${o}`)}}}else if(e.listValue&&t.styles.listStyleType!==-1){const[a]=this.textRenderer.createFontStyle(i);this.ctx.font=a,this.ctx.fillStyle=Oe(i.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right";const A=new It(t.bounds.left,t.bounds.top+fe(t.styles.paddingTop,t.bounds.width),t.bounds.width,Yh(i.lineHeight,i.fontSize.number)/2+1);this.textRenderer.renderTextWithLetterSpacing(new bi(e.listValue,A),i.letterSpacing,Yh(i.lineHeight,i.fontSize.number)/2+2,i.writingMode),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"}}}async renderStackContent(e){Ye(e.element.container.flags,16),await this.renderNodeBackgroundAndBorders(e.element);for(const t of e.negativeZIndex)await this.renderStack(t);await this.renderNodeContent(e.element);for(const t of e.nonInlineLevel)await this.renderNode(t);for(const t of e.nonPositionedFloats)await this.renderStack(t);for(const t of e.nonPositionedInlineLevel)await this.renderStack(t);for(const t of e.inlineLevel)await this.renderNode(t);for(const t of e.zeroOrAutoZIndexOrTransformedOrOpacity)await this.renderStack(t);for(const t of e.positiveZIndex)await this.renderStack(t)}mask(e){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.options.width,0),this.ctx.lineTo(this.options.width,this.options.height),this.ctx.lineTo(0,this.options.height),this.ctx.lineTo(0,0),this.formatPath(e.slice(0).reverse()),this.ctx.closePath()}path(e){this.ctx.beginPath(),this.formatPath(e),this.ctx.closePath()}formatPath(e){e.forEach((t,n)=>{const i=jt(t)?t.start:t;n===0?this.ctx.moveTo(i.x,i.y):this.ctx.lineTo(i.x,i.y),jt(t)&&this.ctx.bezierCurveTo(t.startControl.x,t.startControl.y,t.endControl.x,t.endControl.y,t.end.x,t.end.y)})}async renderNodeBackgroundAndBorders(e){this.effectsRenderer.applyEffects(e.getEffects(2));const t=e.container.styles,n=!Vr(t.backgroundColor)||t.backgroundImage.length,i=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],s=OT(Ni(t.backgroundClip,0),e.curves);(n||t.boxShadow.length)&&(this.ctx.save(),this.path(s),this.ctx.clip(),Vr(t.backgroundColor)||(this.ctx.fillStyle=Oe(t.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(e.container),this.ctx.restore(),t.boxShadow.slice(0).reverse().forEach(A=>{this.ctx.save();const o=ho(e.curves),c=A.inset?0:DT,l=gT(o,-c+(A.inset?1:-1)*A.spread.number,(A.inset?1:-1)*A.spread.number,A.spread.number*(A.inset?-2:2),A.spread.number*(A.inset?-2:2));A.inset?(this.path(o),this.ctx.clip(),this.mask(l)):(this.mask(o),this.ctx.clip(),this.path(l)),this.ctx.shadowOffsetX=A.offsetX.number+c,this.ctx.shadowOffsetY=A.offsetY.number,this.ctx.shadowColor=Oe(A.color),this.ctx.shadowBlur=A.blur.number,this.ctx.fillStyle=A.inset?Oe(A.color):"rgba(0,0,0,1)",this.ctx.fill(),this.ctx.restore()}));let a=0;for(const A of i)A.style!==0&&!Vr(A.color)&&A.width>0&&(A.style===2?await this.borderRenderer.renderDashedDottedBorder(A.color,A.width,a,e.curves,2):A.style===3?await this.borderRenderer.renderDashedDottedBorder(A.color,A.width,a,e.curves,3):A.style===4?await this.borderRenderer.renderDoubleBorder(A.color,A.width,a,e.curves):await this.borderRenderer.renderSolidBorder(A.color,a,e.curves)),a++}async render(e){this.options.backgroundColor&&(this.ctx.fillStyle=Oe(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));const t=yT(e);return await this.renderStack(t),this.effectsRenderer.applyEffects([]),this.canvas}}const LT=r=>r instanceof $1||r instanceof W1?!0:r instanceof ea&&r.type!==co&&r.type!==oo,OT=(r,e)=>{switch(r){case 0:return ho(e);case 2:return uT(e);case 1:default:return fo(e)}},HT=r=>{switch(r){case 1:return"center";case 2:return"right";case 0:default:return"left"}};class NT extends Av{constructor(e,t){super(e,t),this.canvas=t.canvas?t.canvas:document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.options=t,this.canvas.width=Math.floor(t.width*t.scale),this.canvas.height=Math.floor(t.height*t.scale),this.canvas.style.width=`${t.width}px`,this.canvas.style.height=`${t.height}px`,this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-t.x,-t.y),this.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (${t.width}x${t.height} at ${t.x},${t.y}) with scale ${t.scale}`)}async render(e){const t=bd(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),n=await KT(t);return this.options.backgroundColor&&(this.ctx.fillStyle=Oe(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(n,-this.options.x*this.options.scale,-this.options.y*this.options.scale),this.canvas}}const KT=r=>new Promise((e,t)=>{const n=new Image;n.onload=()=>{e(n)},n.onerror=t,n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(r))}`});class ov{constructor({id:e,enabled:t}){this.id=e,this.enabled=t,this.start=Date.now()}debug(...e){this.enabled&&(typeof window<"u"&&window.console&&typeof console.debug=="function"||this.info(...e))}getTime(){return Date.now()-this.start}info(...e){this.enabled&&typeof window<"u"&&window.console}warn(...e){this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"||this.info(...e))}error(...e){this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"||this.info(...e))}}ov.instances={};class VT{constructor(e,t){if(this.context=e,this._options=t,this._cache=new Map,this._pendingOperations=new Map,this.maxSize=t.maxCacheSize??100,this.maxSize<1)throw new Error("Cache maxSize must be at least 1");this.maxSize>1e4&&this.context.logger.warn(`Cache maxSize ${this.maxSize} is very large and may cause memory issues. Consider using a smaller value (recommended: 100-1000).`)}addImage(e){const t=this._pendingOperations.get(e);if(t)return t;if(this.has(e)){const n=this._cache.get(e);return n&&(n.lastAccessed=Date.now()),Promise.resolve()}if(rl(e)||WT(e)){const n=this._addImageInternal(e);return this._pendingOperations.set(e,n),n.finally(()=>{this._pendingOperations.delete(e)}),n}return Promise.resolve()}async _addImageInternal(e){const t=this._options.imageTimeout??15e3,n=new Promise((s,a)=>{setTimeout(()=>{a(new Error(`Image load timeout after ${t}ms: ${e}`))},t)}),i=Promise.race([this.loadImage(e),n]);i.catch(s=>{this.context.logger.error(`Failed to load image ${e}: ${s instanceof Error?s.message:"Unknown error"}`)}),this.set(e,i)}match(e){const t=this._cache.get(e);if(t)return t.lastAccessed=Date.now(),t.value}set(e,t){if(this._cache.has(e)){const n=this._cache.get(e);n.value=t,n.lastAccessed=Date.now();return}this._cache.size>=this.maxSize&&this.evictLRU(),this._cache.set(e,{value:t,lastAccessed:Date.now()})}evictLRU(){let e=null,t=1/0;for(const[n,i]of this._cache.entries())i.lastAccessed<t&&(t=i.lastAccessed,e=n);e&&(this._cache.delete(e),this.context.logger.debug(`Cache: Evicted LRU entry: ${e}`))}size(){return this._cache.size}getMaxSize(){return this.maxSize}clear(){this._cache.clear()}async loadImage(e){const t=this.context.originChecker,n=o=>t.isSameOrigin(o),i=typeof this._options.customIsSameOrigin=="function"?await this._options.customIsSameOrigin(e,n):n(e),s=!nl(e)&&this._options.useCORS===!0&&Tt.SUPPORT_CORS_IMAGES&&!i,a=!nl(e)&&!i&&!rl(e)&&typeof this._options.proxy=="string"&&Tt.SUPPORT_CORS_XHR&&!s;if(!i&&this._options.allowTaint===!1&&!nl(e)&&!rl(e)&&!a&&!s)return;let A=e;return a&&(A=await this.proxy(A)),this.context.logger.debug(`Added image ${e.substring(0,256)}`),await new Promise((o,c)=>{const l=new Image;l.onload=()=>o(l),l.onerror=c,($T(A)||s)&&(l.crossOrigin="anonymous"),l.src=A,l.complete===!0&&setTimeout(()=>o(l),500),this._options.imageTimeout>0&&setTimeout(()=>c(`Timed out (${this._options.imageTimeout}ms) loading image`),this._options.imageTimeout)})}has(e){return this._cache.has(e)}keys(){return Promise.resolve(Object.keys(this._cache))}proxy(e){const t=this._options.proxy;if(!t)throw new Error("No proxy defined");const n=e.substring(0,256);return new Promise((i,s)=>{const a=Tt.SUPPORT_RESPONSE_TYPE?"blob":"text",A=new XMLHttpRequest;A.onload=()=>{if(A.status===200)if(a==="text")i(A.response);else{const c=new FileReader;c.addEventListener("load",()=>i(c.result),!1),c.addEventListener("error",l=>s(l),!1),c.readAsDataURL(A.response)}else s(`Failed to proxy resource ${n} with status code ${A.status}`)},A.onerror=s;const o=t.indexOf("?")>-1?"&":"?";if(A.open("GET",`${t}${o}url=${encodeURIComponent(e)}&responseType=${a}`),a!=="text"&&A instanceof XMLHttpRequest&&(A.responseType=a),this._options.imageTimeout){const c=this._options.imageTimeout;A.timeout=c,A.ontimeout=()=>s(`Timed out (${c}ms) proxying ${n}`)}A.send()})}}const zT=/^data:image\/svg\+xml/i,GT=/^data:image\/.*;base64,/i,qT=/^data:image\/.*/i,WT=r=>Tt.SUPPORT_SVG_DRAWING||!jT(r),nl=r=>qT.test(r),$T=r=>GT.test(r),rl=r=>r.substr(0,4)==="blob",jT=r=>r.substr(-3).toLowerCase()==="svg"||zT.test(r);class XT{constructor(e){if(!e||!e.document)throw new Error("Valid window object required for OriginChecker");if(!e.location||!e.location.href)throw new Error("Window object must have valid location");this.link=e.document.createElement("a"),this.origin=this.getOrigin(e.location.href)}getOrigin(e){return this.link.href=e,this.link.href=this.link.href,this.link.protocol+this.link.hostname+this.link.port}isSameOrigin(e){return this.getOrigin(e)===this.origin}getContextOrigin(){return this.origin}}class ec{constructor(e,t,n){this.windowBounds=t,this.instanceName=`#${ec.instanceCount++}`,this.config=n,this.logger=new ov({id:this.instanceName,enabled:e.logging}),this.originChecker=new XT(n.window),this.cache=e.cache??n.cache??new VT(this,e)}}ec.instanceCount=1;class Ba{constructor(e={}){if(this.window=e.window||(typeof window<"u"?window:null),!this.window)throw new Error("Window object is required but not available");this.cspNonce=e.cspNonce,this.cache=e.cache}static fromElement(e,t={}){const n=e.ownerDocument;if(!n)throw new Error("Element is not attached to a document");const i=n.defaultView;if(!i)throw new Error("Document is not attached to a window");return new Ba({window:i,...t})}clone(e={}){return new Ba({window:e.window||this.window,cspNonce:e.cspNonce??this.cspNonce,cache:e.cache??this.cache})}}class JT{constructor(e={}){this.config={maxImageTimeout:3e5,allowDataUrls:!0,...e}}validateUrl(e,t="general"){if(!e||typeof e!="string")return{valid:!1,error:"URL must be a non-empty string"};if(e.startsWith("data:"))return this.config.allowDataUrls?{valid:!0,sanitized:e}:{valid:!1,error:"Data URLs are not allowed"};if(e.startsWith("blob:"))return{valid:!0,sanitized:e};try{const n=new URL(e);if(!["http:","https:"].includes(n.protocol))return{valid:!1,error:`Protocol ${n.protocol} is not allowed. Only http and https are permitted.`};if(t==="proxy"&&this.config.allowedProxyDomains&&this.config.allowedProxyDomains.length>0){const i=n.hostname.toLowerCase();if(!this.config.allowedProxyDomains.some(a=>{const A=a.toLowerCase();return i===A||i.endsWith("."+A)}))return{valid:!1,error:`Proxy domain ${n.hostname} is not in the allowed list`}}if(t==="proxy"){if(!this.config.allowLocalhostProxy){const i=n.hostname.toLowerCase();if(i==="localhost"||i==="127.0.0.1"||i==="::1")return{valid:!1,error:"Localhost is not allowed for proxy URLs"};if(this.isPrivateIP(i))return{valid:!1,error:"Private IP addresses are not allowed for proxy URLs"};if(i.startsWith("169.254.")||i.startsWith("fe80:"))return{valid:!1,error:"Link-local addresses are not allowed for proxy URLs"}}return{valid:!0,sanitized:e,requiresRuntimeCheck:!0}}return{valid:!0,sanitized:e}}catch(n){return{valid:!1,error:`Invalid URL format: ${n instanceof Error?n.message:"Unknown error"}`}}}isPrivateIP(e){return[/^0\./,/^10\./,/^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\./,/^127\./,/^169\.254\./,/^172\.(1[6-9]|2[0-9]|3[0-1])\./,/^192\.0\.0\./,/^192\.0\.2\./,/^192\.168\./,/^198\.(1[8-9])\./,/^198\.51\.100\./,/^203\.0\.113\./,/^2(2[4-9]|3[0-9])\./,/^24[0-9]\./,/^255\.255\.255\.255$/].some(n=>n.test(e))?!0:e.includes(":")?this.isPrivateIPv6(e):!1}isPrivateIPv6(e){const i=e.toLowerCase().trim().replace(/^\[|\]$/g,"").split("%")[0];if(/^(0:){7}1$/.test(i)||i==="::1"||/^(0:){7}0$/.test(i)||i==="::")return!0;const s=this.expandIPv6(i);if(!s)return this.isPrivateIPv6Prefix(i);const a=parseInt(s.substring(0,2),16);if(a>=252&&a<=253)return!0;if(a===254){const A=parseInt(s.substring(2,4),16);if(A>=128&&A<=191)return!0}return a===255}expandIPv6(e){try{if(e.includes("::")){const t=e.split("::");if(t.length>2)return null;const n=t[0]?t[0].split(":"):[],i=t[1]?t[1].split(":"):[],s=8-n.length-i.length;if(s<0)return null;const a=Array(s).fill("0000");return[...n,...a,...i].map(o=>o.padStart(4,"0")).join(":")}else{const t=e.split(":");return t.length!==8?null:t.map(n=>n.padStart(4,"0")).join(":")}}catch{return null}}isPrivateIPv6Prefix(e){return!!(/^fc[0-9a-f]{0,2}:?/i.test(e)||/^fd[0-9a-f]{0,2}:?/i.test(e)||/^fe[89ab][0-9a-f]:?/i.test(e)||/^ff[0-9a-f]{0,2}:?/i.test(e))}validateCspNonce(e){return!e||typeof e!="string"?{valid:!1,error:"CSP nonce must be a non-empty string"}:e.length<16?{valid:!1,error:"CSP nonce is too short (minimum 16 characters recommended)"}:/^[A-Za-z0-9+/=_-]+$/.test(e)?{valid:!0,sanitized:e}:{valid:!1,error:"CSP nonce contains invalid characters"}}validateImageTimeout(e){return typeof e!="number"||isNaN(e)?{valid:!1,error:"Image timeout must be a number"}:e<0?{valid:!1,error:"Image timeout cannot be negative"}:this.config.maxImageTimeout&&e>this.config.maxImageTimeout?{valid:!1,error:`Image timeout ${e}ms exceeds maximum allowed ${this.config.maxImageTimeout}ms`}:{valid:!0,sanitized:e}}validateDimensions(e,t){if(typeof e!="number"||typeof t!="number")return{valid:!1,error:"Dimensions must be numbers"};if(isNaN(e)||isNaN(t))return{valid:!1,error:"Dimensions cannot be NaN"};if(e<=0||t<=0)return{valid:!1,error:"Dimensions must be positive"};const n=32767;return e>n||t>n?{valid:!1,error:`Dimensions exceed maximum allowed (${n}px)`}:{valid:!0,sanitized:{width:e,height:t}}}validateScale(e){return typeof e!="number"||isNaN(e)?{valid:!1,error:"Scale must be a number"}:e<=0?{valid:!1,error:"Scale must be positive"}:e>10?{valid:!1,error:"Scale factor too large (maximum 10x)"}:{valid:!0,sanitized:e}}validateElement(e){return e?typeof e!="object"?{valid:!1,error:"Element must be an object"}:typeof HTMLElement<"u"&&e instanceof HTMLElement?e.ownerDocument?{valid:!0}:{valid:!1,error:"Element must be attached to a document"}:e.ownerDocument?e.ownerDocument.defaultView?{valid:!0}:{valid:!1,error:"Document must be attached to a window (ownerDocument.defaultView required)"}:{valid:!1,error:"Element must be attached to a document (ownerDocument required)"}:{valid:!1,error:"Element is required"}}validateOptions(e){const t=[],n=e.proxy;if(n!=null&&typeof n=="string"&&n.length>0){const i=this.validateUrl(n,"proxy");i.valid||t.push(`Proxy: ${i.error}`)}if(e.imageTimeout!==void 0){const i=this.validateImageTimeout(e.imageTimeout);i.valid||t.push(`Image timeout: ${i.error}`)}if(e.width!==void 0||e.height!==void 0){const i=e.width??800,s=e.height??600,a=this.validateDimensions(i,s);a.valid||t.push(`Dimensions: ${a.error}`)}if(e.scale!==void 0){const i=this.validateScale(e.scale);i.valid||t.push(`Scale: ${i.error}`)}if(e.cspNonce!==void 0){const i=this.validateCspNonce(e.cspNonce);i.valid||t.push(`CSP nonce: ${i.error}`)}if(this.config.customValidator){const i=this.config.customValidator(e,"options");i.valid||t.push(`Custom validation: ${i.error}`)}return t.length>0?{valid:!1,error:t.join("; ")}:{valid:!0}}}function YT(r={}){return new JT({allowDataUrls:!0,maxImageTimeout:3e5,...r})}class ZT{constructor(e,t=!0){this.context=e,this.activeMetrics=new Map,this.completedMetrics=[],this.enabled=t,this.getTime=typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now()}start(e,t){var n;this.enabled&&(this.activeMetrics.has(e)&&((n=this.context)==null||n.logger.warn(`Performance metric '${e}' already started. Overwriting.`)),this.activeMetrics.set(e,{name:e,startTime:this.getTime(),metadata:t}))}end(e){var n,i;if(!this.enabled)return;const t=this.activeMetrics.get(e);if(!t){(n=this.context)==null||n.logger.warn(`Performance metric '${e}' not found. Was start() called?`);return}return t.endTime=this.getTime(),t.duration=t.endTime-t.startTime,this.completedMetrics.push(t),this.activeMetrics.delete(e),(i=this.context)==null||i.logger.debug(`⏱️ ${e}: ${t.duration.toFixed(2)}ms`,t.metadata),t}measure(e,t,n){this.start(e,n);try{const i=t();return this.end(e),i}catch(i){throw this.end(e),i}}async measureAsync(e,t,n){this.start(e,n);try{const i=await t();return this.end(e),i}catch(i){throw this.end(e),i}}getMetrics(){return[...this.completedMetrics]}getMetric(e){return this.completedMetrics.find(t=>t.name===e)}getSummary(){const e=this.completedMetrics.reduce((n,i)=>n+(i.duration||0),0),t=this.completedMetrics.map(n=>({name:n.name,duration:n.duration||0,percentage:e>0?((n.duration||0)/e*100).toFixed(1)+"%":"0%"}));return{totalDuration:e,metrics:this.getMetrics(),breakdown:t}}logSummary(){if(!this.enabled||this.completedMetrics.length===0||!this.context)return;const e=this.getSummary();this.context.logger.info(`
|
|
44
|
+
📊 Performance Summary (Total: ${e.totalDuration.toFixed(2)}ms):`),e.breakdown.sort((t,n)=>n.duration-t.duration).forEach(t=>{this.context.logger.info(` ${t.name.padEnd(20)} ${t.duration.toFixed(2).padStart(8)}ms ${t.percentage.padStart(6)}`)})}clear(){this.activeMetrics.clear(),this.completedMetrics.splice(0)}isEnabled(){return this.enabled}getActiveMetrics(){return Array.from(this.activeMetrics.keys())}}const cv=(r,e={},t)=>{const n=t||Ba.fromElement(r,{cspNonce:e.cspNonce,cache:e.cache});return nx(r,e,n)},ex=r=>{typeof window<"u"&&(new Ba({window,cspNonce:r}),void 0)};cv.setCspNonce=ex;const tx=r=>{["scale","width","height","imageTimeout","x","y","windowWidth","windowHeight","scrollX","scrollY"].forEach(t=>{const n=r[t];if(n!=null&&typeof n!="number"){const i=Number(n);Number.isNaN(i)||(r[t]=i)}})},nx=async(r,e,t)=>{if(tx(e),!e.skipValidation){const se=e.validator||YT(),ie=se.validateElement(r);if(!ie.valid)throw new Error(ie.error);const Z=se.validateOptions(e);if(!Z.valid)throw new Error(`Invalid options: ${Z.error}`)}if(!r||typeof r!="object")throw new Error("Invalid element provided as first argument");const n=r.ownerDocument;if(!n)throw new Error("Element is not attached to a Document");const i=n.defaultView;if(!i)throw new Error("Document is not attached to a Window");const s={allowTaint:e.allowTaint??!1,imageTimeout:e.imageTimeout??15e3,proxy:e.proxy,useCORS:e.useCORS??!1,customIsSameOrigin:e.customIsSameOrigin},a={logging:e.logging??!0,cache:e.cache??t.cache,...s},A=800,o=600,c=0,l=i,d={windowWidth:e.windowWidth??l.innerWidth??A,windowHeight:e.windowHeight??l.innerHeight??o,scrollX:e.scrollX??l.pageXOffset??c,scrollY:e.scrollY??l.pageYOffset??c},u=new It(d.scrollX,d.scrollY,d.windowWidth,d.windowHeight),h=new ec(a,u,t),p=e.enablePerformanceMonitoring??e.logging??!1,g=new ZT(h,p);g.start("total",{width:d.windowWidth,height:d.windowHeight});const v=e.foreignObjectRendering??!1,w={allowTaint:e.allowTaint??!1,onclone:e.onclone,ignoreElements:e.ignoreElements,iframeContainer:e.iframeContainer,inlineImages:v,copyStyles:v,cspNonce:e.cspNonce??t.cspNonce};h.logger.debug(`Starting document clone with size ${u.width}x${u.height} scrolled to ${-u.left},${-u.top}`),g.start("clone");const B=new Tf(h,r,w),E=B.clonedReferenceElement;if(!E)throw new Error("Unable to find element in cloned iframe");const b=await B.toIFrame(n,u);g.end("clone");const{width:C,height:T,left:F,top:R}=Fu(E)||Wk(E)?cC(E.ownerDocument):Ho(h,E),M=rx(h,E,e.backgroundColor),D={canvas:e.canvas,backgroundColor:M,scale:e.scale??i.devicePixelRatio??1,x:(e.x??0)+F,y:(e.y??0)+R,width:e.width??Math.ceil(C),height:e.height??Math.ceil(T),imageSmoothing:e.imageSmoothing,imageSmoothingQuality:e.imageSmoothingQuality};let O,H;try{return v?(h.logger.debug("Document cloned, using foreign object rendering"),g.start("render-foreignobject"),O=await new NT(h,D).render(E),g.end("render-foreignobject")):(h.logger.debug(`Document cloned, element located at ${F},${R} with size ${C}x${T} using computed rendering`),h.logger.debug("Starting DOM parsing"),g.start("parse"),H=J1(h,E),g.end("parse"),M===H.styles.backgroundColor&&(H.styles.backgroundColor=jn.TRANSPARENT),h.logger.debug(`Starting renderer for element at ${D.x},${D.y} with size ${D.width}x${D.height}`),g.start("render"),O=await new Iu(h,D).render(H),g.end("render")),g.start("cleanup"),(e.removeContainer??!0)&&(Tf.destroy(b)||h.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),g.end("cleanup"),g.end("total"),h.logger.debug("Finished rendering"),p&&g.logSummary(),O}finally{H&&H.restoreTree()}},rx=(r,e,t)=>{const n=e.ownerDocument,i=n.documentElement?Zi(r,getComputedStyle(n.documentElement).backgroundColor):jn.TRANSPARENT,s=n.body?Zi(r,getComputedStyle(n.body).backgroundColor):jn.TRANSPARENT,a=typeof t=="string"?Zi(r,t):t===null?jn.TRANSPARENT:4294967295;return e===n.documentElement?Vr(i)?Vr(s)?a:s:i:a},ix="vnr-clip-overlay";function hs(){const r=window.visualViewport;return{width:Math.round((r==null?void 0:r.width)??document.documentElement.clientWidth),height:Math.round((r==null?void 0:r.height)??document.documentElement.clientHeight),scrollX:window.scrollX,scrollY:window.scrollY}}function sx(r){var e;return((e=r.classList)==null?void 0:e.contains(ix))??!1}function ax(r){var t;return((t=r.tagName)==null?void 0:t.toLowerCase())==="vanira-convai"?!0:typeof r.closest=="function"&&!!r.closest("vanira-convai")}function lv(r){var e,t;return sx(r)||ax(r)||(e=r.classList)!=null&&e.contains("vnr-screen-overlay-root")||(t=r.classList)!=null&&t.contains("vnr-screen-vision-root")?!0:typeof r.closest=="function"&&(!!r.closest(".vnr-screen-overlay-root")||!!r.closest(".vnr-screen-vision-root"))}function Ax(r,e){if(r.width<=e)return r;const t=e/r.width,n=document.createElement("canvas");n.width=e,n.height=Math.round(r.height*t);const i=n.getContext("2d");return i?(i.drawImage(r,0,0,n.width,n.height),n):r}async function dv(r){const e=window.scrollX+r.left,t=window.scrollY+r.top;return cv(document.body,{x:e,y:t,width:r.width,height:r.height,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,scrollX:-window.scrollX,scrollY:-window.scrollY,useCORS:!0,allowTaint:!1,scale:1,ignoreElements:n=>lv(n),logging:!1})}async function uv(r,e=.88){try{const t=await new Promise(n=>r.toBlob(i=>n(i),"image/jpeg",e));if(!t)throw new Error("Failed to encode clip as JPEG");return t}catch(t){const n=t instanceof Error?t.message:String(t);throw/tainted|security|cross-origin/i.test(n)?new Error("Could not export this page region (cross-origin content). Try selecting a simpler area."):t}}const ox="vanira:clip-region-active";function Ed(r){typeof window>"u"||window.dispatchEvent(new CustomEvent(ox,{detail:{active:r}}))}const IA="vnr-clip-overlay",Mf="2147483647",cx="rgba(0, 0, 0, 0.28)";function lx(r={}){const e=r.minSizePx??24,t=r.hint??"Drag to select an area — release to clip.";return new Promise(n=>{let i=!1,s=!1,a=0,A=0,o=!1,c={left:0,top:0,width:0,height:0},l=!1,d=null;const u=Z=>{i||(i=!0,se(),n(Z))},h=document.createElement("div");h.className=IA,h.style.cssText=["position:fixed","inset:0",`z-index:${Mf}`,"cursor:crosshair","user-select:none","touch-action:none","background:transparent","font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"].join(";");const p=document.createElement("div");p.style.cssText=["position:absolute","display:none","pointer-events:none","border:2px solid #6366f1","border-radius:2px","background:transparent","box-shadow:none"].join(";");const g=document.createElement("div");g.style.cssText=["position:absolute","display:none","pointer-events:none","padding:2px 6px","border-radius:4px","font-size:11px","font-weight:600","color:#fff","background:rgba(15,23,42,0.82)","white-space:nowrap"].join(";");const v=document.createElement("div");v.className=IA,v.style.cssText=["position:fixed","top:16px","left:50%","transform:translateX(-50%)",`z-index:${Mf}`,"display:flex","align-items:center","gap:10px","padding:10px 14px","border-radius:14px","background:#0f172a","border:1px solid rgba(255,255,255,0.12)","box-shadow:0 8px 24px rgba(0,0,0,0.25)","max-width:min(520px,calc(100vw - 32px))"].join(";");const w=document.createElement("span");w.style.cssText="flex:1;font-size:13px;color:#e2e8f0;line-height:1.4",w.textContent=t;const B=document.createElement("button");B.type="button",B.textContent="Cancel",B.style.cssText=["padding:8px 12px","border:1px solid rgba(255,255,255,0.15)","border-radius:10px","background:transparent","color:#e2e8f0","font-size:13px","font-weight:600","cursor:pointer"].join(";"),v.appendChild(w),v.appendChild(B);const E=Z=>{Z.key==="Escape"&&!s&&u(null)},b=()=>l&&c.width>=e&&c.height>=e,C=()=>{l=!1,c={left:0,top:0,width:0,height:0},T()},T=()=>{if(!l||c.width<1||c.height<1){p.style.display="none",g.style.display="none";return}p.style.display="block",p.style.left=`${c.left}px`,p.style.top=`${c.top}px`,p.style.width=`${c.width}px`,p.style.height=`${c.height}px`,p.style.boxShadow=`0 0 0 9999px ${cx}`,g.style.display="block",g.textContent=`${Math.round(c.width)} × ${Math.round(c.height)}`,g.style.left=`${c.left}px`,g.style.top=`${Math.max(8,c.top-26)}px`},F=Z=>{const ee=Z instanceof Error?Z.message:"Capture failed";w.textContent=ee.length>120?`${ee.slice(0,117)}…`:ee,w.style.color="#fca5a5",window.setTimeout(()=>{w.textContent=t,w.style.color="#e2e8f0"},4500)},R=async Z=>{if(!(s||i)){s=!0,B.disabled=!0,w.textContent="Clipping…",w.style.color="#e2e8f0",h.style.visibility="hidden",v.style.visibility="hidden";try{const ee=await dv(Z),ue=await uv(ee),Ce=document.documentElement.clientWidth,Ue=document.documentElement.clientHeight;u({blob:ue,region:{x:Z.left/Ce,y:Z.top/Ue,w:Z.width/Ce,h:Z.height/Ue},viewport:{width:Ce,height:Ue},pixelSize:{width:ee.width,height:ee.height}})}catch(ee){s=!1,B.disabled=!1,h.style.visibility="visible",v.style.visibility="visible",F(ee),C()}}},M=Z=>{const ee=Z??d;if(ee!==null)try{h.releasePointerCapture(ee)}catch{}d=null},D=Z=>{if(!(!o||s)){if(o=!1,M(Z==null?void 0:Z.pointerId),b()){R({...c});return}C()}},O=Z=>{s||Z.target.closest(`.${IA}`)!==v&&(o=!0,l=!0,a=Z.clientX,A=Z.clientY,c={left:a,top:A,width:0,height:0},d=Z.pointerId,h.setPointerCapture(Z.pointerId),T())},H=Z=>{if(!o||s)return;const ee=Math.min(a,Z.clientX),ue=Math.min(A,Z.clientY),Ce=Math.max(a,Z.clientX),Ue=Math.max(A,Z.clientY);c={left:ee,top:ue,width:Ce-ee,height:Ue-ue},T()},se=()=>{Ed(!1),document.removeEventListener("keydown",E),window.removeEventListener("pointerup",ie,!0),window.removeEventListener("pointercancel",ie,!0),h.removeEventListener("pointerdown",O),h.removeEventListener("pointermove",H),h.removeEventListener("pointerup",D),h.removeEventListener("pointercancel",D),M(),h.remove(),v.remove()},ie=Z=>D(Z);B.addEventListener("click",()=>u(null)),Ed(!0),h.appendChild(p),h.appendChild(g),document.body.appendChild(h),document.body.appendChild(v),document.addEventListener("keydown",E),window.addEventListener("pointerup",ie,!0),window.addEventListener("pointercancel",ie,!0),h.addEventListener("pointerdown",O),h.addEventListener("pointermove",H),h.addEventListener("pointerup",D),h.addEventListener("pointercancel",D)})}function il(){document.querySelectorAll(`.${IA}`).forEach(r=>r.remove()),Ed(!1)}const dx=["a[href]","button:not([disabled])",'input:not([type="hidden"]):not([disabled])',"select:not([disabled])","textarea:not([disabled])",'[role="button"]','[role="link"]','[role="tab"]','[role="menuitem"]','[role="checkbox"]','[role="radio"]',"label","h1","h2","h3","h4","h5","h6","img[alt]","[data-testid]","[aria-label]","[onclick]"].join(", "),ux='[id]:not([id=""]), svg[id], polygon[id]',hx="svg[id], polygon[id], svg[data-vanira-static-diagram], svg[data-vanira-static-diagram] polygon",hv=new Set(["root","app","__next"]);function _f(r,e,t){const n=r.getScreenCTM(),i=r.ownerSVGElement;if(!n||!i)return[];const s=[];for(let a=0;a<r.points.length;a++){const A=r.points.getItem(a),o=i.createSVGPoint();o.x=A.x,o.y=A.y;const c=o.matrixTransform(n);s.push({x:c.x/e,y:c.y/t})}return s}function fx(r,e,t){if(r instanceof SVGPolygonElement){const n=_f(r,e,t);return n.length>=2?n:void 0}if(r instanceof SVGSVGElement){const n=r.querySelector("polygon");if(!n)return;const i=_f(n,e,t);return i.length>=2?i:void 0}}function Rf(r){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/([^\w-])/g,"\\$1")}function px(r){if(r.id){const i=`#${Rf(r.id)}`;try{if(document.querySelectorAll(i).length===1)return i}catch{}}const e=r.getAttribute("data-testid");if(e){const i=`[data-testid="${e.replace(/"/g,'\\"')}"]`;try{if(document.querySelectorAll(i).length===1)return i}catch{}}const t=[];let n=r;for(;n&&n!==document.body&&n!==document.documentElement;){let i=n.tagName.toLowerCase();if(n.classList.length>0){const a=[...n.classList].filter(A=>!A.startsWith("vnr-")).slice(0,2).map(A=>`.${Rf(A)}`).join("");i+=a}const s=n.parentElement;if(s){const a=[...s.children].filter(A=>A.tagName===n.tagName);a.length>1&&(i+=`:nth-of-type(${a.indexOf(n)+1})`)}t.unshift(i);try{const a=t.join(" > ");if(document.querySelectorAll(a).length===1)return a}catch{}if(n=n.parentElement,t.length>=8)break}return t.join(" > ")||r.tagName.toLowerCase()}function fv(r,e,t){const n=r.getBoundingClientRect();if(n.width<2||n.height<2||n.bottom<=0||n.right<=0||n.top>=t||n.left>=e)return!1;if(r instanceof SVGElement||r instanceof HTMLElement){const i=window.getComputedStyle(r);if(i.display==="none"||i.visibility==="hidden"||Number(i.opacity)===0)return!1}else return!1;return r.getAttribute("aria-hidden")!=="true"}function mx(r,e,t){var A;const n=((A=r.id)==null?void 0:A.toLowerCase())??"";if(hv.has(n)||r===document.body||r===document.documentElement)return!0;const i=r.tagName.toLowerCase();if(i!=="div"&&i!=="main")return!1;const s=r.getBoundingClientRect();return s.width*s.height/Math.max(1,e*t)>.9}function pv(r){return lv(r)?!0:typeof r.closest!="function"?!1:!!r.closest("script, style, noscript, template, head")}function gx(r,e){const t=r.tagName.toLowerCase();return t==="svg"||t==="polygon"?"diagram":t==="button"||e==="button"?"button":t==="a"||e==="link"?"link":t==="input"||t==="select"||t==="textarea"?"input":/^h[1-6]$/.test(t)?"heading":t==="img"?"image":t==="label"?"label":e?"interactive":"text"}function vx(r){const e=r.getAttribute("aria-label")||r.getAttribute("title")||"";if(e.trim())return e.trim().replace(/\s+/g," ").slice(0,240);if(r instanceof SVGPolygonElement&&r.id)return r.id.replace(/-/g," ").slice(0,240);if(r instanceof SVGSVGElement&&r.id)return(e.trim()||r.id.replace(/-/g," ")).slice(0,240);if(!(r instanceof HTMLElement))return r.id?r.id.replace(/-/g," ").slice(0,240):"";if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement){const n=r.getAttribute("placeholder")||r.getAttribute("name")||"";if(n.trim())return n.trim().slice(0,240)}return r instanceof HTMLImageElement&&r.alt.trim()?r.alt.trim().slice(0,240):(r.innerText||r.textContent||"").replace(/\s+/g," ").trim().slice(0,240)}function yx(r){var e,t;if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){const n=(e=r.value)==null?void 0:e.trim();return n?n.slice(0,240):void 0}if(r instanceof HTMLAnchorElement){const n=(t=r.getAttribute("href"))==null?void 0:t.trim();return n?n.slice(0,240):void 0}}function wx(r,e,t){const n=Math.round(r.left),i=Math.round(r.top),s=Math.round(r.width),a=Math.round(r.height),A=n+s/2,o=i+a/2;return{x:r.left/e,y:r.top/t,width:r.width/e,height:r.height/t,center_x:A/e,center_y:o/t,px:{left:n,top:i,width:s,height:a,center_x:Math.round(A),center_y:Math.round(o)}}}function Pf(r){var t;let e=r.label?2:0;switch(r.kind){case"diagram":e+=22;break;case"button":case"link":case"input":e+=12;break;case"heading":e+=9;break;case"interactive":e+=8;break;case"image":case"label":e+=5;break;default:e+=3}return r.kind!=="text"&&(e+=Math.min(4,r.px.width*r.px.height/12e3)),(t=r.stroke_points)!=null&&t.length&&(e+=18),r.id&&hv.has(r.id.toLowerCase())&&(e-=50),e}function po(r,e,t,n,i){if(pv(r)||mx(r,n,i)||!fv(r,n,i))return;const s=vx(r),a=yx(r),A=fx(r,n,i),o=r.id||void 0;if(!s&&!a&&!o&&!A&&r.tagName.toLowerCase()!=="input")return;const c=(r.getAttribute("role")||"").trim()||void 0,l=px(r);if(t.has(l))return;t.add(l);const d=wx(r.getBoundingClientRect(),n,i);e.push({tag:r.tagName.toLowerCase(),kind:gx(r,c??""),role:c,label:s||a||o||l,value:a,id:o,css_selector:l,stroke_points:A,...d})}function bx(r,e,t,n){for(const i of document.querySelectorAll(hx))po(i,r,e,t,n);for(const i of document.querySelectorAll("svg"))if(!(pv(i)||!fv(i,t,n)))for(const s of i.querySelectorAll("polygon"))po(s,r,e,t,n)}function Qu(r){const e=Math.max(1,Math.min(200,(r==null?void 0:r.maxElements)??80)),{width:t,height:n}=(()=>{const A=window.visualViewport;return{width:Math.round((A==null?void 0:A.width)??document.documentElement.clientWidth),height:Math.round((A==null?void 0:A.height)??document.documentElement.clientHeight)}})(),i=new Set,s=[];bx(s,i,t,n);for(const A of document.querySelectorAll(dx))po(A,s,i,t,n);for(const A of document.querySelectorAll(ux))po(A,s,i,t,n);s.sort((A,o)=>Pf(o)-Pf(A));const a=s.slice(0,e).map((A,o)=>({...A,element_id:`e${o+1}`}));return{url:window.location.href,title:document.title,viewport:{width:t,height:n},scroll:{x:window.scrollX,y:window.scrollY},coordinate_system:"normalized_viewport",elements:a}}function Df(r,e,t){const n=Math.max(1,e),i=Math.max(1,t);return Math.round(r/n*i)}function Lf(r){return r.replace(/\s+/g," ").trim().toLowerCase()}function Bx(r){try{const e=document.querySelector(r);return e?!!e.closest('[role="dialog"], dialog, [aria-modal="true"], .modal, .vnr-modal'):!1}catch{return!1}}function Cx(){return!!document.querySelector('[role="dialog"], dialog[open], [aria-modal="true"]')}function Sx(r,e){const t=Lf(e),n=Lf(r.label);return!t||!n?0:n===t?1e3:n.startsWith(t)&&t.length>=2?850:n.split(/[\s/|,;:()]+/).filter(Boolean).some(s=>s===t)?800:t.split(/[\s/|,;:()]+/).some(s=>s===n&&n.length>=3)?750:t.length>=3&&n.includes(t)?500:t.length>=4&&n.length>=4&&t.includes(n)?450:0}function tc(r,e,t){const n=r.viewport.width,i=r.viewport.height;return r.elements.map(s=>({element_id:s.element_id??s.css_selector,label:s.label,kind:s.kind,css_selector:s.css_selector,screenshot_x:Df(s.px.center_x,n,e),screenshot_y:Df(s.px.center_y,i,t),viewport_x:s.px.center_x,viewport_y:s.px.center_y,in_modal:Bx(s.css_selector)}))}function kx(r,e,t,n=45){const i=tc(r,e,t);return i.length===0?"(no interactive elements detected in viewport)":i.slice(0,n).map(s=>{const a=s.in_modal?" [modal]":"";return`- ${s.element_id}: "${s.label}" (${s.kind})${a} → point_at label="${s.label}" OR highlight_on_screen element_id="${s.element_id}"`}).join(`
|
|
45
|
+
`)}function Tx(r){const e=Number(r);return!Number.isFinite(e)||e<=0||e===960?0:Math.round(e)}function mv(r,e){const t=e.trim().toLowerCase();return!t||!(r!=null&&r.length)?null:r.find(n=>n.element_id.toLowerCase()===t)??null}function xx(r){const e=r.trim();if(!e)return null;const t=hs(),n=Qu({maxElements:100}),i=tc(n,t.width,t.height);return mv(i,e)}function Mu(r,e){if(!(r!=null&&r.length)||!e.trim())return null;const t=Cx();let n=null,i=0;for(const s of r){let a=Sx(s,e);a!==0&&(e.length<=12&&(s.kind==="button"||s.kind==="link"||s.kind==="interactive")&&(a+=30),t&&s.in_modal&&(a+=200),t&&!s.in_modal&&(a-=100),a>i&&(i=a,n=s))}return i>=450?n:null}function gv(r){const e=hs(),t=Qu({maxElements:100}),n=tc(t,e.width,e.height),i=Mu(n,r);return i?{element:i,viewportWidth:e.width,viewportHeight:e.height}:null}function Of(r){const e=hs(),t=e.width,n=e.height;if(r.label){const o=gv(r.label);if(o)return{x:o.element.viewport_x,y:o.element.viewport_y,label:o.element.label,source:"live_layout",screenshotWidth:o.viewportWidth,screenshotHeight:o.viewportHeight,viewportWidthCss:o.viewportWidth,viewportHeightCss:o.viewportHeight};const c=Mu(r.staleLayoutElements,r.label);if(c){const l=r.captureScreenshotWidth??t,d=r.captureScreenshotHeight??n,u=r.captureViewportWidth??t,h=r.captureViewportHeight??n;return{x:c.screenshot_x/l*u,y:c.screenshot_y/d*h,label:c.label,source:"stale_layout",screenshotWidth:l,screenshotHeight:d,viewportWidthCss:u,viewportHeightCss:h}}}const i=Math.max(1,r.captureScreenshotWidth??t),s=Math.max(1,r.captureScreenshotHeight??n),a=r.captureViewportWidth??t,A=r.captureViewportHeight??n;return{x:r.modelX/i*a,y:r.modelY/s*A,label:r.label??"",source:"model",screenshotWidth:i,screenshotHeight:s,viewportWidthCss:a,viewportHeightCss:A}}async function Ex(r,e,t){if(!r.videoWidth||!r.videoHeight)return null;const n=r.videoWidth,i=r.videoHeight,s=e>0?Math.min(1,e/n):1,a=Math.round(n*s),A=Math.round(i*s),o=document.createElement("canvas");o.width=a,o.height=A;const c=o.getContext("2d");if(!c)return null;c.drawImage(r,0,0,a,A);const l=await new Promise(d=>{o.toBlob(u=>d(u),"image/jpeg",t)});return l?{blob:l,widthPx:a,heightPx:A}:null}async function Ux(r,e=24,t=125){for(let n=0;n<e;n++){if(r.readyState>=2&&r.videoWidth>0)return;await new Promise(i=>setTimeout(i,t))}}function Fx(r){return r==="browser"?"user's browser tab (cursor is here — primary focus)":r==="window"?"shared application window (primary focus)":"user's screen (cursor is here — primary focus)"}async function Ix(r,e){const t=hs();let n=await dv({left:0,top:0,width:t.width,height:t.height});return r>0&&n.width>r&&(n=Ax(n,r)),{blob:await uv(n,e),widthPx:n.width,heightPx:n.height,viewportWidthCss:t.width,viewportHeightCss:t.height,label:"user's page (visible tab — cursor is here — primary focus)",displaySurface:"browser",isPrimary:!0}}async function Qx(r){var a,A,o;const e=r.maxWidth>0?r.maxWidth:0,t=r.quality??.72;let n=null,i=r.existingVideo??null;const s=()=>{n&&(n.getTracks().forEach(c=>c.stop()),n=null),i&&!r.existingVideo&&(i.remove(),i=null)};try{if(!r.existingStream&&!i){if(!((a=navigator.mediaDevices)!=null&&a.getDisplayMedia))throw new Error("Display capture is not supported in this browser");n=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1}),i=document.createElement("video"),i.autoplay=!0,i.playsInline=!0,i.muted=!0,i.style.cssText="position:fixed;opacity:0;pointer-events:none;width:1px;height:1px",document.body.appendChild(i),i.srcObject=n,await i.play().catch(()=>{})}else r.existingStream&&!i&&(i=document.createElement("video"),i.autoplay=!0,i.playsInline=!0,i.muted=!0,i.style.cssText="position:fixed;opacity:0;pointer-events:none;width:1px;height:1px",document.body.appendChild(i),i.srcObject=r.existingStream,await i.play().catch(()=>{}));if(!i)throw new Error("No video source for display capture");await Ux(i);const c=await Ex(i,e,t);if(!c)throw new Error("Display capture produced a blank frame");const l=(A=r.existingStream??n)==null?void 0:A.getVideoTracks()[0],d=((o=l==null?void 0:l.getSettings)==null?void 0:o.call(l).displaySurface)??"unknown";return{capture:{blob:c.blob,widthPx:c.widthPx,heightPx:c.heightPx,viewportWidthCss:c.widthPx,viewportHeightCss:c.heightPx,label:Fx(d),displaySurface:d,isPrimary:!0},release:s}}catch(c){throw s(),c}}async function Mx(r){const e=r.mode??"tab",t=r.quality??.72,n=r.maxWidth&&r.maxWidth>0?r.maxWidth:0;return e==="tab"&&!r.existingStream?{capture:await Ix(n,t),release:()=>{}}:Qx(r)}const Ud="#3380FF",_x=3,vv=null,yv=1e3,Rx=8e3,Px=24;let Dx=0;function re(r){const e=Number(r);return Number.isFinite(e)?e:null}function Lx(r,e=1){const t=r.stroke??Ud,n=r.stroke_width??_x,i=r.fill??"none",s=r.opacity??1,a=Math.max(0,Math.min(1,s*e));return`stroke="${t}" stroke-width="${n}" fill="${i}" stroke-opacity="${a.toFixed(3)}" fill-opacity="${a.toFixed(3)}"`}function ke(r,e,t){return _u({x:r,y:e},t.screenshotWidth,t.screenshotHeight,t.viewportWidthCss,t.viewportHeightCss)}function Ox(r){const e=r.trim();return!e||e.length>4e3||!/^[MLHVCSQTAZmlhvcsqtaz0-9.,\s+\-eE]+$/.test(e)?null:e}function Hf(r){if(!Array.isArray(r)||r.length<2)return null;const e=[];for(const t of r){if(Array.isArray(t)&&t.length>=2){const n=re(t[0]),i=re(t[1]);if(n===null||i===null)return null;e.push([n,i]);continue}if(t&&typeof t=="object"){const n=re(t.x),i=re(t.y);if(n===null||i===null)return null;e.push([n,i]);continue}return null}return e.length>=2?e:null}function Fd(r,e,t,n,i=0){const s=i*Math.PI/180,a=[];for(let A=0;A<n;A++){const o=s-Math.PI/2+A*2*Math.PI/n;a.push([r+t*Math.cos(o),e+t*Math.sin(o)])}return a}function Nf(r){if(typeof r=="string"&&r.trim()){const t=r.trim().toUpperCase();if(t.length===1&&t>="A"&&t<="Z")return t.charCodeAt(0)-65}const e=re(r);return e!==null?Math.round(e):null}function Hx(r,e){return Array.isArray(r)?r.slice(0,e).map((t,n)=>String(t??String.fromCharCode(65+n))):Array.from({length:e},(t,n)=>String.fromCharCode(65+n))}function wv(r){let e=[];if(typeof r=="string")try{const n=JSON.parse(r);e=Array.isArray(n)?n:[n]}catch{return[]}else if(Array.isArray(r))e=r;else if(r&&typeof r=="object"&&"op"in r)e=[r];else return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const i=n,s=String(i.op??i.type??"").toLowerCase().trim(),a={stroke:typeof i.stroke=="string"?i.stroke:void 0,stroke_width:re(i.stroke_width??i.strokeWidth)??void 0,fill:typeof i.fill=="string"?i.fill:void 0,opacity:re(i.opacity)??void 0};if(s==="line"){const A=re(i.x1),o=re(i.y1),c=re(i.x2),l=re(i.y2);A!==null&&o!==null&&c!==null&&l!==null&&t.push({op:"line",x1:A,y1:o,x2:c,y2:l,...a})}else if(s==="polygon"){const A=Hf(i.points);A&&A.length>=3&&t.push({op:"polygon",points:A,...a})}else if(s==="regular_polygon"){const A=re(i.cx),o=re(i.cy),c=re(i.radius??i.r),l=re(i.sides);A!==null&&o!==null&&c!==null&&l!==null&&l>=3&&t.push({op:"regular_polygon",cx:A,cy:o,radius:c,sides:Math.min(64,Math.round(l)),rotation_deg:re(i.rotation_deg??i.rotationDeg)??0,...a})}else if(s==="circle"){const A=re(i.cx),o=re(i.cy),c=re(i.r??i.radius);A!==null&&o!==null&&c!==null&&t.push({op:"circle",cx:A,cy:o,r:c,...a})}else if(s==="ellipse"){const A=re(i.cx),o=re(i.cy),c=re(i.rx),l=re(i.ry);A!==null&&o!==null&&c!==null&&l!==null&&t.push({op:"ellipse",cx:A,cy:o,rx:c,ry:l,rotation_deg:re(i.rotation_deg??i.rotationDeg)??0,...a})}else if(s==="arrow"){const A=re(i.x1),o=re(i.y1),c=re(i.x2),l=re(i.y2);A!==null&&o!==null&&c!==null&&l!==null&&t.push({op:"arrow",x1:A,y1:o,x2:c,y2:l,...a})}else if(s==="underline"){const A=re(i.x),o=re(i.y),c=re(i.width??i.w);A!==null&&o!==null&&c!==null&&t.push({op:"underline",x:A,y:o,width:c,...a})}else if(s==="highlight_box"||s==="element_highlight"){const A=re(i.x),o=re(i.y),c=re(i.width??i.w),l=re(i.height??i.h);A!==null&&o!==null&&c!==null&&l!==null&&c>0&&l>0&&t.push({op:"highlight_box",x:A,y:o,width:c,height:l,rx:re(i.rx)??void 0,fill:typeof i.fill=="string"?i.fill:"rgba(59,130,246,0.14)",...a})}else if(s==="label"){const A=re(i.x),o=re(i.y),c=String(i.text??"").trim();A!==null&&o!==null&&c&&t.push({op:"label",x:A,y:o,text:c.slice(0,120),font_size:re(i.font_size??i.fontSize)??void 0,...a})}else if(s==="parabola"){const A=re(i.h),o=re(i.k),c=re(i.a),l=re(i.x_min??i.xMin),d=re(i.x_max??i.xMax);A!==null&&o!==null&&c!==null&&l!==null&&d!==null&&d>l&&t.push({op:"parabola",h:A,k:o,a:c,x_min:l,x_max:d,samples:re(i.samples)??void 0,...a})}else if(s==="hyperbola"){const A=re(i.cx),o=re(i.cy),c=re(i.a),l=re(i.b);A!==null&&o!==null&&c!==null&&l!==null&&c>0&&l>0&&t.push({op:"hyperbola",cx:A,cy:o,a:c,b:l,t_min:re(i.t_min??i.tMin)??-2.5,t_max:re(i.t_max??i.tMax)??2.5,samples:re(i.samples)??void 0,...a})}else if(s==="bezier"){const A=Hf(i.points);A&&A.length>=3&&t.push({op:"bezier",points:A,closed:i.closed===!0,...a})}else if(s==="path"){const A=Ox(String(i.d??""));A&&t.push({op:"path",d:A,...a})}else if(s==="vertex_labels"){const A=re(i.cx),o=re(i.cy),c=re(i.radius??i.r),l=re(i.sides);if(A!==null&&o!==null&&c!==null&&l!==null&&l>=3){const d=Math.min(64,Math.round(l)),u=re(i.rotation_deg??i.rotationDeg)??0,h=re(i.label_offset??i.offset)??28,p=Fd(A,o,c,d,u),g=Hx(i.labels,d);for(let v=0;v<d;v++){const[w,B]=p[v],E=w-A,b=B-o,C=Math.hypot(E,b)||1;t.push({op:"label",x:w+E/C*h,y:B+b/C*h,text:g[v].slice(0,12),font_size:re(i.font_size??i.fontSize)??void 0,...a})}}}else if(s==="vertex_line"){const A=re(i.cx),o=re(i.cy),c=re(i.radius??i.r),l=re(i.sides);let d=Nf(i.from_vertex??i.fromVertex??i.from_label??i.fromLabel),u=Nf(i.to_vertex??i.toVertex??i.to_label??i.toLabel);if(A!==null&&o!==null&&c!==null&&l!==null&&l>=3&&d!==null&&u!==null){const h=Math.min(64,Math.round(l)),p=re(i.rotation_deg??i.rotationDeg)??0,g=Fd(A,o,c,h,p),v=g[(d%h+h)%h],w=g[(u%h+h)%h];v&&w&&t.push({op:"line",x1:v[0],y1:v[1],x2:w[0],y2:w[1],...a})}}}return t.slice(0,Px)}function Ca(r,e=!1){if(!r.length)return"";const[t,...n]=r;let i=`M ${t.x.toFixed(2)} ${t.y.toFixed(2)}`;for(const s of n)i+=` L ${s.x.toFixed(2)} ${s.y.toFixed(2)}`;return e&&(i+=" Z"),i}function Nx(r,e){const t=Math.max(8,Math.min(120,r.samples??48)),n=[];for(let i=0;i<=t;i++){const s=r.x_min+(r.x_max-r.x_min)*i/t,a=r.a*(s-r.h)**2+r.k;n.push(ke(s,a,e))}return Ca(n)}function Kx(r,e){const t=Math.max(8,Math.min(120,r.samples??40)),n=r.t_min??-2.5,i=r.t_max??2.5,s=[],a=[];for(let A=0;A<=t;A++){const o=n+(i-n)*A/t,c=Math.cosh(o),l=Math.sinh(o);s.push(ke(r.cx+r.a*c,r.cy+r.b*l,e)),a.push(ke(r.cx-r.a*c,r.cy+r.b*l,e))}return`${Ca(s)} ${Ca(a)}`}function bv(r){return Fd(r.cx,r.cy,r.radius,r.sides,r.rotation_deg??0)}function Vx(r,e,t,n,i){const s=Math.atan2(n-e,t-r),a=14,A=[];for(const o of[-1,1]){const c=t-a*Math.cos(s+o*(28*Math.PI)/180),l=n-a*Math.sin(s+o*(28*Math.PI)/180);A.push(`<line x1="${t}" y1="${n}" x2="${c.toFixed(2)}" y2="${l.toFixed(2)}" ${i} stroke-linecap="round"/>`)}return A.join("")}function zx(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Gx(r){return 1-(1-r)**3}function qx(r,e){if(r.op==="line"||r.op==="arrow"){const t=ke(r.x1,r.y1,e),n=ke(r.x2,r.y2,e);return Math.hypot(n.x-t.x,n.y-t.y)+(r.op==="arrow"?28:0)}if(r.op==="underline"){const t=ke(r.x,r.y,e),n=ke(r.x+r.width,r.y,e);return Math.hypot(n.x-t.x,n.y-t.y)}if(r.op==="highlight_box"){const t=ke(r.x,r.y,e),n=ke(r.x+r.width,r.y+r.height,e);return 2*(Math.abs(n.x-t.x)+Math.abs(n.y-t.y))}if(r.op==="circle"){const t=ke(r.cx,r.cy,e),n=ke(r.cx+r.r,r.cy,e),i=Math.max(4,Math.hypot(n.x-t.x,n.y-t.y));return 2*Math.PI*i}if(r.op==="ellipse"){const t=ke(r.cx,r.cy,e),n=ke(r.cx+r.rx,r.cy,e),i=ke(r.cx,r.cy+r.ry,e),s=Math.abs(n.x-t.x),a=Math.abs(i.y-t.y);return Math.PI*(3*(s+a)-Math.sqrt((3*s+a)*(s+3*a)))}if(r.op==="polygon"||r.op==="regular_polygon"){const t=r.op==="polygon"?r.points.map(([i,s])=>ke(i,s,e)):bv(r).map(([i,s])=>ke(i,s,e));let n=0;for(let i=0;i<t.length;i++){const s=t[i],a=t[(i+1)%t.length];n+=Math.hypot(a.x-s.x,a.y-s.y)}return n}if(r.op==="parabola"){const t=Math.max(8,Math.min(120,r.samples??48));let n=0,i=ke(r.x_min,r.a*(r.x_min-r.h)**2+r.k,e);for(let s=1;s<=t;s++){const a=r.x_min+(r.x_max-r.x_min)*s/t,A=r.a*(a-r.h)**2+r.k,o=ke(a,A,e);n+=Math.hypot(o.x-i.x,o.y-i.y),i=o}return n}if(r.op==="hyperbola")return 200;if(r.op==="bezier"){const t=r.points.map(([i,s])=>ke(i,s,e));let n=0;for(let i=1;i<t.length;i++)n+=Math.hypot(t[i].x-t[i-1].x,t[i].y-t[i-1].y);return n*1.2}return r.op==="path"?Math.max(80,r.d.length*.4):0}function Wx(r,e,t){const n=Gx(Math.max(0,Math.min(1,t)));if(e.isLabel||e.pathLength<=0)return`<g opacity="${n.toFixed(3)}">${r}</g>`;const i=e.pathLength.toFixed(2),s=(e.pathLength*(1-n)).toFixed(2),a=`stroke-dasharray="${i}" stroke-dashoffset="${s}"`;return r.replace(/<(path|line|circle|ellipse)(\s)/g,`<$1 ${a}$2`)}function $x(r,e,t=1){const n=`${Lx(r,t)} stroke-linecap="round" stroke-linejoin="round"`;if(r.op==="line"){const i=ke(r.x1,r.y1,e),s=ke(r.x2,r.y2,e);return`<line x1="${i.x}" y1="${i.y}" x2="${s.x}" y2="${s.y}" ${n}/>`}if(r.op==="arrow"){const i=ke(r.x1,r.y1,e),s=ke(r.x2,r.y2,e);return[`<line x1="${i.x}" y1="${i.y}" x2="${s.x}" y2="${s.y}" ${n}/>`,Vx(i.x,i.y,s.x,s.y,n)].join("")}if(r.op==="underline"){const i=ke(r.x,r.y,e),s=ke(r.x+r.width,r.y,e),a=n.replace(/stroke-width="[^"]+"/,'stroke-width="4"');return`<line x1="${i.x}" y1="${i.y}" x2="${s.x}" y2="${s.y}" ${a}/>`}if(r.op==="highlight_box"){const i=ke(r.x,r.y,e),s=ke(r.x+r.width,r.y+r.height,e),a=Math.max(4,s.x-i.x),A=Math.max(4,s.y-i.y),o=Math.min(r.rx??10,a/2,A/2),c=r.fill??"rgba(59,130,246,0.14)",l=r.stroke??Ud;return[`<rect x="${i.x.toFixed(2)}" y="${i.y.toFixed(2)}" width="${a.toFixed(2)}" height="${A.toFixed(2)}"`,` rx="${o.toFixed(1)}" ${n.replace(/fill="[^"]+"/,`fill="${c}"`)}`,` filter="drop-shadow(0 0 6px ${l}88)"/>`].join("")}if(r.op==="circle"){const i=ke(r.cx,r.cy,e),s=ke(r.cx+r.r,r.cy,e),a=Math.max(4,Math.hypot(s.x-i.x,s.y-i.y));return`<circle cx="${i.x}" cy="${i.y}" r="${a.toFixed(2)}" ${n}/>`}if(r.op==="ellipse"){const i=ke(r.cx,r.cy,e),s=ke(r.cx+r.rx,r.cy,e),a=ke(r.cx,r.cy+r.ry,e),A=Math.max(2,Math.abs(s.x-i.x)),o=Math.max(2,Math.abs(a.y-i.y)),c=r.rotation_deg??0;return c?`<ellipse cx="${i.x}" cy="${i.y}" rx="${A}" ry="${o}" transform="rotate(${c} ${i.x} ${i.y})" ${n}/>`:`<ellipse cx="${i.x}" cy="${i.y}" rx="${A}" ry="${o}" ${n}/>`}if(r.op==="polygon"){const i=r.points.map(([s,a])=>ke(s,a,e));return`<path d="${Ca(i,!0)}" ${n}/>`}if(r.op==="regular_polygon"){const i=bv(r).map(([s,a])=>ke(s,a,e));return`<path d="${Ca(i,!0)}" ${n}/>`}if(r.op==="parabola")return`<path d="${Nx(r,e)}" ${n} fill="none"/>`;if(r.op==="hyperbola")return`<path d="${Kx(r,e)}" ${n} fill="none"/>`;if(r.op==="bezier"){const i=r.points.map(([a,A])=>ke(a,A,e));let s=`M ${i[0].x.toFixed(2)} ${i[0].y.toFixed(2)}`;if(i.length===3)s+=` Q ${i[1].x.toFixed(2)} ${i[1].y.toFixed(2)} ${i[2].x.toFixed(2)} ${i[2].y.toFixed(2)}`;else if(i.length>=4){s+=` C ${i[1].x.toFixed(2)} ${i[1].y.toFixed(2)} ${i[2].x.toFixed(2)} ${i[2].y.toFixed(2)} ${i[3].x.toFixed(2)} ${i[3].y.toFixed(2)}`;for(let a=4;a+2<i.length;a+=2)s+=` S ${i[a].x.toFixed(2)} ${i[a].y.toFixed(2)} ${i[a+1].x.toFixed(2)} ${i[a+1].y.toFixed(2)}`}else s+=` L ${i[1].x.toFixed(2)} ${i[1].y.toFixed(2)}`;return r.closed&&(s+=" Z"),`<path d="${s}" ${n}/>`}if(r.op==="path")return`<path d="${r.d}" ${n}/>`;if(r.op==="label"){const i=ke(r.x,r.y,e),s=r.font_size??11,a=r.stroke??Ud,A=zx(r.text),o=Math.min(280,Math.max(40,A.length*7+16)),c=s+8,l=t.toFixed(3);return[`<rect x="${i.x}" y="${i.y-c/2}" width="${o}" height="${c}" rx="6"`,` fill="rgba(15,23,42,${(.92*t).toFixed(3)})" stroke="${a}" stroke-opacity="${(.5*t).toFixed(3)}" stroke-width="1"/>`,`<text x="${i.x+8}" y="${i.y+s/3}" fill="#f8fafc" fill-opacity="${l}"`,` font-family="-apple-system,BlinkMacSystemFont,sans-serif" font-size="${s}" font-weight="600">${A}</text>`].join("")}return""}function jx(r,e,t){const n=(t==null?void 0:t.born)??performance.now(),i=(t==null?void 0:t.ttlMs)!==void 0?t.ttlMs:vv,s=Math.max(200,Math.min(Rx,(t==null?void 0:t.animateMs)??yv)),a=[];return r.forEach((A,o)=>{const c=$x(A,e);c&&a.push({id:`draw-${++Dx}`,svg:c,born:n+o*s,ttl:i,animateMs:s,pathLength:qx(A,e),isLabel:A.op==="label"})}),a}const Xx=`
|
|
46
|
+
Screen drawing (draw_on_screen) — coordinates in last capture_screen_vision screenshot pixels:
|
|
47
|
+
|
|
48
|
+
Ops (pass as JSON array in "commands"):
|
|
49
|
+
- line: { op:"line", x1,y1,x2,y2 }
|
|
50
|
+
- arrow: { op:"arrow", x1,y1,x2,y2 }
|
|
51
|
+
- polygon: { op:"polygon", points:[[x,y],...] } (3+ vertices)
|
|
52
|
+
- regular_polygon: { op:"regular_polygon", cx,cy,radius,sides } (sides=3 triangle, 8 octagon, 10 decagon)
|
|
53
|
+
- circle: { op:"circle", cx,cy,r }
|
|
54
|
+
- ellipse: { op:"ellipse", cx,cy,rx,ry, rotation_deg? }
|
|
55
|
+
- underline: { op:"underline", x,y,width }
|
|
56
|
+
- highlight_box: { op:"highlight_box", x,y,width,height, rx? } — rounded highlight rect (used by highlight_on_screen)
|
|
57
|
+
- label: { op:"label", x,y,text }
|
|
58
|
+
- parabola: { op:"parabola", h,k,a, x_min,x_max } — y=a(x-h)²+k
|
|
59
|
+
- hyperbola: { op:"hyperbola", cx,cy,a,b, t_min?,t_max? } — horizontal hyperbola branches
|
|
60
|
+
- bezier: { op:"bezier", points:[[x,y],...], closed? } — 3=quadratic, 4+=cubic
|
|
61
|
+
- path: { op:"path", d:"M ... L ..." } — SVG path escape hatch
|
|
62
|
+
- vertex_labels: { op:"vertex_labels", cx,cy,radius,sides, label_offset? } — auto A,B,C… at each vertex (A=top, clockwise). Use alone — do NOT also add manual label ops for the same vertices.
|
|
63
|
+
- vertex_line: { op:"vertex_line", cx,cy,radius,sides, from_label:"A", to_label:"C" } — chord/diagonal between vertices (exact geometry)
|
|
64
|
+
|
|
65
|
+
Overlap: default strict — if any filled shape overlaps another filled shape or label overlaps another label, the batch is REJECTED (nothing drawn) and the tool returns overlap_detected:true. Lines/arrows always draw (diagonals may cross shapes). Labels may overlap area shapes. Set allow_overlap:true to draw at exact coords on top of anything.
|
|
66
|
+
|
|
67
|
+
Optional per command: stroke, stroke_width, fill, opacity.
|
|
68
|
+
draw_on_screen params: animate_ms (default 1000), clear (default false), allow_overlap (default false), ttl_ms (optional). clear_screen_draw removes all.`,Jx=/\[POINT:(?:none|(\d+)\s*,\s*(\d+)(?::([^\]:\s][^\]:]*?))?(?::screen(\d+))?)\]\s*$/;function Yx(r){var c;const e=r.match(Jx);if(!e)return{spokenText:r,coordinate:null,elementLabel:null,screenNumber:null};const t=r.slice(0,e.index).trim(),n=e[1],i=e[2];if(!n||!i)return{spokenText:t,coordinate:null,elementLabel:"none",screenNumber:null};const s=Number(n),a=Number(i);if(!Number.isFinite(s)||!Number.isFinite(a))return{spokenText:t,coordinate:null,elementLabel:null,screenNumber:null};const A=((c=e[3])==null?void 0:c.trim())||null,o=e[4]?Number(e[4]):null;return{spokenText:t,coordinate:{x:s,y:a},elementLabel:A,screenNumber:Number.isFinite(o)?o:null}}function _u(r,e,t,n,i){const s=Math.max(1,e),a=Math.max(1,t),A=Math.max(1,n),o=Math.max(1,i),c=Math.max(0,Math.min(r.x,s)),l=Math.max(0,Math.min(r.y,a));return{x:c/s*A,y:l/a*o}}function Zx(r){const{prompt:e,captures:t,layoutSummary:n}=r,i=e?`Screen vision capture complete. Context: ${e}`:"Screen vision capture complete.",s=t.map((d,u)=>{const h=u+1,g=d.viewportWidthCss===d.widthPx&&d.viewportHeightCss===d.heightPx?" (1:1 with viewport — screenshot pixels equal CSS layout pixels)":d.viewportWidthCss&&d.viewportHeightCss?` (image downscaled from ${d.viewportWidthCss}x${d.viewportHeightCss} viewport)`:"";return`- screen ${h}: ${d.label} — image ${d.widthPx}x${d.heightPx} pixels${g}`}).join(`
|
|
69
|
+
`),a=t[0],A=(a==null?void 0:a.widthPx)??1,o=(a==null?void 0:a.heightPx)??1,c=(a==null?void 0:a.viewportWidthCss)===(a==null?void 0:a.widthPx)&&(a==null?void 0:a.viewportHeightCss)===(a==null?void 0:a.heightPx),l=n!=null&&n.trim()?`
|
|
70
|
+
|
|
71
|
+
DOM layout scan (USE THESE COORDINATES for point_at — do NOT guess from the image):
|
|
72
|
+
Each line gives exact screenshot pixel center for point_at_screen.
|
|
73
|
+
Match the user's target by label text, then copy x,y from that line.
|
|
86
74
|
|
|
87
|
-
|
|
88
|
-
- Call point_at with element_id (e.g. e3) from this scan — cursor flies to the live element.
|
|
89
|
-
- Call outline_targets with element_ids to draw animated outlines on the real DOM.
|
|
90
|
-
- Prefer element_id or css_selector; raw x/y only as fallback.
|
|
75
|
+
${n}`:"";return`${i}
|
|
91
76
|
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
The attached image is ONLY the visible web page (no browser tabs, address bar, or OS chrome).
|
|
78
|
+
Image size: ${A}x${o} pixels. Coordinate origin: top-left; x increases right; y increases down.
|
|
79
|
+
${c?"Screenshot pixels match viewport CSS pixels 1:1.":"Coordinates are in IMAGE pixel space (see layout scan below)."}
|
|
94
80
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
`,document.head.appendChild(t)}if(n.querySelector("#vnr-chalk-defs"))return;const e=document.createElementNS("http://www.w3.org/2000/svg","defs");e.id="vnr-chalk-defs",n.appendChild(e)}function X(n){let e=n.querySelector(".vnr-whiteboard-draw-layer");return e||(e=document.createElementNS("http://www.w3.org/2000/svg","svg"),e.setAttribute("class","vnr-whiteboard-draw-layer"),e.setAttribute("viewBox",`0 0 ${K} ${Z}`),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.position="absolute",e.style.inset="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="none",e.style.zIndex="0",pr(e),n.insertBefore(e,n.firstChild),e)}function ke(n){[...n.childNodes].forEach(e=>{e instanceof SVGDefsElement||e.remove()})}function fr(n){pr(n)}const Be=6,Yn="#ffffff";function B(n,e){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"&&n.trim()!==""){const t=Number(n);if(Number.isFinite(t))return t}return e}function H(n,e=""){return typeof n=="string"?n:e}function oe(n){if(n===!0||n===1)return!0;if(typeof n=="string"){const e=n.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"}return!1}function Bt(n){if(n===!1||n===0)return!0;if(typeof n=="string"){const e=n.trim().toLowerCase();return e==="false"||e==="0"||e==="no"}return!1}function $t(n){if(n===!0||n===1)return!0;if(n===!1||n===0||n===null||n===void 0||n==="")return!1;const e=String(n).trim().toLowerCase();return e==="true"||e==="1"||e==="yes"}function te(n,e){return n>=0&&n<=1?n*e:n}function it(n,e){return{bx:te(n,K),by:te(e,Z)}}function Rt(n){if(Array.isArray(n))return n;if(typeof n=="string"){const e=n.trim();if(!e)return[];try{const r=JSON.parse(e);if(Array.isArray(r))return r.length>0&&Array.isArray(r[0])?[{points:r,close:!0}]:r}catch{}const t=e.split(/\s+/).map(r=>{const[s,i]=r.split(","),o=Number(s),a=Number(i);return Number.isFinite(o)&&Number.isFinite(a)?[o,a]:null}).filter(r=>r!=null);if(t.length>=2)return[{points:t,close:!0}]}return[]}function Gn(n){if(Array.isArray(n))return n;if(typeof n=="string"){const e=n.trim();if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}return[]}function mr(n,e){const t=H(n,e).trim().toLowerCase();return!t||t==="#000"||t==="#000000"||t==="black"?e:H(n,e)}function vr(n,e){if(!n||typeof n!="object")return null;const t=n,r=H(t.text??t.label??t.label_text??t.annotation??(typeof t.annotations=="string"?t.annotations:"")).trim();if(!r)return null;const s=t.x??t.label_x??t.client_x,i=t.y??t.label_y??t.client_y;if(s==null||i==null)return null;const o=Number(s),a=Number(i);return!Number.isFinite(o)||!Number.isFinite(a)?null:{x:o,y:a,text:r,color:mr(t.color??t.label_color,e),font_size:t.font_size!=null?B(t.font_size,28):void 0}}function Jn(n,e){if(!n||typeof n!="object")return null;const t=n;return t.text!=null||t.label!=null||t.label_text!=null||t.annotation!=null||typeof t.annotations=="string"?vr(n,e):null}function Qn(n){return Array.isArray(n)&&n.length>0&&Array.isArray(n[0])?{points:n,close:!0}:n}function yr(n){if(Array.isArray(n)&&n.length>=2){const e=Number(n[0]),t=Number(n[1]);return!Number.isFinite(e)||!Number.isFinite(t)?null:it(e,t)}if(n&&typeof n=="object"&&"x"in n&&"y"in n){const e=Number(n.x),t=Number(n.y);return!Number.isFinite(e)||!Number.isFinite(t)?null:it(e,t)}return null}function Kn(n){return te(n,Math.min(K,Z))}function Zn(n,e,t,r){const s=H(n.kind||n.shape).toLowerCase(),i=s==="circle"||s==="ellipse"||n.r!=null||n.radius!=null||n.rx!=null||n.ry!=null;let o=n.cx??n.center_x??n.x,a=n.cy??n.center_y??n.y,l=n.r??n.radius;const c=n.rx,u=n.ry;if(Array.isArray(r)&&r.length>=3){const f=[];for(const y of r){const v=yr(y);v&&f.push(v)}if(f.length>=8&&i){const y=f.map(w=>w.bx),v=f.map(w=>w.by),g=(Math.min(...y)+Math.max(...y))/2,b=(Math.min(...v)+Math.max(...v))/2,S=Math.max(...f.map(w=>Math.hypot(w.bx-g,w.by-b)));o=o??g/K,a=a??b/Z,l=l??S/Math.min(K,Z)}}if(!i||o==null||a==null)return null;const d=Number(o),p=Number(a);if(!Number.isFinite(d)||!Number.isFinite(p))return null;const h={kind:s==="ellipse"||c!=null||u!=null?"ellipse":"circle",cx:d,cy:p,color:H(n.color,e),stroke_width:n.stroke_width!=null?B(n.stroke_width,t):t};return c!=null||u!=null?(h.rx=Number(c??u),h.ry=Number(u??c),h):l!=null&&Number.isFinite(Number(l))?(h.r=Number(l),h):null}function ot(n,e,t){if(!n||typeof n!="object")return null;const r=n,s=H(r.path_d||r.path||r.d),i=H(r.color,e),o=r.stroke_width!=null?B(r.stroke_width,t):t;if(s)return{path_d:s,close:oe(r.close),color:i,stroke_width:o};const a=r.points,l=Zn(r,e,t,a);if(l)return l;let c=a;if(!Array.isArray(c)){const u=r.from_x??r.p1_x??r.x1,d=r.from_y??r.p1_y??r.y1,p=r.to_x??r.p2_x??r.x2,h=r.to_y??r.p2_y??r.y2;u!=null&&d!=null&&p!=null&&h!=null&&(c=[[u,d],[p,h]])}if(Array.isArray(c)&&c.length>=2){const u=H(r.kind||r.shape_type||r.type).toLowerCase(),d=oe(r.close??r.close_path)||u==="triangle"||u==="polygon"||u==="rectangle";return{points:c,close:d,color:i,stroke_width:o}}return null}function Ye(n,e,t,r,s){const i=B(n[e])??(r?B(n[r]):void 0),o=B(n[t])??(s?B(n[s]):void 0);return i===void 0||o===void 0?null:[i,o]}function Xn(n,e,t){const r=[],s=[],i=H(n.label_text??n.text).trim(),o=B(n.label_x??n.x),a=B(n.label_y??n.y);i&&o!=null&&a!=null&&s.push({x:o,y:a,text:i,color:t});const l=Ye(n,"p1_x","p1_y","x1","y1"),c=Ye(n,"p2_x","p2_y","x2","y2"),u=Ye(n,"p3_x","p3_y","x3","y3");if(l&&c&&u)return r.push({points:[l,c,u],close:!0,color:e}),{strokes:r,labels:s};if(l&&c)return r.push({points:[l,c],close:!1,color:e}),{strokes:r,labels:s};const d=ot({...n,color:n.color??e},e,B(n.stroke_width,Be)??Be);if(d)return r.push(d),{strokes:r,labels:s};const p=B(n.rect_x),h=B(n.rect_y),f=B(n.rect_width??n.width),y=B(n.rect_height??n.height);return p!=null&&h!=null&&f!=null&&y!=null&&r.push({points:[[p,h],[p+f,h],[p+f,h+y],[p,h+y]],close:!0,color:e}),{strokes:r,labels:s}}function es(n,e={}){const t={...e,...n},r=H(t.color??e.color,Yn),s=mr(t.label_color??e.label_color,Wn),i=B(t.stroke_width??e.stroke_width,Be)??Be,o=$t(t.clear_old_diagrams_on_board)||$t(t.clear_drawings)||oe(t.clear)||oe(t.clear_before)||oe(e.clear_before),a=Bt(t.animate)||Bt(e.animate);let l=Math.max(0,B(t.shape_duration_ms??t.duration_ms??e.duration_ms,ue)??ue),c=Math.max(0,B(t.shape_gap_ms??t.gap_ms??e.gap_ms,Dt)??Dt),u=!a;u&&l>0&&l<ue&&(l=ue),l>=ue&&(u=!0);const d=[];for(const y of Gn(t.labels??e.labels)){const v=vr(y,s);v&&d.push(v)}let p=Rt(t.strokes??e.strokes);p.length===0&&(p=Rt(t.annotations??e.annotations));const h=[];for(const y of p){const v=Qn(y),g=Jn(v,s);if(g){d.push(g);continue}const b=ot(v,r,i);b&&h.push(b)}if(h.length===0){const y=t.points??e.points;if(y!=null){const v=ot({points:y,close:t.close??t.close_path??!0,color:r},r,i);v&&h.push(v)}}const f=Xn(t,r,s);for(const y of f.labels)d.some(v=>v.text===y.text&&v.x===y.x&&v.y===y.y)||d.push(y);return h.length===0&&h.push(...f.strokes),{strokes:h,labels:d,clearBefore:o,animate:u,durationMs:l,gapMs:c,strokeWidth:i,strokeColor:r,labelColor:s}}function ts(n){const e=n.points;if(!Array.isArray(e))return[];const t=[];for(const r of e){const s=yr(r);s&&t.push(s)}return t}function rs(n,e){if(n.length===0)return"";const t=n.map((r,s)=>`${s===0?"M":"L"} ${r.bx} ${r.by}`).join(" ");return e&&n.length>=3?`${t} Z`:t}function $e(n,e){return{class:"vnr-board-stroke",fill:"none",stroke:n,"stroke-width":String(e),"stroke-linecap":"round","stroke-linejoin":"round"}}function Re(n,e){for(const[t,r]of Object.entries(e))n.setAttribute(t,r)}function ns(n,e,t){if(n.cx==null||n.cy==null)return null;const r=te(n.cx,K),s=te(n.cy,Z),i="http://www.w3.org/2000/svg";if(n.kind==="ellipse"||n.rx!=null||n.ry!=null){const a=n.rx??n.r,l=n.ry??n.r;if(a==null||l==null)return null;const c=document.createElementNS(i,"ellipse");return c.setAttribute("cx",String(r)),c.setAttribute("cy",String(s)),c.setAttribute("rx",String(te(Number(a),K))),c.setAttribute("ry",String(te(Number(l),Z))),Re(c,$e(e,t)),c}if(n.r==null)return null;const o=document.createElementNS(i,"circle");return o.setAttribute("cx",String(r)),o.setAttribute("cy",String(s)),o.setAttribute("r",String(Kn(Number(n.r)))),Re(o,$e(e,t)),o}function gr(n,e,t){const r=H(n.color,e),s=n.stroke_width!=null?B(n.stroke_width,t)??t:t;if(n.kind==="circle"||n.kind==="ellipse"||n.r!=null||n.rx!=null||n.ry!=null)return ns(n,r,s);const o=document.createElementNS("http://www.w3.org/2000/svg","path"),a=H(n.path_d);if(a)return o.setAttribute("d",a),Re(o,$e(r,s)),o;const l=ts(n);return l.length<2?null:(o.setAttribute("d",rs(l,oe(n.close))),Re(o,$e(r,s)),o)}function br(n,e){const t="http://www.w3.org/2000/svg",r=it(n.x,n.y),s=document.createElementNS(t,"text");return s.setAttribute("class","vnr-board-label"),s.setAttribute("x",String(r.bx)),s.setAttribute("y",String(r.by)),s.setAttribute("fill",n.color||e),s.setAttribute("font-size",String(n.font_size??28)),s.setAttribute("font-family","'Architects Daughter', 'Caveat', cursive, sans-serif"),s.setAttribute("text-anchor","middle"),s.setAttribute("dominant-baseline","hanging"),s.textContent=n.text,s}function ss(n,e){return e<=0?(n.style.opacity="1",Promise.resolve()):(n.style.opacity="0",n.getBoundingClientRect(),n.style.transition=`opacity ${Math.min(e,400)}ms ease-out`,n.style.opacity="1",ht(Math.min(e,400)))}function Ut(n,e,t){fr(n),ke(n);for(const r of e.strokes){const s=gr(r,t.strokeColor,t.strokeWidth);s&&n.appendChild(s)}for(const r of e.labels)n.appendChild(br(r,t.labelColor))}async function is(n,e,t,r){fr(n);let s=0,i=0;for(const o of e){if(r.isAborted())break;const a=gr(o,r.strokeColor,r.strokeWidth);a&&(n.appendChild(a),s+=1,r.animate&&r.durationMs>0&&(await et(a,r.durationMs),r.gapMs>0&&await ht(r.gapMs)))}for(const o of t){if(r.isAborted())break;const a=br(o,r.labelColor);n.appendChild(a),i+=1,r.animate&&r.durationMs>0&&await ss(a,r.durationMs)}return{strokesDrawn:s,labelsDrawn:i}}function we(){return{strokes:[],labels:[]}}function me(n){return n.toLowerCase().replace(/[^a-z0-9]/g,"_")}function os(n){const e=n==null?void 0:n.toLowerCase().trim();if(e){if(e==="tel")return"phone";if(e==="dropdown"||e==="drop_down"||e==="picklist"||e==="combobox")return"select";if(["text","textarea","select","radio","checkbox","email","phone","number","date"].includes(e))return e}}function wr(n,e,t=[]){const r=os(e);return r||(t.length>0?"select":n.includes("email")?"email":n.includes("phone")?"phone":n.includes("date")&&!n.includes("update")?"date":"text")}function as(n){return n?Array.isArray(n)?n.map(e=>{if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return{label:String(t.label??t.value??""),value:String(t.value??t.label??"")}}return String(e)}):typeof n=="string"?n.split(",").map(e=>e.trim()).filter(Boolean):[]:[]}function ls(n){const e=n.value??n.default??n.defaultValue??n.prefill;if(!(e==null||e===""))return String(e)}function Ge(n){const e=String(n.label??n.name??n.title??n.field??n.id??n.key??"").trim();if(!e)return null;const t=String(n.id??n.key??me(e)),r=as(n.options??n.choices??n.values),s=wr(t,String(n.type??""),r);return{id:t,label:e,type:s,required:n.required!==!1,placeholder:n.placeholder?String(n.placeholder):void 0,value:ls(n),options:r}}function Ft(n){const e=n.trim(),t=me(e);return{id:t,label:e,type:wr(t),required:!0,placeholder:`Enter your ${e.toLowerCase()}`,options:[]}}function Ee(n){const e=n.trim();return e?e.startsWith("[")||e.startsWith("{")||e.startsWith('"')?!0:e.includes('"type"')||e.includes('"options"')||e.includes('"label"'):!1}function cs(n){let e=n.trim();for(let t=0;t<3&&typeof e=="string";t++){const r=e.trim();if(!Ee(r))break;try{e=JSON.parse(r)}catch{break}}return e}function Te(n){const e=cs(n);if(Array.isArray(e)||e&&typeof e=="object")return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&!t.startsWith("["))try{return JSON.parse(`[${t}]`)}catch{return null}}return null}function ds(n){return n.length<2?!1:n.every(e=>typeof e=="string"&&(e.includes('"')||e.includes("{")||e.includes("[")))}function us(n){return Te(n.map(e=>e.trim()).join(","))}function pe(n){if(n==null)return[];if(typeof n=="string"){const e=n.trim();if(!e)return[];if(Ee(e)){const t=Te(e);return t!==null?pe(t):[]}return e.split(",").map(t=>t.trim()).filter(Boolean).map(Ft)}if(Array.isArray(n)){if(n.length===1&&typeof n[0]=="string"){const t=n[0].trim();if(Ee(t)){const r=Te(t);if(r!==null)return pe(r)}}if(ds(n)){const t=us(n);if(t!==null)return pe(t)}const e=[];for(const t of n){if(typeof t=="string"){const r=t.trim();if(r.startsWith("{"))try{const s=Ge(JSON.parse(r));if(s){e.push(s);continue}}catch{}if(Ee(r)){const s=Te(r);if(s!==null){e.push(...pe(s));continue}}e.push(Ft(t));continue}if(t&&typeof t=="object"){const r=Ge(t);r&&e.push(r)}}return e}if(typeof n=="object"){const e=Ge(n);return e?[e]:[]}return[]}const hs=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ps=/^\+?[0-9\s\-().]{7,20}$/,fs=/^\d{4}-\d{2}-\d{2}$/;function _r(n,e){const t=n[e.id];return e.type==="checkbox"?t===!0||t==="true"?"true":"false":String(t??"").trim()}function ms(n,e){const t={};for(const r of n){const s=_r(e,r);if(r.type==="checkbox"){r.required&&s!=="true"&&(t[r.id]=`${r.label} is required`);continue}if(r.required&&!s){t[r.id]=`${r.label} is required`;continue}if(!s)continue;const i=vs(r.type,s,r.label);i&&(t[r.id]=i),(r.type==="select"||r.type==="radio")&&r.options.length>0&&(r.options.map(a=>typeof a=="string"?a:a.value).includes(s)||(t[r.id]=`Select a valid ${r.label}`))}return t}function vs(n,e,t){switch(n){case"email":return hs.test(e)?null:`Enter a valid ${t}`;case"phone":return ps.test(e)?null:`Enter a valid phone number for ${t}`;case"number":return Number.isFinite(Number(e))?null:`${t} must be a number`;case"date":return fs.test(e)?Number.isNaN(Date.parse(e))?`Enter a valid ${t}`:null:`${t} must be YYYY-MM-DD`;default:return null}}function ys(n,e){const t={};for(const r of n)t[r.id]=_r(e,r);return t}function xr(n){if(n==null)return{};if(typeof n=="string"){const e=n.trim();if(!e)return{};try{return xr(JSON.parse(e))}catch{return{}}}return typeof n=="object"&&!Array.isArray(n)?n:{}}function gs(n,e){const t=n.prefill??n.values??n.initial_values??n.defaults??e.prefill??e.values??e.initial_values??e.defaults;return xr(t)}function at(n,e){if(n.type==="checkbox"){if(typeof e=="boolean")return e;const t=String(e).trim().toLowerCase();return t==="true"||t==="1"||t==="yes"||t==="on"}return String(e??"").trim()}function bs(n,e){const t=[n.id,n.label,n.label.toLowerCase()];for(const s of t){if(!(s in e))continue;const i=e[s];if(!(i==null||i===""))return at(n,i)}const r=me(n.label);for(const[s,i]of Object.entries(e))if(!(i==null||i==="")&&(s===r||me(s)===r||me(s)===n.id))return at(n,i)}function ws(n,e={}){const t={};for(const r of n){if(r.value!==void 0){t[r.id]=at(r,r.value);continue}const s=bs(r,e);t[r.id]=s!==void 0?s:r.type==="checkbox"?!1:""}return t}const Ot="vanira:board_abort";function Je(n){if(!n)return"";if(typeof n=="string"){if(n.includes("T")||!isNaN(Date.parse(n)))try{return new Date(n).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}catch{}return n}if(typeof n=="object"){const e=n.start||n.startTime||n.time||n.slot,t=n.end||n.endTime;if(e){let r=String(e),s=t?String(t):"";try{(r.includes("T")||!isNaN(Date.parse(r)))&&(r=new Date(r).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})),s&&(s.includes("T")||!isNaN(Date.parse(s)))&&(s=new Date(s).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}))}catch{}return s?`${r} - ${s}`:r}}return String(n)}function _s(n,e,t,r){let s=Date.UTC(n,e,t,0,0,0,0),i=Date.UTC(n,e,t,23,59,59,999);if(r)try{const o=new Date(Date.UTC(n,e,t,12,0,0)),l=new Intl.DateTimeFormat("en-US",{timeZone:r,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(o),c=S=>{var w;return(w=l.find(x=>x.type===S))==null?void 0:w.value},u=parseInt(c("year")||"0",10),d=parseInt(c("month")||"0",10)-1,p=parseInt(c("day")||"0",10),h=parseInt(c("hour")||"0",10),f=parseInt(c("minute")||"0",10),y=parseInt(c("second")||"0",10),v=h===24?0:h,b=Date.UTC(u,d,p,v,f,y,0)-o.getTime();s=Date.UTC(n,e,t,0,0,0,0)-b,i=Date.UTC(n,e,t,23,59,59,999)-b}catch{}return{start:new Date(s),end:new Date(i)}}function xs(n,e){if(!e){const t=-n.getTimezoneOffset(),r=t>=0?"+":"-",s=o=>String(o).padStart(2,"0"),i=o=>String(o).padStart(3,"0");return n.getFullYear()+"-"+s(n.getMonth()+1)+"-"+s(n.getDate())+"T"+s(n.getHours())+":"+s(n.getMinutes())+":"+s(n.getSeconds())+"."+i(n.getMilliseconds())+r+s(Math.floor(Math.abs(t)/60))+":"+s(Math.abs(t)%60)}try{const r=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(n),s=k=>{var E;return((E=r.find(I=>I.type===k))==null?void 0:E.value)||"0"},i=s("year"),o=s("month").padStart(2,"0"),a=s("day").padStart(2,"0");let l=parseInt(s("hour"),10);l===24&&(l=0);const c=String(l).padStart(2,"0"),u=s("minute").padStart(2,"0"),d=s("second").padStart(2,"0"),p=String(n.getMilliseconds()).padStart(3,"0"),h=parseInt(i,10),f=parseInt(o,10)-1,y=parseInt(a,10),g=Date.UTC(h,f,y,l,parseInt(u,10),parseInt(d,10),n.getMilliseconds())-n.getTime(),b=Math.round(g/6e4),S=b>=0?"+":"-",w=Math.abs(b),x=String(Math.floor(w/60)).padStart(2,"0"),C=String(w%60).padStart(2,"0");return`${i}-${o}-${a}T${c}:${u}:${d}.${p}${S}${x}:${C}`}catch{return n.toISOString()}}const Ss=`
|
|
81
|
+
${s}${l}
|
|
82
|
+
|
|
83
|
+
Element pointing:
|
|
84
|
+
1. Prefer DOM layout scan coordinates above — find the label, use its x,y.
|
|
85
|
+
2. Call point_at_screen with label set to the visible button/tab text (e.g. label="Cancel") — the client rescans the live page, including modals opened after capture.
|
|
86
|
+
3. If a modal or dialog opened after capture, call capture_screen_vision again OR use point_at with an exact label — live DOM scan will find modal buttons.
|
|
87
|
+
4. Only guess x,y from the image if the element is missing from the layout scan.
|
|
88
|
+
|
|
89
|
+
The blue buddy cursor flies to the coordinate visually — it does not click.
|
|
90
|
+
|
|
91
|
+
Element highlighting (highlight_on_screen) — after capture_screen_vision:
|
|
92
|
+
1. Prefer layout scan ids: highlight_on_screen with element_id="e4" OR label="Switch to Media tab".
|
|
93
|
+
2. Client live-rescans DOM, draws a glowing box around the element bbox on the overlay.
|
|
94
|
+
3. Persists until clear_screen_draw (same as draw_on_screen). Set point_at:false to skip buddy cursor.
|
|
95
|
+
|
|
96
|
+
${Xx}`}function e7(r,e,t,n,i){const s=n/Math.max(1,e),a=i/Math.max(1,t);return{x:Math.round(r.left*s),y:Math.round(r.top*a),width:Math.max(4,Math.round(r.width*s)),height:Math.max(4,Math.round(r.height*a))}}function t7(r){var i,s,a,A;const e=(i=r.css_selector)==null?void 0:i.trim();if(e)return{element_id:"",label:((s=r.label)==null?void 0:s.trim())||e,kind:"interactive",css_selector:e,screenshot_x:0,screenshot_y:0,viewport_x:0,viewport_y:0};const t=(a=r.element_id)==null?void 0:a.trim();if(t){const o=xx(t);return o||mv(r.staleLayoutElements,t)}const n=(A=r.label)==null?void 0:A.trim();if(n){const o=gv(n);return o?o.element:Mu(r.staleLayoutElements,n)}return null}function n7(r,e=8){try{const t=document.querySelector(r);if(!t)return null;const n=t.getBoundingClientRect();if(n.width<1||n.height<1)return null;const i=hs(),s=Math.max(0,n.left-e),a=Math.max(0,n.top-e),A=Math.min(i.width,n.right+e),o=Math.min(i.height,n.bottom+e);return new DOMRect(s,a,Math.max(4,A-s),Math.max(4,o-a))}catch{return null}}function Kf(r){const e=t7(r);if(!(e!=null&&e.css_selector))return null;const t=Number.isFinite(r.padding)?Math.max(0,r.padding):8,n=n7(e.css_selector,t);if(!n)return null;const i=hs(),s=r.captureCtx,a=(s==null?void 0:s.widthPx)??i.width,A=(s==null?void 0:s.heightPx)??i.height,o=(s==null?void 0:s.viewportWidthCss)??i.width,c=(s==null?void 0:s.viewportHeightCss)??i.height,l=e7({left:n.left,top:n.top,width:n.width,height:n.height},o,c,a,A),d=r.stroke??"#3b82f6";return{command:{op:"highlight_box",x:l.x,y:l.y,width:l.width,height:l.height,rx:r.rx??10,stroke:d,stroke_width:3,fill:"rgba(59,130,246,0.14)",opacity:.95},css_selector:e.css_selector,label:e.label,center_x:Math.round(l.x+l.width/2),center_y:Math.round(l.y+l.height/2),bbox:l}}const ot=8,mo=new Set(["line","arrow"]);function r7(r,e){return r.x<e.x+e.w+ot&&r.x+r.w+ot>e.x&&r.y<e.y+e.h+ot&&r.y+r.h+ot>e.y}function yt(r,e,t){return _u({x:r,y:e},t.screenshotWidth,t.screenshotHeight,t.viewportWidthCss,t.viewportHeightCss)}function ti(r,e=ot){if(!r.length)return null;let t=1/0,n=1/0,i=-1/0,s=-1/0;for(const a of r)t=Math.min(t,a.x),n=Math.min(n,a.y),i=Math.max(i,a.x),s=Math.max(s,a.y);return{x:t-e,y:n-e,w:i-t+e*2,h:s-n+e*2}}function Bv(r,e){if(r.op==="line"||r.op==="arrow")return ti([yt(r.x1,r.y1,e),yt(r.x2,r.y2,e)],12);if(r.op==="underline")return ti([yt(r.x,r.y,e),yt(r.x+r.width,r.y,e)],10);if(r.op==="highlight_box"){const t=yt(r.x,r.y,e),n=yt(r.x+r.width,r.y+r.height,e),i=Math.min(t.x,n.x)-ot,s=Math.min(t.y,n.y)-ot;return{x:i,y:s,w:Math.abs(n.x-t.x)+ot*2,h:Math.abs(n.y-t.y)+ot*2}}if(r.op==="circle"){const t=yt(r.cx,r.cy,e),n=yt(r.cx+r.r,r.cy,e),i=Math.max(4,Math.hypot(n.x-t.x,n.y-t.y));return{x:t.x-i-ot,y:t.y-i-ot,w:i*2+ot*2,h:i*2+ot*2}}if(r.op==="ellipse"){const t=yt(r.cx,r.cy,e),n=yt(r.cx+r.rx,r.cy,e),i=yt(r.cx,r.cy+r.ry,e),s=Math.abs(n.x-t.x),a=Math.abs(i.y-t.y);return{x:t.x-s-ot,y:t.y-a-ot,w:s*2+ot*2,h:a*2+ot*2}}if(r.op==="regular_polygon"){const t=(r.rotation_deg??0)*Math.PI/180,n=[];for(let i=0;i<r.sides;i++){const s=t-Math.PI/2+i*2*Math.PI/r.sides;n.push(yt(r.cx+r.radius*Math.cos(s),r.cy+r.radius*Math.sin(s),e))}return ti(n)}if(r.op==="polygon")return ti(r.points.map(([t,n])=>yt(t,n,e)));if(r.op==="label"){const t=yt(r.x,r.y,e),n=r.font_size??11,i=Math.min(280,Math.max(40,r.text.length*7+16)),s=n+8;return{x:t.x,y:t.y-s/2-ot,w:i+ot,h:s+ot*2}}if(r.op==="parabola"){const t=[];for(let i=0;i<=24;i++){const s=r.x_min+(r.x_max-r.x_min)*i/24,a=r.a*(s-r.h)**2+r.k;t.push(yt(s,a,e))}return ti(t)}if(r.op==="hyperbola"){const t=[],n=r.t_min??-2.5,i=r.t_max??2.5;for(let s=0;s<=20;s++){const a=n+(i-n)*s/20;t.push(yt(r.cx+r.a*Math.cosh(a),r.cy+r.b*Math.sinh(a),e)),t.push(yt(r.cx-r.a*Math.cosh(a),r.cy+r.b*Math.sinh(a),e))}return ti(t)}return r.op==="bezier"?ti(r.points.map(([t,n])=>yt(t,n,e))):null}function i7(r,e){return!(mo.has(r)||mo.has(e)||r==="label"&&e!=="label"||e==="label"&&r!=="label")}function Cv(r,e){const t=[];for(const n of r){if(mo.has(n.op))continue;const i=Bv(n,e);i&&t.push(i)}return t}function s7(r,e,t){const n=t.map((s,a)=>({bounds:s,index:-(a+1),op:"existing"})),i=[];for(let s=0;s<r.length;s++){const a=r[s],A=Bv(a,e);if(!A||mo.has(a.op)){A&&n.push({bounds:A,index:s,op:a.op});continue}for(const o of n)i7(a.op,o.op)&&r7(A,o.bounds)&&i.push({commandIndex:s,op:a.op,conflictsWithIndex:o.index,conflictsWithOp:o.op});n.push({bounds:A,index:s,op:a.op})}return i.length>0?{ok:!1,conflicts:i}:{ok:!0,commands:r,bounds:Cv(r,e)}}function a7(r){const e=r[0],n=e.conflictsWithIndex<0?"an existing on-screen annotation":`command #${e.conflictsWithIndex} (${e.conflictsWithOp})`,i=r.length>1?` (+${r.length-1} more)`:"";return`Draw rejected: overlap detected between command #${e.commandIndex} (${e.op}) and ${n}${i}. Adjust coordinates, call clear_screen_draw, or set allow_overlap:true.`}class A7{constructor(){L(this,"svg",null);L(this,"items",[]);L(this,"occupiedBounds",[]);L(this,"frameId",null);L(this,"mountedRoot",null)}mount(e){if(this.svg&&this.mountedRoot===e)return;this.unmount();const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("class","vnr-screen-draw-layer"),t.setAttribute("aria-hidden","true"),t.style.cssText=["position:absolute","inset:0","width:100%","height:100%","pointer-events:none","overflow:visible"].join(";"),e.insertBefore(t,e.firstChild),this.svg=t,this.mountedRoot=e}unmount(){var e;this.stopFrame(),this.items=[],this.occupiedBounds=[],(e=this.svg)==null||e.remove(),this.svg=null,this.mountedRoot=null}clear(){this.items=[],this.occupiedBounds=[],this.svg&&(this.svg.innerHTML=""),this.stopFrame()}drawCommands(e,t={}){const n=wv(e);if(!n.length||!this.svg)return{drawn:0,message:"No draw commands"};t.clearExisting&&this.clear();const i=this.resolveCoordContext(t);if(!(t.allowOverlap===!0)){const A=s7(n,i,this.occupiedBounds);if(!A.ok){const o=a7(A.conflicts);return{drawn:0,rejected:!0,overlapDetected:!0,conflicts:A.conflicts,message:o}}return this.occupiedBounds.push(...A.bounds),this.renderCommands(A.commands,i,t)}const a=Cv(n,i);return this.occupiedBounds.push(...a),this.renderCommands(n,i,t)}drawParsed(e,t={}){return this.drawCommands(e,t)}renderCommands(e,t,n){const i=n.animateMs??yv,s=n.ttlMs!==void 0?n.ttlMs:vv,a=jx(e,t,{ttlMs:s,animateMs:i});return this.items.push(...a),this.scheduleFrame(),{drawn:a.length}}resolveCoordContext(e){const t=e.screenshotWidth??window.innerWidth,n=e.screenshotHeight??window.innerHeight,i=e.viewportWidthCss??window.innerWidth,s=e.viewportHeightCss??window.innerHeight;return{screenshotWidth:t,screenshotHeight:n,viewportWidthCss:i,viewportHeightCss:s}}scheduleFrame(){if(this.frameId!==null)return;const e=()=>{this.frameId=null,this.render(),this.items.length>0&&this.needsAnimationFrame()&&(this.frameId=requestAnimationFrame(e))};this.frameId=requestAnimationFrame(e)}needsAnimationFrame(){const e=performance.now();return this.items.some(t=>{const n=e-t.born;return n<0||n<t.animateMs||t.ttl!==null&&n>t.ttl*.75})}stopFrame(){this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}render(){if(!this.svg)return;const e=performance.now(),t=[],n=[];for(const i of this.items){const s=e-i.born;if(s<0){t.push(i);continue}if(i.ttl!==null&&s>i.ttl)continue;t.push(i);let a=1;i.ttl!==null&&s>i.ttl*.75&&(a=Math.max(0,1-(s-i.ttl*.75)/(i.ttl*.25)));const A=Math.min(1,s/i.animateMs);let o=Wx(i.svg,i,A);a<.999&&(o=`<g opacity="${a.toFixed(3)}">${o}</g>`),n.push(o)}this.items=t,this.svg.innerHTML=n.join(""),t.length===0&&(this.occupiedBounds=[])}}function o7(){const r=window.innerWidth,e=window.innerHeight,t=Math.round(r*.5),n=Math.round(e*.45);Qr().drawOnScreen([{op:"regular_polygon",cx:t,cy:n-80,radius:50,sides:3,stroke:"#3380FF"},{op:"regular_polygon",cx:t-160,cy:n,radius:45,sides:8,stroke:"#22c55e"},{op:"regular_polygon",cx:t+160,cy:n,radius:45,sides:10,stroke:"#f59e0b"},{op:"parabola",h:t,k:n+120,a:.003,x_min:t-200,x_max:t+200,stroke:"#ec4899"},{op:"hyperbola",cx:t,cy:n+140,a:40,b:28,stroke:"#8b5cf6"},{op:"arrow",x1:t-120,y1:n+200,x2:t+40,y2:n+60,stroke:"#3380FF"},{op:"label",x:t-80,y:n+220,text:"Tier B demo"}],{clear:!0,screenshotWidth:r,screenshotHeight:e,viewportWidthCss:r,viewportHeightCss:e,ttlMs:12e3,animateMs:800})}function c7(){typeof window>"u"||(window.__vnrDrawDemo=o7)}const Vf="#3b82f6",zf=["right here!","this one!","over here!","look here!"];class l7{constructor(){L(this,"root",null);L(this,"buddy",null);L(this,"bubble",null);L(this,"spinner",null);L(this,"waveform",null);L(this,"visible",!1);L(this,"voiceState","idle");L(this,"buddyMode","following");L(this,"position",{x:120,y:120});L(this,"followTimer",null);L(this,"animTimer",null);L(this,"returnTimer",null);L(this,"lastCapture",null);L(this,"opacity",0);L(this,"drawLayer",new A7)}ensureMounted(){if(typeof document>"u"||this.root)return;const e=document.createElement("div");e.className="vnr-screen-vision-root",e.setAttribute("aria-hidden","true"),e.style.cssText=["position:fixed","inset:0","z-index:2147483640","pointer-events:none","overflow:hidden"].join(";");const t=document.createElement("div");t.className="vnr-screen-vision-buddy",t.style.cssText=["position:absolute","width:0","height:0","opacity:0","transition:opacity 0.25s ease","will-change:transform,left,top"].join(";"),t.innerHTML=`
|
|
97
|
+
<div class="vnr-buddy-triangle" style="
|
|
98
|
+
width:0;height:0;
|
|
99
|
+
border-left:14px solid transparent;
|
|
100
|
+
border-right:14px solid transparent;
|
|
101
|
+
border-bottom:24px solid ${Vf};
|
|
102
|
+
filter:drop-shadow(0 0 8px ${Vf});
|
|
103
|
+
transform:rotate(-35deg);
|
|
104
|
+
transform-origin:50% 80%;
|
|
105
|
+
"></div>
|
|
106
|
+
`;const n=document.createElement("div");n.className="vnr-buddy-bubble",n.style.cssText=["position:absolute","left:28px","top:-8px","max-width:220px","padding:8px 12px","border-radius:12px","background:rgba(15,23,42,0.92)","border:1px solid rgba(255,255,255,0.12)","color:#f8fafc","font:600 12px/1.35 -apple-system,BlinkMacSystemFont,sans-serif","white-space:nowrap","opacity:0","transform:scale(0.92)","transition:opacity 0.2s ease, transform 0.2s ease"].join(";");const i=document.createElement("div");i.className="vnr-buddy-spinner",i.style.cssText=["position:absolute","left:-6px","top:-6px","width:28px","height:28px","border-radius:50%","border:3px solid rgba(59,130,246,0.25)","border-top-color:#3b82f6","animation:vnr-sv-spin 0.8s linear infinite","opacity:0"].join(";");const s=document.createElement("div");s.className="vnr-buddy-waveform",s.style.cssText=["position:absolute","left:-4px","top:2px","display:flex","gap:3px","align-items:flex-end","height:18px","opacity:0"].join(";");for(let a=0;a<4;a++){const A=document.createElement("span");A.style.cssText=["display:block","width:3px","height:8px","border-radius:2px","background:#3b82f6",`animation:vnr-sv-wave 0.9s ease-in-out ${a*.12}s infinite alternate`].join(";"),s.appendChild(A)}if(!document.getElementById("vnr-screen-vision-styles")){const a=document.createElement("style");a.id="vnr-screen-vision-styles",a.textContent=`
|
|
107
|
+
@keyframes vnr-sv-spin { to { transform: rotate(360deg); } }
|
|
108
|
+
@keyframes vnr-sv-wave {
|
|
109
|
+
from { height: 6px; opacity: 0.55; }
|
|
110
|
+
to { height: 16px; opacity: 1; }
|
|
111
|
+
}
|
|
112
|
+
`,document.head.appendChild(a)}t.appendChild(n),t.appendChild(i),t.appendChild(s),e.appendChild(t),document.body.appendChild(e),this.root=e,this.drawLayer.mount(e),this.buddy=t,this.bubble=n,this.spinner=i,this.waveform=s,this.seedFromCursor(),this.startFollowing()}setCaptureContext(e){this.lastCapture=e}getCaptureContext(){return this.lastCapture}setVoiceState(e){this.voiceState=e,this.syncAffordances()}show(){this.ensureMounted(),this.visible=!0,this.opacity=1,this.applyBuddyOpacity()}hide(){this.visible=!1,this.opacity=0,this.applyBuddyOpacity(),this.hideBubble(),this.buddyMode="following",this.clearAnimTimer()}destroy(){var e;this.stopFollowing(),this.clearAnimTimer(),this.drawLayer.unmount(),this.returnTimer&&clearTimeout(this.returnTimer),(e=this.root)==null||e.remove(),this.root=null,this.buddy=null,this.bubble=null,this.spinner=null,this.waveform=null}pointAtScreenshotPixels(e,t,n){var l,d,u,h;this.ensureMounted(),this.show();const i=(n==null?void 0:n.screenshotWidth)??((l=this.lastCapture)==null?void 0:l.widthPx)??window.innerWidth,s=(n==null?void 0:n.screenshotHeight)??((d=this.lastCapture)==null?void 0:d.heightPx)??window.innerHeight,a=(n==null?void 0:n.viewportWidthCss)??((u=this.lastCapture)==null?void 0:u.viewportWidthCss)??window.innerWidth,A=(n==null?void 0:n.viewportHeightCss)??((h=this.lastCapture)==null?void 0:h.viewportHeightCss)??window.innerHeight,o=_u({x:e,y:t},i,s,a,A),c={x:Math.max(20,Math.min(o.x+8,window.innerWidth-20)),y:Math.max(20,Math.min(o.y+12,window.innerHeight-20))};this.buddyMode="navigating",this.animateBezierFlight(this.position,c,()=>{this.buddyMode="pointing";const p=(n==null?void 0:n.bubbleText)||(n!=null&&n.label?n.label:zf[Math.floor(Math.random()*zf.length)]);this.showBubble(p),this.returnTimer&&clearTimeout(this.returnTimer),this.returnTimer=setTimeout(()=>this.flyBackToCursor(),3e3)})}dismissPointing(){this.returnTimer&&clearTimeout(this.returnTimer),this.hideBubble(),this.buddyMode="following",this.clearAnimTimer()}drawOnScreen(e,t){this.ensureMounted(),this.show();const n=this.lastCapture;return this.drawLayer.drawCommands(e,{screenshotWidth:(t==null?void 0:t.screenshotWidth)??(n==null?void 0:n.widthPx),screenshotHeight:(t==null?void 0:t.screenshotHeight)??(n==null?void 0:n.heightPx),viewportWidthCss:(t==null?void 0:t.viewportWidthCss)??(n==null?void 0:n.viewportWidthCss),viewportHeightCss:(t==null?void 0:t.viewportHeightCss)??(n==null?void 0:n.viewportHeightCss),ttlMs:t==null?void 0:t.ttlMs,animateMs:t==null?void 0:t.animateMs,clearExisting:(t==null?void 0:t.clear)===!0||(t==null?void 0:t.clearExisting)===!0,allowOverlap:t==null?void 0:t.allowOverlap})}clearDrawings(){this.drawLayer.clear()}seedFromCursor(){const e=Math.min(window.innerWidth-40,Math.max(40,window.innerWidth*.5)),t=Math.min(window.innerHeight-40,Math.max(40,window.innerHeight*.5));this.position={x:e+35,y:t+25},this.applyPosition()}startFollowing(){this.followTimer||(this.followTimer=setInterval(()=>{if(!this.visible||this.buddyMode!=="following")return;const e=Math.max(20,Math.min(window.innerWidth-20,this.getMouseX())),t=Math.max(20,Math.min(window.innerHeight-20,this.getMouseY()));this.position={x:e+35,y:t+25},this.applyPosition()},16))}stopFollowing(){this.followTimer&&clearInterval(this.followTimer),this.followTimer=null}getMouseX(){return window.__vnrLastMouseX??window.innerWidth/2}getMouseY(){return window.__vnrLastMouseY??window.innerHeight/2}applyPosition(){this.buddy&&(this.buddy.style.left=`${this.position.x}px`,this.buddy.style.top=`${this.position.y}px`)}applyBuddyOpacity(){this.buddy&&(this.buddy.style.opacity=this.visible?String(this.opacity):"0")}syncAffordances(){if(!this.spinner||!this.waveform||!this.buddy)return;const e=this.buddy.querySelector(".vnr-buddy-triangle");this.spinner.style.opacity=this.voiceState==="processing"?"1":"0",this.waveform.style.opacity=this.voiceState==="listening"?"1":"0",e&&(e.style.opacity=this.voiceState==="idle"||this.voiceState==="responding"?"1":"0.15")}showBubble(e){this.bubble&&(this.bubble.textContent=e,this.bubble.style.opacity="1",this.bubble.style.transform="scale(1)")}hideBubble(){this.bubble&&(this.bubble.style.opacity="0",this.bubble.style.transform="scale(0.92)")}flyBackToCursor(){this.hideBubble(),this.buddyMode="navigating";const e={x:this.getMouseX()+35,y:this.getMouseY()+25};this.animateBezierFlight(this.position,e,()=>{this.buddyMode="following"})}clearAnimTimer(){this.animTimer&&clearInterval(this.animTimer),this.animTimer=null}animateBezierFlight(e,t,n){this.clearAnimTimer();const i=Math.hypot(t.x-e.x,t.y-e.y),s=Math.max(600,Math.min(1400,600+i*.8)),a=performance.now(),A={x:(e.x+t.x)/2,y:Math.min(e.y,t.y)-Math.min(120,i*.35)};this.animTimer=setInterval(()=>{const o=performance.now()-a,c=Math.min(1,o/s),l=1-c,d=l*l*e.x+2*l*c*A.x+c*c*t.x,u=l*l*e.y+2*l*c*A.y+c*c*t.y;this.position={x:d,y:u},this.applyPosition(),c>=1&&(this.clearAnimTimer(),n())},16)}}function d7(){if(typeof window>"u")return()=>{};const r=e=>{window.__vnrLastMouseX=e.clientX,window.__vnrLastMouseY=e.clientY};return window.addEventListener("mousemove",r,{passive:!0}),()=>window.removeEventListener("mousemove",r)}let sl=null;function Qr(){return sl||(sl=new l7,d7(),c7()),sl}const u7="vanira:board-active";function al(r,e=!1){typeof window>"u"||window.dispatchEvent(new CustomEvent(u7,{detail:{active:r,reduced:e}}))}class rn{constructor(e,t,n){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=n}static range(e,t){return t?!e||!e.loc||!t.loc||e.loc.lexer!==t.loc.lexer?null:new rn(e.loc.lexer,e.loc.start,t.loc.end):e&&e.loc}}class gn{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new gn(t,rn.range(this,e))}}class W{constructor(e,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var n="KaTeX parse error: "+e,i,s,a=t&&t.loc;if(a&&a.start<=a.end){var A=a.lexer.input;i=a.start,s=a.end,i===A.length?n+=" at end of input: ":n+=" at position "+(i+1)+": ";var o=A.slice(i,s).replace(/[^]/g,"$&̲"),c;i>15?c="…"+A.slice(i-15,i):c=A.slice(0,i);var l;s+15<A.length?l=A.slice(s,s+15)+"…":l=A.slice(s),n+=c+o+l}var d=new Error(n);return d.name="ParseError",d.__proto__=W.prototype,d.position=i,i!=null&&s!=null&&(d.length=s-i),d.rawMessage=e,d}}W.prototype.__proto__=Error.prototype;var h7=function(e,t){return e.indexOf(t)!==-1},f7=function(e,t){return e===void 0?t:e},p7=/([A-Z])/g,m7=function(e){return e.replace(p7,"-$1").toLowerCase()},g7={"&":"&",">":">","<":"<",'"':""","'":"'"},v7=/[&><"']/g;function y7(r){return String(r).replace(v7,e=>g7[e])}var Sv=function r(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?r(e.body[0]):e:e.type==="font"?r(e.body):e},w7=function(e){var t=Sv(e);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},b7=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},B7=function(e){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},ce={contains:h7,deflt:f7,escape:y7,hyphenate:m7,getBaseElem:Sv,isCharacterBox:w7,protocolFromUrl:B7},QA={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:r=>"#"+r},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(r,e)=>(e.push(r),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:r=>Math.max(0,r),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:r=>Math.max(0,r),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:r=>Math.max(0,r),cli:"-e, --max-expand <n>",cliProcessor:r=>r==="Infinity"?1/0:parseInt(r)},globalGroup:{type:"boolean",cli:!1}};function C7(r){if(r.default)return r.default;var e=r.type,t=Array.isArray(e)?e[0]:e;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class Ru{constructor(e){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var t in QA)if(QA.hasOwnProperty(t)){var n=QA[t];this[t]=e[t]!==void 0?n.processor?n.processor(e[t]):e[t]:C7(n)}}reportNonstrict(e,t,n){var i=this.strict;if(typeof i=="function"&&(i=i(e,t,n)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new W("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+e+"]"),n);typeof console<"u"}}useStrictBehavior(e,t,n){var i=this.strict;if(typeof i=="function")try{i=i(e,t,n)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:(typeof console<"u",!1)}isTrusted(e){if(e.url&&!e.protocol){var t=ce.protocolFromUrl(e.url);if(t==null)return!1;e.protocol=t}var n=typeof this.trust=="function"?this.trust(e):this.trust;return!!n}}class Er{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return zn[S7[this.id]]}sub(){return zn[k7[this.id]]}fracNum(){return zn[T7[this.id]]}fracDen(){return zn[x7[this.id]]}cramp(){return zn[E7[this.id]]}text(){return zn[U7[this.id]]}isTight(){return this.size>=2}}var Pu=0,go=1,ns=2,vr=3,Sa=4,mn=5,ls=6,Ot=7,zn=[new Er(Pu,0,!1),new Er(go,0,!0),new Er(ns,1,!1),new Er(vr,1,!0),new Er(Sa,2,!1),new Er(mn,2,!0),new Er(ls,3,!1),new Er(Ot,3,!0)],S7=[Sa,mn,Sa,mn,ls,Ot,ls,Ot],k7=[mn,mn,mn,mn,Ot,Ot,Ot,Ot],T7=[ns,vr,Sa,mn,ls,Ot,ls,Ot],x7=[vr,vr,mn,mn,Ot,Ot,Ot,Ot],E7=[go,go,vr,vr,mn,mn,Ot,Ot],U7=[Pu,go,ns,vr,ns,vr,ns,vr],de={DISPLAY:zn[Pu],TEXT:zn[ns],SCRIPT:zn[Sa],SCRIPTSCRIPT:zn[ls]},Id=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function F7(r){for(var e=0;e<Id.length;e++)for(var t=Id[e],n=0;n<t.blocks.length;n++){var i=t.blocks[n];if(r>=i[0]&&r<=i[1])return t.name}return null}var MA=[];Id.forEach(r=>r.blocks.forEach(e=>MA.push(...e)));function kv(r){for(var e=0;e<MA.length;e+=2)if(r>=MA[e]&&r<=MA[e+1])return!0;return!1}var Oi=80,I7=function(e,t){return"M95,"+(622+e+t)+`
|
|
113
|
+
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
114
|
+
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
115
|
+
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
116
|
+
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
|
|
117
|
+
c69,-144,104.5,-217.7,106.5,-221
|
|
118
|
+
l`+e/2.075+" -"+e+`
|
|
119
|
+
c5.3,-9.3,12,-14,20,-14
|
|
120
|
+
H400000v`+(40+e)+`H845.2724
|
|
121
|
+
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
|
|
122
|
+
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
|
|
123
|
+
M`+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},Q7=function(e,t){return"M263,"+(601+e+t)+`c0.7,0,18,39.7,52,119
|
|
124
|
+
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
|
|
125
|
+
c340,-704.7,510.7,-1060.3,512,-1067
|
|
126
|
+
l`+e/2.084+" -"+e+`
|
|
127
|
+
c4.7,-7.3,11,-11,19,-11
|
|
128
|
+
H40000v`+(40+e)+`H1012.3
|
|
129
|
+
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
|
|
130
|
+
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
|
|
131
|
+
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
|
|
132
|
+
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
|
|
133
|
+
M`+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},M7=function(e,t){return"M983 "+(10+e+t)+`
|
|
134
|
+
l`+e/3.13+" -"+e+`
|
|
135
|
+
c4,-6.7,10,-10,18,-10 H400000v`+(40+e)+`
|
|
136
|
+
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
|
|
137
|
+
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
|
|
138
|
+
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
|
|
139
|
+
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
|
|
140
|
+
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
|
|
141
|
+
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
|
|
142
|
+
M`+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},_7=function(e,t){return"M424,"+(2398+e+t)+`
|
|
143
|
+
c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
|
|
144
|
+
c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
|
|
145
|
+
s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
|
|
146
|
+
s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081
|
|
147
|
+
l`+e/4.223+" -"+e+`c4,-6.7,10,-10,18,-10 H400000
|
|
148
|
+
v`+(40+e)+`H1014.6
|
|
149
|
+
s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
|
|
150
|
+
c-2,6,-10,9,-24,9
|
|
151
|
+
c-8,0,-12,-0.7,-12,-2z M`+(1001+e)+" "+t+`
|
|
152
|
+
h400000v`+(40+e)+"h-400000z"},R7=function(e,t){return"M473,"+(2713+e+t)+`
|
|
153
|
+
c339.3,-1799.3,509.3,-2700,510,-2702 l`+e/5.298+" -"+e+`
|
|
154
|
+
c3.3,-7.3,9.3,-11,18,-11 H400000v`+(40+e)+`H1017.7
|
|
155
|
+
s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9
|
|
156
|
+
c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200
|
|
157
|
+
c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26
|
|
158
|
+
s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,
|
|
159
|
+
606zM`+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"},P7=function(e){var t=e/2;return"M400000 "+e+" H0 L"+t+" 0 l65 45 L145 "+(e-80)+" H400000z"},D7=function(e,t,n){var i=n-54-t-e;return"M702 "+(e+t)+"H400000"+(40+e)+`
|
|
160
|
+
H742v`+i+`l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1
|
|
161
|
+
h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170
|
|
162
|
+
c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667
|
|
163
|
+
219 661 l218 661zM702 `+t+"H400000v"+(40+e)+"H742z"},L7=function(e,t,n){t=1e3*t;var i="";switch(e){case"sqrtMain":i=I7(t,Oi);break;case"sqrtSize1":i=Q7(t,Oi);break;case"sqrtSize2":i=M7(t,Oi);break;case"sqrtSize3":i=_7(t,Oi);break;case"sqrtSize4":i=R7(t,Oi);break;case"sqrtTall":i=D7(t,Oi,n)}return i},O7=function(e,t){switch(e){case"⎜":return"M291 0 H417 V"+t+" H291z M291 0 H417 V"+t+" H291z";case"∣":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145z";case"∥":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145z"+("M367 0 H410 V"+t+" H367z M367 0 H410 V"+t+" H367z");case"⎟":return"M457 0 H583 V"+t+" H457z M457 0 H583 V"+t+" H457z";case"⎢":return"M319 0 H403 V"+t+" H319z M319 0 H403 V"+t+" H319z";case"⎥":return"M263 0 H347 V"+t+" H263z M263 0 H347 V"+t+" H263z";case"⎪":return"M384 0 H504 V"+t+" H384z M384 0 H504 V"+t+" H384z";case"⏐":return"M312 0 H355 V"+t+" H312z M312 0 H355 V"+t+" H312z";case"‖":return"M257 0 H300 V"+t+" H257z M257 0 H300 V"+t+" H257z"+("M478 0 H521 V"+t+" H478z M478 0 H521 V"+t+" H478z");default:return""}},Gf={doubleleftarrow:`M262 157
|
|
164
|
+
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
|
|
165
|
+
0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
|
|
166
|
+
14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
|
|
167
|
+
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
|
|
168
|
+
157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
|
|
169
|
+
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
|
|
170
|
+
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
|
|
171
|
+
m8 0v40h399730v-40zm0 194v40h399730v-40z`,doublerightarrow:`M399738 392l
|
|
172
|
+
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
|
|
173
|
+
14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
|
|
174
|
+
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
|
|
175
|
+
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
|
|
176
|
+
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
|
|
177
|
+
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
|
|
178
|
+
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z`,leftarrow:`M400000 241H110l3-3c68.7-52.7 113.7-120
|
|
179
|
+
135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
|
|
180
|
+
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
|
|
181
|
+
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
|
|
182
|
+
490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
|
|
183
|
+
1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
|
|
184
|
+
l-3-3h399890zM100 241v40h399900v-40z`,leftbrace:`M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
|
|
185
|
+
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
|
|
186
|
+
5-6 9-10 13-.7 1-7.3 1-20 1H6z`,leftbraceunder:`M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
|
|
187
|
+
35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
|
|
188
|
+
0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
|
|
189
|
+
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z`,leftgroup:`M400000 80
|
|
190
|
+
H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
|
|
191
|
+
435 0h399565z`,leftgroupunder:`M400000 262
|
|
192
|
+
H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
|
|
193
|
+
435 219h399565z`,leftharpoon:`M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
|
|
194
|
+
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
|
|
195
|
+
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
|
|
196
|
+
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z`,leftharpoonplus:`M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
|
|
197
|
+
20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
|
|
198
|
+
-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
|
|
199
|
+
-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
|
|
200
|
+
m0 0v40h400000v-40z`,leftharpoondown:`M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
|
|
201
|
+
5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
|
|
202
|
+
1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
|
|
203
|
+
-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z`,leftharpoondownplus:`M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
|
|
204
|
+
10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
|
|
205
|
+
-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
|
|
206
|
+
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`,lefthook:`M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
|
|
207
|
+
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
|
|
208
|
+
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
|
|
209
|
+
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:`M40 281 V428 H0 V94 H40 V241 H400000 v40z
|
|
210
|
+
M40 281 V428 H0 V94 H40 V241 H400000 v40z`,leftmapsto:`M40 281 V448H0V74H40V241H400000v40z
|
|
211
|
+
M40 281 V448H0V74H40V241H400000v40z`,leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
|
|
212
|
+
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
|
|
213
|
+
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
|
|
214
|
+
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:`M0 50 h400000 v40H0z m0 194h40000v40H0z
|
|
215
|
+
M0 50 h400000 v40H0z m0 194h40000v40H0z`,midbrace:`M200428 334
|
|
216
|
+
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
|
|
217
|
+
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
|
|
218
|
+
311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
|
|
219
|
+
12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z`,midbraceunder:`M199572 214
|
|
220
|
+
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
|
|
221
|
+
53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
|
|
222
|
+
11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
|
|
223
|
+
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z`,oiintSize1:`M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
|
|
224
|
+
-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
|
|
225
|
+
m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
|
|
226
|
+
60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z`,oiintSize2:`M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8
|
|
227
|
+
-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z
|
|
228
|
+
m502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2
|
|
229
|
+
c0 110 84 276 504 276s502.4-166 502.4-276z`,oiiintSize1:`M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
|
|
230
|
+
-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
|
|
231
|
+
m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
|
|
232
|
+
85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z`,oiiintSize2:`M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8
|
|
233
|
+
-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z
|
|
234
|
+
m770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1
|
|
235
|
+
c0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z`,rightarrow:`M0 241v40h399891c-47.3 35.3-84 78-110 128
|
|
236
|
+
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
|
|
237
|
+
11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
|
|
238
|
+
39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
|
|
239
|
+
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
|
|
240
|
+
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
|
|
241
|
+
151.7 139 205zm0 0v40h399900v-40z`,rightbrace:`M400000 542l
|
|
242
|
+
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
|
|
243
|
+
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
|
|
244
|
+
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z`,rightbraceunder:`M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
|
|
245
|
+
28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
|
|
246
|
+
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z`,rightgroup:`M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
|
|
247
|
+
3-1 3-3v-38c-76-158-257-219-435-219H0z`,rightgroupunder:`M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
|
|
248
|
+
0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z`,rightharpoon:`M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
|
|
249
|
+
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
|
|
250
|
+
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
|
|
251
|
+
69.2 92 94.5zm0 0v40h399900v-40z`,rightharpoonplus:`M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
|
|
252
|
+
-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
|
|
253
|
+
2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
|
|
254
|
+
m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`,rightharpoondown:`M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
|
|
255
|
+
8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
|
|
256
|
+
-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
|
|
257
|
+
-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z`,rightharpoondownplus:`M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
|
|
258
|
+
15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
|
|
259
|
+
8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
|
|
260
|
+
-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
|
|
261
|
+
m0-194v40h400000v-40zm0 0v40h400000v-40z`,righthook:`M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
|
|
262
|
+
15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
|
|
263
|
+
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
|
|
264
|
+
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
|
|
265
|
+
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`,rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
|
|
266
|
+
1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
|
|
267
|
+
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
|
|
268
|
+
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`,twoheadleftarrow:`M0 167c68 40
|
|
269
|
+
115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
|
|
270
|
+
-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
|
|
271
|
+
-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
|
|
272
|
+
-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
|
|
273
|
+
10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z`,twoheadrightarrow:`M400000 167
|
|
274
|
+
c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
|
|
275
|
+
41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
|
|
276
|
+
18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
|
|
277
|
+
-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
|
|
278
|
+
101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z`,tilde1:`M200 55.538c-77 0-168 73.953-177 73.953-3 0-7
|
|
279
|
+
-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0
|
|
280
|
+
114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0
|
|
281
|
+
4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128
|
|
282
|
+
-68.267.847-113-73.952-191-73.952z`,tilde2:`M344 55.266c-142 0-300.638 81.316-311.5 86.418
|
|
283
|
+
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
|
|
284
|
+
31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
|
|
285
|
+
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
|
|
286
|
+
181.476 676 181.476c-149 0-189-126.21-332-126.21z`,tilde3:`M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457
|
|
287
|
+
-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0
|
|
288
|
+
411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697
|
|
289
|
+
16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696
|
|
290
|
+
-338 0-409-156.573-744-156.573z`,tilde4:`M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345
|
|
291
|
+
-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409
|
|
292
|
+
177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9
|
|
293
|
+
14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409
|
|
294
|
+
-175.236-744-175.236z`,vec:`M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
|
|
295
|
+
3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
|
|
296
|
+
10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
|
|
297
|
+
-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
|
|
298
|
+
-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
|
|
299
|
+
H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
|
|
300
|
+
c-16-25.333-24-45-24-59z`,widehat1:`M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22
|
|
301
|
+
c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`,widehat2:`M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
|
|
302
|
+
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widehat3:`M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10
|
|
303
|
+
-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widehat4:`M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10
|
|
304
|
+
-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,widecheck1:`M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,
|
|
305
|
+
-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`,widecheck2:`M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
|
306
|
+
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,widecheck3:`M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
|
307
|
+
-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,widecheck4:`M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
|
308
|
+
-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,baraboveleftarrow:`M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202
|
|
309
|
+
c4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5
|
|
310
|
+
c-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130
|
|
311
|
+
s-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47
|
|
312
|
+
121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6
|
|
313
|
+
s2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11
|
|
314
|
+
c0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z
|
|
315
|
+
M100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z`,rightarrowabovebar:`M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32
|
|
316
|
+
-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0
|
|
317
|
+
13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39
|
|
318
|
+
-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5
|
|
319
|
+
-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
|
|
320
|
+
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
|
|
321
|
+
151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z`,baraboveshortleftharpoon:`M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
|
|
322
|
+
c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17
|
|
323
|
+
c2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21
|
|
324
|
+
c-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40
|
|
325
|
+
c-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z
|
|
326
|
+
M0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z`,rightharpoonaboveshortbar:`M0,241 l0,40c399126,0,399993,0,399993,0
|
|
327
|
+
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
|
328
|
+
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
|
|
329
|
+
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
|
330
|
+
M0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z`,shortbaraboveleftharpoon:`M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11
|
|
331
|
+
c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,
|
|
332
|
+
1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,
|
|
333
|
+
-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z
|
|
334
|
+
M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`,shortrightharpoonabovebar:`M53,241l0,40c398570,0,399437,0,399437,0
|
|
335
|
+
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
|
336
|
+
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
|
|
337
|
+
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
|
338
|
+
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},H7=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+` v1759 h347 v-84
|
|
339
|
+
H403z M403 1759 V0 H319 V1759 v`+t+" v1759 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+` v1759 H0 v84 H347z
|
|
340
|
+
M347 1759 V0 H263 V1759 v`+t+" v1759 h84z";case"vert":return"M145 15 v585 v"+t+` v585 c2.667,10,9.667,15,21,15
|
|
341
|
+
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
342
|
+
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v`+t+" v585 h43z";case"doublevert":return"M145 15 v585 v"+t+` v585 c2.667,10,9.667,15,21,15
|
|
343
|
+
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
344
|
+
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v`+t+` v585 h43z
|
|
345
|
+
M367 15 v585 v`+t+` v585 c2.667,10,9.667,15,21,15
|
|
346
|
+
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
347
|
+
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v`+t+" v585 h43z";case"lfloor":return"M319 602 V0 H403 V602 v"+t+` v1715 h263 v84 H319z
|
|
348
|
+
MM319 602 V0 H403 V602 v`+t+" v1715 H319z";case"rfloor":return"M319 602 V0 H403 V602 v"+t+` v1799 H0 v-84 H319z
|
|
349
|
+
MM319 602 V0 H403 V602 v`+t+" v1715 H319z";case"lceil":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+` v602 h84z
|
|
350
|
+
M403 1759 V0 H319 V1759 v`+t+" v602 h84z";case"rceil":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+` v602 h84z
|
|
351
|
+
M347 1759 V0 h-84 V1759 v`+t+" v602 h84z";case"lparen":return`M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1
|
|
352
|
+
c-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,
|
|
353
|
+
-36,557 l0,`+(t+84)+`c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,
|
|
354
|
+
949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9
|
|
355
|
+
c0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,
|
|
356
|
+
-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189
|
|
357
|
+
l0,-`+(t+92)+`c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,
|
|
358
|
+
-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z`;case"rparen":return`M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,
|
|
359
|
+
63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5
|
|
360
|
+
c11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,`+(t+9)+`
|
|
361
|
+
c-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664
|
|
362
|
+
c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11
|
|
363
|
+
c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17
|
|
364
|
+
c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558
|
|
365
|
+
l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
366
|
+
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw new Error("Unknown stretchy delimiter.")}};class Ea{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return ce.contains(this.classes,e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e="",t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){var e=t=>t.toText();return this.children.map(e).join("")}}var Wn={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},rA={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},qf={Å:"A",Ð:"D",Þ:"o",å:"a",ð:"d",þ:"o",А:"A",Б:"B",В:"B",Г:"F",Д:"A",Е:"E",Ж:"K",З:"3",И:"N",Й:"N",К:"K",Л:"N",М:"M",Н:"H",О:"O",П:"N",Р:"P",С:"C",Т:"T",У:"y",Ф:"O",Х:"X",Ц:"U",Ч:"h",Ш:"W",Щ:"W",Ъ:"B",Ы:"X",Ь:"B",Э:"3",Ю:"X",Я:"R",а:"a",б:"b",в:"a",г:"r",д:"y",е:"e",ж:"m",з:"e",и:"n",й:"n",к:"n",л:"n",м:"m",н:"n",о:"o",п:"n",р:"p",с:"c",т:"o",у:"y",ф:"b",х:"x",ц:"n",ч:"n",ш:"w",щ:"w",ъ:"a",ы:"m",ь:"a",э:"e",ю:"m",я:"r"};function N7(r,e){Wn[r]=e}function Du(r,e,t){if(!Wn[e])throw new Error("Font metrics not found for font: "+e+".");var n=r.charCodeAt(0),i=Wn[e][n];if(!i&&r[0]in qf&&(n=qf[r[0]].charCodeAt(0),i=Wn[e][n]),!i&&t==="text"&&kv(n)&&(i=Wn[e][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var Al={};function K7(r){var e;if(r>=5?e=0:r>=3?e=1:e=2,!Al[e]){var t=Al[e]={cssEmPerMu:rA.quad[e]/18};for(var n in rA)rA.hasOwnProperty(n)&&(t[n]=rA[n][e])}return Al[e]}var V7=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],Wf=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],$f=function(e,t){return t.size<2?e:V7[e-1][t.size-1]};class hr{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||hr.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=Wf[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){var t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return new hr(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:$f(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:Wf[e-1]})}havingBaseStyle(e){e=e||this.style.text();var t=$f(hr.BASESIZE,e);return this.size===t&&this.textSize===hr.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==hr.BASESIZE?["sizing","reset-size"+this.size,"size"+hr.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=K7(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}hr.BASESIZE=6;var Qd={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},z7={ex:!0,em:!0,mu:!0},Tv=function(e){return typeof e!="string"&&(e=e.unit),e in Qd||e in z7||e==="ex"},Ze=function(e,t){var n;if(e.unit in Qd)n=Qd[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit==="mu")n=t.fontMetrics().cssEmPerMu;else{var i;if(t.style.isTight()?i=t.havingStyle(t.style.text()):i=t,e.unit==="ex")n=i.fontMetrics().xHeight;else if(e.unit==="em")n=i.fontMetrics().quad;else throw new W("Invalid unit: '"+e.unit+"'");i!==t&&(n*=i.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},j=function(e){return+e.toFixed(4)+"em"},$r=function(e){return e.filter(t=>t).join(" ")},xv=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push("mtight");var i=t.getColor();i&&(this.style.color=i)}},Ev=function(e){var t=document.createElement(e);t.className=$r(this.classes);for(var n in this.style)this.style.hasOwnProperty(n)&&(t.style[n]=this.style[n]);for(var i in this.attributes)this.attributes.hasOwnProperty(i)&&t.setAttribute(i,this.attributes[i]);for(var s=0;s<this.children.length;s++)t.appendChild(this.children[s].toNode());return t},Uv=function(e){var t="<"+e;this.classes.length&&(t+=' class="'+ce.escape($r(this.classes))+'"');var n="";for(var i in this.style)this.style.hasOwnProperty(i)&&(n+=ce.hyphenate(i)+":"+this.style[i]+";");n&&(t+=' style="'+ce.escape(n)+'"');for(var s in this.attributes)this.attributes.hasOwnProperty(s)&&(t+=" "+s+'="'+ce.escape(this.attributes[s])+'"');t+=">";for(var a=0;a<this.children.length;a++)t+=this.children[a].toMarkup();return t+="</"+e+">",t};class Ua{constructor(e,t,n,i){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,xv.call(this,e,n,i),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return ce.contains(this.classes,e)}toNode(){return Ev.call(this,"span")}toMarkup(){return Uv.call(this,"span")}}class Lu{constructor(e,t,n,i){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,xv.call(this,t,i),this.children=n||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return ce.contains(this.classes,e)}toNode(){return Ev.call(this,"a")}toMarkup(){return Uv.call(this,"a")}}class G7{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.style=n}hasClass(e){return ce.contains(this.classes,e)}toNode(){var e=document.createElement("img");e.src=this.src,e.alt=this.alt,e.className="mord";for(var t in this.style)this.style.hasOwnProperty(t)&&(e.style[t]=this.style[t]);return e}toMarkup(){var e='<img src="'+ce.escape(this.src)+'"'+(' alt="'+ce.escape(this.alt)+'"'),t="";for(var n in this.style)this.style.hasOwnProperty(n)&&(t+=ce.hyphenate(n)+":"+this.style[n]+";");return t&&(e+=' style="'+ce.escape(t)+'"'),e+="'/>",e}}var q7={î:"ı̂",ï:"ı̈",í:"ı́",ì:"ı̀"};class vn{constructor(e,t,n,i,s,a,A,o){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=i||0,this.skew=s||0,this.width=a||0,this.classes=A||[],this.style=o||{},this.maxFontSize=0;var c=F7(this.text.charCodeAt(0));c&&this.classes.push(c+"_fallback"),/[îïíì]/.test(this.text)&&(this.text=q7[this.text])}hasClass(e){return ce.contains(this.classes,e)}toNode(){var e=document.createTextNode(this.text),t=null;this.italic>0&&(t=document.createElement("span"),t.style.marginRight=j(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=$r(this.classes));for(var n in this.style)this.style.hasOwnProperty(n)&&(t=t||document.createElement("span"),t.style[n]=this.style[n]);return t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t="<span";this.classes.length&&(e=!0,t+=' class="',t+=ce.escape($r(this.classes)),t+='"');var n="";this.italic>0&&(n+="margin-right:"+this.italic+"em;");for(var i in this.style)this.style.hasOwnProperty(i)&&(n+=ce.hyphenate(i)+":"+this.style[i]+";");n&&(e=!0,t+=' style="'+ce.escape(n)+'"');var s=ce.escape(this.text);return e?(t+=">",t+=s,t+="</span>",t):s}}class br{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");for(var n in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,n)&&t.setAttribute(n,this.attributes[n]);for(var i=0;i<this.children.length;i++)t.appendChild(this.children[i].toNode());return t}toMarkup(){var e='<svg xmlns="http://www.w3.org/2000/svg"';for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=" "+t+'="'+ce.escape(this.attributes[t])+'"');e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</svg>",e}}class jr{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"path");return this.alternate?t.setAttribute("d",this.alternate):t.setAttribute("d",Gf[this.pathName]),t}toMarkup(){return this.alternate?'<path d="'+ce.escape(this.alternate)+'"/>':'<path d="'+ce.escape(Gf[this.pathName])+'"/>'}}class Md{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"line");for(var n in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,n)&&t.setAttribute(n,this.attributes[n]);return t}toMarkup(){var e="<line";for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=" "+t+'="'+ce.escape(this.attributes[t])+'"');return e+="/>",e}}function jf(r){if(r instanceof vn)return r;throw new Error("Expected symbolNode but got "+String(r)+".")}function W7(r){if(r instanceof Ua)return r;throw new Error("Expected span<HtmlDomNode> but got "+String(r)+".")}var $7={bin:1,close:1,inner:1,open:1,punct:1,rel:1},j7={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},Ve={math:{},text:{}};function f(r,e,t,n,i,s){Ve[r][i]={font:e,group:t,replace:n},s&&n&&(Ve[r][n]=Ve[r][i])}var m="math",z="text",y="main",x="ams",ze="accent-token",ne="bin",Kt="close",fs="inner",le="mathord",ht="op-token",An="open",nc="punct",U="rel",kr="spacing",I="textord";f(m,y,U,"≡","\\equiv",!0);f(m,y,U,"≺","\\prec",!0);f(m,y,U,"≻","\\succ",!0);f(m,y,U,"∼","\\sim",!0);f(m,y,U,"⊥","\\perp");f(m,y,U,"⪯","\\preceq",!0);f(m,y,U,"⪰","\\succeq",!0);f(m,y,U,"≃","\\simeq",!0);f(m,y,U,"∣","\\mid",!0);f(m,y,U,"≪","\\ll",!0);f(m,y,U,"≫","\\gg",!0);f(m,y,U,"≍","\\asymp",!0);f(m,y,U,"∥","\\parallel");f(m,y,U,"⋈","\\bowtie",!0);f(m,y,U,"⌣","\\smile",!0);f(m,y,U,"⊑","\\sqsubseteq",!0);f(m,y,U,"⊒","\\sqsupseteq",!0);f(m,y,U,"≐","\\doteq",!0);f(m,y,U,"⌢","\\frown",!0);f(m,y,U,"∋","\\ni",!0);f(m,y,U,"∝","\\propto",!0);f(m,y,U,"⊢","\\vdash",!0);f(m,y,U,"⊣","\\dashv",!0);f(m,y,U,"∋","\\owns");f(m,y,nc,".","\\ldotp");f(m,y,nc,"⋅","\\cdotp");f(m,y,I,"#","\\#");f(z,y,I,"#","\\#");f(m,y,I,"&","\\&");f(z,y,I,"&","\\&");f(m,y,I,"ℵ","\\aleph",!0);f(m,y,I,"∀","\\forall",!0);f(m,y,I,"ℏ","\\hbar",!0);f(m,y,I,"∃","\\exists",!0);f(m,y,I,"∇","\\nabla",!0);f(m,y,I,"♭","\\flat",!0);f(m,y,I,"ℓ","\\ell",!0);f(m,y,I,"♮","\\natural",!0);f(m,y,I,"♣","\\clubsuit",!0);f(m,y,I,"℘","\\wp",!0);f(m,y,I,"♯","\\sharp",!0);f(m,y,I,"♢","\\diamondsuit",!0);f(m,y,I,"ℜ","\\Re",!0);f(m,y,I,"♡","\\heartsuit",!0);f(m,y,I,"ℑ","\\Im",!0);f(m,y,I,"♠","\\spadesuit",!0);f(m,y,I,"§","\\S",!0);f(z,y,I,"§","\\S");f(m,y,I,"¶","\\P",!0);f(z,y,I,"¶","\\P");f(m,y,I,"†","\\dag");f(z,y,I,"†","\\dag");f(z,y,I,"†","\\textdagger");f(m,y,I,"‡","\\ddag");f(z,y,I,"‡","\\ddag");f(z,y,I,"‡","\\textdaggerdbl");f(m,y,Kt,"⎱","\\rmoustache",!0);f(m,y,An,"⎰","\\lmoustache",!0);f(m,y,Kt,"⟯","\\rgroup",!0);f(m,y,An,"⟮","\\lgroup",!0);f(m,y,ne,"∓","\\mp",!0);f(m,y,ne,"⊖","\\ominus",!0);f(m,y,ne,"⊎","\\uplus",!0);f(m,y,ne,"⊓","\\sqcap",!0);f(m,y,ne,"∗","\\ast");f(m,y,ne,"⊔","\\sqcup",!0);f(m,y,ne,"◯","\\bigcirc",!0);f(m,y,ne,"∙","\\bullet",!0);f(m,y,ne,"‡","\\ddagger");f(m,y,ne,"≀","\\wr",!0);f(m,y,ne,"⨿","\\amalg");f(m,y,ne,"&","\\And");f(m,y,U,"⟵","\\longleftarrow",!0);f(m,y,U,"⇐","\\Leftarrow",!0);f(m,y,U,"⟸","\\Longleftarrow",!0);f(m,y,U,"⟶","\\longrightarrow",!0);f(m,y,U,"⇒","\\Rightarrow",!0);f(m,y,U,"⟹","\\Longrightarrow",!0);f(m,y,U,"↔","\\leftrightarrow",!0);f(m,y,U,"⟷","\\longleftrightarrow",!0);f(m,y,U,"⇔","\\Leftrightarrow",!0);f(m,y,U,"⟺","\\Longleftrightarrow",!0);f(m,y,U,"↦","\\mapsto",!0);f(m,y,U,"⟼","\\longmapsto",!0);f(m,y,U,"↗","\\nearrow",!0);f(m,y,U,"↩","\\hookleftarrow",!0);f(m,y,U,"↪","\\hookrightarrow",!0);f(m,y,U,"↘","\\searrow",!0);f(m,y,U,"↼","\\leftharpoonup",!0);f(m,y,U,"⇀","\\rightharpoonup",!0);f(m,y,U,"↙","\\swarrow",!0);f(m,y,U,"↽","\\leftharpoondown",!0);f(m,y,U,"⇁","\\rightharpoondown",!0);f(m,y,U,"↖","\\nwarrow",!0);f(m,y,U,"⇌","\\rightleftharpoons",!0);f(m,x,U,"≮","\\nless",!0);f(m,x,U,"","\\@nleqslant");f(m,x,U,"","\\@nleqq");f(m,x,U,"⪇","\\lneq",!0);f(m,x,U,"≨","\\lneqq",!0);f(m,x,U,"","\\@lvertneqq");f(m,x,U,"⋦","\\lnsim",!0);f(m,x,U,"⪉","\\lnapprox",!0);f(m,x,U,"⊀","\\nprec",!0);f(m,x,U,"⋠","\\npreceq",!0);f(m,x,U,"⋨","\\precnsim",!0);f(m,x,U,"⪹","\\precnapprox",!0);f(m,x,U,"≁","\\nsim",!0);f(m,x,U,"","\\@nshortmid");f(m,x,U,"∤","\\nmid",!0);f(m,x,U,"⊬","\\nvdash",!0);f(m,x,U,"⊭","\\nvDash",!0);f(m,x,U,"⋪","\\ntriangleleft");f(m,x,U,"⋬","\\ntrianglelefteq",!0);f(m,x,U,"⊊","\\subsetneq",!0);f(m,x,U,"","\\@varsubsetneq");f(m,x,U,"⫋","\\subsetneqq",!0);f(m,x,U,"","\\@varsubsetneqq");f(m,x,U,"≯","\\ngtr",!0);f(m,x,U,"","\\@ngeqslant");f(m,x,U,"","\\@ngeqq");f(m,x,U,"⪈","\\gneq",!0);f(m,x,U,"≩","\\gneqq",!0);f(m,x,U,"","\\@gvertneqq");f(m,x,U,"⋧","\\gnsim",!0);f(m,x,U,"⪊","\\gnapprox",!0);f(m,x,U,"⊁","\\nsucc",!0);f(m,x,U,"⋡","\\nsucceq",!0);f(m,x,U,"⋩","\\succnsim",!0);f(m,x,U,"⪺","\\succnapprox",!0);f(m,x,U,"≆","\\ncong",!0);f(m,x,U,"","\\@nshortparallel");f(m,x,U,"∦","\\nparallel",!0);f(m,x,U,"⊯","\\nVDash",!0);f(m,x,U,"⋫","\\ntriangleright");f(m,x,U,"⋭","\\ntrianglerighteq",!0);f(m,x,U,"","\\@nsupseteqq");f(m,x,U,"⊋","\\supsetneq",!0);f(m,x,U,"","\\@varsupsetneq");f(m,x,U,"⫌","\\supsetneqq",!0);f(m,x,U,"","\\@varsupsetneqq");f(m,x,U,"⊮","\\nVdash",!0);f(m,x,U,"⪵","\\precneqq",!0);f(m,x,U,"⪶","\\succneqq",!0);f(m,x,U,"","\\@nsubseteqq");f(m,x,ne,"⊴","\\unlhd");f(m,x,ne,"⊵","\\unrhd");f(m,x,U,"↚","\\nleftarrow",!0);f(m,x,U,"↛","\\nrightarrow",!0);f(m,x,U,"⇍","\\nLeftarrow",!0);f(m,x,U,"⇏","\\nRightarrow",!0);f(m,x,U,"↮","\\nleftrightarrow",!0);f(m,x,U,"⇎","\\nLeftrightarrow",!0);f(m,x,U,"△","\\vartriangle");f(m,x,I,"ℏ","\\hslash");f(m,x,I,"▽","\\triangledown");f(m,x,I,"◊","\\lozenge");f(m,x,I,"Ⓢ","\\circledS");f(m,x,I,"®","\\circledR");f(z,x,I,"®","\\circledR");f(m,x,I,"∡","\\measuredangle",!0);f(m,x,I,"∄","\\nexists");f(m,x,I,"℧","\\mho");f(m,x,I,"Ⅎ","\\Finv",!0);f(m,x,I,"⅁","\\Game",!0);f(m,x,I,"‵","\\backprime");f(m,x,I,"▲","\\blacktriangle");f(m,x,I,"▼","\\blacktriangledown");f(m,x,I,"■","\\blacksquare");f(m,x,I,"⧫","\\blacklozenge");f(m,x,I,"★","\\bigstar");f(m,x,I,"∢","\\sphericalangle",!0);f(m,x,I,"∁","\\complement",!0);f(m,x,I,"ð","\\eth",!0);f(z,y,I,"ð","ð");f(m,x,I,"╱","\\diagup");f(m,x,I,"╲","\\diagdown");f(m,x,I,"□","\\square");f(m,x,I,"□","\\Box");f(m,x,I,"◊","\\Diamond");f(m,x,I,"¥","\\yen",!0);f(z,x,I,"¥","\\yen",!0);f(m,x,I,"✓","\\checkmark",!0);f(z,x,I,"✓","\\checkmark");f(m,x,I,"ℶ","\\beth",!0);f(m,x,I,"ℸ","\\daleth",!0);f(m,x,I,"ℷ","\\gimel",!0);f(m,x,I,"ϝ","\\digamma",!0);f(m,x,I,"ϰ","\\varkappa");f(m,x,An,"┌","\\@ulcorner",!0);f(m,x,Kt,"┐","\\@urcorner",!0);f(m,x,An,"└","\\@llcorner",!0);f(m,x,Kt,"┘","\\@lrcorner",!0);f(m,x,U,"≦","\\leqq",!0);f(m,x,U,"⩽","\\leqslant",!0);f(m,x,U,"⪕","\\eqslantless",!0);f(m,x,U,"≲","\\lesssim",!0);f(m,x,U,"⪅","\\lessapprox",!0);f(m,x,U,"≊","\\approxeq",!0);f(m,x,ne,"⋖","\\lessdot");f(m,x,U,"⋘","\\lll",!0);f(m,x,U,"≶","\\lessgtr",!0);f(m,x,U,"⋚","\\lesseqgtr",!0);f(m,x,U,"⪋","\\lesseqqgtr",!0);f(m,x,U,"≑","\\doteqdot");f(m,x,U,"≓","\\risingdotseq",!0);f(m,x,U,"≒","\\fallingdotseq",!0);f(m,x,U,"∽","\\backsim",!0);f(m,x,U,"⋍","\\backsimeq",!0);f(m,x,U,"⫅","\\subseteqq",!0);f(m,x,U,"⋐","\\Subset",!0);f(m,x,U,"⊏","\\sqsubset",!0);f(m,x,U,"≼","\\preccurlyeq",!0);f(m,x,U,"⋞","\\curlyeqprec",!0);f(m,x,U,"≾","\\precsim",!0);f(m,x,U,"⪷","\\precapprox",!0);f(m,x,U,"⊲","\\vartriangleleft");f(m,x,U,"⊴","\\trianglelefteq");f(m,x,U,"⊨","\\vDash",!0);f(m,x,U,"⊪","\\Vvdash",!0);f(m,x,U,"⌣","\\smallsmile");f(m,x,U,"⌢","\\smallfrown");f(m,x,U,"≏","\\bumpeq",!0);f(m,x,U,"≎","\\Bumpeq",!0);f(m,x,U,"≧","\\geqq",!0);f(m,x,U,"⩾","\\geqslant",!0);f(m,x,U,"⪖","\\eqslantgtr",!0);f(m,x,U,"≳","\\gtrsim",!0);f(m,x,U,"⪆","\\gtrapprox",!0);f(m,x,ne,"⋗","\\gtrdot");f(m,x,U,"⋙","\\ggg",!0);f(m,x,U,"≷","\\gtrless",!0);f(m,x,U,"⋛","\\gtreqless",!0);f(m,x,U,"⪌","\\gtreqqless",!0);f(m,x,U,"≖","\\eqcirc",!0);f(m,x,U,"≗","\\circeq",!0);f(m,x,U,"≜","\\triangleq",!0);f(m,x,U,"∼","\\thicksim");f(m,x,U,"≈","\\thickapprox");f(m,x,U,"⫆","\\supseteqq",!0);f(m,x,U,"⋑","\\Supset",!0);f(m,x,U,"⊐","\\sqsupset",!0);f(m,x,U,"≽","\\succcurlyeq",!0);f(m,x,U,"⋟","\\curlyeqsucc",!0);f(m,x,U,"≿","\\succsim",!0);f(m,x,U,"⪸","\\succapprox",!0);f(m,x,U,"⊳","\\vartriangleright");f(m,x,U,"⊵","\\trianglerighteq");f(m,x,U,"⊩","\\Vdash",!0);f(m,x,U,"∣","\\shortmid");f(m,x,U,"∥","\\shortparallel");f(m,x,U,"≬","\\between",!0);f(m,x,U,"⋔","\\pitchfork",!0);f(m,x,U,"∝","\\varpropto");f(m,x,U,"◀","\\blacktriangleleft");f(m,x,U,"∴","\\therefore",!0);f(m,x,U,"∍","\\backepsilon");f(m,x,U,"▶","\\blacktriangleright");f(m,x,U,"∵","\\because",!0);f(m,x,U,"⋘","\\llless");f(m,x,U,"⋙","\\gggtr");f(m,x,ne,"⊲","\\lhd");f(m,x,ne,"⊳","\\rhd");f(m,x,U,"≂","\\eqsim",!0);f(m,y,U,"⋈","\\Join");f(m,x,U,"≑","\\Doteq",!0);f(m,x,ne,"∔","\\dotplus",!0);f(m,x,ne,"∖","\\smallsetminus");f(m,x,ne,"⋒","\\Cap",!0);f(m,x,ne,"⋓","\\Cup",!0);f(m,x,ne,"⩞","\\doublebarwedge",!0);f(m,x,ne,"⊟","\\boxminus",!0);f(m,x,ne,"⊞","\\boxplus",!0);f(m,x,ne,"⋇","\\divideontimes",!0);f(m,x,ne,"⋉","\\ltimes",!0);f(m,x,ne,"⋊","\\rtimes",!0);f(m,x,ne,"⋋","\\leftthreetimes",!0);f(m,x,ne,"⋌","\\rightthreetimes",!0);f(m,x,ne,"⋏","\\curlywedge",!0);f(m,x,ne,"⋎","\\curlyvee",!0);f(m,x,ne,"⊝","\\circleddash",!0);f(m,x,ne,"⊛","\\circledast",!0);f(m,x,ne,"⋅","\\centerdot");f(m,x,ne,"⊺","\\intercal",!0);f(m,x,ne,"⋒","\\doublecap");f(m,x,ne,"⋓","\\doublecup");f(m,x,ne,"⊠","\\boxtimes",!0);f(m,x,U,"⇢","\\dashrightarrow",!0);f(m,x,U,"⇠","\\dashleftarrow",!0);f(m,x,U,"⇇","\\leftleftarrows",!0);f(m,x,U,"⇆","\\leftrightarrows",!0);f(m,x,U,"⇚","\\Lleftarrow",!0);f(m,x,U,"↞","\\twoheadleftarrow",!0);f(m,x,U,"↢","\\leftarrowtail",!0);f(m,x,U,"↫","\\looparrowleft",!0);f(m,x,U,"⇋","\\leftrightharpoons",!0);f(m,x,U,"↶","\\curvearrowleft",!0);f(m,x,U,"↺","\\circlearrowleft",!0);f(m,x,U,"↰","\\Lsh",!0);f(m,x,U,"⇈","\\upuparrows",!0);f(m,x,U,"↿","\\upharpoonleft",!0);f(m,x,U,"⇃","\\downharpoonleft",!0);f(m,y,U,"⊶","\\origof",!0);f(m,y,U,"⊷","\\imageof",!0);f(m,x,U,"⊸","\\multimap",!0);f(m,x,U,"↭","\\leftrightsquigarrow",!0);f(m,x,U,"⇉","\\rightrightarrows",!0);f(m,x,U,"⇄","\\rightleftarrows",!0);f(m,x,U,"↠","\\twoheadrightarrow",!0);f(m,x,U,"↣","\\rightarrowtail",!0);f(m,x,U,"↬","\\looparrowright",!0);f(m,x,U,"↷","\\curvearrowright",!0);f(m,x,U,"↻","\\circlearrowright",!0);f(m,x,U,"↱","\\Rsh",!0);f(m,x,U,"⇊","\\downdownarrows",!0);f(m,x,U,"↾","\\upharpoonright",!0);f(m,x,U,"⇂","\\downharpoonright",!0);f(m,x,U,"⇝","\\rightsquigarrow",!0);f(m,x,U,"⇝","\\leadsto");f(m,x,U,"⇛","\\Rrightarrow",!0);f(m,x,U,"↾","\\restriction");f(m,y,I,"‘","`");f(m,y,I,"$","\\$");f(z,y,I,"$","\\$");f(z,y,I,"$","\\textdollar");f(m,y,I,"%","\\%");f(z,y,I,"%","\\%");f(m,y,I,"_","\\_");f(z,y,I,"_","\\_");f(z,y,I,"_","\\textunderscore");f(m,y,I,"∠","\\angle",!0);f(m,y,I,"∞","\\infty",!0);f(m,y,I,"′","\\prime");f(m,y,I,"△","\\triangle");f(m,y,I,"Γ","\\Gamma",!0);f(m,y,I,"Δ","\\Delta",!0);f(m,y,I,"Θ","\\Theta",!0);f(m,y,I,"Λ","\\Lambda",!0);f(m,y,I,"Ξ","\\Xi",!0);f(m,y,I,"Π","\\Pi",!0);f(m,y,I,"Σ","\\Sigma",!0);f(m,y,I,"Υ","\\Upsilon",!0);f(m,y,I,"Φ","\\Phi",!0);f(m,y,I,"Ψ","\\Psi",!0);f(m,y,I,"Ω","\\Omega",!0);f(m,y,I,"A","Α");f(m,y,I,"B","Β");f(m,y,I,"E","Ε");f(m,y,I,"Z","Ζ");f(m,y,I,"H","Η");f(m,y,I,"I","Ι");f(m,y,I,"K","Κ");f(m,y,I,"M","Μ");f(m,y,I,"N","Ν");f(m,y,I,"O","Ο");f(m,y,I,"P","Ρ");f(m,y,I,"T","Τ");f(m,y,I,"X","Χ");f(m,y,I,"¬","\\neg",!0);f(m,y,I,"¬","\\lnot");f(m,y,I,"⊤","\\top");f(m,y,I,"⊥","\\bot");f(m,y,I,"∅","\\emptyset");f(m,x,I,"∅","\\varnothing");f(m,y,le,"α","\\alpha",!0);f(m,y,le,"β","\\beta",!0);f(m,y,le,"γ","\\gamma",!0);f(m,y,le,"δ","\\delta",!0);f(m,y,le,"ϵ","\\epsilon",!0);f(m,y,le,"ζ","\\zeta",!0);f(m,y,le,"η","\\eta",!0);f(m,y,le,"θ","\\theta",!0);f(m,y,le,"ι","\\iota",!0);f(m,y,le,"κ","\\kappa",!0);f(m,y,le,"λ","\\lambda",!0);f(m,y,le,"μ","\\mu",!0);f(m,y,le,"ν","\\nu",!0);f(m,y,le,"ξ","\\xi",!0);f(m,y,le,"ο","\\omicron",!0);f(m,y,le,"π","\\pi",!0);f(m,y,le,"ρ","\\rho",!0);f(m,y,le,"σ","\\sigma",!0);f(m,y,le,"τ","\\tau",!0);f(m,y,le,"υ","\\upsilon",!0);f(m,y,le,"ϕ","\\phi",!0);f(m,y,le,"χ","\\chi",!0);f(m,y,le,"ψ","\\psi",!0);f(m,y,le,"ω","\\omega",!0);f(m,y,le,"ε","\\varepsilon",!0);f(m,y,le,"ϑ","\\vartheta",!0);f(m,y,le,"ϖ","\\varpi",!0);f(m,y,le,"ϱ","\\varrho",!0);f(m,y,le,"ς","\\varsigma",!0);f(m,y,le,"φ","\\varphi",!0);f(m,y,ne,"∗","*",!0);f(m,y,ne,"+","+");f(m,y,ne,"−","-",!0);f(m,y,ne,"⋅","\\cdot",!0);f(m,y,ne,"∘","\\circ",!0);f(m,y,ne,"÷","\\div",!0);f(m,y,ne,"±","\\pm",!0);f(m,y,ne,"×","\\times",!0);f(m,y,ne,"∩","\\cap",!0);f(m,y,ne,"∪","\\cup",!0);f(m,y,ne,"∖","\\setminus",!0);f(m,y,ne,"∧","\\land");f(m,y,ne,"∨","\\lor");f(m,y,ne,"∧","\\wedge",!0);f(m,y,ne,"∨","\\vee",!0);f(m,y,I,"√","\\surd");f(m,y,An,"⟨","\\langle",!0);f(m,y,An,"∣","\\lvert");f(m,y,An,"∥","\\lVert");f(m,y,Kt,"?","?");f(m,y,Kt,"!","!");f(m,y,Kt,"⟩","\\rangle",!0);f(m,y,Kt,"∣","\\rvert");f(m,y,Kt,"∥","\\rVert");f(m,y,U,"=","=");f(m,y,U,":",":");f(m,y,U,"≈","\\approx",!0);f(m,y,U,"≅","\\cong",!0);f(m,y,U,"≥","\\ge");f(m,y,U,"≥","\\geq",!0);f(m,y,U,"←","\\gets");f(m,y,U,">","\\gt",!0);f(m,y,U,"∈","\\in",!0);f(m,y,U,"","\\@not");f(m,y,U,"⊂","\\subset",!0);f(m,y,U,"⊃","\\supset",!0);f(m,y,U,"⊆","\\subseteq",!0);f(m,y,U,"⊇","\\supseteq",!0);f(m,x,U,"⊈","\\nsubseteq",!0);f(m,x,U,"⊉","\\nsupseteq",!0);f(m,y,U,"⊨","\\models");f(m,y,U,"←","\\leftarrow",!0);f(m,y,U,"≤","\\le");f(m,y,U,"≤","\\leq",!0);f(m,y,U,"<","\\lt",!0);f(m,y,U,"→","\\rightarrow",!0);f(m,y,U,"→","\\to");f(m,x,U,"≱","\\ngeq",!0);f(m,x,U,"≰","\\nleq",!0);f(m,y,kr," ","\\ ");f(m,y,kr," ","\\space");f(m,y,kr," ","\\nobreakspace");f(z,y,kr," ","\\ ");f(z,y,kr," "," ");f(z,y,kr," ","\\space");f(z,y,kr," ","\\nobreakspace");f(m,y,kr,null,"\\nobreak");f(m,y,kr,null,"\\allowbreak");f(m,y,nc,",",",");f(m,y,nc,";",";");f(m,x,ne,"⊼","\\barwedge",!0);f(m,x,ne,"⊻","\\veebar",!0);f(m,y,ne,"⊙","\\odot",!0);f(m,y,ne,"⊕","\\oplus",!0);f(m,y,ne,"⊗","\\otimes",!0);f(m,y,I,"∂","\\partial",!0);f(m,y,ne,"⊘","\\oslash",!0);f(m,x,ne,"⊚","\\circledcirc",!0);f(m,x,ne,"⊡","\\boxdot",!0);f(m,y,ne,"△","\\bigtriangleup");f(m,y,ne,"▽","\\bigtriangledown");f(m,y,ne,"†","\\dagger");f(m,y,ne,"⋄","\\diamond");f(m,y,ne,"⋆","\\star");f(m,y,ne,"◃","\\triangleleft");f(m,y,ne,"▹","\\triangleright");f(m,y,An,"{","\\{");f(z,y,I,"{","\\{");f(z,y,I,"{","\\textbraceleft");f(m,y,Kt,"}","\\}");f(z,y,I,"}","\\}");f(z,y,I,"}","\\textbraceright");f(m,y,An,"{","\\lbrace");f(m,y,Kt,"}","\\rbrace");f(m,y,An,"[","\\lbrack",!0);f(z,y,I,"[","\\lbrack",!0);f(m,y,Kt,"]","\\rbrack",!0);f(z,y,I,"]","\\rbrack",!0);f(m,y,An,"(","\\lparen",!0);f(m,y,Kt,")","\\rparen",!0);f(z,y,I,"<","\\textless",!0);f(z,y,I,">","\\textgreater",!0);f(m,y,An,"⌊","\\lfloor",!0);f(m,y,Kt,"⌋","\\rfloor",!0);f(m,y,An,"⌈","\\lceil",!0);f(m,y,Kt,"⌉","\\rceil",!0);f(m,y,I,"\\","\\backslash");f(m,y,I,"∣","|");f(m,y,I,"∣","\\vert");f(z,y,I,"|","\\textbar",!0);f(m,y,I,"∥","\\|");f(m,y,I,"∥","\\Vert");f(z,y,I,"∥","\\textbardbl");f(z,y,I,"~","\\textasciitilde");f(z,y,I,"\\","\\textbackslash");f(z,y,I,"^","\\textasciicircum");f(m,y,U,"↑","\\uparrow",!0);f(m,y,U,"⇑","\\Uparrow",!0);f(m,y,U,"↓","\\downarrow",!0);f(m,y,U,"⇓","\\Downarrow",!0);f(m,y,U,"↕","\\updownarrow",!0);f(m,y,U,"⇕","\\Updownarrow",!0);f(m,y,ht,"∐","\\coprod");f(m,y,ht,"⋁","\\bigvee");f(m,y,ht,"⋀","\\bigwedge");f(m,y,ht,"⨄","\\biguplus");f(m,y,ht,"⋂","\\bigcap");f(m,y,ht,"⋃","\\bigcup");f(m,y,ht,"∫","\\int");f(m,y,ht,"∫","\\intop");f(m,y,ht,"∬","\\iint");f(m,y,ht,"∭","\\iiint");f(m,y,ht,"∏","\\prod");f(m,y,ht,"∑","\\sum");f(m,y,ht,"⨂","\\bigotimes");f(m,y,ht,"⨁","\\bigoplus");f(m,y,ht,"⨀","\\bigodot");f(m,y,ht,"∮","\\oint");f(m,y,ht,"∯","\\oiint");f(m,y,ht,"∰","\\oiiint");f(m,y,ht,"⨆","\\bigsqcup");f(m,y,ht,"∫","\\smallint");f(z,y,fs,"…","\\textellipsis");f(m,y,fs,"…","\\mathellipsis");f(z,y,fs,"…","\\ldots",!0);f(m,y,fs,"…","\\ldots",!0);f(m,y,fs,"⋯","\\@cdots",!0);f(m,y,fs,"⋱","\\ddots",!0);f(m,y,I,"⋮","\\varvdots");f(m,y,ze,"ˊ","\\acute");f(m,y,ze,"ˋ","\\grave");f(m,y,ze,"¨","\\ddot");f(m,y,ze,"~","\\tilde");f(m,y,ze,"ˉ","\\bar");f(m,y,ze,"˘","\\breve");f(m,y,ze,"ˇ","\\check");f(m,y,ze,"^","\\hat");f(m,y,ze,"⃗","\\vec");f(m,y,ze,"˙","\\dot");f(m,y,ze,"˚","\\mathring");f(m,y,le,"","\\@imath");f(m,y,le,"","\\@jmath");f(m,y,I,"ı","ı");f(m,y,I,"ȷ","ȷ");f(z,y,I,"ı","\\i",!0);f(z,y,I,"ȷ","\\j",!0);f(z,y,I,"ß","\\ss",!0);f(z,y,I,"æ","\\ae",!0);f(z,y,I,"œ","\\oe",!0);f(z,y,I,"ø","\\o",!0);f(z,y,I,"Æ","\\AE",!0);f(z,y,I,"Œ","\\OE",!0);f(z,y,I,"Ø","\\O",!0);f(z,y,ze,"ˊ","\\'");f(z,y,ze,"ˋ","\\`");f(z,y,ze,"ˆ","\\^");f(z,y,ze,"˜","\\~");f(z,y,ze,"ˉ","\\=");f(z,y,ze,"˘","\\u");f(z,y,ze,"˙","\\.");f(z,y,ze,"¸","\\c");f(z,y,ze,"˚","\\r");f(z,y,ze,"ˇ","\\v");f(z,y,ze,"¨",'\\"');f(z,y,ze,"˝","\\H");f(z,y,ze,"◯","\\textcircled");var Fv={"--":!0,"---":!0,"``":!0,"''":!0};f(z,y,I,"–","--",!0);f(z,y,I,"–","\\textendash");f(z,y,I,"—","---",!0);f(z,y,I,"—","\\textemdash");f(z,y,I,"‘","`",!0);f(z,y,I,"‘","\\textquoteleft");f(z,y,I,"’","'",!0);f(z,y,I,"’","\\textquoteright");f(z,y,I,"“","``",!0);f(z,y,I,"“","\\textquotedblleft");f(z,y,I,"”","''",!0);f(z,y,I,"”","\\textquotedblright");f(m,y,I,"°","\\degree",!0);f(z,y,I,"°","\\degree");f(z,y,I,"°","\\textdegree",!0);f(m,y,I,"£","\\pounds");f(m,y,I,"£","\\mathsterling",!0);f(z,y,I,"£","\\pounds");f(z,y,I,"£","\\textsterling",!0);f(m,x,I,"✠","\\maltese");f(z,x,I,"✠","\\maltese");var Xf='0123456789/@."';for(var ol=0;ol<Xf.length;ol++){var Jf=Xf.charAt(ol);f(m,y,I,Jf,Jf)}var Yf='0123456789!@*()-=+";:?/.,';for(var cl=0;cl<Yf.length;cl++){var Zf=Yf.charAt(cl);f(z,y,I,Zf,Zf)}var vo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(var ll=0;ll<vo.length;ll++){var iA=vo.charAt(ll);f(m,y,le,iA,iA),f(z,y,I,iA,iA)}f(m,x,I,"C","ℂ");f(z,x,I,"C","ℂ");f(m,x,I,"H","ℍ");f(z,x,I,"H","ℍ");f(m,x,I,"N","ℕ");f(z,x,I,"N","ℕ");f(m,x,I,"P","ℙ");f(z,x,I,"P","ℙ");f(m,x,I,"Q","ℚ");f(z,x,I,"Q","ℚ");f(m,x,I,"R","ℝ");f(z,x,I,"R","ℝ");f(m,x,I,"Z","ℤ");f(z,x,I,"Z","ℤ");f(m,y,le,"h","ℎ");f(z,y,le,"h","ℎ");var he="";for(var Rt=0;Rt<vo.length;Rt++){var et=vo.charAt(Rt);he=String.fromCharCode(55349,56320+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56372+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56424+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56580+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56684+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56736+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56788+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56840+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56944+Rt),f(m,y,le,et,he),f(z,y,I,et,he),Rt<26&&(he=String.fromCharCode(55349,56632+Rt),f(m,y,le,et,he),f(z,y,I,et,he),he=String.fromCharCode(55349,56476+Rt),f(m,y,le,et,he),f(z,y,I,et,he))}he="𝕜";f(m,y,le,"k",he);f(z,y,I,"k",he);for(var ni=0;ni<10;ni++){var Ur=ni.toString();he=String.fromCharCode(55349,57294+ni),f(m,y,le,Ur,he),f(z,y,I,Ur,he),he=String.fromCharCode(55349,57314+ni),f(m,y,le,Ur,he),f(z,y,I,Ur,he),he=String.fromCharCode(55349,57324+ni),f(m,y,le,Ur,he),f(z,y,I,Ur,he),he=String.fromCharCode(55349,57334+ni),f(m,y,le,Ur,he),f(z,y,I,Ur,he)}var _d="ÐÞþ";for(var dl=0;dl<_d.length;dl++){var sA=_d.charAt(dl);f(m,y,le,sA,sA),f(z,y,I,sA,sA)}var aA=[["mathbf","textbf","Main-Bold"],["mathbf","textbf","Main-Bold"],["mathnormal","textit","Math-Italic"],["mathnormal","textit","Math-Italic"],["boldsymbol","boldsymbol","Main-BoldItalic"],["boldsymbol","boldsymbol","Main-BoldItalic"],["mathscr","textscr","Script-Regular"],["","",""],["","",""],["","",""],["mathfrak","textfrak","Fraktur-Regular"],["mathfrak","textfrak","Fraktur-Regular"],["mathbb","textbb","AMS-Regular"],["mathbb","textbb","AMS-Regular"],["mathboldfrak","textboldfrak","Fraktur-Regular"],["mathboldfrak","textboldfrak","Fraktur-Regular"],["mathsf","textsf","SansSerif-Regular"],["mathsf","textsf","SansSerif-Regular"],["mathboldsf","textboldsf","SansSerif-Bold"],["mathboldsf","textboldsf","SansSerif-Bold"],["mathitsf","textitsf","SansSerif-Italic"],["mathitsf","textitsf","SansSerif-Italic"],["","",""],["","",""],["mathtt","texttt","Typewriter-Regular"],["mathtt","texttt","Typewriter-Regular"]],ep=[["mathbf","textbf","Main-Bold"],["","",""],["mathsf","textsf","SansSerif-Regular"],["mathboldsf","textboldsf","SansSerif-Bold"],["mathtt","texttt","Typewriter-Regular"]],X7=function(e,t){var n=e.charCodeAt(0),i=e.charCodeAt(1),s=(n-55296)*1024+(i-56320)+65536,a=t==="math"?0:1;if(119808<=s&&s<120484){var A=Math.floor((s-119808)/26);return[aA[A][2],aA[A][a]]}else if(120782<=s&&s<=120831){var o=Math.floor((s-120782)/10);return[ep[o][2],ep[o][a]]}else{if(s===120485||s===120486)return[aA[0][2],aA[0][a]];if(120486<s&&s<120782)return["",""];throw new W("Unsupported character: "+e)}},rc=function(e,t,n){return Ve[n][e]&&Ve[n][e].replace&&(e=Ve[n][e].replace),{value:e,metrics:Du(e,t,n)}},kn=function(e,t,n,i,s){var a=rc(e,t,n),A=a.metrics;e=a.value;var o;if(A){var c=A.italic;(n==="text"||i&&i.font==="mathit")&&(c=0),o=new vn(e,A.height,A.depth,c,A.skew,A.width,s)}else typeof console<"u",o=new vn(e,0,0,0,0,0,s);if(i){o.maxFontSize=i.sizeMultiplier,i.style.isTight()&&o.classes.push("mtight");var l=i.getColor();l&&(o.style.color=l)}return o},J7=function(e,t,n,i){return i===void 0&&(i=[]),n.font==="boldsymbol"&&rc(e,"Main-Bold",t).metrics?kn(e,"Main-Bold",t,n,i.concat(["mathbf"])):e==="\\"||Ve[t][e].font==="main"?kn(e,"Main-Regular",t,n,i):kn(e,"AMS-Regular",t,n,i.concat(["amsrm"]))},Y7=function(e,t,n,i,s){return s!=="textord"&&rc(e,"Math-BoldItalic",t).metrics?{fontName:"Math-BoldItalic",fontClass:"boldsymbol"}:{fontName:"Main-Bold",fontClass:"mathbf"}},Z7=function(e,t,n){var i=e.mode,s=e.text,a=["mord"],A=i==="math"||i==="text"&&t.font,o=A?t.font:t.fontFamily,c="",l="";if(s.charCodeAt(0)===55349&&([c,l]=X7(s,i)),c.length>0)return kn(s,c,i,t,a.concat(l));if(o){var d,u;if(o==="boldsymbol"){var h=Y7(s,i,t,a,n);d=h.fontName,u=[h.fontClass]}else A?(d=Mv[o].fontName,u=[o]):(d=AA(o,t.fontWeight,t.fontShape),u=[o,t.fontWeight,t.fontShape]);if(rc(s,d,i).metrics)return kn(s,d,i,t,a.concat(u));if(Fv.hasOwnProperty(s)&&d.slice(0,10)==="Typewriter"){for(var p=[],g=0;g<s.length;g++)p.push(kn(s[g],d,i,t,a.concat(u)));return Qv(p)}}if(n==="mathord")return kn(s,"Math-Italic",i,t,a.concat(["mathnormal"]));if(n==="textord"){var v=Ve[i][s]&&Ve[i][s].font;if(v==="ams"){var w=AA("amsrm",t.fontWeight,t.fontShape);return kn(s,w,i,t,a.concat("amsrm",t.fontWeight,t.fontShape))}else if(v==="main"||!v){var B=AA("textrm",t.fontWeight,t.fontShape);return kn(s,B,i,t,a.concat(t.fontWeight,t.fontShape))}else{var E=AA(v,t.fontWeight,t.fontShape);return kn(s,E,i,t,a.concat(E,t.fontWeight,t.fontShape))}}else throw new Error("unexpected type: "+n+" in makeOrd")},e8=(r,e)=>{if($r(r.classes)!==$r(e.classes)||r.skew!==e.skew||r.maxFontSize!==e.maxFontSize)return!1;if(r.classes.length===1){var t=r.classes[0];if(t==="mbin"||t==="mord")return!1}for(var n in r.style)if(r.style.hasOwnProperty(n)&&r.style[n]!==e.style[n])return!1;for(var i in e.style)if(e.style.hasOwnProperty(i)&&r.style[i]!==e.style[i])return!1;return!0},t8=r=>{for(var e=0;e<r.length-1;e++){var t=r[e],n=r[e+1];t instanceof vn&&n instanceof vn&&e8(t,n)&&(t.text+=n.text,t.height=Math.max(t.height,n.height),t.depth=Math.max(t.depth,n.depth),t.italic=n.italic,r.splice(e+1,1),e--)}return r},Ou=function(e){for(var t=0,n=0,i=0,s=0;s<e.children.length;s++){var a=e.children[s];a.height>t&&(t=a.height),a.depth>n&&(n=a.depth),a.maxFontSize>i&&(i=a.maxFontSize)}e.height=t,e.depth=n,e.maxFontSize=i},zt=function(e,t,n,i){var s=new Ua(e,t,n,i);return Ou(s),s},Iv=(r,e,t,n)=>new Ua(r,e,t,n),n8=function(e,t,n){var i=zt([e],[],t);return i.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),i.style.borderBottomWidth=j(i.height),i.maxFontSize=1,i},r8=function(e,t,n,i){var s=new Lu(e,t,n,i);return Ou(s),s},Qv=function(e){var t=new Ea(e);return Ou(t),t},i8=function(e,t){return e instanceof Ea?zt([],[e],t):e},s8=function(e){if(e.positionType==="individualShift"){for(var t=e.children,n=[t[0]],i=-t[0].shift-t[0].elem.depth,s=i,a=1;a<t.length;a++){var A=-t[a].shift-s-t[a].elem.depth,o=A-(t[a-1].elem.height+t[a-1].elem.depth);s=s+A,n.push({type:"kern",size:o}),n.push(t[a])}return{children:n,depth:i}}var c;if(e.positionType==="top"){for(var l=e.positionData,d=0;d<e.children.length;d++){var u=e.children[d];l-=u.type==="kern"?u.size:u.elem.height+u.elem.depth}c=l}else if(e.positionType==="bottom")c=-e.positionData;else{var h=e.children[0];if(h.type!=="elem")throw new Error('First child must have type "elem".');if(e.positionType==="shift")c=-h.elem.depth-e.positionData;else if(e.positionType==="firstBaseline")c=-h.elem.depth;else throw new Error("Invalid positionType "+e.positionType+".")}return{children:e.children,depth:c}},a8=function(e,t){for(var{children:n,depth:i}=s8(e),s=0,a=0;a<n.length;a++){var A=n[a];if(A.type==="elem"){var o=A.elem;s=Math.max(s,o.maxFontSize,o.height)}}s+=2;var c=zt(["pstrut"],[]);c.style.height=j(s);for(var l=[],d=i,u=i,h=i,p=0;p<n.length;p++){var g=n[p];if(g.type==="kern")h+=g.size;else{var v=g.elem,w=g.wrapperClasses||[],B=g.wrapperStyle||{},E=zt(w,[c,v],void 0,B);E.style.top=j(-s-h-v.depth),g.marginLeft&&(E.style.marginLeft=g.marginLeft),g.marginRight&&(E.style.marginRight=g.marginRight),l.push(E),h+=v.height+v.depth}d=Math.min(d,h),u=Math.max(u,h)}var b=zt(["vlist"],l);b.style.height=j(u);var C;if(d<0){var T=zt([],[]),F=zt(["vlist"],[T]);F.style.height=j(-d);var R=zt(["vlist-s"],[new vn("")]);C=[zt(["vlist-r"],[b,R]),zt(["vlist-r"],[F])]}else C=[zt(["vlist-r"],[b])];var M=zt(["vlist-t"],C);return C.length===2&&M.classes.push("vlist-t2"),M.height=u,M.depth=-d,M},A8=(r,e)=>{var t=zt(["mspace"],[],e),n=Ze(r,e);return t.style.marginRight=j(n),t},AA=function(e,t,n){var i="";switch(e){case"amsrm":i="AMS";break;case"textrm":i="Main";break;case"textsf":i="SansSerif";break;case"texttt":i="Typewriter";break;default:i=e}var s;return t==="textbf"&&n==="textit"?s="BoldItalic":t==="textbf"?s="Bold":t==="textit"?s="Italic":s="Regular",i+"-"+s},Mv={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},_v={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},o8=function(e,t){var[n,i,s]=_v[e],a=new jr(n),A=new br([a],{width:j(i),height:j(s),style:"width:"+j(i),viewBox:"0 0 "+1e3*i+" "+1e3*s,preserveAspectRatio:"xMinYMin"}),o=Iv(["overlay"],[A],t);return o.height=s,o.style.height=j(s),o.style.width=j(i),o},P={fontMap:Mv,makeSymbol:kn,mathsym:J7,makeSpan:zt,makeSvgSpan:Iv,makeLineSpan:n8,makeAnchor:r8,makeFragment:Qv,wrapFragment:i8,makeVList:a8,makeOrd:Z7,makeGlue:A8,staticSvg:o8,svgData:_v,tryCombineChars:t8},je={number:3,unit:"mu"},ri={number:4,unit:"mu"},Ar={number:5,unit:"mu"},c8={mord:{mop:je,mbin:ri,mrel:Ar,minner:je},mop:{mord:je,mop:je,mrel:Ar,minner:je},mbin:{mord:ri,mop:ri,mopen:ri,minner:ri},mrel:{mord:Ar,mop:Ar,mopen:Ar,minner:Ar},mopen:{},mclose:{mop:je,mbin:ri,mrel:Ar,minner:je},mpunct:{mord:je,mop:je,mrel:Ar,mopen:je,mclose:je,mpunct:je,minner:je},minner:{mord:je,mop:je,mbin:ri,mrel:Ar,mopen:je,mpunct:je,minner:je}},l8={mord:{mop:je},mop:{mord:je,mop:je},mbin:{},mrel:{},mopen:{},mclose:{mop:je},mpunct:{},minner:{mop:je}},Rv={},yo={},wo={};function te(r){for(var{type:e,names:t,props:n,handler:i,htmlBuilder:s,mathmlBuilder:a}=r,A={type:e,numArgs:n.numArgs,argTypes:n.argTypes,allowedInArgument:!!n.allowedInArgument,allowedInText:!!n.allowedInText,allowedInMath:n.allowedInMath===void 0?!0:n.allowedInMath,numOptionalArgs:n.numOptionalArgs||0,infix:!!n.infix,primitive:!!n.primitive,handler:i},o=0;o<t.length;++o)Rv[t[o]]=A;e&&(s&&(yo[e]=s),a&&(wo[e]=a))}function Ei(r){var{type:e,htmlBuilder:t,mathmlBuilder:n}=r;te({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},htmlBuilder:t,mathmlBuilder:n})}var bo=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},At=function(e){return e.type==="ordgroup"?e.body:[e]},Br=P.makeSpan,d8=["leftmost","mbin","mopen","mrel","mop","mpunct"],u8=["rightmost","mrel","mclose","mpunct"],h8={display:de.DISPLAY,text:de.TEXT,script:de.SCRIPT,scriptscript:de.SCRIPTSCRIPT},f8={mord:"mord",mop:"mop",mbin:"mbin",mrel:"mrel",mopen:"mopen",mclose:"mclose",mpunct:"mpunct",minner:"minner"},mt=function(e,t,n,i){i===void 0&&(i=[null,null]);for(var s=[],a=0;a<e.length;a++){var A=xe(e[a],t);if(A instanceof Ea){var o=A.children;s.push(...o)}else s.push(A)}if(P.tryCombineChars(s),!n)return s;var c=t;if(e.length===1){var l=e[0];l.type==="sizing"?c=t.havingSize(l.size):l.type==="styling"&&(c=t.havingStyle(h8[l.style]))}var d=Br([i[0]||"leftmost"],[],t),u=Br([i[1]||"rightmost"],[],t),h=n==="root";return tp(s,(p,g)=>{var v=g.classes[0],w=p.classes[0];v==="mbin"&&ce.contains(u8,w)?g.classes[0]="mord":w==="mbin"&&ce.contains(d8,v)&&(p.classes[0]="mord")},{node:d},u,h),tp(s,(p,g)=>{var v=Rd(g),w=Rd(p),B=v&&w?p.hasClass("mtight")?l8[v][w]:c8[v][w]:null;if(B)return P.makeGlue(B,c)},{node:d},u,h),s},tp=function r(e,t,n,i,s){i&&e.push(i);for(var a=0;a<e.length;a++){var A=e[a],o=Pv(A);if(o){r(o.children,t,n,null,s);continue}var c=!A.hasClass("mspace");if(c){var l=t(A,n.node);l&&(n.insertAfter?n.insertAfter(l):(e.unshift(l),a++))}c?n.node=A:s&&A.hasClass("newline")&&(n.node=Br(["leftmost"])),n.insertAfter=(d=>u=>{e.splice(d+1,0,u),a++})(a)}i&&e.pop()},Pv=function(e){return e instanceof Ea||e instanceof Lu||e instanceof Ua&&e.hasClass("enclosing")?e:null},p8=function r(e,t){var n=Pv(e);if(n){var i=n.children;if(i.length){if(t==="right")return r(i[i.length-1],"right");if(t==="left")return r(i[0],"left")}}return e},Rd=function(e,t){return e?(t&&(e=p8(e,t)),f8[e.classes[0]]||null):null},ka=function(e,t){var n=["nulldelimiter"].concat(e.baseSizingClasses());return Br(t.concat(n))},xe=function(e,t,n){if(!e)return Br();if(yo[e.type]){var i=yo[e.type](e,t);if(n&&t.size!==n.size){i=Br(t.sizingClasses(n),[i],t);var s=t.sizeMultiplier/n.sizeMultiplier;i.height*=s,i.depth*=s}return i}else throw new W("Got group of unknown type: '"+e.type+"'")};function oA(r,e){var t=Br(["base"],r,e),n=Br(["strut"]);return n.style.height=j(t.height+t.depth),t.depth&&(n.style.verticalAlign=j(-t.depth)),t.children.unshift(n),t}function Pd(r,e){var t=null;r.length===1&&r[0].type==="tag"&&(t=r[0].tag,r=r[0].body);var n=mt(r,e,"root"),i;n.length===2&&n[1].hasClass("tag")&&(i=n.pop());for(var s=[],a=[],A=0;A<n.length;A++)if(a.push(n[A]),n[A].hasClass("mbin")||n[A].hasClass("mrel")||n[A].hasClass("allowbreak")){for(var o=!1;A<n.length-1&&n[A+1].hasClass("mspace")&&!n[A+1].hasClass("newline");)A++,a.push(n[A]),n[A].hasClass("nobreak")&&(o=!0);o||(s.push(oA(a,e)),a=[])}else n[A].hasClass("newline")&&(a.pop(),a.length>0&&(s.push(oA(a,e)),a=[]),s.push(n[A]));a.length>0&&s.push(oA(a,e));var c;t?(c=oA(mt(t,e,!0)),c.classes=["tag"],s.push(c)):i&&s.push(i);var l=Br(["katex-html"],s);if(l.setAttribute("aria-hidden","true"),c){var d=c.children[0];d.style.height=j(l.height+l.depth),l.depth&&(d.style.verticalAlign=j(-l.depth))}return l}function Dv(r){return new Ea(r)}class hn{constructor(e,t,n){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=n||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=$r(this.classes));for(var n=0;n<this.children.length;n++)e.appendChild(this.children[n].toNode());return e}toMarkup(){var e="<"+this.type;for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&(e+=" "+t+'="',e+=ce.escape(this.attributes[t]),e+='"');this.classes.length>0&&(e+=' class ="'+ce.escape($r(this.classes))+'"'),e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</"+this.type+">",e}toText(){return this.children.map(e=>e.toText()).join("")}}class ra{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return ce.escape(this.toText())}toText(){return this.text}}class m8{constructor(e){this.width=void 0,this.character=void 0,this.width=e,e>=.05555&&e<=.05556?this.character=" ":e>=.1666&&e<=.1667?this.character=" ":e>=.2222&&e<=.2223?this.character=" ":e>=.2777&&e<=.2778?this.character=" ":e>=-.05556&&e<=-.05555?this.character=" ":e>=-.1667&&e<=-.1666?this.character=" ":e>=-.2223&&e<=-.2222?this.character=" ":e>=-.2778&&e<=-.2777?this.character=" ":this.character=null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",j(this.width)),e}toMarkup(){return this.character?"<mtext>"+this.character+"</mtext>":'<mspace width="'+j(this.width)+'"/>'}toText(){return this.character?this.character:" "}}var q={MathNode:hn,TextNode:ra,SpaceNode:m8,newDocumentFragment:Dv},yn=function(e,t,n){return Ve[t][e]&&Ve[t][e].replace&&e.charCodeAt(0)!==55349&&!(Fv.hasOwnProperty(e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)==="tt"||n.font&&n.font.slice(4,6)==="tt"))&&(e=Ve[t][e].replace),new q.TextNode(e)},Hu=function(e){return e.length===1?e[0]:new q.MathNode("mrow",e)},Nu=function(e,t){if(t.fontFamily==="texttt")return"monospace";if(t.fontFamily==="textsf")return t.fontShape==="textit"&&t.fontWeight==="textbf"?"sans-serif-bold-italic":t.fontShape==="textit"?"sans-serif-italic":t.fontWeight==="textbf"?"bold-sans-serif":"sans-serif";if(t.fontShape==="textit"&&t.fontWeight==="textbf")return"bold-italic";if(t.fontShape==="textit")return"italic";if(t.fontWeight==="textbf")return"bold";var n=t.font;if(!n||n==="mathnormal")return null;var i=e.mode;if(n==="mathit")return"italic";if(n==="boldsymbol")return e.type==="textord"?"bold":"bold-italic";if(n==="mathbf")return"bold";if(n==="mathbb")return"double-struck";if(n==="mathfrak")return"fraktur";if(n==="mathscr"||n==="mathcal")return"script";if(n==="mathsf")return"sans-serif";if(n==="mathtt")return"monospace";var s=e.text;if(ce.contains(["\\imath","\\jmath"],s))return null;Ve[i][s]&&Ve[i][s].replace&&(s=Ve[i][s].replace);var a=P.fontMap[n].fontName;return Du(s,a,i)?P.fontMap[n].variant:null},Zt=function(e,t,n){if(e.length===1){var i=Le(e[0],t);return n&&i instanceof hn&&i.type==="mo"&&(i.setAttribute("lspace","0em"),i.setAttribute("rspace","0em")),[i]}for(var s=[],a,A=0;A<e.length;A++){var o=Le(e[A],t);if(o instanceof hn&&a instanceof hn){if(o.type==="mtext"&&a.type==="mtext"&&o.getAttribute("mathvariant")===a.getAttribute("mathvariant")){a.children.push(...o.children);continue}else if(o.type==="mn"&&a.type==="mn"){a.children.push(...o.children);continue}else if(o.type==="mi"&&o.children.length===1&&a.type==="mn"){var c=o.children[0];if(c instanceof ra&&c.text==="."){a.children.push(...o.children);continue}}else if(a.type==="mi"&&a.children.length===1){var l=a.children[0];if(l instanceof ra&&l.text==="̸"&&(o.type==="mo"||o.type==="mi"||o.type==="mn")){var d=o.children[0];d instanceof ra&&d.text.length>0&&(d.text=d.text.slice(0,1)+"̸"+d.text.slice(1),s.pop())}}}s.push(o),a=o}return s},Xr=function(e,t,n){return Hu(Zt(e,t,n))},Le=function(e,t){if(!e)return new q.MathNode("mrow");if(wo[e.type]){var n=wo[e.type](e,t);return n}else throw new W("Got group of unknown type: '"+e.type+"'")};function np(r,e,t,n,i){var s=Zt(r,t),a;s.length===1&&s[0]instanceof hn&&ce.contains(["mrow","mtable"],s[0].type)?a=s[0]:a=new q.MathNode("mrow",s);var A=new q.MathNode("annotation",[new q.TextNode(e)]);A.setAttribute("encoding","application/x-tex");var o=new q.MathNode("semantics",[a,A]),c=new q.MathNode("math",[o]);c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n&&c.setAttribute("display","block");var l=i?"katex":"katex-mathml";return P.makeSpan([l],[c])}var Lv=function(e){return new hr({style:e.displayMode?de.DISPLAY:de.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},Ov=function(e,t){if(t.displayMode){var n=["katex-display"];t.leqno&&n.push("leqno"),t.fleqn&&n.push("fleqn"),e=P.makeSpan(n,[e])}return e},g8=function(e,t,n){var i=Lv(n),s;if(n.output==="mathml")return np(e,t,i,n.displayMode,!0);if(n.output==="html"){var a=Pd(e,i);s=P.makeSpan(["katex"],[a])}else{var A=np(e,t,i,n.displayMode,!1),o=Pd(e,i);s=P.makeSpan(["katex"],[A,o])}return Ov(s,n)},v8=function(e,t,n){var i=Lv(n),s=Pd(e,i),a=P.makeSpan(["katex"],[s]);return Ov(a,n)},y8={widehat:"^",widecheck:"ˇ",widetilde:"~",utilde:"~",overleftarrow:"←",underleftarrow:"←",xleftarrow:"←",overrightarrow:"→",underrightarrow:"→",xrightarrow:"→",underbrace:"⏟",overbrace:"⏞",overgroup:"⏠",undergroup:"⏡",overleftrightarrow:"↔",underleftrightarrow:"↔",xleftrightarrow:"↔",Overrightarrow:"⇒",xRightarrow:"⇒",overleftharpoon:"↼",xleftharpoonup:"↼",overrightharpoon:"⇀",xrightharpoonup:"⇀",xLeftarrow:"⇐",xLeftrightarrow:"⇔",xhookleftarrow:"↩",xhookrightarrow:"↪",xmapsto:"↦",xrightharpoondown:"⇁",xleftharpoondown:"↽",xrightleftharpoons:"⇌",xleftrightharpoons:"⇋",xtwoheadleftarrow:"↞",xtwoheadrightarrow:"↠",xlongequal:"=",xtofrom:"⇄",xrightleftarrows:"⇄",xrightequilibrium:"⇌",xleftequilibrium:"⇋","\\cdrightarrow":"→","\\cdleftarrow":"←","\\cdlongequal":"="},w8=function(e){var t=new q.MathNode("mo",[new q.TextNode(y8[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},b8={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},B8=function(e){return e.type==="ordgroup"?e.body.length:1},C8=function(e,t){function n(){var A=4e5,o=e.label.slice(1);if(ce.contains(["widehat","widecheck","widetilde","utilde"],o)){var c=e,l=B8(c.base),d,u,h;if(l>5)o==="widehat"||o==="widecheck"?(d=420,A=2364,h=.42,u=o+"4"):(d=312,A=2340,h=.34,u="tilde4");else{var p=[1,1,2,2,3,3][l];o==="widehat"||o==="widecheck"?(A=[0,1062,2364,2364,2364][p],d=[0,239,300,360,420][p],h=[0,.24,.3,.3,.36,.42][p],u=o+p):(A=[0,600,1033,2339,2340][p],d=[0,260,286,306,312][p],h=[0,.26,.286,.3,.306,.34][p],u="tilde"+p)}var g=new jr(u),v=new br([g],{width:"100%",height:j(h),viewBox:"0 0 "+A+" "+d,preserveAspectRatio:"none"});return{span:P.makeSvgSpan([],[v],t),minWidth:0,height:h}}else{var w=[],B=b8[o],[E,b,C]=B,T=C/1e3,F=E.length,R,M;if(F===1){var D=B[3];R=["hide-tail"],M=[D]}else if(F===2)R=["halfarrow-left","halfarrow-right"],M=["xMinYMin","xMaxYMin"];else if(F===3)R=["brace-left","brace-center","brace-right"],M=["xMinYMin","xMidYMin","xMaxYMin"];else throw new Error(`Correct katexImagesData or update code here to support
|
|
367
|
+
`+F+" children.");for(var O=0;O<F;O++){var H=new jr(E[O]),se=new br([H],{width:"400em",height:j(T),viewBox:"0 0 "+A+" "+C,preserveAspectRatio:M[O]+" slice"}),ie=P.makeSvgSpan([R[O]],[se],t);if(F===1)return{span:ie,minWidth:b,height:T};ie.style.height=j(T),w.push(ie)}return{span:P.makeSpan(["stretchy"],w,t),minWidth:b,height:T}}}var{span:i,minWidth:s,height:a}=n();return i.height=a,i.style.height=j(a),s>0&&(i.style.minWidth=j(s)),i},S8=function(e,t,n,i,s){var a,A=e.height+e.depth+n+i;if(/fbox|color|angl/.test(t)){if(a=P.makeSpan(["stretchy",t],[],s),t==="fbox"){var o=s.color&&s.getColor();o&&(a.style.borderColor=o)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new Md({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&c.push(new Md({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var l=new br(c,{width:"100%",height:j(A)});a=P.makeSvgSpan([],[l],s)}return a.height=A,a.style.height=j(A),a},Cr={encloseSpan:S8,mathMLnode:w8,svgSpan:C8};function ye(r,e){if(!r||r.type!==e)throw new Error("Expected node of type "+e+", but got "+(r?"node of type "+r.type:String(r)));return r}function Ku(r){var e=ic(r);if(!e)throw new Error("Expected node of symbol group type, but got "+(r?"node of type "+r.type:String(r)));return e}function ic(r){return r&&(r.type==="atom"||j7.hasOwnProperty(r.type))?r:null}var Vu=(r,e)=>{var t,n,i;r&&r.type==="supsub"?(n=ye(r.base,"accent"),t=n.base,r.base=t,i=W7(xe(r,e)),r.base=n):(n=ye(r,"accent"),t=n.base);var s=xe(t,e.havingCrampedStyle()),a=n.isShifty&&ce.isCharacterBox(t),A=0;if(a){var o=ce.getBaseElem(t),c=xe(o,e.havingCrampedStyle());A=jf(c).skew}var l=n.label==="\\c",d=l?s.height+s.depth:Math.min(s.height,e.fontMetrics().xHeight),u;if(n.isStretchy)u=Cr.svgSpan(n,e),u=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:u,wrapperClasses:["svg-align"],wrapperStyle:A>0?{width:"calc(100% - "+j(2*A)+")",marginLeft:j(2*A)}:void 0}]},e);else{var h,p;n.label==="\\vec"?(h=P.staticSvg("vec",e),p=P.svgData.vec[1]):(h=P.makeOrd({mode:n.mode,text:n.label},e,"textord"),h=jf(h),h.italic=0,p=h.width,l&&(d+=h.depth)),u=P.makeSpan(["accent-body"],[h]);var g=n.label==="\\textcircled";g&&(u.classes.push("accent-full"),d=s.height);var v=A;g||(v-=p/2),u.style.left=j(v),n.label==="\\textcircled"&&(u.style.top=".2em"),u=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-d},{type:"elem",elem:u}]},e)}var w=P.makeSpan(["mord","accent"],[u],e);return i?(i.children[0]=w,i.height=Math.max(w.height,i.height),i.classes[0]="mord",i):w},Hv=(r,e)=>{var t=r.isStretchy?Cr.mathMLnode(r.label):new q.MathNode("mo",[yn(r.label,r.mode)]),n=new q.MathNode("mover",[Le(r.base,e),t]);return n.setAttribute("accent","true"),n},k8=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(r=>"\\"+r).join("|"));te({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(r,e)=>{var t=bo(e[0]),n=!k8.test(r.funcName),i=!n||r.funcName==="\\widehat"||r.funcName==="\\widetilde"||r.funcName==="\\widecheck";return{type:"accent",mode:r.parser.mode,label:r.funcName,isStretchy:n,isShifty:i,base:t}},htmlBuilder:Vu,mathmlBuilder:Hv});te({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(r,e)=>{var t=e[0],n=r.parser.mode;return n==="math"&&(r.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+r.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:r.funcName,isStretchy:!1,isShifty:!0,base:t}},htmlBuilder:Vu,mathmlBuilder:Hv});te({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"accentUnder",mode:t.mode,label:n,base:i}},htmlBuilder:(r,e)=>{var t=xe(r.base,e),n=Cr.svgSpan(r,e),i=r.label==="\\utilde"?.12:0,s=P.makeVList({positionType:"top",positionData:t.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:i},{type:"elem",elem:t}]},e);return P.makeSpan(["mord","accentunder"],[s],e)},mathmlBuilder:(r,e)=>{var t=Cr.mathMLnode(r.label),n=new q.MathNode("munder",[Le(r.base,e),t]);return n.setAttribute("accentunder","true"),n}});var cA=r=>{var e=new q.MathNode("mpadded",r?[r]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};te({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler(r,e,t){var{parser:n,funcName:i}=r;return{type:"xArrow",mode:n.mode,label:i,body:e[0],below:t[0]}},htmlBuilder(r,e){var t=e.style,n=e.havingStyle(t.sup()),i=P.wrapFragment(xe(r.body,n,e),e),s=r.label.slice(0,2)==="\\x"?"x":"cd";i.classes.push(s+"-arrow-pad");var a;r.below&&(n=e.havingStyle(t.sub()),a=P.wrapFragment(xe(r.below,n,e),e),a.classes.push(s+"-arrow-pad"));var A=Cr.svgSpan(r,e),o=-e.fontMetrics().axisHeight+.5*A.height,c=-e.fontMetrics().axisHeight-.5*A.height-.111;(i.depth>.25||r.label==="\\xleftequilibrium")&&(c-=i.depth);var l;if(a){var d=-e.fontMetrics().axisHeight+a.height+.5*A.height+.111;l=P.makeVList({positionType:"individualShift",children:[{type:"elem",elem:i,shift:c},{type:"elem",elem:A,shift:o},{type:"elem",elem:a,shift:d}]},e)}else l=P.makeVList({positionType:"individualShift",children:[{type:"elem",elem:i,shift:c},{type:"elem",elem:A,shift:o}]},e);return l.children[0].children[0].children[1].classes.push("svg-align"),P.makeSpan(["mrel","x-arrow"],[l],e)},mathmlBuilder(r,e){var t=Cr.mathMLnode(r.label);t.setAttribute("minsize",r.label.charAt(0)==="x"?"1.75em":"3.0em");var n;if(r.body){var i=cA(Le(r.body,e));if(r.below){var s=cA(Le(r.below,e));n=new q.MathNode("munderover",[t,s,i])}else n=new q.MathNode("mover",[t,i])}else if(r.below){var a=cA(Le(r.below,e));n=new q.MathNode("munder",[t,a])}else n=cA(),n=new q.MathNode("mover",[t,n]);return n}});var T8=P.makeSpan;function Nv(r,e){var t=mt(r.body,e,!0);return T8([r.mclass],t,e)}function Kv(r,e){var t,n=Zt(r.body,e);return r.mclass==="minner"?t=new q.MathNode("mpadded",n):r.mclass==="mord"?r.isCharacterBox?(t=n[0],t.type="mi"):t=new q.MathNode("mi",n):(r.isCharacterBox?(t=n[0],t.type="mo"):t=new q.MathNode("mo",n),r.mclass==="mbin"?(t.attributes.lspace="0.22em",t.attributes.rspace="0.22em"):r.mclass==="mpunct"?(t.attributes.lspace="0em",t.attributes.rspace="0.17em"):r.mclass==="mopen"||r.mclass==="mclose"?(t.attributes.lspace="0em",t.attributes.rspace="0em"):r.mclass==="minner"&&(t.attributes.lspace="0.0556em",t.attributes.width="+0.1111em")),t}te({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"mclass",mode:t.mode,mclass:"m"+n.slice(5),body:At(i),isCharacterBox:ce.isCharacterBox(i)}},htmlBuilder:Nv,mathmlBuilder:Kv});var sc=r=>{var e=r.type==="ordgroup"&&r.body.length?r.body[0]:r;return e.type==="atom"&&(e.family==="bin"||e.family==="rel")?"m"+e.family:"mord"};te({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(r,e){var{parser:t}=r;return{type:"mclass",mode:t.mode,mclass:sc(e[0]),body:At(e[1]),isCharacterBox:ce.isCharacterBox(e[1])}}});te({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler(r,e){var{parser:t,funcName:n}=r,i=e[1],s=e[0],a;n!=="\\stackrel"?a=sc(i):a="mrel";var A={type:"op",mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:n!=="\\stackrel",body:At(i)},o={type:"supsub",mode:s.mode,base:A,sup:n==="\\underset"?null:s,sub:n==="\\underset"?s:null};return{type:"mclass",mode:t.mode,mclass:a,body:[o],isCharacterBox:ce.isCharacterBox(o)}},htmlBuilder:Nv,mathmlBuilder:Kv});te({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(r,e){var{parser:t}=r;return{type:"pmb",mode:t.mode,mclass:sc(e[0]),body:At(e[0])}},htmlBuilder(r,e){var t=mt(r.body,e,!0),n=P.makeSpan([r.mclass],t,e);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(r,e){var t=Zt(r.body,e),n=new q.MathNode("mstyle",t);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});var x8={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},rp=()=>({type:"styling",body:[],mode:"math",style:"display"}),ip=r=>r.type==="textord"&&r.text==="@",E8=(r,e)=>(r.type==="mathord"||r.type==="atom")&&r.text===e;function U8(r,e,t){var n=x8[r];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return t.callFunction(n,[e[0]],[e[1]]);case"\\uparrow":case"\\downarrow":{var i=t.callFunction("\\\\cdleft",[e[0]],[]),s={type:"atom",text:n,mode:"math",family:"rel"},a=t.callFunction("\\Big",[s],[]),A=t.callFunction("\\\\cdright",[e[1]],[]),o={type:"ordgroup",mode:"math",body:[i,a,A]};return t.callFunction("\\\\cdparent",[o],[])}case"\\\\cdlongequal":return t.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{var c={type:"textord",text:"\\Vert",mode:"math"};return t.callFunction("\\Big",[c],[])}default:return{type:"textord",text:" ",mode:"math"}}}function F8(r){var e=[];for(r.gullet.beginGroup(),r.gullet.macros.set("\\cr","\\\\\\relax"),r.gullet.beginGroup();;){e.push(r.parseExpression(!1,"\\\\")),r.gullet.endGroup(),r.gullet.beginGroup();var t=r.fetch().text;if(t==="&"||t==="\\\\")r.consume();else if(t==="\\end"){e[e.length-1].length===0&&e.pop();break}else throw new W("Expected \\\\ or \\cr or \\end",r.nextToken)}for(var n=[],i=[n],s=0;s<e.length;s++){for(var a=e[s],A=rp(),o=0;o<a.length;o++)if(!ip(a[o]))A.body.push(a[o]);else{n.push(A),o+=1;var c=Ku(a[o]).text,l=new Array(2);if(l[0]={type:"ordgroup",mode:"math",body:[]},l[1]={type:"ordgroup",mode:"math",body:[]},!("=|.".indexOf(c)>-1))if("<>AV".indexOf(c)>-1)for(var d=0;d<2;d++){for(var u=!0,h=o+1;h<a.length;h++){if(E8(a[h],c)){u=!1,o=h;break}if(ip(a[h]))throw new W("Missing a "+c+" character to complete a CD arrow.",a[h]);l[d].body.push(a[h])}if(u)throw new W("Missing a "+c+" character to complete a CD arrow.",a[o])}else throw new W('Expected one of "<>AV=|." after @',a[o]);var p=U8(c,l,r),g={type:"styling",body:[p],mode:"math",style:"display"};n.push(g),A=rp()}s%2===0?n.push(A):n.shift(),n=[],i.push(n)}r.gullet.endGroup(),r.gullet.endGroup();var v=new Array(i[0].length).fill({type:"align",align:"c",pregap:.25,postgap:.25});return{type:"array",mode:"math",body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:v,colSeparationType:"CD",hLinesBeforeRow:new Array(i.length+1).fill([])}}te({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler(r,e){var{parser:t,funcName:n}=r;return{type:"cdlabel",mode:t.mode,side:n.slice(4),label:e[0]}},htmlBuilder(r,e){var t=e.havingStyle(e.style.sup()),n=P.wrapFragment(xe(r.label,t,e),e);return n.classes.push("cd-label-"+r.side),n.style.bottom=j(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(r,e){var t=new q.MathNode("mrow",[Le(r.label,e)]);return t=new q.MathNode("mpadded",[t]),t.setAttribute("width","0"),r.side==="left"&&t.setAttribute("lspace","-1width"),t.setAttribute("voffset","0.7em"),t=new q.MathNode("mstyle",[t]),t.setAttribute("displaystyle","false"),t.setAttribute("scriptlevel","1"),t}});te({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler(r,e){var{parser:t}=r;return{type:"cdlabelparent",mode:t.mode,fragment:e[0]}},htmlBuilder(r,e){var t=P.wrapFragment(xe(r.fragment,e),e);return t.classes.push("cd-vert-arrow"),t},mathmlBuilder(r,e){return new q.MathNode("mrow",[Le(r.fragment,e)])}});te({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(r,e){for(var{parser:t}=r,n=ye(e[0],"ordgroup"),i=n.body,s="",a=0;a<i.length;a++){var A=ye(i[a],"textord");s+=A.text}var o=parseInt(s),c;if(isNaN(o))throw new W("\\@char has non-numeric argument "+s);if(o<0||o>=1114111)throw new W("\\@char with invalid code point "+s);return o<=65535?c=String.fromCharCode(o):(o-=65536,c=String.fromCharCode((o>>10)+55296,(o&1023)+56320)),{type:"textord",mode:t.mode,text:c}}});var Vv=(r,e)=>{var t=mt(r.body,e.withColor(r.color),!1);return P.makeFragment(t)},zv=(r,e)=>{var t=Zt(r.body,e.withColor(r.color)),n=new q.MathNode("mstyle",t);return n.setAttribute("mathcolor",r.color),n};te({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(r,e){var{parser:t}=r,n=ye(e[0],"color-token").color,i=e[1];return{type:"color",mode:t.mode,color:n,body:At(i)}},htmlBuilder:Vv,mathmlBuilder:zv});te({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(r,e){var{parser:t,breakOnTokenText:n}=r,i=ye(e[0],"color-token").color;t.gullet.macros.set("\\current@color",i);var s=t.parseExpression(!0,n);return{type:"color",mode:t.mode,color:i,body:s}},htmlBuilder:Vv,mathmlBuilder:zv});te({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler(r,e,t){var{parser:n}=r,i=n.gullet.future().text==="["?n.parseSizeGroup(!0):null,s=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:s,size:i&&ye(i,"size").value}},htmlBuilder(r,e){var t=P.makeSpan(["mspace"],[],e);return r.newLine&&(t.classes.push("newline"),r.size&&(t.style.marginTop=j(Ze(r.size,e)))),t},mathmlBuilder(r,e){var t=new q.MathNode("mspace");return r.newLine&&(t.setAttribute("linebreak","newline"),r.size&&t.setAttribute("height",j(Ze(r.size,e)))),t}});var Dd={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},Gv=r=>{var e=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(e))throw new W("Expected a control sequence",r);return e},I8=r=>{var e=r.gullet.popToken();return e.text==="="&&(e=r.gullet.popToken(),e.text===" "&&(e=r.gullet.popToken())),e},qv=(r,e,t,n)=>{var i=r.gullet.macros.get(t.text);i==null&&(t.noexpand=!0,i={tokens:[t],numArgs:0,unexpandable:!r.gullet.isExpandable(t.text)}),r.gullet.macros.set(e,i,n)};te({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler(r){var{parser:e,funcName:t}=r;e.consumeSpaces();var n=e.fetch();if(Dd[n.text])return(t==="\\global"||t==="\\\\globallong")&&(n.text=Dd[n.text]),ye(e.parseFunction(),"internal");throw new W("Invalid token after macro prefix",n)}});te({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(r){var{parser:e,funcName:t}=r,n=e.gullet.popToken(),i=n.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(i))throw new W("Expected a control sequence",n);for(var s=0,a,A=[[]];e.gullet.future().text!=="{";)if(n=e.gullet.popToken(),n.text==="#"){if(e.gullet.future().text==="{"){a=e.gullet.future(),A[s].push("{");break}if(n=e.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new W('Invalid argument number "'+n.text+'"');if(parseInt(n.text)!==s+1)throw new W('Argument number "'+n.text+'" out of order');s++,A.push([])}else{if(n.text==="EOF")throw new W("Expected a macro definition");A[s].push(n.text)}var{tokens:o}=e.gullet.consumeArg();return a&&o.unshift(a),(t==="\\edef"||t==="\\xdef")&&(o=e.gullet.expandTokens(o),o.reverse()),e.gullet.macros.set(i,{tokens:o,numArgs:s,delimiters:A},t===Dd[t]),{type:"internal",mode:e.mode}}});te({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(r){var{parser:e,funcName:t}=r,n=Gv(e.gullet.popToken());e.gullet.consumeSpaces();var i=I8(e);return qv(e,n,i,t==="\\\\globallet"),{type:"internal",mode:e.mode}}});te({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(r){var{parser:e,funcName:t}=r,n=Gv(e.gullet.popToken()),i=e.gullet.popToken(),s=e.gullet.popToken();return qv(e,n,s,t==="\\\\globalfuture"),e.gullet.pushToken(s),e.gullet.pushToken(i),{type:"internal",mode:e.mode}}});var Vs=function(e,t,n){var i=Ve.math[e]&&Ve.math[e].replace,s=Du(i||e,t,n);if(!s)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return s},zu=function(e,t,n,i){var s=n.havingBaseStyle(t),a=P.makeSpan(i.concat(s.sizingClasses(n)),[e],n),A=s.sizeMultiplier/n.sizeMultiplier;return a.height*=A,a.depth*=A,a.maxFontSize=s.sizeMultiplier,a},Wv=function(e,t,n){var i=t.havingBaseStyle(n),s=(1-t.sizeMultiplier/i.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=j(s),e.height-=s,e.depth+=s},Q8=function(e,t,n,i,s,a){var A=P.makeSymbol(e,"Main-Regular",s,i),o=zu(A,t,i,a);return n&&Wv(o,i,t),o},M8=function(e,t,n,i){return P.makeSymbol(e,"Size"+t+"-Regular",n,i)},$v=function(e,t,n,i,s,a){var A=M8(e,t,s,i),o=zu(P.makeSpan(["delimsizing","size"+t],[A],i),de.TEXT,i,a);return n&&Wv(o,i,de.TEXT),o},ul=function(e,t,n){var i;t==="Size1-Regular"?i="delim-size1":i="delim-size4";var s=P.makeSpan(["delimsizinginner",i],[P.makeSpan([],[P.makeSymbol(e,t,n)])]);return{type:"elem",elem:s}},hl=function(e,t,n){var i=Wn["Size4-Regular"][e.charCodeAt(0)]?Wn["Size4-Regular"][e.charCodeAt(0)][4]:Wn["Size1-Regular"][e.charCodeAt(0)][4],s=new jr("inner",O7(e,Math.round(1e3*t))),a=new br([s],{width:j(i),height:j(t),style:"width:"+j(i),viewBox:"0 0 "+1e3*i+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),A=P.makeSvgSpan([],[a],n);return A.height=t,A.style.height=j(t),A.style.width=j(i),{type:"elem",elem:A}},Ld=.008,lA={type:"kern",size:-1*Ld},_8=["|","\\lvert","\\rvert","\\vert"],R8=["\\|","\\lVert","\\rVert","\\Vert"],jv=function(e,t,n,i,s,a){var A,o,c,l,d="",u=0;A=c=l=e,o=null;var h="Size1-Regular";e==="\\uparrow"?c=l="⏐":e==="\\Uparrow"?c=l="‖":e==="\\downarrow"?A=c="⏐":e==="\\Downarrow"?A=c="‖":e==="\\updownarrow"?(A="\\uparrow",c="⏐",l="\\downarrow"):e==="\\Updownarrow"?(A="\\Uparrow",c="‖",l="\\Downarrow"):ce.contains(_8,e)?(c="∣",d="vert",u=333):ce.contains(R8,e)?(c="∥",d="doublevert",u=556):e==="["||e==="\\lbrack"?(A="⎡",c="⎢",l="⎣",h="Size4-Regular",d="lbrack",u=667):e==="]"||e==="\\rbrack"?(A="⎤",c="⎥",l="⎦",h="Size4-Regular",d="rbrack",u=667):e==="\\lfloor"||e==="⌊"?(c=A="⎢",l="⎣",h="Size4-Regular",d="lfloor",u=667):e==="\\lceil"||e==="⌈"?(A="⎡",c=l="⎢",h="Size4-Regular",d="lceil",u=667):e==="\\rfloor"||e==="⌋"?(c=A="⎥",l="⎦",h="Size4-Regular",d="rfloor",u=667):e==="\\rceil"||e==="⌉"?(A="⎤",c=l="⎥",h="Size4-Regular",d="rceil",u=667):e==="("||e==="\\lparen"?(A="⎛",c="⎜",l="⎝",h="Size4-Regular",d="lparen",u=875):e===")"||e==="\\rparen"?(A="⎞",c="⎟",l="⎠",h="Size4-Regular",d="rparen",u=875):e==="\\{"||e==="\\lbrace"?(A="⎧",o="⎨",l="⎩",c="⎪",h="Size4-Regular"):e==="\\}"||e==="\\rbrace"?(A="⎫",o="⎬",l="⎭",c="⎪",h="Size4-Regular"):e==="\\lgroup"||e==="⟮"?(A="⎧",l="⎩",c="⎪",h="Size4-Regular"):e==="\\rgroup"||e==="⟯"?(A="⎫",l="⎭",c="⎪",h="Size4-Regular"):e==="\\lmoustache"||e==="⎰"?(A="⎧",l="⎭",c="⎪",h="Size4-Regular"):(e==="\\rmoustache"||e==="⎱")&&(A="⎫",l="⎩",c="⎪",h="Size4-Regular");var p=Vs(A,h,s),g=p.height+p.depth,v=Vs(c,h,s),w=v.height+v.depth,B=Vs(l,h,s),E=B.height+B.depth,b=0,C=1;if(o!==null){var T=Vs(o,h,s);b=T.height+T.depth,C=2}var F=g+E+b,R=Math.max(0,Math.ceil((t-F)/(C*w))),M=F+R*C*w,D=i.fontMetrics().axisHeight;n&&(D*=i.sizeMultiplier);var O=M/2-D,H=[];if(d.length>0){var se=M-g-E,ie=Math.round(M*1e3),Z=H7(d,Math.round(se*1e3)),ee=new jr(d,Z),ue=(u/1e3).toFixed(3)+"em",Ce=(ie/1e3).toFixed(3)+"em",Ue=new br([ee],{width:ue,height:Ce,viewBox:"0 0 "+u+" "+ie}),Ge=P.makeSvgSpan([],[Ue],i);Ge.height=ie/1e3,Ge.style.width=ue,Ge.style.height=Ce,H.push({type:"elem",elem:Ge})}else{if(H.push(ul(l,h,s)),H.push(lA),o===null){var qe=M-g-E+2*Ld;H.push(hl(c,qe,i))}else{var We=(M-g-E-b)/2+2*Ld;H.push(hl(c,We,i)),H.push(lA),H.push(ul(o,h,s)),H.push(lA),H.push(hl(c,We,i))}H.push(lA),H.push(ul(A,h,s))}var gt=i.havingBaseStyle(de.TEXT),$e=P.makeVList({positionType:"bottom",positionData:O,children:H},gt);return zu(P.makeSpan(["delimsizing","mult"],[$e],gt),de.TEXT,i,a)},fl=80,pl=.08,ml=function(e,t,n,i,s){var a=L7(e,i,n),A=new jr(e,a),o=new br([A],{width:"400em",height:j(t),viewBox:"0 0 400000 "+n,preserveAspectRatio:"xMinYMin slice"});return P.makeSvgSpan(["hide-tail"],[o],s)},P8=function(e,t){var n=t.havingBaseSizing(),i=Zv("\\surd",e*n.sizeMultiplier,Yv,n),s=n.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),A,o=0,c=0,l=0,d;return i.type==="small"?(l=1e3+1e3*a+fl,e<1?s=1:e<1.4&&(s=.7),o=(1+a+pl)/s,c=(1+a)/s,A=ml("sqrtMain",o,l,a,t),A.style.minWidth="0.853em",d=.833/s):i.type==="large"?(l=(1e3+fl)*ia[i.size],c=(ia[i.size]+a)/s,o=(ia[i.size]+a+pl)/s,A=ml("sqrtSize"+i.size,o,l,a,t),A.style.minWidth="1.02em",d=1/s):(o=e+a+pl,c=e+a,l=Math.floor(1e3*e+a)+fl,A=ml("sqrtTall",o,l,a,t),A.style.minWidth="0.742em",d=1.056),A.height=c,A.style.height=j(o),{span:A,advanceWidth:d,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*s}},Xv=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","\\surd"],D8=["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱"],Jv=["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],ia=[0,1.2,1.8,2.4,3],L8=function(e,t,n,i,s){if(e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle"),ce.contains(Xv,e)||ce.contains(Jv,e))return $v(e,t,!1,n,i,s);if(ce.contains(D8,e))return jv(e,ia[t],!1,n,i,s);throw new W("Illegal delimiter: '"+e+"'")},O8=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],H8=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"stack"}],Yv=[{type:"small",style:de.SCRIPTSCRIPT},{type:"small",style:de.SCRIPT},{type:"small",style:de.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],N8=function(e){if(e.type==="small")return"Main-Regular";if(e.type==="large")return"Size"+e.size+"-Regular";if(e.type==="stack")return"Size4-Regular";throw new Error("Add support for delim type '"+e.type+"' here.")},Zv=function(e,t,n,i){for(var s=Math.min(2,3-i.style.size),a=s;a<n.length&&n[a].type!=="stack";a++){var A=Vs(e,N8(n[a]),"math"),o=A.height+A.depth;if(n[a].type==="small"){var c=i.havingBaseStyle(n[a].style);o*=c.sizeMultiplier}if(o>t)return n[a]}return n[n.length-1]},ey=function(e,t,n,i,s,a){e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle");var A;ce.contains(Jv,e)?A=O8:ce.contains(Xv,e)?A=Yv:A=H8;var o=Zv(e,t,A,i);return o.type==="small"?Q8(e,o.style,n,i,s,a):o.type==="large"?$v(e,o.size,n,i,s,a):jv(e,t,n,i,s,a)},K8=function(e,t,n,i,s,a){var A=i.fontMetrics().axisHeight*i.sizeMultiplier,o=901,c=5/i.fontMetrics().ptPerEm,l=Math.max(t-A,n+A),d=Math.max(l/500*o,2*l-c);return ey(e,d,!0,i,s,a)},yr={sqrtImage:P8,sizedDelim:L8,sizeToMaxHeight:ia,customSizedDelim:ey,leftRightDelim:K8},sp={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},V8=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];function ac(r,e){var t=ic(r);if(t&&ce.contains(V8,t.text))return t;throw t?new W("Invalid delimiter '"+t.text+"' after '"+e.funcName+"'",r):new W("Invalid delimiter type '"+r.type+"'",r)}te({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(r,e)=>{var t=ac(e[0],r);return{type:"delimsizing",mode:r.parser.mode,size:sp[r.funcName].size,mclass:sp[r.funcName].mclass,delim:t.text}},htmlBuilder:(r,e)=>r.delim==="."?P.makeSpan([r.mclass]):yr.sizedDelim(r.delim,r.size,e,r.mode,[r.mclass]),mathmlBuilder:r=>{var e=[];r.delim!=="."&&e.push(yn(r.delim,r.mode));var t=new q.MathNode("mo",e);r.mclass==="mopen"||r.mclass==="mclose"?t.setAttribute("fence","true"):t.setAttribute("fence","false"),t.setAttribute("stretchy","true");var n=j(yr.sizeToMaxHeight[r.size]);return t.setAttribute("minsize",n),t.setAttribute("maxsize",n),t}});function ap(r){if(!r.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}te({type:"leftright-right",names:["\\right"],props:{numArgs:1,primitive:!0},handler:(r,e)=>{var t=r.parser.gullet.macros.get("\\current@color");if(t&&typeof t!="string")throw new W("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:r.parser.mode,delim:ac(e[0],r).text,color:t}}});te({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(r,e)=>{var t=ac(e[0],r),n=r.parser;++n.leftrightDepth;var i=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);var s=ye(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:i,left:t.text,right:s.delim,rightColor:s.color}},htmlBuilder:(r,e)=>{ap(r);for(var t=mt(r.body,e,!0,["mopen","mclose"]),n=0,i=0,s=!1,a=0;a<t.length;a++)t[a].isMiddle?s=!0:(n=Math.max(t[a].height,n),i=Math.max(t[a].depth,i));n*=e.sizeMultiplier,i*=e.sizeMultiplier;var A;if(r.left==="."?A=ka(e,["mopen"]):A=yr.leftRightDelim(r.left,n,i,e,r.mode,["mopen"]),t.unshift(A),s)for(var o=1;o<t.length;o++){var c=t[o],l=c.isMiddle;l&&(t[o]=yr.leftRightDelim(l.delim,n,i,l.options,r.mode,[]))}var d;if(r.right===".")d=ka(e,["mclose"]);else{var u=r.rightColor?e.withColor(r.rightColor):e;d=yr.leftRightDelim(r.right,n,i,u,r.mode,["mclose"])}return t.push(d),P.makeSpan(["minner"],t,e)},mathmlBuilder:(r,e)=>{ap(r);var t=Zt(r.body,e);if(r.left!=="."){var n=new q.MathNode("mo",[yn(r.left,r.mode)]);n.setAttribute("fence","true"),t.unshift(n)}if(r.right!=="."){var i=new q.MathNode("mo",[yn(r.right,r.mode)]);i.setAttribute("fence","true"),r.rightColor&&i.setAttribute("mathcolor",r.rightColor),t.push(i)}return Hu(t)}});te({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(r,e)=>{var t=ac(e[0],r);if(!r.parser.leftrightDepth)throw new W("\\middle without preceding \\left",t);return{type:"middle",mode:r.parser.mode,delim:t.text}},htmlBuilder:(r,e)=>{var t;if(r.delim===".")t=ka(e,[]);else{t=yr.sizedDelim(r.delim,1,e,r.mode,[]);var n={delim:r.delim,options:e};t.isMiddle=n}return t},mathmlBuilder:(r,e)=>{var t=r.delim==="\\vert"||r.delim==="|"?yn("|","text"):yn(r.delim,r.mode),n=new q.MathNode("mo",[t]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});var Gu=(r,e)=>{var t=P.wrapFragment(xe(r.body,e),e),n=r.label.slice(1),i=e.sizeMultiplier,s,a=0,A=ce.isCharacterBox(r.body);if(n==="sout")s=P.makeSpan(["stretchy","sout"]),s.height=e.fontMetrics().defaultRuleThickness/i,a=-.5*e.fontMetrics().xHeight;else if(n==="phase"){var o=Ze({number:.6,unit:"pt"},e),c=Ze({number:.35,unit:"ex"},e),l=e.havingBaseSizing();i=i/l.sizeMultiplier;var d=t.height+t.depth+o+c;t.style.paddingLeft=j(d/2+o);var u=Math.floor(1e3*d*i),h=P7(u),p=new br([new jr("phase",h)],{width:"400em",height:j(u/1e3),viewBox:"0 0 400000 "+u,preserveAspectRatio:"xMinYMin slice"});s=P.makeSvgSpan(["hide-tail"],[p],e),s.style.height=j(d),a=t.depth+o+c}else{/cancel/.test(n)?A||t.classes.push("cancel-pad"):n==="angl"?t.classes.push("anglpad"):t.classes.push("boxpad");var g=0,v=0,w=0;/box/.test(n)?(w=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness),g=e.fontMetrics().fboxsep+(n==="colorbox"?0:w),v=g):n==="angl"?(w=Math.max(e.fontMetrics().defaultRuleThickness,e.minRuleThickness),g=4*w,v=Math.max(0,.25-t.depth)):(g=A?.2:0,v=g),s=Cr.encloseSpan(t,n,g,v,e),/fbox|boxed|fcolorbox/.test(n)?(s.style.borderStyle="solid",s.style.borderWidth=j(w)):n==="angl"&&w!==.049&&(s.style.borderTopWidth=j(w),s.style.borderRightWidth=j(w)),a=t.depth+v,r.backgroundColor&&(s.style.backgroundColor=r.backgroundColor,r.borderColor&&(s.style.borderColor=r.borderColor))}var B;if(r.backgroundColor)B=P.makeVList({positionType:"individualShift",children:[{type:"elem",elem:s,shift:a},{type:"elem",elem:t,shift:0}]},e);else{var E=/cancel|phase/.test(n)?["svg-align"]:[];B=P.makeVList({positionType:"individualShift",children:[{type:"elem",elem:t,shift:0},{type:"elem",elem:s,shift:a,wrapperClasses:E}]},e)}return/cancel/.test(n)&&(B.height=t.height,B.depth=t.depth),/cancel/.test(n)&&!A?P.makeSpan(["mord","cancel-lap"],[B],e):P.makeSpan(["mord"],[B],e)},qu=(r,e)=>{var t=0,n=new q.MathNode(r.label.indexOf("colorbox")>-1?"mpadded":"menclose",[Le(r.body,e)]);switch(r.label){case"\\cancel":n.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike");break;case"\\phase":n.setAttribute("notation","phasorangle");break;case"\\sout":n.setAttribute("notation","horizontalstrike");break;case"\\fbox":n.setAttribute("notation","box");break;case"\\angl":n.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(t=e.fontMetrics().fboxsep*e.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*t+"pt"),n.setAttribute("height","+"+2*t+"pt"),n.setAttribute("lspace",t+"pt"),n.setAttribute("voffset",t+"pt"),r.label==="\\fcolorbox"){var i=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness);n.setAttribute("style","border: "+i+"em solid "+String(r.borderColor))}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike");break}return r.backgroundColor&&n.setAttribute("mathbackground",r.backgroundColor),n};te({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","text"]},handler(r,e,t){var{parser:n,funcName:i}=r,s=ye(e[0],"color-token").color,a=e[1];return{type:"enclose",mode:n.mode,label:i,backgroundColor:s,body:a}},htmlBuilder:Gu,mathmlBuilder:qu});te({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","text"]},handler(r,e,t){var{parser:n,funcName:i}=r,s=ye(e[0],"color-token").color,a=ye(e[1],"color-token").color,A=e[2];return{type:"enclose",mode:n.mode,label:i,backgroundColor:a,borderColor:s,body:A}},htmlBuilder:Gu,mathmlBuilder:qu});te({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler(r,e){var{parser:t}=r;return{type:"enclose",mode:t.mode,label:"\\fbox",body:e[0]}}});te({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\sout","\\phase"],props:{numArgs:1},handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"enclose",mode:t.mode,label:n,body:i}},htmlBuilder:Gu,mathmlBuilder:qu});te({type:"enclose",names:["\\angl"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!1},handler(r,e){var{parser:t}=r;return{type:"enclose",mode:t.mode,label:"\\angl",body:e[0]}}});var ty={};function er(r){for(var{type:e,names:t,props:n,handler:i,htmlBuilder:s,mathmlBuilder:a}=r,A={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},o=0;o<t.length;++o)ty[t[o]]=A;s&&(yo[e]=s),a&&(wo[e]=a)}var ny={};function S(r,e){ny[r]=e}function Ap(r){var e=[];r.consumeSpaces();var t=r.fetch().text;for(t==="\\relax"&&(r.consume(),r.consumeSpaces(),t=r.fetch().text);t==="\\hline"||t==="\\hdashline";)r.consume(),e.push(t==="\\hdashline"),r.consumeSpaces(),t=r.fetch().text;return e}var Ac=r=>{var e=r.parser.settings;if(!e.displayMode)throw new W("{"+r.envName+"} can be used only in display mode.")};function Wu(r){if(r.indexOf("ed")===-1)return r.indexOf("*")===-1}function Zr(r,e,t){var{hskipBeforeAndAfter:n,addJot:i,cols:s,arraystretch:a,colSeparationType:A,autoTag:o,singleRow:c,emptySingleRow:l,maxNumCols:d,leqno:u}=e;if(r.gullet.beginGroup(),c||r.gullet.macros.set("\\cr","\\\\\\relax"),!a){var h=r.gullet.expandMacroAsText("\\arraystretch");if(h==null)a=1;else if(a=parseFloat(h),!a||a<0)throw new W("Invalid \\arraystretch: "+h)}r.gullet.beginGroup();var p=[],g=[p],v=[],w=[],B=o!=null?[]:void 0;function E(){o&&r.gullet.macros.set("\\@eqnsw","1",!0)}function b(){B&&(r.gullet.macros.get("\\df@tag")?(B.push(r.subparse([new gn("\\df@tag")])),r.gullet.macros.set("\\df@tag",void 0,!0)):B.push(!!o&&r.gullet.macros.get("\\@eqnsw")==="1"))}for(E(),w.push(Ap(r));;){var C=r.parseExpression(!1,c?"\\end":"\\\\");r.gullet.endGroup(),r.gullet.beginGroup(),C={type:"ordgroup",mode:r.mode,body:C},t&&(C={type:"styling",mode:r.mode,style:t,body:[C]}),p.push(C);var T=r.fetch().text;if(T==="&"){if(d&&p.length===d){if(c||A)throw new W("Too many tab characters: &",r.nextToken);r.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}r.consume()}else if(T==="\\end"){b(),p.length===1&&C.type==="styling"&&C.body[0].body.length===0&&(g.length>1||!l)&&g.pop(),w.length<g.length+1&&w.push([]);break}else if(T==="\\\\"){r.consume();var F=void 0;r.gullet.future().text!==" "&&(F=r.parseSizeGroup(!0)),v.push(F?F.value:null),b(),w.push(Ap(r)),p=[],g.push(p),E()}else throw new W("Expected & or \\\\ or \\cr or \\end",r.nextToken)}return r.gullet.endGroup(),r.gullet.endGroup(),{type:"array",mode:r.mode,addJot:i,arraystretch:a,body:g,cols:s,rowGaps:v,hskipBeforeAndAfter:n,hLinesBeforeRow:w,colSeparationType:A,tags:B,leqno:u}}function $u(r){return r.slice(0,1)==="d"?"display":"text"}var tr=function(e,t){var n,i,s=e.body.length,a=e.hLinesBeforeRow,A=0,o=new Array(s),c=[],l=Math.max(t.fontMetrics().arrayRuleWidth,t.minRuleThickness),d=1/t.fontMetrics().ptPerEm,u=5*d;if(e.colSeparationType&&e.colSeparationType==="small"){var h=t.havingStyle(de.SCRIPT).sizeMultiplier;u=.2778*(h/t.sizeMultiplier)}var p=e.colSeparationType==="CD"?Ze({number:3,unit:"ex"},t):12*d,g=3*d,v=e.arraystretch*p,w=.7*v,B=.3*v,E=0;function b(ae){for(var pe=0;pe<ae.length;++pe)pe>0&&(E+=.25),c.push({pos:E,isDashed:ae[pe]})}for(b(a[0]),n=0;n<e.body.length;++n){var C=e.body[n],T=w,F=B;A<C.length&&(A=C.length);var R=new Array(C.length);for(i=0;i<C.length;++i){var M=xe(C[i],t);F<M.depth&&(F=M.depth),T<M.height&&(T=M.height),R[i]=M}var D=e.rowGaps[n],O=0;D&&(O=Ze(D,t),O>0&&(O+=B,F<O&&(F=O),O=0)),e.addJot&&(F+=g),R.height=T,R.depth=F,E+=T,R.pos=E,E+=F+O,o[n]=R,b(a[n+1])}var H=E/2+t.fontMetrics().axisHeight,se=e.cols||[],ie=[],Z,ee,ue=[];if(e.tags&&e.tags.some(ae=>ae))for(n=0;n<s;++n){var Ce=o[n],Ue=Ce.pos-H,Ge=e.tags[n],qe=void 0;Ge===!0?qe=P.makeSpan(["eqn-num"],[],t):Ge===!1?qe=P.makeSpan([],[],t):qe=P.makeSpan([],mt(Ge,t,!0),t),qe.depth=Ce.depth,qe.height=Ce.height,ue.push({type:"elem",elem:qe,shift:Ue})}for(i=0,ee=0;i<A||ee<se.length;++i,++ee){for(var We=se[ee]||{},gt=!0;We.type==="separator";){if(gt||(Z=P.makeSpan(["arraycolsep"],[]),Z.style.width=j(t.fontMetrics().doubleRuleSep),ie.push(Z)),We.separator==="|"||We.separator===":"){var $e=We.separator==="|"?"solid":"dashed",en=P.makeSpan(["vertical-separator"],[],t);en.style.height=j(E),en.style.borderRightWidth=j(l),en.style.borderRightStyle=$e,en.style.margin="0 "+j(-l/2);var Mt=E-H;Mt&&(en.style.verticalAlign=j(-Mt)),ie.push(en)}else throw new W("Invalid separator type: "+We.separator);ee++,We=se[ee]||{},gt=!1}if(!(i>=A)){var vt=void 0;(i>0||e.hskipBeforeAndAfter)&&(vt=ce.deflt(We.pregap,u),vt!==0&&(Z=P.makeSpan(["arraycolsep"],[]),Z.style.width=j(vt),ie.push(Z)));var _t=[];for(n=0;n<s;++n){var _e=o[n],on=_e[i];if(on){var ms=_e.pos-H;on.depth=_e.depth,on.height=_e.height,_t.push({type:"elem",elem:on,shift:ms})}}_t=P.makeVList({positionType:"individualShift",children:_t},t),_t=P.makeSpan(["col-align-"+(We.align||"c")],[_t]),ie.push(_t),(i<A-1||e.hskipBeforeAndAfter)&&(vt=ce.deflt(We.postgap,u),vt!==0&&(Z=P.makeSpan(["arraycolsep"],[]),Z.style.width=j(vt),ie.push(Z)))}}if(o=P.makeSpan(["mtable"],ie),c.length>0){for(var gs=P.makeLineSpan("hline",t,l),lc=P.makeLineSpan("hdashline",t,l),vs=[{type:"elem",elem:o,shift:0}];c.length>0;){var Ui=c.pop(),Ia=Ui.pos-H;Ui.isDashed?vs.push({type:"elem",elem:lc,shift:Ia}):vs.push({type:"elem",elem:gs,shift:Ia})}o=P.makeVList({positionType:"individualShift",children:vs},t)}if(ue.length===0)return P.makeSpan(["mord"],[o],t);var Fi=P.makeVList({positionType:"individualShift",children:ue},t);return Fi=P.makeSpan(["tag"],[Fi],t),P.makeFragment([o,Fi])},z8={c:"center ",l:"left ",r:"right "},nr=function(e,t){for(var n=[],i=new q.MathNode("mtd",[],["mtr-glue"]),s=new q.MathNode("mtd",[],["mml-eqn-num"]),a=0;a<e.body.length;a++){for(var A=e.body[a],o=[],c=0;c<A.length;c++)o.push(new q.MathNode("mtd",[Le(A[c],t)]));e.tags&&e.tags[a]&&(o.unshift(i),o.push(i),e.leqno?o.unshift(s):o.push(s)),n.push(new q.MathNode("mtr",o))}var l=new q.MathNode("mtable",n),d=e.arraystretch===.5?.1:.16+e.arraystretch-1+(e.addJot?.09:0);l.setAttribute("rowspacing",j(d));var u="",h="";if(e.cols&&e.cols.length>0){var p=e.cols,g="",v=!1,w=0,B=p.length;p[0].type==="separator"&&(u+="top ",w=1),p[p.length-1].type==="separator"&&(u+="bottom ",B-=1);for(var E=w;E<B;E++)p[E].type==="align"?(h+=z8[p[E].align],v&&(g+="none "),v=!0):p[E].type==="separator"&&v&&(g+=p[E].separator==="|"?"solid ":"dashed ",v=!1);l.setAttribute("columnalign",h.trim()),/[sd]/.test(g)&&l.setAttribute("columnlines",g.trim())}if(e.colSeparationType==="align"){for(var b=e.cols||[],C="",T=1;T<b.length;T++)C+=T%2?"0em ":"1em ";l.setAttribute("columnspacing",C.trim())}else e.colSeparationType==="alignat"||e.colSeparationType==="gather"?l.setAttribute("columnspacing","0em"):e.colSeparationType==="small"?l.setAttribute("columnspacing","0.2778em"):e.colSeparationType==="CD"?l.setAttribute("columnspacing","0.5em"):l.setAttribute("columnspacing","1em");var F="",R=e.hLinesBeforeRow;u+=R[0].length>0?"left ":"",u+=R[R.length-1].length>0?"right ":"";for(var M=1;M<R.length-1;M++)F+=R[M].length===0?"none ":R[M][0]?"dashed ":"solid ";return/[sd]/.test(F)&&l.setAttribute("rowlines",F.trim()),u!==""&&(l=new q.MathNode("menclose",[l]),l.setAttribute("notation",u.trim())),e.arraystretch&&e.arraystretch<1&&(l=new q.MathNode("mstyle",[l]),l.setAttribute("scriptlevel","1")),l},ry=function(e,t){e.envName.indexOf("ed")===-1&&Ac(e);var n=[],i=e.envName.indexOf("at")>-1?"alignat":"align",s=e.envName==="split",a=Zr(e.parser,{cols:n,addJot:!0,autoTag:s?void 0:Wu(e.envName),emptySingleRow:!0,colSeparationType:i,maxNumCols:s?2:void 0,leqno:e.parser.settings.leqno},"display"),A,o=0,c={type:"ordgroup",mode:e.mode,body:[]};if(t[0]&&t[0].type==="ordgroup"){for(var l="",d=0;d<t[0].body.length;d++){var u=ye(t[0].body[d],"textord");l+=u.text}A=Number(l),o=A*2}var h=!o;a.body.forEach(function(w){for(var B=1;B<w.length;B+=2){var E=ye(w[B],"styling"),b=ye(E.body[0],"ordgroup");b.body.unshift(c)}if(h)o<w.length&&(o=w.length);else{var C=w.length/2;if(A<C)throw new W("Too many math in a row: "+("expected "+A+", but got "+C),w[0])}});for(var p=0;p<o;++p){var g="r",v=0;p%2===1?g="l":p>0&&h&&(v=1),n[p]={type:"align",align:g,pregap:v,postgap:0}}return a.colSeparationType=h?"align":"alignat",a};er({type:"array",names:["array","darray"],props:{numArgs:1},handler(r,e){var t=ic(e[0]),n=t?[e[0]]:ye(e[0],"ordgroup").body,i=n.map(function(a){var A=Ku(a),o=A.text;if("lcr".indexOf(o)!==-1)return{type:"align",align:o};if(o==="|")return{type:"separator",separator:"|"};if(o===":")return{type:"separator",separator:":"};throw new W("Unknown column alignment: "+o,a)}),s={cols:i,hskipBeforeAndAfter:!0,maxNumCols:i.length};return Zr(r.parser,s,$u(r.envName))},htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(r){var e={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[r.envName.replace("*","")],t="c",n={hskipBeforeAndAfter:!1,cols:[{type:"align",align:t}]};if(r.envName.charAt(r.envName.length-1)==="*"){var i=r.parser;if(i.consumeSpaces(),i.fetch().text==="["){if(i.consume(),i.consumeSpaces(),t=i.fetch().text,"lcr".indexOf(t)===-1)throw new W("Expected l or c or r",i.nextToken);i.consume(),i.consumeSpaces(),i.expect("]"),i.consume(),n.cols=[{type:"align",align:t}]}}var s=Zr(r.parser,n,$u(r.envName)),a=Math.max(0,...s.body.map(A=>A.length));return s.cols=new Array(a).fill({type:"align",align:t}),e?{type:"leftright",mode:r.mode,body:[s],left:e[0],right:e[1],rightColor:void 0}:s},htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(r){var e={arraystretch:.5},t=Zr(r.parser,e,"script");return t.colSeparationType="small",t},htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["subarray"],props:{numArgs:1},handler(r,e){var t=ic(e[0]),n=t?[e[0]]:ye(e[0],"ordgroup").body,i=n.map(function(a){var A=Ku(a),o=A.text;if("lc".indexOf(o)!==-1)return{type:"align",align:o};throw new W("Unknown column alignment: "+o,a)});if(i.length>1)throw new W("{subarray} can contain only one column");var s={cols:i,hskipBeforeAndAfter:!1,arraystretch:.5};if(s=Zr(r.parser,s,"script"),s.body.length>0&&s.body[0].length>1)throw new W("{subarray} can contain only one column");return s},htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(r){var e={arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},t=Zr(r.parser,e,$u(r.envName));return{type:"leftright",mode:r.mode,body:[t],left:r.envName.indexOf("r")>-1?".":"\\{",right:r.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:ry,htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(r){ce.contains(["gather","gather*"],r.envName)&&Ac(r);var e={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:Wu(r.envName),emptySingleRow:!0,leqno:r.parser.settings.leqno};return Zr(r.parser,e,"display")},htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:ry,htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(r){Ac(r);var e={autoTag:Wu(r.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:r.parser.settings.leqno};return Zr(r.parser,e,"display")},htmlBuilder:tr,mathmlBuilder:nr});er({type:"array",names:["CD"],props:{numArgs:0},handler(r){return Ac(r),F8(r.parser)},htmlBuilder:tr,mathmlBuilder:nr});S("\\nonumber","\\gdef\\@eqnsw{0}");S("\\notag","\\nonumber");te({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(r,e){throw new W(r.funcName+" valid only within array environment")}});var op=ty;te({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler(r,e){var{parser:t,funcName:n}=r,i=e[0];if(i.type!=="ordgroup")throw new W("Invalid environment name",i);for(var s="",a=0;a<i.body.length;++a)s+=ye(i.body[a],"textord").text;if(n==="\\begin"){if(!op.hasOwnProperty(s))throw new W("No such environment: "+s,i);var A=op[s],{args:o,optArgs:c}=t.parseArguments("\\begin{"+s+"}",A),l={mode:t.mode,envName:s,parser:t},d=A.handler(l,o,c);t.expect("\\end",!1);var u=t.nextToken,h=ye(t.parseFunction(),"environment");if(h.name!==s)throw new W("Mismatch: \\begin{"+s+"} matched by \\end{"+h.name+"}",u);return d}return{type:"environment",mode:t.mode,name:s,nameGroup:i}}});var iy=(r,e)=>{var t=r.font,n=e.withFont(t);return xe(r.body,n)},sy=(r,e)=>{var t=r.font,n=e.withFont(t);return Le(r.body,n)},cp={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};te({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=bo(e[0]),s=n;return s in cp&&(s=cp[s]),{type:"font",mode:t.mode,font:s.slice(1),body:i}},htmlBuilder:iy,mathmlBuilder:sy});te({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(r,e)=>{var{parser:t}=r,n=e[0],i=ce.isCharacterBox(n);return{type:"mclass",mode:t.mode,mclass:sc(n),body:[{type:"font",mode:t.mode,font:"boldsymbol",body:n}],isCharacterBox:i}}});te({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:(r,e)=>{var{parser:t,funcName:n,breakOnTokenText:i}=r,{mode:s}=t,a=t.parseExpression(!0,i),A="math"+n.slice(1);return{type:"font",mode:s,font:A,body:{type:"ordgroup",mode:t.mode,body:a}}},htmlBuilder:iy,mathmlBuilder:sy});var ay=(r,e)=>{var t=e;return r==="display"?t=t.id>=de.SCRIPT.id?t.text():de.DISPLAY:r==="text"&&t.size===de.DISPLAY.size?t=de.TEXT:r==="script"?t=de.SCRIPT:r==="scriptscript"&&(t=de.SCRIPTSCRIPT),t},ju=(r,e)=>{var t=ay(r.size,e.style),n=t.fracNum(),i=t.fracDen(),s;s=e.havingStyle(n);var a=xe(r.numer,s,e);if(r.continued){var A=8.5/e.fontMetrics().ptPerEm,o=3.5/e.fontMetrics().ptPerEm;a.height=a.height<A?A:a.height,a.depth=a.depth<o?o:a.depth}s=e.havingStyle(i);var c=xe(r.denom,s,e),l,d,u;r.hasBarLine?(r.barSize?(d=Ze(r.barSize,e),l=P.makeLineSpan("frac-line",e,d)):l=P.makeLineSpan("frac-line",e),d=l.height,u=l.height):(l=null,d=0,u=e.fontMetrics().defaultRuleThickness);var h,p,g;t.size===de.DISPLAY.size||r.size==="display"?(h=e.fontMetrics().num1,d>0?p=3*u:p=7*u,g=e.fontMetrics().denom1):(d>0?(h=e.fontMetrics().num2,p=u):(h=e.fontMetrics().num3,p=3*u),g=e.fontMetrics().denom2);var v;if(l){var B=e.fontMetrics().axisHeight;h-a.depth-(B+.5*d)<p&&(h+=p-(h-a.depth-(B+.5*d))),B-.5*d-(c.height-g)<p&&(g+=p-(B-.5*d-(c.height-g)));var E=-(B-.5*d);v=P.makeVList({positionType:"individualShift",children:[{type:"elem",elem:c,shift:g},{type:"elem",elem:l,shift:E},{type:"elem",elem:a,shift:-h}]},e)}else{var w=h-a.depth-(c.height-g);w<p&&(h+=.5*(p-w),g+=.5*(p-w)),v=P.makeVList({positionType:"individualShift",children:[{type:"elem",elem:c,shift:g},{type:"elem",elem:a,shift:-h}]},e)}s=e.havingStyle(t),v.height*=s.sizeMultiplier/e.sizeMultiplier,v.depth*=s.sizeMultiplier/e.sizeMultiplier;var b;t.size===de.DISPLAY.size?b=e.fontMetrics().delim1:t.size===de.SCRIPTSCRIPT.size?b=e.havingStyle(de.SCRIPT).fontMetrics().delim2:b=e.fontMetrics().delim2;var C,T;return r.leftDelim==null?C=ka(e,["mopen"]):C=yr.customSizedDelim(r.leftDelim,b,!0,e.havingStyle(t),r.mode,["mopen"]),r.continued?T=P.makeSpan([]):r.rightDelim==null?T=ka(e,["mclose"]):T=yr.customSizedDelim(r.rightDelim,b,!0,e.havingStyle(t),r.mode,["mclose"]),P.makeSpan(["mord"].concat(s.sizingClasses(e)),[C,P.makeSpan(["mfrac"],[v]),T],e)},Xu=(r,e)=>{var t=new q.MathNode("mfrac",[Le(r.numer,e),Le(r.denom,e)]);if(!r.hasBarLine)t.setAttribute("linethickness","0px");else if(r.barSize){var n=Ze(r.barSize,e);t.setAttribute("linethickness",j(n))}var i=ay(r.size,e.style);if(i.size!==e.style.size){t=new q.MathNode("mstyle",[t]);var s=i.size===de.DISPLAY.size?"true":"false";t.setAttribute("displaystyle",s),t.setAttribute("scriptlevel","0")}if(r.leftDelim!=null||r.rightDelim!=null){var a=[];if(r.leftDelim!=null){var A=new q.MathNode("mo",[new q.TextNode(r.leftDelim.replace("\\",""))]);A.setAttribute("fence","true"),a.push(A)}if(a.push(t),r.rightDelim!=null){var o=new q.MathNode("mo",[new q.TextNode(r.rightDelim.replace("\\",""))]);o.setAttribute("fence","true"),a.push(o)}return Hu(a)}return t};te({type:"genfrac",names:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],s=e[1],a,A=null,o=null,c="auto";switch(n){case"\\dfrac":case"\\frac":case"\\tfrac":a=!0;break;case"\\\\atopfrac":a=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":a=!1,A="(",o=")";break;case"\\\\bracefrac":a=!1,A="\\{",o="\\}";break;case"\\\\brackfrac":a=!1,A="[",o="]";break;default:throw new Error("Unrecognized genfrac command")}switch(n){case"\\dfrac":case"\\dbinom":c="display";break;case"\\tfrac":case"\\tbinom":c="text";break}return{type:"genfrac",mode:t.mode,continued:!1,numer:i,denom:s,hasBarLine:a,leftDelim:A,rightDelim:o,size:c,barSize:null}},htmlBuilder:ju,mathmlBuilder:Xu});te({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],s=e[1];return{type:"genfrac",mode:t.mode,continued:!0,numer:i,denom:s,hasBarLine:!0,leftDelim:null,rightDelim:null,size:"display",barSize:null}}});te({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler(r){var{parser:e,funcName:t,token:n}=r,i;switch(t){case"\\over":i="\\frac";break;case"\\choose":i="\\binom";break;case"\\atop":i="\\\\atopfrac";break;case"\\brace":i="\\\\bracefrac";break;case"\\brack":i="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:i,token:n}}});var lp=["display","text","script","scriptscript"],dp=function(e){var t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};te({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler(r,e){var{parser:t}=r,n=e[4],i=e[5],s=bo(e[0]),a=s.type==="atom"&&s.family==="open"?dp(s.text):null,A=bo(e[1]),o=A.type==="atom"&&A.family==="close"?dp(A.text):null,c=ye(e[2],"size"),l,d=null;c.isBlank?l=!0:(d=c.value,l=d.number>0);var u="auto",h=e[3];if(h.type==="ordgroup"){if(h.body.length>0){var p=ye(h.body[0],"textord");u=lp[Number(p.text)]}}else h=ye(h,"textord"),u=lp[Number(h.text)];return{type:"genfrac",mode:t.mode,numer:n,denom:i,continued:!1,hasBarLine:l,barSize:d,leftDelim:a,rightDelim:o,size:u}},htmlBuilder:ju,mathmlBuilder:Xu});te({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler(r,e){var{parser:t,funcName:n,token:i}=r;return{type:"infix",mode:t.mode,replaceWith:"\\\\abovefrac",size:ye(e[0],"size").value,token:i}}});te({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],s=b7(ye(e[1],"infix").size),a=e[2],A=s.number>0;return{type:"genfrac",mode:t.mode,numer:i,denom:a,continued:!1,hasBarLine:A,barSize:s,leftDelim:null,rightDelim:null,size:"auto"}},htmlBuilder:ju,mathmlBuilder:Xu});var Ay=(r,e)=>{var t=e.style,n,i;r.type==="supsub"?(n=r.sup?xe(r.sup,e.havingStyle(t.sup()),e):xe(r.sub,e.havingStyle(t.sub()),e),i=ye(r.base,"horizBrace")):i=ye(r,"horizBrace");var s=xe(i.base,e.havingBaseStyle(de.DISPLAY)),a=Cr.svgSpan(i,e),A;if(i.isOver?(A=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:a}]},e),A.children[0].children[0].children[1].classes.push("svg-align")):(A=P.makeVList({positionType:"bottom",positionData:s.depth+.1+a.height,children:[{type:"elem",elem:a},{type:"kern",size:.1},{type:"elem",elem:s}]},e),A.children[0].children[0].children[0].classes.push("svg-align")),n){var o=P.makeSpan(["mord",i.isOver?"mover":"munder"],[A],e);i.isOver?A=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:.2},{type:"elem",elem:n}]},e):A=P.makeVList({positionType:"bottom",positionData:o.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:o}]},e)}return P.makeSpan(["mord",i.isOver?"mover":"munder"],[A],e)},G8=(r,e)=>{var t=Cr.mathMLnode(r.label);return new q.MathNode(r.isOver?"mover":"munder",[Le(r.base,e),t])};te({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler(r,e){var{parser:t,funcName:n}=r;return{type:"horizBrace",mode:t.mode,label:n,isOver:/^\\over/.test(n),base:e[0]}},htmlBuilder:Ay,mathmlBuilder:G8});te({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(r,e)=>{var{parser:t}=r,n=e[1],i=ye(e[0],"url").url;return t.settings.isTrusted({command:"\\href",url:i})?{type:"href",mode:t.mode,href:i,body:At(n)}:t.formatUnsupportedCmd("\\href")},htmlBuilder:(r,e)=>{var t=mt(r.body,e,!1);return P.makeAnchor(r.href,[],t,e)},mathmlBuilder:(r,e)=>{var t=Xr(r.body,e);return t instanceof hn||(t=new hn("mrow",[t])),t.setAttribute("href",r.href),t}});te({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(r,e)=>{var{parser:t}=r,n=ye(e[0],"url").url;if(!t.settings.isTrusted({command:"\\url",url:n}))return t.formatUnsupportedCmd("\\url");for(var i=[],s=0;s<n.length;s++){var a=n[s];a==="~"&&(a="\\textasciitilde"),i.push({type:"textord",mode:"text",text:a})}var A={type:"text",mode:t.mode,font:"\\texttt",body:i};return{type:"href",mode:t.mode,href:n,body:At(A)}}});te({type:"hbox",names:["\\hbox"],props:{numArgs:1,argTypes:["text"],allowedInText:!0,primitive:!0},handler(r,e){var{parser:t}=r;return{type:"hbox",mode:t.mode,body:At(e[0])}},htmlBuilder(r,e){var t=mt(r.body,e,!1);return P.makeFragment(t)},mathmlBuilder(r,e){return new q.MathNode("mrow",Zt(r.body,e))}});te({type:"html",names:["\\htmlClass","\\htmlId","\\htmlStyle","\\htmlData"],props:{numArgs:2,argTypes:["raw","original"],allowedInText:!0},handler:(r,e)=>{var{parser:t,funcName:n,token:i}=r,s=ye(e[0],"raw").string,a=e[1];t.settings.strict&&t.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var A,o={};switch(n){case"\\htmlClass":o.class=s,A={command:"\\htmlClass",class:s};break;case"\\htmlId":o.id=s,A={command:"\\htmlId",id:s};break;case"\\htmlStyle":o.style=s,A={command:"\\htmlStyle",style:s};break;case"\\htmlData":{for(var c=s.split(","),l=0;l<c.length;l++){var d=c[l].split("=");if(d.length!==2)throw new W("Error parsing key-value for \\htmlData");o["data-"+d[0].trim()]=d[1].trim()}A={command:"\\htmlData",attributes:o};break}default:throw new Error("Unrecognized html command")}return t.settings.isTrusted(A)?{type:"html",mode:t.mode,attributes:o,body:At(a)}:t.formatUnsupportedCmd(n)},htmlBuilder:(r,e)=>{var t=mt(r.body,e,!1),n=["enclosing"];r.attributes.class&&n.push(...r.attributes.class.trim().split(/\s+/));var i=P.makeSpan(n,t,e);for(var s in r.attributes)s!=="class"&&r.attributes.hasOwnProperty(s)&&i.setAttribute(s,r.attributes[s]);return i},mathmlBuilder:(r,e)=>Xr(r.body,e)});te({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInText:!0},handler:(r,e)=>{var{parser:t}=r;return{type:"htmlmathml",mode:t.mode,html:At(e[0]),mathml:At(e[1])}},htmlBuilder:(r,e)=>{var t=mt(r.html,e,!1);return P.makeFragment(t)},mathmlBuilder:(r,e)=>Xr(r.mathml,e)});var gl=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new W("Invalid size: '"+e+"' in \\includegraphics");var n={number:+(t[1]+t[2]),unit:t[3]};if(!Tv(n))throw new W("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n};te({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:(r,e,t)=>{var{parser:n}=r,i={number:0,unit:"em"},s={number:.9,unit:"em"},a={number:0,unit:"em"},A="";if(t[0])for(var o=ye(t[0],"raw").string,c=o.split(","),l=0;l<c.length;l++){var d=c[l].split("=");if(d.length===2){var u=d[1].trim();switch(d[0].trim()){case"alt":A=u;break;case"width":i=gl(u);break;case"height":s=gl(u);break;case"totalheight":a=gl(u);break;default:throw new W("Invalid key: '"+d[0]+"' in \\includegraphics.")}}}var h=ye(e[0],"url").url;return A===""&&(A=h,A=A.replace(/^.*[\\/]/,""),A=A.substring(0,A.lastIndexOf("."))),n.settings.isTrusted({command:"\\includegraphics",url:h})?{type:"includegraphics",mode:n.mode,alt:A,width:i,height:s,totalheight:a,src:h}:n.formatUnsupportedCmd("\\includegraphics")},htmlBuilder:(r,e)=>{var t=Ze(r.height,e),n=0;r.totalheight.number>0&&(n=Ze(r.totalheight,e)-t);var i=0;r.width.number>0&&(i=Ze(r.width,e));var s={height:j(t+n)};i>0&&(s.width=j(i)),n>0&&(s.verticalAlign=j(-n));var a=new G7(r.src,r.alt,s);return a.height=t,a.depth=n,a},mathmlBuilder:(r,e)=>{var t=new q.MathNode("mglyph",[]);t.setAttribute("alt",r.alt);var n=Ze(r.height,e),i=0;if(r.totalheight.number>0&&(i=Ze(r.totalheight,e)-n,t.setAttribute("valign",j(-i))),t.setAttribute("height",j(n+i)),r.width.number>0){var s=Ze(r.width,e);t.setAttribute("width",j(s))}return t.setAttribute("src",r.src),t}});te({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler(r,e){var{parser:t,funcName:n}=r,i=ye(e[0],"size");if(t.settings.strict){var s=n[1]==="m",a=i.value.unit==="mu";s?(a||t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, "+("not "+i.value.unit+" units")),t.mode!=="math"&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):a&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:t.mode,dimension:i.value}},htmlBuilder(r,e){return P.makeGlue(r.dimension,e)},mathmlBuilder(r,e){var t=Ze(r.dimension,e);return new q.SpaceNode(t)}});te({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"lap",mode:t.mode,alignment:n.slice(5),body:i}},htmlBuilder:(r,e)=>{var t;r.alignment==="clap"?(t=P.makeSpan([],[xe(r.body,e)]),t=P.makeSpan(["inner"],[t],e)):t=P.makeSpan(["inner"],[xe(r.body,e)]);var n=P.makeSpan(["fix"],[]),i=P.makeSpan([r.alignment],[t,n],e),s=P.makeSpan(["strut"]);return s.style.height=j(i.height+i.depth),i.depth&&(s.style.verticalAlign=j(-i.depth)),i.children.unshift(s),i=P.makeSpan(["thinbox"],[i],e),P.makeSpan(["mord","vbox"],[i],e)},mathmlBuilder:(r,e)=>{var t=new q.MathNode("mpadded",[Le(r.body,e)]);if(r.alignment!=="rlap"){var n=r.alignment==="llap"?"-1":"-0.5";t.setAttribute("lspace",n+"width")}return t.setAttribute("width","0px"),t}});te({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(r,e){var{funcName:t,parser:n}=r,i=n.mode;n.switchMode("math");var s=t==="\\("?"\\)":"$",a=n.parseExpression(!1,s);return n.expect(s),n.switchMode(i),{type:"styling",mode:n.mode,style:"text",body:a}}});te({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(r,e){throw new W("Mismatched "+r.funcName)}});var up=(r,e)=>{switch(e.style.size){case de.DISPLAY.size:return r.display;case de.TEXT.size:return r.text;case de.SCRIPT.size:return r.script;case de.SCRIPTSCRIPT.size:return r.scriptscript;default:return r.text}};te({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(r,e)=>{var{parser:t}=r;return{type:"mathchoice",mode:t.mode,display:At(e[0]),text:At(e[1]),script:At(e[2]),scriptscript:At(e[3])}},htmlBuilder:(r,e)=>{var t=up(r,e),n=mt(t,e,!1);return P.makeFragment(n)},mathmlBuilder:(r,e)=>{var t=up(r,e);return Xr(t,e)}});var oy=(r,e,t,n,i,s,a)=>{r=P.makeSpan([],[r]);var A=t&&ce.isCharacterBox(t),o,c;if(e){var l=xe(e,n.havingStyle(i.sup()),n);c={elem:l,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-l.depth)}}if(t){var d=xe(t,n.havingStyle(i.sub()),n);o={elem:d,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-d.height)}}var u;if(c&&o){var h=n.fontMetrics().bigOpSpacing5+o.elem.height+o.elem.depth+o.kern+r.depth+a;u=P.makeVList({positionType:"bottom",positionData:h,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:o.elem,marginLeft:j(-s)},{type:"kern",size:o.kern},{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:j(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}else if(o){var p=r.height-a;u=P.makeVList({positionType:"top",positionData:p,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:o.elem,marginLeft:j(-s)},{type:"kern",size:o.kern},{type:"elem",elem:r}]},n)}else if(c){var g=r.depth+a;u=P.makeVList({positionType:"bottom",positionData:g,children:[{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:j(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}else return r;var v=[u];if(o&&s!==0&&!A){var w=P.makeSpan(["mspace"],[],n);w.style.marginRight=j(s),v.unshift(w)}return P.makeSpan(["mop","op-limits"],v,n)},cy=["\\smallint"],ps=(r,e)=>{var t,n,i=!1,s;r.type==="supsub"?(t=r.sup,n=r.sub,s=ye(r.base,"op"),i=!0):s=ye(r,"op");var a=e.style,A=!1;a.size===de.DISPLAY.size&&s.symbol&&!ce.contains(cy,s.name)&&(A=!0);var o;if(s.symbol){var c=A?"Size2-Regular":"Size1-Regular",l="";if((s.name==="\\oiint"||s.name==="\\oiiint")&&(l=s.name.slice(1),s.name=l==="oiint"?"\\iint":"\\iiint"),o=P.makeSymbol(s.name,c,"math",e,["mop","op-symbol",A?"large-op":"small-op"]),l.length>0){var d=o.italic,u=P.staticSvg(l+"Size"+(A?"2":"1"),e);o=P.makeVList({positionType:"individualShift",children:[{type:"elem",elem:o,shift:0},{type:"elem",elem:u,shift:A?.08:0}]},e),s.name="\\"+l,o.classes.unshift("mop"),o.italic=d}}else if(s.body){var h=mt(s.body,e,!0);h.length===1&&h[0]instanceof vn?(o=h[0],o.classes[0]="mop"):o=P.makeSpan(["mop"],h,e)}else{for(var p=[],g=1;g<s.name.length;g++)p.push(P.mathsym(s.name[g],s.mode,e));o=P.makeSpan(["mop"],p,e)}var v=0,w=0;return(o instanceof vn||s.name==="\\oiint"||s.name==="\\oiiint")&&!s.suppressBaseShift&&(v=(o.height-o.depth)/2-e.fontMetrics().axisHeight,w=o.italic),i?oy(o,t,n,e,a,w,v):(v&&(o.style.position="relative",o.style.top=j(v)),o)},Fa=(r,e)=>{var t;if(r.symbol)t=new hn("mo",[yn(r.name,r.mode)]),ce.contains(cy,r.name)&&t.setAttribute("largeop","false");else if(r.body)t=new hn("mo",Zt(r.body,e));else{t=new hn("mi",[new ra(r.name.slice(1))]);var n=new hn("mo",[yn("","text")]);r.parentIsSupSub?t=new hn("mrow",[t,n]):t=Dv([t,n])}return t},q8={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨆":"\\bigsqcup"};te({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨄","⨆"],props:{numArgs:0},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=n;return i.length===1&&(i=q8[i]),{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:i}},htmlBuilder:ps,mathmlBuilder:Fa});te({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:At(n)}},htmlBuilder:ps,mathmlBuilder:Fa});var W8={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint"};te({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler(r){var{parser:e,funcName:t}=r;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:t}},htmlBuilder:ps,mathmlBuilder:Fa});te({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler(r){var{parser:e,funcName:t}=r;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:t}},htmlBuilder:ps,mathmlBuilder:Fa});te({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","∫","∬","∭","∮","∯","∰"],props:{numArgs:0},handler(r){var{parser:e,funcName:t}=r,n=t;return n.length===1&&(n=W8[n]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:ps,mathmlBuilder:Fa});var ly=(r,e)=>{var t,n,i=!1,s;r.type==="supsub"?(t=r.sup,n=r.sub,s=ye(r.base,"operatorname"),i=!0):s=ye(r,"operatorname");var a;if(s.body.length>0){for(var A=s.body.map(d=>{var u=d.text;return typeof u=="string"?{type:"textord",mode:d.mode,text:u}:d}),o=mt(A,e.withFont("mathrm"),!0),c=0;c<o.length;c++){var l=o[c];l instanceof vn&&(l.text=l.text.replace(/\u2212/,"-").replace(/\u2217/,"*"))}a=P.makeSpan(["mop"],o,e)}else a=P.makeSpan(["mop"],[],e);return i?oy(a,t,n,e,e.style,0,0):a},$8=(r,e)=>{for(var t=Zt(r.body,e.withFont("mathrm")),n=!0,i=0;i<t.length;i++){var s=t[i];if(!(s instanceof q.SpaceNode))if(s instanceof q.MathNode)switch(s.type){case"mi":case"mn":case"ms":case"mspace":case"mtext":break;case"mo":{var a=s.children[0];s.children.length===1&&a instanceof q.TextNode?a.text=a.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):n=!1;break}default:n=!1}else n=!1}if(n){var A=t.map(l=>l.toText()).join("");t=[new q.TextNode(A)]}var o=new q.MathNode("mi",t);o.setAttribute("mathvariant","normal");var c=new q.MathNode("mo",[yn("","text")]);return r.parentIsSupSub?new q.MathNode("mrow",[o,c]):q.newDocumentFragment([o,c])};te({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0];return{type:"operatorname",mode:t.mode,body:At(i),alwaysHandleSupSub:n==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1}},htmlBuilder:ly,mathmlBuilder:$8});S("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@");Ei({type:"ordgroup",htmlBuilder(r,e){return r.semisimple?P.makeFragment(mt(r.body,e,!1)):P.makeSpan(["mord"],mt(r.body,e,!0),e)},mathmlBuilder(r,e){return Xr(r.body,e,!0)}});te({type:"overline",names:["\\overline"],props:{numArgs:1},handler(r,e){var{parser:t}=r,n=e[0];return{type:"overline",mode:t.mode,body:n}},htmlBuilder(r,e){var t=xe(r.body,e.havingCrampedStyle()),n=P.makeLineSpan("overline-line",e),i=e.fontMetrics().defaultRuleThickness,s=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t},{type:"kern",size:3*i},{type:"elem",elem:n},{type:"kern",size:i}]},e);return P.makeSpan(["mord","overline"],[s],e)},mathmlBuilder(r,e){var t=new q.MathNode("mo",[new q.TextNode("‾")]);t.setAttribute("stretchy","true");var n=new q.MathNode("mover",[Le(r.body,e),t]);return n.setAttribute("accent","true"),n}});te({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"phantom",mode:t.mode,body:At(n)}},htmlBuilder:(r,e)=>{var t=mt(r.body,e.withPhantom(),!1);return P.makeFragment(t)},mathmlBuilder:(r,e)=>{var t=Zt(r.body,e);return new q.MathNode("mphantom",t)}});te({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"hphantom",mode:t.mode,body:n}},htmlBuilder:(r,e)=>{var t=P.makeSpan([],[xe(r.body,e.withPhantom())]);if(t.height=0,t.depth=0,t.children)for(var n=0;n<t.children.length;n++)t.children[n].height=0,t.children[n].depth=0;return t=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t}]},e),P.makeSpan(["mord"],[t],e)},mathmlBuilder:(r,e)=>{var t=Zt(At(r.body),e),n=new q.MathNode("mphantom",t),i=new q.MathNode("mpadded",[n]);return i.setAttribute("height","0px"),i.setAttribute("depth","0px"),i}});te({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:(r,e)=>{var{parser:t}=r,n=e[0];return{type:"vphantom",mode:t.mode,body:n}},htmlBuilder:(r,e)=>{var t=P.makeSpan(["inner"],[xe(r.body,e.withPhantom())]),n=P.makeSpan(["fix"],[]);return P.makeSpan(["mord","rlap"],[t,n],e)},mathmlBuilder:(r,e)=>{var t=Zt(At(r.body),e),n=new q.MathNode("mphantom",t),i=new q.MathNode("mpadded",[n]);return i.setAttribute("width","0px"),i}});te({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(r,e){var{parser:t}=r,n=ye(e[0],"size").value,i=e[1];return{type:"raisebox",mode:t.mode,dy:n,body:i}},htmlBuilder(r,e){var t=xe(r.body,e),n=Ze(r.dy,e);return P.makeVList({positionType:"shift",positionData:-n,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(r,e){var t=new q.MathNode("mpadded",[Le(r.body,e)]),n=r.dy.number+r.dy.unit;return t.setAttribute("voffset",n),t}});te({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler(r){var{parser:e}=r;return{type:"internal",mode:e.mode}}});te({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,argTypes:["size","size","size"]},handler(r,e,t){var{parser:n}=r,i=t[0],s=ye(e[0],"size"),a=ye(e[1],"size");return{type:"rule",mode:n.mode,shift:i&&ye(i,"size").value,width:s.value,height:a.value}},htmlBuilder(r,e){var t=P.makeSpan(["mord","rule"],[],e),n=Ze(r.width,e),i=Ze(r.height,e),s=r.shift?Ze(r.shift,e):0;return t.style.borderRightWidth=j(n),t.style.borderTopWidth=j(i),t.style.bottom=j(s),t.width=n,t.height=i+s,t.depth=-s,t.maxFontSize=i*1.125*e.sizeMultiplier,t},mathmlBuilder(r,e){var t=Ze(r.width,e),n=Ze(r.height,e),i=r.shift?Ze(r.shift,e):0,s=e.color&&e.getColor()||"black",a=new q.MathNode("mspace");a.setAttribute("mathbackground",s),a.setAttribute("width",j(t)),a.setAttribute("height",j(n));var A=new q.MathNode("mpadded",[a]);return i>=0?A.setAttribute("height",j(i)):(A.setAttribute("height",j(i)),A.setAttribute("depth",j(-i))),A.setAttribute("voffset",j(i)),A}});function dy(r,e,t){for(var n=mt(r,e,!1),i=e.sizeMultiplier/t.sizeMultiplier,s=0;s<n.length;s++){var a=n[s].classes.indexOf("sizing");a<0?Array.prototype.push.apply(n[s].classes,e.sizingClasses(t)):n[s].classes[a+1]==="reset-size"+e.size&&(n[s].classes[a+1]="reset-size"+t.size),n[s].height*=i,n[s].depth*=i}return P.makeFragment(n)}var hp=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],j8=(r,e)=>{var t=e.havingSize(r.size);return dy(r.body,t,e)};te({type:"sizing",names:hp,props:{numArgs:0,allowedInText:!0},handler:(r,e)=>{var{breakOnTokenText:t,funcName:n,parser:i}=r,s=i.parseExpression(!1,t);return{type:"sizing",mode:i.mode,size:hp.indexOf(n)+1,body:s}},htmlBuilder:j8,mathmlBuilder:(r,e)=>{var t=e.havingSize(r.size),n=Zt(r.body,t),i=new q.MathNode("mstyle",n);return i.setAttribute("mathsize",j(t.sizeMultiplier)),i}});te({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:(r,e,t)=>{var{parser:n}=r,i=!1,s=!1,a=t[0]&&ye(t[0],"ordgroup");if(a)for(var A="",o=0;o<a.body.length;++o){var c=a.body[o];if(A=c.text,A==="t")i=!0;else if(A==="b")s=!0;else{i=!1,s=!1;break}}else i=!0,s=!0;var l=e[0];return{type:"smash",mode:n.mode,body:l,smashHeight:i,smashDepth:s}},htmlBuilder:(r,e)=>{var t=P.makeSpan([],[xe(r.body,e)]);if(!r.smashHeight&&!r.smashDepth)return t;if(r.smashHeight&&(t.height=0,t.children))for(var n=0;n<t.children.length;n++)t.children[n].height=0;if(r.smashDepth&&(t.depth=0,t.children))for(var i=0;i<t.children.length;i++)t.children[i].depth=0;var s=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t}]},e);return P.makeSpan(["mord"],[s],e)},mathmlBuilder:(r,e)=>{var t=new q.MathNode("mpadded",[Le(r.body,e)]);return r.smashHeight&&t.setAttribute("height","0px"),r.smashDepth&&t.setAttribute("depth","0px"),t}});te({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler(r,e,t){var{parser:n}=r,i=t[0],s=e[0];return{type:"sqrt",mode:n.mode,body:s,index:i}},htmlBuilder(r,e){var t=xe(r.body,e.havingCrampedStyle());t.height===0&&(t.height=e.fontMetrics().xHeight),t=P.wrapFragment(t,e);var n=e.fontMetrics(),i=n.defaultRuleThickness,s=i;e.style.id<de.TEXT.id&&(s=e.fontMetrics().xHeight);var a=i+s/4,A=t.height+t.depth+a+i,{span:o,ruleWidth:c,advanceWidth:l}=yr.sqrtImage(A,e),d=o.height-c;d>t.height+t.depth+a&&(a=(a+d-t.height-t.depth)/2);var u=o.height-t.height-a-c;t.style.paddingLeft=j(l);var h=P.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t,wrapperClasses:["svg-align"]},{type:"kern",size:-(t.height+u)},{type:"elem",elem:o},{type:"kern",size:c}]},e);if(r.index){var p=e.havingStyle(de.SCRIPTSCRIPT),g=xe(r.index,p,e),v=.6*(h.height-h.depth),w=P.makeVList({positionType:"shift",positionData:-v,children:[{type:"elem",elem:g}]},e),B=P.makeSpan(["root"],[w]);return P.makeSpan(["mord","sqrt"],[B,h],e)}else return P.makeSpan(["mord","sqrt"],[h],e)},mathmlBuilder(r,e){var{body:t,index:n}=r;return n?new q.MathNode("mroot",[Le(t,e),Le(n,e)]):new q.MathNode("msqrt",[Le(t,e)])}});var fp={display:de.DISPLAY,text:de.TEXT,script:de.SCRIPT,scriptscript:de.SCRIPTSCRIPT};te({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(r,e){var{breakOnTokenText:t,funcName:n,parser:i}=r,s=i.parseExpression(!0,t),a=n.slice(1,n.length-5);return{type:"styling",mode:i.mode,style:a,body:s}},htmlBuilder(r,e){var t=fp[r.style],n=e.havingStyle(t).withFont("");return dy(r.body,n,e)},mathmlBuilder(r,e){var t=fp[r.style],n=e.havingStyle(t),i=Zt(r.body,n),s=new q.MathNode("mstyle",i),a={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]},A=a[r.style];return s.setAttribute("scriptlevel",A[0]),s.setAttribute("displaystyle",A[1]),s}});var X8=function(e,t){var n=e.base;if(n)if(n.type==="op"){var i=n.limits&&(t.style.size===de.DISPLAY.size||n.alwaysHandleSupSub);return i?ps:null}else if(n.type==="operatorname"){var s=n.alwaysHandleSupSub&&(t.style.size===de.DISPLAY.size||n.limits);return s?ly:null}else{if(n.type==="accent")return ce.isCharacterBox(n.base)?Vu:null;if(n.type==="horizBrace"){var a=!e.sub;return a===n.isOver?Ay:null}else return null}else return null};Ei({type:"supsub",htmlBuilder(r,e){var t=X8(r,e);if(t)return t(r,e);var{base:n,sup:i,sub:s}=r,a=xe(n,e),A,o,c=e.fontMetrics(),l=0,d=0,u=n&&ce.isCharacterBox(n);if(i){var h=e.havingStyle(e.style.sup());A=xe(i,h,e),u||(l=a.height-h.fontMetrics().supDrop*h.sizeMultiplier/e.sizeMultiplier)}if(s){var p=e.havingStyle(e.style.sub());o=xe(s,p,e),u||(d=a.depth+p.fontMetrics().subDrop*p.sizeMultiplier/e.sizeMultiplier)}var g;e.style===de.DISPLAY?g=c.sup1:e.style.cramped?g=c.sup3:g=c.sup2;var v=e.sizeMultiplier,w=j(.5/c.ptPerEm/v),B=null;if(o){var E=r.base&&r.base.type==="op"&&r.base.name&&(r.base.name==="\\oiint"||r.base.name==="\\oiiint");(a instanceof vn||E)&&(B=j(-a.italic))}var b;if(A&&o){l=Math.max(l,g,A.depth+.25*c.xHeight),d=Math.max(d,c.sub2);var C=c.defaultRuleThickness,T=4*C;if(l-A.depth-(o.height-d)<T){d=T-(l-A.depth)+o.height;var F=.8*c.xHeight-(l-A.depth);F>0&&(l+=F,d-=F)}var R=[{type:"elem",elem:o,shift:d,marginRight:w,marginLeft:B},{type:"elem",elem:A,shift:-l,marginRight:w}];b=P.makeVList({positionType:"individualShift",children:R},e)}else if(o){d=Math.max(d,c.sub1,o.height-.8*c.xHeight);var M=[{type:"elem",elem:o,marginLeft:B,marginRight:w}];b=P.makeVList({positionType:"shift",positionData:d,children:M},e)}else if(A)l=Math.max(l,g,A.depth+.25*c.xHeight),b=P.makeVList({positionType:"shift",positionData:-l,children:[{type:"elem",elem:A,marginRight:w}]},e);else throw new Error("supsub must have either sup or sub.");var D=Rd(a,"right")||"mord";return P.makeSpan([D],[a,P.makeSpan(["msupsub"],[b])],e)},mathmlBuilder(r,e){var t=!1,n,i;r.base&&r.base.type==="horizBrace"&&(i=!!r.sup,i===r.base.isOver&&(t=!0,n=r.base.isOver)),r.base&&(r.base.type==="op"||r.base.type==="operatorname")&&(r.base.parentIsSupSub=!0);var s=[Le(r.base,e)];r.sub&&s.push(Le(r.sub,e)),r.sup&&s.push(Le(r.sup,e));var a;if(t)a=n?"mover":"munder";else if(r.sub)if(r.sup){var c=r.base;c&&c.type==="op"&&c.limits&&e.style===de.DISPLAY||c&&c.type==="operatorname"&&c.alwaysHandleSupSub&&(e.style===de.DISPLAY||c.limits)?a="munderover":a="msubsup"}else{var o=r.base;o&&o.type==="op"&&o.limits&&(e.style===de.DISPLAY||o.alwaysHandleSupSub)||o&&o.type==="operatorname"&&o.alwaysHandleSupSub&&(o.limits||e.style===de.DISPLAY)?a="munder":a="msub"}else{var A=r.base;A&&A.type==="op"&&A.limits&&(e.style===de.DISPLAY||A.alwaysHandleSupSub)||A&&A.type==="operatorname"&&A.alwaysHandleSupSub&&(A.limits||e.style===de.DISPLAY)?a="mover":a="msup"}return new q.MathNode(a,s)}});Ei({type:"atom",htmlBuilder(r,e){return P.mathsym(r.text,r.mode,e,["m"+r.family])},mathmlBuilder(r,e){var t=new q.MathNode("mo",[yn(r.text,r.mode)]);if(r.family==="bin"){var n=Nu(r,e);n==="bold-italic"&&t.setAttribute("mathvariant",n)}else r.family==="punct"?t.setAttribute("separator","true"):(r.family==="open"||r.family==="close")&&t.setAttribute("stretchy","false");return t}});var uy={mi:"italic",mn:"normal",mtext:"normal"};Ei({type:"mathord",htmlBuilder(r,e){return P.makeOrd(r,e,"mathord")},mathmlBuilder(r,e){var t=new q.MathNode("mi",[yn(r.text,r.mode,e)]),n=Nu(r,e)||"italic";return n!==uy[t.type]&&t.setAttribute("mathvariant",n),t}});Ei({type:"textord",htmlBuilder(r,e){return P.makeOrd(r,e,"textord")},mathmlBuilder(r,e){var t=yn(r.text,r.mode,e),n=Nu(r,e)||"normal",i;return r.mode==="text"?i=new q.MathNode("mtext",[t]):/[0-9]/.test(r.text)?i=new q.MathNode("mn",[t]):r.text==="\\prime"?i=new q.MathNode("mo",[t]):i=new q.MathNode("mi",[t]),n!==uy[i.type]&&i.setAttribute("mathvariant",n),i}});var vl={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},yl={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};Ei({type:"spacing",htmlBuilder(r,e){if(yl.hasOwnProperty(r.text)){var t=yl[r.text].className||"";if(r.mode==="text"){var n=P.makeOrd(r,e,"textord");return n.classes.push(t),n}else return P.makeSpan(["mspace",t],[P.mathsym(r.text,r.mode,e)],e)}else{if(vl.hasOwnProperty(r.text))return P.makeSpan(["mspace",vl[r.text]],[],e);throw new W('Unknown type of space "'+r.text+'"')}},mathmlBuilder(r,e){var t;if(yl.hasOwnProperty(r.text))t=new q.MathNode("mtext",[new q.TextNode(" ")]);else{if(vl.hasOwnProperty(r.text))return new q.MathNode("mspace");throw new W('Unknown type of space "'+r.text+'"')}return t}});var pp=()=>{var r=new q.MathNode("mtd",[]);return r.setAttribute("width","50%"),r};Ei({type:"tag",mathmlBuilder(r,e){var t=new q.MathNode("mtable",[new q.MathNode("mtr",[pp(),new q.MathNode("mtd",[Xr(r.body,e)]),pp(),new q.MathNode("mtd",[Xr(r.tag,e)])])]);return t.setAttribute("width","100%"),t}});var mp={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},gp={"\\textbf":"textbf","\\textmd":"textmd"},J8={"\\textit":"textit","\\textup":"textup"},vp=(r,e)=>{var t=r.font;if(t){if(mp[t])return e.withTextFontFamily(mp[t]);if(gp[t])return e.withTextFontWeight(gp[t]);if(t==="\\emph")return e.fontShape==="textit"?e.withTextFontShape("textup"):e.withTextFontShape("textit")}else return e;return e.withTextFontShape(J8[t])};te({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler(r,e){var{parser:t,funcName:n}=r,i=e[0];return{type:"text",mode:t.mode,body:At(i),font:n}},htmlBuilder(r,e){var t=vp(r,e),n=mt(r.body,t,!0);return P.makeSpan(["mord","text"],n,t)},mathmlBuilder(r,e){var t=vp(r,e);return Xr(r.body,t)}});te({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler(r,e){var{parser:t}=r;return{type:"underline",mode:t.mode,body:e[0]}},htmlBuilder(r,e){var t=xe(r.body,e),n=P.makeLineSpan("underline-line",e),i=e.fontMetrics().defaultRuleThickness,s=P.makeVList({positionType:"top",positionData:t.height,children:[{type:"kern",size:i},{type:"elem",elem:n},{type:"kern",size:3*i},{type:"elem",elem:t}]},e);return P.makeSpan(["mord","underline"],[s],e)},mathmlBuilder(r,e){var t=new q.MathNode("mo",[new q.TextNode("‾")]);t.setAttribute("stretchy","true");var n=new q.MathNode("munder",[Le(r.body,e),t]);return n.setAttribute("accentunder","true"),n}});te({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler(r,e){var{parser:t}=r;return{type:"vcenter",mode:t.mode,body:e[0]}},htmlBuilder(r,e){var t=xe(r.body,e),n=e.fontMetrics().axisHeight,i=.5*(t.height-n-(t.depth+n));return P.makeVList({positionType:"shift",positionData:i,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(r,e){return new q.MathNode("mpadded",[Le(r.body,e)],["vcenter"])}});te({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(r,e,t){throw new W("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(r,e){for(var t=yp(r),n=[],i=e.havingStyle(e.style.text()),s=0;s<t.length;s++){var a=t[s];a==="~"&&(a="\\textasciitilde"),n.push(P.makeSymbol(a,"Typewriter-Regular",r.mode,i,["mord","texttt"]))}return P.makeSpan(["mord","text"].concat(i.sizingClasses(e)),P.tryCombineChars(n),i)},mathmlBuilder(r,e){var t=new q.TextNode(yp(r)),n=new q.MathNode("mtext",[t]);return n.setAttribute("mathvariant","monospace"),n}});var yp=r=>r.body.replace(/ /g,r.star?"␣":" "),pi=Rv,hy=`[ \r
|
|
368
|
+
]`,Y8="\\\\[a-zA-Z@]+",Z8="\\\\[^\uD800-\uDFFF]",eE="("+Y8+")"+hy+"*",tE=`\\\\(
|
|
369
|
+
|[ \r ]+
|
|
370
|
+
?)[ \r ]*`,Od="[̀-ͯ]",nE=new RegExp(Od+"+$"),rE="("+hy+"+)|"+(tE+"|")+"([!-\\[\\]-‧-豈-]"+(Od+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(Od+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+eE)+("|"+Z8+")");class wp{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(rE,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new gn("EOF",new rn(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new W("Unexpected character: '"+e[t]+"'",new gn(e[t],new rn(this,t,t+1)));var i=n[6]||n[3]||(n[2]?"\\ ":" ");if(this.catcodes[i]===14){var s=e.indexOf(`
|
|
371
|
+
`,this.tokenRegex.lastIndex);return s===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=s+1,this.lex()}return new gn(i,new rn(this,t,this.tokenRegex.lastIndex))}}class iE{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new W("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var t in e)e.hasOwnProperty(t)&&(e[t]==null?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var i=0;i<this.undefStack.length;i++)delete this.undefStack[i][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var s=this.undefStack[this.undefStack.length-1];s&&!s.hasOwnProperty(e)&&(s[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}}var sE=ny;S("\\noexpand",function(r){var e=r.popToken();return r.isExpandable(e.text)&&(e.noexpand=!0,e.treatAsRelax=!0),{tokens:[e],numArgs:0}});S("\\expandafter",function(r){var e=r.popToken();return r.expandOnce(!0),{tokens:[e],numArgs:0}});S("\\@firstoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[0],numArgs:0}});S("\\@secondoftwo",function(r){var e=r.consumeArgs(2);return{tokens:e[1],numArgs:0}});S("\\@ifnextchar",function(r){var e=r.consumeArgs(3);r.consumeSpaces();var t=r.future();return e[0].length===1&&e[0][0].text===t.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}});S("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}");S("\\TextOrMath",function(r){var e=r.consumeArgs(2);return r.mode==="text"?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});var bp={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};S("\\char",function(r){var e=r.popToken(),t,n="";if(e.text==="'")t=8,e=r.popToken();else if(e.text==='"')t=16,e=r.popToken();else if(e.text==="`")if(e=r.popToken(),e.text[0]==="\\")n=e.text.charCodeAt(1);else{if(e.text==="EOF")throw new W("\\char` missing argument");n=e.text.charCodeAt(0)}else t=10;if(t){if(n=bp[e.text],n==null||n>=t)throw new W("Invalid base-"+t+" digit "+e.text);for(var i;(i=bp[r.future().text])!=null&&i<t;)n*=t,n+=i,r.popToken()}return"\\@char{"+n+"}"});var Ju=(r,e,t)=>{var n=r.consumeArg().tokens;if(n.length!==1)throw new W("\\newcommand's first argument must be a macro name");var i=n[0].text,s=r.isDefined(i);if(s&&!e)throw new W("\\newcommand{"+i+"} attempting to redefine "+(i+"; use \\renewcommand"));if(!s&&!t)throw new W("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");var a=0;if(n=r.consumeArg().tokens,n.length===1&&n[0].text==="["){for(var A="",o=r.expandNextToken();o.text!=="]"&&o.text!=="EOF";)A+=o.text,o=r.expandNextToken();if(!A.match(/^\s*[0-9]+\s*$/))throw new W("Invalid number of arguments: "+A);a=parseInt(A),n=r.consumeArg().tokens}return r.macros.set(i,{tokens:n,numArgs:a}),""};S("\\newcommand",r=>Ju(r,!1,!0));S("\\renewcommand",r=>Ju(r,!0,!1));S("\\providecommand",r=>Ju(r,!0,!0));S("\\message",r=>{var e=r.consumeArgs(1)[0];return""});S("\\errmessage",r=>{var e=r.consumeArgs(1)[0];return""});S("\\show",r=>{var e=r.popToken(),t=e.text;return""});S("\\bgroup","{");S("\\egroup","}");S("~","\\nobreakspace");S("\\lq","`");S("\\rq","'");S("\\aa","\\r a");S("\\AA","\\r A");S("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}");S("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");S("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}");S("ℬ","\\mathscr{B}");S("ℰ","\\mathscr{E}");S("ℱ","\\mathscr{F}");S("ℋ","\\mathscr{H}");S("ℐ","\\mathscr{I}");S("ℒ","\\mathscr{L}");S("ℳ","\\mathscr{M}");S("ℛ","\\mathscr{R}");S("ℭ","\\mathfrak{C}");S("ℌ","\\mathfrak{H}");S("ℨ","\\mathfrak{Z}");S("\\Bbbk","\\Bbb{k}");S("·","\\cdotp");S("\\llap","\\mathllap{\\textrm{#1}}");S("\\rlap","\\mathrlap{\\textrm{#1}}");S("\\clap","\\mathclap{\\textrm{#1}}");S("\\mathstrut","\\vphantom{(}");S("\\underbar","\\underline{\\text{#1}}");S("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}');S("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}");S("\\ne","\\neq");S("≠","\\neq");S("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}");S("∉","\\notin");S("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}");S("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}");S("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}");S("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}");S("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}");S("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}");S("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}");S("⟂","\\perp");S("‼","\\mathclose{!\\mkern-0.8mu!}");S("∌","\\notni");S("⌜","\\ulcorner");S("⌝","\\urcorner");S("⌞","\\llcorner");S("⌟","\\lrcorner");S("©","\\copyright");S("®","\\textregistered");S("️","\\textregistered");S("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}');S("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}');S("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}');S("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}');S("\\vdots","\\mathord{\\varvdots\\rule{0pt}{15pt}}");S("⋮","\\vdots");S("\\varGamma","\\mathit{\\Gamma}");S("\\varDelta","\\mathit{\\Delta}");S("\\varTheta","\\mathit{\\Theta}");S("\\varLambda","\\mathit{\\Lambda}");S("\\varXi","\\mathit{\\Xi}");S("\\varPi","\\mathit{\\Pi}");S("\\varSigma","\\mathit{\\Sigma}");S("\\varUpsilon","\\mathit{\\Upsilon}");S("\\varPhi","\\mathit{\\Phi}");S("\\varPsi","\\mathit{\\Psi}");S("\\varOmega","\\mathit{\\Omega}");S("\\substack","\\begin{subarray}{c}#1\\end{subarray}");S("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");S("\\boxed","\\fbox{$\\displaystyle{#1}$}");S("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");S("\\implies","\\DOTSB\\;\\Longrightarrow\\;");S("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");var Bp={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};S("\\dots",function(r){var e="\\dotso",t=r.expandAfterFuture().text;return t in Bp?e=Bp[t]:(t.slice(0,4)==="\\not"||t in Ve.math&&ce.contains(["bin","rel"],Ve.math[t].group))&&(e="\\dotsb"),e});var Yu={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};S("\\dotso",function(r){var e=r.future().text;return e in Yu?"\\ldots\\,":"\\ldots"});S("\\dotsc",function(r){var e=r.future().text;return e in Yu&&e!==","?"\\ldots\\,":"\\ldots"});S("\\cdots",function(r){var e=r.future().text;return e in Yu?"\\@cdots\\,":"\\@cdots"});S("\\dotsb","\\cdots");S("\\dotsm","\\cdots");S("\\dotsi","\\!\\cdots");S("\\dotsx","\\ldots\\,");S("\\DOTSI","\\relax");S("\\DOTSB","\\relax");S("\\DOTSX","\\relax");S("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");S("\\,","\\tmspace+{3mu}{.1667em}");S("\\thinspace","\\,");S("\\>","\\mskip{4mu}");S("\\:","\\tmspace+{4mu}{.2222em}");S("\\medspace","\\:");S("\\;","\\tmspace+{5mu}{.2777em}");S("\\thickspace","\\;");S("\\!","\\tmspace-{3mu}{.1667em}");S("\\negthinspace","\\!");S("\\negmedspace","\\tmspace-{4mu}{.2222em}");S("\\negthickspace","\\tmspace-{5mu}{.277em}");S("\\enspace","\\kern.5em ");S("\\enskip","\\hskip.5em\\relax");S("\\quad","\\hskip1em\\relax");S("\\qquad","\\hskip2em\\relax");S("\\tag","\\@ifstar\\tag@literal\\tag@paren");S("\\tag@paren","\\tag@literal{({#1})}");S("\\tag@literal",r=>{if(r.macros.get("\\df@tag"))throw new W("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});S("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");S("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");S("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");S("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");S("\\newline","\\\\\\relax");S("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var fy=j(Wn["Main-Regular"][84][1]-.7*Wn["Main-Regular"][65][1]);S("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+fy+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");S("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+fy+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}");S("\\hspace","\\@ifstar\\@hspacer\\@hspace");S("\\@hspace","\\hskip #1\\relax");S("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");S("\\ordinarycolon",":");S("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}");S("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}');S("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}');S("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}');S("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}');S("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}');S("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}');S("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}');S("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}');S("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}');S("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}');S("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}');S("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}');S("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}');S("∷","\\dblcolon");S("∹","\\eqcolon");S("≔","\\coloneqq");S("≕","\\eqqcolon");S("⩴","\\Coloneqq");S("\\ratio","\\vcentcolon");S("\\coloncolon","\\dblcolon");S("\\colonequals","\\coloneqq");S("\\coloncolonequals","\\Coloneqq");S("\\equalscolon","\\eqqcolon");S("\\equalscoloncolon","\\Eqqcolon");S("\\colonminus","\\coloneq");S("\\coloncolonminus","\\Coloneq");S("\\minuscolon","\\eqcolon");S("\\minuscoloncolon","\\Eqcolon");S("\\coloncolonapprox","\\Colonapprox");S("\\coloncolonsim","\\Colonsim");S("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");S("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");S("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");S("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");S("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}");S("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");S("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");S("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");S("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");S("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}");S("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}");S("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}");S("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}");S("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}");S("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}");S("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}");S("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}");S("\\nleqq","\\html@mathml{\\@nleqq}{≰}");S("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}");S("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}");S("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}");S("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}");S("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}");S("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}");S("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}");S("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}");S("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}");S("\\imath","\\html@mathml{\\@imath}{ı}");S("\\jmath","\\html@mathml{\\@jmath}{ȷ}");S("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}");S("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}");S("⟦","\\llbracket");S("⟧","\\rrbracket");S("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}");S("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}");S("⦃","\\lBrace");S("⦄","\\rBrace");S("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}");S("⦵","\\minuso");S("\\darr","\\downarrow");S("\\dArr","\\Downarrow");S("\\Darr","\\Downarrow");S("\\lang","\\langle");S("\\rang","\\rangle");S("\\uarr","\\uparrow");S("\\uArr","\\Uparrow");S("\\Uarr","\\Uparrow");S("\\N","\\mathbb{N}");S("\\R","\\mathbb{R}");S("\\Z","\\mathbb{Z}");S("\\alef","\\aleph");S("\\alefsym","\\aleph");S("\\Alpha","\\mathrm{A}");S("\\Beta","\\mathrm{B}");S("\\bull","\\bullet");S("\\Chi","\\mathrm{X}");S("\\clubs","\\clubsuit");S("\\cnums","\\mathbb{C}");S("\\Complex","\\mathbb{C}");S("\\Dagger","\\ddagger");S("\\diamonds","\\diamondsuit");S("\\empty","\\emptyset");S("\\Epsilon","\\mathrm{E}");S("\\Eta","\\mathrm{H}");S("\\exist","\\exists");S("\\harr","\\leftrightarrow");S("\\hArr","\\Leftrightarrow");S("\\Harr","\\Leftrightarrow");S("\\hearts","\\heartsuit");S("\\image","\\Im");S("\\infin","\\infty");S("\\Iota","\\mathrm{I}");S("\\isin","\\in");S("\\Kappa","\\mathrm{K}");S("\\larr","\\leftarrow");S("\\lArr","\\Leftarrow");S("\\Larr","\\Leftarrow");S("\\lrarr","\\leftrightarrow");S("\\lrArr","\\Leftrightarrow");S("\\Lrarr","\\Leftrightarrow");S("\\Mu","\\mathrm{M}");S("\\natnums","\\mathbb{N}");S("\\Nu","\\mathrm{N}");S("\\Omicron","\\mathrm{O}");S("\\plusmn","\\pm");S("\\rarr","\\rightarrow");S("\\rArr","\\Rightarrow");S("\\Rarr","\\Rightarrow");S("\\real","\\Re");S("\\reals","\\mathbb{R}");S("\\Reals","\\mathbb{R}");S("\\Rho","\\mathrm{P}");S("\\sdot","\\cdot");S("\\sect","\\S");S("\\spades","\\spadesuit");S("\\sub","\\subset");S("\\sube","\\subseteq");S("\\supe","\\supseteq");S("\\Tau","\\mathrm{T}");S("\\thetasym","\\vartheta");S("\\weierp","\\wp");S("\\Zeta","\\mathrm{Z}");S("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");S("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");S("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits");S("\\bra","\\mathinner{\\langle{#1}|}");S("\\ket","\\mathinner{|{#1}\\rangle}");S("\\braket","\\mathinner{\\langle{#1}\\rangle}");S("\\Bra","\\left\\langle#1\\right|");S("\\Ket","\\left|#1\\right\\rangle");var py=r=>e=>{var t=e.consumeArg().tokens,n=e.consumeArg().tokens,i=e.consumeArg().tokens,s=e.consumeArg().tokens,a=e.macros.get("|"),A=e.macros.get("\\|");e.macros.beginGroup();var o=d=>u=>{r&&(u.macros.set("|",a),i.length&&u.macros.set("\\|",A));var h=d;if(!d&&i.length){var p=u.future();p.text==="|"&&(u.popToken(),h=!0)}return{tokens:h?i:n,numArgs:0}};e.macros.set("|",o(!1)),i.length&&e.macros.set("\\|",o(!0));var c=e.consumeArg().tokens,l=e.expandTokens([...s,...c,...t]);return e.macros.endGroup(),{tokens:l.reverse(),numArgs:0}};S("\\bra@ket",py(!1));S("\\bra@set",py(!0));S("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");S("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");S("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");S("\\angln","{\\angl n}");S("\\blue","\\textcolor{##6495ed}{#1}");S("\\orange","\\textcolor{##ffa500}{#1}");S("\\pink","\\textcolor{##ff00af}{#1}");S("\\red","\\textcolor{##df0030}{#1}");S("\\green","\\textcolor{##28ae7b}{#1}");S("\\gray","\\textcolor{gray}{#1}");S("\\purple","\\textcolor{##9d38bd}{#1}");S("\\blueA","\\textcolor{##ccfaff}{#1}");S("\\blueB","\\textcolor{##80f6ff}{#1}");S("\\blueC","\\textcolor{##63d9ea}{#1}");S("\\blueD","\\textcolor{##11accd}{#1}");S("\\blueE","\\textcolor{##0c7f99}{#1}");S("\\tealA","\\textcolor{##94fff5}{#1}");S("\\tealB","\\textcolor{##26edd5}{#1}");S("\\tealC","\\textcolor{##01d1c1}{#1}");S("\\tealD","\\textcolor{##01a995}{#1}");S("\\tealE","\\textcolor{##208170}{#1}");S("\\greenA","\\textcolor{##b6ffb0}{#1}");S("\\greenB","\\textcolor{##8af281}{#1}");S("\\greenC","\\textcolor{##74cf70}{#1}");S("\\greenD","\\textcolor{##1fab54}{#1}");S("\\greenE","\\textcolor{##0d923f}{#1}");S("\\goldA","\\textcolor{##ffd0a9}{#1}");S("\\goldB","\\textcolor{##ffbb71}{#1}");S("\\goldC","\\textcolor{##ff9c39}{#1}");S("\\goldD","\\textcolor{##e07d10}{#1}");S("\\goldE","\\textcolor{##a75a05}{#1}");S("\\redA","\\textcolor{##fca9a9}{#1}");S("\\redB","\\textcolor{##ff8482}{#1}");S("\\redC","\\textcolor{##f9685d}{#1}");S("\\redD","\\textcolor{##e84d39}{#1}");S("\\redE","\\textcolor{##bc2612}{#1}");S("\\maroonA","\\textcolor{##ffbde0}{#1}");S("\\maroonB","\\textcolor{##ff92c6}{#1}");S("\\maroonC","\\textcolor{##ed5fa6}{#1}");S("\\maroonD","\\textcolor{##ca337c}{#1}");S("\\maroonE","\\textcolor{##9e034e}{#1}");S("\\purpleA","\\textcolor{##ddd7ff}{#1}");S("\\purpleB","\\textcolor{##c6b9fc}{#1}");S("\\purpleC","\\textcolor{##aa87ff}{#1}");S("\\purpleD","\\textcolor{##7854ab}{#1}");S("\\purpleE","\\textcolor{##543b78}{#1}");S("\\mintA","\\textcolor{##f5f9e8}{#1}");S("\\mintB","\\textcolor{##edf2df}{#1}");S("\\mintC","\\textcolor{##e0e5cc}{#1}");S("\\grayA","\\textcolor{##f6f7f7}{#1}");S("\\grayB","\\textcolor{##f0f1f2}{#1}");S("\\grayC","\\textcolor{##e3e5e6}{#1}");S("\\grayD","\\textcolor{##d6d8da}{#1}");S("\\grayE","\\textcolor{##babec2}{#1}");S("\\grayF","\\textcolor{##888d93}{#1}");S("\\grayG","\\textcolor{##626569}{#1}");S("\\grayH","\\textcolor{##3b3e40}{#1}");S("\\grayI","\\textcolor{##21242c}{#1}");S("\\kaBlue","\\textcolor{##314453}{#1}");S("\\kaGreen","\\textcolor{##71B307}{#1}");var my={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class aE{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new iE(sE,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new wp(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,i;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;t=this.popToken(),{tokens:i,end:n}=this.consumeArg(["]"])}else({tokens:i,start:t,end:n}=this.consumeArg());return this.pushToken(new gn("EOF",n.loc)),this.pushTokens(i),t.range(n,"")}consumeSpaces(){for(;;){var e=this.future();if(e.text===" ")this.stack.pop();else break}}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var i=this.future(),s,a=0,A=0;do{if(s=this.popToken(),t.push(s),s.text==="{")++a;else if(s.text==="}"){if(--a,a===-1)throw new W("Extra }",s)}else if(s.text==="EOF")throw new W("Unexpected end of input in a macro argument, expected '"+(e&&n?e[A]:"}")+"'",s);if(e&&n)if((a===0||a===1&&e[A]==="{")&&s.text===e[A]){if(++A,A===e.length){t.splice(-A,A);break}}else A=0}while(a!==0||n);return i.text==="{"&&t[t.length-1].text==="}"&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:i,end:s}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new W("The length of delimiters doesn't match the number of args!");for(var n=t[0],i=0;i<n.length;i++){var s=this.popToken();if(n[i]!==s.text)throw new W("Use of the macro doesn't match its definition",s)}}for(var a=[],A=0;A<e;A++)a.push(this.consumeArg(t&&t[A+1]).tokens);return a}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new W("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var t=this.popToken(),n=t.text,i=t.noexpand?null:this._getExpansion(n);if(i==null||e&&i.unexpandable){if(e&&i==null&&n[0]==="\\"&&!this.isDefined(n))throw new W("Undefined control sequence: "+n);return this.pushToken(t),!1}this.countExpansion(1);var s=i.tokens,a=this.consumeArgs(i.numArgs,i.delimiters);if(i.numArgs){s=s.slice();for(var A=s.length-1;A>=0;--A){var o=s[A];if(o.text==="#"){if(A===0)throw new W("Incomplete placeholder at end of macro body",o);if(o=s[--A],o.text==="#")s.splice(A+1,1);else if(/^[1-9]$/.test(o.text))s.splice(A,2,...a[+o.text-1]);else throw new W("Not a valid argument number",o)}}}return this.pushTokens(s),s.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new gn(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var i=this.stack.pop();i.treatAsRelax&&(i.noexpand=!1,i.treatAsRelax=!1),t.push(i)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(n=>n.text).join("")}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var i=typeof t=="function"?t(this):t;if(typeof i=="string"){var s=0;if(i.indexOf("#")!==-1)for(var a=i.replace(/##/g,"");a.indexOf("#"+(s+1))!==-1;)++s;for(var A=new wp(i,this.settings),o=[],c=A.lex();c.text!=="EOF";)o.push(c),c=A.lex();o.reverse();var l={tokens:o,numArgs:s};return l}return i}isDefined(e){return this.macros.has(e)||pi.hasOwnProperty(e)||Ve.math.hasOwnProperty(e)||Ve.text.hasOwnProperty(e)||my.hasOwnProperty(e)}isExpandable(e){var t=this.macros.get(e);return t!=null?typeof t=="string"||typeof t=="function"||!t.unexpandable:pi.hasOwnProperty(e)&&!pi[e].primitive}}var Cp=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,dA=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g",ʰ:"h","ⁱ":"i",ʲ:"j","ᵏ":"k",ˡ:"l","ᵐ":"m",ⁿ:"n","ᵒ":"o","ᵖ":"p",ʳ:"r",ˢ:"s","ᵗ":"t","ᵘ":"u","ᵛ":"v",ʷ:"w",ˣ:"x",ʸ:"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),wl={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},Sp={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"};class oc{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new aE(e,t,this.mode),this.settings=t,this.leftrightDepth=0}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new W("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new gn("}")),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,n}parseExpression(e,t){for(var n=[];;){this.mode==="math"&&this.consumeSpaces();var i=this.fetch();if(oc.endOfExpression.indexOf(i.text)!==-1||t&&i.text===t||e&&pi[i.text]&&pi[i.text].infix)break;var s=this.parseAtom(t);if(s){if(s.type==="internal")continue}else break;n.push(s)}return this.mode==="text"&&this.formLigatures(n),this.handleInfixNodes(n)}handleInfixNodes(e){for(var t=-1,n,i=0;i<e.length;i++)if(e[i].type==="infix"){if(t!==-1)throw new W("only one infix operator per group",e[i].token);t=i,n=e[i].replaceWith}if(t!==-1&&n){var s,a,A=e.slice(0,t),o=e.slice(t+1);A.length===1&&A[0].type==="ordgroup"?s=A[0]:s={type:"ordgroup",mode:this.mode,body:A},o.length===1&&o[0].type==="ordgroup"?a=o[0]:a={type:"ordgroup",mode:this.mode,body:o};var c;return n==="\\\\abovefrac"?c=this.callFunction(n,[s,e[t],a],[]):c=this.callFunction(n,[s,a],[]),[c]}else return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var i=this.parseGroup(e);if(!i)throw new W("Expected group after '"+n+"'",t);return i}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:"textord",mode:"text",text:e[n]});var i={type:"text",mode:this.mode,body:t},s={type:"color",mode:this.mode,color:this.settings.errorColor,body:[i]};return s}parseAtom(e){var t=this.parseGroup("atom",e);if(this.mode==="text")return t;for(var n,i;;){this.consumeSpaces();var s=this.fetch();if(s.text==="\\limits"||s.text==="\\nolimits"){if(t&&t.type==="op"){var a=s.text==="\\limits";t.limits=a,t.alwaysHandleSupSub=!0}else if(t&&t.type==="operatorname")t.alwaysHandleSupSub&&(t.limits=s.text==="\\limits");else throw new W("Limit controls must follow a math operator",s);this.consume()}else if(s.text==="^"){if(n)throw new W("Double superscript",s);n=this.handleSupSubscript("superscript")}else if(s.text==="_"){if(i)throw new W("Double subscript",s);i=this.handleSupSubscript("subscript")}else if(s.text==="'"){if(n)throw new W("Double superscript",s);var A={type:"textord",mode:this.mode,text:"\\prime"},o=[A];for(this.consume();this.fetch().text==="'";)o.push(A),this.consume();this.fetch().text==="^"&&o.push(this.handleSupSubscript("superscript")),n={type:"ordgroup",mode:this.mode,body:o}}else if(dA[s.text]){var c=Cp.test(s.text),l=[];for(l.push(new gn(dA[s.text])),this.consume();;){var d=this.fetch().text;if(!dA[d]||Cp.test(d)!==c)break;l.unshift(new gn(dA[d])),this.consume()}var u=this.subparse(l);c?i={type:"ordgroup",mode:"math",body:u}:n={type:"ordgroup",mode:"math",body:u}}else break}return n||i?{type:"supsub",mode:this.mode,base:t,sup:n,sub:i}:t}parseFunction(e,t){var n=this.fetch(),i=n.text,s=pi[i];if(!s)return null;if(this.consume(),t&&t!=="atom"&&!s.allowedInArgument)throw new W("Got function '"+i+"' with no arguments"+(t?" as "+t:""),n);if(this.mode==="text"&&!s.allowedInText)throw new W("Can't use function '"+i+"' in text mode",n);if(this.mode==="math"&&s.allowedInMath===!1)throw new W("Can't use function '"+i+"' in math mode",n);var{args:a,optArgs:A}=this.parseArguments(i,s);return this.callFunction(i,a,A,n,e)}callFunction(e,t,n,i,s){var a={funcName:e,parser:this,token:i,breakOnTokenText:s},A=pi[e];if(A&&A.handler)return A.handler(a,t,n);throw new W("No function handler for "+e)}parseArguments(e,t){var n=t.numArgs+t.numOptionalArgs;if(n===0)return{args:[],optArgs:[]};for(var i=[],s=[],a=0;a<n;a++){var A=t.argTypes&&t.argTypes[a],o=a<t.numOptionalArgs;(t.primitive&&A==null||t.type==="sqrt"&&a===1&&s[0]==null)&&(A="primitive");var c=this.parseGroupOfType("argument to '"+e+"'",A,o);if(o)s.push(c);else if(c!=null)i.push(c);else throw new W("Null argument, please report this as a bug")}return{args:i,optArgs:s}}parseGroupOfType(e,t,n){switch(t){case"color":return this.parseColorGroup(n);case"size":return this.parseSizeGroup(n);case"url":return this.parseUrlGroup(n);case"math":case"text":return this.parseArgumentGroup(n,t);case"hbox":{var i=this.parseArgumentGroup(n,"text");return i!=null?{type:"styling",mode:i.mode,body:[i],style:"text"}:null}case"raw":{var s=this.parseStringGroup("raw",n);return s!=null?{type:"raw",mode:"text",string:s.text}:null}case"primitive":{if(n)throw new W("A primitive argument cannot be optional");var a=this.parseGroup(e);if(a==null)throw new W("Expected group as "+e,this.fetch());return a}case"original":case null:case void 0:return this.parseArgumentGroup(n);default:throw new W("Unknown group type as "+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===" ";)this.consume()}parseStringGroup(e,t){var n=this.gullet.scanArgument(t);if(n==null)return null;for(var i="",s;(s=this.fetch()).text!=="EOF";)i+=s.text,this.consume();return this.consume(),n.text=i,n}parseRegexGroup(e,t){for(var n=this.fetch(),i=n,s="",a;(a=this.fetch()).text!=="EOF"&&e.test(s+a.text);)i=a,s+=i.text,this.consume();if(s==="")throw new W("Invalid "+t+": '"+n.text+"'",n);return n.range(i,s)}parseColorGroup(e){var t=this.parseStringGroup("color",e);if(t==null)return null;var n=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new W("Invalid color: '"+t.text+"'",t);var i=n[0];return/^[0-9a-f]{6}$/i.test(i)&&(i="#"+i),{type:"color-token",mode:this.mode,color:i}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),!e&&this.gullet.future().text!=="{"?t=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"):t=this.parseStringGroup("size",e),!t)return null;!e&&t.text.length===0&&(t.text="0pt",n=!0);var i=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!i)throw new W("Invalid size: '"+t.text+"'",t);var s={number:+(i[1]+i[2]),unit:i[3]};if(!Tv(s))throw new W("Invalid unit: '"+s.unit+"'",t);return{type:"size",mode:this.mode,value:s,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var t=this.parseStringGroup("url",e);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),t==null)return null;var n=t.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:n}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var i=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var s=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var a={type:"ordgroup",mode:this.mode,loc:n.loc,body:s};return t&&this.switchMode(i),a}parseGroup(e,t){var n=this.fetch(),i=n.text,s;if(i==="{"||i==="\\begingroup"){this.consume();var a=i==="{"?"}":"\\endgroup";this.gullet.beginGroup();var A=this.parseExpression(!1,a),o=this.fetch();this.expect(a),this.gullet.endGroup(),s={type:"ordgroup",mode:this.mode,loc:rn.range(n,o),body:A,semisimple:i==="\\begingroup"||void 0}}else if(s=this.parseFunction(t,e)||this.parseSymbol(),s==null&&i[0]==="\\"&&!my.hasOwnProperty(i)){if(this.settings.throwOnError)throw new W("Undefined control sequence: "+i,n);s=this.formatUnsupportedCmd(i),this.consume()}return s}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var i=e[n],s=i.text;s==="-"&&e[n+1].text==="-"&&(n+1<t&&e[n+2].text==="-"?(e.splice(n,3,{type:"textord",mode:"text",loc:rn.range(i,e[n+2]),text:"---"}),t-=2):(e.splice(n,2,{type:"textord",mode:"text",loc:rn.range(i,e[n+1]),text:"--"}),t-=1)),(s==="'"||s==="`")&&e[n+1].text===s&&(e.splice(n,2,{type:"textord",mode:"text",loc:rn.range(i,e[n+1]),text:s+s}),t-=1)}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),i=n.charAt(0)==="*";if(i&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new W(`\\verb assertion failed --
|
|
372
|
+
please report what input caused this bug`);return n=n.slice(1,-1),{type:"verb",mode:"text",body:n,star:i}}Sp.hasOwnProperty(t[0])&&!Ve[this.mode][t[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+t[0]+'" used in math mode',e),t=Sp[t[0]]+t.slice(1));var s=nE.exec(t);s&&(t=t.substring(0,s.index),t==="i"?t="ı":t==="j"&&(t="ȷ"));var a;if(Ve[this.mode][t]){this.settings.strict&&this.mode==="math"&&_d.indexOf(t)>=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var A=Ve[this.mode][t].group,o=rn.range(e),c;if($7.hasOwnProperty(A)){var l=A;c={type:"atom",mode:this.mode,family:l,loc:o,text:t}}else c={type:A,mode:this.mode,loc:o,text:t};a=c}else if(t.charCodeAt(0)>=128)this.settings.strict&&(kv(t.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'"'+(" ("+t.charCodeAt(0)+")"),e)),a={type:"textord",mode:"text",loc:rn.range(e),text:t};else return null;if(this.consume(),s)for(var d=0;d<s[0].length;d++){var u=s[0][d];if(!wl[u])throw new W("Unknown accent ' "+u+"'",e);var h=wl[u][this.mode]||wl[u].text;if(!h)throw new W("Accent "+u+" unsupported in "+this.mode+" mode",e);a={type:"accent",mode:this.mode,loc:rn.range(e),label:h,isStretchy:!1,isShifty:!0,base:a}}return a}}oc.endOfExpression=["}","\\endgroup","\\end","\\right","&"];var Zu=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var n=new oc(e,t);delete n.gullet.macros.current["\\df@tag"];var i=n.parse();if(delete n.gullet.macros.current["\\current@color"],delete n.gullet.macros.current["\\color"],n.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new W("\\tag works only in display equations");i=[{type:"tag",mode:"text",body:i,tag:n.subparse([new gn("\\df@tag")])}]}return i},gy=function(e,t,n){t.textContent="";var i=e0(e,n).toNode();t.appendChild(i)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u",gy=function(){throw new W("KaTeX doesn't work in quirks mode.")});var AE=function(e,t){var n=e0(e,t).toMarkup();return n},oE=function(e,t){var n=new Ru(t);return Zu(e,n)},vy=function(e,t,n){if(n.throwOnError||!(e instanceof W))throw e;var i=P.makeSpan(["katex-error"],[new vn(t)]);return i.setAttribute("title",e.toString()),i.setAttribute("style","color:"+n.errorColor),i},e0=function(e,t){var n=new Ru(t);try{var i=Zu(e,n);return g8(i,e,n)}catch(s){return vy(s,e,n)}},cE=function(e,t){var n=new Ru(t);try{var i=Zu(e,n);return v8(i,e,n)}catch(s){return vy(s,e,n)}},Ta={version:"0.16.11",render:gy,renderToString:AE,ParseError:W,SETTINGS_SCHEMA:QA,__parse:oE,__renderToDomTree:e0,__renderToHTMLTree:cE,__setFontMetrics:N7,__defineSymbol:f,__defineFunction:te,__defineMacro:S,__domTree:{Span:Ua,Anchor:Lu,SymbolNode:vn,SvgNode:br,PathNode:jr,LineNode:Md}},lE=function(e,t,n){for(var i=n,s=0,a=e.length;i<t.length;){var A=t[i];if(s<=0&&t.slice(i,i+a)===e)return i;A==="\\"?i++:A==="{"?s++:A==="}"&&s--,i++}return-1},dE=function(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")},uE=/^\\begin{/,hE=function(e,t){for(var n,i=[],s=new RegExp("("+t.map(c=>dE(c.left)).join("|")+")");n=e.search(s),n!==-1;){n>0&&(i.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));var a=t.findIndex(c=>e.startsWith(c.left));if(n=lE(t[a].right,e,t[a].left.length),n===-1)break;var A=e.slice(0,n+t[a].right.length),o=uE.test(A)?A:e.slice(t[a].left.length,n);i.push({type:"math",data:o,rawData:A,display:t[a].display}),e=e.slice(n+t[a].right.length)}return e!==""&&i.push({type:"text",data:e}),i},fE=function(e,t){var n=hE(e,t.delimiters);if(n.length===1&&n[0].type==="text")return null;for(var i=document.createDocumentFragment(),s=0;s<n.length;s++)if(n[s].type==="text")i.appendChild(document.createTextNode(n[s].data));else{var a=document.createElement("span"),A=n[s].data;t.displayMode=n[s].display;try{t.preProcess&&(A=t.preProcess(A)),Ta.render(A,a,t)}catch(o){if(!(o instanceof Ta.ParseError))throw o;t.errorCallback("KaTeX auto-render: Failed to parse `"+n[s].data+"` with ",o),i.appendChild(document.createTextNode(n[s].rawData));continue}i.appendChild(a)}return i},pE=function r(e,t){for(var n=0;n<e.childNodes.length;n++){var i=e.childNodes[n];if(i.nodeType===3){for(var s=i.textContent,a=i.nextSibling,A=0;a&&a.nodeType===Node.TEXT_NODE;)s+=a.textContent,a=a.nextSibling,A++;var o=fE(s,t);if(o){for(var c=0;c<A;c++)i.nextSibling.remove();n+=o.childNodes.length-1,e.replaceChild(o,i)}else n+=A}else i.nodeType===1&&function(){var l=" "+i.className+" ",d=t.ignoredTags.indexOf(i.nodeName.toLowerCase())===-1&&t.ignoredClasses.every(u=>l.indexOf(" "+u+" ")===-1);d&&r(i,t)}()}},mE=function(e,t){if(!e)throw new Error("No element provided to render");var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.delimiters=n.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],n.ignoredTags=n.ignoredTags||["script","noscript","style","textarea","pre","code","option"],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},pE(e,n)};function gE(r){if(!r||!r.includes("\\"))return r;const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(n!=="\\"){e.push(n);continue}const i=r[t+1];if(i===" "||i===" "||i===":"||i===";"||i===","||i==="!"){e.push(i),t+=1;continue}e.push("\\")}return e.join("")}function vE(r){if(!r||/\$/.test(r)||yy(r))return r;const e=r.match(/^(.+?:\s*)([a-zA-Z]_\{?\d+\}?[\s\S]+)$/);if(!e)return r;const[,t,n]=e;if(!/[+\-=*^]|\\cdots|\.\.\.|\\ldots/.test(n)||!/[a-zA-Z]_(\{?\d+\}?|\{)/.test(n))return r;const i=n.trim().replace(/\.\.\./g,"\\cdots");return`${t}$${i}$`}function yE(r){return/\$\$[\s\S]+\$\$/.test(r)||/\$[^$\n]+\$/.test(r)||/\\\([\s\S]+\\\)/.test(r)||/\\\[[\s\S]+\\\]/.test(r)}const wE=/\\(?:frac|text|int|sum|sqrt|begin|end|sin|cos|tan|cot|sec|csc|log|ln|lim|partial|infty|alpha|beta|theta|pi|sigma|omega|phi|psi|Delta|Gamma|Lambda|cdot|times|pm|mp|leq|geq|neq|approx|equiv|left|right|mathbf|mathrm|mathit|mathbb|mathcal|dfrac|tfrac|binom|vec|hat|bar|overline|underline|quad|qquad|dots|ldots|operatorname|tag|label|ref|iint|oint|det|gcd|max|min|mod|exp|arg|Re|Im|Pr|sinh|cosh|tanh|arcsin|arccos|arctan)[\s{[(\\]|\\[{}]/;function yy(r){const e=r.trim();return!e||yE(e)?!1:wE.test(e)||/^\\[a-zA-Z]+/.test(e)}function bl(r){if(!r||!r.includes("\\")&&!r.includes("_"))return r;const e=r.split(`
|
|
373
|
+
`),t=[];let n=[],i=!1;const s=()=>{if(n.length===0)return;const a=n.join(`
|
|
374
|
+
`).trim();a&&t.push(`$$${a}$$`),n=[]};for(const a of e){const A=vE(a),o=/\\begin\{[^}]+}/.test(A),c=/\\end\{[^}]+}/.test(A);if(i||o||yy(A)){n.push(A),i=(i||o)&&!c;continue}s(),t.push(A)}return s(),t.join(`
|
|
375
|
+
`)}function cc(r){if(!r)return r;const e=gE(r);if(!e.includes("\\")&&!e.includes("_"))return e;const t=[];let n=0;const i=[{left:"$$",right:"$$"},{left:"\\[",right:"\\]"},{left:"\\(",right:"\\)"},{left:"$",right:"$"}];for(;n<e.length;){let s=null;for(const o of i){const c=e.indexOf(o.left,n);c!==-1&&(!s||c<s.start||c===s.start&&o.left.length>s.left.length)&&(s={...o,start:c})}if(!s){t.push(bl(e.slice(n)));break}s.start>n&&t.push(bl(e.slice(n,s.start)));const a=s.start+s.left.length,A=e.indexOf(s.right,a);if(A===-1){t.push(bl(e.slice(s.start)));break}t.push(e.slice(s.start,A+s.right.length)),n=A+s.right.length}return t.join("")}function bE(r,e){return r.trim()?cc(r):r}const BE="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css",wy=[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1}];function CE(){if(typeof document>"u"||document.getElementById("vnr-katex-css"))return;const r=document.createElement("link");r.id="vnr-katex-css",r.rel="stylesheet",r.href=BE,r.crossOrigin="anonymous",document.head.appendChild(r)}function kp(r){return/(\$\$[\s\S]+?\$\$|\$[^$\n]+?\$|\\\[[\s\S]+?\\\]|\\\([\s\S]+?\\\)|\\begin\{)/.test(r)||/\\(?:frac|text|int|sum|sqrt|begin|end|sin|cos|tan)\b/.test(r)}function _A(r){let e=0,t=r.length,n="none",i=0;for(;e<r.length;){if(r.startsWith("$$",e)){if(n==="double"){n="none",e+=2;continue}if(n==="none"){n="double",i=e,e+=2;continue}}if(n==="none"&&r[e]==="$"&&!r.startsWith("$$",e)){n="dollar",i=e,e+=1;continue}if(n==="dollar"&&r[e]==="$"){n="none",e+=1;continue}if(n==="none"&&r.startsWith("\\[",e)){n="bracket",i=e,e+=2;continue}if(n==="bracket"&&r.startsWith("\\]",e)){n="none",e+=2;continue}if(n==="none"&&r.startsWith("\\(",e)){n="paren",i=e,e+=2;continue}if(n==="paren"&&r.startsWith("\\)",e)){n="none",e+=2;continue}e+=1}return n!=="none"&&(t=i),r.slice(0,t)}function Bo(r){const e=cc(r),t=[];let n=0;for(;n<e.length;){let i=null;for(const A of wy){const o=e.indexOf(A.left,n);o!==-1&&(!i||o<i.start||o===i.start&&A.left.length>i.open.length)&&(i={open:A.left,close:A.right,display:A.display,start:o})}if(!i){const A=e.slice(n);A&&t.push({kind:"plain",text:A});break}i.start>n&&t.push({kind:"plain",text:e.slice(n,i.start)});const s=i.start+i.open.length,a=e.indexOf(i.close,s);if(a===-1){t.push({kind:"plain",text:e.slice(i.start)});break}t.push({kind:"math",latex:e.slice(s,a).trim(),display:i.display}),n=a+i.close.length}return t}function SE(r,e){const t=e.split(`
|
|
376
|
+
`);t.forEach((n,i)=>{n&&r.appendChild(document.createTextNode(n)),i<t.length-1&&r.appendChild(document.createElement("br"))})}function kE(r,e){try{return Ta.renderToString(r,{displayMode:e,throwOnError:!1,strict:"ignore"})}catch{return Ta.renderToString(String.raw`\text{?}`,{displayMode:e,throwOnError:!1})}}function Tp(r){const e=document.createElement("span");e.className="vnr-chalk-cursor",e.setAttribute("aria-hidden","true"),e.textContent="|",r.appendChild(e)}function by(r,e,t){const n=Bo(e);if(r.innerHTML="",r.dataset.empty=e.trim().length===0?"true":"false",n.length===0){if(t!=null&&t.showCursor){const s=document.createElement("div");s.className="vnr-chalk-board-content",Tp(s),r.appendChild(s)}return n}const i=document.createElement("div");return i.className="vnr-chalk-board-content",n.forEach((s,a)=>{const A=s.kind==="math"&&s.display,o=document.createElement(A?"div":"span");if(o.className=["vnr-chalk-segment",`vnr-chalk-${s.kind}`,s.kind==="math"?s.display?"vnr-chalk-math-display":"vnr-chalk-math-inline":""].filter(Boolean).join(" "),a===(t==null?void 0:t.revealingSegmentIndex)&&s.kind==="math"){const c=t.revealMs??Math.max(120,s.latex.length*42);o.classList.add("vnr-chalk-revealing"),o.style.setProperty("--vnr-chalk-reveal-ms",`${c}ms`)}s.kind==="plain"?SE(o,s.text):o.innerHTML=kE(s.latex,s.display),i.appendChild(o)}),t!=null&&t.showCursor&&Tp(i),r.appendChild(i),n}function TE(r,e,t=!1){const n=cc(r);if(e.textContent=n,e.dataset.empty=r.trim().length===0?"true":"false",t){const i=document.createElement("span");i.className="vnr-chalk-cursor",i.textContent="|",e.appendChild(i)}try{mE(e,{delimiters:[...wy],throwOnError:!1,errorColor:"#ff8a8a",strict:"ignore"})}catch{}}const xE=1.75;function EE(r,e){return Math.max(180,r.latex.length*e*xE)}function UE(r){for(let e=r.length-1;e>=0;e--)if(r[e].kind==="math")return e;return-1}function FE(r){const{surface:e,initialText:t,appendText:n,delayMs:i,schedule:s,shouldContinue:a,onSourceChar:A,onComplete:o}=r;let c=0,l=t;const d=(h,p)=>{const g=_A(h);by(e,g,{showCursor:!0,revealingSegmentIndex:p==null?void 0:p.segmentIndex,revealMs:p==null?void 0:p.revealMs}),e.scrollTop=e.scrollHeight},u=()=>{if(!a()||!document.body.contains(e)){d(l);return}if(c>=n.length){d(l),o();return}const h=_A(l),g=Bo(h).filter(E=>E.kind==="math").length;l+=n[c],c+=1,A(c);const v=_A(l),w=Bo(v);if(w.filter(E=>E.kind==="math").length>g){const E=UE(w),b=w[E];if((b==null?void 0:b.kind)==="math"){const C=EE(b,i);d(l,{segmentIndex:E,revealMs:C}),s(u,C);return}}d(l),s(u,i)};d(l),s(u,i)}const IE="LaTeX did not render — nothing was written on the chalkboard. Use plain text lines for Telugu/English headings. Put each formula on its own line inside $$...$$ (display) or $...$ (inline). Do not send naked \\\\frac, \\\\text, or \\\\int without delimiters. Fix the errors below and call write_latex_text again.",QE=/\\[a-zA-Z]+/;function ME(r){let e=0,t=!1;for(;e<r.length;){if(r.startsWith("$$",e)){t=!t,e+=2;continue}e+=1}return t}function _E(r){try{return Ta.renderToString(r.latex,{displayMode:r.display,throwOnError:!0,strict:"ignore"}),null}catch(e){return{code:"katex_parse_error",message:e instanceof Error?e.message:"KaTeX parse error",snippet:r.latex.slice(0,160)}}}function RE(r){const e=r.trim();if(!e)return{ok:!1,normalized:"",errors:[{code:"unrendered_latex",message:"latex_text is empty",snippet:""}],agent_message:"latex_text was empty — pass content to write on the chalkboard."};const t=[];ME(e)&&t.push({code:"unclosed_delimiter",message:"Unclosed $$ delimiter — every $$ must be paired",snippet:e.slice(0,160)});const n=cc(e),i=Bo(n);for(const s of i){if(s.kind==="plain"){QE.test(s.text)&&t.push({code:"unrendered_latex",message:"LaTeX commands appear as plain text (fix delimiters or syntax)",snippet:s.text.trim().slice(0,160)});continue}const a=_E(s);a&&t.push(a)}return{ok:t.length===0,normalized:n,errors:t,agent_message:t.length>0?`${IE} Errors: ${t.map(s=>s.message).join("; ")}`:""}}function PE(r,e,t){return{status:"error",preset_id:"vanira_write_latex_text",latex_render_ok:!1,board_written:!1,latex_errors:r,message:e,has_notes_on_board:t>0,notes_char_count:t,verification_hint:"Nothing new was written — do NOT tell the student the formula is visible. Fix LaTeX format and call write_latex_text again."}}const xp="vanira:agent-playback-ended",DE="You might have missed the whiteboard — call write_latex_text (or type_on_whiteboard for plain text) so the student can see what you explained. if you are on other task or waiting for user to show something then fine";function LE(r){return!!r.has_notes_on_board}class OE{constructor(e,t){L(this,"active",!1);L(this,"sendContext",null);L(this,"getSnapshot");L(this,"isBoardBusy");L(this,"onAgentTurnEnd");this.getSnapshot=e,this.isBoardBusy=t,this.onAgentTurnEnd=()=>this.checkAfterAgentTurn()}start(e){if(this.active){this.sendContext=e;return}this.active=!0,this.sendContext=e,window.addEventListener(xp,this.onAgentTurnEnd)}stop(){this.active&&(this.active=!1,this.sendContext=null,window.removeEventListener(xp,this.onAgentTurnEnd))}checkAfterAgentTurn(){if(!this.active||!this.sendContext||this.isBoardBusy())return;const e=this.getSnapshot();if(LE(e))return;const t={board_turn_check:{has_whiteboard:!1,...e,message:DE}};try{this.sendContext(t)}catch{}}}function HE(){var r,e;if(typeof window>"u")return!1;try{if(window.__VANIRA_DEBUG__===!0||localStorage.getItem("vanira:debug")==="1"||new URLSearchParams(window.location.search).has("vanira_debug"))return!0}catch{}try{const t={url:typeof document>"u"?require("url").pathToFileURL(__filename).href:dc&&dc.tagName.toUpperCase()==="SCRIPT"&&dc.src||new URL("headless/index.cjs",document.baseURI).href};if(((r=t.env)==null?void 0:r.DEV)===!0||((e=t.env)==null?void 0:e.VANIRA_SDK_DEV)===!0)return!0}catch{}return!1}let Bl=null;function By(){return Bl===null&&(Bl=HE()),Bl}function Cy(r,e,t){if(!(typeof window>"u"))try{const n=window.__VANIRA_DEBUG_LOG__??[];for(n.push({t:Date.now(),tag:r,message:e,data:t});n.length>250;)n.shift();window.__VANIRA_DEBUG_LOG__=n}catch{}}function Fs(r,e,t){By()&&Cy(r,e,t)}function NE(r,e,t){By()&&Cy(r,`WARN ${e}`,t)}function sa(r){return r.toLowerCase().replace(/[^a-z0-9]/g,"_")}function KE(r){const e=r==null?void 0:r.toLowerCase().trim();if(e){if(e==="tel")return"phone";if(e==="dropdown"||e==="drop_down"||e==="picklist"||e==="combobox")return"select";if(["text","textarea","select","radio","checkbox","email","phone","number","date"].includes(e))return e}}function Sy(r,e,t=[]){const n=KE(e);return n||(t.length>0?"select":r.includes("email")?"email":r.includes("phone")?"phone":r.includes("date")&&!r.includes("update")?"date":"text")}function VE(r){return r?Array.isArray(r)?r.map(e=>{if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return{label:String(t.label??t.value??""),value:String(t.value??t.label??"")}}return String(e)}):typeof r=="string"?r.split(",").map(e=>e.trim()).filter(Boolean):[]:[]}function zE(r){const e=r.value??r.default??r.defaultValue??r.prefill;if(!(e==null||e===""))return String(e)}function Cl(r){const e=String(r.label??r.name??r.title??r.field??r.id??r.key??"").trim();if(!e)return null;const t=String(r.id??r.key??sa(e)),n=VE(r.options??r.choices??r.values),i=Sy(t,String(r.type??""),n);return{id:t,label:e,type:i,required:r.required!==!1,placeholder:r.placeholder?String(r.placeholder):void 0,value:zE(r),options:n}}function Ep(r){const e=r.trim(),t=sa(e);return{id:t,label:e,type:Sy(t),required:!0,placeholder:`Enter your ${e.toLowerCase()}`,options:[]}}function RA(r){const e=r.trim();return e?e.startsWith("[")||e.startsWith("{")||e.startsWith('"')?!0:e.includes('"type"')||e.includes('"options"')||e.includes('"label"'):!1}function GE(r){let e=r.trim();for(let t=0;t<3&&typeof e=="string";t++){const n=e.trim();if(!RA(n))break;try{e=JSON.parse(n)}catch{break}}return e}function PA(r){const e=GE(r);if(Array.isArray(e)||e&&typeof e=="object")return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&!t.startsWith("["))try{return JSON.parse(`[${t}]`)}catch{return null}}return null}function qE(r){return r.length<2?!1:r.every(e=>typeof e=="string"&&(e.includes('"')||e.includes("{")||e.includes("[")))}function WE(r){return PA(r.map(e=>e.trim()).join(","))}function zs(r){if(r==null)return[];if(typeof r=="string"){const e=r.trim();if(!e)return[];if(RA(e)){const t=PA(e);return t!==null?zs(t):[]}return e.split(",").map(t=>t.trim()).filter(Boolean).map(Ep)}if(Array.isArray(r)){if(r.length===1&&typeof r[0]=="string"){const t=r[0].trim();if(RA(t)){const n=PA(t);if(n!==null)return zs(n)}}if(qE(r)){const t=WE(r);if(t!==null)return zs(t)}const e=[];for(const t of r){if(typeof t=="string"){const n=t.trim();if(n.startsWith("{"))try{const i=Cl(JSON.parse(n));if(i){e.push(i);continue}}catch{}if(RA(n)){const i=PA(n);if(i!==null){e.push(...zs(i));continue}}e.push(Ep(t));continue}if(t&&typeof t=="object"){const n=Cl(t);n&&e.push(n)}}return e}if(typeof r=="object"){const e=Cl(r);return e?[e]:[]}return[]}const $E=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,jE=/^\+?[0-9\s\-().]{7,20}$/,XE=/^\d{4}-\d{2}-\d{2}$/;function ky(r,e){const t=r[e.id];return e.type==="checkbox"?t===!0||t==="true"?"true":"false":String(t??"").trim()}function JE(r,e){const t={};for(const n of r){const i=ky(e,n);if(n.type==="checkbox"){n.required&&i!=="true"&&(t[n.id]=`${n.label} is required`);continue}if(n.required&&!i){t[n.id]=`${n.label} is required`;continue}if(!i)continue;const s=YE(n.type,i,n.label);s&&(t[n.id]=s),(n.type==="select"||n.type==="radio")&&n.options.length>0&&(n.options.map(A=>typeof A=="string"?A:A.value).includes(i)||(t[n.id]=`Select a valid ${n.label}`))}return t}function YE(r,e,t){switch(r){case"email":return $E.test(e)?null:`Enter a valid ${t}`;case"phone":return jE.test(e)?null:`Enter a valid phone number for ${t}`;case"number":return Number.isFinite(Number(e))?null:`${t} must be a number`;case"date":return XE.test(e)?Number.isNaN(Date.parse(e))?`Enter a valid ${t}`:null:`${t} must be YYYY-MM-DD`;default:return null}}function ZE(r,e){const t={};for(const n of r)t[n.id]=ky(e,n);return t}function Ty(r){if(r==null)return{};if(typeof r=="string"){const e=r.trim();if(!e)return{};try{return Ty(JSON.parse(e))}catch{return{}}}return typeof r=="object"&&!Array.isArray(r)?r:{}}function eU(r,e){const t=r.prefill??r.values??r.initial_values??r.defaults??e.prefill??e.values??e.initial_values??e.defaults;return Ty(t)}function Hd(r,e){if(r.type==="checkbox"){if(typeof e=="boolean")return e;const t=String(e).trim().toLowerCase();return t==="true"||t==="1"||t==="yes"||t==="on"}return String(e??"").trim()}function tU(r,e){const t=[r.id,r.label,r.label.toLowerCase()];for(const i of t){if(!(i in e))continue;const s=e[i];if(!(s==null||s===""))return Hd(r,s)}const n=sa(r.label);for(const[i,s]of Object.entries(e))if(!(s==null||s==="")&&(i===n||sa(i)===n||sa(i)===r.id))return Hd(r,s)}function nU(r,e={}){const t={};for(const n of r){if(n.value!==void 0){t[n.id]=Hd(n,n.value);continue}const i=tU(n,e);t[n.id]=i!==void 0?i:n.type==="checkbox"?!1:""}return t}const Sl="document-autocapture/",xy=4,Up="Align your ID inside the frame",rU="Ready — tap Capture now";let kl=null;function Ey(){if(typeof window<"u"&&window.location)return new URL(`/${Sl}`,window.location.origin).href;if(typeof document<"u")for(const r of document.getElementsByTagName("script")){const e=r.src;if(e&&/vanira-sdk/i.test(e))return new URL(Sl,e).href}return`/${Sl}`}function iU(){return new URL("index.js",Ey()).href}function sU(){return new URL("models/",Ey()).href}async function aU(){return kl||(kl=import(iU())),kl}function AU(r){const e=Math.round(r/xy*100);return Math.max(8,Math.min(98,e))}async function oU(r){const{createScanner:e}=await aU();return e({videoElement:r.video,autoCapture:!1,maxCaptures:1,quality:"fast",preferredMode:"fallback",detection:"auto",cocoSsd:!1,videoConstraints:{facingMode:{ideal:r.facingMode}},mlModelBaseUrl:sU(),captureMimeType:"image/jpeg",captureQuality:.9,outputMaxWidth:1920,postCaptureRefine:!0,confidenceThreshold:.24,minStableConfidence:.2,minRectangularity:.48,blurVarianceMin:6,glareRatioMax:.22,cvContourEnabled:!0,minAreaFraction:.04,autoCaptureMinAreaFraction:.06})}function cU(r,e,t){return .299*r+.587*e+.114*t}function lU(r,e,t){if(r.videoWidth===0||r.videoHeight===0)return null;const n=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const s=r.videoWidth,a=r.videoHeight,A=n.width,o=n.height,c=s/a,l=A/o;let d=0,u=0,h=s,p=a;c>l?(h=a*l,d=(s-h)/2):(p=s/l,u=(a-p)/2);const g=(i.left-n.left)/A,v=(i.top-n.top)/o,w=i.width/A,B=i.height/o;return{x:d+g*h,y:u+v*p,w:Math.max(1,w*h),h:Math.max(1,B*p)}}function dU(r,e,t){if(e<4||t<4)return 0;const n=[];for(let p=0;p<r.length;p+=4)n.push(cU(r[p],r[p+1],r[p+2]));let i=0;for(const p of n)i+=p;const s=i/n.length;let a=0;for(const p of n)a+=(p-s)**2;a/=n.length;const A=Math.sqrt(a);let o=0,c=0;for(let p=1;p<t-1;p++)for(let g=1;g<e-1;g++){const v=p*e+g,w=Math.abs(n[v+1]-n[v-1]),B=Math.abs(n[v+e]-n[v-e]);o+=w+B,c++}const l=c>0?o/c:0;if(s<35||A<12)return 0;const d=Math.min(1,A/55),u=Math.min(1,l/28),h=s>200?.75:1;return Math.min(1,(d*.55+u*.45)*h)}function uU(r,e,t,n,i){const s=lU(r,e,t);if(!s)return{inFrame:!1,score:0};const a=s.w/s.h;i.width=72,i.height=Math.max(40,Math.round(72/a)),n.drawImage(r,s.x,s.y,s.w,s.h,0,0,i.width,i.height);const A=n.getImageData(0,0,i.width,i.height),o=dU(A.data,i.width,i.height);return{inFrame:o>=.38,score:o}}const be={accent:"#111111",muted:"#6b7280",subtle:"#9ca3af",track:"#e5e7eb",success:"#16a34a",videoBg:"#000000",guideHint:"rgba(255,255,255,0.5)",guideReady:"rgba(255,255,255,0.92)",guideWarn:"rgba(255,255,255,0.35)",scrim:"0 0 0 9999px rgba(0,0,0,0.62)",hintBar:"rgba(0,0,0,0.82)"},Fp='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="m9 12 2 2 4-4"/></svg>',hU='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>',fU='<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>';function Uy(){return`
|
|
377
|
+
<div class="vnr-kyc-trust" role="note" aria-label="Security information">
|
|
378
|
+
<div class="vnr-kyc-trust-main">
|
|
379
|
+
<span class="vnr-kyc-trust-icon">${Fp}</span>
|
|
380
|
+
<div class="vnr-kyc-trust-text">
|
|
381
|
+
<p class="vnr-kyc-trust-title">Secure verification</p>
|
|
382
|
+
<p class="vnr-kyc-trust-copy">Captured locally in your browser and sent over an encrypted connection. Nothing is saved on your device after upload.</p>
|
|
383
|
+
</div>
|
|
384
|
+
</div>
|
|
385
|
+
<div class="vnr-kyc-trust-chips">
|
|
386
|
+
<span class="vnr-kyc-trust-chip">${hU} TLS encrypted</span>
|
|
387
|
+
<span class="vnr-kyc-trust-chip">${fU} Browser-only</span>
|
|
388
|
+
<span class="vnr-kyc-trust-chip">${Fp.replace('width="18" height="18"','width="11" height="11"')} Private session</span>
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
`}const pU=85.6/53.98;function mU(r){return typeof navigator>"u"?{}:{userAgent:navigator.userAgent||"",maxTouchPoints:navigator.maxTouchPoints,innerWidth:typeof window<"u"?window.innerWidth:void 0}}function Fy(r){const{userAgent:e="",maxTouchPoints:t=0,innerWidth:n}=mU();return!!(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e)||t>1&&typeof n=="number"&&n<1024)}function gU(r){return Fy()?"environment":"user"}function vU(){return"user"}function yU(r){return Fy()?"mobile":"desktop"}function wU(r,e){const t=Math.min(r.length,e.length);if(t===0)return 0;let n=0;for(let i=0;i<t;i+=4)n+=Math.abs(r[i]-e[i]),n+=Math.abs(r[i+1]-e[i+1]),n+=Math.abs(r[i+2]-e[i+2]);return n/(t/4*3)}const Nd=.5,Kd=.5,bU=.24,Vd=.4,BU=.28,CU=.42,SU=2,kU=.1;function TU(r,e,t){const n=Math.max(r,e,t),i=Math.min(r,e,t);if(n<40||n-i<10)return!1;const s=.299*r+.587*e+.114*t,a=128-.168736*r-.331264*e+.5*t,A=128+.5*r-.418688*e-.081312*t,o=s>55&&a>70&&a<135&&A>125&&A<185,c=r>45&&e>28&&t>18&&r>=e-8&&e>=t-10&&r-t>10;return o||c}function Ip(r,e,t=1){const n=(r-Nd)/(bU*t),i=(e-Kd)/(Vd*t);return n*n+i*i<=1}function xU(r,e,t){let n=0,i=0,s=0,a=0,A=0,o=0,c=0,l=0,d=0;const u=Math.max(1,Math.floor(t/56)),h=Math.max(1,Math.floor(e/56));for(let C=0;C<t;C+=u){const T=(C+.5)/t;for(let F=0;F<e;F+=h){const R=(F+.5)/e,M=(C*e+F)*4,D=r[M],O=r[M+1],H=r[M+2],se=TU(D,O,H);Ip(R,T)?(n++,se&&(i++,R<Nd?s++:a++,T<Kd-Vd*.22?A++:T>Kd+Vd*.22?c++:o++)):se&&Ip(R,T,1.45)&&(R<Nd?l++:d++)}}if(n===0)return{framed:!1,guideText:"Center your face in the oval",guideColor:be.muted};const p=i/n,g=i>0?Math.min(s,a)/Math.max(s,a,1):0,v=[A,o,c].filter(C=>C>0).length,w=i>0?Math.min(A,o,c)/Math.max(i,1):0,B=Math.max(l,d),E=Math.min(s,a),b=i>0&&g<.5&&B>E*.45&&B>i*.08;return p<BU?{framed:!1,guideText:"Move closer — fill the oval with your face",guideColor:be.muted}:g<CU||b?{framed:!1,guideText:"Center your full face in the oval",guideColor:be.muted}:v<SU||w<kU?{framed:!1,guideText:"Align your full face inside the oval",guideColor:be.muted}:{framed:!0,guideText:"Face aligned",guideColor:be.guideReady}}const Qp=6,EU=15,UU=2800;class FU{constructor(){L(this,"prevPixels",null);L(this,"baselineDiffs",[]);L(this,"baseline",1);L(this,"phase","framing");L(this,"calibrationFrames",0);L(this,"framedStreak",0);L(this,"unframedGrace",0);L(this,"actionProgress",0);L(this,"actionDetected",!1);L(this,"actionStartedAt",0)}reset(){this.prevPixels=null,this.baselineDiffs=[],this.baseline=1,this.phase="framing",this.calibrationFrames=0,this.framedStreak=0,this.unframedGrace=0,this.actionProgress=0,this.actionDetected=!1,this.actionStartedAt=0}resetLiveness(){this.prevPixels=null,this.baselineDiffs=[],this.baseline=1,this.phase="framing",this.calibrationFrames=0,this.framedStreak=0,this.unframedGrace=0,this.actionProgress=0,this.actionDetected=!1,this.actionStartedAt=0}tick(e,t,n){const i=xU(e,t,n),s=this.phase==="calibrating"||this.phase==="action";if(i.framed)this.unframedGrace=0;else if(s&&this.unframedGrace<EU)this.unframedGrace++;else return this.resetLiveness(),{phase:"framing",progressPct:Math.min(20,Math.round(this.framedStreak*2)),guideText:i.guideText,guideColor:i.guideColor,verified:!1,framed:!1};const a=i.framed||s;if(this.framedStreak++,this.framedStreak<Qp&&this.phase==="framing")return{phase:"framing",progressPct:Math.min(25,Math.round(this.framedStreak/Qp*25)),guideText:"Hold your face in the oval…",guideColor:be.subtle,verified:!1,framed:a};this.phase==="framing"&&(this.phase="calibrating");let A=0;if(this.prevPixels&&(A=wU(this.prevPixels,e)),this.prevPixels=e,this.phase==="calibrating"){A>0&&(this.calibrationFrames++,this.baselineDiffs.push(A));const o=25+Math.min(15,Math.round(this.calibrationFrames/12*15));if(this.calibrationFrames>=12){const c=this.baselineDiffs.reduce((l,d)=>l+d,0);this.baseline=Math.max(.2,c/this.baselineDiffs.length),this.phase="action",this.actionStartedAt=Date.now()}return{phase:"calibrating",progressPct:o,guideText:"Hold still…",guideColor:be.subtle,verified:!1,framed:a}}if(this.phase==="action"){const o=Math.max(2.5,this.baseline*2.5);A>o&&A<40&&(this.actionProgress=Math.min(50,this.actionProgress+18),this.actionDetected=!0);const c=A<=o*2,l=this.actionDetected&&(this.actionProgress>=30||c),d=this.actionStartedAt>0&&Date.now()-this.actionStartedAt>=UU;return l||d?(this.phase="verified",{phase:"verified",progressPct:100,guideText:"✓ Capturing…",guideColor:be.success,verified:!0,framed:a}):{phase:"action",progressPct:40+Math.min(50,this.actionProgress),guideText:d?"✓ Capturing…":"Blink once or turn slightly",guideColor:be.muted,verified:!1,framed:a}}return{phase:"verified",progressPct:100,guideText:"✓ Capturing…",guideColor:be.success,verified:!0,framed:a}}}const IU=100,QU=450;function Mp(r){if(!(r instanceof Error))return!1;const e=r.name;return e==="NotAllowedError"||e==="PermissionDeniedError"||/permission/i.test(r.message)}function MU(r){const{mode:e,presetId:t,title:n,description:i,reason:s,documentSide:a="front",toolCallId:A,host:o,client:c,onComplete:l,onCancel:d,isActive:u}=r,h=e==="document"?gU():vU(),p=yU();let g=null,v=null,w=[],B=null,E=!1,b=!1,C=0,T=0,F=!1;o.setCaptureActive(!0);const R=o.createOverlay(),M=document.createElement("div");M.className="vnr-modal",M.style.cssText="position:relative;max-width:520px;width:100%";const D=e==="document"?"document":"oval",O=e==="document"?`border:2px dashed ${be.guideHint};border-radius:12px;width:min(88%,340px);aspect-ratio:${pU};box-shadow:${be.scrim};transition:border-color 0.25s ease`:`border:2px dashed ${be.guideHint};border-radius:50%;width:180px;height:240px;box-shadow:${be.scrim};transition:border-color 0.25s ease`;M.innerHTML=`
|
|
392
|
+
<button class="vnr-close-btn" aria-label="Close">
|
|
393
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
394
|
+
</button>
|
|
395
|
+
<h2 class="vnr-title" style="padding-right:32px">${n}</h2>
|
|
396
|
+
<p style="margin:0 0 10px;font-size:13px;color:#6b7280;line-height:1.5">${i}</p>
|
|
397
|
+
<p style="margin:0 0 12px;font-size:11px;color:#9ca3af">${e==="document"?"Manual capture":"Auto-capture after liveness"} · ${p} · ${h==="user"?"front camera":"rear camera"}</p>
|
|
398
|
+
<div class="vnr-video-wrap" id="vnr-kyc-wrap" style="position:relative;min-height:220px;background:${be.videoBg};border-radius:12px;overflow:hidden">
|
|
399
|
+
<video id="vnr-kyc-video" autoplay playsinline muted style="width:100%;display:block;object-fit:cover;min-height:220px"></video>
|
|
400
|
+
<div id="vnr-kyc-hint" style="display:none;position:absolute;top:10px;left:10px;right:10px;z-index:2;text-align:center;color:#fff;font-size:11px;font-weight:600;background:${be.hintBar};padding:7px 10px;border-radius:8px;border:1px solid rgba(255,255,255,0.12);pointer-events:none"></div>
|
|
401
|
+
<div id="vnr-kyc-guide" data-shape="${D}" style="display:none;position:absolute;inset:0;pointer-events:none;margin:auto;${O}"></div>
|
|
402
|
+
<div id="vnr-kyc-overlay" style="position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:${be.videoBg}">
|
|
403
|
+
<div class="vnr-spinner" style="width:32px;height:32px;border-width:3px;border-color:rgba(255,255,255,.15);border-top-color:#fff"></div>
|
|
404
|
+
<p style="margin:0;font-size:13px;color:#94a3b8">Opening camera…</p>
|
|
405
|
+
</div>
|
|
406
|
+
</div>
|
|
407
|
+
<div id="vnr-kyc-progress-wrap" style="display:none;margin-top:12px">
|
|
408
|
+
<div style="display:flex;justify-content:space-between;font-size:11px;font-weight:700;color:#6b7280;margin-bottom:6px;letter-spacing:0.04em">
|
|
409
|
+
<span>${e==="document"?"ID IN FRAME":"LIVENESS"}</span>
|
|
410
|
+
<span id="vnr-kyc-pct" style="color:${be.accent}">0%</span>
|
|
411
|
+
</div>
|
|
412
|
+
<div style="width:100%;height:4px;background:${be.track};border-radius:2px;overflow:hidden">
|
|
413
|
+
<div id="vnr-kyc-bar" style="width:0%;height:100%;background:${be.accent};transition:width 0.1s linear"></div>
|
|
414
|
+
</div>
|
|
415
|
+
</div>
|
|
416
|
+
<canvas id="vnr-kyc-canvas" style="display:none"></canvas>
|
|
417
|
+
<div id="vnr-kyc-status" style="display:none;margin-top:12px"></div>
|
|
418
|
+
${Uy()}
|
|
419
|
+
<div class="vnr-actions" style="margin-top:14px${e==="document"?";display:flex;gap:8px":""}">
|
|
420
|
+
${e==="document"?'<button type="button" id="vnr-kyc-capture-now" class="vnr-confirm-btn">Capture now</button>':""}
|
|
421
|
+
<button class="vnr-cancel-btn" id="vnr-kyc-cancel"${e==="document"?' style="flex:1"':""}>Cancel</button>
|
|
422
|
+
</div>
|
|
423
|
+
`,R.appendChild(M);const H=M.querySelector("#vnr-kyc-video"),se=M.querySelector("#vnr-kyc-canvas"),ie=M.querySelector("#vnr-kyc-overlay"),Z=M.querySelector("#vnr-kyc-status"),ee=M.querySelector("#vnr-kyc-guide"),ue=M.querySelector("#vnr-kyc-hint"),Ce=e==="selfie"?(()=>{const ae=document.createElement("div");return ae.id="vnr-kyc-guide-text",ae.style.cssText=`position:absolute;bottom:-48px;left:-48px;right:-48px;text-align:center;color:#fff;font-size:11px;font-weight:600;background:${be.hintBar};padding:8px 10px;border-radius:8px;border:1px solid rgba(255,255,255,0.12)`,ee.appendChild(ae),ae})():ue,Ue=e==="document"?M.querySelector("#vnr-kyc-capture-now"):null,Ge=M.querySelector("#vnr-kyc-wrap"),qe=M.querySelector("#vnr-kyc-progress-wrap"),We=M.querySelector("#vnr-kyc-bar"),gt=M.querySelector("#vnr-kyc-pct"),$e=document.createElement("canvas"),en=$e.getContext("2d");e==="selfie"?($e.width=120,$e.height=160):($e.width=80,$e.height=60);const Mt=e==="selfie"?new FU:null,vt=()=>{if(e!=="document"&&!M.querySelector(".vnr-live-badge")){const ae=document.createElement("div");ae.className="vnr-live-badge",ae.innerHTML='<span class="vnr-live-dot"></span>AUTO',M.querySelector("#vnr-kyc-wrap").appendChild(ae)}},_t=()=>{B&&(clearInterval(B),B=null);for(const ae of w)ae();w=[],v&&(v.destroy(),v=null),g==null||g.getTracks().forEach(ae=>ae.stop()),g=null,o.setCaptureStream(null),H.srcObject=null},_e=ae=>{b||(b=!0,_t(),o.setCaptureActive(!1),ae&&d(ae))};M.querySelector(".vnr-close-btn").addEventListener("click",()=>{_e("User closed"),o.dismiss()}),M.querySelector("#vnr-kyc-cancel").addEventListener("click",()=>{_e("User cancelled"),o.dismiss()});const on=(ae,pe,ft,tn)=>c!=null&&c.uploadMedia?c.uploadMedia(ae,s,ft).then(({media_id:Dn,url:rr})=>{Z.innerHTML='<div class="vnr-center" style="color:#16a34a">✓ Uploaded</div>',o.setCaptureActive(!1),setTimeout(()=>{o.dismiss(),l({status:"success",preset_id:t,reason:s,media_id:Dn,url:rr,file_name:ae.name,file_type:ae.type,file_size:ae.size,facing_mode:h,device_class:p,auto_captured:!0,liveness_passed:!0,message:ft,...pe})},350)}):(o.setCaptureActive(!1),o.dismiss(),l({status:"success",preset_id:t,reason:s,data_url:tn,facing_mode:h,device_class:p,auto_captured:!0,liveness_passed:!0,message:"Capture complete (no upload client).",...pe}),Promise.resolve()),ms=async()=>{if(!(E||b)&&!(H.videoWidth===0||H.videoHeight===0)){E=!0,se.width=H.videoWidth,se.height=H.videoHeight,se.getContext("2d").drawImage(H,0,0),await(v==null?void 0:v.stop()),_t(),ee.style.display="none",qe.style.display="none",Z.style.display="block",Z.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Uploading…</div>';try{const ae=await new Promise(tn=>se.toBlob(Dn=>tn(Dn),"image/jpeg",.9));if(!ae)throw new Error("Capture failed");const pe=`kyc-id-${a}`,ft=new File([ae],`${pe}-${Date.now()}.jpg`,{type:"image/jpeg"});await on(ft,{document_side:a,quality_score:.7,capture_engine:"vanira-raw-frame",manual_capture:!0},`ID document (${a}) captured and uploaded.`,se.toDataURL("image/jpeg",.9))}catch(ae){E=!1,F=!1;const pe=ae instanceof Error?ae.message:"Upload failed";Z.innerHTML=`<div class="vnr-center" style="color:#ef4444">${pe}</div>`,d(pe)}}},gs=async()=>{if(!(F||E||b||!v)){F=!0,Ce.innerText="Capturing…",ee.style.borderColor=be.guideReady;try{const ae=await v.captureManual();await lc(ae)}catch{F=!1,await ms()}}},lc=async ae=>{var pe;if(!(E||b)){E=!0,F=!0,C=(pe=ae.quality)!=null&&pe.ok?.92:.75,await(v==null?void 0:v.stop()),g=null,o.setCaptureStream(null),ee.style.display="none",ee.style.borderColor=be.guideReady,qe.style.display="none",Z.style.display="block",Z.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Uploading…</div>';try{const ft=`kyc-id-${a}`,tn=new File([ae.blob],`${ft}-${Date.now()}.jpg`,{type:ae.blob.type||"image/jpeg"});await on(tn,{document_side:a,quality_score:C,capture_engine:"js-document-autocapture",warp_tier:ae.warpTierUsed,output_width:ae.width,output_height:ae.height},`ID document (${a}) captured and uploaded.`)}catch(ft){E=!1,F=!1;const tn=ft instanceof Error?ft.message:"Upload failed";Z.innerHTML=`<div class="vnr-center" style="color:#ef4444">${tn}</div>`,d(tn)}}};e==="document"&&M.querySelector("#vnr-kyc-capture-now").addEventListener("click",()=>{gs()});const vs=async()=>{if(E||b||H.videoWidth===0||H.videoHeight===0)return;E=!0,se.width=H.videoWidth,se.height=H.videoHeight,se.getContext("2d").drawImage(H,0,0),_t(),ee.style.display="none",qe.style.display="none",Z.style.display="block",Z.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Uploading…</div>';try{const pe=await new Promise(Dn=>se.toBlob(rr=>Dn(rr),"image/jpeg",.9));if(!pe)throw new Error("Capture failed");const ft=new File([pe],`kyc-selfie-${Date.now()}.jpg`,{type:"image/jpeg"}),tn=se.toDataURL("image/jpeg",.9);await on(ft,{face_quality_score:.85},"Selfie captured and uploaded.",tn)}catch(pe){E=!1;const ft=pe instanceof Error?pe.message:"Upload failed";Z.innerHTML=`<div class="vnr-center" style="color:#ef4444">${ft}</div>`,d(ft)}},Ui=async()=>{var ae;if(!(!u()||b)){if(ie.style.display="flex",v){for(const pe of w)pe();w=[],await v.destroy(),v=null}v=await oU({video:H,facingMode:h}),w.push(v.on("frame",pe=>{const ft=pe.detection.status==="found",tn=uU(H,Ge,ee,en,$e),Dn=ft||tn.inFrame;Dn?T=Math.min(xy,T+1):T=Math.max(0,T-1);const rr=T>=2,t0=Dn?AU(T):Math.round(tn.score*40);We.style.width=rr?"100%":`${Math.max(8,t0)}%`,gt.innerText=rr?"Ready":Dn?`${t0}%`:"—",gt.style.color=rr?be.accent:be.subtle,ee.style.borderColor=rr?be.guideReady:Dn?be.guideHint:be.guideWarn,ue.innerText=rr?rU:Up,Ue&&(Ue.style.opacity="1",Ue.style.cursor="pointer")}),v.on("error",pe=>{var ft;!u()||b||E||Mp(pe)&&(v==null||v.stop(),(ft=o.notifyCameraPermissionDenied)==null||ft.call(o,c,A),o.fillCameraPermissionPrompt(ie,{onRetry:()=>{ie.innerHTML=`
|
|
424
|
+
<div class="vnr-spinner" style="width:32px;height:32px;border-width:3px;border-color:rgba(255,255,255,.15);border-top-color:#fff"></div>
|
|
425
|
+
<p style="margin:0;font-size:13px;color:#94a3b8">Opening camera…</p>
|
|
426
|
+
`,ie.style.display="flex",Ui()},onDismiss:()=>{_e("Camera permission denied"),o.dismiss()}}))}));try{if(await v.start(),!u()||b){await v.destroy();return}ie.style.display="none",ee.style.display="block",ue.style.display="block",qe.style.display="block",ue.innerText=Up,Ue&&(Ue.style.opacity="1",Ue.style.cursor="pointer"),vt(),g=H.srcObject,g&&o.setCaptureStream(g)}catch(pe){if(!u()||b)return;if(Mp(pe)){(ae=o.notifyCameraPermissionDenied)==null||ae.call(o,c,A),o.fillCameraPermissionPrompt(ie,{onRetry:()=>{ie.innerHTML=`
|
|
427
|
+
<div class="vnr-spinner" style="width:32px;height:32px;border-width:3px;border-color:rgba(255,255,255,.15);border-top-color:#fff"></div>
|
|
428
|
+
<p style="margin:0;font-size:13px;color:#94a3b8">Opening camera…</p>
|
|
429
|
+
`,ie.style.display="flex",Ui()},onDismiss:()=>{_e("Camera permission denied"),o.dismiss()}});return}_e(pe instanceof Error?pe.message:"Camera failed"),o.dismiss()}}},Ia=()=>{ee.style.display="block",qe.style.display="block",vt(),B=setInterval(()=>{if(!g||H.paused||H.ended||E||b||!Mt)return;en.drawImage(H,0,0,$e.width,$e.height);const ae=en.getImageData(0,0,$e.width,$e.height),pe=Mt.tick(ae.data,$e.width,$e.height);Ce.innerText=pe.guideText,Ce.style.color=pe.guideColor,We.style.width=`${pe.progressPct}%`,gt.innerText=`${pe.progressPct}%`,We.style.backgroundColor=pe.verified?be.success:be.accent,gt.style.color=pe.verified?be.success:be.accent,pe.framed?ee.style.borderColor=pe.verified?be.success:be.guideReady:(ee.style.borderColor=be.guideWarn,ee.style.boxShadow=be.scrim),pe.verified&&pe.framed&&(ee.style.borderColor=be.success,ee.style.boxShadow=be.scrim,B&&(clearInterval(B),B=null),setTimeout(()=>vs(),QU))},IU)},Fi=()=>{u()&&(ie.style.display="flex",navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:h}},audio:!1}).then(ae=>{if(!u()){ae.getTracks().forEach(pe=>pe.stop());return}return g=ae,o.setCaptureStream(ae),H.srcObject=ae,H.play().catch(()=>{})}).then(()=>{if(!u()||!g)return;ie.style.display="none";const ae=()=>{if(H.videoWidth>0&&H.videoHeight>0){Ia();return}requestAnimationFrame(ae)};ae()}).catch(()=>{var ae;u()&&((ae=o.notifyCameraPermissionDenied)==null||ae.call(o,c,A),o.fillCameraPermissionPrompt(ie,{onRetry:Fi,onDismiss:()=>{_e("Camera permission denied"),o.dismiss()}}))}))};return e==="document"?Ui():Fi(),{stop:()=>{_e()}}}const _U="#111111",_p=24;function RU(r){const{presetId:e,title:t,description:n,reason:i,host:s,client:a,onComplete:A,onCancel:o}=r;let c=!1,l=0,d=!1;const u=s.createOverlay(),h=document.createElement("div");h.className="vnr-modal",h.style.cssText="position:relative;max-width:520px;width:100%",h.innerHTML=`
|
|
430
|
+
<button class="vnr-close-btn" aria-label="Close">
|
|
431
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
432
|
+
</button>
|
|
433
|
+
<h2 class="vnr-title" style="padding-right:32px">${t}</h2>
|
|
434
|
+
<p style="margin:0 0 12px;font-size:13px;color:#6b7280;line-height:1.5">${n}</p>
|
|
435
|
+
<div style="position:relative;border:1px solid #e5e7eb;border-radius:12px;background:#fff;overflow:hidden;touch-action:none">
|
|
436
|
+
<canvas id="vnr-kyc-sig-canvas" style="display:block;width:100%;height:180px;cursor:crosshair"></canvas>
|
|
437
|
+
<div style="position:absolute;left:16px;right:16px;bottom:12px;border-bottom:1px dashed #cbd5e1;pointer-events:none"></div>
|
|
438
|
+
<p style="position:absolute;left:16px;bottom:16px;margin:0;font-size:10px;color:#94a3b8;pointer-events:none">Sign above the line</p>
|
|
439
|
+
</div>
|
|
440
|
+
<div id="vnr-kyc-sig-status" style="display:none;margin-top:12px"></div>
|
|
441
|
+
${Uy()}
|
|
442
|
+
<div class="vnr-actions" style="margin-top:14px">
|
|
443
|
+
<button class="vnr-cancel-btn" id="vnr-kyc-sig-cancel">Cancel</button>
|
|
444
|
+
<button class="vnr-cancel-btn" id="vnr-kyc-sig-clear" type="button">Clear</button>
|
|
445
|
+
<button class="vnr-confirm-btn" id="vnr-kyc-sig-submit" disabled>Submit signature</button>
|
|
446
|
+
</div>
|
|
447
|
+
`,u.appendChild(h);const p=h.querySelector("#vnr-kyc-sig-canvas"),g=h.querySelector("#vnr-kyc-sig-status"),v=h.querySelector("#vnr-kyc-sig-submit"),w=p.getContext("2d"),B=()=>{const D=p.getBoundingClientRect(),O=window.devicePixelRatio||1;p.width=Math.max(1,Math.floor(D.width*O)),p.height=Math.max(1,Math.floor(D.height*O)),w.setTransform(1,0,0,1,0,0),w.scale(O,O),w.lineCap="round",w.lineJoin="round",w.lineWidth=2.2,w.strokeStyle=_U};B(),window.addEventListener("resize",B);const E=()=>{c||(c=!0,window.removeEventListener("resize",B))},b=D=>{const O=p.getBoundingClientRect();return{x:D.clientX-O.left,y:D.clientY-O.top}},C=()=>{v.disabled=l<_p},T=()=>{const D=p.getBoundingClientRect();w.clearRect(0,0,D.width,D.height),l=0,C()},F=D=>{if(c)return;d=!0,p.setPointerCapture(D.pointerId);const{x:O,y:H}=b(D);w.beginPath(),w.moveTo(O,H)},R=D=>{if(!d||c)return;const{x:O,y:H}=b(D);w.lineTo(O,H),w.stroke(),l++,C()},M=D=>{if(d){d=!1;try{p.releasePointerCapture(D.pointerId)}catch{}}};return p.addEventListener("pointerdown",F),p.addEventListener("pointermove",R),p.addEventListener("pointerup",M),p.addEventListener("pointercancel",M),p.addEventListener("pointerleave",M),h.querySelector(".vnr-close-btn").addEventListener("click",()=>{E(),s.dismiss(),o("User closed")}),h.querySelector("#vnr-kyc-sig-cancel").addEventListener("click",()=>{E(),s.dismiss(),o("User cancelled")}),h.querySelector("#vnr-kyc-sig-clear").addEventListener("click",T),v.addEventListener("click",async()=>{if(!(l<_p||c)){c=!0,v.disabled=!0,g.style.display="block",g.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Uploading signature…</div>';try{const D=await new Promise(H=>{p.toBlob(se=>H(se),"image/png")});if(!D)throw new Error("Signature export failed");const O=new File([D],`kyc-signature-${Date.now()}.png`,{type:"image/png"});if(a!=null&&a.uploadMedia){const{media_id:H,url:se}=await a.uploadMedia(O,i,"KYC signature captured");g.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ Signature uploaded</div>',setTimeout(()=>{s.dismiss(),A({status:"success",preset_id:e,reason:i,media_id:H,url:se,file_name:O.name,file_type:O.type,file_size:O.size,stroke_points:l,message:"Signature captured and uploaded."})},350)}else{const H=p.toDataURL("image/png");s.dismiss(),A({status:"success",preset_id:e,reason:i,data_url:H,stroke_points:l,message:"Signature captured (no upload client)."})}}catch(D){c=!1;const O=D instanceof Error?D.message:"Upload failed";g.innerHTML=`<div class="vnr-center" style="color:#ef4444">${O}</div>`,v.disabled=!1}}}),{stop:E}}const Rp="vanira:board_abort";function Tl(r){if(!r)return"";if(typeof r=="string"){if(r.includes("T")||!isNaN(Date.parse(r)))try{return new Date(r).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}catch{}return r}if(typeof r=="object"){const e=r.start||r.startTime||r.time||r.slot,t=r.end||r.endTime;if(e){let n=String(e),i=t?String(t):"";try{(n.includes("T")||!isNaN(Date.parse(n)))&&(n=new Date(n).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})),i&&(i.includes("T")||!isNaN(Date.parse(i)))&&(i=new Date(i).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}))}catch{}return i?`${n} - ${i}`:n}}return String(r)}function PU(r,e,t,n){let i=Date.UTC(r,e,t,0,0,0,0),s=Date.UTC(r,e,t,23,59,59,999);if(n)try{const a=new Date(Date.UTC(r,e,t,12,0,0)),o=new Intl.DateTimeFormat("en-US",{timeZone:n,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(a),c=E=>{var b;return(b=o.find(C=>C.type===E))==null?void 0:b.value},l=parseInt(c("year")||"0",10),d=parseInt(c("month")||"0",10)-1,u=parseInt(c("day")||"0",10),h=parseInt(c("hour")||"0",10),p=parseInt(c("minute")||"0",10),g=parseInt(c("second")||"0",10),v=h===24?0:h,B=Date.UTC(l,d,u,v,p,g,0)-a.getTime();i=Date.UTC(r,e,t,0,0,0,0)-B,s=Date.UTC(r,e,t,23,59,59,999)-B}catch{}return{start:new Date(i),end:new Date(s)}}function DU(r,e){if(!e){const t=-r.getTimezoneOffset(),n=t>=0?"+":"-",i=a=>String(a).padStart(2,"0"),s=a=>String(a).padStart(3,"0");return r.getFullYear()+"-"+i(r.getMonth()+1)+"-"+i(r.getDate())+"T"+i(r.getHours())+":"+i(r.getMinutes())+":"+i(r.getSeconds())+"."+s(r.getMilliseconds())+n+i(Math.floor(Math.abs(t)/60))+":"+i(Math.abs(t)%60)}try{const n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(r),i=F=>{var R;return((R=n.find(M=>M.type===F))==null?void 0:R.value)||"0"},s=i("year"),a=i("month").padStart(2,"0"),A=i("day").padStart(2,"0");let o=parseInt(i("hour"),10);o===24&&(o=0);const c=String(o).padStart(2,"0"),l=i("minute").padStart(2,"0"),d=i("second").padStart(2,"0"),u=String(r.getMilliseconds()).padStart(3,"0"),h=parseInt(s,10),p=parseInt(a,10)-1,g=parseInt(A,10),w=Date.UTC(h,p,g,o,parseInt(l,10),parseInt(d,10),r.getMilliseconds())-r.getTime(),B=Math.round(w/6e4),E=B>=0?"+":"-",b=Math.abs(B),C=String(Math.floor(b/60)).padStart(2,"0"),T=String(b%60).padStart(2,"0");return`${s}-${a}-${A}T${c}:${l}:${d}.${u}${E}${C}:${T}`}catch{return r.toISOString()}}const LU=`
|
|
115
448
|
.vnr-overlay {
|
|
116
449
|
position: fixed; inset: 0; z-index: 2147483647;
|
|
117
450
|
background: rgba(0,0,0,0.45);
|
|
@@ -132,11 +465,13 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
132
465
|
pointer-events: auto;
|
|
133
466
|
}
|
|
134
467
|
.vnr-overlay.vnr-whiteboard-overlay-expanded {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
468
|
+
display: flex;
|
|
469
|
+
align-items: flex-end;
|
|
470
|
+
justify-content: center;
|
|
471
|
+
padding: max(48px, calc(24px + env(safe-area-inset-top, 0px))) 16px max(104px, calc(72px + env(safe-area-inset-bottom, 0px)));
|
|
472
|
+
}
|
|
473
|
+
.vnr-overlay.vnr-whiteboard-overlay-expanded .vnr-whiteboard-modal {
|
|
474
|
+
translate: 0 20px;
|
|
140
475
|
}
|
|
141
476
|
.vnr-overlay.vnr-whiteboard-overlay-reduced {
|
|
142
477
|
display: block;
|
|
@@ -231,6 +566,15 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
231
566
|
.vnr-video-wrap video { width:100%; height:100%; object-fit:cover; display:block; }
|
|
232
567
|
.vnr-live-badge { position:absolute; top:10px; left:10px; display:flex; align-items:center; gap:6px; padding:3px 9px; border-radius:999px; background:rgba(15,23,42,0.72); border:1px solid rgba(255,255,255,0.1); font-size:11px; font-weight:600; color:#f8fafc; text-transform:uppercase; letter-spacing:.04em; }
|
|
233
568
|
.vnr-live-dot { width:7px; height:7px; border-radius:50%; background:#22c55e; flex-shrink:0; }
|
|
569
|
+
.vnr-kyc-trust { margin-top:12px; padding:12px 14px; border-radius:12px; background:#f9fafb; border:1px solid #e5e7eb; }
|
|
570
|
+
.vnr-kyc-trust-main { display:flex; align-items:flex-start; gap:10px; }
|
|
571
|
+
.vnr-kyc-trust-icon { display:flex; align-items:center; justify-content:center; flex-shrink:0; width:34px; height:34px; border-radius:10px; background:#111; color:#fff; }
|
|
572
|
+
.vnr-kyc-trust-text { min-width:0; }
|
|
573
|
+
.vnr-kyc-trust-title { margin:0 0 4px; font-size:12px; font-weight:700; color:#111; letter-spacing:-0.01em; }
|
|
574
|
+
.vnr-kyc-trust-copy { margin:0; font-size:11px; line-height:1.45; color:#6b7280; }
|
|
575
|
+
.vnr-kyc-trust-chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
|
|
576
|
+
.vnr-kyc-trust-chip { display:inline-flex; align-items:center; gap:5px; padding:4px 8px; border-radius:999px; background:#fff; border:1px solid #e5e7eb; font-size:10px; font-weight:600; color:#374151; letter-spacing:0.02em; }
|
|
577
|
+
.vnr-kyc-trust-chip svg { flex-shrink:0; color:#111; }
|
|
234
578
|
/* Upload dropzone */
|
|
235
579
|
.vnr-dropzone { border:2px dashed #cbd5e1; border-radius:14px; padding:32px 20px; text-align:center; cursor:pointer; background:#fafafa; transition:border-color 0.2s,background 0.2s; }
|
|
236
580
|
.vnr-dropzone:hover, .vnr-dropzone.drag { border-color:#374151; background:#f3f4f6; }
|
|
@@ -242,7 +586,7 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
242
586
|
}
|
|
243
587
|
.vnr-click-pulse {
|
|
244
588
|
animation: vnr-click-pulse 0.45s ease-out;
|
|
245
|
-
outline: 2px solid #
|
|
589
|
+
outline: 2px solid #111 !important;
|
|
246
590
|
outline-offset: 3px !important;
|
|
247
591
|
}
|
|
248
592
|
/* Whiteboard */
|
|
@@ -254,6 +598,7 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
254
598
|
flex-shrink: 0;
|
|
255
599
|
box-sizing: border-box;
|
|
256
600
|
transition: width 0.2s ease, max-width 0.2s ease, height 0.2s ease, max-height 0.2s ease;
|
|
601
|
+
background-color: #0a1810;
|
|
257
602
|
}
|
|
258
603
|
.vnr-overlay.vnr-whiteboard-overlay-reduced .vnr-whiteboard-modal {
|
|
259
604
|
box-shadow: 0 20px 52px rgba(0,0,0,0.6) !important;
|
|
@@ -268,8 +613,8 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
268
613
|
justify-content: flex-end;
|
|
269
614
|
gap: 6px;
|
|
270
615
|
padding: 8px 10px;
|
|
271
|
-
background: linear-gradient(180deg, #
|
|
272
|
-
border-bottom: 1px solid rgba(255,255,255,0.
|
|
616
|
+
background: linear-gradient(180deg, #122a1c 0%, #0a1810 100%);
|
|
617
|
+
border-bottom: 1px solid rgba(255,255,255,0.06);
|
|
273
618
|
z-index: 30;
|
|
274
619
|
}
|
|
275
620
|
.vnr-overlay.vnr-whiteboard-overlay-reduced .vnr-whiteboard-header {
|
|
@@ -301,9 +646,63 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
301
646
|
color: #fecaca;
|
|
302
647
|
}
|
|
303
648
|
.vnr-whiteboard-action-btn.is-close:hover { background: rgba(239,68,68,0.2); }
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
`).trim();return{chapterTitle:s,body:i}}getBoardSnapshot(){this.syncChalkboardNotes();const e=this.boardInk.strokes.length>0||this.boardInk.labels.length>0,t=this.chalkboardContent;return{board_layout:e?"diagram_top_notes_bottom":"notes_full",has_diagram:e,strokes_on_board:this.boardInk.strokes.length,labels_on_board:this.boardInk.labels.length,board_size:{width:K,height:Z},coordinate_system:"board_normalized_or_pixels",notes_content:t,notes_char_count:t.length,chapter_title:this.boardChapterTitle||null,agent_hint:e?"TOP = diagram (800×500), BOTTOM = notes. strokes:[{points,close}] — right △: [[0.15,0.25],[0.15,0.75],[0.55,0.75]]. labels below (y≥0.78). clear_old_diagrams_on_board:true wipes.":'draw_on_board: strokes:[{points:[[0.15,0.25],[0.15,0.75],[0.55,0.75]],close:true}] for right triangle. labels:[{x:0.35,y:0.82,text:"..."}]. NOT bare points string or centered apex.'}}syncDiagramLayer(e){Ut(e,this.boardInk,{strokeColor:"#ffffff",labelColor:"#4A9EFF",strokeWidth:6})}getBoardProgressSnapshot(){const e=this.activeBoardProgress;if(!e||e.plannedUnits<=0)return null;const t=this.chalkboardContent,r=e.mode==="type"?t.slice(e.textAtStart.length):t;return{write_progress_pct:Math.min(100,Math.round(e.unitsDone/e.plannedUnits*100)),characters_written:e.unitsDone,characters_planned:e.plannedUnits,partial_text_this_command:r}}getNavigateTerminalResult(e,t,r){return{status:e,reason:t||(e==="interrupted"?"Server interrupted":"Navigation cancelled"),preset_id:m.Navigate,navigated_to:r,target_url:r}}completeNavigate(e={}){const t=this.activeNavigate;if(!t||t.settled)return;const r=t.ctx.toolCallId;r&&this.settledNavigateToolCallIds.has(r)||(t.settled=!0,r&&this.settledNavigateToolCallIds.add(r),this.activeNavigate=null,t.onComplete({status:"success",preset_id:m.Navigate,navigated_to:t.targetUrl,target_url:t.targetUrl,...e}))}cancelNavigate(e,t){const r=this.activeNavigate;if(!r||r.settled)return;const s=r.ctx.toolCallId;s&&this.settledNavigateToolCallIds.has(s)||(r.settled=!0,s&&this.settledNavigateToolCallIds.add(s),this.activeNavigate=null,r.onCancel(e,{status:t}))}bindActiveModalPreset(e,t,r,s){this.activeModalPreset={ctx:e,presetId:t,onComplete:r,onCancel:s}}clearActiveModalPreset(){this.activeModalPreset&&(this.activeModalPreset.settled=!0,this.activeModalPreset=null)}cancelActiveModalPreset(e,t){const r=this.activeModalPreset;!r||r.settled||(r.settled=!0,this.activeModalPreset=null,this.overlay&&(this.overlay.remove(),this.overlay=null),this.stopCaptureCamera(),r.onCancel(e,{status:t}))}getBoardTerminalResult(e,t,r){const s={status:e,reason:t||(e==="interrupted"?"Server interrupted":"User dismissed"),...r?{preset_id:r}:{}};if(!r||!vt(r))return s;const i=this.chalkboardContent,o=this.getBoardProgressSnapshot();return{...s,text_written:i,whiteboard_content:i,board_snapshot:this.getBoardSnapshot(),...o||{}}}flushBoardContext(e){if(this.boardClient)try{typeof this.boardClient.sendContextUpdate=="function"?this.boardClient.sendContextUpdate(e):typeof this.boardClient.updateContext=="function"&&this.boardClient.updateContext(e)}catch{}}clearActiveBoardProgress(){this.activeBoardProgress=null}syncBoardProgressUnits(e){this.activeBoardProgress&&(this.activeBoardProgress.unitsDone=e)}buildBoardContextPayload(e,t,r){const s=this.activeBoardProgress,i=(s==null?void 0:s.ctx.toolCallId)===e.toolCallId;let o,a,l,c;i&&s&&(a=s.unitsDone,l=s.plannedUnits,o=s.plannedUnits>0?Math.min(100,Math.round(s.unitsDone/s.plannedUnits*100)):100,s.mode==="type"?c=t.slice(s.textAtStart.length):c=t);const u={ui_state:"whiteboard_active",tool_status:"interrupted",visible_preset:e.presetId,tool_call_id:e.toolCallId,interrupted:!0,interrupt_reason:r||"Server interrupted",whiteboard_content:t};if(o!==void 0){u.write_progress_pct=o,u.characters_written=a,u.characters_planned=l,u.partial_text_this_command=c??"";const d=(s==null?void 0:s.mode)==="erase"?"erase":"write",p=(c??"").length>120?`${(c??"").slice(0,120)}…`:c??"",h=(s==null?void 0:s.mode)==="erase"?"The board already reflects this partial erase — continue from here; do not repeat earlier steps.":"The board already contains this content — continue typing from here; do not repeat what is already on the board.";u.message=`Whiteboard ${d} interrupted at ${o}% (${a}/${l} characters this command). Partial text this turn: "${p}". `+h}return u}sendBoardContextUpdate(e,t,r){this.flushBoardContext(this.buildBoardContextPayload(e,t,r))}handle(e,t,r,s){const i=e.data||e;let o={};const a=i.arguments||i.args;if(typeof a=="string")try{o=JSON.parse(a)}catch{o={}}else a&&typeof a=="object"&&(o=a);const l=i.client_fields||{},c=ct(l,a,i.name||i.tool_name);if(!c||!Y(c))return!1;const u={...o,...l},d={toolCallId:i.tool_call_id||i.call_id||"",presetId:c,clientFields:u,args:o,toolCall:i};this.injectStyles();const p=!!document.querySelector(".vnr-whiteboard-modal");switch(vt(c)?p||this.dismissNonBoardUi():Fr(c)||Or(c)||this.dismiss(),c){case m.Calendar:return this.renderCalendar(d,t,r),!0;case m.Form:return this.renderForm(d,t,r),!0;case m.Camera:return this.renderCamera(d,t,r,s),!0;case m.Upload:return this.renderUpload(d,t,r,s),!0;case m.ClipRegion:return this.renderClipRegion(d,t,r,s),!0;case m.TabScreenshot:return this.renderTabScreenshot(d,t,r,s),!0;case m.Navigate:return this.renderNavigate(d,t,r),!0;case m.HighlightElement:return this.renderHighlight(d,t,r),!0;case m.ClickElement:return this.renderClickElement(d,t,r),!0;case m.SelectOption:return this.renderSelectOption(d,t,r),!0;case m.SetDate:return this.renderSetDate(d,t,r),!0;case m.TypeText:return this.enqueueBoardCommand({ctx:d,presetId:m.TypeText,onComplete:t,onCancel:r},s),!0;case m.EraseText:return this.enqueueBoardCommand({ctx:d,presetId:m.EraseText,onComplete:t,onCancel:r},s),!0;case m.Draw:return this.enqueueBoardCommand({ctx:d,presetId:m.Draw,onComplete:t,onCancel:r},s),!0;case m.EraseDraw:return this.enqueueBoardCommand({ctx:d,presetId:m.EraseDraw,onComplete:t,onCancel:r},s),!0;case m.LiveVision:return this.handleOpenLiveCamera(u,s,d.toolCallId),t({status:"success",preset_id:m.LiveVision,message:"Live camera session started"}),!0;case m.CloseLiveCamera:return this.handleCloseLiveCamera(s),t({status:"success",preset_id:m.CloseLiveCamera,message:"Live camera stopped"}),!0;case m.LiveScreen:return this.handleOpenLiveScreen(u,s,d.toolCallId),t({status:"success",preset_id:m.LiveScreen,message:"Live screen share started"}),!0;case m.CloseLiveScreen:return this.handleCloseLiveScreen(s),t({status:"success",preset_id:m.CloseLiveScreen,message:"Live screen share stopped"}),!0;case m.ScreenInk:return this.renderScreenInk(d,t,r),!0;case m.ScreenCursor:return this.renderScreenCursor(d,t,r),!0;case m.ScreenClick:return this.renderScreenClick(d,t,r),!0;case m.ClearScreenOverlay:return De(),t({status:"success",preset_id:m.ClearScreenOverlay,message:"Screen overlay cleared"}),!0;case m.PageScan:return Rn(d,t,r,s),!0;case m.PointAt:return Un(d,t,r),!0;case m.OutlineTargets:return Fn(d,t,r),!0;case m.ClearGuide:return On(d,t),!0;default:return!1}}abortBoardTools(e="Interrupted",t){const r=this.activeNavigate;r&&!r.settled&&(!t||r.ctx.toolCallId===t)&&this.cancelNavigate(e,"interrupted");const s=this.activeModalPreset;s&&!s.settled&&(!t||s.ctx.toolCallId===t)&&this.cancelActiveModalPreset(e,"interrupted");const i=a=>!t||a.ctx.toolCallId===t;if(this.boardQueueActive&&i(this.boardQueueActive)||this.boardQueue.some(i)){if(this.clearBoardAnimTimer(),this.activePresetGeneration++,this.boardQueueActive&&i(this.boardQueueActive)){const a=this.boardQueueActive;this.boardQueueActive=null,this.settleBoardCancel(a,e,"interrupted")}this.boardQueue=this.boardQueue.filter(a=>i(a)?(this.settleBoardCancel(a,e,"interrupted"),!1):!0)}}dismiss(){this.activeNavigate&&!this.activeNavigate.settled&&this.cancelNavigate("Session ended","interrupted"),this.activeModalPreset=null,this.resetBoardSession(),this.stopCaptureCamera(),this.handleCloseLiveCamera(null),this.handleCloseLiveScreen(null),qe(),this.overlay&&(this.overlay.remove(),this.overlay=null)}teardownSession(){this.dismiss(),De()}enqueueBoardCommand(e,t){var s;t&&(this.boardClient=t),this.boardClient&&document.querySelector(".vnr-whiteboard-modal")&&this.ensureBoardTurnMonitor();const r=e.ctx.toolCallId;r&&(this.settledBoardToolCallIds.has(r)||((s=this.boardQueueActive)==null?void 0:s.ctx.toolCallId)===r||this.boardQueue.some(i=>i.ctx.toolCallId===r))||(this.boardQueue.push(e),j("Board:Queue",`Enqueued ${e.presetId}`,{pending:this.boardQueue.length,toolCallId:e.ctx.toolCallId}),this.processBoardQueue())}processBoardQueue(){if(this.boardQueueActive||this.boardQueue.length===0)return;const e=this.boardQueue.shift();this.boardQueueActive=e,j("Board:Queue",`Running ${e.presetId}`,{toolCallId:e.ctx.toolCallId});const t=(i,o)=>{if(this.boardQueueActive===e){if(e.settled||e.aborted){this.boardQueueActive=null;return}this.boardQueueActive=null,o!==void 0?this.settleBoardCancel(e,o):this.settleBoardComplete(e,i||{}),this.processBoardQueue()}},r=i=>t(i),s=i=>{this.activePresetGeneration++,t(null,i||"Cancelled"),!this.boardQueueActive&&this.boardQueue.length===0&&this.closeBoardUi()};e.presetId===m.TypeText?this.renderTypeText(e.ctx,r,s):e.presetId===m.Draw?this.renderDrawShapes(e.ctx,r,s):e.presetId===m.EraseDraw?this.renderEraseDrawingBoard(e.ctx,r,s):this.renderEraseText(e.ctx,r,s)}closeBoardUi(){this.boardTurnMonitor.stop(),this.boardViewMode="expanded",je(!1),this.dismissWhiteboard(),this.overlay&&(!document.body.contains(this.overlay)||!this.overlay.childElementCount)&&(this.overlay.remove(),this.overlay=null)}getBoardOverlay(){const e=document.querySelector(".vnr-whiteboard-modal");return(e==null?void 0:e.closest(".vnr-overlay"))??this.overlay}applyBoardLayoutMode(e,t){const r=e??this.getBoardOverlay(),s=t??document.querySelector(".vnr-whiteboard-modal");if(!r||!s)return;const i=this.boardViewMode==="reduced";r.classList.remove("vnr-whiteboard-overlay-hidden"),r.classList.add("vnr-whiteboard-overlay"),r.classList.toggle("vnr-whiteboard-overlay-reduced",i),r.classList.toggle("vnr-whiteboard-overlay-expanded",!i),this.syncBoardResizeButton(s.querySelector(".vnr-whiteboard-resize-btn")),je(!0,i),this.syncBoardDragLayout(s),this.ensureBoardTurnMonitor()}clearBoardDragStyles(e){e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.removeProperty("margin"),e.style.removeProperty("transform")}clampBoardDragPosition(e,t,r){const i=Math.max(8,window.innerWidth-e.offsetWidth-8),o=Math.max(8,window.innerHeight-e.offsetHeight-8);return{x:Math.min(i,Math.max(8,t)),y:Math.min(o,Math.max(8,r))}}applyBoardDragPosition(e,t,r){const s=this.clampBoardDragPosition(e,t,r);e.style.setProperty("position","fixed","important"),e.style.setProperty("left",`${s.x}px`,"important"),e.style.setProperty("top",`${s.y}px`,"important"),e.style.setProperty("right","auto","important"),e.style.setProperty("bottom","auto","important"),e.style.setProperty("margin","0","important"),e.style.setProperty("transform","none","important"),this.boardDragPosition=s}defaultReducedBoardPosition(e){const r=Math.max(96,20+(typeof window<"u"?Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue("env(safe-area-inset-bottom)")||"0",10):0));return this.clampBoardDragPosition(e,window.innerWidth-e.offsetWidth-16,window.innerHeight-e.offsetHeight-r)}syncBoardDragLayout(e){if(this.boardViewMode==="reduced"){const t=this.boardDragPosition??this.defaultReducedBoardPosition(e);this.applyBoardDragPosition(e,t.x,t.y)}else this.clearBoardDragStyles(e)}wireBoardDrag(e,t){if(this.boardDragWiredModal===t)return;this.boardDragWiredModal=t;let r=!1,s=0,i=0,o=0,a=0;const l=d=>{if(this.boardViewMode!=="reduced"||d.target.closest("button"))return;r=!0,e.setPointerCapture(d.pointerId);const p=t.getBoundingClientRect();s=d.clientX,i=d.clientY,o=p.left,a=p.top,e.classList.add("is-dragging"),d.preventDefault()},c=d=>{r&&this.applyBoardDragPosition(t,o+(d.clientX-s),a+(d.clientY-i))},u=d=>{r&&(r=!1,e.classList.remove("is-dragging"),e.hasPointerCapture(d.pointerId)&&e.releasePointerCapture(d.pointerId))};e.addEventListener("pointerdown",l),e.addEventListener("pointermove",c),e.addEventListener("pointerup",u),e.addEventListener("pointercancel",u)}ensureBoardTurnMonitor(){this.boardClient&&this.boardTurnMonitor.start(e=>this.flushBoardContext(e))}revealBoardUi(e){this.applyBoardLayoutMode(this.getBoardOverlay(),e)}dismissNonBoardUi(){this.stopCaptureCamera(),this.handleCloseLiveCamera(null),this.handleCloseLiveScreen(null),qe(),this.overlay&&!this.overlay.querySelector(".vnr-whiteboard-modal")&&(this.overlay.remove(),this.overlay=null)}settleBoardCancel(e,t,r="cancelled"){if(e.settled)return;e.aborted=!0,e.settled=!0;const s=e.ctx.toolCallId;s&&this.settledBoardToolCallIds.add(s);const i=this.chalkboardContent;r==="interrupted"&&this.sendBoardContextUpdate(e.ctx,i,t),e.onCancel(t,{status:r}),this.clearActiveBoardProgress()}settleBoardComplete(e,t){if(e.settled||e.aborted)return;e.settled=!0;const r=e.ctx.toolCallId;r&&this.settledBoardToolCallIds.add(r);const s=this.chalkboardContent;e.onComplete({status:"success",preset_id:e.presetId,tool_call_id:e.ctx.toolCallId,text_written:s,whiteboard_content:s,...this.buildBoardVerification(),...t}),this.clearActiveBoardProgress()}clearBoardAnimTimer(){this.boardAnimTimer&&(clearTimeout(this.boardAnimTimer),this.boardAnimTimer=null)}scheduleBoardAnim(e,t){this.clearBoardAnimTimer(),this.boardAnimTimer=setTimeout(()=>{this.boardAnimTimer=null,e()},t)}dismissWhiteboard(){document.querySelectorAll(".vnr-whiteboard-modal").forEach(e=>{var t;(t=e.closest(".vnr-overlay"))==null||t.remove()}),this.overlay&&!document.body.contains(this.overlay)&&(this.overlay=null)}stopCaptureCamera(){var e;this.captureActive=!1,this.captureLivenessInterval&&(clearInterval(this.captureLivenessInterval),this.captureLivenessInterval=null),(e=this.captureStream)==null||e.getTracks().forEach(t=>t.stop()),this.captureStream=null}getBrowserPermissionHint(){const e=navigator.userAgent;return/iPhone|iPad/i.test(e)?"Open Settings → Safari → Camera and allow access for this site.":/Android/i.test(e)?"Tap the lock icon in the address bar → Permissions → Camera → Allow.":"Click the camera icon in your browser's address bar and allow access."}fillCameraPermissionPrompt(e,t){e.style.display="flex",e.innerHTML=`
|
|
649
|
+
.vnr-whiteboard-action-btn:disabled {
|
|
650
|
+
opacity: 0.4;
|
|
651
|
+
cursor: not-allowed;
|
|
652
|
+
}
|
|
653
|
+
.vnr-whiteboard-textarea {
|
|
654
|
+
overflow-y: auto;
|
|
655
|
+
overflow-x: hidden;
|
|
656
|
+
}
|
|
657
|
+
.vnr-whiteboard-textarea:empty::before,
|
|
658
|
+
.vnr-whiteboard-textarea[data-empty="true"]::before {
|
|
659
|
+
content: 'Notes appear here…';
|
|
660
|
+
color: rgba(255,255,255,0.35);
|
|
661
|
+
font-style: italic;
|
|
662
|
+
}
|
|
663
|
+
.vnr-whiteboard-textarea .katex {
|
|
664
|
+
color: #ffffff;
|
|
665
|
+
font-size: 1.08em;
|
|
666
|
+
}
|
|
667
|
+
.vnr-whiteboard-textarea .katex-display {
|
|
668
|
+
margin: 0.6em 0;
|
|
669
|
+
overflow-x: auto;
|
|
670
|
+
overflow-y: hidden;
|
|
671
|
+
}
|
|
672
|
+
.vnr-chalk-board-content {
|
|
673
|
+
white-space: pre-wrap;
|
|
674
|
+
word-break: break-word;
|
|
675
|
+
}
|
|
676
|
+
.vnr-chalk-segment.vnr-chalk-math-display {
|
|
677
|
+
display: block;
|
|
678
|
+
margin: 0.5em 0;
|
|
679
|
+
}
|
|
680
|
+
.vnr-chalk-segment.vnr-chalk-revealing {
|
|
681
|
+
display: inline-block;
|
|
682
|
+
overflow: hidden;
|
|
683
|
+
max-width: 100%;
|
|
684
|
+
vertical-align: bottom;
|
|
685
|
+
clip-path: inset(0 100% 0 0);
|
|
686
|
+
animation: vnr-chalk-equation-reveal var(--vnr-chalk-reveal-ms, 600ms) linear forwards;
|
|
687
|
+
}
|
|
688
|
+
.vnr-chalk-segment.vnr-chalk-revealing.vnr-chalk-math-display {
|
|
689
|
+
display: block;
|
|
690
|
+
}
|
|
691
|
+
@keyframes vnr-chalk-equation-reveal {
|
|
692
|
+
from { clip-path: inset(0 100% 0 0); }
|
|
693
|
+
to { clip-path: inset(0 0 0 0); }
|
|
694
|
+
}
|
|
695
|
+
.vnr-chalk-cursor {
|
|
696
|
+
display: inline-block;
|
|
697
|
+
color: rgba(255, 255, 255, 0.95);
|
|
698
|
+
font-weight: 300;
|
|
699
|
+
margin-left: 1px;
|
|
700
|
+
animation: vnr-chalk-cursor-blink 1s step-end infinite;
|
|
701
|
+
}
|
|
702
|
+
@keyframes vnr-chalk-cursor-blink {
|
|
703
|
+
50% { opacity: 0; }
|
|
704
|
+
}
|
|
705
|
+
`,OU='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 14h6v6"/><path d="M20 10h-6V4"/><path d="M14 10l7-7"/><path d="M3 21l7-7"/></svg>',HU='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',Pp='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',NU='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',Iy="vanira:board-size",Is=["small","medium","large"],KU=1.2,VU={small:{maxWidth:"min(440px, 94vw)",height:"min(340px, 52vh)"},medium:{maxWidth:"min(680px, 96vw)",height:"min(520px, 68vh)"},large:{maxWidth:"min(920px, 98vw)",height:"min(680px, 72vh)"}},zU="#3d2817",GU=20,qU=["radial-gradient(ellipse 120% 90% at 50% 8%, rgba(255,255,255,0.035) 0%, transparent 52%)","radial-gradient(ellipse 80% 60% at 50% 100%, rgba(0,0,0,0.35) 0%, transparent 55%)","linear-gradient(168deg, #163222 0%, #0f2418 42%, #0a1810 100%)"].join(", "),WU=["0 0 0 3px #2a1810","0 28px 64px rgba(0,0,0,0.62)","inset 0 0 72px rgba(0,0,0,0.42)","inset 0 2px 0 rgba(255,255,255,0.04)"].join(", ");function xl(r){r.style.backgroundColor="#0a1810",r.style.backgroundImage=qU,r.style.backgroundRepeat="no-repeat",r.style.backgroundSize="cover",r.style.border=`${GU}px solid ${zU}`,r.style.boxShadow=WU}function $U(){try{const r=localStorage.getItem(Iy);if(r==="small"||r==="medium"||r==="large")return r}catch{}return"medium"}function jU(r){try{localStorage.setItem(Iy,r)}catch{}}function Dp(r,e){return e===1?r:r.replace(/(\d+(?:\.\d+)?)(px|vw|vh)/g,(t,n,i)=>{const s=Number(n)*e;return`${i==="px"?Math.round(s):s}${i}`})}function Lp(r){r.style.cssText=["position:fixed","left:-2000px","top:0","width:640px","height:480px","opacity:0.01","pointer-events:none","z-index:-1"].join(";")}async function uA(r,e=8e3){return await r.play().catch(()=>{}),r.videoWidth>0&&r.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&await Op(r,1500)?!0:new Promise(t=>{let n=!1;const i=async A=>{if(!n){if(n=!0,r.removeEventListener("loadeddata",s),r.removeEventListener("playing",s),clearTimeout(a),!A){t(!1);return}t(await Op(r,1500))}},s=()=>{r.videoWidth>0&&i(!0)};r.addEventListener("loadeddata",s),r.addEventListener("playing",s);const a=setTimeout(()=>void i(r.videoWidth>0),e);s()})}function Op(r,e){const t=r.requestVideoFrameCallback;return typeof t!="function"?Promise.resolve(r.videoWidth>0):new Promise(n=>{const i=setTimeout(()=>n(!1),e);t.call(r,()=>{clearTimeout(i),n(r.videoWidth>0)})})}function hA(r,e){if(e){const t=e.querySelector("video");if(t&&t.videoWidth>0)return t}return r}function Qy(r,e,t){const n=Math.min(e,48),i=Math.min(t,48);if(n<=0||i<=0)return!0;const{data:s}=r.getImageData(0,0,n,i);let a=0;const A=s.length/4;for(let o=0;o<s.length;o+=4)a+=s[o]*.299+s[o+1]*.587+s[o+2]*.114;return a/A<14}async function XU(r,e,t=.75){if(!r||r.videoWidth===0)return null;const n=r.videoWidth,i=r.videoHeight,s=Math.min(1,e/n),a=document.createElement("canvas");a.width=Math.round(n*s),a.height=Math.round(i*s);const A=a.getContext("2d",{willReadFrequently:!0});return!A||(A.drawImage(r,0,0,a.width,a.height),Qy(A,a.width,a.height))?null:await new Promise(o=>{a.toBlob(c=>o(c),"image/jpeg",t)})}async function zd(r,e,t,n=.75){const i=await XU(r,t,n);if(i)return i;const s=e==null?void 0:e.getVideoTracks()[0];if(!s||s.readyState!=="live"||typeof ImageCapture>"u")return null;try{const A=await new ImageCapture(s).grabFrame(),o=Math.min(1,t/A.width),c=Math.round(A.width*o),l=Math.round(A.height*o),d=document.createElement("canvas");d.width=c,d.height=l;const u=d.getContext("2d",{willReadFrequently:!0});return u?(u.drawImage(A,0,0,c,l),A.close(),Qy(u,c,l)?null:await new Promise(h=>{d.toBlob(p=>h(p),"image/jpeg",n)})):(A.close(),null)}catch(a){return NE("[LiveCapture]",`ImageCapture failed: ${a instanceof Error?a.message:String(a)}`),null}}async function Hp(r,e,t,n=20,i=250){for(let s=0;s<n;s++){if(await zd(r,e,t,.6))return!0;await new Promise(A=>setTimeout(A,i))}return!1}class JU{constructor(e){L(this,"overlay",null);L(this,"styleInjected",!1);L(this,"chalkboardContent","");L(this,"calViewYear",0);L(this,"calViewMonth",0);L(this,"calSelectedTs",null);L(this,"calSelectedTime",null);L(this,"lvSessionId",null);L(this,"lvStream",null);L(this,"lvCaptureInterval",null);L(this,"lvAutoStopTimeout",null);L(this,"lvFrameSeq",0);L(this,"lvVideo",null);L(this,"lvCanvas",null);L(this,"lvPip",null);L(this,"lvPermissionBanner",null);L(this,"lsSessionId",null);L(this,"lsStream",null);L(this,"lsCaptureInterval",null);L(this,"lsAutoStopTimeout",null);L(this,"lsFrameSeq",0);L(this,"lsVideo",null);L(this,"lsCanvas",null);L(this,"lsPip",null);L(this,"lsPermissionBanner",null);L(this,"captureActive",!1);L(this,"kycCaptureStop",null);L(this,"captureStream",null);L(this,"captureLivenessInterval",null);L(this,"activePresetGeneration",0);L(this,"boardQueue",[]);L(this,"boardQueueActive",null);L(this,"boardAnimTimer",null);L(this,"settledBoardToolCallIds",new Set);L(this,"activeNavigate",null);L(this,"settledNavigateToolCallIds",new Set);L(this,"activeModalPreset",null);L(this,"boardClient",null);L(this,"boardTurnMonitor",new OE(()=>this.buildBoardVerification(),()=>this.boardQueueActive!==null||this.boardQueue.length>0||this.activeBoardProgress!==null));L(this,"activeBoardProgress",null);L(this,"boardSizePreset",$U());L(this,"boardViewMode","expanded");L(this,"boardDragPosition",null);L(this,"boardDragWiredModal",null)}resetChalkboard(){this.chalkboardContent=""}resetBoardSession(){this.boardTurnMonitor.stop(),this.boardDragPosition=null,this.boardDragWiredModal=null,this.activePresetGeneration++,al(!1),this.clearBoardAnimTimer(),this.boardQueue=[],this.boardQueueActive=null,this.settledBoardToolCallIds.clear(),this.activeBoardProgress=null,this.boardClient=null,this.chalkboardContent="",this.closeBoardUi()}getChalkboardContent(){return this.chalkboardContent}hasActiveBoardSession(){return!!document.querySelector(".vnr-whiteboard-modal")||this.chalkboardContent.length>0||this.boardQueue.length>0||this.boardQueueActive!==null}syncChalkboardNotes(){const e=this.getChalkboardSurface();e&&this.paintChalkboardSurface(e,this.chalkboardContent)}getChalkboardSurface(){return document.querySelector(".vnr-whiteboard-textarea")}paintChalkboardSurface(e,t,n){this.chalkboardContent=t,e.dataset.empty=t.trim().length===0?"true":"false";const i=n!=null&&n.typing?_A(t):t,s=(n==null?void 0:n.showCursor)===!0;kp(t)||kp(i)?by(e,i,{showCursor:s}):TE(i,e,s),e.scrollTop=e.scrollHeight}buildBoardVerification(){this.syncChalkboardNotes();const e=this.chalkboardContent;return{notes_char_count:e.length,notes_preview:e.slice(0,200)||null,has_notes_on_board:e.length>0,verification_hint:"Do NOT tell the student notes are visible unless has_notes_on_board is true in this tool result."}}getBoardSnapshot(){this.syncChalkboardNotes();const e=this.chalkboardContent;return{board_layout:"notes_full",has_diagram:!1,notes_content:e,notes_char_count:e.length}}getBoardProgressSnapshot(){const e=this.activeBoardProgress;if(!e||e.plannedUnits<=0)return null;const t=this.chalkboardContent,n=e.mode==="type"?t.slice(e.textAtStart.length):t;return{write_progress_pct:Math.min(100,Math.round(e.unitsDone/e.plannedUnits*100)),characters_written:e.unitsDone,characters_planned:e.plannedUnits,partial_text_this_command:n}}getNavigateTerminalResult(e,t,n){return{status:e,reason:t||(e==="interrupted"?"Server interrupted":"Navigation cancelled"),preset_id:_.Navigate,navigated_to:n,target_url:n}}completeNavigate(e={}){const t=this.activeNavigate;if(!t||t.settled)return;const n=t.ctx.toolCallId;n&&this.settledNavigateToolCallIds.has(n)||(t.settled=!0,n&&this.settledNavigateToolCallIds.add(n),this.activeNavigate=null,t.onComplete({status:"success",preset_id:_.Navigate,navigated_to:t.targetUrl,target_url:t.targetUrl,...e}))}cancelNavigate(e,t){const n=this.activeNavigate;if(!n||n.settled)return;const i=n.ctx.toolCallId;i&&this.settledNavigateToolCallIds.has(i)||(n.settled=!0,i&&this.settledNavigateToolCallIds.add(i),this.activeNavigate=null,n.onCancel(e,{status:t}))}bindActiveModalPreset(e,t,n,i){this.activeModalPreset={ctx:e,presetId:t,onComplete:n,onCancel:i}}clearActiveModalPreset(){this.activeModalPreset&&(this.activeModalPreset.settled=!0,this.activeModalPreset=null)}cancelActiveModalPreset(e,t){const n=this.activeModalPreset;!n||n.settled||(n.settled=!0,this.activeModalPreset=null,this.overlay&&(this.overlay.remove(),this.overlay=null),this.stopCaptureCamera(),n.onCancel(e,{status:t}))}getBoardTerminalResult(e,t,n){const i={status:e,reason:t||(e==="interrupted"?"Server interrupted":"User dismissed"),...n?{preset_id:n}:{}};if(!n||!n0(n))return i;const s=this.chalkboardContent,a=this.getBoardProgressSnapshot();return{...i,text_written:s,whiteboard_content:s,board_snapshot:this.getBoardSnapshot(),...a||{}}}flushBoardContext(e){if(this.boardClient)try{typeof this.boardClient.sendContextUpdate=="function"?this.boardClient.sendContextUpdate(e):typeof this.boardClient.updateContext=="function"&&this.boardClient.updateContext(e)}catch{}}clearActiveBoardProgress(){this.activeBoardProgress=null}syncBoardProgressUnits(e){this.activeBoardProgress&&(this.activeBoardProgress.unitsDone=e)}buildBoardContextPayload(e,t,n){const i=this.activeBoardProgress,s=(i==null?void 0:i.ctx.toolCallId)===e.toolCallId;let a,A,o,c;s&&i&&(A=i.unitsDone,o=i.plannedUnits,a=i.plannedUnits>0?Math.min(100,Math.round(i.unitsDone/i.plannedUnits*100)):100,i.mode==="type"?c=t.slice(i.textAtStart.length):c=t);const l={ui_state:"whiteboard_active",tool_status:"interrupted",visible_preset:e.presetId,tool_call_id:e.toolCallId,interrupted:!0,interrupt_reason:n||"Server interrupted",whiteboard_content:t};if(a!==void 0){l.write_progress_pct=a,l.characters_written=A,l.characters_planned=o,l.partial_text_this_command=c??"";const d=(i==null?void 0:i.mode)==="erase"?"erase":"write",u=(c??"").length>120?`${(c??"").slice(0,120)}…`:c??"",h=(i==null?void 0:i.mode)==="erase"?"The board already reflects this partial erase — continue from here; do not repeat earlier steps.":"The board already contains this content — continue typing from here; do not repeat what is already on the board.";l.message=`Whiteboard ${d} interrupted at ${a}% (${A}/${o} characters this command). Partial text this turn: "${u}". `+h}return l}sendBoardContextUpdate(e,t,n){this.flushBoardContext(this.buildBoardContextPayload(e,t,n))}handle(e,t,n,i){const s=e.data||e;let a={};const A=s.arguments||s.args;if(typeof A=="string")try{a=JSON.parse(A)}catch{a={}}else A&&typeof A=="object"&&(a=A);const o=s.client_fields||{},c=Gd(o,A,s.name||s.tool_name);if(!c||!Xn(c))return!1;const l={...a,...o},d={toolCallId:s.tool_call_id||s.call_id||"",presetId:c,clientFields:l,args:a,toolCall:s};this.injectStyles();const u=!!document.querySelector(".vnr-whiteboard-modal");switch(n0(c)?u||this.dismissNonBoardUi():qy(c)||this.dismiss(),c){case _.Calendar:return this.renderCalendar(d,t,n),!0;case _.Form:return this.renderForm(d,t,n),!0;case _.Camera:return this.renderCamera(d,t,n,i),!0;case _.KycDocumentCapture:return this.renderKycCapture("document",d,t,n,i),!0;case _.KycSelfieCapture:return this.renderKycCapture("selfie",d,t,n,i),!0;case _.KycSignatureCapture:return this.renderKycSignatureCapture(d,t,n,i),!0;case _.Upload:return this.renderUpload(d,t,n,i),!0;case _.ClipRegion:return this.renderClipRegion(d,t,n,i),!0;case _.ScreenVision:return this.renderScreenVision(d,t,n,i),!0;case _.PointAt:return this.renderPointAt(d,t,n),!0;case _.DrawOnScreen:return this.renderDrawOnScreen(d,t,n),!0;case _.ClearScreenDraw:return this.renderClearScreenDraw(d,t,n),!0;case _.HighlightOnScreen:return this.renderHighlightOnScreen(d,t,n),!0;case _.Navigate:return this.renderNavigate(d,t,n),!0;case _.HighlightElement:return this.renderHighlight(d,t,n),!0;case _.ClickElement:return this.renderClickElement(d,t,n),!0;case _.SelectOption:return this.renderSelectOption(d,t,n),!0;case _.SetDate:return this.renderSetDate(d,t,n),!0;case _.TypeText:return this.enqueueBoardCommand({ctx:d,presetId:_.TypeText,onComplete:t,onCancel:n},i),!0;case _.WriteLatexText:return this.enqueueBoardCommand({ctx:d,presetId:_.WriteLatexText,onComplete:t,onCancel:n},i),!0;case _.EraseText:return this.enqueueBoardCommand({ctx:d,presetId:_.EraseText,onComplete:t,onCancel:n},i),!0;case _.LiveVision:return this.handleOpenLiveCamera(l,i,d.toolCallId),t({status:"success",preset_id:_.LiveVision,message:"Live camera session started"}),!0;case _.CloseLiveCamera:return this.handleCloseLiveCamera(i),t({status:"success",preset_id:_.CloseLiveCamera,message:"Live camera stopped"}),!0;case _.LiveScreen:return this.handleOpenLiveScreen(l,i,d.toolCallId),t({status:"success",preset_id:_.LiveScreen,message:"Live screen share started"}),!0;case _.CloseLiveScreen:return this.handleCloseLiveScreen(i),t({status:"success",preset_id:_.CloseLiveScreen,message:"Live screen share stopped"}),!0;default:return!1}}abortBoardTools(e="Interrupted",t){const n=this.activeNavigate;n&&!n.settled&&(!t||n.ctx.toolCallId===t)&&this.cancelNavigate(e,"interrupted");const i=this.activeModalPreset;i&&!i.settled&&(!t||i.ctx.toolCallId===t)&&this.cancelActiveModalPreset(e,"interrupted");const s=A=>!t||A.ctx.toolCallId===t;if(this.boardQueueActive&&s(this.boardQueueActive)||this.boardQueue.some(s)){if(this.clearBoardAnimTimer(),this.activePresetGeneration++,this.boardQueueActive&&s(this.boardQueueActive)){const A=this.boardQueueActive;this.boardQueueActive=null,this.settleBoardCancel(A,e,"interrupted")}this.boardQueue=this.boardQueue.filter(A=>s(A)?(this.settleBoardCancel(A,e,"interrupted"),!1):!0)}}dismiss(){this.activeNavigate&&!this.activeNavigate.settled&&this.cancelNavigate("Session ended","interrupted"),this.activeModalPreset=null,this.resetBoardSession(),this.stopCaptureCamera(),this.handleCloseLiveCamera(null),this.handleCloseLiveScreen(null),il(),Qr().hide(),this.overlay&&(this.overlay.remove(),this.overlay=null)}teardownSession(){this.dismiss()}enqueueBoardCommand(e,t){var i;t&&(this.boardClient=t),this.boardClient&&document.querySelector(".vnr-whiteboard-modal")&&this.ensureBoardTurnMonitor();const n=e.ctx.toolCallId;n&&(this.settledBoardToolCallIds.has(n)||((i=this.boardQueueActive)==null?void 0:i.ctx.toolCallId)===n||this.boardQueue.some(s=>s.ctx.toolCallId===n))||(this.boardQueue.push(e),Fs("Board:Queue",`Enqueued ${e.presetId}`,{pending:this.boardQueue.length,toolCallId:e.ctx.toolCallId}),this.processBoardQueue())}processBoardQueue(){if(this.boardQueueActive||this.boardQueue.length===0)return;const e=this.boardQueue.shift();this.boardQueueActive=e,Fs("Board:Queue",`Running ${e.presetId}`,{toolCallId:e.ctx.toolCallId});const t=(s,a)=>{if(this.boardQueueActive===e){if(e.settled||e.aborted){this.boardQueueActive=null;return}this.boardQueueActive=null,a!==void 0?this.settleBoardCancel(e,a):this.settleBoardComplete(e,s||{}),this.processBoardQueue()}},n=s=>t(s),i=s=>{this.activePresetGeneration++,t(null,s||"Cancelled"),!this.boardQueueActive&&this.boardQueue.length===0&&this.closeBoardUi()};e.presetId===_.TypeText?this.renderTypeText(e.ctx,n,i):e.presetId===_.WriteLatexText?this.renderWriteLatexText(e.ctx,n,i):this.renderEraseText(e.ctx,n,i)}closeBoardUi(){this.boardTurnMonitor.stop(),this.boardViewMode="expanded",al(!1),this.dismissWhiteboard(),this.overlay&&(!document.body.contains(this.overlay)||!this.overlay.childElementCount)&&(this.overlay.remove(),this.overlay=null)}getBoardOverlay(){const e=document.querySelector(".vnr-whiteboard-modal");return(e==null?void 0:e.closest(".vnr-overlay"))??this.overlay}applyBoardLayoutMode(e,t){const n=e??this.getBoardOverlay(),i=t??document.querySelector(".vnr-whiteboard-modal");if(!n||!i)return;const s=this.boardViewMode==="reduced";n.classList.remove("vnr-whiteboard-overlay-hidden"),n.classList.add("vnr-whiteboard-overlay"),n.classList.toggle("vnr-whiteboard-overlay-reduced",s),n.classList.toggle("vnr-whiteboard-overlay-expanded",!s),this.syncBoardResizeButton(i.querySelector(".vnr-whiteboard-resize-btn")),this.syncBoardGrowButton(i),al(!0,s),this.syncBoardDragLayout(i),this.ensureBoardTurnMonitor()}clearBoardDragStyles(e){e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.removeProperty("margin"),e.style.removeProperty("transform")}clampBoardDragPosition(e,t,n){const s=Math.max(8,window.innerWidth-e.offsetWidth-8),a=Math.max(8,window.innerHeight-e.offsetHeight-8);return{x:Math.min(s,Math.max(8,t)),y:Math.min(a,Math.max(8,n))}}applyBoardDragPosition(e,t,n){const i=this.clampBoardDragPosition(e,t,n);e.style.setProperty("position","fixed","important"),e.style.setProperty("left",`${i.x}px`,"important"),e.style.setProperty("top",`${i.y}px`,"important"),e.style.setProperty("right","auto","important"),e.style.setProperty("bottom","auto","important"),e.style.setProperty("margin","0","important"),e.style.setProperty("transform","none","important"),this.boardDragPosition=i}defaultReducedBoardPosition(e){const n=Math.max(96,20+(typeof window<"u"?Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue("env(safe-area-inset-bottom)")||"0",10):0));return this.clampBoardDragPosition(e,window.innerWidth-e.offsetWidth-16,window.innerHeight-e.offsetHeight-n)}syncBoardDragLayout(e){if(this.boardViewMode==="reduced"){const t=this.boardDragPosition??this.defaultReducedBoardPosition(e);this.applyBoardDragPosition(e,t.x,t.y)}else this.clearBoardDragStyles(e)}wireBoardDrag(e,t){if(this.boardDragWiredModal===t)return;this.boardDragWiredModal=t;let n=!1,i=0,s=0,a=0,A=0;const o=d=>{if(this.boardViewMode!=="reduced"||d.target.closest("button"))return;n=!0,e.setPointerCapture(d.pointerId);const u=t.getBoundingClientRect();i=d.clientX,s=d.clientY,a=u.left,A=u.top,e.classList.add("is-dragging"),d.preventDefault()},c=d=>{n&&this.applyBoardDragPosition(t,a+(d.clientX-i),A+(d.clientY-s))},l=d=>{n&&(n=!1,e.classList.remove("is-dragging"),e.hasPointerCapture(d.pointerId)&&e.releasePointerCapture(d.pointerId))};e.addEventListener("pointerdown",o),e.addEventListener("pointermove",c),e.addEventListener("pointerup",l),e.addEventListener("pointercancel",l)}ensureBoardTurnMonitor(){this.boardClient&&this.boardTurnMonitor.start(e=>this.flushBoardContext(e))}revealBoardUi(e){this.applyBoardLayoutMode(this.getBoardOverlay(),e)}dismissNonBoardUi(){this.stopCaptureCamera(),this.handleCloseLiveCamera(null),this.handleCloseLiveScreen(null),il(),this.overlay&&!this.overlay.querySelector(".vnr-whiteboard-modal")&&(this.overlay.remove(),this.overlay=null)}settleBoardCancel(e,t,n="cancelled"){if(e.settled)return;e.aborted=!0,e.settled=!0;const i=e.ctx.toolCallId;i&&this.settledBoardToolCallIds.add(i);const s=this.chalkboardContent;n==="interrupted"&&this.sendBoardContextUpdate(e.ctx,s,t),e.onCancel(t,{status:n}),this.clearActiveBoardProgress()}settleBoardComplete(e,t){if(e.settled||e.aborted)return;e.settled=!0;const n=e.ctx.toolCallId;n&&this.settledBoardToolCallIds.add(n);const i=this.chalkboardContent;e.onComplete({status:"success",preset_id:e.presetId,tool_call_id:e.ctx.toolCallId,text_written:i,whiteboard_content:i,...this.buildBoardVerification(),...t}),this.clearActiveBoardProgress()}clearBoardAnimTimer(){this.boardAnimTimer&&(clearTimeout(this.boardAnimTimer),this.boardAnimTimer=null)}scheduleBoardAnim(e,t){this.clearBoardAnimTimer(),this.boardAnimTimer=setTimeout(()=>{this.boardAnimTimer=null,e()},t)}dismissWhiteboard(){document.querySelectorAll(".vnr-whiteboard-modal").forEach(e=>{var t;(t=e.closest(".vnr-overlay"))==null||t.remove()}),this.overlay&&!document.body.contains(this.overlay)&&(this.overlay=null)}stopCaptureCamera(){var e,t;(e=this.kycCaptureStop)==null||e.call(this),this.kycCaptureStop=null,this.captureActive=!1,this.captureLivenessInterval&&(clearInterval(this.captureLivenessInterval),this.captureLivenessInterval=null),(t=this.captureStream)==null||t.getTracks().forEach(n=>n.stop()),this.captureStream=null}getBrowserPermissionHint(){const e=navigator.userAgent;return/iPhone|iPad/i.test(e)?"Open Settings → Safari → Camera and allow access for this site.":/Android/i.test(e)?"Tap the lock icon in the address bar → Permissions → Camera → Allow.":"Click the camera icon in your browser's address bar and allow access."}fillCameraPermissionPrompt(e,t){e.style.display="flex",e.innerHTML=`
|
|
307
706
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:24px;text-align:center;width:100%;height:100%;box-sizing:border-box">
|
|
308
707
|
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="#f87171" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
309
708
|
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/>
|
|
@@ -318,43 +717,43 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
318
717
|
${t.onDismiss?'<button type="button" id="vnr-cam-perm-dismiss" class="vnr-cancel-btn">Cancel</button>':""}
|
|
319
718
|
</div>
|
|
320
719
|
</div>
|
|
321
|
-
`,e.querySelector("#vnr-cam-perm-retry").addEventListener("click",t.onRetry),t.onDismiss&&e.querySelector("#vnr-cam-perm-dismiss").addEventListener("click",t.onDismiss)}notifyCameraPermissionDenied(e,t){const
|
|
720
|
+
`,e.querySelector("#vnr-cam-perm-retry").addEventListener("click",t.onRetry),t.onDismiss&&e.querySelector("#vnr-cam-perm-dismiss").addEventListener("click",t.onDismiss)}notifyCameraPermissionDenied(e,t){const n="Camera permission denied. Please allow camera access in your browser settings.";if(e!=null&&e.sendToolError&&t)try{e.sendToolError(t,n)}catch{}}showLiveCameraPermissionBanner(e,t){var i;(i=this.lvPermissionBanner)==null||i.remove();const n=document.createElement("div");n.id="vnr-live-cam-perm-banner",n.style.cssText=["position:fixed","bottom:24px","left:50%","transform:translateX(-50%)","z-index:2147483647","max-width:360px","width:calc(100% - 32px)","padding:16px 18px","border-radius:16px","background:#0f172a","border:1px solid rgba(248,113,113,0.35)","box-shadow:0 12px 32px rgba(0,0,0,0.35)","font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"].join(";"),n.innerHTML=`
|
|
322
721
|
<p style="margin:0 0 6px;font-size:13px;font-weight:700;color:#f87171">Camera access blocked</p>
|
|
323
722
|
<p style="margin:0 0 12px;font-size:12px;color:#94a3b8;line-height:1.5">${this.getBrowserPermissionHint()}</p>
|
|
324
723
|
<div style="display:flex;gap:8px">
|
|
325
|
-
<button type="button" id="vnr-lv-perm-retry" style="flex:1;padding:9px 14px;border:none;border-radius:10px;background:#
|
|
724
|
+
<button type="button" id="vnr-lv-perm-retry" style="flex:1;padding:9px 14px;border:none;border-radius:10px;background:#111;color:#fff;font-size:13px;font-weight:600;cursor:pointer">Try Again</button>
|
|
326
725
|
<button type="button" id="vnr-lv-perm-dismiss" style="padding:9px 14px;border:1px solid rgba(255,255,255,0.15);border-radius:10px;background:transparent;color:#e2e8f0;font-size:13px;font-weight:600;cursor:pointer">Dismiss</button>
|
|
327
726
|
</div>
|
|
328
|
-
`,
|
|
329
|
-
<p style="margin:0 0 6px;font-size:13px;font-weight:700;color:#60a5fa">${
|
|
330
|
-
<p style="margin:0 0 12px;font-size:12px;color:#94a3b8;line-height:1.5">${
|
|
727
|
+
`,n.querySelector("#vnr-lv-perm-retry").addEventListener("click",e),n.querySelector("#vnr-lv-perm-dismiss").addEventListener("click",t),document.body.appendChild(n),this.lvPermissionBanner=n}async sendClientEvent(e,t,n){if(typeof(e==null?void 0:e.sendEventWhenReady)=="function"){await e.sendEventWhenReady(t,n);return}if(e!=null&&e.sendEvent){e.sendEvent(t,n);return}}handleOpenLiveCamera(e,t,n){this.handleCloseLiveScreen(t),this.handleCloseLiveCamera(t);const i=e.scope??"until_call_end",s=Math.min(Number(e.target_fps??1),Number(e.max_fps??3)),a=Number(e.max_width??640),A=e.reason??"camera_capture",o=Number(e.duration_sec??0),c=e.facing_mode??"environment",l=e.show_preview!==!1&&e.show_preview!=="false",d=`lv_${crypto.randomUUID()}`;this.lvSessionId=d,this.lvFrameSeq=0;const u=document.createElement("video");u.autoplay=!0,u.playsInline=!0,u.muted=!0,Lp(u),document.body.appendChild(u),this.lvVideo=u;const h=document.createElement("canvas");h.style.display="none",document.body.appendChild(h),this.lvCanvas=h,l&&(this.lvPip=this.createLivePip(c,()=>this.handleCloseLiveCamera(t))),(()=>{navigator.mediaDevices.getUserMedia({video:{facingMode:c,width:{ideal:a*2}}}).then(async g=>{var B;if(!this.lvSessionId){g.getTracks().forEach(E=>E.stop());return}if((B=this.lvPermissionBanner)==null||B.remove(),this.lvPermissionBanner=null,this.lvStream=g,u.srcObject=g,this.lvPip){const E=this.lvPip.querySelector("video");E&&(E.srcObject=g,await uA(E))}await uA(u);const v=hA(u,this.lvPip)??u;await Hp(v,g,a),await this.sendClientEvent(t,"client_live_camera_started",{data:{session_id:d,scope:i,...i==="timed"&&o>0?{duration_sec:o}:{},reason:A,target_fps:s}});const w=Math.round(1e3/s);this.lvCaptureInterval=setInterval(()=>{this.captureAndSendFrame(t,d,a,A)},w),i==="timed"&&o>0&&(this.lvAutoStopTimeout=setTimeout(()=>{this.handleCloseLiveCamera(t)},o*1e3))}).catch(g=>{var v,w;this.lvSessionId=null,(v=this.lvStream)==null||v.getTracks().forEach(B=>B.stop()),this.lvStream=null,(w=this.lvPip)==null||w.remove(),this.lvPip=null,u.remove(),this.lvVideo=null,h.remove(),this.lvCanvas=null,this.notifyCameraPermissionDenied(t,n),this.showLiveCameraPermissionBanner(()=>this.handleOpenLiveCamera(e,t,n),()=>{var B;(B=this.lvPermissionBanner)==null||B.remove(),this.lvPermissionBanner=null})})})()}handleCloseLiveCamera(e){var n,i,s,a,A;const t=this.lvSessionId;this.lvSessionId=null,this.lvCaptureInterval&&(clearInterval(this.lvCaptureInterval),this.lvCaptureInterval=null),this.lvAutoStopTimeout&&(clearTimeout(this.lvAutoStopTimeout),this.lvAutoStopTimeout=null),(n=this.lvStream)==null||n.getTracks().forEach(o=>o.stop()),this.lvStream=null,(i=this.lvVideo)==null||i.remove(),this.lvVideo=null,(s=this.lvCanvas)==null||s.remove(),this.lvCanvas=null,(a=this.lvPip)==null||a.remove(),this.lvPip=null,(A=this.lvPermissionBanner)==null||A.remove(),this.lvPermissionBanner=null,t&&e&&this.sendClientEvent(e,"client_live_camera_stopped",{data:{session_id:t}})}classifyLiveScreenShareFailure(e){if(e instanceof DOMException){if(e.name==="AbortError")return"cancelled";if(e.name==="NotAllowedError"){const n=(e.message||"").toLowerCase();return n.includes("dismiss")||n.includes("cancel")||n.includes("abort")?"cancelled":"denied"}}const t=e instanceof Error?(e.message||"").toLowerCase():"";return t.includes("cancel")||t.includes("dismiss")||t.includes("abort")?"cancelled":"denied"}emitLiveScreenShareFailure(e,t,n,i,s,a){const A=s instanceof DOMException||s instanceof Error?s.name:void 0,o=a??(i==="cancelled"?"User cancelled screen share without selecting a source.":"Screen share permission was not granted."),c=i==="cancelled"?"client_live_screen_cancelled":"client_live_screen_denied";if(e!=null&&e.sendEvent&&e.sendEvent(c,{data:{...t?{session_id:t}:{},...n?{tool_call_id:n}:{},message:o,...A?{error_name:A}:{}}}),e!=null&&e.sendToolError&&n)try{e.sendToolError(n,o)}catch{}}notifyScreenShareUnavailable(e,t){this.emitLiveScreenShareFailure(e,null,t,"denied",void 0,"Screen sharing is not supported in this browser or device.")}showLiveScreenPermissionBanner(e,t,n){var A;(A=this.lsPermissionBanner)==null||A.remove();const i=e==="cancelled"?"Screen share cancelled":"Screen share blocked",s=e==="cancelled"?"You closed the picker without sharing. Try again when you are ready to show your screen.":"Choose a screen, window, or browser tab when prompted to share with the agent.",a=document.createElement("div");a.id="vnr-live-screen-perm-banner",a.style.cssText=["position:fixed","bottom:24px","left:50%","transform:translateX(-50%)","z-index:2147483647","max-width:360px","width:calc(100% - 32px)","padding:16px 18px","border-radius:16px","background:#0f172a","border:1px solid rgba(96,165,250,0.35)","box-shadow:0 12px 32px rgba(0,0,0,0.35)","font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"].join(";"),a.innerHTML=`
|
|
728
|
+
<p style="margin:0 0 6px;font-size:13px;font-weight:700;color:#60a5fa">${i}</p>
|
|
729
|
+
<p style="margin:0 0 12px;font-size:12px;color:#94a3b8;line-height:1.5">${s}</p>
|
|
331
730
|
<div style="display:flex;gap:8px">
|
|
332
|
-
<button type="button" id="vnr-ls-perm-retry" style="flex:1;padding:9px 14px;border:none;border-radius:10px;background:#
|
|
731
|
+
<button type="button" id="vnr-ls-perm-retry" style="flex:1;padding:9px 14px;border:none;border-radius:10px;background:#111;color:#fff;font-size:13px;font-weight:600;cursor:pointer">Try Again</button>
|
|
333
732
|
<button type="button" id="vnr-ls-perm-dismiss" style="padding:9px 14px;border:1px solid rgba(255,255,255,0.15);border-radius:10px;background:transparent;color:#e2e8f0;font-size:13px;font-weight:600;cursor:pointer">Dismiss</button>
|
|
334
733
|
</div>
|
|
335
|
-
`,
|
|
734
|
+
`,a.querySelector("#vnr-ls-perm-retry").addEventListener("click",t),a.querySelector("#vnr-ls-perm-dismiss").addEventListener("click",n),document.body.appendChild(a),this.lsPermissionBanner=a}handleOpenLiveScreen(e,t,n){var g;if(this.handleCloseLiveScreen(t),this.handleCloseLiveCamera(t),!((g=navigator.mediaDevices)!=null&&g.getDisplayMedia)){this.notifyScreenShareUnavailable(t,n);return}const i=e.scope??"until_call_end",s=Math.min(Number(e.target_fps??1),Number(e.max_fps??3)),a=Number(e.max_width??1280),A=e.reason??"screen_capture",o=Number(e.duration_sec??0),c=e.prefer_current_tab===!0||e.prefer_current_tab==="true",l=e.show_preview!==!1&&e.show_preview!=="false",d=`ls_${crypto.randomUUID()}`;this.lsSessionId=d,this.lsFrameSeq=0;const u=document.createElement("video");u.autoplay=!0,u.playsInline=!0,u.muted=!0,Lp(u),document.body.appendChild(u),this.lsVideo=u;const h=document.createElement("canvas");h.style.display="none",document.body.appendChild(h),this.lsCanvas=h,l&&(this.lsPip=this.createLiveScreenPip(()=>this.handleCloseLiveScreen(t))),(()=>{const v=c?{displaySurface:"browser"}:!0;navigator.mediaDevices.getDisplayMedia({video:v,audio:!1}).then(async w=>{var T,F;if(!this.lsSessionId){w.getTracks().forEach(R=>R.stop());return}(T=this.lsPermissionBanner)==null||T.remove(),this.lsPermissionBanner=null,this.lsStream=w,u.srcObject=w;const B=w.getVideoTracks()[0];if(B&&(B.onended=()=>{this.handleCloseLiveScreen(t)}),this.lsPip){const R=this.lsPip.querySelector("video");R&&(R.srcObject=w,await uA(R))}await uA(u);const E=hA(u,this.lsPip)??u;await Hp(E,w,a,12,200);const b=((F=B==null?void 0:B.getSettings)==null?void 0:F.call(B).displaySurface)??"unknown";await this.sendClientEvent(t,"client_live_screen_started",{data:{session_id:d,scope:i,...i==="timed"&&o>0?{duration_sec:o}:{},display_surface:b,reason:A,target_fps:s}});const C=Math.round(1e3/s);this.lsCaptureInterval=setInterval(()=>{this.captureAndSendScreenFrame(t,d,a,A)},C),i==="timed"&&o>0&&(this.lsAutoStopTimeout=setTimeout(()=>{this.handleCloseLiveScreen(t)},o*1e3))}).catch(w=>{var E,b;const B=this.classifyLiveScreenShareFailure(w);this.lsSessionId=null,(E=this.lsStream)==null||E.getTracks().forEach(C=>C.stop()),this.lsStream=null,(b=this.lsPip)==null||b.remove(),this.lsPip=null,u.remove(),this.lsVideo=null,h.remove(),this.lsCanvas=null,this.emitLiveScreenShareFailure(t,d,n,B,w),this.showLiveScreenPermissionBanner(B,()=>this.handleOpenLiveScreen(e,t,n),()=>{var C;(C=this.lsPermissionBanner)==null||C.remove(),this.lsPermissionBanner=null})})})()}handleCloseLiveScreen(e){var n,i,s,a,A;const t=this.lsSessionId;this.lsSessionId=null,this.lsCaptureInterval&&(clearInterval(this.lsCaptureInterval),this.lsCaptureInterval=null),this.lsAutoStopTimeout&&(clearTimeout(this.lsAutoStopTimeout),this.lsAutoStopTimeout=null),(n=this.lsStream)==null||n.getTracks().forEach(o=>o.stop()),this.lsStream=null,(i=this.lsVideo)==null||i.remove(),this.lsVideo=null,(s=this.lsCanvas)==null||s.remove(),this.lsCanvas=null,(a=this.lsPip)==null||a.remove(),this.lsPip=null,(A=this.lsPermissionBanner)==null||A.remove(),this.lsPermissionBanner=null,t&&e&&this.sendClientEvent(e,"client_live_screen_stopped",{data:{session_id:t}})}async uploadLiveStreamFrame(e,t,n,i){const s=`frame_${n}.jpg`;if(typeof e.uploadMediaFrame=="function")return e.uploadMediaFrame(t,i,s);const a=e.serverUrl||"";let A="";try{A=new URL(a).origin}catch{A=a.replace(/\/webrtc.*$/,"").replace(/\/$/,"")}const o=e.callId||"",c=`${A}/media/upload`,l=new FormData;l.append("file",t,s),l.append("call_id",o),l.append("reason",i);const d=await fetch(c,{method:"POST",body:l});if(!d.ok)throw new Error(`Upload HTTP ${d.status}`);const u=await d.json();if(!u.media_id||!u.url)throw new Error("Upload response missing media_id/url");return{media_id:u.media_id,url:u.url,content_type:u.content_type||"image/jpeg"}}async captureAndSendScreenFrame(e,t,n,i){if(!e||!this.lsVideo||!this.lsCanvas||!this.lsSessionId)return;const s=hA(this.lsVideo,this.lsPip);if(!s||s.readyState<2||s.videoWidth===0)return;let a;try{a=await zd(s,this.lsStream,n,.75)}catch{return}if(!a)return;const A=this.lsCanvas,o=s.videoWidth||n,c=s.videoHeight||n,l=Math.min(1,n/o);A.width=Math.round(o*l),A.height=Math.round(c*l);try{const{media_id:d,url:u,content_type:h}=await this.uploadLiveStreamFrame(e,a,t,i);if(!this.lsSessionId||this.lsSessionId!==t||!d||!u)return;const p=++this.lsFrameSeq;await this.sendClientEvent(e,"client_media_frame",{data:{session_id:t,source:"screen",frame_seq:p,media_id:d,media_url:u,content_type:h,reason:i,viewport:{width:A.width,height:A.height}}})}catch{}}createLiveScreenPip(e){const t=document.createElement("div");if(t.id="vnr-live-screen-pip",t.style.cssText=["position:fixed","bottom:24px","right:24px","z-index:2147483647","width:220px","height:124px","border-radius:16px","overflow:hidden","background:#0f172a","border:1px solid rgba(96,165,250,0.25)","box-shadow:0 12px 32px rgba(0,0,0,0.35)","font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif","transition:transform 0.2s ease"].join(";"),t.innerHTML=`
|
|
336
735
|
<video autoplay playsinline muted style="width:100%;height:100%;object-fit:contain;display:block;background:#020617"></video>
|
|
337
736
|
<div style="position:absolute;top:10px;left:10px;display:flex;align-items:center;gap:6px;padding:3px 8px;border-radius:6px;background:rgba(15,23,42,0.8);border:1px solid rgba(255,255,255,0.1);font-size:10px;font-weight:700;color:#f8fafc;text-transform:uppercase;letter-spacing:0.04em;pointer-events:none;">
|
|
338
737
|
<span style="width:6px;height:6px;border-radius:50%;background:#3b82f6;flex-shrink:0;animation:vnr-pip-pulse 1.5s ease-in-out infinite;"></span>
|
|
339
738
|
SCREEN
|
|
340
739
|
</div>
|
|
341
740
|
<button id="vnr-screen-pip-stop" style="position:absolute;top:10px;right:10px;width:22px;height:22px;border-radius:50%;background:rgba(15,23,42,0.8);border:1px solid rgba(255,255,255,0.1);color:#fff;font-size:10px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background 0.2s,transform 0.2s;">✕</button>
|
|
342
|
-
`,!document.getElementById("vnr-pip-style")){const
|
|
741
|
+
`,!document.getElementById("vnr-pip-style")){const n=document.createElement("style");n.id="vnr-pip-style",n.textContent=`
|
|
343
742
|
@keyframes vnr-pip-pulse{0%,100%{opacity:1;transform:scale(1);}50%{opacity:.5;transform:scale(1.2);}}
|
|
344
743
|
#vnr-live-screen-pip:hover { transform: scale(1.02); }
|
|
345
744
|
#vnr-screen-pip-stop:hover { background: rgba(239,68,68,0.9) !important; transform: scale(1.1); }
|
|
346
|
-
`,document.head.appendChild(
|
|
347
|
-
<video autoplay playsinline muted style="width:100%;height:100%;object-fit:cover;display:block;${
|
|
745
|
+
`,document.head.appendChild(n)}return t.querySelector("#vnr-screen-pip-stop").addEventListener("click",()=>e()),document.body.appendChild(t),t}async captureAndSendFrame(e,t,n,i){if(!e||!this.lvVideo||!this.lvCanvas||!this.lvSessionId)return;const s=hA(this.lvVideo,this.lvPip);if(!s||s.readyState<2||s.videoWidth===0)return;let a;try{a=await zd(s,this.lvStream,n,.75)}catch{return}if(!a)return;const A=this.lvCanvas,o=s.videoWidth||n,c=s.videoHeight||n,l=Math.min(1,n/o);A.width=Math.round(o*l),A.height=Math.round(c*l);try{const{media_id:d,url:u,content_type:h}=await this.uploadLiveStreamFrame(e,a,t,i);if(!this.lvSessionId||this.lvSessionId!==t||!d||!u)return;const p=++this.lvFrameSeq;await this.sendClientEvent(e,"client_media_frame",{data:{session_id:t,frame_seq:p,media_id:d,media_url:u,content_type:h,reason:i}})}catch{}}createLivePip(e,t){const n=document.createElement("div");n.id="vnr-live-pip";const i=e==="user";if(n.style.cssText=["position:fixed","bottom:24px","right:24px","z-index:2147483647","width:180px","height:135px","border-radius:16px","overflow:hidden","background:#0f172a","border:1px solid rgba(255,255,255,0.15)","box-shadow:0 12px 32px rgba(0,0,0,0.35)","font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif","transition:transform 0.2s ease"].join(";"),n.innerHTML=`
|
|
746
|
+
<video autoplay playsinline muted style="width:100%;height:100%;object-fit:cover;display:block;${i?"transform:scaleX(-1);":""}"></video>
|
|
348
747
|
<div style="position:absolute;top:10px;left:10px;display:flex;align-items:center;gap:6px;padding:3px 8px;border-radius:6px;background:rgba(15,23,42,0.8);border:1px solid rgba(255,255,255,0.1);font-size:10px;font-weight:700;color:#f8fafc;text-transform:uppercase;letter-spacing:0.04em;pointer-events:none;">
|
|
349
748
|
<span style="width:6px;height:6px;border-radius:50%;background:#ef4444;flex-shrink:0;animation:vnr-pip-pulse 1.5s ease-in-out infinite;"></span>
|
|
350
749
|
REC
|
|
351
750
|
</div>
|
|
352
751
|
<button id="vnr-pip-stop" style="position:absolute;top:10px;right:10px;width:22px;height:22px;border-radius:50%;background:rgba(15,23,42,0.8);border:1px solid rgba(255,255,255,0.1);color:#fff;font-size:10px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background 0.2s,transform 0.2s;">✕</button>
|
|
353
|
-
`,!document.getElementById("vnr-pip-style")){const
|
|
752
|
+
`,!document.getElementById("vnr-pip-style")){const s=document.createElement("style");s.id="vnr-pip-style",s.textContent=`
|
|
354
753
|
@keyframes vnr-pip-pulse{0%,100%{opacity:1;transform:scale(1);}50%{opacity:.5;transform:scale(1.2);}}
|
|
355
754
|
#vnr-live-pip:hover { transform: scale(1.02); }
|
|
356
755
|
#vnr-pip-stop:hover { background: rgba(239,68,68,0.9) !important; transform: scale(1.1); }
|
|
357
|
-
`,document.head.appendChild(
|
|
756
|
+
`,document.head.appendChild(s)}return n.querySelector("#vnr-pip-stop").addEventListener("click",()=>t()),document.body.appendChild(n),n}injectStyles(){if(this.styleInjected||document.getElementById("vnr-preset-styles"))return;const e=document.createElement("style");e.id="vnr-preset-styles",e.textContent=LU,document.head.appendChild(e),this.styleInjected=!0}createOverlay(){const e=document.createElement("div");return e.className="vnr-overlay",document.body.appendChild(e),this.overlay=e,e}createModal(e,t,n){const i=document.createElement("div");return i.className="vnr-modal",i.style.position="relative",i.innerHTML=`
|
|
358
757
|
<button class="vnr-close-btn" aria-label="Close">
|
|
359
758
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
360
759
|
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
@@ -365,40 +764,40 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
365
764
|
<svg width="14" height="14" style="flex-shrink:0;margin-top:1px" fill="none" stroke="#9ca3af" stroke-width="2" viewBox="0 0 24 24">
|
|
366
765
|
<path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
367
766
|
</svg>
|
|
368
|
-
<span>${
|
|
767
|
+
<span>${n}</span>
|
|
369
768
|
</div>
|
|
370
|
-
`,e.appendChild(
|
|
769
|
+
`,e.appendChild(i),i}renderCalendar(e,t,n){this.bindActiveModalPreset(e,_.Calendar,t,n);const i=v=>{this.clearActiveModalPreset(),t({status:"success",preset_id:_.Calendar,...v})},s=v=>{this.clearActiveModalPreset(),n(v,{status:"cancelled"})},a=new Date;a.setHours(0,0,0,0),this.calViewYear=a.getFullYear(),this.calViewMonth=a.getMonth(),this.calSelectedTs=null,this.calSelectedTime=null;const A=e.clientFields.title||"Select Date & Time",o=e.args.reason||"Please select a preferred time for your appointment.",c=this.createOverlay(),l=this.createModal(c,A,o);l.querySelector(".vnr-close-btn").addEventListener("click",()=>{this.dismiss(),s("User closed the preset")});const d=document.createElement("div");l.appendChild(d);const u=document.createElement("div");u.style.display="none",l.appendChild(u);const h=document.createElement("div");h.className="vnr-actions",h.innerHTML=`
|
|
371
770
|
<button class="vnr-cancel-btn">Cancel</button>
|
|
372
771
|
<button class="vnr-confirm-btn" disabled>
|
|
373
772
|
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg>
|
|
374
773
|
Confirm
|
|
375
774
|
</button>
|
|
376
|
-
`,
|
|
775
|
+
`,l.appendChild(h);const p=h.querySelector(".vnr-confirm-btn");h.querySelector(".vnr-cancel-btn").addEventListener("click",()=>{this.dismiss(),s("User cancelled")}),p.addEventListener("click",()=>{if(!this.calSelectedTs||!this.calSelectedTime)return;const v=new Date(this.calSelectedTs),w=Tl(this.calSelectedTime),B=v.getFullYear(),E=String(v.getMonth()+1).padStart(2,"0"),b=String(v.getDate()).padStart(2,"0"),C=`${B}-${E}-${b}`,T=e.clientFields.timezone||"";let F=typeof this.calSelectedTime=="object"?{...this.calSelectedTime}:void 0;if(F){for(const R of["start","startTime","end","endTime"])if(F[R]&&typeof F[R]=="string"&&(F[R].includes("T")||!isNaN(Date.parse(F[R]))))try{F[R]=DU(new Date(F[R]),T)}catch{}}this.dismiss(),i({date:C,time:w,timestamp:this.calSelectedTs,formatted:`${v.toLocaleDateString("en-US",{weekday:"long",month:"short",day:"numeric"})} at ${w}`,slot_data:F})});const g=()=>{const v=new Date;v.setHours(0,0,0,0);const w=new Date(this.calViewYear,this.calViewMonth,1).getDay(),B=new Date(this.calViewYear,this.calViewMonth+1,0).getDate(),E=new Date(this.calViewYear,this.calViewMonth,1).toLocaleDateString("en-US",{month:"long",year:"numeric"}),b=this.calViewYear===v.getFullYear()&&this.calViewMonth===v.getMonth();d.innerHTML=`
|
|
377
776
|
<div class="vnr-month-nav">
|
|
378
|
-
<button class="vnr-nav-btn" id="vnr-prev" ${
|
|
777
|
+
<button class="vnr-nav-btn" id="vnr-prev" ${b?"disabled":""}>
|
|
379
778
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="15 18 9 12 15 6"/></svg>
|
|
380
779
|
</button>
|
|
381
|
-
<span class="vnr-month-label">${
|
|
780
|
+
<span class="vnr-month-label">${E}</span>
|
|
382
781
|
<button class="vnr-nav-btn" id="vnr-next">
|
|
383
782
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="9 18 15 12 9 6"/></svg>
|
|
384
783
|
</button>
|
|
385
784
|
</div>
|
|
386
785
|
<div class="vnr-cal-grid" id="vnr-grid"></div>
|
|
387
|
-
`,d.querySelector("#vnr-prev").addEventListener("click",()=>{this.calViewMonth===0?(this.calViewMonth=11,this.calViewYear--):this.calViewMonth--,
|
|
786
|
+
`,d.querySelector("#vnr-prev").addEventListener("click",()=>{this.calViewMonth===0?(this.calViewMonth=11,this.calViewYear--):this.calViewMonth--,g()}),d.querySelector("#vnr-next").addEventListener("click",()=>{this.calViewMonth===11?(this.calViewMonth=0,this.calViewYear++):this.calViewMonth++,g()});const C=d.querySelector("#vnr-grid");["Su","Mo","Tu","We","Th","Fr","Sa"].forEach(T=>{const F=document.createElement("div");F.className="vnr-wd",F.textContent=T,C.appendChild(F)});for(let T=0;T<w;T++){const F=document.createElement("div");C.appendChild(F)}for(let T=1;T<=B;T++){const F=new Date(this.calViewYear,this.calViewMonth,T).getTime(),R=F<v.getTime(),M=F===v.getTime(),D=this.calSelectedTs===F,O=document.createElement("div");O.style.textAlign="center";const H=document.createElement("button");H.className="vnr-day-btn",R&&H.classList.add("vnr-day-past"),M&&!D&&H.classList.add("vnr-day-today"),D&&H.classList.add("vnr-day-sel"),H.disabled=R,H.textContent=String(T),H.addEventListener("click",()=>{this.calSelectedTs=F,this.calSelectedTime=null,p.disabled=!0,g(),this.loadSlots(e,u,p)}),O.appendChild(H),C.appendChild(O)}};g()}loadSlots(e,t,n){const i=e.clientFields.slots_api_url;if(!this.calSelectedTs||!i){this.renderSlots(t,["09:00 AM","10:30 AM","01:00 PM","02:30 PM","04:00 PM"],n);return}const s=new Date(this.calSelectedTs),a=s.getFullYear(),A=String(s.getMonth()+1).padStart(2,"0"),o=String(s.getDate()).padStart(2,"0"),c=`${a}-${A}-${o}`,l=e.clientFields.timezone||"",d=PU(a,s.getMonth(),s.getDate(),l),u=d.start,h=d.end,p=b=>{if(typeof b!="string")return b;let C=b.replace(/\{\{date\}\}/g,c).replace(/\{\{timezone\}\}/g,l).replace(/\{\{start_of_day\}\}/g,u.toISOString()).replace(/\{\{end_of_day\}\}/g,h.toISOString());return Object.entries(e.clientFields).forEach(([T,F])=>{if(F!=null){const R=T.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),M=new RegExp(`\\{\\{${R}\\}\\}`,"g");C=C.replace(M,String(F))}}),C},g=(e.clientFields.slots_api_method||"GET").toUpperCase();let v={"Content-Type":"application/json"};try{Object.entries(JSON.parse(e.clientFields.slots_api_headers||"{}")).forEach(([b,C])=>{v[b]=p(String(C))})}catch{}let w={};try{Object.entries(JSON.parse(e.clientFields.slots_api_body||"{}")).forEach(([b,C])=>{w[b]=p(String(C))})}catch{}let B=p(i);const E={method:g,headers:v};if(g==="GET"){const b=new URLSearchParams(Object.entries(w).map(([C,T])=>[C,String(T)])).toString();b&&(B+=(B.includes("?")?"&":"?")+b)}else E.body=JSON.stringify(w);t.style.display="block",t.innerHTML='<div class="vnr-divider"></div><div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Loading slots…</div>',fetch(B,E).then(b=>{if(!b.ok)throw new Error(`HTTP ${b.status}`);return b.json()}).then(b=>{let C=[];if(Array.isArray(b))C=b;else if(b&&typeof b=="object"){for(const T of["slots","free_slots","times","data","available_slots"])if(Array.isArray(b[T])){C=b[T];break}}this.renderSlots(t,C,n)}).catch(()=>{t.innerHTML='<div class="vnr-divider"></div><div class="vnr-center" style="color:#ef4444">Failed to load slots. Please try again.</div>'})}renderSlots(e,t,n){const i=this.calSelectedTs?new Date(this.calSelectedTs).toLocaleDateString("en-US",{weekday:"long",month:"short",day:"numeric"}):"Available Times",s=t.some(A=>Tl(A).length>8)?2:3;if(e.style.display="block",e.innerHTML=`
|
|
388
787
|
<div class="vnr-divider"></div>
|
|
389
|
-
<div class="vnr-section-label">${
|
|
390
|
-
${t.length===0?'<div class="vnr-center">No slots available for this date.</div>':`<div class="vnr-slots-grid" style="grid-template-columns:repeat(${
|
|
391
|
-
`,t.length===0)return;const
|
|
788
|
+
<div class="vnr-section-label">${i}</div>
|
|
789
|
+
${t.length===0?'<div class="vnr-center">No slots available for this date.</div>':`<div class="vnr-slots-grid" style="grid-template-columns:repeat(${s},1fr)"></div>`}
|
|
790
|
+
`,t.length===0)return;const a=e.querySelector(".vnr-slots-grid");t.forEach(A=>{const o=document.createElement("button");o.className="vnr-slot-btn",this.calSelectedTime!==null&&(typeof A=="object"&&typeof this.calSelectedTime=="object"?JSON.stringify(A)===JSON.stringify(this.calSelectedTime):A===this.calSelectedTime)&&o.classList.add("vnr-slot-sel"),o.textContent=Tl(A),o.addEventListener("click",()=>{this.calSelectedTime=A,n.disabled=!1,a.querySelectorAll(".vnr-slot-btn").forEach(l=>l.classList.remove("vnr-slot-sel")),o.classList.add("vnr-slot-sel")}),a.appendChild(o)})}collectFormFieldValues(e,t){const n={};for(const i of t){if(i.type==="checkbox"){const a=e.querySelector(`#vnr_${i.id}`);n[i.id]=!!(a!=null&&a.checked);continue}if(i.type==="radio"){const a=e.querySelector(`input[name="vnr_${i.id}"]:checked`);n[i.id]=(a==null?void 0:a.value)??"";continue}const s=e.querySelector(`#vnr_${i.id}`);n[i.id]=String((s==null?void 0:s.value)??"").trim()}return n}appendFormFieldElement(e,t,n){const i=document.createElement("div");i.className="vnr-field-wrap",i.dataset.fieldId=t.id;const s=t.placeholder||`Enter your ${t.label.toLowerCase()}`,a=c=>typeof c=="string"?c:c.value,A=c=>typeof c=="string"?c:c.label;if(t.type!=="checkbox"){const c=document.createElement("label");c.className="vnr-field-label",c.htmlFor=`vnr_${t.id}`,c.textContent=t.required?`${t.label} *`:t.label,i.appendChild(c)}switch(t.type){case"textarea":{const c=document.createElement("textarea");c.className="vnr-input vnr-textarea",c.id=`vnr_${t.id}`,c.rows=4,c.placeholder=s,typeof n=="string"&&(c.value=n),i.appendChild(c);break}case"select":{const c=document.createElement("select");c.className="vnr-input",c.id=`vnr_${t.id}`;const l=document.createElement("option");l.value="",l.textContent="Select…",c.appendChild(l);for(const d of t.options){const u=document.createElement("option");u.value=a(d),u.textContent=A(d),c.appendChild(u)}typeof n=="string"&&n&&(c.value=n),i.appendChild(c);break}case"radio":{const c=document.createElement("div");c.className="vnr-radio-group";const l=typeof n=="string"?n:"";t.options.forEach((d,u)=>{const h=document.createElement("label");h.className="vnr-radio-row";const p=document.createElement("input");p.type="radio",p.name=`vnr_${t.id}`,p.id=`vnr_${t.id}_${u}`;const g=a(d);p.value=g,l&&l===g&&(p.checked=!0);const v=document.createElement("span");v.textContent=A(d),h.appendChild(p),h.appendChild(v),c.appendChild(h)}),i.appendChild(c);break}case"checkbox":{const c=document.createElement("label");c.className="vnr-checkbox-row";const l=document.createElement("input");l.type="checkbox",l.id=`vnr_${t.id}`,l.checked=n===!0||n==="true";const d=document.createElement("span");d.textContent=t.required?`${t.label} *`:t.label,c.appendChild(l),c.appendChild(d),i.appendChild(c);break}default:{const c=document.createElement("input");c.className="vnr-input",c.id=`vnr_${t.id}`,c.placeholder=s,t.type==="phone"?c.type="tel":t.type==="email"||t.type==="number"||t.type==="date"?c.type=t.type:c.type="text",typeof n=="string"&&(c.value=n),i.appendChild(c);break}}const o=document.createElement("p");o.className="vnr-field-error",o.style.display="none",i.appendChild(o),e.appendChild(i)}showFormFieldErrors(e,t){e.querySelectorAll(".vnr-field-wrap").forEach(n=>{var A,o;const i=n.dataset.fieldId;if(!i)return;const s=n.querySelector(".vnr-field-error"),a=t[i];a&&s?(s.textContent=a,s.style.display="block",(A=n.querySelector(".vnr-input, .vnr-textarea"))==null||A.classList.add("vnr-input-error")):s&&(s.style.display="none",(o=n.querySelector(".vnr-input, .vnr-textarea"))==null||o.classList.remove("vnr-input-error"))})}renderForm(e,t,n){this.bindActiveModalPreset(e,_.Form,t,n);const i=v=>{this.clearActiveModalPreset(),t({status:"success",preset_id:_.Form,...v})},s=v=>{this.clearActiveModalPreset(),n(v,{status:"cancelled"})},a=e.args.title||e.clientFields.title||"Please fill out this form",A=e.args.reason||"Please provide the following information.",o=zs(e.args.fields??e.clientFields.fields),c=nU(o,eU(e.args,e.clientFields)),l=this.createOverlay(),d=this.createModal(l,a,A);d.querySelector(".vnr-close-btn").addEventListener("click",()=>{this.dismiss(),s("User closed")});const u=document.createElement("div");if(u.className="vnr-fields",o.length===0){const v=document.createElement("p");v.className="vnr-form-error",v.style.color="#dc2626",v.style.fontSize="13px",v.textContent="No form fields configured.",u.appendChild(v)}else o.forEach(v=>this.appendFormFieldElement(u,v,c[v.id]));d.appendChild(u);const h=document.createElement("p");h.className="vnr-form-error",h.style.cssText="display:none;color:#dc2626;font-size:13px;margin:8px 0 0;",d.appendChild(h);const p=document.createElement("div");p.className="vnr-actions",p.style.marginTop="16px",p.innerHTML=`
|
|
392
791
|
<button class="vnr-cancel-btn">Cancel</button>
|
|
393
792
|
<button class="vnr-confirm-btn">
|
|
394
793
|
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"/></svg>
|
|
395
794
|
Submit
|
|
396
795
|
</button>
|
|
397
|
-
`,d.appendChild(
|
|
796
|
+
`,d.appendChild(p),p.querySelector(".vnr-cancel-btn").addEventListener("click",()=>{this.dismiss(),s("User cancelled")});const g=p.querySelector(".vnr-confirm-btn");o.length===0&&(g.disabled=!0),g.addEventListener("click",()=>{if(o.length===0){h.textContent="No form fields configured.",h.style.display="block";return}const v=this.collectFormFieldValues(d,o),w=JE(o,v);if(Object.keys(w).length>0){this.showFormFieldErrors(d,w),h.textContent="Please fix the highlighted fields.",h.style.display="block";const E=Object.keys(w)[0],b=d.querySelector(`[data-field-id="${E}"]`),C=b==null?void 0:b.querySelector("input, textarea, select");C==null||C.focus();return}h.style.display="none",this.showFormFieldErrors(d,{}),g.disabled=!0,g.innerHTML='<div class="vnr-spinner"></div>';const B=ZE(o,v);setTimeout(()=>{this.dismiss(),i(B)},300)})}renderKycCapture(e,t,n,i,s){const a=e==="document"?_.KycDocumentCapture:_.KycSelfieCapture;this.bindActiveModalPreset(t,a,n,i);const A=g=>{this.clearActiveModalPreset(),n({status:"success",preset_id:a,...g})},o=(g,v="cancelled")=>{this.clearActiveModalPreset(),i(g,{status:v})},c=String(t.args.document_side??t.clientFields.document_side??"front").toLowerCase()==="back"?"back":"front",l=e==="document"?c==="back"?"Scan back of ID":"Scan your ID":"Verify it's you",d=e==="document"?c==="back"?"Hold the back of your ID in the frame. We'll capture automatically when edges are clear.":"Hold your ID in the frame. On desktop, use your webcam; on mobile, we use the rear camera.":"Center your face in the oval. Blink or turn slightly when prompted — we'll capture automatically.",u=String(t.args.reason??t.clientFields.reason??"").trim();if(!u){o("reason is required — media routing key (e.g. kyc_document or kyc_selfie)");return}this.stopCaptureCamera();const h=this,p=MU({mode:e,presetId:a,title:String(t.clientFields.title??t.args.title??l),description:String(t.clientFields.description??t.args.description??d),reason:u,documentSide:c,toolCallId:t.toolCallId,host:{setCaptureActive:g=>{h.captureActive=g},setCaptureStream:g=>{h.captureStream=g},createOverlay:()=>h.createOverlay(),dismiss:()=>h.dismiss(),getBrowserPermissionHint:()=>h.getBrowserPermissionHint(),fillCameraPermissionPrompt:(g,v)=>h.fillCameraPermissionPrompt(g,v),notifyCameraPermissionDenied:(g,v)=>h.notifyCameraPermissionDenied(g,v)},client:s,onComplete:g=>{h.kycCaptureStop=null,A(g)},onCancel:g=>{h.kycCaptureStop=null,o(g)},isActive:()=>h.captureActive});this.kycCaptureStop=p.stop}renderKycSignatureCapture(e,t,n,i){const s=_.KycSignatureCapture;this.bindActiveModalPreset(e,s,t,n);const a=l=>{this.clearActiveModalPreset(),t({status:"success",preset_id:s,...l})},A=(l,d="cancelled")=>{this.clearActiveModalPreset(),n(l,{status:d})},o=String(e.args.reason??e.clientFields.reason??"").trim();if(!o){A("reason is required — media routing key (e.g. kyc_signature)");return}const c=RU({presetId:s,title:String(e.clientFields.title??e.args.title??"Sign here"),description:String(e.clientFields.description??e.args.description??"Draw your signature in the box below, then submit."),reason:o,host:{createOverlay:()=>this.createOverlay(),dismiss:()=>this.dismiss()},client:i,onComplete:a,onCancel:l=>A(l)});this.kycCaptureStop=c.stop}renderCamera(e,t,n,i){this.bindActiveModalPreset(e,_.Camera,t,n);const s=ee=>{this.clearActiveModalPreset(),t({status:"success",preset_id:_.Camera,...ee})},a=(ee,ue="cancelled")=>{this.clearActiveModalPreset(),n(ee,{status:ue})},A=this,o=e.clientFields.title||"Take a Photo",c=e.clientFields.description||"Point your camera at the subject, then tap capture.",l=e.clientFields.facing_mode||e.args.facing_mode||"environment",d=e.clientFields.reason||"camera_capture",u=e.clientFields.liveness_check===!0||e.clientFields.liveness_check==="true"||e.args.liveness_check===!0||e.args.liveness_check==="true";let h=null,p=null;this.stopCaptureCamera(),this.captureActive=!0;const g=this.createOverlay(),v=document.createElement("div");v.className="vnr-modal",v.style.cssText="position:relative;max-width:480px;width:100%",v.innerHTML=`
|
|
398
797
|
<button class="vnr-close-btn" aria-label="Close">
|
|
399
798
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
400
799
|
</button>
|
|
401
|
-
<h2 class="vnr-title" style="padding-right:32px">${
|
|
800
|
+
<h2 class="vnr-title" style="padding-right:32px">${o}</h2>
|
|
402
801
|
<p style="margin:0 0 14px;font-size:13px;color:#6b7280;line-height:1.5">${c}</p>
|
|
403
802
|
|
|
404
803
|
<div class="vnr-liveness-toggle-wrap" style="display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;background:#f9fafb;border:1px solid #e5e7eb;border-radius:10px;padding:8px 12px">
|
|
@@ -425,10 +824,10 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
425
824
|
<div id="vnr-liveness-progress-container" style="display:none;margin-top:12px">
|
|
426
825
|
<div style="display:flex;justify-content:space-between;font-size:11px;font-weight:700;color:#6b7280;margin-bottom:6px;letter-spacing:0.04em">
|
|
427
826
|
<span>LIVENESS ANALYSIS</span>
|
|
428
|
-
<span id="vnr-liveness-pct" style="color:#
|
|
827
|
+
<span id="vnr-liveness-pct" style="color:#111">0%</span>
|
|
429
828
|
</div>
|
|
430
|
-
<div style="width:100%;height:
|
|
431
|
-
<div id="vnr-liveness-bar" style="width:0%;height:100%;background:#
|
|
829
|
+
<div style="width:100%;height:4px;background:#e5e7eb;border-radius:2px;overflow:hidden">
|
|
830
|
+
<div id="vnr-liveness-bar" style="width:0%;height:100%;background:#111;transition:width 0.1s linear"></div>
|
|
432
831
|
</div>
|
|
433
832
|
</div>
|
|
434
833
|
|
|
@@ -441,20 +840,15 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
441
840
|
Capture & Send
|
|
442
841
|
</button>
|
|
443
842
|
</div>
|
|
444
|
-
`,
|
|
843
|
+
`,g.appendChild(v);const w=v.querySelector("#vnr-cam-video"),B=v.querySelector("#vnr-cam-canvas"),E=v.querySelector("#vnr-cam-overlay"),b=v.querySelector("#vnr-cam-status"),C=v.querySelector("#vnr-cam-capture"),T=v.querySelector("#vnr-cam-liveness-toggle"),F=v.querySelector("#vnr-liveness-progress-container"),R=v.querySelector("#vnr-liveness-bar"),M=v.querySelector("#vnr-liveness-pct"),D=v.querySelector("#vnr-cam-guide"),O=v.querySelector("#vnr-cam-guide-text"),H=()=>{p&&(clearInterval(p),p=null),this.captureLivenessInterval=null,h==null||h.getTracks().forEach(ee=>ee.stop()),h=null,A.captureStream=null,w.srcObject=null};v.querySelector(".vnr-close-btn").addEventListener("click",()=>{H(),this.captureActive=!1,this.dismiss(),a("User closed")}),v.querySelector("#vnr-cam-cancel").addEventListener("click",()=>{H(),this.captureActive=!1,this.dismiss(),a("User cancelled")});const se=()=>{this.captureActive&&(E.style.display="flex",E.innerHTML=`
|
|
445
844
|
<div class="vnr-spinner" style="width:32px;height:32px;border-width:3px;border-color:rgba(255,255,255,.15);border-top-color:#fff"></div>
|
|
446
845
|
<p style="margin:0;font-size:13px;color:#94a3b8">Opening camera…</p>
|
|
447
|
-
`,x.disabled=!0,navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:u}},audio:!1}).then(T=>{if(!this.captureActive){T.getTracks().forEach(M=>M.stop());return}return h=T,a.captureStream=T,g.srcObject=T,g.play().catch(()=>{})}).then(()=>{if(!(!this.captureActive||!h)){if(S.style.display="none",!v.querySelector(".vnr-live-badge")){const T=document.createElement("div");T.className="vnr-live-badge",T.innerHTML='<span class="vnr-live-dot"></span>LIVE',v.querySelector("#vnr-cam-wrap").appendChild(T)}C.checked=p,O()}}).catch(()=>{this.captureActive&&(this.notifyCameraPermissionDenied(s,e.toolCallId),this.fillCameraPermissionPrompt(S,{onRetry:F,onDismiss:()=>{D(),this.captureActive=!1,this.dismiss(),o("Camera permission denied","cancelled")}}))}))};F();function O(){f&&(clearInterval(f),f=null,a.captureLivenessInterval=null),C.checked?(k.style.display="block",L.style.display="block",x.disabled=!0,A()):(k.style.display="none",L.style.display="none",x.disabled=!1)}C.addEventListener("change",O);function A(){let T=null;const M=[];let R=1,U=0,J=0,ye=0,ft=!1;const Ue=document.createElement("canvas"),mt=Ue.getContext("2d");Ue.width=80,Ue.height=60,E.style.width="0%",E.style.backgroundColor="#6366f1",I.style.color="#6366f1",I.innerText="0%",L.style.borderColor="rgba(255,255,255,0.45)",L.style.boxShadow="0 0 0 9999px rgba(15,23,42,0.6)",$.innerText="Align your face in center",$.style.color="#fff",f=setInterval(()=>{if(!h||g.paused||g.ended)return;mt.drawImage(g,0,0,80,60);const ne=mt.getImageData(0,0,80,60).data;if(T){let ge=0;for(let V=0;V<ne.length;V+=4)ge+=Math.abs(ne[V]-T[V]),ge+=Math.abs(ne[V+1]-T[V+1]),ge+=Math.abs(ne[V+2]-T[V+2]);const be=ge/(ne.length/4*3);if(J===0){ye++,M.push(be);const V=Math.min(100,Math.round(ye/15*100));E.style.width=`${V*.3}%`,I.innerText=`${Math.round(V*.3)}%`,$.innerText="Hold still to calibrate…",$.style.color="#a5b4fc",ye>=15&&(R=M.reduce((Er,Tr)=>Er+Tr,0)/M.length,R<.2&&(R=.2),J=1,ye=0,E.style.width="30%",I.innerText="30%")}else if(J===1){$.innerText="Now blink or turn head slightly",$.style.color="#ffd2d2";const V=Math.max(3,R*3.5);if(be>V&&be<30){U+=15,U>70&&(U=70,ft=!0);const Fe=30+U;E.style.width=`${Fe}%`,I.innerText=`${Fe}%`}else ft&&be<=V*1.5&&(J=2,E.style.width="100%",E.style.backgroundColor="#10b981",I.innerText="100%",I.style.color="#10b981",$.innerText="✓ Liveness Verified! Click Capture & Send.",$.style.color="#10b981",L.style.borderColor="#10b981",L.style.boxShadow="0 0 0 9999px rgba(16,185,129,0.2)",x.disabled=!1,f&&(clearInterval(f),f=null,a.captureLivenessInterval=null))}}T=ne},100),a.captureLivenessInterval=f}x.addEventListener("click",async()=>{if(!h||g.videoWidth===0)return;b.width=g.videoWidth,b.height=g.videoHeight,b.getContext("2d").drawImage(g,0,0),D(),v.querySelector("#vnr-cam-wrap").setAttribute("style","display:none"),v.querySelector(".vnr-liveness-toggle-wrap")&&(v.querySelector(".vnr-liveness-toggle-wrap").style.display="none"),k.style.display="none",x.disabled=!0,w.style.display="block",w.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Sending photo…</div>';try{const M=await new Promise(U=>b.toBlob(J=>U(J),"image/jpeg",.85));if(!M)throw new Error("Capture failed");const R=new File([M],`capture-${Date.now()}.jpg`,{type:"image/jpeg"});if(s&&typeof s.uploadMedia=="function"){const{media_id:U,url:J}=await s.uploadMedia(R,d,"User captured a photo via camera");w.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ Photo sent!</div>',setTimeout(()=>{this.dismiss(),i({file_name:R.name,file_type:R.type,file_size:R.size,media_id:U,url:J,message:"User captured and sent a photo."})},400)}else{const U=b.toDataURL("image/jpeg",.85);w.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ Photo ready!</div>',setTimeout(()=>{this.dismiss(),i({file_name:R.name,data_url:U,message:"User captured a photo."})},400)}}catch(M){w.innerHTML=`<div class="vnr-center" style="color:#ef4444">${(M==null?void 0:M.message)||"Capture failed"}</div>`}})}renderClipRegion(e,t,r,s){const i=e.args??{},o=String(i.reason??e.clientFields.reason??"page_clip"),a=String(i.prompt??i.message??e.clientFields.default_prompt??"").trim(),l=String(e.clientFields.hint??(a?`Select the area to answer: "${a}"`:"Drag to select an area — release to clip.")),c=Number(e.clientFields.min_region_px??24),u=d=>{qe(),r(d,{status:"cancelled"})};if(typeof document>"u"){u("Page clip is only available in browser environments");return}nn({hint:l,minSizePx:c}).then(async d=>{if(!d){u("User cancelled region selection");return}const p=new File([d.blob],`clip-${Date.now()}.jpg`,{type:"image/jpeg"}),h=a?`User clipped a page region and asked: ${a}`:"User clipped a region of the page and sent it for analysis.";try{await this.completeBlockingMediaTool(s,p,o,{preset_id:m.ClipRegion,region:d.region,viewport:d.viewport,pixel_size:d.pixelSize,prompt:a||void 0,message:h},t)}catch(f){const y=f instanceof Error?f.message:"Clip upload failed";r(y,{status:"cancelled"})}}).catch(d=>{u(d instanceof Error?d.message:"Region clip failed")})}async completeBlockingMediaTool(e,t,r,s,i){const o=e==null?void 0:e.uploadMediaForToolResult;let a,l;if(o&&typeof o=="function")try{const u=await o.call(e,t,r);a=u.media_id,l=u.url}catch{}if(a&&l){i({status:"success",media_id:a,url:l,...s});return}const c=await new Promise((u,d)=>{const p=new FileReader;p.onload=()=>u(String(p.result)),p.onerror=()=>d(new Error("Failed to read media blob")),p.readAsDataURL(t)});i({status:"success",data_url:c,...s})}renderTabScreenshot(e,t,r,s){const i=e.args??{},o=String(i.reason??e.clientFields.reason??"tab_screenshot"),a=String(i.prompt??i.message??e.clientFields.default_prompt??"").trim(),l=Number(i.max_width??e.clientFields.max_width??1280),c=Number(i.max_elements??e.clientFields.max_elements??80);if(typeof document>"u"){r("Tab screenshot is only available in browser environments");return}(async()=>{try{const u=lr({maxElements:Number.isFinite(c)?c:80}),d=ln(u),h=`${a?`Tab snapshot captured. Context: ${a}`:"Tab snapshot of the visible page captured."}
|
|
448
|
-
|
|
449
|
-
COORDINATES ARE NORMALIZED VIEWPORT (0–1), NOT JPEG PIXELS. viewport=${u.viewport.width}x${u.viewport.height}
|
|
450
|
-
|
|
451
|
-
For screen_ink prefer css_selector (live DOM) OR copy stroke_points from below:
|
|
452
|
-
${d}`,f={layout:u,elements:u.elements,element_count:u.elements.length,layout_summary:d,coordinate_system:u.coordinate_system,drawing_guide:"Use screen_ink with css_selector for exact placement, or strokes:[{ points: element.stroke_points, close:true }]. Coords are 0–1 viewport fractions."};t({status:"success",preset_id:m.TabScreenshot,viewport:u.viewport,prompt:a||void 0,message:h,...f}),(async()=>{try{let y=await tr();Number.isFinite(l)&&l>0&&(y=rr(y,l));const v=await ut(y),g=new File([v],`tab-${Date.now()}.jpg`,{type:"image/jpeg"}),b=s==null?void 0:s.uploadMediaForToolResult;b&&typeof b=="function"&&await b.call(s,g,o)}catch{}})()}catch(u){const d=u instanceof Error?u.message:"Tab screenshot failed";r(d,{status:"cancelled"})}})()}renderUpload(e,t,r,s){this.bindActiveModalPreset(e,m.Upload,t,r);const i=w=>{this.clearActiveModalPreset(),t({status:"success",preset_id:m.Upload,...w})},o=w=>{this.clearActiveModalPreset(),r(w,{status:"cancelled"})},a=e.clientFields.title||"Upload a File",l=e.clientFields.description||"Drop or select a file to send to your agent.",c=e.clientFields.reason||"upload",u=e.clientFields.accept||"image/*,application/pdf,text/plain,text/csv";let d=null;const p=this.createOverlay(),h=document.createElement("div");h.className="vnr-modal",h.style.cssText="position:relative;max-width:480px;width:100%",h.innerHTML=`
|
|
846
|
+
`,C.disabled=!0,navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:l}},audio:!1}).then(ee=>{if(!this.captureActive){ee.getTracks().forEach(ue=>ue.stop());return}return h=ee,A.captureStream=ee,w.srcObject=ee,w.play().catch(()=>{})}).then(()=>{if(!(!this.captureActive||!h)){if(E.style.display="none",!v.querySelector(".vnr-live-badge")){const ee=document.createElement("div");ee.className="vnr-live-badge",ee.innerHTML='<span class="vnr-live-dot"></span>LIVE',v.querySelector("#vnr-cam-wrap").appendChild(ee)}T.checked=u,ie()}}).catch(()=>{this.captureActive&&(this.notifyCameraPermissionDenied(i,e.toolCallId),this.fillCameraPermissionPrompt(E,{onRetry:se,onDismiss:()=>{H(),this.captureActive=!1,this.dismiss(),a("Camera permission denied","cancelled")}}))}))};se();function ie(){p&&(clearInterval(p),p=null,A.captureLivenessInterval=null),T.checked?(F.style.display="block",D.style.display="block",C.disabled=!0,Z()):(F.style.display="none",D.style.display="none",C.disabled=!1)}T.addEventListener("change",ie);function Z(){let ee=null;const ue=[];let Ce=1,Ue=0,Ge=0,qe=0,We=!1;const gt=document.createElement("canvas"),$e=gt.getContext("2d");gt.width=80,gt.height=60,R.style.width="0%",R.style.backgroundColor="#111",M.style.color="#111",M.innerText="0%",D.style.borderColor="rgba(255,255,255,0.45)",D.style.boxShadow="0 0 0 9999px rgba(15,23,42,0.6)",O.innerText="Align your face in center",O.style.color="#fff",p=setInterval(()=>{if(!h||w.paused||w.ended)return;$e.drawImage(w,0,0,80,60);const Mt=$e.getImageData(0,0,80,60).data;if(ee){let vt=0;for(let _e=0;_e<Mt.length;_e+=4)vt+=Math.abs(Mt[_e]-ee[_e]),vt+=Math.abs(Mt[_e+1]-ee[_e+1]),vt+=Math.abs(Mt[_e+2]-ee[_e+2]);const _t=vt/(Mt.length/4*3);if(Ge===0){qe++,ue.push(_t);const _e=Math.min(100,Math.round(qe/15*100));R.style.width=`${_e*.3}%`,M.innerText=`${Math.round(_e*.3)}%`,O.innerText="Hold still to calibrate…",O.style.color="#9ca3af",qe>=15&&(Ce=ue.reduce((ms,gs)=>ms+gs,0)/ue.length,Ce<.2&&(Ce=.2),Ge=1,qe=0,R.style.width="30%",M.innerText="30%")}else if(Ge===1){O.innerText="Now blink or turn head slightly",O.style.color="#ffd2d2";const _e=Math.max(3,Ce*3.5);if(_t>_e&&_t<30){Ue+=15,Ue>70&&(Ue=70,We=!0);const on=30+Ue;R.style.width=`${on}%`,M.innerText=`${on}%`}else We&&_t<=_e*1.5&&(Ge=2,R.style.width="100%",R.style.backgroundColor="#10b981",M.innerText="100%",M.style.color="#10b981",O.innerText="✓ Liveness Verified! Click Capture & Send.",O.style.color="#10b981",D.style.borderColor="#10b981",D.style.boxShadow="0 0 0 9999px rgba(16,185,129,0.2)",C.disabled=!1,p&&(clearInterval(p),p=null,A.captureLivenessInterval=null))}}ee=Mt},100),A.captureLivenessInterval=p}C.addEventListener("click",async()=>{if(!h||w.videoWidth===0)return;B.width=w.videoWidth,B.height=w.videoHeight,B.getContext("2d").drawImage(w,0,0),H(),v.querySelector("#vnr-cam-wrap").setAttribute("style","display:none"),v.querySelector(".vnr-liveness-toggle-wrap")&&(v.querySelector(".vnr-liveness-toggle-wrap").style.display="none"),F.style.display="none",C.disabled=!0,b.style.display="block",b.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Sending photo…</div>';try{const ue=await new Promise(Ue=>B.toBlob(Ge=>Ue(Ge),"image/jpeg",.85));if(!ue)throw new Error("Capture failed");const Ce=new File([ue],`capture-${Date.now()}.jpg`,{type:"image/jpeg"});if(i&&typeof i.uploadMedia=="function"){const{media_id:Ue,url:Ge}=await i.uploadMedia(Ce,d,"User captured a photo via camera");b.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ Photo sent!</div>',setTimeout(()=>{this.dismiss(),s({file_name:Ce.name,file_type:Ce.type,file_size:Ce.size,media_id:Ue,url:Ge,message:"User captured and sent a photo."})},400)}else{const Ue=B.toDataURL("image/jpeg",.85);b.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ Photo ready!</div>',setTimeout(()=>{this.dismiss(),s({file_name:Ce.name,data_url:Ue,message:"User captured a photo."})},400)}}catch(ue){b.innerHTML=`<div class="vnr-center" style="color:#ef4444">${(ue==null?void 0:ue.message)||"Capture failed"}</div>`}})}renderClipRegion(e,t,n,i){const s=e.args??{},a=String(s.reason??e.clientFields.reason??"page_clip"),A=String(s.prompt??s.message??e.clientFields.default_prompt??"").trim(),o=String(e.clientFields.hint??(A?`Select the area to answer: "${A}"`:"Drag to select an area — release to clip.")),c=Number(e.clientFields.min_region_px??24),l=d=>{il(),n(d,{status:"cancelled"})};if(typeof document>"u"){l("Page clip is only available in browser environments");return}lx({hint:o,minSizePx:c}).then(async d=>{if(!d){l("User cancelled region selection");return}const u=new File([d.blob],`clip-${Date.now()}.jpg`,{type:"image/jpeg"}),h=A?`User clipped a page region and asked: ${A}`:"User clipped a region of the page and sent it for analysis.";try{await this.completeBlockingMediaTool(i,u,a,{preset_id:_.ClipRegion,region:d.region,viewport:d.viewport,pixel_size:d.pixelSize,prompt:A||void 0,message:h},t)}catch(p){const g=p instanceof Error?p.message:"Clip upload failed";n(g,{status:"cancelled"})}}).catch(d=>{l(d instanceof Error?d.message:"Region clip failed")})}async completeBlockingMediaTool(e,t,n,i,s,a){const A=e==null?void 0:e.uploadMediaForToolResult;let o,c;if(A&&typeof A=="function")try{const d=await A.call(e,t,n);o=d.media_id,c=d.url}catch{}if(o&&c){if(s({status:"success",media_id:o,url:c,...i}),a!=null&&a.notifyVision){const d=e==null?void 0:e.sendMediaUpdate;typeof d=="function"&&d.call(e,{media_id:o,media_url:c,content_type:a.notifyVision.contentType??t.type??"image/jpeg",reason:n,message:a.notifyVision.message??String(i.message??"")})}return}const l=await new Promise((d,u)=>{const h=new FileReader;h.onload=()=>d(String(h.result)),h.onerror=()=>u(new Error("Failed to read media blob")),h.readAsDataURL(t)});s({status:"success",data_url:l,...i})}renderScreenVision(e,t,n,i){const s=e.args??{},a=String(s.reason??e.clientFields.reason??"screen_vision"),A=String(s.prompt??s.message??e.clientFields.default_prompt??"").trim(),o=Tx(s.max_width??e.clientFields.max_width),c=Number(s.jpeg_quality??e.clientFields.jpeg_quality??.72),d=String(s.capture_surface??e.clientFields.capture_surface??"tab").toLowerCase()==="display"?"display":"tab",u=d==="display"&&s.reuse_live_screen!==!1&&e.clientFields.reuse_live_screen!==!1;if(typeof document>"u"){n("Screen vision is only available in browser environments");return}const h=Qr();h.setVoiceState("processing"),h.dismissPointing(),h.hide(),(async()=>{let p=()=>{};try{const g=u&&this.lsStream?this.lsStream:null,v=u&&this.lsVideo?this.lsVideo:null,w=Number.isFinite(c)?Math.min(1,Math.max(.4,c)):.72,{capture:B,release:E}=await Mx({maxWidth:o,quality:w,mode:g?"display":d,existingStream:g,existingVideo:v});p=E;const b=Qu({maxElements:80}),C=tc(b,B.widthPx,B.heightPx),T=kx(b,B.widthPx,B.heightPx);h.hide(),h.setCaptureContext({widthPx:B.widthPx,heightPx:B.heightPx,viewportWidthCss:B.viewportWidthCss,viewportHeightCss:B.viewportHeightCss,label:B.label,layoutElements:C});const F=Zx({prompt:A||void 0,captures:[{label:B.label,widthPx:B.widthPx,heightPx:B.heightPx,viewportWidthCss:B.viewportWidthCss,viewportHeightCss:B.viewportHeightCss,isPrimary:B.isPrimary}],layoutSummary:T});h.setVoiceState("idle"),h.show();const R={preset_id:_.ScreenVision,message:F,prompt:A||void 0,coordinate_system:"screenshot_pixels",capture_surface:d,screenshot_width:B.widthPx,screenshot_height:B.heightPx,viewport_width_css:B.viewportWidthCss,viewport_height_css:B.viewportHeightCss,jpeg_quality:w,display_surface:B.displaySurface,capture_label:B.label,page_layout:C};if(!i){t({status:"success",...R});return}await this.completeBlockingMediaTool(i,B.blob,a,R,t,{notifyVision:{message:F,contentType:"image/jpeg"}})}catch(g){h.setVoiceState("idle");const v=g instanceof Error?g.message:"Screen vision capture failed";n(v,{status:"cancelled"})}finally{p()}})()}renderPointAt(e,t,n){const i=e.args??{},s=e.clientFields??{},a=Qr(),A=a.getCaptureContext(),o=String(i.point_tag??s.point_tag??"").trim();if(o){const p=Yx(o);if(p.coordinate){const g=Of({label:p.elementLabel??void 0,modelX:p.coordinate.x,modelY:p.coordinate.y,captureScreenshotWidth:A==null?void 0:A.widthPx,captureScreenshotHeight:A==null?void 0:A.heightPx,captureViewportWidth:A==null?void 0:A.viewportWidthCss,captureViewportHeight:A==null?void 0:A.viewportHeightCss,staleLayoutElements:A==null?void 0:A.layoutElements});a.setVoiceState("responding"),a.pointAtScreenshotPixels(g.x,g.y,{label:g.label||p.elementLabel||void 0,screenshotWidth:g.screenshotWidth,screenshotHeight:g.screenshotHeight,viewportWidthCss:g.viewportWidthCss,viewportHeightCss:g.viewportHeightCss}),t({status:"success",preset_id:_.PointAt,message:g.label?`Buddy pointing at "${g.label}" (${Math.round(g.x)}, ${Math.round(g.y)}) [${g.source}]`:`Buddy pointing at (${Math.round(g.x)}, ${Math.round(g.y)})`}),window.setTimeout(()=>a.setVoiceState("idle"),3200);return}t({status:"success",preset_id:_.PointAt,message:"No pointing coordinate (POINT:none)"});return}const c=Number(i.x??s.x),l=Number(i.y??s.y);if(!Number.isFinite(c)||!Number.isFinite(l)){n("point_at_screen requires x and y in screenshot pixel space");return}const d=String(i.label??s.label??"").trim()||void 0,u=String(i.bubble_text??s.bubble_text??"").trim()||void 0,h=Of({label:d,modelX:c,modelY:l,captureScreenshotWidth:Number(i.screenshot_width??s.screenshot_width??(A==null?void 0:A.widthPx)),captureScreenshotHeight:Number(i.screenshot_height??s.screenshot_height??(A==null?void 0:A.heightPx)),captureViewportWidth:Number(i.viewport_width_css??s.viewport_width_css??(A==null?void 0:A.viewportWidthCss)),captureViewportHeight:Number(i.viewport_height_css??s.viewport_height_css??(A==null?void 0:A.viewportHeightCss)),staleLayoutElements:A==null?void 0:A.layoutElements});a.setVoiceState("responding"),a.show(),a.pointAtScreenshotPixels(h.x,h.y,{label:h.label||d,bubbleText:u,screenshotWidth:h.screenshotWidth,screenshotHeight:h.screenshotHeight,viewportWidthCss:h.viewportWidthCss,viewportHeightCss:h.viewportHeightCss}),t({status:"success",preset_id:_.PointAt,message:h.label||d?`Buddy pointing at "${h.label||d}" (${Math.round(h.x)}, ${Math.round(h.y)}) [${h.source}]`:`Buddy pointing at (${Math.round(h.x)}, ${Math.round(h.y)})`}),window.setTimeout(()=>a.setVoiceState("idle"),3200)}renderDrawOnScreen(e,t,n){const i=e.args??{},s=e.clientFields??{},a=Qr(),A=a.getCaptureContext(),o=i.clear===!0||s.clear===!0||i.clear_existing===!0||s.clear_existing===!0;let c=i.commands??s.commands??i.commands_json??s.commands_json;if(typeof c=="string")try{c=JSON.parse(c)}catch{n("draw_on_screen: commands must be a JSON array");return}const l=wv(c);if(!l.length){n("draw_on_screen requires a non-empty commands array");return}const d=i.ttl_ms??s.ttl_ms;let u;if(d!=null&&d!==""){const w=Number(d);u=Number.isFinite(w)&&w>0?w:null}const h=i.animate_ms??s.animate_ms,p=Number(h),g=i.allow_overlap===!0||s.allow_overlap===!0,v=a.drawOnScreen(l,{clear:o,ttlMs:u,animateMs:Number.isFinite(p)&&p>0?p:void 0,allowOverlap:g,screenshotWidth:Number(i.screenshot_width??s.screenshot_width??(A==null?void 0:A.widthPx)),screenshotHeight:Number(i.screenshot_height??s.screenshot_height??(A==null?void 0:A.heightPx)),viewportWidthCss:Number(i.viewport_width_css??s.viewport_width_css??(A==null?void 0:A.viewportWidthCss)),viewportHeightCss:Number(i.viewport_height_css??s.viewport_height_css??(A==null?void 0:A.viewportHeightCss))});if(v.rejected||v.overlapDetected){t({status:"error",overlap_detected:!0,preset_id:_.DrawOnScreen,drawn:0,message:v.message??"Draw rejected: overlap detected",conflicts:v.conflicts,hint:"Adjust coordinates, call clear_screen_draw first, or set allow_overlap:true to draw on existing shapes."});return}a.show(),t({status:"success",preset_id:_.DrawOnScreen,drawn:v.drawn,message:`Drew ${v.drawn} shape(s) on screen (${l.map(w=>w.op).join(", ")})`})}renderClearScreenDraw(e,t,n){Qr().clearDrawings(),t({status:"success",preset_id:_.ClearScreenDraw,message:"Screen annotations cleared"})}renderHighlightOnScreen(e,t,n){const i=e.args??{},s=e.clientFields??{},a=Qr(),A=a.getCaptureContext(),o=String(i.label??s.label??"").trim(),c=String(i.element_id??s.element_id??"").trim(),l=String(i.css_selector??s.css_selector??i.selector??s.selector??"").trim();if(!o&&!c&&!l){n("highlight_on_screen requires label, element_id, or css_selector");return}const d=Kf({label:o||void 0,element_id:c||void 0,css_selector:l||void 0,staleLayoutElements:A==null?void 0:A.layoutElements,captureCtx:A,padding:Number(i.padding??s.padding??8),stroke:String(i.color??i.stroke??s.color??s.stroke??"#3b82f6"),rx:Number(i.rx??s.rx)||void 0});if(!d){n(`Element not found for highlight (${c||o||l})`);return}try{const b=document.querySelector(d.css_selector);b==null||b.scrollIntoView({behavior:"smooth",block:"center"})}catch{}const u=i.clear===!0||s.clear===!0,h=i.ttl_ms??s.ttl_ms;let p;if(h!=null&&h!==""){const b=Number(h);p=Number.isFinite(b)&&b>0?b:null}const g=i.animate_ms??s.animate_ms,v=Number(g),w=i.allow_overlap===!0||s.allow_overlap===!0,B=i.point_at!==!1&&s.point_at!==!1,E=a.drawOnScreen([d.command],{clear:u,ttlMs:p,animateMs:Number.isFinite(v)&&v>0?v:void 0,allowOverlap:w,screenshotWidth:A==null?void 0:A.widthPx,screenshotHeight:A==null?void 0:A.heightPx,viewportWidthCss:A==null?void 0:A.viewportWidthCss,viewportHeightCss:A==null?void 0:A.viewportHeightCss});if(E.rejected||E.overlapDetected){t({status:"error",overlap_detected:!0,preset_id:_.HighlightOnScreen,drawn:0,message:E.message??"Highlight rejected: overlap detected",conflicts:E.conflicts,hint:"Call clear_screen_draw first or set allow_overlap:true."});return}B&&(a.setVoiceState("responding"),a.pointAtScreenshotPixels(d.center_x,d.center_y,{label:d.label,screenshotWidth:A==null?void 0:A.widthPx,screenshotHeight:A==null?void 0:A.heightPx,viewportWidthCss:A==null?void 0:A.viewportWidthCss,viewportHeightCss:A==null?void 0:A.viewportHeightCss}),window.setTimeout(()=>a.setVoiceState("idle"),3200)),a.show(),t({status:"success",preset_id:_.HighlightOnScreen,message:`Highlighted "${d.label}" (${d.bbox.width}x${d.bbox.height}px box)`,element_label:d.label,css_selector:d.css_selector,bbox:d.bbox,center_x:d.center_x,center_y:d.center_y})}renderUpload(e,t,n,i){this.bindActiveModalPreset(e,_.Upload,t,n);const s=b=>{this.clearActiveModalPreset(),t({status:"success",preset_id:_.Upload,...b})},a=b=>{this.clearActiveModalPreset(),n(b,{status:"cancelled"})},A=e.clientFields.title||"Upload a File",o=e.clientFields.description||"Drop or select a file to send to your agent.",c=e.clientFields.reason||"upload",l=e.clientFields.accept||"image/*,application/pdf,text/plain,text/csv";let d=null;const u=this.createOverlay(),h=document.createElement("div");h.className="vnr-modal",h.style.cssText="position:relative;max-width:480px;width:100%",h.innerHTML=`
|
|
453
847
|
<button class="vnr-close-btn" aria-label="Close">
|
|
454
848
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
455
849
|
</button>
|
|
456
|
-
<h2 class="vnr-title" style="padding-right:32px">${
|
|
457
|
-
<p style="margin:0 0 14px;font-size:13px;color:#6b7280;line-height:1.5">${
|
|
850
|
+
<h2 class="vnr-title" style="padding-right:32px">${A}</h2>
|
|
851
|
+
<p style="margin:0 0 14px;font-size:13px;color:#6b7280;line-height:1.5">${o}</p>
|
|
458
852
|
<div class="vnr-dropzone" id="vnr-drop-zone">
|
|
459
853
|
<div style="font-size:32px;margin-bottom:8px">📁</div>
|
|
460
854
|
<p style="margin:0 0 4px;font-weight:600;color:#374151;font-size:14px">Drag & drop here</p>
|
|
@@ -462,7 +856,7 @@ ${d}`,f={layout:u,elements:u.elements,element_count:u.elements.length,layout_sum
|
|
|
462
856
|
<span style="display:inline-block;padding:7px 16px;background:#111;color:#fff;border-radius:9px;font-size:13px;font-weight:600">Choose File</span>
|
|
463
857
|
<p style="margin:12px 0 0;font-size:11px;color:#9ca3af">Images, PDF, CSV, Docs · Max 10 MB</p>
|
|
464
858
|
</div>
|
|
465
|
-
<input id="vnr-file-input" type="file" accept="${
|
|
859
|
+
<input id="vnr-file-input" type="file" accept="${l}" style="display:none">
|
|
466
860
|
<div id="vnr-file-preview" style="display:none;border:1px solid #e5e7eb;border-radius:12px;padding:14px;background:#f9fafb"></div>
|
|
467
861
|
<div id="vnr-upload-status" style="display:none"></div>
|
|
468
862
|
<div class="vnr-actions" style="margin-top:14px">
|
|
@@ -472,18 +866,17 @@ ${d}`,f={layout:u,elements:u.elements,element_count:u.elements.length,layout_sum
|
|
|
472
866
|
Upload & Send
|
|
473
867
|
</button>
|
|
474
868
|
</div>
|
|
475
|
-
`,
|
|
869
|
+
`,u.appendChild(h);const p=h.querySelector("#vnr-drop-zone"),g=h.querySelector("#vnr-file-input"),v=h.querySelector("#vnr-file-preview"),w=h.querySelector("#vnr-upload-status"),B=h.querySelector("#vnr-up-submit");h.querySelector(".vnr-close-btn").addEventListener("click",()=>{this.dismiss(),a("User closed")}),h.querySelector("#vnr-up-cancel").addEventListener("click",()=>{this.dismiss(),a("User cancelled")});const E=b=>{d=b,p.style.display="none";const C=b.type.startsWith("image/")?"🖼️":b.type.includes("pdf")?"📄":"📁",T=(b.size/1024).toFixed(1);v.style.display="block",v.innerHTML=`
|
|
476
870
|
<div style="display:flex;align-items:center;gap:10px">
|
|
477
|
-
<span style="font-size:28px">${
|
|
871
|
+
<span style="font-size:28px">${C}</span>
|
|
478
872
|
<div style="flex:1;min-width:0">
|
|
479
|
-
<p style="margin:0;font-weight:600;font-size:13px;color:#111;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${
|
|
480
|
-
<p style="margin:3px 0 0;font-size:11px;color:#6b7280">${
|
|
873
|
+
<p style="margin:0;font-weight:600;font-size:13px;color:#111;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${b.name}</p>
|
|
874
|
+
<p style="margin:3px 0 0;font-size:11px;color:#6b7280">${b.type||"unknown"} · ${T} KB</p>
|
|
481
875
|
</div>
|
|
482
876
|
<button id="vnr-remove-file" style="width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#fff;border:1px solid #e5e7eb;border-radius:8px;cursor:pointer;color:#6b7280;flex-shrink:0">
|
|
483
877
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
484
878
|
</button>
|
|
485
879
|
</div>
|
|
486
|
-
`,v.querySelector("#vnr-remove-file").addEventListener("click",()=>{d=null,v.style.display="none",f.style.display="block",b.disabled=!0}),b.disabled=!1};f.addEventListener("click",()=>y.click()),f.addEventListener("dragover",w=>{w.preventDefault(),f.classList.add("drag")}),f.addEventListener("dragleave",()=>f.classList.remove("drag")),f.addEventListener("drop",w=>{var C;w.preventDefault(),f.classList.remove("drag");const x=(C=w.dataTransfer)==null?void 0:C.files[0];x&&S(x)}),y.addEventListener("change",()=>{var x;const w=(x=y.files)==null?void 0:x[0];w&&S(w)}),b.addEventListener("click",async()=>{if(!d)return;const w=d;f.style.display="none",v.style.display="none",g.style.display="block",g.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Uploading…</div>',b.disabled=!0;try{if(s&&typeof s.uploadMedia=="function"){const{media_id:x,url:C}=await s.uploadMedia(w,c,`User uploaded: ${w.name}`);g.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ File sent!</div>',setTimeout(()=>{this.dismiss(),i({file_name:w.name,file_type:w.type,file_size:w.size,media_id:x,url:C,message:`User uploaded: ${w.name}`})},400)}else{const x=new FileReader;x.onload=C=>{g.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ File ready!</div>',setTimeout(()=>{this.dismiss(),i({file_name:w.name,file_type:w.type,file_size:w.size,data_url:C.target.result,message:`User uploaded: ${w.name}`})},400)},x.readAsDataURL(w)}}catch(x){g.innerHTML=`<div class="vnr-center" style="color:#ef4444">${(x==null?void 0:x.message)||"Upload failed. Please try again."}</div>`,b.disabled=!1,this.dismiss(),this.clearActiveModalPreset(),r((x==null?void 0:x.message)||"Upload failed",{status:"cancelled"})}})}extractElementRoute(e){const t=e.args||{},r=e.clientFields||{};return String(t.route||r.route||t.target_route||r.target_route||"").trim()}normalizeRouteForCompare(e){const t=(e.trim()||"/").split("#")[0],r=t.startsWith("/")?t:`/${t}`;try{const s=new URL(r,window.location.origin);return`${s.pathname}${s.search}`||"/"}catch{return r||"/"}}isCurrentRoute(e){const t=this.normalizeRouteForCompare(e);return(`${window.location.pathname}${window.location.search}`||"/")===t}parseDomTarget(e){const t=e.trim();return t?/^[.#\[]/.test(t)||t.includes(" ")||t.includes(">")?{selector:t}:{elementId:t.replace(/^#/,"")}:{}}findDomTarget(e){if(e.selector)try{const t=document.querySelector(e.selector);if(t)return t}catch{}return e.elementId?document.getElementById(e.elementId.replace(/^#/,"")):null}waitForRouteReady(e,t,r=6e3,s=100){return new Promise(i=>{const o=Date.now()+r,a=!!(t.elementId||t.selector),l=()=>{const c=this.isCurrentRoute(e),u=a?!!this.findDomTarget(t):!0;if(c&&u){i(!0);return}if(Date.now()>=o){i(c);return}window.setTimeout(l,s)};window.setTimeout(l,80)})}dispatchAgentNavigate(e,t){Zt(e,{presetId:t.presetId,toolName:t.toolName});const r={url:e,path:e,handled:!1,initiated_by:"agent",preset_id:t.presetId};return window.dispatchEvent(new CustomEvent("vanira:navigate",{detail:r,cancelable:!0})),r}async withElementRoute(e,t,r,s,i){if(!e){s({navigated:!1});return}if(this.isCurrentRoute(e)){s({navigated:!1,route:e});return}const o=this.resolveNavigateTarget(e);if("external"in o){r("Element route must be a same-origin path");return}const a=o.internal;if(!this.dispatchAgentNavigate(a,{presetId:i,toolName:"element_route"}).handled){window.location.assign(a);return}if(!await this.waitForRouteReady(a,t)){r(`Timed out navigating to ${a} for element action`);return}s({navigated:!0,route:a})}resolveNavigateTarget(e){const t=e.trim()||"/";if(t.startsWith("http://")||t.startsWith("https://"))try{const r=new URL(t);return r.origin===window.location.origin?{internal:`${r.pathname}${r.search}${r.hash}`||"/"}:{external:t}}catch{return{internal:t}}return{internal:t}}renderNavigate(e,t,r){var c,u;const s=String(((c=e.clientFields)==null?void 0:c.target_url)||((u=e.args)==null?void 0:u.target_url)||"/"),i=e.toolCallId;if(i&&this.settledNavigateToolCallIds.has(i))return;this.activeNavigate={ctx:e,onComplete:t,onCancel:r,targetUrl:s};const o=this.resolveNavigateTarget(s);if("external"in o){window.open(o.external,"_blank","noopener,noreferrer"),this.completeNavigate({navigation_type:"external"});return}const a=o.internal;if(!this.dispatchAgentNavigate(a,{presetId:m.Navigate,toolName:"vanira_navigate"}).handled){this.cancelNavigate("No SPA listener handled vanira:navigate","cancelled");return}this.completeNavigate({path:a,navigation_type:"internal"})}renderHighlight(e,t,r){const s=e.args||{},i=e.clientFields||{},o=String(s.css_selector||i.css_selector||s.selector||i.selector||""),a=String(s.highlight_color||i.highlight_color||s.color||i.color||"#a855f7"),l=Number(s.duration_ms||i.duration_ms||3e3);if(!o){r("No css_selector provided for highlight");return}const c=document.querySelector(o);if(!c){r(`Element not found for selector: "${o}"`);return}const u=c.style.outline,d=c.style.outlineOffset,p=c.style.boxShadow,h=c.style.transition,f=c.style.scrollMarginTop;c.style.transition="outline 0.2s ease, box-shadow 0.2s ease",c.style.outline=`3px solid ${a}`,c.style.outlineOffset="6px",c.style.boxShadow=`0 0 0 8px ${a}33, 0 0 32px ${a}88`,c.style.scrollMarginTop="100px",c.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{c.style.outline=u,c.style.outlineOffset=d,c.style.boxShadow=p,c.style.transition=h,c.style.scrollMarginTop=f},l),t({status:"success",preset_id:m.HighlightElement,message:`Element highlighted: ${o}`})}renderScreenInk(e,t,r){const s=e.args||{},i=e.clientFields||{},o=fe(),a=s.interactive===!0||s.user_draw===!0||i.interactive===!0||String(s.interactive??i.interactive??"").toLowerCase()==="true";(async()=>{const l=await o.applyInkFromArgs(s,i),c=l.strokes+l.labels;if(c===0&&!a){r("No valid strokes or labels (provide strokes[], labels[], or points)");return}const u=[];l.strokes>0&&u.push(`${l.strokes} stroke(s)`),l.labels>0&&u.push(`${l.labels} label(s)`),t({status:"success",preset_id:m.ScreenInk,message:a?`Drew ${u.join(" and ")}; user can freehand draw until cleared`:`Drew ${u.join(" and ")}`,stroke_count:l.strokes,label_count:l.labels,annotation_count:c,interactive:a||void 0})})()}renderScreenCursor(e,t,r){const s=e.args||{},i=e.clientFields||{},o=String(s.color||i.color||"#f97316"),a=String(s.label||i.label||""),l=Number(s.duration_ms??i.duration_ms??2500),u=fe().showCursor({x:s.x??i.x,y:s.y??i.y,css_selector:String(s.css_selector||i.css_selector||s.selector||i.selector||"")||void 0,label:a||void 0,color:o,duration_ms:l});if(!u){r("No valid position for screen cursor (provide x/y or css_selector)");return}t({status:"success",preset_id:m.ScreenCursor,message:"Screen cursor shown",x:u.px,y:u.py})}renderScreenClick(e,t,r){const s=e.args||{},i=e.clientFields||{},o=String(s.color||i.color||"#f97316"),a=s.show_ripple??i.show_ripple??!0,l=s.show_cursor??i.show_cursor??!0,c=s.perform_click??i.perform_click??!0,u=String(s.css_selector||i.css_selector||s.selector||i.selector||"").trim();let d,p;if(u){const v=document.querySelector(u);if(!v){r(`Element not found for selector: "${u}"`);return}const g=v.getBoundingClientRect();d=g.left+g.width/2,p=g.top+g.height/2}else{const v=s.x??i.x,g=s.y??i.y;if(v==null||g==null){r("No valid position for screen click (provide x/y or css_selector)");return}const b=window.innerWidth,S=window.innerHeight,w=Number(v),x=Number(g);d=w>=0&&w<=1?w*b:w,p=x>=0&&x<=1?x*S:x}const h=fe();l&&h.showCursor({x:d,y:p,color:o,duration_ms:800}),a&&h.showClickRipple(d,p,o);let f="",y="";if(c){const v=Ln(d,p);v&&(Pn(v),f=v.tagName.toLowerCase(),y=v.id||"")}t({status:"success",preset_id:m.ScreenClick,message:c&&f?`Clicked ${f}${y?`#${y}`:""} at (${Math.round(d)}, ${Math.round(p)})`:`Click ripple at (${Math.round(d)}, ${Math.round(p)})`,x:d,y:p,clicked_tag:f||void 0,clicked_id:y||void 0})}renderClickElement(e,t,r){const s=e.args||{},i=e.clientFields||{},o=String(s.element_id||i.element_id||s.id||i.id||"").trim().replace(/^#/,""),a=s.scroll_before_click??i.scroll_before_click??!0,l=this.extractElementRoute(e);if(!o){r("No element_id provided for click");return}this.withElementRoute(l,{elementId:o},r,c=>{this.executeClickElement(o,a,c,t,r)},m.ClickElement)}executeClickElement(e,t,r,s,i){const o=document.getElementById(e);if(!o){i(`Element not found for id: "${e}"`);return}if(!this.isElementClickable(o)){i(`Element matched but is not clickable: "#${e}"`);return}t!==!1&&t!=="false"&&o.scrollIntoView({behavior:"smooth",block:"center"}),o.classList.add("vnr-click-pulse"),window.setTimeout(()=>o.classList.remove("vnr-click-pulse"),450),this.programmaticClick(o),s({status:"success",preset_id:m.ClickElement,element_id:e,...r.route?{route:r.route}:{},...r.navigated?{navigated_to_route:r.route}:{},message:`Clicked element: #${e}`,tag_name:o.tagName.toLowerCase(),element_text:(o.textContent||"").trim().slice(0,120)})}renderSelectOption(e,t,r){const s=e.args||{},i=e.clientFields||{},o=String(s.element_id||i.element_id||s.id||i.id||"").trim().replace(/^#/,""),a=this.extractElementRoute(e),l=String(s.option_value||i.option_value||"").trim(),c=String(s.option_label||i.option_label||s.option_text||i.option_text||"").trim();if(!o){r("No element_id provided for select");return}if(!l&&!c){r("Provide option_value or option_label");return}this.withElementRoute(a,{elementId:o},r,u=>{this.executeSelectOption(o,l,c,u,t,r)},m.SelectOption)}async executeSelectOption(e,t,r,s,i,o){var u,d,p,h;const a=document.getElementById(e);if(!a){o(`Element not found for id: "${e}"`);return}a.scrollIntoView({behavior:"smooth",block:"center"});let l="",c="";if(a instanceof HTMLSelectElement){if(!this.setNativeSelectValue(a,t,r)){o(`No matching option in #${e}`);return}l=a.value,c=((d=(u=a.options[a.selectedIndex])==null?void 0:u.text)==null?void 0:d.trim())||l}else{const f=a.querySelector("select");if(f instanceof HTMLSelectElement){if(!this.setNativeSelectValue(f,t,r)){o(`No matching option in #${e} select`);return}l=f.value,c=((h=(p=f.options[f.selectedIndex])==null?void 0:p.text)==null?void 0:h.trim())||l}else{if(!await this.selectCustomDropdownOption(a,t,r)){o(`Could not select option in #${e}`);return}l=t||r,c=r||t}}i({status:"success",preset_id:m.SelectOption,element_id:e,option_value:l||t,option_label:c||r,...s.route?{route:s.route}:{},...s.navigated?{navigated_to_route:s.route}:{},message:`Selected option in #${e}`})}setNativeSelectValue(e,t,r){const s=t.trim();if(s&&this.applyNativeSelectMatch(e,s,{matchValue:!0,matchLabel:!0}))return!0;const i=r.trim();return!!(i&&this.applyNativeSelectMatch(e,i,{matchValue:!0,matchLabel:!0}))}applyNativeSelectMatch(e,t,r){const s=t.trim();if(!s)return!1;const i=s.toLowerCase();for(const o of Array.from(e.options))if(r.matchValue&&o.value===s)return e.value=o.value,this.dispatchInputChange(e),!0;if(r.matchLabel)for(const o of Array.from(e.options)){const a=o.text.trim().toLowerCase();if(a===i||a.includes(i))return e.value=o.value,this.dispatchInputChange(e),!0}return!1}async selectCustomDropdownOption(e,t,r){this.programmaticClick(e),await new Promise(o=>window.setTimeout(o,200));const s=(r||t||"").trim().toLowerCase(),i=Array.from(document.querySelectorAll('[role="option"], [role="menuitem"], [role="menuitemradio"], li, button, a, div'));for(const o of i){if(!o.offsetParent&&o!==document.activeElement)continue;const a=(o.textContent||"").trim().toLowerCase(),l=o.getAttribute("data-value")||o.getAttribute("value")||"";if(t&&l===t)return this.programmaticClick(o),!0;if(s&&a&&(a===s||a.includes(s)))return this.programmaticClick(o),!0}return!1}renderSetDate(e,t,r){const s=e.args||{},i=e.clientFields||{},o=String(s.element_id||i.element_id||s.id||i.id||"").trim().replace(/^#/,""),a=this.extractElementRoute(e),l=String(s.date||i.date||"").trim(),c=String(s.input_kind||i.input_kind||"text").trim().toLowerCase(),u=String(s.text_format||i.text_format||"YYYY-MM-DD").trim();if(!o){r("No element_id provided for set date");return}if(!this.parseIsoDate(l)){r("date must be ISO YYYY-MM-DD");return}this.withElementRoute(a,{elementId:o},r,d=>{this.executeSetDate(o,l,c,u,d,t,r)},m.SetDate)}executeSetDate(e,t,r,s,i,o,a){const l=document.getElementById(e);if(!l){a(`Element not found for id: "${e}"`);return}if(!(l instanceof HTMLInputElement)&&!(l instanceof HTMLTextAreaElement)){a(`Element #${e} is not an input or textarea`);return}l.scrollIntoView({behavior:"smooth",block:"center"}),l.focus({preventScroll:!0});const c=r==="native_date"||l.type==="date",u=c?t:this.formatIsoDate(t,s);this.setNativeInputValue(l,u),o({status:"success",preset_id:m.SetDate,element_id:e,date:t,formatted_value:u,input_kind:c?"native_date":"text",text_format:c?"YYYY-MM-DD":s,...i.route?{route:i.route}:{},...i.navigated?{navigated_to_route:i.route}:{},message:`Set date on #${e}`})}parseIsoDate(e){const t=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;const r=parseInt(t[1],10),s=parseInt(t[2],10),i=parseInt(t[3],10);return s<1||s>12||i<1||i>31?null:{y:t[1],mo:t[2],d:t[3],year:r,month:s,day:i}}formatIsoDate(e,t){const r=this.parseIsoDate(e);if(!r)return e;const{y:s,mo:i,d:o,month:a,day:l}=r,c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];switch(t){case"DD/MM/YYYY":return`${o}/${i}/${s}`;case"MM/DD/YYYY":return`${i}/${o}/${s}`;case"DD-MM-YYYY":return`${o}-${i}-${s}`;case"D MMM YYYY":return`${l} ${c[a-1]} ${s}`;case"YYYY-MM-DD":default:return e}}setNativeInputValue(e,t){var i;const r=e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,s=(i=Object.getOwnPropertyDescriptor(r,"value"))==null?void 0:i.set;s?s.call(e,t):e.value=t,this.dispatchInputChange(e)}dispatchInputChange(e){e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}isElementClickable(e){if(e.hasAttribute("disabled")||"disabled"in e&&e.disabled)return!1;const t=window.getComputedStyle(e);return!(t.display==="none"||t.visibility==="hidden"||t.pointerEvents==="none")}programmaticClick(e){try{e.focus({preventScroll:!0})}catch{}const t=e.tagName.toLowerCase(),r=t==="input"?e.type.toLowerCase():"";if((t==="button"||t==="a"||["submit","button","checkbox","radio","reset"].includes(r))&&typeof e.click=="function"){e.click();return}const i={bubbles:!0,cancelable:!0,view:window,button:0,buttons:1};e.dispatchEvent(new MouseEvent("mousedown",i)),e.dispatchEvent(new MouseEvent("mouseup",i)),e.dispatchEvent(new MouseEvent("click",i))}applyBoardSizeToModal(e){const t=As[this.boardSizePreset],r=this.boardViewMode==="reduced"?.5:1,s=Vt(t.maxWidth,r),i=Vt(t.height,r);e.style.setProperty("width",s,"important"),e.style.setProperty("max-width",s,"important"),e.style.setProperty("height",i,"important"),e.style.setProperty("max-height",i,"important"),e.classList.toggle("is-reduced",r<1),this.boardViewMode==="reduced"&&this.syncBoardDragLayout(e)}syncBoardResizeButton(e){if(!e)return;const t=this.boardViewMode==="reduced";e.innerHTML=t?ks:Cs,e.setAttribute("aria-label",t?"Restore board size":"Shrink board to half size"),e.title=t?"Restore board size":"Shrink board to half size"}toggleBoardReduced(e){const t=this.boardViewMode==="reduced";this.boardViewMode=t?"expanded":"reduced",t||(this.boardDragPosition=null),this.applyBoardSizeToModal(e),this.applyBoardLayoutMode(this.getBoardOverlay(),e)}wireChalkboardChrome(e,t){let r=e.querySelector(".vnr-whiteboard-header");if(r){const s=r.querySelector(".vnr-whiteboard-resize-btn");s&&(s.onclick=()=>this.toggleBoardReduced(e));const i=r.querySelector(".vnr-whiteboard-close-btn");i&&(i.onclick=()=>{if(this.activePresetGeneration++,t)try{t()}catch{}this.closeBoardUi()})}else{r=document.createElement("div"),r.className="vnr-whiteboard-header";const s=document.createElement("button");s.type="button",s.className="vnr-whiteboard-action-btn vnr-whiteboard-resize-btn",s.onclick=()=>this.toggleBoardReduced(e);const i=document.createElement("button");i.type="button",i.className="vnr-whiteboard-action-btn is-close vnr-whiteboard-close-btn",i.innerHTML=Es,i.setAttribute("aria-label","Close board"),i.title="Close board",i.onclick=()=>{if(this.activePresetGeneration++,t)try{t()}catch{}this.closeBoardUi()},r.appendChild(s),r.appendChild(i);const o=e.querySelector(".vnr-whiteboard-canvas-wrap");o?e.insertBefore(r,o):e.prepend(r)}this.applyBoardSizeToModal(e),this.applyBoardLayoutMode(this.getBoardOverlay(),e),r&&this.wireBoardDrag(r,e)}wireChalkboardCloseButton(e,t){this.wireChalkboardChrome(e,t)}styleChalkboardTextarea(e){e.style.width="100%",e.style.height="100%",e.style.flex="1",e.style.position="relative",e.style.zIndex="1",e.style.background="transparent",e.style.border="none",e.style.padding="20px 28px 24px",e.style.fontSize="22px",e.style.lineHeight="1.55",e.style.fontFamily="'Architects Daughter', 'Caveat', 'Chalkboard SE', 'Chalkboard', cursive, sans-serif",e.style.color="#ffffff",e.style.textShadow="0 0 3px rgba(255, 255, 255, 0.45), 0 0 8px rgba(255, 255, 255, 0.15)",e.style.outline="none",e.style.resize="none",e.style.boxSizing="border-box"}applySplitBoardLayout(e,t){let r=e.querySelector(".vnr-whiteboard-draw-zone");if(r)return r;j("Board","Applying split layout — diagram top, notes below");const s=e.querySelector(".vnr-whiteboard-draw-layer");r=document.createElement("div"),r.className="vnr-whiteboard-draw-zone",r.style.flex="0 0 42%",r.style.minHeight="0",r.style.position="relative",r.style.width="100%",r.style.borderBottom="1px solid rgba(255,255,255,0.1)",r.style.background="#08080a";const i=document.createElement("div");for(i.className="vnr-whiteboard-text-zone",i.style.flex="1",i.style.minHeight="0",i.style.display="flex",i.style.flexDirection="column",i.style.position="relative",i.style.background="#0a0a0c",i.style.overflow="hidden";e.firstChild;)e.removeChild(e.firstChild);return e.appendChild(r),e.appendChild(i),i.appendChild(t),s?r.appendChild(s):X(r),this.styleChalkboardTextarea(t),this.syncBoardLayout(e),r}syncBoardLayout(e){const t=e.querySelector(".vnr-whiteboard-draw-zone");if(!t)return;const r=this.boardInk.strokes.length>0||this.boardInk.labels.length>0||this.boardDrawInProgress;t.style.display=r?"":"none",t.style.flex=r?"0 0 42%":"0 0 0",t.style.minHeight=r?"200px":"0",this.syncBoardChapterTitle(t),j("Board:Layout",r?"diagram top + notes below":"notes full board",{strokes:this.boardInk.strokes.length,labels:this.boardInk.labels.length})}syncBoardChapterTitle(e){const t=e??document.querySelector(".vnr-whiteboard-draw-zone");if(!t)return;let r=t.querySelector(".vnr-board-chapter-title");if(!this.boardChapterTitle){r==null||r.remove();return}r||(r=document.createElement("div"),r.className="vnr-board-chapter-title",r.style.cssText=["position:absolute","top:10px","left:12px","right:12px","z-index:3","pointer-events:none","text-align:center","color:#4A9EFF",'font-family:"Architects Daughter","Caveat",cursive,sans-serif',"font-size:22px","line-height:1.3","text-shadow:none"].join(";"),t.appendChild(r)),r.textContent=this.boardChapterTitle}getBoardDrawZone(e){const t=this.upgradeChalkboardCanvas(e),r=this.applySplitBoardLayout(t,e);return this.syncBoardLayout(t),r}upgradeChalkboardCanvas(e){let t=e.closest(".vnr-whiteboard-canvas-wrap");if(t)return t;j("Board","Upgrading legacy chalkboard — adding draw layer");const r=e.parentElement;if(!r)return e;t=document.createElement("div"),t.className="vnr-whiteboard-canvas-wrap",t.style.display="flex",t.style.flexDirection="column",t.style.flex="1",t.style.height="100%",t.style.position="relative",r.insertBefore(t,e),t.appendChild(e),e.style.position="relative",e.style.zIndex="1",e.style.background="transparent",this.applySplitBoardLayout(t,e);const s=t.querySelector(".vnr-whiteboard-draw-zone");return(this.boardInk.strokes.length>0||this.boardInk.labels.length>0)&&this.syncDiagramLayer(X(s)),t}ensureChalkboardTextarea(e){let t=document.querySelector(".vnr-whiteboard-textarea");if(t){this.syncChalkboardNotes();const o=this.upgradeChalkboardCanvas(t);this.applySplitBoardLayout(o,t);const a=o.querySelector(".vnr-whiteboard-draw-zone"),l=X(a);l.childElementCount<=1&&(this.boardInk.strokes.length>0||this.boardInk.labels.length>0)&&this.syncDiagramLayer(l);const c=t.closest(".vnr-whiteboard-modal");return c&&(this.wireChalkboardChrome(c,e),this.revealBoardUi(c)),this.syncBoardLayout(o),t}if(!document.getElementById("vnr-chalk-font")){const o=document.createElement("link");o.id="vnr-chalk-font",o.rel="stylesheet",o.href="https://fonts.googleapis.com/css2?family=Architects+Daughter&family=Caveat:wght@400;700&display=swap",document.head.appendChild(o)}const r=this.createOverlay();r.classList.add("vnr-whiteboard-overlay","vnr-whiteboard-overlay-expanded");const s=document.createElement("div");s.className="vnr-modal vnr-whiteboard-modal",s.style.position="relative",s.style.display="flex",s.style.flexDirection="column",s.style.background="#0d0e12",s.style.border="12px solid #5c4033",s.style.borderRadius="16px",s.style.boxShadow="0 25px 60px rgba(0,0,0,0.65), inset 0 0 30px rgba(0,0,0,0.95)",s.style.padding="0",s.style.overflow="hidden",this.applyBoardSizeToModal(s);const i=document.createElement("div");if(i.className="vnr-whiteboard-canvas-wrap",i.style.display="flex",i.style.flexDirection="column",i.style.flex="1",i.style.minHeight="0",i.style.height="auto",i.style.position="relative",t=document.createElement("textarea"),t.className="vnr-whiteboard-textarea",t.placeholder="Notes appear here…",t.value=this.chalkboardContent,t.addEventListener("input",()=>{this.chalkboardContent=t.value}),i.appendChild(t),this.applySplitBoardLayout(i,t),this.syncBoardLayout(i),this.boardInk.strokes.length>0||this.boardInk.labels.length>0){const o=i.querySelector(".vnr-whiteboard-draw-zone");this.syncDiagramLayer(X(o))}return s.appendChild(i),r.appendChild(s),this.wireChalkboardChrome(s,e),t}eraseChalkboardInMemory(e,t){return e==="words"?this.eraseLastWords(this.chalkboardContent,t):(this.boardChapterTitle="","")}renderEraseDrawingBoard(e,t,r){this.syncChalkboardNotes();const s=this.boardInk.strokes.length,i=this.boardInk.labels.length,o=s>0||i>0,a=document.querySelector(".vnr-whiteboard-textarea");if(a){const l=this.getBoardDrawZone(a),c=X(l);ke(c);const u=a.closest(".vnr-whiteboard-canvas-wrap");u&&this.syncBoardLayout(u)}else if(o){this.ensureChalkboardTextarea(()=>r("User dismissed chalkboard"));const l=document.querySelector(".vnr-whiteboard-textarea");if(l){const c=this.getBoardDrawZone(l);ke(X(c));const u=l.closest(".vnr-whiteboard-canvas-wrap");u&&this.syncBoardLayout(u)}}this.boardInk=we(),this.boardDrawInProgress=!1,this.boardChapterTitle="",j("Board:EraseDraw","Cleared diagram panel (notes kept)",{strokesCleared:s,labelsCleared:i}),t({status:"success",preset_id:m.EraseDraw,message:o?`Cleared ${s} stroke(s) and ${i} label(s) from the diagram panel. Written notes were kept.`:"Diagram panel was already empty. Written notes were not changed.",strokes_cleared:s,labels_cleared:i,shapes_cleared:s+i,diagram_cleared:!0,notes_preserved:!0,whiteboard_content:this.chalkboardContent,text_written:this.chalkboardContent,board_snapshot:this.getBoardSnapshot(),...this.buildBoardVerification()})}renderDrawShapes(e,t,r){const s={...e.clientFields||{},...e.args||{}};this.syncChalkboardNotes();const i=es(s,e.clientFields||{}),o=this.activePresetGeneration;if(j("Board:Draw","draw_on_board invoked",{toolCallId:e.toolCallId,strokes:i.strokes.length,labels:i.labels.length,clearBefore:i.clearBefore,animate:i.animate,shape_duration_ms:i.durationMs}),!i.clearBefore&&i.strokes.length===0&&i.labels.length===0){hr("Board:Draw","No strokes or labels",s),t({status:"error",preset_id:m.Draw,message:"Provide strokes[] or labels[] (same as vanira_screen_ink), or flat points/path_d/label_text+coords. Use clear_old_diagrams_on_board:true to wipe the diagram.",board_snapshot:this.getBoardSnapshot()});return}const a=this.ensureChalkboardTextarea(()=>r("User dismissed chalkboard"));if(!a){t({status:"error",message:"Could not open chalkboard"});return}this.syncChalkboardNotes();const l=this.getBoardDrawZone(a),c=X(l);if(i.clearBefore){ke(c),this.boardInk=we();const p=a.closest(".vnr-whiteboard-canvas-wrap");p&&this.syncBoardLayout(p),j("Board:Draw","Cleared old diagrams on board (notes kept)")}if(i.strokes.length===0&&i.labels.length===0){t({status:"success",preset_id:m.Draw,message:"Old diagrams cleared from board",strokes_drawn:0,labels_drawn:0,shapes_drawn:0,clear_old_diagrams_on_board:!0,clear_drawings:!0,board_snapshot:this.getBoardSnapshot(),...this.buildBoardVerification()});return}const u=(p,h,f={})=>{this.boardDrawInProgress=!1;const y=o!==this.activePresetGeneration,v=a.closest(".vnr-whiteboard-canvas-wrap");v&&this.syncBoardLayout(v);const g={status:y?"cancelled":"success",preset_id:m.Draw,message:y?`Draw interrupted (${p} stroke(s), ${h} label(s) on board)`:`Drew ${p} stroke(s) and ${h} label(s) on chalkboard`,strokes_drawn:p,labels_drawn:h,shapes_drawn:p+h,shape_duration_ms:i.durationMs,clear_old_diagrams_on_board:i.clearBefore,clear_drawings:i.clearBefore,whiteboard_content:this.chalkboardContent,text_written:this.chalkboardContent,board_snapshot:this.getBoardSnapshot(),...this.buildBoardVerification(),...f};j("Board:Draw","finished",g),t(g)};this.boardDrawInProgress=!0;const d=a.closest(".vnr-whiteboard-canvas-wrap");if(d&&this.syncBoardLayout(d),!i.animate||i.durationMs<=0){this.boardInk.strokes.push(...i.strokes),this.boardInk.labels.push(...i.labels),this.syncDiagramLayer(c),u(i.strokes.length,i.labels.length);return}(this.boardInk.strokes.length>0||this.boardInk.labels.length>0)&&Ut(c,this.boardInk,{strokeColor:i.strokeColor,labelColor:i.labelColor,strokeWidth:i.strokeWidth}),is(c,i.strokes,i.labels,{strokeColor:i.strokeColor,labelColor:i.labelColor,strokeWidth:i.strokeWidth,animate:!0,durationMs:i.durationMs,gapMs:i.gapMs,isAborted:()=>o!==this.activePresetGeneration}).then(({strokesDrawn:p,labelsDrawn:h})=>{this.boardInk.strokes.push(...i.strokes),this.boardInk.labels.push(...i.labels);const f={};(p<i.strokes.length||h<i.labels.length)&&(f.flushed_remaining=!0),u(p,h,f)})}renderTypeText(e,t,r){const s=e.args||{},i=e.clientFields||{},o=String(s.element_id||i.element_id||s.css_selector||i.css_selector||s.selector||i.selector||"").trim(),a=o?this.extractElementRoute(e):"",l=c=>{this.executeTypeText(e,t,r,o,c)};if(!a){l({navigated:!1});return}this.withElementRoute(a,this.parseDomTarget(o),r,l,m.TypeText)}executeTypeText(e,t,r,s,i){const o=e.args||{},a=e.clientFields||{};let l=String(o.text_to_type||a.text_to_type||o.text||a.text||o.value||a.value||o.search_query||a.search_query||o.query||a.query||"");const{chapterTitle:c,body:u}=this.splitChapterHeading(l),d=Number(o.delay_ms!==void 0?o.delay_ms:a.delay_ms!==void 0?a.delay_ms:50),p=this.resolveTypingMode(e),h=k=>{const E={...k,...i.route?{route:i.route}:{},...i.navigated?{navigated_to_route:i.route}:{}};if(document.querySelector(".vnr-whiteboard-modal")){E.board_snapshot=this.getBoardSnapshot();const I=document.querySelector(".vnr-whiteboard-canvas-wrap");I&&this.syncBoardLayout(I)}t(E)};let f=null;s&&!c&&(f=this.findDomTarget(this.parseDomTarget(s)));const y=()=>{j("Board:Type","Using chalkboard fallback",{toolCallId:e.toolCallId,textPreview:(u||l).slice(0,80),sessionChars:this.chalkboardContent.length});const k=this.ensureChalkboardTextarea(()=>r("User dismissed typing popup"));if(!k){h({status:"error",message:"Could not open chalkboard"});return}k.focus(),c&&(this.boardChapterTitle=c);const E=c&&!u?l.trim().split(`
|
|
487
|
-
`)[
|
|
488
|
-
|
|
489
|
-
`),l=Math.max(o,a);if(l===-1){s="";break}else s=s.slice(0,l).trimEnd()}return s}}function jt(n){const e=(n==null?void 0:n.data)||n;return String((e==null?void 0:e.tool_call_id)||(e==null?void 0:e.call_id)||"")}const Ms=z.forwardRef(function({client:e,toolCall:t=null,onCustomTool:r},s){const i=z.useRef(null),o=z.useRef(new Set),a=z.useRef(new Set),l=z.useRef([]),c=z.useRef(!1);z.useEffect(()=>(i.current=new Ps(null),()=>{var h;(h=i.current)==null||h.resetBoardSession()}),[]),z.useEffect(()=>{const h=f=>{var v;const y=f.detail||{};(v=i.current)==null||v.abortBoardTools(y.reason||"Server interrupted",y.toolCallId)};return window.addEventListener(Ot,h),()=>window.removeEventListener(Ot,h)},[]);const u=z.useCallback(()=>{if(c.current||!i.current||!e)return;const h=l.current.shift();if(!h)return;c.current=!0;const f=h.data||h,y=f.arguments||f.args,v=f.client_fields||{},g=ct(v,y,f.name||f.tool_name),b=jt(h),S=()=>{c.current=!1,l.current.length>0&&u()};if(!g||!Y(g)){r&&r(h),S();return}!$r(g)&&e.sendContextUpdate&&b&&(e.sendToolResult(b,{status:"popup_shown",message:`The UI preset ${g} is now visible. I am waiting for the user to complete it. STAY SILENT.`}),e.sendContextUpdate({ui_state:"waiting_for_preset_data",tool_status:"active_waiting",visible_preset:g})),i.current.handle(h,x=>{var k,E;if(!b){S();return}const C=typeof x=="string"?{response:x}:x;if(Qe(g)){S();return}if(gt(g)){(C==null?void 0:C.status)!=="cancelled"&&!o.current.has(b)&&(o.current.add(b),e.sendToolResult(b,C)),S();return}if(Ke(g)){if((C==null?void 0:C.status)==="cancelled"){S();return}(k=e.triggerActionInterrupt)==null||k.call(e);const I=yt(g,f.name||f.tool_name||"",v);(E=e.sendActionTrigger)==null||E.call(e,I,C),S();return}e.triggerActionInterrupt&&e.triggerActionInterrupt(),e.sendActionTrigger?e.sendActionTrigger(yt(g,f.name||f.tool_name||"",v),C):e.sendToolResult(b,C),S()},(x,C)=>{var k,E;if(!b){S();return}if(gt(g)){const I=(C==null?void 0:C.status)??"cancelled",L=String(v.target_url||(typeof y=="object"&&y?y.target_url:"")||"");o.current.has(b)||(o.current.add(b),e.sendToolResult(b,g===m.Navigate?((k=i.current)==null?void 0:k.getNavigateTerminalResult(I,x,L||void 0))??{status:I,reason:x||"Navigation cancelled",preset_id:g,target_url:L||void 0}:((E=i.current)==null?void 0:E.getBoardTerminalResult(I,x,g))??{status:I,reason:x||"User dismissed",preset_id:g})),S();return}if(Qe(g))try{e.sendToolResult(b,{status:"cancelled",reason:x||"User dismissed",preset_id:g})}catch{}else if(Ke(g))if(typeof e.sendToolError=="function")e.sendToolError(b,x||"User cancelled the action");else try{e.sendToolResult(b,{status:"cancelled",reason:x||"User dismissed",preset_id:g})}catch{}else typeof e.sendToolError=="function"&&e.sendToolError(b,x||"User cancelled the action");S()},e)||(r&&r(h),S())},[e,r]),d=z.useCallback(h=>{const f=jt(h);if(f){if(a.current.has(f))return;a.current.add(f)}l.current.push(h),u()},[u]),p=z.useCallback(()=>{var h,f;l.current=[],c.current=!1,a.current.clear(),o.current.clear(),(h=i.current)!=null&&h.hasActiveBoardSession()||((f=i.current)==null||f.dismiss(),De())},[]);return z.useImperativeHandle(s,()=>({enqueueToolCall:d,clearQueue:p}),[d,p]),z.useEffect(()=>{t&&d(t)},[t,d]),z.useEffect(()=>{e||p()},[e,p]),null});class Ns{constructor(e){_(this,"el");this.el=new Audio,this.el.srcObject=e,this.el.play().catch(t=>{})}pause(){}cleanup(){this.el.pause(),this.el.srcObject=null}onEnded(e){this.el.onended=e}}class Ds{createRemotePlayer(e){return new Ns(e)}}class Bs{async getUserAudio(e){return navigator.mediaDevices.getUserMedia({audio:e})}stopStream(e){e.getTracks().forEach(t=>t.stop())}}class $s{create(e){return new RTCPeerConnection({iceServers:e.iceServers,iceTransportPolicy:e.iceTransportPolicy??"all"})}}class Rs{bind(e,t){return e.onopen=()=>t.onOpen(),e.onerror=r=>t.onError(r),e.onmessage=r=>{if(typeof r.data=="string"){t.onMessage({text:r.data});return}if(r.data instanceof ArrayBuffer){try{const s=new TextDecoder().decode(r.data),i=JSON.parse(s);Kt(i)&&t.onMessage({text:s})}catch{}return}r.data instanceof Blob&&r.data.text().then(s=>{t.onMessage({text:s})}).catch(s=>{})},{send(r){e.readyState==="open"&&e.send(r)},isOpen(){return e.readyState==="open"},close(){e.close()}}}}var Wt;const Cr={supportsAudioEndedEvent:!0,supportsScreenShare:typeof navigator<"u"&&typeof((Wt=navigator.mediaDevices)==null?void 0:Wt.getDisplayMedia)=="function",supportsDom:typeof document<"u",supportsHtmlAudio:typeof Audio<"u",supportsCustomElements:typeof customElements<"u",supportsLocalStorage:typeof localStorage<"u",supportsBroadcastChannel:typeof BroadcastChannel<"u"},kr={name:"browser",callType:"web",runtimeName:"browser",callIdPrefix:"web_",capabilities:Cr,audio:new Ds,media:new Bs,peer:new $s,dataChannel:new Rs};function Us(n){return new Me({...n,runtime:kr})}exports.PresetRenderer=Ms;exports.RouteContextTracker=Xt;exports.VaniraClient=Me;exports.browserCapabilities=Cr;exports.browserRuntime=kr;exports.createBrowserClient=Us;exports.getCurrentPageRoute=he;exports.hasContinueSession=qr;exports.loadContinueSession=Pe;exports.markAgentNavigation=Zt;exports.normalizePageRoute=dt;exports.saveCallSession=Qt;
|
|
880
|
+
`,v.querySelector("#vnr-remove-file").addEventListener("click",()=>{d=null,v.style.display="none",p.style.display="block",B.disabled=!0}),B.disabled=!1};p.addEventListener("click",()=>g.click()),p.addEventListener("dragover",b=>{b.preventDefault(),p.classList.add("drag")}),p.addEventListener("dragleave",()=>p.classList.remove("drag")),p.addEventListener("drop",b=>{var T;b.preventDefault(),p.classList.remove("drag");const C=(T=b.dataTransfer)==null?void 0:T.files[0];C&&E(C)}),g.addEventListener("change",()=>{var C;const b=(C=g.files)==null?void 0:C[0];b&&E(b)}),B.addEventListener("click",async()=>{if(!d)return;const b=d;p.style.display="none",v.style.display="none",w.style.display="block",w.innerHTML='<div class="vnr-center"><div class="vnr-spinner" style="margin:0 auto 8px"></div>Uploading…</div>',B.disabled=!0;try{if(i&&typeof i.uploadMedia=="function"){const{media_id:C,url:T}=await i.uploadMedia(b,c,`User uploaded: ${b.name}`);w.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ File sent!</div>',setTimeout(()=>{this.dismiss(),s({file_name:b.name,file_type:b.type,file_size:b.size,media_id:C,url:T,message:`User uploaded: ${b.name}`})},400)}else{const C=new FileReader;C.onload=T=>{w.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ File ready!</div>',setTimeout(()=>{this.dismiss(),s({file_name:b.name,file_type:b.type,file_size:b.size,data_url:T.target.result,message:`User uploaded: ${b.name}`})},400)},C.readAsDataURL(b)}}catch(C){w.innerHTML=`<div class="vnr-center" style="color:#ef4444">${(C==null?void 0:C.message)||"Upload failed. Please try again."}</div>`,B.disabled=!1,this.dismiss(),this.clearActiveModalPreset(),n((C==null?void 0:C.message)||"Upload failed",{status:"cancelled"})}})}extractElementRoute(e){const t=e.args||{},n=e.clientFields||{};return String(t.route||n.route||t.target_route||n.target_route||"").trim()}normalizeRouteForCompare(e){const t=(e.trim()||"/").split("#")[0],n=t.startsWith("/")?t:`/${t}`;try{const i=new URL(n,window.location.origin);return`${i.pathname}${i.search}`||"/"}catch{return n||"/"}}isCurrentRoute(e){const t=this.normalizeRouteForCompare(e);return(`${window.location.pathname}${window.location.search}`||"/")===t}parseDomTarget(e){const t=e.trim();return t?/^[.#\[]/.test(t)||t.includes(" ")||t.includes(">")?{selector:t}:{elementId:t.replace(/^#/,"")}:{}}findDomTarget(e){if(e.selector)try{const t=document.querySelector(e.selector);if(t)return t}catch{}return e.elementId?document.getElementById(e.elementId.replace(/^#/,"")):null}waitForRouteReady(e,t,n=6e3,i=100){return new Promise(s=>{const a=Date.now()+n,A=!!(t.elementId||t.selector),o=()=>{const c=this.isCurrentRoute(e),l=A?!!this.findDomTarget(t):!0;if(c&&l){s(!0);return}if(Date.now()>=a){s(c);return}window.setTimeout(o,i)};window.setTimeout(o,80)})}dispatchAgentNavigate(e,t){Wp(e,{presetId:t.presetId,toolName:t.toolName});const n={url:e,path:e,handled:!1,initiated_by:"agent",preset_id:t.presetId};return window.dispatchEvent(new CustomEvent("vanira:navigate",{detail:n,cancelable:!0})),n}async withElementRoute(e,t,n,i,s){if(!e){i({navigated:!1});return}if(this.isCurrentRoute(e)){i({navigated:!1,route:e});return}const a=this.resolveNavigateTarget(e);if("external"in a){n("Element route must be a same-origin path");return}const A=a.internal;if(!this.dispatchAgentNavigate(A,{presetId:s,toolName:"element_route"}).handled){window.location.assign(A);return}if(!await this.waitForRouteReady(A,t)){n(`Timed out navigating to ${A} for element action`);return}i({navigated:!0,route:A})}resolveNavigateTarget(e){const t=e.trim()||"/";if(t.startsWith("http://")||t.startsWith("https://"))try{const n=new URL(t);return n.origin===window.location.origin?{internal:`${n.pathname}${n.search}${n.hash}`||"/"}:{external:t}}catch{return{internal:t}}return{internal:t}}renderNavigate(e,t,n){var c,l;const i=String(((c=e.clientFields)==null?void 0:c.target_url)||((l=e.args)==null?void 0:l.target_url)||"/"),s=e.toolCallId;if(s&&this.settledNavigateToolCallIds.has(s))return;this.activeNavigate={ctx:e,onComplete:t,onCancel:n,targetUrl:i};const a=this.resolveNavigateTarget(i);if("external"in a){window.open(a.external,"_blank","noopener,noreferrer"),this.completeNavigate({navigation_type:"external"});return}const A=a.internal;if(!this.dispatchAgentNavigate(A,{presetId:_.Navigate,toolName:"vanira_navigate"}).handled){this.cancelNavigate("No SPA listener handled vanira:navigate","cancelled");return}this.completeNavigate({path:A,navigation_type:"internal"})}renderHighlight(e,t,n){const i=e.args||{},s=e.clientFields||{};let a=String(i.css_selector||s.css_selector||i.selector||s.selector||"").trim();const A=String(i.label||s.label||"").trim(),o=String(i.element_id||s.element_id||"").trim(),c=String(i.highlight_color||s.highlight_color||i.color||s.color||"#a855f7"),l=Number(i.duration_ms||s.duration_ms||3e3);if(!a&&(A||o)){const w=Qr().getCaptureContext(),B=Kf({label:A||void 0,element_id:o||void 0,staleLayoutElements:w==null?void 0:w.layoutElements,captureCtx:w});B&&(a=B.css_selector)}if(!a){n("No css_selector, label, or element_id provided for highlight");return}const d=document.querySelector(a);if(!d){n(`Element not found for selector: "${a}"`);return}const u=d.style.outline,h=d.style.outlineOffset,p=d.style.boxShadow,g=d.style.transition,v=d.style.scrollMarginTop;d.style.transition="outline 0.2s ease, box-shadow 0.2s ease",d.style.outline=`3px solid ${c}`,d.style.outlineOffset="6px",d.style.boxShadow=`0 0 0 8px ${c}33, 0 0 32px ${c}88`,d.style.scrollMarginTop="100px",d.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{d.style.outline=u,d.style.outlineOffset=h,d.style.boxShadow=p,d.style.transition=g,d.style.scrollMarginTop=v},l),t({status:"success",preset_id:_.HighlightElement,message:`Element highlighted: ${a}`})}renderClickElement(e,t,n){const i=e.args||{},s=e.clientFields||{},a=String(i.element_id||s.element_id||i.id||s.id||"").trim().replace(/^#/,""),A=i.scroll_before_click??s.scroll_before_click??!0,o=this.extractElementRoute(e);if(!a){n("No element_id provided for click");return}this.withElementRoute(o,{elementId:a},n,c=>{this.executeClickElement(a,A,c,t,n)},_.ClickElement)}executeClickElement(e,t,n,i,s){const a=document.getElementById(e);if(!a){s(`Element not found for id: "${e}"`);return}if(!this.isElementClickable(a)){s(`Element matched but is not clickable: "#${e}"`);return}t!==!1&&t!=="false"&&a.scrollIntoView({behavior:"smooth",block:"center"}),a.classList.add("vnr-click-pulse"),window.setTimeout(()=>a.classList.remove("vnr-click-pulse"),450),this.programmaticClick(a),i({status:"success",preset_id:_.ClickElement,element_id:e,...n.route?{route:n.route}:{},...n.navigated?{navigated_to_route:n.route}:{},message:`Clicked element: #${e}`,tag_name:a.tagName.toLowerCase(),element_text:(a.textContent||"").trim().slice(0,120)})}renderSelectOption(e,t,n){const i=e.args||{},s=e.clientFields||{},a=String(i.element_id||s.element_id||i.id||s.id||"").trim().replace(/^#/,""),A=this.extractElementRoute(e),o=String(i.option_value||s.option_value||"").trim(),c=String(i.option_label||s.option_label||i.option_text||s.option_text||"").trim();if(!a){n("No element_id provided for select");return}if(!o&&!c){n("Provide option_value or option_label");return}this.withElementRoute(A,{elementId:a},n,l=>{this.executeSelectOption(a,o,c,l,t,n)},_.SelectOption)}async executeSelectOption(e,t,n,i,s,a){var l,d,u,h;const A=document.getElementById(e);if(!A){a(`Element not found for id: "${e}"`);return}A.scrollIntoView({behavior:"smooth",block:"center"});let o="",c="";if(A instanceof HTMLSelectElement){if(!this.setNativeSelectValue(A,t,n)){a(`No matching option in #${e}`);return}o=A.value,c=((d=(l=A.options[A.selectedIndex])==null?void 0:l.text)==null?void 0:d.trim())||o}else{const p=A.querySelector("select");if(p instanceof HTMLSelectElement){if(!this.setNativeSelectValue(p,t,n)){a(`No matching option in #${e} select`);return}o=p.value,c=((h=(u=p.options[p.selectedIndex])==null?void 0:u.text)==null?void 0:h.trim())||o}else{if(!await this.selectCustomDropdownOption(A,t,n)){a(`Could not select option in #${e}`);return}o=t||n,c=n||t}}s({status:"success",preset_id:_.SelectOption,element_id:e,option_value:o||t,option_label:c||n,...i.route?{route:i.route}:{},...i.navigated?{navigated_to_route:i.route}:{},message:`Selected option in #${e}`})}setNativeSelectValue(e,t,n){const i=t.trim();if(i&&this.applyNativeSelectMatch(e,i,{matchValue:!0,matchLabel:!0}))return!0;const s=n.trim();return!!(s&&this.applyNativeSelectMatch(e,s,{matchValue:!0,matchLabel:!0}))}applyNativeSelectMatch(e,t,n){const i=t.trim();if(!i)return!1;const s=i.toLowerCase();for(const a of Array.from(e.options))if(n.matchValue&&a.value===i)return e.value=a.value,this.dispatchInputChange(e),!0;if(n.matchLabel)for(const a of Array.from(e.options)){const A=a.text.trim().toLowerCase();if(A===s||A.includes(s))return e.value=a.value,this.dispatchInputChange(e),!0}return!1}async selectCustomDropdownOption(e,t,n){this.programmaticClick(e),await new Promise(a=>window.setTimeout(a,200));const i=(n||t||"").trim().toLowerCase(),s=Array.from(document.querySelectorAll('[role="option"], [role="menuitem"], [role="menuitemradio"], li, button, a, div'));for(const a of s){if(!a.offsetParent&&a!==document.activeElement)continue;const A=(a.textContent||"").trim().toLowerCase(),o=a.getAttribute("data-value")||a.getAttribute("value")||"";if(t&&o===t)return this.programmaticClick(a),!0;if(i&&A&&(A===i||A.includes(i)))return this.programmaticClick(a),!0}return!1}renderSetDate(e,t,n){const i=e.args||{},s=e.clientFields||{},a=String(i.element_id||s.element_id||i.id||s.id||"").trim().replace(/^#/,""),A=this.extractElementRoute(e),o=String(i.date||s.date||"").trim(),c=String(i.input_kind||s.input_kind||"text").trim().toLowerCase(),l=String(i.text_format||s.text_format||"YYYY-MM-DD").trim();if(!a){n("No element_id provided for set date");return}if(!this.parseIsoDate(o)){n("date must be ISO YYYY-MM-DD");return}this.withElementRoute(A,{elementId:a},n,d=>{this.executeSetDate(a,o,c,l,d,t,n)},_.SetDate)}executeSetDate(e,t,n,i,s,a,A){const o=document.getElementById(e);if(!o){A(`Element not found for id: "${e}"`);return}if(!(o instanceof HTMLInputElement)&&!(o instanceof HTMLTextAreaElement)){A(`Element #${e} is not an input or textarea`);return}o.scrollIntoView({behavior:"smooth",block:"center"}),o.focus({preventScroll:!0});const c=n==="native_date"||o.type==="date",l=c?t:this.formatIsoDate(t,i);this.setNativeInputValue(o,l),a({status:"success",preset_id:_.SetDate,element_id:e,date:t,formatted_value:l,input_kind:c?"native_date":"text",text_format:c?"YYYY-MM-DD":i,...s.route?{route:s.route}:{},...s.navigated?{navigated_to_route:s.route}:{},message:`Set date on #${e}`})}parseIsoDate(e){const t=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;const n=parseInt(t[1],10),i=parseInt(t[2],10),s=parseInt(t[3],10);return i<1||i>12||s<1||s>31?null:{y:t[1],mo:t[2],d:t[3],year:n,month:i,day:s}}formatIsoDate(e,t){const n=this.parseIsoDate(e);if(!n)return e;const{y:i,mo:s,d:a,month:A,day:o}=n,c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];switch(t){case"DD/MM/YYYY":return`${a}/${s}/${i}`;case"MM/DD/YYYY":return`${s}/${a}/${i}`;case"DD-MM-YYYY":return`${a}-${s}-${i}`;case"D MMM YYYY":return`${o} ${c[A-1]} ${i}`;case"YYYY-MM-DD":default:return e}}setNativeInputValue(e,t){var s;const n=e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,i=(s=Object.getOwnPropertyDescriptor(n,"value"))==null?void 0:s.set;i?i.call(e,t):e.value=t,this.dispatchInputChange(e)}dispatchInputChange(e){e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}isElementClickable(e){if(e.hasAttribute("disabled")||"disabled"in e&&e.disabled)return!1;const t=window.getComputedStyle(e);return!(t.display==="none"||t.visibility==="hidden"||t.pointerEvents==="none")}programmaticClick(e){try{e.focus({preventScroll:!0})}catch{}const t=e.tagName.toLowerCase(),n=t==="input"?e.type.toLowerCase():"";if((t==="button"||t==="a"||["submit","button","checkbox","radio","reset"].includes(n))&&typeof e.click=="function"){e.click();return}const s={bubbles:!0,cancelable:!0,view:window,button:0,buttons:1};e.dispatchEvent(new MouseEvent("mousedown",s)),e.dispatchEvent(new MouseEvent("mouseup",s)),e.dispatchEvent(new MouseEvent("click",s))}applyBoardSizeToModal(e){const t=VU[this.boardSizePreset],n=this.boardViewMode==="reduced"?.5:1,i=KU*n,s=Dp(t.maxWidth,i),a=Dp(t.height,i);e.style.setProperty("width",s,"important"),e.style.setProperty("max-width",s,"important"),e.style.setProperty("height",a,"important"),e.style.setProperty("max-height",a,"important"),e.classList.toggle("is-reduced",n<1),e.dataset.boardSize=this.boardSizePreset,this.boardViewMode==="reduced"&&this.syncBoardDragLayout(e),this.syncBoardGrowButton(e)}syncBoardGrowButton(e){const t=e.querySelector(".vnr-whiteboard-grow-btn");if(!t)return;const n=this.boardSizePreset===Is[Is.length-1];t.disabled=n,t.title=n?"Board is at maximum size":"Increase board size",t.setAttribute("aria-label",n?"Board is at maximum size":"Increase board size")}growBoardSize(e){const t=Is.indexOf(this.boardSizePreset);t<0||t>=Is.length-1||(this.boardSizePreset=Is[t+1],jU(this.boardSizePreset),this.applyBoardSizeToModal(e),this.applyBoardLayoutMode(this.getBoardOverlay(),e))}syncBoardResizeButton(e){if(!e)return;const t=this.boardViewMode==="reduced";e.innerHTML=t?HU:OU,e.setAttribute("aria-label",t?"Restore board size":"Shrink board to half size"),e.title=t?"Restore board size":"Shrink board to half size"}toggleBoardReduced(e){const t=this.boardViewMode==="reduced";this.boardViewMode=t?"expanded":"reduced",t||(this.boardDragPosition=null),this.applyBoardSizeToModal(e),this.applyBoardLayoutMode(this.getBoardOverlay(),e)}wireChalkboardChrome(e,t){let n=e.querySelector(".vnr-whiteboard-header");if(n){const i=n.querySelector(".vnr-whiteboard-resize-btn");i&&(i.onclick=()=>this.toggleBoardReduced(e));let s=n.querySelector(".vnr-whiteboard-grow-btn");if(!s){s=document.createElement("button"),s.type="button",s.className="vnr-whiteboard-action-btn vnr-whiteboard-grow-btn",s.innerHTML=Pp;const A=n.querySelector(".vnr-whiteboard-close-btn");A?n.insertBefore(s,A):n.appendChild(s)}s.onclick=()=>this.growBoardSize(e);const a=n.querySelector(".vnr-whiteboard-close-btn");a&&(a.onclick=()=>{if(this.activePresetGeneration++,t)try{t()}catch{}this.closeBoardUi()})}else{n=document.createElement("div"),n.className="vnr-whiteboard-header";const i=document.createElement("button");i.type="button",i.className="vnr-whiteboard-action-btn vnr-whiteboard-resize-btn",i.onclick=()=>this.toggleBoardReduced(e);const s=document.createElement("button");s.type="button",s.className="vnr-whiteboard-action-btn vnr-whiteboard-grow-btn",s.innerHTML=Pp,s.title="Increase board size",s.setAttribute("aria-label","Increase board size"),s.onclick=()=>this.growBoardSize(e);const a=document.createElement("button");a.type="button",a.className="vnr-whiteboard-action-btn is-close vnr-whiteboard-close-btn",a.innerHTML=NU,a.setAttribute("aria-label","Close board"),a.title="Close board",a.onclick=()=>{if(this.activePresetGeneration++,t)try{t()}catch{}this.closeBoardUi()},n.appendChild(i),n.appendChild(s),n.appendChild(a);const A=e.querySelector(".vnr-whiteboard-canvas-wrap");A?e.insertBefore(n,A):e.prepend(n)}xl(e),this.applyBoardSizeToModal(e),this.applyBoardLayoutMode(this.getBoardOverlay(),e),n&&this.wireBoardDrag(n,e)}wireChalkboardCloseButton(e,t){this.wireChalkboardChrome(e,t)}styleChalkboardSurface(e){e.style.width="100%",e.style.height="100%",e.style.flex="1",e.style.position="relative",e.style.overflowY="auto",e.style.overflowX="hidden",e.style.zIndex="1",e.style.background="transparent",e.style.border="none",e.style.padding="20px 28px 24px",e.style.fontSize="22px",e.style.lineHeight="1.55",e.style.fontFamily="'Architects Daughter', 'Caveat', 'Chalkboard SE', 'Chalkboard', cursive, sans-serif",e.style.color="#ffffff",e.style.textShadow="0 0 3px rgba(255, 255, 255, 0.45), 0 0 8px rgba(255, 255, 255, 0.15)",e.style.outline="none",e.style.boxSizing="border-box",e.style.whiteSpace="pre-wrap",e.style.wordBreak="break-word"}upgradeChalkboardCanvas(e){let t=e.closest(".vnr-whiteboard-canvas-wrap");if(t)return t;const n=e.parentElement;return n?(t=document.createElement("div"),t.className="vnr-whiteboard-canvas-wrap",t.style.display="flex",t.style.flexDirection="column",t.style.flex="1",t.style.height="100%",t.style.position="relative",n.insertBefore(t,e),t.appendChild(e),this.styleChalkboardSurface(e),t):e}ensureChalkboardTextarea(e){let t=this.getChalkboardSurface();if(t){this.syncChalkboardNotes(),this.upgradeChalkboardCanvas(t);const a=t.closest(".vnr-whiteboard-modal");return a&&(xl(a),this.wireChalkboardChrome(a,e),this.revealBoardUi(a)),t}if(CE(),!document.getElementById("vnr-chalk-font")){const a=document.createElement("link");a.id="vnr-chalk-font",a.rel="stylesheet",a.href="https://fonts.googleapis.com/css2?family=Architects+Daughter&family=Caveat:wght@400;700&display=swap",document.head.appendChild(a)}const n=this.createOverlay();n.classList.add("vnr-whiteboard-overlay","vnr-whiteboard-overlay-expanded");const i=document.createElement("div");i.className="vnr-modal vnr-whiteboard-modal",i.style.position="relative",i.style.display="flex",i.style.flexDirection="column",i.style.borderRadius="16px",i.style.padding="0",i.style.overflow="hidden",xl(i),this.applyBoardSizeToModal(i);const s=document.createElement("div");return s.className="vnr-whiteboard-canvas-wrap",s.style.display="flex",s.style.flexDirection="column",s.style.flex="1",s.style.minHeight="0",s.style.height="auto",s.style.position="relative",t=document.createElement("div"),t.className="vnr-whiteboard-textarea",t.setAttribute("role","document"),t.setAttribute("aria-label","Chalkboard notes"),t.tabIndex=0,this.paintChalkboardSurface(t,this.chalkboardContent),s.appendChild(t),this.styleChalkboardSurface(t),i.appendChild(s),n.appendChild(i),this.wireChalkboardChrome(i,e),t}eraseChalkboardInMemory(e,t){return e==="words"?this.eraseLastWords(this.chalkboardContent,t):""}extractBoardWriteText(e,t){const n=e.args||{},i=e.clientFields||{};if(t===_.WriteLatexText){const s=String(n.latex_text||i.latex_text||n.text_to_type||i.text_to_type||n.text||i.text||"");return bE(s)}return String(n.text_to_type||i.text_to_type||n.text||i.text||n.value||i.value||n.search_query||i.search_query||n.query||i.query||"")}renderWriteLatexText(e,t,n){this.executeTypeText(e,t,n,"",{navigated:!1},{forceChalkboard:!0,resultPresetId:_.WriteLatexText})}renderTypeText(e,t,n){const i=e.args||{},s=e.clientFields||{},a=String(i.element_id||s.element_id||i.css_selector||s.css_selector||i.selector||s.selector||"").trim(),A=a?this.extractElementRoute(e):"",o=c=>{this.executeTypeText(e,t,n,a,c,{resultPresetId:_.TypeText})};if(!A){o({navigated:!1});return}this.withElementRoute(A,this.parseDomTarget(a),n,o,_.TypeText)}executeTypeText(e,t,n,i,s,a){const A=e.args||{},o=e.clientFields||{},c=(a==null?void 0:a.resultPresetId)??_.TypeText,l=(a==null?void 0:a.forceChalkboard)===!0;let d=this.extractBoardWriteText(e,c);const u=Number(A.delay_ms!==void 0?A.delay_ms:o.delay_ms!==void 0?o.delay_ms:50),h=this.resolveTypingMode(e),p=R=>{const M={...R,...s.route?{route:s.route}:{},...s.navigated?{navigated_to_route:s.route}:{}};document.querySelector(".vnr-whiteboard-modal")&&(M.board_snapshot=this.getBoardSnapshot()),t(M)};if(c===_.WriteLatexText){const R=String(A.latex_text||o.latex_text||A.text_to_type||o.text_to_type||""),M=RE(R);if(!M.ok){Fs("Board:LaTeX","Validation failed — board not updated",M.errors),p(PE(M.errors,M.agent_message,this.chalkboardContent.length));return}d=M.normalized}let g=null;i&&(g=this.findDomTarget(this.parseDomTarget(i)));const v=()=>{Fs("Board:Type",l?"Writing LaTeX on chalkboard":"Using chalkboard fallback",{toolCallId:e.toolCallId,textPreview:d.slice(0,80),sessionChars:this.chalkboardContent.length});const R=this.ensureChalkboardTextarea(()=>n("User dismissed typing popup"));if(!R){p({status:"error",message:"Could not open chalkboard"});return}R.focus();const M=d;let D=this.chalkboardContent||"";const O=D?`
|
|
881
|
+
${M}`:M,H=D+O,se=this.activePresetGeneration,ie=u<=0,Z=()=>{this.chalkboardContent=H,this.paintChalkboardSurface(R,H),p({status:"success",preset_id:c,typing_mode:"append",message:c===_.WriteLatexText?"Wrote LaTeX on chalkboard":"Typed on chalkboard",whiteboard_content:this.chalkboardContent,text_written:this.chalkboardContent,latex_written:c===_.WriteLatexText?this.chalkboardContent:void 0,...this.buildBoardVerification()})};this.activeBoardProgress={ctx:e,mode:"type",textAtStart:D,plannedUnits:O.length,unitsDone:0},ie?(this.paintChalkboardSurface(R,H),this.syncBoardProgressUnits(O.length),Fs("Board:Type","Chalkboard typed (instant)",{chars:this.chalkboardContent.length,preview:this.chalkboardContent.slice(0,120)}),Z()):FE({surface:R,initialText:D,appendText:O,delayMs:u,schedule:(ee,ue)=>this.scheduleBoardAnim(ee,ue),shouldContinue:()=>se===this.activePresetGeneration&&document.body.contains(R),onSourceChar:ee=>{this.chalkboardContent=D+O.slice(0,ee),this.syncBoardProgressUnits(ee)},onComplete:()=>{se===this.activePresetGeneration&&(this.chalkboardContent=H,this.syncBoardProgressUnits(O.length),Z())}})};if(l||!g){v();return}if(g.focus(),!(g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||"value"in g)){g.textContent=d,p({status:"success"});return}const B=g;let E=B.value||"";if(h==="replace"&&E&&(this.setNativeInputValue(B,""),E=""),u<=0){B.value=E+d,this.dispatchInputChange(B),p({status:"success",preset_id:_.TypeText,typing_mode:h,message:`Typed into ${i||"input"}`});return}let b=E,C=0;const T=this.activePresetGeneration,F=()=>{T===this.activePresetGeneration&&document.body.contains(B)&&(C<d.length?(b+=d[C],B.value=b,B.dispatchEvent(new Event("input",{bubbles:!0})),C++,this.scheduleBoardAnim(F,u)):(B.dispatchEvent(new Event("change",{bubbles:!0})),p({status:"success",preset_id:_.TypeText,typing_mode:h,message:`Typed into ${i||"input"}`})))};F()}resolveTypingMode(e){const t=e.args||{},n=e.clientFields||{},i=String(t.typing_mode||n.typing_mode||"append").trim().toLowerCase();return i==="replace"||i==="clear"||i==="clear_first"||i==="erase_and_type"?"replace":"append"}renderEraseText(e,t,n){const i=e.args||{},s=e.clientFields||{},a=String(i.element_id||s.element_id||i.css_selector||s.css_selector||i.selector||s.selector||"").trim(),A=a?this.extractElementRoute(e):"",o=c=>{this.executeEraseText(e,t,n,a,c)};if(!A){o({navigated:!1});return}this.withElementRoute(A,this.parseDomTarget(a),n,o,_.EraseText)}executeEraseText(e,t,n,i,s){const a=e.args||{},A=e.clientFields||{},o=String(a.mode||A.mode||"all").trim().toLowerCase(),c=Number(a.num_words!==void 0?a.num_words:a.words_count!==void 0?a.words_count:a.count!==void 0?a.count:1),l=Number(a.delay_ms!==void 0?a.delay_ms:A.delay_ms!==void 0?A.delay_ms:50),d=b=>{t({...b,...s.route?{route:s.route}:{},...s.navigated?{navigated_to_route:s.route}:{}})};let u=null;if(i&&(u=this.findDomTarget(this.parseDomTarget(i))),u||(u=this.getChalkboardSurface()),!u&&this.chalkboardContent&&(u=this.ensureChalkboardTextarea(()=>n("User dismissed chalkboard"))),!u){if(this.chalkboardContent){const b=this.eraseChalkboardInMemory(o,c);this.chalkboardContent=b;const C=this.getChalkboardSurface();C&&this.paintChalkboardSurface(C,b),d({status:"success",erased_from_memory:!0});return}d({status:"error",message:"Target element not found"});return}if(u.classList.contains("vnr-whiteboard-textarea")){const b=u.closest(".vnr-whiteboard-modal");b&&this.wireChalkboardCloseButton(b,()=>n("User dismissed chalkboard"));const C=u,T=this.chalkboardContent,F=o==="words"?this.eraseLastWords(T,c):"";if(l<=0){this.paintChalkboardSurface(C,F);const H=Math.max(0,T.length-F.length);this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:T,plannedUnits:H,unitsDone:H},d({status:"success"});return}const R=this.activePresetGeneration,M=Math.max(0,T.length-F.length);this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:T,plannedUnits:M,unitsDone:0};let D=T;const O=()=>{R===this.activePresetGeneration&&document.body.contains(C)&&(D.length>F.length?(D=D.slice(0,-1),this.paintChalkboardSurface(C,D),this.syncBoardProgressUnits(T.length-D.length),this.scheduleBoardAnim(O,Math.max(10,l/2))):d({status:"success"}))};O();return}if(!(u instanceof HTMLInputElement)&&!(u instanceof HTMLTextAreaElement)){if(o==="words"){const b=u.textContent||"";u.textContent=this.eraseLastWords(b,c)}else u.textContent="";d({status:"success"});return}const h=u,p=h.value||"";let g="";if(o==="words"?g=this.eraseLastWords(p,c):g="",l<=0){if(h.value=g,h.classList.contains("vnr-whiteboard-textarea")){this.chalkboardContent=g;const b=Math.max(0,p.length-g.length);this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:p,plannedUnits:b,unitsDone:b}}h.dispatchEvent(new Event("input",{bubbles:!0})),h.dispatchEvent(new Event("change",{bubbles:!0})),d({status:"success"});return}const v=this.activePresetGeneration,w=h.classList.contains("vnr-whiteboard-textarea"),B=Math.max(0,p.length-g.length);w&&(this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:p,plannedUnits:B,unitsDone:0});const E=()=>{v===this.activePresetGeneration&&document.body.contains(h)&&(h.value.length>g.length?(h.value=h.value.slice(0,-1),w&&(this.chalkboardContent=h.value,this.syncBoardProgressUnits(p.length-h.value.length)),h.dispatchEvent(new Event("input",{bubbles:!0})),h.classList.contains("vnr-whiteboard-textarea")&&(h.scrollTop=h.scrollHeight),this.scheduleBoardAnim(E,Math.max(10,l/2))):(h.dispatchEvent(new Event("change",{bubbles:!0})),d({status:"success"})))};E()}eraseLastWords(e,t){if(!e)return"";const n=e.trimEnd();if(!n)return"";let i=n;for(let s=0;s<t;s++){const a=i.lastIndexOf(" "),A=i.lastIndexOf(`
|
|
882
|
+
`),o=Math.max(a,A);if(o===-1){i="";break}else i=i.slice(0,o).trimEnd()}return i}}function Np(r){const e=(r==null?void 0:r.data)||r;return String((e==null?void 0:e.tool_call_id)||(e==null?void 0:e.call_id)||"")}const YU=Vt.forwardRef(function({client:e,toolCall:t=null,onCustomTool:n},i){const s=Vt.useRef(null),a=Vt.useRef(new Set),A=Vt.useRef(new Set),o=Vt.useRef([]),c=Vt.useRef(!1);Vt.useEffect(()=>(s.current=new JU(null),()=>{var h;(h=s.current)==null||h.resetBoardSession()}),[]),Vt.useEffect(()=>{const h=p=>{var v;const g=p.detail||{};(v=s.current)==null||v.abortBoardTools(g.reason||"Server interrupted",g.toolCallId)};return window.addEventListener(Rp,h),()=>window.removeEventListener(Rp,h)},[]);const l=Vt.useCallback(()=>{if(c.current||!s.current||!e)return;const h=o.current.shift();if(!h)return;c.current=!0;const p=h.data||h,g=p.arguments||p.args,v=p.client_fields||{},w=Gd(v,g,p.name||p.tool_name),B=Np(h),E=()=>{c.current=!1,o.current.length>0&&l()};if(!w||!Xn(w)){n&&n(h),E();return}!Vy(w)&&e.sendContextUpdate&&B&&(e.sendToolResult(B,{status:"popup_shown",message:`The UI preset ${w} is now visible. I am waiting for the user to complete it. STAY SILENT.`}),e.sendContextUpdate({ui_state:"waiting_for_preset_data",tool_status:"active_waiting",visible_preset:w})),s.current.handle(h,C=>{var F,R;if(!B){E();return}const T=typeof C=="string"?{response:C}:C;if(El(w)){E();return}if(i0(w)){(T==null?void 0:T.status)!=="cancelled"&&!a.current.has(B)&&(a.current.add(B),e.sendToolResult(B,T)),E();return}if(Ul(w)){if((T==null?void 0:T.status)==="cancelled"){E();return}(F=e.triggerActionInterrupt)==null||F.call(e);const M=r0(w,p.name||p.tool_name||"",v);(R=e.sendActionTrigger)==null||R.call(e,M,T),E();return}e.triggerActionInterrupt&&e.triggerActionInterrupt(),e.sendActionTrigger?e.sendActionTrigger(r0(w,p.name||p.tool_name||"",v),T):e.sendToolResult(B,T),E()},(C,T)=>{var F,R;if(!B){E();return}if(i0(w)){const M=(T==null?void 0:T.status)??"cancelled",D=String(v.target_url||(typeof g=="object"&&g?g.target_url:"")||"");a.current.has(B)||(a.current.add(B),e.sendToolResult(B,w===_.Navigate?((F=s.current)==null?void 0:F.getNavigateTerminalResult(M,C,D||void 0))??{status:M,reason:C||"Navigation cancelled",preset_id:w,target_url:D||void 0}:((R=s.current)==null?void 0:R.getBoardTerminalResult(M,C,w))??{status:M,reason:C||"User dismissed",preset_id:w})),E();return}if(El(w))try{e.sendToolResult(B,{status:"cancelled",reason:C||"User dismissed",preset_id:w})}catch{}else if(Ul(w))if(typeof e.sendToolError=="function")e.sendToolError(B,C||"User cancelled the action");else try{e.sendToolResult(B,{status:"cancelled",reason:C||"User dismissed",preset_id:w})}catch{}else typeof e.sendToolError=="function"&&e.sendToolError(B,C||"User cancelled the action");E()},e)||(n&&n(h),E())},[e,n]),d=Vt.useCallback(h=>{const p=Np(h);if(p){if(A.current.has(p))return;A.current.add(p)}o.current.push(h),l()},[l]),u=Vt.useCallback(()=>{var h,p;o.current=[],c.current=!1,A.current.clear(),a.current.clear(),(h=s.current)!=null&&h.hasActiveBoardSession()||(p=s.current)==null||p.dismiss()},[]);return Vt.useImperativeHandle(i,()=>({enqueueToolCall:d,clearQueue:u}),[d,u]),Vt.useEffect(()=>{t&&d(t)},[t,d]),Vt.useEffect(()=>{e||u()},[e,u]),null});class ZU{constructor(e){L(this,"el");this.el=new Audio,this.el.srcObject=e,this.el.play().catch(t=>{})}pause(){}cleanup(){this.el.pause(),this.el.srcObject=null}onEnded(e){this.el.onended=e}}class eF{createRemotePlayer(e){return new ZU(e)}}class tF{async getUserAudio(e){return navigator.mediaDevices.getUserMedia({audio:e})}stopStream(e){e.getTracks().forEach(t=>t.stop())}}class nF{create(e){return new RTCPeerConnection({iceServers:e.iceServers,iceTransportPolicy:e.iceTransportPolicy??"all"})}}class rF{bind(e,t){return e.onopen=()=>t.onOpen(),e.onerror=n=>t.onError(n),e.onmessage=n=>{if(typeof n.data=="string"){t.onMessage({text:n.data});return}if(n.data instanceof ArrayBuffer){try{const i=new TextDecoder().decode(n.data),s=JSON.parse(i);qp(s)&&t.onMessage({text:i})}catch{}return}n.data instanceof Blob&&n.data.text().then(i=>{t.onMessage({text:i})}).catch(i=>{})},{send(n){e.readyState==="open"&&e.send(n)},isOpen(){return e.readyState==="open"},close(){e.close()}}}}var Kp;const My={supportsAudioEndedEvent:!0,supportsScreenShare:typeof navigator<"u"&&typeof((Kp=navigator.mediaDevices)==null?void 0:Kp.getDisplayMedia)=="function",supportsDom:typeof document<"u",supportsHtmlAudio:typeof Audio<"u",supportsCustomElements:typeof customElements<"u",supportsLocalStorage:typeof localStorage<"u",supportsBroadcastChannel:typeof BroadcastChannel<"u"},_y={name:"browser",callType:"web",runtimeName:"browser",callIdPrefix:"web_",capabilities:My,audio:new eF,media:new tF,peer:new nF,dataChannel:new rF};function iF(r){return new NA({...r,runtime:_y})}exports.LiveKitVoiceClient=oC;exports.PresetRenderer=YU;exports.RouteContextTracker=$p;exports.VaniraClient=NA;exports.browserCapabilities=My;exports.browserRuntime=_y;exports.createBrowserClient=iF;exports.getCurrentPageRoute=Qs;exports.hasContinueSession=Xy;exports.loadContinueSession=HA;exports.markAgentNavigation=Wp;exports.normalizePageRoute=qd;exports.saveCallSession=Gp;
|