@vanira/sdk 0.0.84 → 0.0.85
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 +471 -158
- package/dist/headless/index.d.ts +3 -0
- package/dist/headless/index.js +42946 -4051
- 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 +21285 -689
- package/dist/platforms/react-native.cjs +1 -1
- package/dist/platforms/react-native.js +397 -387
- package/dist/vanira-sdk.es.js +46507 -7599
- package/dist/vanira-sdk.js +492 -222
- package/dist/vanira-sdk.umd.js +526 -213
- package/package.json +6 -5
- package/dist/chunks/html2canvas.js +0 -6
package/dist/headless/index.cjs
CHANGED
|
@@ -1,117 +1,379 @@
|
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";var hy=Object.defineProperty;var fy=(r,e,t)=>e in r?hy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var D=(r,e,t)=>fy(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("react");var rc=typeof document<"u"?document.currentScript:null;const py="https://api.vanira.io",R={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"},my=Object.values(R),gy=new Set(my),vy=new Set([R.Camera,R.LiveVision,R.LiveScreen]),yy=new Set([R.Navigate,R.HighlightElement,R.ClickElement,R.SelectOption,R.SetDate,R.TypeText,R.WriteLatexText,R.EraseText,R.LiveVision,R.CloseLiveCamera,R.LiveScreen,R.CloseLiveScreen,R.ScreenVision,R.PointAt,R.DrawOnScreen,R.ClearScreenDraw,R.HighlightOnScreen]),wy=new Set([R.TypeText,R.WriteLatexText,R.EraseText]);function Kn(r){return!!r&&gy.has(r)}function by(r){return Kn(r)&&yy.has(r)}function Vu(r){return Kn(r)&&wy.has(r)}function gl(r){return Kn(r)&&vy.has(r)}const By=new Set([R.Form,R.Calendar]);function vl(r){return Kn(r)&&By.has(r)}function zu(r,e,t){return t!=null&&t.action_name?String(t.action_name):r===R.Calendar?"calendar_slot_selected":`user_submitted_${e||"collect_user_data"}`}function Gu(r){return Kn(r)&&!gl(r)&&!vl(r)}const Cy=new Set([R.ScreenVision,R.PointAt,R.DrawOnScreen,R.ClearScreenDraw,R.HighlightOnScreen]);function Sy(r){return Kn(r)&&Cy.has(r)}function Sp(r){if(typeof r=="string")try{return JSON.parse(r)}catch{return{}}return r&&typeof r=="object"?r:{}}const qu={type_on_whiteboard:R.TypeText,write_on_whiteboard:R.TypeText,write_on_white_board:R.TypeText,dom_typing_simulation:R.TypeText,write_latex_text:R.WriteLatexText,write_latex_on_board:R.WriteLatexText,latex_on_whiteboard:R.WriteLatexText,erase_text:R.EraseText,dom_erase:R.EraseText,open_live_camera:R.LiveVision,live_vision:R.LiveVision,close_live_camera:R.CloseLiveCamera,stop_live_camera:R.CloseLiveCamera,open_live_screen:R.LiveScreen,close_live_screen:R.CloseLiveScreen,screen_vision:R.ScreenVision,capture_screen_vision:R.ScreenVision,capture_screen:R.ScreenVision,tab_screenshot:R.ScreenVision,capture_tab:R.ScreenVision,capture_tab_screenshot:R.ScreenVision,screenshot_tab:R.ScreenVision,point_at:R.PointAt,point_at_screen:R.PointAt,draw_on_screen:R.DrawOnScreen,screen_draw:R.DrawOnScreen,clear_screen_draw:R.ClearScreenDraw,clear_screen_annotations:R.ClearScreenDraw,highlight_on_screen:R.HighlightOnScreen,highlight_element_on_screen:R.HighlightOnScreen,highlight_screen_element:R.HighlightOnScreen},Wu={vanira_tab_screenshot:R.ScreenVision};function Ty(r,e){const t=r.latex_text??(e==null?void 0:e.latex_text);return typeof t=="string"&&t.trim().length>0}function $u(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 ky(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 xy(r,e){const t=r==null?void 0:r.preset_id;if(typeof t=="string"){if(Kn(t))return t;const s=Wu[t];if(s)return s}const i=Sp(e).preset_id;if(typeof i=="string"){if(Kn(i))return i;const s=Wu[i];if(s)return s}}function Id(r,e,t){const n=Sp(e);let i=xy(r,n);if(i===R.Form&&$u(n,r)&&!ky(n,r))return R.TypeText;if(i)return i;const s=String(t??"").trim().toLowerCase();if(s&&qu[s])return qu[s];if(Ty(n,r))return R.WriteLatexText;if($u(n,r))return R.TypeText}const kA="vanira_latest_call_id",yl="vanira_prospect_id";function xA(r){return`vanira_latest_call_id_${r}`}function EA(r){return`vanira_prospect_id_${r}`}function Tp(r){return`vanira_call_meta_${r}`}function yr(r,e){if(!r)return null;try{return r.getItem(e)}catch{return null}}function UA(r){if(typeof window>"u"||!r)return null;const e=[],t=yr(window.localStorage,Tp(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=yr(window.localStorage,EA(r)),s=yr(window.sessionStorage,EA(r)),a=yr(window.localStorage,yl);return n(yr(window.localStorage,xA(r)),i||a,2),n(yr(window.sessionStorage,xA(r)),s||a,1),n(yr(window.localStorage,kA),a,0),n(yr(window.sessionStorage,kA),a,0),e.length?(e.sort((A,o)=>o.updatedAt-A.updatedAt),e[0]):null}function kp(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(Tp(r),JSON.stringify(n)),(s=window.localStorage)==null||s.setItem(xA(r),e),(a=window.sessionStorage)==null||a.setItem(xA(r),e),t&&((A=window.localStorage)==null||A.setItem(EA(r),t),(o=window.sessionStorage)==null||o.setItem(EA(r),t)),(c=window.localStorage)==null||c.setItem(kA,e),(l=window.sessionStorage)==null||l.setItem(kA,e),t&&((d=window.localStorage)==null||d.setItem(yl,t),(u=window.sessionStorage)==null||u.setItem(yl,t))}catch{}}function Ey(r){var e;return!!((e=UA(r))!=null&&e.callId)}const Uy=new Set(["client_tool_call","clearAudio","client_tool_cancel"]);function xp(r){if(!r||typeof r!="object")return!1;const e=r.event;return typeof e=="string"&&Uy.has(e)}const ic=16*1024,Fy=256*1024;function sc(r,e){return(r==null?void 0:r.readyState)==="open"&&(e==null?void 0:e.readyState)==="open"}function Iy(r,e){return{control:(r==null?void 0:r.readyState)??"missing",mediaBytes:(e==null?void 0:e.readyState)??"missing"}}async function Qy(r,e,t=8e3){if(sc(r,e))return!0;const n=Date.now()+t;for(;Date.now()<n;){if(sc(r,e))return!0;await new Promise(i=>setTimeout(i,50))}return sc(r,e)}async function Xu(r){for(;r.bufferedAmount>Fy;)await new Promise(e=>setTimeout(e,10))}async function My(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/ic);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 m=0;m<d;m+=ic){await Xu(A);const g=Math.min(m+ic,d);A.send(h.subarray(m,g))}return await Xu(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 _y(r){return typeof r.arrayBuffer=="function"?r.arrayBuffer():new Response(r).arrayBuffer()}let jr=null;const Ry=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 Ep(r,e){jr={targetRoute:Qd(r),presetId:e==null?void 0:e.presetId,toolName:e==null?void 0:e.toolName,expiresAt:Date.now()+Ry}}function Py(r){if(!jr)return null;if(Date.now()>jr.expiresAt)return jr=null,null;const e=Qd(r),t=jr.targetRoute;if(!(e===t||e.startsWith(t.split("#")[0])||t.startsWith(e.split("#")[0])))return null;const i=jr;return jr=null,i}function ws(){return typeof window>"u"?"/":`${window.location.pathname}${window.location.search}${window.location.hash}`||"/"}class Up{constructor(e){D(this,"active",!1);D(this,"initialSent",!1);D(this,"lastRoute","");D(this,"sendContext");D(this,"isReady");D(this,"cleanupFns",[]);D(this,"initialRetryTimer",null);D(this,"routePollTimer",null);D(this,"originalPushState",null);D(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=ws(),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=ws();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=ws();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()||Py(e)||this.sendRouteContext("route_changed",n,t,"user")}sendRouteContext(e,t,n,i="user"){const s=ws();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 rr=class rr{constructor(e){D(this,"serverUrl");D(this,"agentId");D(this,"callId");D(this,"prospectId");D(this,"apiKey");D(this,"backendUrl");D(this,"token");D(this,"onConnected");D(this,"onDisconnected");D(this,"onError");D(this,"onTranscription");D(this,"onLocalStream");D(this,"onRemoteTrack");D(this,"onClientToolCall");D(this,"onSessionStarted");D(this,"sessionStartedEmitted",!1);D(this,"pc",null);D(this,"dataChannel",null);D(this,"mediaBytesChannel",null);D(this,"audioElement",null);D(this,"localStream",null);D(this,"micMuted",!1);D(this,"connected",!1);D(this,"icePollInterval",null);D(this,"appliedRemoteCandidates",new Set);D(this,"iceServers");D(this,"callSessionLoaded",!1);D(this,"connectGeneration",0);D(this,"runtime");D(this,"sessionBehavior");D(this,"routeTracker",null);D(this,"_status","idle");D(this,"listeners",new Map);D(this,"liveVision");D(this,"liveVisionAutoStarted",!1);if(!e.agentId)throw new Error("agentId is required");const t=!!(e.apiKey||e.token),n=!!(e.serverUrl&&e.callId),i=rr.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||py).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=UA(this.agentId);o&&(e.callId||(this.callId=o.callId),!this.prospectId&&o.prospectId&&(this.prospectId=o.prospectId))}if(!this.prospectId&&s)try{const o=UA(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 Up({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 m="Microphone access denied. Please allow microphone access in your browser settings.";h&&(u.includes("CriOS")?m="Microphone access blocked. Please enable it in iOS Settings > Chrome > Microphone, then reload the page.":u.includes("FxiOS")?m="Microphone access blocked. Please enable it in iOS Settings > Firefox > Microphone, then reload the page.":m="Microphone access blocked. Please enable it in iOS Settings > Safari > Microphone (or tap 'aA' > Website Settings > Allow Microphone).");const g=new Error(m);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);xp(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(m=>{}),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,m,g,y,b,B,U,w,C,E,I;const d=((h=this.pc)==null?void 0:h.connectionState)==="connected"||((m=this.pc)==null?void 0:m.iceConnectionState)==="connected"||((g=this.pc)==null?void 0:g.iceConnectionState)==="completed",u=((y=this.pc)==null?void 0:y.connectionState)==="failed"||((b=this.pc)==null?void 0:b.iceConnectionState)==="failed"||((B=this.pc)==null?void 0:B.connectionState)==="closed"||((U=this.pc)==null?void 0:U.iceConnectionState)==="closed"||((w=this.pc)==null?void 0:w.connectionState)==="disconnected"||((C=this.pc)==null?void 0:C.iceConnectionState)==="disconnected";((E=this.pc)==null?void 0:E.connectionState)==="connected"&&this.stopRemoteIcePolling(),d&&!this.connected?(this.connected=!0,(I=this.routeTracker)==null||I.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=rr.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,kp(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=rr.inflightCreates.get(i);s||(s=this.postCreateCall(e,n,t),rr.inflightCreates.set(i,s),s.finally(()=>{rr.inflightCreates.get(i)===s&&rr.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:R.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=Id(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 Qy(this.dataChannel,this.mediaBytesChannel)?this._uploadMediaViaDataChannel(e,t,n):(Iy(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 _y(e);return My({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()}};D(rr,"inflightCreates",new Map);let FA=rr;function Dy(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 Ly=Object.defineProperty,Oy=(r,e,t)=>e in r?Ly(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ju=(r,e,t)=>Oy(r,typeof e!="symbol"?e+"":e,t);class wt{constructor(){Ju(this,"_locking"),Ju(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 We(r,e){if(!r)throw new Error(e)}const Hy=34028234663852886e22,Ny=-34028234663852886e22,Ky=4294967295,Vy=2147483647,zy=-2147483648;function rA(r){if(typeof r!="number")throw new Error("invalid int 32: "+typeof r);if(!Number.isInteger(r)||r>Vy||r<zy)throw new Error("invalid int 32: "+r)}function wl(r){if(typeof r!="number")throw new Error("invalid uint 32: "+typeof r);if(!Number.isInteger(r)||r>Ky||r<0)throw new Error("invalid uint 32: "+r)}function Fp(r){if(typeof r!="number")throw new Error("invalid float 32: "+typeof r);if(Number.isFinite(r)&&(r>Hy||r<Ny))throw new Error("invalid float 32: "+r)}const Ip=Symbol("@bufbuild/protobuf/enum-type");function Gy(r){const e=r[Ip];return We(e,"missing enum type on enum object"),e}function Qp(r,e,t,n){r[Ip]=Mp(e,t.map(i=>({no:i.no,name:i.name,localName:r[i.no]})))}function Mp(r,e,t){const n=Object.create(null),i=Object.create(null),s=[];for(const a of e){const A=_p(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 qy(r,e,t){const n={};for(const i of e){const s=_p(i);n[s.localName]=s.no,n[s.no]=s.localName}return Qp(n,r,e),n}function _p(r){return"localName"in r?r:Object.assign(Object.assign({},r),{localName:r.name})}class Md{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 Wy(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 Md),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 $y(){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 ac(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 iA=4294967296;function ju(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>=iA&&(i=i+(n/iA|0),n=n%iA)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Pp(n,i):_d(n,i)}function Xy(r,e){let t=_d(r,e);const n=t.hi&2147483648;n&&(t=Pp(t.lo,t.hi));const i=Rp(t.lo,t.hi);return n?"-"+i:i}function Rp(r,e){var t=Jy(r,e);if(r=t.lo,e=t.hi,e<=2097151)return String(iA*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()+Yu(A)+Yu(a)}function Jy(r,e){return{lo:r>>>0,hi:e>>>0}}function _d(r,e){return{lo:r|0,hi:e|0}}function Pp(r,e){return e=~e,r?r=~r+1:e+=1,_d(r,e)}const Yu=r=>{const e=String(r);return"0000000".slice(e.length)+e};function Zu(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 jy(){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 Yy(){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=>We(/^-?[0-9]+$/.test(i),"int64 invalid: ".concat(i)),n=i=>We(/^[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),ju(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),n(i),ju(i)},dec(i,s){return Xy(i,s)},uDec(i,s){return Rp(i,s)}}}const Le=Yy();var N;(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"})(N||(N={}));var Lr;(function(r){r[r.BIGINT=0]="BIGINT",r[r.STRING=1]="STRING"})(Lr||(Lr={}));function wr(r,e,t){if(e===t)return!0;if(r==N.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 N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return e==t}return!1}function $i(r,e){switch(r){case N.BOOL:return!1;case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return e==0?Le.zero:"0";case N.DOUBLE:case N.FLOAT:return 0;case N.BYTES:return new Uint8Array(0);case N.STRING:return"";default:return 0}}function Dp(r,e){switch(r){case N.BOOL:return e===!1;case N.STRING:return e==="";case N.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}function e0(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 Zy(r){if(Array.isArray(r))return r}function ye(r,e,t){return(e=rw(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ew(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 tw(){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 ie(r,e){return Zy(r)||ew(r,e)||iw(r,e)||tw()}function nw(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 rw(r){var e=nw(r,"string");return typeof e=="symbol"?e:e+""}function iw(r,e){if(r){if(typeof r=="string")return e0(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)?e0(r,e):void 0}}var Ze;(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"})(Ze||(Ze={}));class sw{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(wl(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return rA(e),Zu(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){Fp(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){wl(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){rA(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return rA(e),e=(e<<1^e>>31)>>>0,Zu(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=Le.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=Le.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=Le.enc(e);return ac(t.lo,t.hi,this.buf),this}sint64(e){let t=Le.enc(e),n=t.hi>>31,i=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return ac(i,s,this.buf),this}uint64(e){let t=Le.uEnc(e);return ac(t.lo,t.hi,this.buf),this}}class aw{constructor(e,t){this.varint64=$y,this.uint32=jy,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 Ze.Varint:for(;this.buf[this.pos++]&128;);break;case Ze.Bit64:this.pos+=4;case Ze.Bit32:this.pos+=4;break;case Ze.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Ze.StartGroup:for(;;){const s=this.tag(),a=ie(s,2),A=a[0],o=a[1];if(o===Ze.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 Le.dec(...this.varint64())}uint64(){return Le.uDec(...this.varint64())}sint64(){let e=this.varint64(),t=ie(e,2),n=t[0],i=t[1],s=-(n&1);return n=(n>>>1|(i&1)<<31)^s,i=i>>>1^s,Le.dec(n,i)}bool(){let e=this.varint64(),t=ie(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 Le.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Le.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 Aw(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 Lp(r){const e=r.field.localName,t=Object.create(null);return t[e]=ow(r),[t,()=>t[e]]}function ow(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 $i(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 cw(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 ar="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),uo=[];for(let r=0;r<ar.length;r++)uo[ar[r].charCodeAt(0)]=r;uo[45]=ar.indexOf("+");uo[95]=ar.indexOf("/");const Op={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=uo[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+=ar[n>>2],i=(n&3)<<4,t=1;break;case 1:e+=ar[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=ar[i|n>>6],e+=ar[n&63],t=0;break}return t&&(e+=ar[i],e+="=",t==1&&(e+="=")),e}};function lw(r,e,t){Np(e,r);const n=e.runtime.bin.makeReadOptions(t),i=cw(r.getType().runtime.bin.listUnknownFields(r),e.field),s=Lp(e),a=ie(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 dw(r,e,t,n){Np(e,r);const i=e.runtime.bin.makeReadOptions(n),s=e.runtime.bin.makeWriteOptions(n);if(Hp(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=ie(c,2),d=l[0],u=l[1],h=o.skip(u,d);r.getType().runtime.bin.onUnknownField(r,d,u,h)}}function Hp(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 Np(r,e){We(r.extendee.typeName==e.getType().typeName,"extension ".concat(r.typeName," can only be applied to message ").concat(r.extendee.typeName))}function Kp(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:!Dp(r.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function t0(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?$i(r.T,r.L):void 0;break;case"message":e[t]=void 0;break}}function Ar(r,e){if(r===null||typeof r!="object"||!Object.getOwnPropertyNames(Md.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 Vp(r,e){return Ar(e)||!r.fieldWrapper?e:r.fieldWrapper.wrapField(e)}N.DOUBLE,N.FLOAT,N.INT64,N.UINT64,N.INT32,N.UINT32,N.BOOL,N.STRING,N.BYTES;const n0={ignoreUnknownFields:!1},r0={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function uw(r){return r?Object.assign(Object.assign({},n0),r):n0}function hw(r){return r?Object.assign(Object.assign({},r0),r):r0}const IA=Symbol(),sA=Symbol();function fw(){return{makeReadOptions:uw,makeWriteOptions:hw,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(Rn(e)));n=n??new r;const i=new Map,s=t.typeRegistry;for(const A of Object.entries(e)){var a=ie(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)}i0(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=Lp(u),m=ie(h,2),g=m[0],y=m[1];i0(g,c,u.field,t,u),dw(n,u,y(),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(!Kp(i,r)){if(i.req)throw"required field not set";if(!e.emitDefaultValues||!mw(i))continue}const a=i.oneof?r[i.oneof.localName].value:r[i.localName],A=s0(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&&Hp(r,A)){const o=lw(r,A,e),c=s0(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 Ms(r,e,t??Lr.BIGINT,!0)},writeScalar(r,e,t){if(e!==void 0&&(t||Dp(r,e)))return aA(r,e)},debug:Rn}}function Rn(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 i0(r,e,t,n,i){let s=t.localName;if(t.repeated){if(We(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(Rn(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(Rn(o)));switch(t.kind){case"message":A.push(t.T.fromJson(o,n));break;case"enum":const c=Ac(t.T,o,n.ignoreUnknownFields,!0);c!==sA&&A.push(c);break;case"scalar":try{A.push(Ms(t.T,o,t.L,!0))}catch(l){let d="cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Rn(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(Rn(e)));const A=r[s];for(const o of Object.entries(e)){var a=ie(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=pw(t.K,c)}catch(u){let h="cannot decode map key for field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Rn(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=Ac(t.V.T,l,n.ignoreUnknownFields,!0);u!==sA&&(A[d]=u);break;case"scalar":try{A[d]=Ms(t.V.T,l,Lr.BIGINT,!0)}catch(h){let m="cannot decode map value for field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Rn(e));throw h instanceof Error&&h.message.length>0&&(m+=": ".concat(h.message)),new Error(m)}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];Ar(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=Ac(t.T,e,n.ignoreUnknownFields,!1);switch(c){case IA:t0(t,r);break;case sA:break;default:r[s]=c;break}break;case"scalar":try{const l=Ms(t.T,e,t.L,!1);switch(l){case IA:t0(t,r);break;default:r[s]=l;break}}catch(l){let d="cannot decode field ".concat(i.typeName,".").concat(t.name," from JSON: ").concat(Rn(e));throw l instanceof Error&&l.message.length>0&&(d+=": ".concat(l.message)),new Error(d)}break}}function pw(r,e){if(r===N.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ms(r,e,Lr.BIGINT,!0).toString()}function Ms(r,e,t,n){if(e===null)return n?$i(r,t):IA;switch(r){case N.DOUBLE:case N.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==N.FLOAT&&Fp(i),i;case N.INT32:case N.FIXED32:case N.SFIXED32:case N.SINT32:case N.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==N.UINT32||r==N.FIXED32?wl(s):rA(s),s;case N.INT64:case N.SFIXED64:case N.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=Le.parse(e);return t?a.toString():a;case N.FIXED64:case N.UINT64:if(typeof e!="number"&&typeof e!="string")break;const A=Le.uParse(e);return t?A.toString():A;case N.BOOL:if(typeof e!="boolean")break;return e;case N.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case N.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Op.dec(e)}throw new Error}function Ac(r,e,t,n){if(e===null)return r.typeName=="google.protobuf.NullValue"?0:n?r.values[0].no:IA;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 sA;break}throw new Error("cannot decode enum ".concat(r.typeName," from JSON: ").concat(Rn(e)))}function mw(r){return r.repeated||r.kind=="map"?!0:!(r.oneof||r.kind=="message"||r.opt||r.req)}function s0(r,e,t){if(r.kind=="map"){We(typeof e=="object"&&e!=null);const a={},A=Object.entries(e);switch(r.V.kind){case"scalar":for(const c of A){var n=ie(c,2);const l=n[0],d=n[1];a[l.toString()]=aA(r.V.T,d)}break;case"message":for(const c of A){var i=ie(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=ie(c,2);const l=s[0],d=s[1];a[l.toString()]=oc(o,d,t.enumAsInteger)}break}return t.emitDefaultValues||A.length>0?a:void 0}if(r.repeated){We(Array.isArray(e));const a=[];switch(r.kind){case"scalar":for(let A=0;A<e.length;A++)a.push(aA(r.T,e[A]));break;case"enum":for(let A=0;A<e.length;A++)a.push(oc(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 aA(r.T,e);case"enum":return oc(r.T,e,t.enumAsInteger);case"message":return Vp(r.T,e).toJson(t)}}function oc(r,e,t){var n;if(We(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 aA(r,e){switch(r){case N.INT32:case N.SFIXED32:case N.SINT32:case N.FIXED32:case N.UINT32:return We(typeof e=="number"),e;case N.FLOAT:case N.DOUBLE:return We(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case N.STRING:return We(typeof e=="string"),e;case N.BOOL:return We(typeof e=="boolean"),e;case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return We(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case N.BYTES:return We(e instanceof Uint8Array),Op.enc(e)}}const Bi=Symbol("@bufbuild/protobuf/unknown-fields"),a0={readUnknownFields:!0,readerFactory:r=>new aw(r)},A0={writeUnknownFields:!0,writerFactory:()=>new sw};function gw(r){return r?Object.assign(Object.assign({},a0),r):a0}function vw(r){return r?Object.assign(Object.assign({},A0),r):A0}function yw(){return{makeReadOptions:gw,makeWriteOptions:vw,listUnknownFields(r){var e;return(e=r[Bi])!==null&&e!==void 0?e:[]},discardUnknownFields(r){delete r[Bi]},writeUnknownFields(r,e){const n=r[Bi];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[Bi])||(i[Bi]=[]),i[Bi].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=ie(c,2);if(A=l[0],o=l[1],i===!0&&o==Ze.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}o0(r,e,d,o,n)}if(i&&(o!=Ze.EndGroup||A!==t))throw new Error("invalid end group tag")},readField:o0,writeMessage(r,e,t){const n=r.getType();for(const i of n.fields.byNumber()){if(!Kp(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];c0(i,s,e,t)}return t.writeUnknownFields&&this.writeUnknownFields(r,e),e},writeField(r,e,t,n){e!==void 0&&c0(r,e,t,n)}}}function o0(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"?N.INT32:t.T;let o=QA;if(t.kind=="scalar"&&t.L>0&&(o=bw),s){let m=r[a];if(n==Ze.LengthDelimited&&A!=N.STRING&&A!=N.BYTES){let y=e.uint32()+e.pos;for(;e.pos<y;)m.push(o(e,A))}else m.push(o(e,A))}else r[a]=o(e,A);break;case"message":const c=t.T;s?r[a].push(AA(e,new c,i,t)):Ar(r[a])?AA(e,r[a],i,t):(r[a]=AA(e,new c,i,t),c.fieldWrapper&&!t.oneof&&!t.repeated&&(r[a]=c.fieldWrapper.unwrapField(r[a])));break;case"map":let l=ww(t,e,i),d=ie(l,2),u=d[0],h=d[1];r[a][u]=h;break}}function AA(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 ww(r,e,t){const n=e.uint32(),i=e.pos+n;let s,a;for(;e.pos<i;){const A=e.tag();switch(ie(A,1)[0]){case 1:s=QA(e,r.K);break;case 2:switch(r.V.kind){case"scalar":a=QA(e,r.V.T);break;case"enum":a=e.int32();break;case"message":a=AA(e,new r.V.T,t,void 0);break}break}}if(s===void 0&&(s=$i(r.K,Lr.BIGINT)),typeof s!="string"&&typeof s!="number"&&(s=s.toString()),a===void 0)switch(r.V.kind){case"scalar":a=$i(r.V.T,Lr.BIGINT);break;case"enum":a=r.V.T.values[0].no;break;case"message":a=new r.V.T;break}return[s,a]}function bw(r,e){const t=QA(r,e);return typeof t=="bigint"?t.toString():t}function QA(r,e){switch(e){case N.STRING:return r.string();case N.BOOL:return r.bool();case N.DOUBLE:return r.double();case N.FLOAT:return r.float();case N.INT32:return r.int32();case N.INT64:return r.int64();case N.UINT64:return r.uint64();case N.FIXED64:return r.fixed64();case N.BYTES:return r.bytes();case N.FIXED32:return r.fixed32();case N.SFIXED32:return r.sfixed32();case N.SFIXED64:return r.sfixed64();case N.SINT64:return r.sint64();case N.UINT32:return r.uint32();case N.SINT32:return r.sint32()}}function c0(r,e,t,n){We(e!==void 0);const i=r.repeated;switch(r.kind){case"scalar":case"enum":let a=r.kind=="enum"?N.INT32:r.T;if(i)if(We(Array.isArray(e)),r.packed)Cw(t,a,r.no,e);else for(const A of e)_s(t,a,r.no,A);else _s(t,a,r.no,e);break;case"message":if(i){We(Array.isArray(e));for(const A of e)l0(t,n,r,A)}else l0(t,n,r,e);break;case"map":We(typeof e=="object"&&e!=null);for(const A of Object.entries(e)){var s=ie(A,2);const o=s[0],c=s[1];Bw(t,n,r,o,c)}break}}function Bw(r,e,t,n,i){r.tag(t.no,Ze.LengthDelimited),r.fork();let s=n;switch(t.K){case N.INT32:case N.FIXED32:case N.UINT32:case N.SFIXED32:case N.SINT32:s=Number.parseInt(n);break;case N.BOOL:We(n=="true"||n=="false"),s=n=="true";break}switch(_s(r,t.K,1,s),t.V.kind){case"scalar":_s(r,t.V.T,2,i);break;case"enum":_s(r,N.INT32,2,i);break;case"message":We(i!==void 0),r.tag(2,Ze.LengthDelimited).bytes(i.toBinary(e));break}r.join()}function l0(r,e,t,n){const i=Vp(t.T,n);t.delimited?r.tag(t.no,Ze.StartGroup).raw(i.toBinary(e)).tag(t.no,Ze.EndGroup):r.tag(t.no,Ze.LengthDelimited).bytes(i.toBinary(e))}function _s(r,e,t,n){We(n!==void 0);let i=zp(e),s=ie(i,2),a=s[0],A=s[1];r.tag(t,a)[A](n)}function Cw(r,e,t,n){if(!n.length)return;r.tag(t,Ze.LengthDelimited).fork();let i=zp(e),s=ie(i,2),a=s[1];for(let A=0;A<n.length;A++)r[a](n[A]);r.join()}function zp(r){let e=Ze.Varint;switch(r){case N.BYTES:case N.STRING:e=Ze.LengthDelimited;break;case N.DOUBLE:case N.FIXED64:case N.SFIXED64:e=Ze.Bit64;break;case N.FIXED32:case N.SFIXED32:case N.FLOAT:e=Ze.Bit32;break}const t=N[r].toLowerCase();return[e,t]}function Sw(){return{setEnumType:Qp,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"&&!Ar(l,c.T)?l=new c.T(l):c&&c.kind==="scalar"&&c.T===N.BYTES&&(l=As(l)),a[s]={case:o,value:l};break;case"scalar":case"enum":let d=A[s];i.T===N.BYTES&&(d=i.repeated?d.map(As):As(d)),a[s]=d;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===N.BYTES)for(const m of Object.entries(A[s])){var n=ie(m,2);const g=n[0],y=n[1];a[s][g]=As(y)}else Object.assign(a[s],A[s]);break;case"message":const h=i.V.T;for(const m of Object.keys(A[s])){let g=A[s][m];h.fieldWrapper||(g=new h(g)),a[s][m]=g}break}break;case"message":const u=i.T;if(i.repeated)a[s]=A[s].map(h=>Ar(h,u)?h:new u(h));else{const h=A[s];u.fieldWrapper?u.typeName==="google.protobuf.BytesValue"?a[s]=As(h):a[s]=h:a[s]=Ar(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)=>wr(n.T,a,s[A]));case"enum":return i.every((a,A)=>wr(N.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&&!Ar(a)&&(a=n.T.fieldWrapper.wrapField(a)),A!==void 0&&!Ar(A)&&(A=n.T.fieldWrapper.wrapField(A))),n.T.equals(a,A);case"enum":return wr(N.INT32,i,s);case"scalar":return wr(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 wr(N.INT32,i.value,s.value);case"scalar":return wr(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=>wr(N.INT32,i[u],s[u]));case"scalar":const d=n.V.T;return c.every(u=>wr(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(ba);else if(s.kind=="map"){A=n[s.localName];for(const o of Object.entries(a)){var i=ie(o,2);const c=i[0],l=i[1];A[c]=ba(l)}}else s.kind=="oneof"?A=s.findField(a.case)?{case:a.case,value:ba(a.value)}:{case:void 0}:A=ba(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 ba(r){if(r===void 0)return r;if(Ar(r))return r.clone();if(r instanceof Uint8Array){const e=new Uint8Array(r.byteLength);return e.set(r),e}return r}function As(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function Tw(r,e,t){return{syntax:r,json:fw(),bin:yw(),util:Object.assign(Object.assign({},Sw()),{newFieldList:e,initFields:t}),makeMessageType(n,i,s){return Wy(this,n,i,s)},makeEnum:qy,makeEnumType:Mp,getEnumType:Gy,makeExtension(n,i,s){return Aw(this,n,i,s)}}}class kw{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 Gp(r,e){const t=qp(r);return e?t:Qw(Iw(t))}function xw(r){return Gp(r,!1)}const Ew=qp;function qp(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 Uw=new Set(["constructor","toString","toJSON","valueOf"]),Fw=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Wp=r=>"".concat(r,"$"),Iw=r=>Fw.has(r)?Wp(r):r,Qw=r=>Uw.has(r)?Wp(r):r;class Mw{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=xw(e)}addField(e){We(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 _w(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=Gp(l.name,l.oneof!==void 0),d.jsonName=(t=l.jsonName)!==null&&t!==void 0?t:Ew(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:Lr.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!=N.BYTES&&l.T!=N.STRING),l.oneof!==void 0){const u=typeof l.oneof=="string"?l.oneof:l.oneof.name;(!c||c.name!=u)&&(c=new Mw(u)),d.oneof=c,c.addField(d)}o.push(d)}return o}const Q=Tw("proto3",r=>new kw(r,e=>_w(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]=$i(e.T,e.L);break}}});class Ot extends Md{constructor(e){super(),this.seconds=Le.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=Le.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 Ot.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Ot({seconds:Le.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Ot().fromBinary(e,t)}static fromJson(e,t){return new Ot().fromJson(e,t)}static fromJsonString(e,t){return new Ot().fromJsonString(e,t)}static equals(e,t){return Q.util.equals(Ot,e,t)}}Ot.runtime=Q;Ot.typeName="google.protobuf.Timestamp";Ot.fields=Q.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const Rw=Q.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Ot},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:Pw,repeated:!0},{no:5,name:"events",kind:"message",T:Lw,repeated:!0}]),Pw=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:Dw,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),Dw=Q.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Ot},{no:3,name:"value",kind:"scalar",T:2}]),Lw=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:Ot},{no:7,name:"normalized_end_timestamp",kind:"message",T:Ot,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),$p=Q.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),vn=Q.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),nt=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"}]),Rd=Q.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),bs=Q.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),$s=Q.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),Sn=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"}]),Yr=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"}]),Ow=Q.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),ut=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"}]),Xi=Q.makeEnum("livekit.PacketTrailerFeature",[{no:0,name:"PTF_USER_TIMESTAMP"},{no:1,name:"PTF_FRAME_ID"}]),ho=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:MA,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:om}]),MA=Q.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),Hw=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(nt),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}]),pi=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(Pi)},{no:4,name:"tracks",kind:"message",T:Mi,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:Hw},{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(Xs)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:Q.getEnumType(Sn)},{no:18,name:"kind_details",kind:"enum",T:Q.getEnumType(Nw),repeated:!0},{no:19,name:"data_tracks",kind:"message",T:fo,repeated:!0},{no:20,name:"client_protocol",kind:"scalar",T:5}]),Pi=Q.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),Xs=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"}]),Nw=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"}]),Qe=Q.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),Kw=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:Mr,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:Q.getEnumType(Xp)},{no:6,name:"sdp_cid",kind:"scalar",T:9}]),Mi=Q.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:Q.getEnumType(vn)},{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(nt)},{no:10,name:"layers",kind:"message",T:Mr,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:Kw,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(Qe)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:om},{no:19,name:"audio_features",kind:"enum",T:Q.getEnumType(ut),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:Q.getEnumType($p)},{no:21,name:"packet_trailer_features",kind:"enum",T:Q.getEnumType(Xi),repeated:!0}]),fo=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(Qe)}]),Vw=Q.makeMessageType("livekit.DataTrackSubscriptionOptions",()=>[{no:1,name:"target_fps",kind:"scalar",T:13,opt:!0}]),Mr=Q.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:Q.getEnumType(Rd)},{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}]),Xp=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"}]),Ct=Q.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:Q.getEnumType(_r)},{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:Pd,oneof:"value"},{no:3,name:"speaker",kind:"message",T:zw,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:Zp,oneof:"value"},{no:7,name:"transcription",kind:"message",T:Gw,oneof:"value"},{no:8,name:"metrics",kind:"message",T:Rw,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:_A,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:Dd,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:po,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:Ld,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:RA,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:PA,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:DA,oneof:"value"},{no:18,name:"encrypted_packet",kind:"message",T:Jp,oneof:"value"},{no:16,name:"sequence",kind:"scalar",T:13},{no:17,name:"participant_sid",kind:"scalar",T:9}]),_r=Q.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),Jp=Q.makeMessageType("livekit.EncryptedPacket",()=>[{no:1,name:"encryption_type",kind:"enum",T:Q.getEnumType(Qe)},{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}]),jp=Q.makeMessageType("livekit.EncryptedPacketPayload",()=>[{no:1,name:"user",kind:"message",T:Pd,oneof:"value"},{no:3,name:"chat_message",kind:"message",T:_A,oneof:"value"},{no:4,name:"rpc_request",kind:"message",T:Dd,oneof:"value"},{no:5,name:"rpc_ack",kind:"message",T:po,oneof:"value"},{no:6,name:"rpc_response",kind:"message",T:Ld,oneof:"value"},{no:7,name:"stream_header",kind:"message",T:RA,oneof:"value"},{no:8,name:"stream_chunk",kind:"message",T:PA,oneof:"value"},{no:9,name:"stream_trailer",kind:"message",T:DA,oneof:"value"}]),zw=Q.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:Yp,repeated:!0}]),Yp=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}]),Pd=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}]),Zp=Q.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),Gw=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:qw,repeated:!0}]),qw=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}]),_A=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}]),Dd=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}]),po=Q.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),Ld=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:em,oneof:"value"},{no:4,name:"compressed_payload",kind:"scalar",T:12,oneof:"value"}]),em=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}]),tm=Q.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),nm=Q.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:Q.getEnumType(rm)},{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}]),rm=Q.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),im=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(am),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"}]),am=Q.makeEnum("livekit.ClientInfo.Capability",[{no:0,name:"CAP_UNUSED"},{no:1,name:"CAP_PACKET_TRAILER"}]),Am=Q.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:d0},{no:2,name:"screen",kind:"message",T:d0},{no:3,name:"resume_connection",kind:"enum",T:Q.getEnumType($s)},{no:4,name:"disabled_codecs",kind:"message",T:Ww},{no:5,name:"force_relay",kind:"enum",T:Q.getEnumType($s)}]),d0=Q.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:Q.getEnumType($s)}]),Ww=Q.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:MA,repeated:!0},{no:2,name:"publish",kind:"message",T:MA,repeated:!0}]),om=Q.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),bl=Q.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),cm=Q.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:Q.getEnumType(bl)},{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"}),lm=Q.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),RA=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(Qe)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:cm,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:lm,oneof:"content_header"}],{localName:"DataStream_Header"}),PA=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"}),DA=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"}),$w=Q.makeMessageType("livekit.SubscribedAudioCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"enabled",kind:"scalar",T:8}]),yn=Q.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),Bl=Q.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),Xw=Q.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),Jw=Q.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:Or,oneof:"message"},{no:2,name:"answer",kind:"message",T:Or,oneof:"message"},{no:3,name:"trickle",kind:"message",T:mo,oneof:"message"},{no:4,name:"add_track",kind:"message",T:Js,oneof:"message"},{no:5,name:"mute",kind:"message",T:go,oneof:"message"},{no:6,name:"subscription",kind:"message",T:vo,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:hm,oneof:"message"},{no:8,name:"leave",kind:"message",T:yo,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:pm,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:vm,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:qd,oneof:"message"},{no:13,name:"simulate",kind:"message",T:Mn,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:zd,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:bm,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:Vd,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:fm,oneof:"message"},{no:19,name:"publish_data_track_request",kind:"message",T:Od,oneof:"message"},{no:20,name:"unpublish_data_track_request",kind:"message",T:Nd,oneof:"message"},{no:21,name:"update_data_subscription",kind:"message",T:dm,oneof:"message"}]),u0=Q.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:eb,oneof:"message"},{no:2,name:"answer",kind:"message",T:Or,oneof:"message"},{no:3,name:"offer",kind:"message",T:Or,oneof:"message"},{no:4,name:"trickle",kind:"message",T:mo,oneof:"message"},{no:5,name:"update",kind:"message",T:rb,oneof:"message"},{no:6,name:"track_published",kind:"message",T:Kd,oneof:"message"},{no:8,name:"leave",kind:"message",T:yo,oneof:"message"},{no:9,name:"mute",kind:"message",T:go,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:ib,oneof:"message"},{no:11,name:"room_update",kind:"message",T:sb,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:Ab,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:cb,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:db,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:hb,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:nb,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:tb,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:pb,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:vb,oneof:"message"},{no:22,name:"request_response",kind:"message",T:yb,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:wb,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:fb,oneof:"message"},{no:25,name:"media_sections_requirement",kind:"message",T:Cb,oneof:"message"},{no:26,name:"subscribed_audio_codec_update",kind:"message",T:ub,oneof:"message"},{no:27,name:"publish_data_track_response",kind:"message",T:Hd,oneof:"message"},{no:28,name:"unpublish_data_track_response",kind:"message",T:jw,oneof:"message"},{no:29,name:"data_track_subscriber_handles",kind:"message",T:Yw,oneof:"message"}]),Cl=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:Mr,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:Q.getEnumType(Xp)}]),Js=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(vn)},{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(nt)},{no:9,name:"layers",kind:"message",T:Mr,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:Cl,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(Qe)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:Q.getEnumType($p)},{no:17,name:"audio_features",kind:"enum",T:Q.getEnumType(ut),repeated:!0},{no:18,name:"packet_trailer_features",kind:"enum",T:Q.getEnumType(Xi),repeated:!0}]),Od=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(Qe)}]),Hd=Q.makeMessageType("livekit.PublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:fo}]),Nd=Q.makeMessageType("livekit.UnpublishDataTrackRequest",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13}]),jw=Q.makeMessageType("livekit.UnpublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:fo}]),Yw=Q.makeMessageType("livekit.DataTrackSubscriberHandles",()=>[{no:1,name:"sub_handles",kind:"map",K:13,V:{kind:"message",T:Zw}}]),Zw=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"}),mo=Q.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:Q.getEnumType(yn)},{no:3,name:"final",kind:"scalar",T:8}]),go=Q.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),eb=Q.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:ho},{no:2,name:"participant",kind:"message",T:pi},{no:3,name:"other_participants",kind:"message",T:pi,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:mm,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:Am},{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:nm},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:MA,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),tb=Q.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:mm,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:Am},{no:3,name:"server_info",kind:"message",T:nm},{no:4,name:"last_message_seq",kind:"scalar",T:13}]),Kd=Q.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:Mi}]),nb=Q.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Or=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}}]),rb=Q.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:pi,repeated:!0}]),vo=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:tm,repeated:!0}]),dm=Q.makeMessageType("livekit.UpdateDataSubscription",()=>[{no:1,name:"updates",kind:"message",T:um,repeated:!0}]),um=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:Vw}],{localName:"UpdateDataSubscription_Update"}),hm=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(Rd)},{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}]),Vd=Q.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:Q.getEnumType(ut),repeated:!0}]),fm=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}]),yo=Q.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:Q.getEnumType(Sn)},{no:3,name:"action",kind:"enum",T:Q.getEnumType(Di)},{no:4,name:"regions",kind:"message",T:mb}]),Di=Q.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),pm=Q.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:Mr,repeated:!0}]),zd=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}]),mm=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}]),ib=Q.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:Yp,repeated:!0}]),sb=Q.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:ho}]),ab=Q.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:Q.getEnumType(bs)},{no:3,name:"score",kind:"scalar",T:2}]),Ab=Q.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:ab,repeated:!0}]),ob=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(Bl)}]),cb=Q.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:ob,repeated:!0}]),Gd=Q.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:Q.getEnumType(Rd)},{no:2,name:"enabled",kind:"scalar",T:8}]),lb=Q.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:Gd,repeated:!0}]),db=Q.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:Gd,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:lb,repeated:!0}]),ub=Q.makeMessageType("livekit.SubscribedAudioCodecUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_audio_codecs",kind:"message",T:$w,repeated:!0}]),gm=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}]),vm=Q.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:gm,repeated:!0}]),hb=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}]),fb=Q.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:ho},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:pi},{no:4,name:"other_participants",kind:"message",T:pi,repeated:!0}]),qd=Q.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:Or},{no:2,name:"subscription",kind:"message",T:vo},{no:3,name:"publish_tracks",kind:"message",T:Kd,repeated:!0},{no:4,name:"data_channels",kind:"message",T:wm,repeated:!0},{no:5,name:"offer",kind:"message",T:Or},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0},{no:7,name:"datachannel_receive_states",kind:"message",T:ym,repeated:!0},{no:8,name:"publish_data_tracks",kind:"message",T:Hd,repeated:!0}]),ym=Q.makeMessageType("livekit.DataChannelReceiveState",()=>[{no:1,name:"publisher_sid",kind:"scalar",T:9},{no:2,name:"last_seq",kind:"scalar",T:13}]),wm=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(yn)}]),Mn=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(Xw),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"}]),bm=Q.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),pb=Q.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),mb=Q.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:gb,repeated:!0}]),gb=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}]),vb=Q.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:Q.getEnumType(Ow)}]),yb=Q.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:Q.getEnumType(ei)},{no:3,name:"message",kind:"scalar",T:9},{no:4,name:"trickle",kind:"message",T:mo,oneof:"request"},{no:5,name:"add_track",kind:"message",T:Js,oneof:"request"},{no:6,name:"mute",kind:"message",T:go,oneof:"request"},{no:7,name:"update_metadata",kind:"message",T:zd,oneof:"request"},{no:8,name:"update_audio_track",kind:"message",T:Vd,oneof:"request"},{no:9,name:"update_video_track",kind:"message",T:fm,oneof:"request"},{no:10,name:"publish_data_track",kind:"message",T:Od,oneof:"request"},{no:11,name:"unpublish_data_track",kind:"message",T:Nd,oneof:"request"}]),ei=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"}]),wb=Q.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Bm=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}]),bb=Q.makeMessageType("livekit.JoinRequest",()=>[{no:1,name:"client_info",kind:"message",T:im},{no:2,name:"connection_settings",kind:"message",T:Bm},{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:Js,repeated:!0},{no:6,name:"publisher_offer",kind:"message",T:Or},{no:7,name:"reconnect",kind:"scalar",T:8},{no:8,name:"reconnect_reason",kind:"enum",T:Q.getEnumType(Yr)},{no:9,name:"participant_sid",kind:"scalar",T:9},{no:10,name:"sync_state",kind:"message",T:qd}]),Bb=Q.makeMessageType("livekit.WrappedJoinRequest",()=>[{no:1,name:"compression",kind:"enum",T:Q.getEnumType(Sl)},{no:2,name:"join_request",kind:"scalar",T:12}]),Sl=Q.makeEnum("livekit.WrappedJoinRequest.Compression",[{no:0,name:"NONE"},{no:1,name:"GZIP"}]),Cb=Q.makeMessageType("livekit.MediaSectionsRequirement",()=>[{no:1,name:"num_audios",kind:"scalar",T:13},{no:2,name:"num_videos",kind:"scalar",T:13}]);function Sb(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var oA={exports:{}},Tb=oA.exports,h0;function kb(){return h0||(h0=1,function(r){(function(e,t){r.exports?r.exports=t():e.log=t()})(Tb,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,y){var b=g[y];if(typeof b.bind=="function")return b.bind(g);try{return Function.prototype.bind.call(b,g)}catch{return function(){return Function.prototype.apply.apply(b,[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(),y=0;y<i.length;y++){var b=i[y];this[b]=y<g?e:this.methodFactory(b,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,y,b){return c(g)||d.apply(this,arguments)}function h(g,y){var b=this,B,U,w,C="loglevel";typeof g=="string"?C+=":"+g:typeof g=="symbol"&&(C=void 0);function E(O){var q=(i[O]||"silent").toUpperCase();if(!(typeof window===t||!C)){try{window.localStorage[C]=q;return}catch{}try{window.document.cookie=encodeURIComponent(C)+"="+q+";"}catch{}}}function I(){var O;if(!(typeof window===t||!C)){try{O=window.localStorage[C]}catch{}if(typeof O===t)try{var q=window.document.cookie,ue=encodeURIComponent(C),ce=q.indexOf(ue+"=");ce!==-1&&(O=/^([^;]+)/.exec(q.slice(ce+ue.length+1))[1])}catch{}return b.levels[O]===void 0&&(O=void 0),O}}function _(){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 P(O){var q=O;if(typeof q=="string"&&b.levels[q.toUpperCase()]!==void 0&&(q=b.levels[q.toUpperCase()]),typeof q=="number"&&q>=0&&q<=b.levels.SILENT)return q;throw new TypeError("log.setLevel() called with invalid level: "+O)}b.name=g,b.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},b.methodFactory=y||u,b.getLevel=function(){return w??U??B},b.setLevel=function(O,q){return w=P(O),q!==!1&&E(w),l.call(b)},b.setDefaultLevel=function(O){U=P(O),I()||b.setLevel(O,!1)},b.resetLevel=function(){w=null,_(),l.call(b)},b.enableAll=function(O){b.setLevel(b.levels.TRACE,O)},b.disableAll=function(O){b.setLevel(b.levels.SILENT,O)},b.rebuild=function(){if(a!==b&&(B=P(a.getLevel())),l.call(b),a===b)for(var O in s)s[O].rebuild()},B=P(a?a.getLevel():"WARN");var L=I();L!=null&&(w=P(L)),l.call(b)}a=new h,a.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var b=s[y];return b||(b=s[y]=new h(y,a.methodFactory)),b};var m=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=m),a},a.getLoggers=function(){return s},a.default=a,a})}(oA)),oA.exports}var wo=kb(),Tl;(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"})(Tl||(Tl={}));var pt;(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"})(pt||(pt={}));let fe=wo.getLogger(pt.Default);Object.values(pt).map(r=>wo.getLogger(r));fe.setDefaultLevel(Tl.info);function Kt(r,e){const t=wo.getLogger(r);return t.setDefaultLevel(fe.getLevel()),e?xb(t,e):t}function xb(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 Eb=wo.getLogger(pt.E2EE),os=7e3,Ub=[0,300,2*2*300,3*3*300,4*4*300,os,os,os,os,os];class Fb{constructor(e){this._retryDelays=e!==void 0?[...e]:Ub}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 Ib(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 T(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 f0(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 Ji(r){return this instanceof Ji?(this.v=r,this):new Ji(r)}function Qb(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(m){return Promise.resolve(m).then(h,d)}}function A(h,m){n[h]&&(i[h]=function(g){return new Promise(function(y,b){s.push([h,g,y,b])>1||o(h,g)})},m&&(i[h]=m(i[h])))}function o(h,m){try{c(n[h](m))}catch(g){u(s[0][3],g)}}function c(h){h.value instanceof Ji?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,m){h(m),s.shift(),s.length&&o(s[0][0],s[0][1])}}function Mb(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:Ji(r[i](a)),done:!1}:s?s(a):a}:s}}function wn(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 f0=="function"?f0(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 Ba={exports:{}},p0;function _b(){if(p0)return Ba.exports;p0=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(C,E,I){return Function.prototype.apply.call(C,E,I)},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(w){}var i=Number.isNaN||function(C){return C!==C};function s(){s.init.call(this)}Ba.exports=s,Ba.exports.once=b,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function A(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(w){if(typeof w!="number"||w<0||i(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");a=w}}),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(w){return w._maxListeners===void 0?s.defaultMaxListeners:w._maxListeners}s.prototype.getMaxListeners=function(){return o(this)},s.prototype.emit=function(C){for(var E=[],I=1;I<arguments.length;I++)E.push(arguments[I]);var _=C==="error",P=this._events;if(P!==void 0)_=_&&P.error===void 0;else if(!_)return!1;if(_){var L;if(E.length>0&&(L=E[0]),L instanceof Error)throw L;var O=new Error("Unhandled error."+(L?" ("+L.message+")":""));throw O.context=L,O}var q=P[C];if(q===void 0)return!1;if(typeof q=="function")e(q,this,E);else for(var ue=q.length,ce=m(q,ue),I=0;I<ue;++I)e(ce[I],this,E);return!0};function c(w,C,E,I){var _,P,L;if(A(E),P=w._events,P===void 0?(P=w._events=Object.create(null),w._eventsCount=0):(P.newListener!==void 0&&(w.emit("newListener",C,E.listener?E.listener:E),P=w._events),L=P[C]),L===void 0)L=P[C]=E,++w._eventsCount;else if(typeof L=="function"?L=P[C]=I?[E,L]:[L,E]:I?L.unshift(E):L.push(E),_=o(w),_>0&&L.length>_&&!L.warned){L.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+L.length+" "+String(C)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=w,O.type=C,O.count=L.length}return w}s.prototype.addListener=function(C,E){return c(this,C,E,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(C,E){return c(this,C,E,!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(w,C,E){var I={fired:!1,wrapFn:void 0,target:w,type:C,listener:E},_=l.bind(I);return _.listener=E,I.wrapFn=_,_}s.prototype.once=function(C,E){return A(E),this.on(C,d(this,C,E)),this},s.prototype.prependOnceListener=function(C,E){return A(E),this.prependListener(C,d(this,C,E)),this},s.prototype.removeListener=function(C,E){var I,_,P,L,O;if(A(E),_=this._events,_===void 0)return this;if(I=_[C],I===void 0)return this;if(I===E||I.listener===E)--this._eventsCount===0?this._events=Object.create(null):(delete _[C],_.removeListener&&this.emit("removeListener",C,I.listener||E));else if(typeof I!="function"){for(P=-1,L=I.length-1;L>=0;L--)if(I[L]===E||I[L].listener===E){O=I[L].listener,P=L;break}if(P<0)return this;P===0?I.shift():g(I,P),I.length===1&&(_[C]=I[0]),_.removeListener!==void 0&&this.emit("removeListener",C,O||E)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(C){var E,I,_;if(I=this._events,I===void 0)return this;if(I.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):I[C]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete I[C]),this;if(arguments.length===0){var P=Object.keys(I),L;for(_=0;_<P.length;++_)L=P[_],L!=="removeListener"&&this.removeAllListeners(L);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(E=I[C],typeof E=="function")this.removeListener(C,E);else if(E!==void 0)for(_=E.length-1;_>=0;_--)this.removeListener(C,E[_]);return this};function u(w,C,E){var I=w._events;if(I===void 0)return[];var _=I[C];return _===void 0?[]:typeof _=="function"?E?[_.listener||_]:[_]:E?y(_):m(_,_.length)}s.prototype.listeners=function(C){return u(this,C,!0)},s.prototype.rawListeners=function(C){return u(this,C,!1)},s.listenerCount=function(w,C){return typeof w.listenerCount=="function"?w.listenerCount(C):h.call(w,C)},s.prototype.listenerCount=h;function h(w){var C=this._events;if(C!==void 0){var E=C[w];if(typeof E=="function")return 1;if(E!==void 0)return E.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function m(w,C){for(var E=new Array(C),I=0;I<C;++I)E[I]=w[I];return E}function g(w,C){for(;C+1<w.length;C++)w[C]=w[C+1];w.pop()}function y(w){for(var C=new Array(w.length),E=0;E<C.length;++E)C[E]=w[E].listener||w[E];return C}function b(w,C){return new Promise(function(E,I){function _(L){w.removeListener(C,P),I(L)}function P(){typeof w.removeListener=="function"&&w.removeListener("error",_),E([].slice.call(arguments))}U(w,C,P,{once:!0}),C!=="error"&&B(w,_,{once:!0})})}function B(w,C,E){typeof w.on=="function"&&U(w,"error",C,E)}function U(w,C,E,I){if(typeof w.on=="function")I.once?w.once(C,E):w.on(C,E);else if(typeof w.addEventListener=="function")w.addEventListener(C,function _(P){I.once&&w.removeEventListener(C,_),E(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return Ba.exports}var zt=_b();let Cm=!0,Rb=!0;function Bs(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseFloat(n[t],10)}function vi(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 Pb(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Cm=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function Db(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Rb=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function Sm(){}function Lb(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(Bs(t.userAgent,/Firefox\/(\d+)\./,1));else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection)e.browser="chrome",e.version=parseInt(Bs(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2))||null;else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=parseInt(Bs(t.userAgent,/AppleWebKit\/(\d+)\./,1)),e.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype,e._safariVersion=Bs(t.userAgent,/Version\/(\d+(\.?\d+))/,1);else return e.browser="Not a supported browser.",e;return e}function m0(r){return Object.prototype.toString.call(r)==="[object Object]"}function Tm(r){return m0(r)?Object.keys(r).reduce(function(e,t){const n=m0(r[t]),i=n?Tm(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function kl(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?kl(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{kl(r,r.get(i),t)})}))}function g0(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&&kl(r,A,i)})}),i}const v0=Sm;function km(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(m=>m.kind==="videoinput");let h=u.find(m=>d.some(g=>m.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),v0("chrome: "+JSON.stringify(A)),o(A)})}A.video=n(A.video)}return v0("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 xm(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function Em(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 vi(r,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function Um(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 Fm(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=>g0(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}),vi(r,"track",i=>(i.receiver._pc=i.srcElement,i)),r.RTCRtpReceiver.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>g0(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 Im(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 Qm(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Im(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 m=this._streams[d.id];if(m)m.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],m=c._streams[h.id];d=d.replace(new RegExp(m.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],m=c._streams[h.id];d=d.replace(new RegExp(h.id,"g"),m.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,[m=>{const g=s(this,m);u[0].apply(null,[g])},m=>{u[1]&&u[1].apply(null,m)},arguments[2]]):l.apply(this,arguments).then(m=>s(this,m))}};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 xl(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 Mm(r,e){e.version>102||vi(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}var y0=Object.freeze({__proto__:null,fixNegotiationNeeded:Mm,shimAddTrackRemoveTrack:Qm,shimAddTrackRemoveTrackWithNative:Im,shimGetSendersWithDtmf:Um,shimGetUserMedia:km,shimMediaStream:xm,shimOnTrack:Em,shimPeerConnection:xl,shimSenderReceiverGetStats:Fm});function _m(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 Ob(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 Rm(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 El(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 Pm(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 Dm(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 Lm(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}),vi(r,"track",t=>(t.receiver._pc=t.srcElement,t)),r.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Om(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 Hm(r){r.DataChannel&&!r.RTCDataChannel&&(r.RTCDataChannel=r.DataChannel)}function Nm(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 Km(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 Vm(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 zm(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 w0=Object.freeze({__proto__:null,shimAddTransceiver:Nm,shimCreateAnswer:zm,shimCreateOffer:Vm,shimGetDisplayMedia:Ob,shimGetParameters:Km,shimGetStats:Pm,shimGetUserMedia:_m,shimOnTrack:Rm,shimPeerConnection:El,shimRTCDataChannel:Hm,shimReceiverGetStats:Lm,shimRemoveStream:Om,shimSenderGetStats:Dm});function Gm(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 qm(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 Wm(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 $m(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(Xm(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(n,i,s){e.mediaDevices.getUserMedia(n).then(i,s)}).bind(e))}function Xm(r){return r&&r.video!==void 0?Object.assign({},r,{video:Tm(r.video)}):r}function Jm(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 jm(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 Ym(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 Zm(r){typeof r!="object"||r.AudioContext||(r.AudioContext=r.webkitAudioContext)}var b0=Object.freeze({__proto__:null,shimAudioContext:Zm,shimCallbacksAPI:Wm,shimConstraints:Xm,shimCreateOfferLegacy:Ym,shimGetUserMedia:$m,shimLocalStreamsAPI:Gm,shimRTCIceServerUrls:Jm,shimRemoteStreamsAPI:qm,shimTrackEventTransceiver:jm}),cc={exports:{}},B0;function Hb(){return B0||(B0=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(m=>parseInt(m,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}(cc)),cc.exports}var eg=Hb(),Li=Sb(eg),Nb=Dy({__proto__:null,default:Li},[eg]);function cA(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=Li.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,vi(r,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new r.RTCIceCandidate(t.candidate),writable:"false"}),t))}function Ul(r){!r.RTCIceCandidate||r.RTCIceCandidate&&"relayProtocol"in r.RTCIceCandidate.prototype||vi(r,"icecandidate",e=>{if(e.candidate){const t=Li.parseCandidate(e.candidate.candidate);t.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e})}function lA(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=Li.splitSections(A.sdp);return o.shift(),o.some(c=>{const l=Li.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=Li.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 dA(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},vi(r,"datachannel",i=>(t(i.channel,i.target),i))}function Fl(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 Il(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 uA(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 hA(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 Kb=Object.freeze({__proto__:null,removeExtmapAllowMixed:Il,shimAddIceCandidateNullOrEmpty:uA,shimConnectionState:Fl,shimMaxMessageSize:lA,shimParameterlessSetLocalDescription:hA,shimRTCIceCandidate:cA,shimRTCIceCandidateRelayProtocol:Ul,shimSendThrowTypeError:dA});function Vb(){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=Sm,i=Lb(e),s={browserDetails:i,commonShim:Kb,extractVersion:Bs,disableLog:Pb,disableWarnings:Db,sdp:Nb};switch(i.browser){case"chrome":if(!y0||!xl||!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=y0,uA(e,i),hA(e),km(e,i),xm(e),xl(e,i),Em(e,i),Qm(e,i),Um(e),Fm(e,i),Mm(e,i),cA(e),Ul(e),Fl(e),lA(e,i),dA(e,i),Il(e,i);break;case"firefox":if(!w0||!El||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),s;n("adapter.js shimming firefox."),s.browserShim=w0,uA(e,i),hA(e),_m(e,i),El(e,i),Pm(e,i),Rm(e),Om(e),Dm(e),Lm(e),Hm(e),Nm(e),Km(e),Vm(e),zm(e),cA(e),Fl(e),lA(e,i),dA(e,i);break;case"safari":if(!b0||!t.shimSafari)return n("Safari shim is not included in this adapter release."),s;n("adapter.js shimming safari."),s.browserShim=b0,uA(e,i),hA(e),Jm(e),Ym(e),Wm(e),Gm(e),qm(e),jm(e),$m(e),Zm(e),cA(e),Ul(e),lA(e,i),dA(e,i),Il(e,i);break;default:n("Unsupported browser!");break}return s}Vb({window:typeof window>"u"?void 0:window});var Ql,tg;class Ft extends(tg=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)}}Ql=Ft;Ft.resolve=r=>Reflect.get(tg,"resolve",Ql).call(Ql,r);const zb=/version\/(\d+(\.?_?\d+)+)/i;let lc;function Qt(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof navigator>"u")return;const t=navigator.userAgent.toLowerCase();if(lc===void 0||e){const n=Gb.find(i=>i.test.test(t));lc=n==null?void 0:n.describe(t)}return lc}const Gb=[{test:/firefox|iceweasel|fxios/i,describe(r){return{name:"Firefox",version:fA(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,r),os:r.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:dc(r)}}},{test:/chrom|crios|crmo/i,describe(r){return{name:"Chrome",version:fA(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,r),os:r.toLowerCase().includes("crios")?"iOS":void 0,osVersion:dc(r)}}},{test:/safari|applewebkit/i,describe(r){return{name:"Safari",version:fA(zb,r),os:r.includes("mobile/")?"iOS":"macOS",osVersion:dc(r)}}}];function fA(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 dc(r){return r.includes("mac os")?fA(/\(.+?(\d+_\d+(:?_\d+)?)/,r,1).replace(/_/g,"."):void 0}var qb="2.20.0";const Wb=qb,$b=17,ng=0,LA=1,Xb=LA;class mr 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 dn extends mr{}var Ie;(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"})(Ie||(Ie={}));class se extends dn{constructor(e,t,n,i){super(1,e),this.name="ConnectionError",this.status=n,this.reason=t,this.context=i,this.reasonName=Ie[t]}static notAllowed(e,t,n){return new se(e,Ie.NotAllowed,t,n)}static timeout(e){return new se(e,Ie.Timeout)}static leaveRequest(e,t){return new se(e,Ie.LeaveRequest,void 0,t)}static internal(e,t){return new se(e,Ie.InternalError,void 0,t)}static cancelled(e){return new se(e,Ie.Cancelled)}static serverUnreachable(e,t){return new se(e,Ie.ServerUnreachable,t)}static websocket(e,t,n){return new se(e,Ie.WebSocket,t,n)}static serviceNotFound(e,t){return new se(e,Ie.ServiceNotFound,void 0,t)}}class Wd extends mr{constructor(e){super(21,e??"device is unsupported"),this.name="DeviceUnsupportedError"}}class or extends mr{constructor(e){super(20,e??"track is invalid"),this.name="TrackInvalidError"}}class Jb extends mr{constructor(e){super(10,e??"unsupported server"),this.name="UnsupportedServer"}}class Ke extends mr{constructor(e){super(12,e??"unexpected connection state"),this.name="UnexpectedConnectionState"}}class ci extends mr{constructor(e){super(13,e??"unable to negotiate"),this.name="NegotiationError"}}class jb extends mr{constructor(e){super(14,e??"unable to publish data"),this.name="PublishDataError"}}class C0 extends mr{constructor(e,t){super(15,e),this.name="PublishTrackError",this.status=t}}class S0 extends dn{constructor(e,t){super(15,e),this.name="SignalRequestError",this.reason=t,this.reasonName=typeof t=="string"?t:ei[t]}}var Et;(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"})(Et||(Et={}));class tn extends dn{constructor(e,t){super(16,e),this.name="DataStreamError",this.reason=t,this.reasonName=Et[t]}}class Ci extends mr{constructor(e){super(18,e),this.name="SignalReconnectError"}}var OA;(function(r){r.PermissionDenied="PermissionDenied",r.NotFound="NotFound",r.DeviceInUse="DeviceInUse",r.Other="Other"})(OA||(OA={}));(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})(OA||(OA={}));class it{}it.setTimeout=function(){return setTimeout(...arguments)};it.setInterval=function(){return setInterval(...arguments)};it.clearTimeout=function(){return clearTimeout(...arguments)};it.clearInterval=function(){return clearInterval(...arguments)};var K;(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"})(K||(K={}));var J;(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"})(J||(J={}));var z;(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"})(z||(z={}));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 Yb(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 Ue{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 Zb=["vp8","h264"],e4=["vp8","h264","vp9","av1","h265"];function rg(r){return!!Zb.find(e=>e===r)}const t4=rg;var T0;(function(r){r[r.PREFER_REGRESSION=0]="PREFER_REGRESSION",r[r.SIMULCAST=1]="SIMULCAST",r[r.REGRESSION=2]="REGRESSION"})(T0||(T0={}));var Ml;(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}})(Ml||(Ml={}));const js={h90:new Ue(160,90,9e4,20),h180:new Ue(320,180,16e4,20),h216:new Ue(384,216,18e4,20),h360:new Ue(640,360,45e4,20),h540:new Ue(960,540,8e5,25),h720:new Ue(1280,720,17e5,30),h1080:new Ue(1920,1080,3e6,30),h1440:new Ue(2560,1440,5e6,30),h2160:new Ue(3840,2160,8e6,30)},_l={h120:new Ue(160,120,7e4,20),h180:new Ue(240,180,125e3,20),h240:new Ue(320,240,14e4,20),h360:new Ue(480,360,33e4,20),h480:new Ue(640,480,5e5,20),h540:new Ue(720,540,6e5,25),h720:new Ue(960,720,13e5,30),h1080:new Ue(1440,1080,23e5,30),h1440:new Ue(1920,1440,38e5,30)},$d={h360fps3:new Ue(640,360,2e5,3,"medium"),h360fps15:new Ue(640,360,4e5,15,"medium"),h720fps5:new Ue(1280,720,8e5,5,"medium"),h720fps15:new Ue(1280,720,15e5,15,"medium"),h720fps30:new Ue(1280,720,2e6,30,"medium"),h1080fps15:new Ue(1920,1080,25e5,15,"medium"),h1080fps30:new Ue(1920,1080,5e6,30,"medium"),original:new Ue(0,0,7e6,30,"medium")};function ig(r,e,t){var n,i,s,a;const A=Ag(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&&(Rl(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&&(Rl(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 Rl(r,e){return Object.keys(e).forEach(t=>{r[t]===void 0&&(r[t]=e[t])}),r}function Xd(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":Rl(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 T(this,arguments,void 0,function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return function*(){const n=ag();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 Tt(t),i.getByteTimeDomainData(a);const o=a.some(c=>c!==128&&c!==0);return n.close(),!o}return!1}()})}function ag(){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=()=>T(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 n4(r){return r==="audioinput"?H.Source.Microphone:r==="videoinput"?H.Source.Camera:H.Source.Unknown}function Pl(r){return r===H.Source.Microphone?"audioinput":r===H.Source.Camera?"videoinput":void 0}function r4(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,gi()?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 Rs(r){return r.split("/")[1].toLowerCase()}function i4(r){const e=[];return r.forEach(t=>{t.track!==void 0&&e.push(new Kd({cid:t.track.mediaStreamID,track:t.trackInfo}))}),e}function ve(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?ve(r.track):{})}}function s4(){return typeof RTCRtpReceiver<"u"&&typeof RTCRtpReceiver.prototype.getSynchronizationSources=="function"}function a4(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 Ag(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:Yb(e)}}function A4(r){switch(r){case nt.CAMERA:return H.Source.Camera;case nt.MICROPHONE:return H.Source.Microphone;case nt.SCREEN_SHARE:return H.Source.ScreenShare;case nt.SCREEN_SHARE_AUDIO:return H.Source.ScreenShareAudio;default:return H.Source.Unknown}}function k0(r,e){return r.width*r.height<e.width*e.height}function o4(r,e){var t;return(t=r.layers)===null||t===void 0?void 0:t.find(n=>n.quality===e)}const c4=5e3,cs=[];var Xt;(function(r){r[r.LOW=0]="LOW",r[r.MEDIUM=1]="MEDIUM",r[r.HIGH=2]="HIGH"})(Xt||(Xt={}));class H extends zt.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=H.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=fe,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),c4):this.handleAppVisibilityChanged()},this.log=Kt((i=n.loggerName)!==null&&i!==void 0?i:pt.Track),this.loggerContextCb=n.loggerContextCb,this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=H.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),ve(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let t="audio";this.kind===H.Kind.Video&&(t="video"),this.attachedElements.length===0&&this.kind===H.Kind.Video&&this.addAppVisibilityListener(),e||(t==="audio"&&(cs.forEach(s=>{s.parentElement===null&&!e&&(e=s)}),e&&cs.splice(cs.indexOf(e),1)),e||(e=document.createElement(t))),this.attachedElements.includes(e)||this.attachedElements.push(e),_i(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"?fe.debug("".concat(i?"audio":"video"," playback aborted, likely due to new play request")):fe.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){Oi(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=>{Oi(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=Kt(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),cs.forEach(n=>{n.parentElement||(t=!1)}),t&&cs.push(e)}}handleAppVisibilityChanged(){return T(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===H.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){Ht()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){Ht()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function _i(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)),(!gi()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=t.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==t&&(e.srcObject=t,(gi()||mi())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=t,e.play().catch(()=>{})},0))}function Oi(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 vn.AUDIO;case e.Video:return vn.VIDEO;default:return vn.DATA}}r.kindToProto=i;function s(c){switch(c){case vn.AUDIO:return e.Audio;case vn.VIDEO:return e.Video;default:return e.Unknown}}r.kindFromProto=s;function a(c){switch(c){case t.Camera:return nt.CAMERA;case t.Microphone:return nt.MICROPHONE;case t.ScreenShare:return nt.SCREEN_SHARE;case t.ScreenShareAudio:return nt.SCREEN_SHARE_AUDIO;default:return nt.UNKNOWN}}r.sourceToProto=a;function A(c){switch(c){case nt.CAMERA:return t.Camera;case nt.MICROPHONE:return t.Microphone;case nt.SCREEN_SHARE:return t.ScreenShare;case nt.SCREEN_SHARE_AUDIO:return t.ScreenShareAudio;default:return t.Unknown}}r.sourceFromProto=A;function o(c){switch(c){case Bl.ACTIVE:return n.Active;case Bl.PAUSED:return n.Paused;default:return n.Unknown}}r.streamStateFromProto=o})(H||(H={}));const l4="|",x0="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function d4(r){const e=r.split(l4);return e.length>1?[e[0],r.substr(e[0].length+1)]:[r,""]}function Tt(r){return new Ft(e=>it.setTimeout(e,r))}function Dl(){return"addTransceiver"in RTCPeerConnection.prototype}function Ll(){return"addTrack"in RTCPeerConnection.prototype}function u4(){if(!("getCapabilities"in RTCRtpSender)||gi()||mi())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 h4(){if(!("getCapabilities"in RTCRtpSender)||mi())return!1;if(gi()){const t=Qt();if(t!=null&&t.version&&Vn(t.version,"16")<0||(t==null?void 0:t.os)==="iOS"&&(t!=null&&t.osVersion)&&Vn(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 bn(r){return r==="av1"||r==="vp9"}function Ol(r){return!document||Ys()?!1:(r||(r=document.createElement("audio")),"setSinkId"in r)}function f4(){return typeof RTCPeerConnection>"u"?!1:Dl()||Ll()}function mi(){var r;return((r=Qt())===null||r===void 0?void 0:r.name)==="Firefox"}function p4(){const r=Qt();return!!r&&r.name==="Chrome"&&r.os!=="iOS"}function Hl(){return typeof window<"u"&&typeof window.RTCRtpScriptTransform<"u"&&!p4()}function gi(){var r;return((r=Qt())===null||r===void 0?void 0:r.name)==="Safari"}function Ys(){const r=Qt();return(r==null?void 0:r.name)==="Safari"||(r==null?void 0:r.os)==="iOS"}function m4(){const r=Qt();return(r==null?void 0:r.name)==="Safari"&&r.version.startsWith("17.")||(r==null?void 0:r.os)==="iOS"&&!!(r!=null&&r.osVersion)&&Vn(r.osVersion,"17")>=0}function g4(r){return r||(r=Qt()),(r==null?void 0:r.name)==="Safari"&&Vn(r.version,"18.3")>0||(r==null?void 0:r.os)==="iOS"&&!!(r!=null&&r.osVersion)&&Vn(r.osVersion,"18.3")>0}function og(){var r,e;return Ht()?(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 v4(){const r=Qt(),e="17.2";if(r)return r.name!=="Safari"&&r.os!=="iOS"||r.os==="iOS"&&r.osVersion&&Vn(r.osVersion,e)>=0?!0:r.name==="Safari"&&Vn(r.version,e)>=0}function Ht(){return typeof document<"u"}function xn(){return navigator.product=="ReactNative"}function ji(r){return r.hostname.endsWith(".livekit.cloud")||r.hostname.endsWith(".livekit.run")}function uc(r){return ji(r)?r.hostname.split(".")[0]:null}function cg(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function lg(){if(!xn())return;let r=cg();if(r)return r.platform}function E0(){if(Ht())return window.devicePixelRatio;if(xn()){let r=cg();if(r)return r.devicePixelRatio}return 1}function Vn(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 y4(r){for(const e of r)e.target.handleResize(e)}function w4(r){for(const e of r)e.target.handleVisibilityChanged(e)}let hc=null;const U0=()=>(hc||(hc=new ResizeObserver(y4)),hc);let fc=null;const F0=()=>(fc||(fc=new IntersectionObserver(w4,{root:null,rootMargin:"0px"})),fc);function b4(r){var e;const t=new im({capabilities:r,sdk:sm.JS,protocol:$b,clientProtocol:Xb,version:Wb});return xn()&&(t.os=(e=lg())!==null&&e!==void 0?e:""),t}function I0(){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=ie(A,1),c=o[0];if(!c)throw Error("Could not get empty media stream video track");return c.enabled=t,c}let ls;function pc(){if(!ls){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=ie(r,1);if(ls=e[0],!ls)throw Error("Could not get empty media stream audio track");ls.enabled=!1}return ls.clone()}class ft{get isResolved(){return this._isResolved}constructor(e,t){this._isResolved=!1,this.onFinally=t,this.promise=new Promise((n,i)=>T(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 B4(r){return e4.includes(r)}function li(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 C4(r){return r.startsWith("http")?r.replace(/^(http)/,"ws"):r}function Zs(r){return r.startsWith("ws")?r.replace(/^(ws)/,"http"):r}function S4(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 T4(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 Q0(r){switch(r.reason){case Ie.LeaveRequest:return r.context;case Ie.Cancelled:return Sn.CLIENT_INITIATED;case Ie.NotAllowed:return Sn.USER_REJECTED;case Ie.ServerUnreachable:return Sn.JOIN_FAILURE;default:return Sn.UNKNOWN_REASON}}function pA(r){return r!==void 0?Number(r):void 0}function Zr(r){return r!==void 0?BigInt(r):void 0}function Hi(r){return!!r&&!(r instanceof MediaStreamTrack)&&r.isLocal}function Hn(r){return!!r&&r.kind==H.Kind.Audio}function ur(r){return!!r&&r.kind==H.Kind.Video}function Fn(r){return Hi(r)&&ur(r)}function er(r){return Hi(r)&&Hn(r)}function Nl(r){return!!r&&!r.isLocal}function k4(r){return!!r&&!r.isLocal}function mc(r){return Nl(r)&&ur(r)}function x4(r){return r.isLocal}function E4(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 U4(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 dg(){return typeof CompressionStream<"u"}function F4(){return dg()&&!mi()}function I4(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const n=Q4(r,e);return t?n:Jd(n,"v1")}function Q4(r,e){const t=new URL(C4(r));return e.forEach((n,i)=>{t.searchParams.set(i,n)}),Jd(t,"rtc")}function M4(r){const e=new URL(Zs(r));return Jd(e,"validate")}function ug(r){return r.endsWith("/")?r:"".concat(r,"/")}function Jd(r,e){return r.pathname="".concat(ug(r.pathname)).concat(e),r}function M0(r){if(typeof r=="string")return u0.fromJson(JSON.parse(r),{ignoreUnknownFields:!0});if(r instanceof ArrayBuffer)return u0.fromBinary(new Uint8Array(r));throw new Error("could not decode websocket message: ".concat(typeof r))}function _4(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 R4=10,ds="lk_e2ee",P4="LKFrameEncryptionKey",D4={sharedKey:!1,ratchetSalt:P4,ratchetWindowSize:8,failureTolerance:R4,keyringSize:16,keySize:128};var Rr;(function(r){r.SetKey="setKey",r.RatchetRequest="ratchetRequest",r.KeyRatcheted="keyRatcheted"})(Rr||(Rr={}));var _0;(function(r){r.KeyRatcheted="keyRatcheted"})(_0||(_0={}));var Ur;(function(r){r.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",r.EncryptionError="encryptionError"})(Ur||(Ur={}));var R0;(function(r){r.Error="cryptorError"})(R0||(R0={}));function L4(){return jd()||O4()}function O4(){return typeof window<"u"&&typeof window.RTCRtpScriptTransform<"u"}function jd(){return typeof window<"u"&&typeof window.RTCRtpSender<"u"&&typeof window.RTCRtpSender.prototype.createEncodedStreams<"u"}function H4(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 jp({value:r.value})}class sU extends zt.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.latestManuallySetKeyIndex=0,this.onKeyRatcheted=(t,n,i)=>{fe.debug("key ratcheted event received",{ratchetResult:t,participantId:n,keyIndex:i})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},D4),e),this.on(Rr.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(Rr.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(Rr.RatchetRequest,e,t)}}var P0;(function(r){r[r.InvalidKey=0]="InvalidKey",r[r.MissingKey=1]="MissingKey",r[r.InternalError=2]="InternalError"})(P0||(P0={}));function ea(){return Hl()}function ta(r){return!!(r!=null&&r.worker)&&(jd()||ea())}function HA(r){return!!(r!=null&&r.timestamp||r!=null&&r.frameId)}function N4(r){const e=[];return r!=null&&r.timestamp&&e.push(Xi.PTF_USER_TIMESTAMP),r!=null&&r.frameId&&e.push(Xi.PTF_FRAME_ID),e}function K4(r){if(!r||r.length===0)return;const e={};return r.includes(Xi.PTF_USER_TIMESTAMP)&&(e.timestamp=!0),r.includes(Xi.PTF_FRAME_ID)&&(e.frameId=!0),e.timestamp||e.frameId?e:void 0}function Yd(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,m=new Array(h),g=0;g<h;g++)m[g]=arguments[g];const y=this;return new Promise((b,B)=>{const U=function(){if(s=void 0,c=Date.now(),!a){const C=r.apply(y,m);A&&A(C),l.forEach(E=>{let I=E.resolve;return I(C)}),l=[]}},w=a&&s===void 0;if(s!==void 0&&it.clearTimeout(s),s=it.setTimeout(U,d()),w){const C=r.apply(y,m);return A&&A(C),b(C)}l.push({resolve:b,reject:B})})};return u.cancel=function(h){s!==void 0&&it.clearTimeout(s),l.forEach(m=>{let g=m.reject;return g(h)}),l=[]},u}const Zd=2e3;function bo(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 hg extends H{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 T(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(),Zd)),s4()&&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 gc=100;class eu extends hg{constructor(e,t,n,i,s){super(e,t,H.Kind.Video,n,s),this.elementInfos=[],this.monitorReceiver=()=>T(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=bo(a,this.prevStats)),this.prevStats=a}),this.debouncedHandleResize=Yd(()=>{this.updateDimensions()},gc),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===H.StreamState.Active&&this.updateVisibility()}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(t=>{e?Oi(this._mediaStreamTrack,t):_i(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 V4(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 T(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 T(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<gc){it.setTimeout(()=>{this.updateVisibility()},gc);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"?E0():t||(E0()>2?2:1)}}class V4{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=us(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=us(this.element),(s=this.handleVisibilityChanged)===null||s===void 0||s.call(this)})})},this.onLeavePiP=()=>{var n;this.isPiP=us(this.element),(n=this.handleVisibilityChanged)===null||n===void 0||n.call(this)},this.element=e,this.isIntersecting=t??Kl(e),this.isPiP=Ht()&&us(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,t,n;this.isIntersecting=Kl(this.element),this.isPiP=us(this.element),this.element.handleResize=()=>{var i;(i=this.handleResize)===null||i===void 0||i.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,F0().observe(this.element),U0().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=F0())===null||e===void 0||e.unobserve(this.element),(t=U0())===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 us(r){var e,t;return document.pictureInPictureElement===r?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?Kl(r,(t=window.documentPictureInPicture)===null||t===void 0?void 0:t.window):!1}function Kl(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 z4 extends zt.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(fe.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(Ur.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(Ur.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(Ur.ParticipantEncryptionStatusChanged,o.enabled,d)}break;case"ratchetKey":this.keyProvider.emit(Rr.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=>{fe.error("e2ee worker encountered an error:",{error:n.error}),this.emit(Ur.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(!L4())throw new Wd("tried to setup end-to-end encryption on an unsupported browser");if(fe.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:Eb.getLevel()}};this.worker&&(fe.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(t))}}setParticipantCryptorEnabled(e,t){fe.debug("set e2ee to ".concat(e," for participant ").concat(t)),this.postEnable(e,t)}setSifTrailer(e){!e||e.length===0?fe.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 eu&&a.track.frameMetadataExtractor){a.track.frameMetadataExtractor.storeMetadata(t,n,i);return}}}setupEngine(e){e.on(z.RTPVideoMapUpdate,t=>{this.postRTPMap(t)})}setupEventListeners(e,t){e.on(K.TrackPublished,(n,i)=>this.setParticipantCryptorEnabled(n.trackInfo.encryption!==Qe.NONE,i.identity)),e.on(K.ConnectionStateChanged,n=>{n===Te.Connected&&e.remoteParticipants.forEach(i=>{i.trackPublications.forEach(s=>{this.setParticipantCryptorEnabled(s.trackInfo.encryption!==Qe.NONE,i.identity)})})}).on(K.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(K.TrackSubscribed,(n,i,s)=>{this.setupE2EEReceiver(n,s.identity,i.trackInfo)}).on(K.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(J.LocalSenderCreated,(n,i)=>T(this,void 0,void 0,function*(){this.setupE2EESender(i,n)})),e.localParticipant.on(J.LocalTrackPublished,n=>{if(!ur(n.track)||!Ys())return;const i={kind:"updateCodec",data:{trackId:n.track.mediaStreamID,codec:Rs(n.trackInfo.codecs[0].mimeType),participantIdentity:this.room.localParticipant.identity,hasPacketTrailer:!1}};this.worker.postMessage(i)}),t.on(Rr.SetKey,(n,i)=>this.postKey(n,i??!0)).on(Rr.RatchetRequest,(n,i)=>this.postRatchetRequest(n,i))}encryptData(e){return T(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 ft;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 ft;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"?Rs(n.mimeType):void 0,i)}setupE2EESender(e,t){var n,i,s;if(!Hi(e)||!t){t||fe.warn("early return because sender is not ready");return}this.handleSender(t,e.mediaStreamID,void 0,ur(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 T(this,void 0,void 0,function*(){if(this.worker){if(Hl()){const a={kind:"decode",participantIdentity:n,trackId:t,codec:i,hasPacketTrailer:s};e.transform=new RTCRtpScriptTransform(this.worker,a)}else{if(ds 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:ds in e,hasPacketTrailer:s}};this.worker.postMessage(o,[A,a])}e[ds]=!0}})}handleSender(e,t,n,i){var s;if(!(ds 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(Hl()){fe.info("initialize script transform");const a={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:t,codec:n,hasPacketTrailer:HA(i),packetTrailer:i};e.transform=new RTCRtpScriptTransform(this.worker,a)}else{fe.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:HA(i),packetTrailer:i}};this.worker.postMessage(A,[a.readable,a.writable])}e[ds]=!0}}}const G4=300;class q4{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>=G4;){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 W4{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=>{fe.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(K.TrackSubscribed,(t,n,i)=>{t.kind==="video"&&this.setupReceiver(t,n.trackInfo)}).on(K.TrackUnsubscribed,t=>{this.teardownTrack(t)}).on(K.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(!ta(this.worker?{worker:this.worker}:void 0)&&!(!((i=this.room)===null||i===void 0)&&i.hasE2EESetup)){fe.warn("frame metadata transform not supported; skipping extraction");return}const o=new q4,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(ea()){"transform"in e&&(e.transform=null);return}if(this.worker&&ta({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(ea()){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)){fe.warn("createEncodedStreams not supported");return}let a;try{a=e.createEncodedStreams()}catch(o){fe.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 eu&&(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 $4=500,X4=15e3;class Ni{constructor(){this.failedConnectionAttempts=new Map,this.backOffPromises=new Map}static getInstance(){return this._instance||(this._instance=new Ni),this._instance}addFailedConnectionAttempt(e){var t;const n=new URL(e),i=uc(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,Tt(Math.min($4*Math.pow(2,s),X4)))}getBackOffPromise(e){const t=new URL(e),n=t&&uc(t);return n&&this.backOffPromises.get(n)||Promise.resolve()}resetFailedConnectionAttempts(e){const t=new URL(e),n=t&&uc(t);n&&(this.failedConnectionAttempts.set(n,0),this.backOffPromises.set(n,Promise.resolve()))}resetAll(){this.backOffPromises.clear(),this.failedConnectionAttempts.clear()}}Ni._instance=null;const vc="default";class ht{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new ht),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return T(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=ht.userMediaPromiseMap)===null||s===void 0?void 0:s.size)>0){fe.debug("awaiting getUserMedia promise");try{t?yield ht.userMediaPromiseMap.get(t):yield Promise.all(ht.userMediaPromiseMap.values())}catch{fe.warn("error waiting for media permissons")}}let a=yield navigator.mediaDevices.enumerateDevices();if(i&&!(gi()&&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 T(this,void 0,void 0,function*(){if(t!==vc)return t;const i=yield this.getDevices(e),s=i.find(A=>A.deviceId===vc);if(!s){fe.warn("could not reliably determine default device");return}const a=i.find(A=>A.deviceId!==vc&&A.groupId===(n??s.groupId));if(!a){fe.warn("could not reliably determine default device");return}return a==null?void 0:a.deviceId})}hasDeviceInUse(e){return e?ht.userMediaPromiseMap.has(e):ht.userMediaPromiseMap.size>0}}ht.mediaDeviceKinds=["audioinput","audiooutput","videoinput"];ht.userMediaPromiseMap=new Map;const tu=65535,fg=4294967295;class Tn{static u16(e){return new Tn(e,tu)}static u32(e){return new Tn(e,fg)}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 Tn(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 Tn(e,this.maxSize)}isBefore(e){const t=this.value>>>0,i=(e.value>>>0)-t>>>0;return i!==0&&i<this.maxSize+1}}class Ki{static fromRtpTicks(e){return new Ki(e,9e4)}static rtpRandom(){const e=Math.round(Math.random()*fg);return Ki.fromRtpTicks(e)}constructor(e,t){this.timestamp=Tn.u32(e),this.rateInHz=t}asTicks(){return this.timestamp.value}clone(){return new Ki(this.timestamp.value,this.rateInHz)}wrappingAdd(e){this.timestamp.increment(e)}isBefore(e){return this.timestamp.isBefore(e.timestamp)}}class ti{constructor(e,t,n){this.epoch=t,this.base=n,this.previous=n.clone(),this.rateInHz=e}static startingNow(e,t){return new ti(t,new Date,e)}static startingAtTime(e,t,n){return new ti(n,e,t)}static rtpStartingNow(e){return ti.startingNow(e,9e4)}static rtpStartingAtTime(e,t){return ti.startingAtTime(e,t,9e4)}now(){return this.at(new Date)}at(e){let t=e.getTime()-this.epoch.getTime(),n=ti.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 nu(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 di;(function(r){r[r.Reserved=0]="Reserved",r[r.TooLarge=1]="TooLarge"})(di||(di={}));class Yi extends dn{constructor(e,t){super(19,e),this.name="DataTrackHandleError",this.reason=t,this.reasonName=di[t]}isReason(e){return this.reason===e}static tooLarge(){return new Yi("Value too large to be a valid track handle",di.TooLarge)}static reserved(e){return new Yi("0x".concat(e.toString(16)," is a reserved value."),di.Reserved)}}const J4={fromNumber(r){if(r===0)throw Yi.reserved(r);if(r>tu)throw Yi.tooLarge();return r}};class j4{constructor(){this.value=0}get(){return this.value+=1,this.value>tu?null:this.value}reset(){this.value=0}}const NA={from(r){return{sid:r.sid,pubHandle:r.pubHandle,name:r.name,usesE2ee:r.encryption!==Qe.NONE}},toProtobuf(r){return new fo({sid:r.sid,pubHandle:r.pubHandle,name:r.name,encryption:r.usesE2ee?Qe.GCM:Qe.NONE})}};var Ps;(function(r){r[r.WAITING=0]="WAITING",r[r.RUNNING=1]="RUNNING",r[r.COMPLETED=2]="COMPLETED"})(Ps||(Ps={}));class Y4{constructor(){this.pendingTasks=new Map,this.taskMutex=new wt,this.nextTaskIndex=0}run(e){return T(this,void 0,void 0,function*(){const t={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:Ps.WAITING};this.pendingTasks.set(t.id,t);const n=yield this.taskMutex.lock();try{return t.executedAt=Date.now(),t.status=Ps.RUNNING,yield e()}finally{t.status=Ps.COMPLETED,this.pendingTasks.delete(t.id),n()}})}flush(){return T(this,void 0,void 0,function*(){return this.run(()=>T(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}class Z4{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 Ft((A,o)=>{const c=()=>{o(se.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 Ft((A,o)=>{const c=()=>T(this,void 0,void 0,function*(){const l=new Ft(u=>{s.readyState!==WebSocket.CLOSED&&s.addEventListener("close",h=>{u(h)},{once:!0})}),d=yield Ft.race([Tt(250),l]);d?A(d):o(se.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 e2=["syncState","trickle","offer","answer","simulate","leave"];function t2(r){const e=e2.indexOf(r.case)>=0;return fe.trace("request allowed to bypass queue:",{canPass:e,req:r}),e}var Fe;(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"})(Fe||(Fe={}));const n2=250;class ru{get currentState(){return this.state}get isDisconnected(){return this.state===Fe.DISCONNECTING||this.state===Fe.DISCONNECTED}get isEstablishingConnection(){return this.state===Fe.CONNECTING||this.state===Fe.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=Fe.DISCONNECTED,this.log=fe,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=Kt((n=t.loggerName)!==null&&n!==void 0?n:pt.Signal,()=>this.logContext),this.useJSON=e,this.requestQueue=new Y4,this.queuedRequests=[],this.closingLock=new wt,this.connectionLock=new wt,this.state=Fe.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 T(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=Fe.CONNECTING,c.options=A,yield c.connect(s,a,A,o,l,d)}()})}reconnect(e,t,n,i){return T(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=Fe.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 T(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=b4(A.clientInfoCapabilities),m=l?r2(a,h,A):yield i2(a,h,A,d),g=I4(s,m,l).toString(),y=M4(g).toString();return new Promise((b,B)=>T(c,void 0,void 0,function*(){var U,w;try{let C=!1;const E=O=>T(this,void 0,void 0,function*(){if(C)return;C=!0;const q=O instanceof Event?O.currentTarget:O,ue=_4(q,"Abort handler called");this.streamWriter&&!this.isDisconnected?this.sendLeave().then(()=>this.close(ue)).catch(ce=>{this.log.error(ce),this.close()}):this.close(),I(),B(se.cancelled(ue))});o==null||o.addEventListener("abort",E);const I=()=>{clearTimeout(_),o==null||o.removeEventListener("abort",E)},_=setTimeout(()=>{E(se.timeout("room connection has timed out (signal)"))},A.websocketTimeout),P=(O,q)=>{this.handleSignalConnected(O,_,q)},L=new URL(g);if(L.searchParams.has("access_token")&&L.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(L),{reconnect:A.reconnect,reconnectReason:A.reconnectReason}),this.ws=new Z4(g);try{this.ws.closed.then(he=>{var Se;this.isEstablishingConnection&&B(se.internal("Websocket got closed during a (re)connection attempt: ".concat(he.reason))),he.closeCode!==1e3&&(this.log.warn("websocket closed",{reason:he.reason,code:he.closeCode,wasClean:he.closeCode===1e3,state:this.state}),this.state===Fe.CONNECTED&&this.handleOnClose((Se=he.reason)!==null&&Se!==void 0?Se:"Unexpected WS error"))}).catch(he=>{this.isEstablishingConnection&&B(se.internal("Websocket error during a (re)connection attempt: ".concat(he)))});const O=yield this.ws.opened.catch(he=>T(this,void 0,void 0,function*(){if(this.state!==Fe.CONNECTED){this.state=Fe.DISCONNECTED,clearTimeout(_);const Se=yield this.handleConnectionError(he,y);B(Se);return}this.handleWSError(he),B(he)}));if(clearTimeout(_),!O)return;const q=O.readable.getReader();this.streamWriter=O.writable.getWriter();const ue=yield q.read();if(q.releaseLock(),!ue.value)throw se.internal("no message received as first message");const ce=M0(ue.value),ne=this.validateFirstMessage(ce,(U=A.reconnect)!==null&&U!==void 0?U:!1);if(!ne.isValid){B(ne.error);return}((w=ce.message)===null||w===void 0?void 0:w.case)==="join"&&(this.pingTimeoutDuration=ce.message.value.pingTimeout,this.pingIntervalDuration=ce.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&this.log.debug("ping config",{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration}),this.onJoined&&this.onJoined(ce.message.value));const re=ne.shouldProcessFirstMessage?ce:void 0;P(O,re),b(ne.response)}catch(O){B(O)}finally{I()}}finally{u()}}))}()})}startReadingLoop(e,t){return T(this,void 0,void 0,function*(){for(t&&this.handleSignalResponse(t);;){this.signalLatency&&(yield Tt(this.signalLatency));const n=yield e.read(),i=n.done,s=n.value;if(i)break;const a=M0(s);this.handleSignalResponse(a)}})}close(){return T(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([Fe.DISCONNECTING||Fe.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=Fe.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,Tt(n2)])}}catch(s){e.log.debug("websocket error while closing",{error:s})}finally{t&&(e.state=Fe.DISCONNECTED),i()}}()})}sendOffer(e,t){this.log.debug("sending offer",{offerSdp:e.sdp}),this.sendRequest({case:"offer",value:ni(e,t)})}sendAnswer(e,t){return this.log.debug("sending answer",{answerSdp:e.sdp}),this.sendRequest({case:"answer",value:ni(e,t)})}sendIceCandidate(e,t){return this.log.debug("sending ice candidate",{candidate:e}),this.sendRequest({case:"trickle",value:new mo({candidateInit:JSON.stringify(e),target:t})})}sendMuteTrack(e,t){return this.sendRequest({case:"mute",value:new go({sid:e,muted:t})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,t){return T(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 zd({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 pm({trackSid:e,layers:t})})}sendUpdateSubscriptionPermissions(e,t){return this.sendRequest({case:"subscriptionPermission",value:new vm({allParticipants:e,trackPermissions:t})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:Le.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new bm({timestamp:Le.parse(Date.now()),rtt:Le.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,t){return this.sendRequest({case:"updateAudioTrack",value:new Vd({trackSid:e,features:t})})}sendLeave(){return this.sendRequest({case:"leave",value:new yo({reason:Sn.CLIENT_INITIATED,action:Di.DISCONNECT})})}sendPublishDataTrackRequest(e,t,n){return this.sendRequest({case:"publishDataTrackRequest",value:new Od({pubHandle:e,name:t,encryption:n?Qe.GCM:Qe.NONE})})}sendUnPublishDataTrackRequest(e){return this.sendRequest({case:"unpublishDataTrackRequest",value:new Nd({pubHandle:e})})}sendUpdateDataSubscription(e,t){return this.sendRequest({case:"updateDataSubscription",value:new dm({updates:[new um({trackSid:e,subscribe:t})]})})}sendRequest(e){return T(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&&!t2(t)&&n.state===Fe.RECONNECTING){n.queuedRequests.push(()=>T(n,void 0,void 0,function*(){yield this.sendRequest(t,!0)}));return}if(i||(yield n.requestQueue.flush()),n.signalLatency&&(yield Tt(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 Jw({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=D0(i.value);this.onAnswer&&this.onAnswer(a,i.value.id,i.value.midToTrackId)}else if(i.case==="offer"){const a=D0(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 T(this,void 0,void 0,function*(){if(this.state===Fe.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=it.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&&it.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=it.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval"),this.clearPingTimeout(),this.pingInterval&&it.clearInterval(this.pingInterval)}handleSignalConnected(e,t,n){this.state=Fe.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===Fe.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:se.leaveRequest("Received leave request while trying to (re)connect",e.message.value.reason)}:t?{isValid:!1,error:se.internal("Unexpected first message")}:{isValid:!1,error:se.internal("did not receive join response, got ".concat((A=e.message)===null||A===void 0?void 0:A.case," instead"))}}handleConnectionError(e,t){return T(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")?se.notAllowed(i,n.status):se.serviceNotFound("v1 RTC path not found. Consider upgrading your LiveKit server version","v0-rtc");case 401:case 403:const s=yield n.text();return se.notAllowed(s,n.status);default:break}return e instanceof se?e:se.internal("Encountered unknown websocket error during connection: ".concat(e),{status:n.status,statusText:n.statusText})}catch(n){return n instanceof se?n:se.serverUnreachable(n instanceof Error?n.message:"server was not reachable")}})}}function D0(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 ni(r,e){return new Or({sdp:r.sdp,type:r.type,id:e})}function r2(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",xn()?"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 i2(r,e,t,n){return T(this,void 0,void 0,function*(){const i=new URLSearchParams;i.set("access_token",r);const s=new bb({clientInfo:e,connectionSettings:new Bm({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(dg()){const u=new CompressionStream("gzip"),h=u.writable.getWriter();h.write(new Uint8Array(a)),h.close();const m=[],g=u.readable.getReader();for(;;){const U=yield g.read(),w=U.done,C=U.value;if(w)break;m.push(C)}const y=m.reduce((U,w)=>U+w.length,0),b=new Uint8Array(y);let B=0;for(const U of m)b.set(U,B),B+=U.length;A=b,o=Sl.GZIP}else A=a,o=Sl.NONE;const l=new Bb({joinRequest:A,compression:o}).toBinary(),d=u=>{const h=Array.from(u,m=>String.fromCodePoint(m)).join("");return btoa(h)};return i.set("join_request",d(l).replace(/\+/g,"-").replace(/\//g,"_")),i})}class L0{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 s2{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=ie(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=ie(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=ie(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=ie(n,2);const i=t[0],s=t[1];s.expiresAt>=Date.now()&&e.set(i,s.value)}return e}}var hn={},yc={},wc={exports:{}},O0;function iu(){if(O0)return wc.exports;O0=1;var r=wc.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")})}),wc.exports}var H0;function a2(){return H0||(H0=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=iu(),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 m=0;m<(i[u]||[]).length;m+=1){var g=i[u][m];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}})})}}(yc)),yc}var bc,N0;function A2(){if(N0)return bc;N0=1;var r=iu(),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 bc=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(m){l.push(n(u,h,m))})})})}),l.join(`\r
|
|
38
|
+
`)+`\r
|
|
39
|
+
`},bc}var K0;function o2(){if(K0)return hn;K0=1;var r=a2(),e=A2(),t=iu();return hn.grammar=t,hn.write=e,hn.parse=r.parse,hn.parseParams=r.parseParams,hn.parseFmtpConfig=r.parseFmtpConfig,hn.parsePayloads=r.parsePayloads,hn.parseRemoteCandidates=r.parseRemoteCandidates,hn.parseImageAttributes=r.parseImageAttributes,hn.parseSimulcastStreamList=r.parseSimulcastStreamList,hn}var Zt=o2();const c2=.7,l2=20,Fr={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",OfferAnswered:"offerAnswered",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class V0 extends zt.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=fe,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=Yd(i=>T(this,void 0,void 0,function*(){this.emit(Fr.NegotiationStarted);try{yield this.createAndSendOffer()}catch(s){if(i)i(s);else throw s}}),l2),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=Kt((n=t.loggerName)!==null&&n!==void 0?n:pt.PCTransport),this.loggerOptions=t,this.config=e,this._pc=this.createPC(),this.offerLock=new wt}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 T(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 T(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=d2(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=Zt.parse((n=A.sdp)!==null&&n!==void 0?n:"");o.media.forEach(c=>{Ca(c)}),this.log.debug("setting pending initial offer before processing answer",this.logContext),yield this.setMungedSDP(A,Zt.write(o))}const a=Zt.parse((i=e.sdp)!==null&&i!==void 0?i:"");a.media.forEach(A=>{const o=su(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=Zt.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(Fr.OfferAnswered,t)),this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(Fr.NegotiationComplete),e.sdp&&Zt.parse(e.sdp).media.forEach(A=>{A.type==="video"&&this.emit(Fr.RTPVideoPayloadTypes,A.rtp)})),!0})}createInitialOffer(){return T(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=Zt.parse((e=i.sdp)!==null&&e!==void 0?e:"");return s.media.forEach(a=>{Ca(a)}),i.sdp=Zt.write(s),{offer:i,offerId:n}}finally{t()}})}createAndSendOffer(e){return T(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=Zt.parse((t=s.sdp)!==null&&t!==void 0?t:"");if(a.media.forEach(A=>{Ca(A),A.type==="audio"?z0(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||(bn(o.codec)&&!gi()&&this.ensureVideoDDExtensionForSVC(A,a),!bn(o.codec)))return!0;const l=Math.round(o.maxbr*c2);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,Zt.write(a)),this.onOffer(s,this.latestOfferId)}finally{n()}})}createAndSetAnswer(){return T(this,void 0,void 0,function*(){var e;const t=yield this.pc.createAnswer(),n=Zt.parse((e=t.sdp)!==null&&e!==void 0?e:"");return n.media.forEach(i=>{Ca(i),i.type==="audio"&&z0(i,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(t,Zt.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 Ke("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 Ke("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 T(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 T(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 ci(o)}})}ensureVideoDDExtensionForSVC(e,t){var n,i;if(!((n=e.ext)===null||n===void 0?void 0:n.some(a=>a.uri===x0))){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:x0})}}}function z0(r,e,t){const n=su(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 d2(r){var e;const t=[],n=[],i=Zt.parse((e=r.sdp)!==null&&e!==void 0?e:"");let s=0;return i.media.forEach(a=>{var A;const o=su(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 Ca(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 su(r){return typeof r=="number"?r.toFixed(0):r}const Vl="vp8",u2={audioPreset:Ml.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:$d.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:Vl,backupCodec:!0,preConnectBuffer:!1},pg={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},mg={deviceId:{ideal:"default"},resolution:js.h720.resolution},h2={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new Fb,disconnectOnPageLeave:!0,webAudioMix:!1,singlePeerConnection:!0},au={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var Ve;(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"})(Ve||(Ve={}));class G0{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=au.peerConnectionTimeout,this.log=fe,this.updateState=()=>{var s,a;const A=this.state,o=this.requiredTransports.map(c=>c.getConnectionState());o.every(c=>c==="connected")?this.state=Ve.CONNECTED:o.some(c=>c==="failed")?this.state=Ve.FAILED:o.some(c=>c==="connecting")?this.state=Ve.CONNECTING:o.every(c=>c==="closed")?this.state=Ve.CLOSED:o.some(c=>c==="closed")?this.state=Ve.CLOSING:o.every(c=>c==="new")&&(this.state=Ve.NEW),A!==this.state&&(this.log.debug("pc state change: from ".concat(Ve[A]," to ").concat(Ve[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=Kt((i=t.loggerName)!==null&&i!==void 0?i:pt.PCManager),this.loggerOptions=t,this.isPublisherConnectionRequired=e!=="subscriber-primary",this.isSubscriberConnectionRequired=e==="subscriber-primary",this.publisher=new V0(n,t),this._mode=e,e!=="publisher-only"&&(this.subscriber=new V0(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,yn.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,yn.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=Ve.NEW,this.connectionLock=new wt,this.remoteOfferLock=new wt}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 T(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 T(this,void 0,void 0,function*(){this.subscriber&&(this.subscriber.restartingIce=!0),this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,t){return T(this,void 0,void 0,function*(){var n;t===yn.PUBLISHER?yield this.publisher.addIceCandidate(e):yield(n=this.subscriber)===null||n===void 0?void 0:n.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e,t){return T(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 T(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 T(this,void 0,void 0,function*(){return new Ft((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(Fr.OfferAnswered,A),e.signal.removeEventListener("abort",o))},A=l=>{l>i&&(a(),t())},o=()=>{a(),n(new ci("negotiation aborted"))},c=setTimeout(()=>{a(),n(new ci("negotiation timed out"))},this.peerConnectionTimeout);e.signal.addEventListener("abort",o),this.publisher.on(Fr.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===yn.PUBLISHER?this.publisher.getConnectedAddress():e===yn.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 T(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)=>T(s,void 0,void 0,function*(){const l=()=>{this.log.warn("abort transport connection",this.logContext),it.clearTimeout(d),c(se.cancelled("room connection has been cancelled"))};i!=null&&i.signal.aborted&&l(),i==null||i.signal.addEventListener("abort",l);const d=it.setTimeout(()=>{i==null||i.signal.removeEventListener("abort",l),c(se.internal("could not establish pc connection"))},a);for(;this.state!==Ve.CONNECTED;)if(yield Tt(50),i!=null&&i.signal.aborted){c(se.cancelled("room connection has been cancelled"));return}it.clearTimeout(d),i==null||i.signal.removeEventListener("abort",l),o()}))}()})}}const Au=typeof MediaRecorder<"u";class f2{constructor(){throw new Error("MediaRecorder is not available in this environment")}}const p2=Au?MediaRecorder:f2;class m2 extends p2{constructor(e,t){if(!Au)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=>T(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 g2(){return Au}const v2=1e3,y2=1e4;class gg extends H{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=Yd(()=>T(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>T(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 wt,this.pauseUpstreamLock=new wt,this.trackChangeLock=new wt,this.trackChangeLock.lock().then(a=>T(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!==H.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 T(this,void 0,void 0,function*(){var i;if(e===this._mediaStreamTrack&&!t)return;this._mediaStreamTrack&&(this.attachedElements.forEach(a=>{Oi(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&&(_i(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=>{_i(s??e,a)}))})}waitForDimensions(){return T(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:v2;return function*(){var n;if(e.kind===H.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((n=Qt())===null||n===void 0?void 0:n.os)==="iOS"&&(yield Tt(10));const i=Date.now();for(;Date.now()-i<t;){const s=e.dimensions;if(s)return s;yield Tt(50)}throw new or("unable to get track dimensions after timeout")}()})}setDeviceId(e){return T(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===li(e)?!0:(this._constraints.deviceId=e,this.isMuted?(this.pendingDeviceChange=!0,!0):(yield this.restartTrack(),li(e)===this._mediaStreamTrack.getSettings().deviceId))})}getDeviceId(){return T(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===H.Source.ScreenShare)return;const n=e._mediaStreamTrack.getSettings(),i=n.deviceId,s=n.groupId,a=e.kind===H.Kind.Audio?"audioinput":"videoinput";return t?ht.getInstance().normalizeDeviceId(a,i,s):i}()})}mute(){return T(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return T(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,t){return T(this,void 0,void 0,function*(){const n=yield this.trackChangeLock.lock();try{if(!this.sender)throw new or("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 T(this,void 0,void 0,function*(){})}restart(e,t){return T(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=Ib(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===H.Kind.Video?o.video=s||a?{deviceId:s,facingMode:a}:!0:o.audio=s?Object.assign({deviceId:s},A):!0,this.attachedElements.forEach(d=>{Oi(this.mediaStreamTrack,d)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const l=(yield navigator.mediaDevices.getUserMedia(o)).getTracks()[0];return this.kind===H.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 T(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),og()&&(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 T(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=Qt();if((n==null?void 0:n.name)==="Safari"&&Vn(n.version,"12.0")<0)throw new Wd("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 T(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 T(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 T(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(_i(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&&(Oi(n._mediaStreamTrack,c),_i(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 T(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 T(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(!g2()){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 m2(this,{mimeType:t})}this.localTrackRecorder.start(e),this.autoStopPreConnectBuffer=setTimeout(()=>{this.log.warn("preconnect buffer timed out, stopping recording automatically",this.logContext),this.stopPreConnectBuffer()},y2)}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 KA extends gg{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,H.Kind.Audio,t,n,s),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>T(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=bo(a,this.prevStats)),this.prevStats=a}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit($.AudioTrackFeatureUpdate,this,ut.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit($.AudioTrackFeatureUpdate,this,ut.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=i,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return T(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===H.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 T(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source===H.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 T(this,void 0,void 0,function*(){let t;if(e){const n=Xd({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 T(this,void 0,void 0,function*(){const i=yield n.restart.call(this,e,t);return this.checkForSilence(),i})}startMonitor(){Ht()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},Zd)))}setProcessor(e){return T(this,void 0,void 0,function*(){var t;const n=yield this.trackChangeLock.lock();try{if(!xn()&&!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 T(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 T(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 w2(r,e,t){switch(r.kind){case"audio":return new KA(r,e,!1,void 0,t);case"video":return new zA(r,e,!1,t);default:throw new or("unsupported track type: ".concat(r.kind))}}const b2=Object.values(js),B2=Object.values(_l),C2=Object.values($d),S2=[js.h180,js.h360],T2=[_l.h180,_l.h360],k2=r=>[{scaleResolutionDownBy:2,fps:r.encoding.maxFramerate}].map(t=>{var n,i;return new Ue(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)}),zl=["q","h","f"];function VA(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=x2(r,e,t,c),fe.debug("using video encoding",a));const l=a.maxFramerate,d=new Ue(e,t,a.maxBitrate,a.maxFramerate,a.priority);if(o&&bn(c)){const y=new yg(o),b=[];if(y.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(o));const B=Qt();if(Ys()||xn()||(B==null?void 0:B.name)==="Chrome"&&Vn(B==null?void 0:B.version,"113")<0){const U=y.suffix=="h"?2:3,w=g4(B);for(let C=0;C<y.spatial;C+=1)b.push({rid:zl[2-C],maxBitrate:a.maxBitrate/Math.pow(U,C),maxFramerate:d.encoding.maxFramerate,scaleResolutionDownBy:w?Math.pow(2,C):void 0});b[0].scalabilityMode=o}else b.push({maxBitrate:a.maxBitrate,maxFramerate:d.encoding.maxFramerate,scalabilityMode:o});return d.encoding.priority&&(b[0].priority=d.encoding.priority,b[0].networkPriority=d.encoding.priority),fe.debug("using svc encoding",{encodings:b}),b}if(!A)return[a];let u;r?u=(i=W0(n==null?void 0:n.screenShareSimulcastLayers))!==null&&i!==void 0?i:q0(r,d):u=(s=W0(n==null?void 0:n.videoSimulcastLayers))!==null&&s!==void 0?s:q0(r,d);let h;if(u.length>0){const y=u[0];if(u.length>1){var m=u,g=ie(m,2);h=g[1]}const b=Math.max(e,t);if(b>=960&&h)return Bc(e,t,[y,h,d],l);if(b>=480)return Bc(e,t,[y,d],l)}return Bc(e,t,[d])}function vg(r,e,t){var n,i,s,a;if(!t.backupCodec||t.backupCodec===!0||t.backupCodec.codec===t.videoCodec)return;e!==t.backupCodec.codec&&fe.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===H.Source.ScreenShare&&t.simulcast&&(t.simulcast=!1),VA(r.source===H.Source.ScreenShare,o,c,t)}function x2(r,e,t,n){const i=E2(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 E2(r,e,t){if(r)return C2;const n=e>t?e/t:t/e;return Math.abs(n-16/9)<Math.abs(n-4/3)?b2:B2}function q0(r,e){if(r)return k2(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)?S2:T2}function Bc(r,e,t,n){const i=[];if(t.forEach((s,a)=>{if(a>=zl.length)return;const A=Math.min(r,e),c={rid:zl[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=Qt(),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)}),xn()&&lg()==="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,fe.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),fe.info('Setting framerate of encoding "'.concat((o=A.rid)!==null&&o!==void 0?o:"",'" to ').concat(s)),A.maxFramerate=s)})}return i}function W0(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 yg{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 U2(r){return r.source===H.Source.ScreenShare||r.constraints.height&&li(r.constraints.height)>=1080?"maintain-resolution":"balanced"}const F2=5e3;class zA extends gg{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,H.Kind.Video,t,n,i),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.isCpuConstrained=!1,this.optimizeForPerformance=!1,this.monitorSender=()=>T(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+=bo(c,u)}),this._currentBitrate=o}this.prevStats=a}),this.senderLock=new wt}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!Ht())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()},Zd))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return T(this,void 0,void 0,function*(){var t,n,i,s,a;yield e.pauseUpstream.call(this);try{for(var A=!0,o=wn(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 T(this,void 0,void 0,function*(){var t,n,i,s,a;yield e.resumeUpstream.call(this);try{for(var A=!0,o=wn(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 T(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===H.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 T(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source===H.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 T(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=Xt.LOW;n<=Xt.HIGH;n+=1)t.push(new Gd({quality:n,enabled:n<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(bn(this.codec),t)}restartTrack(e){return T(this,void 0,void 0,function*(){var t,n,i,s,a;let A;if(e){const d=Xd({video:e});typeof d.video!="boolean"&&(A=d.video)}yield this.restart(A),this.isCpuConstrained=!1;try{for(var o=!0,c=wn(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 T(this,void 0,void 0,function*(){yield this.refreshSenderEncodings()})}refreshSenderEncodings(){return T(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===H.Source.ScreenShare,a=VA(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=ie(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"||!rg(o))continue;const l=Object.assign({},this.publishOptions),d=vg(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 T(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 T(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=wn(i.simulcastCodecs.values()),m;m=yield h.next(),a=m.done,!a;u=!0)c=m.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 T(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)},F2))}setPublishingCodecs(e){return T(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(bn(e[0].codec),e[0].qualities),[];this.subscribedCodecs=e;const c=[];try{for(t=!0,n=wn(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(bn(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 $0(d.sender,d.encodings,l.qualities,this.senderLock,bn(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 T(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 $0(this.sender,this.encodings,t,this.senderLock,e,this.log,this.logContext))})}prioritizePerformance(){return T(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&&bn(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 T(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),og()&&this.isInBackground&&this.source===H.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function $0(r,e,t,n,i,s,a){return T(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 m;let g=(m=u.rid)!==null&&m!==void 0?m:"";g===""&&(g="q");const y=wg(g),b=t.find(B=>B.quality===y);b&&u.active!==b.enabled&&(l=!0,u.active=b.enabled,s.debug("setting layer ".concat(b.quality," to ").concat(u.active?"enabled":"disabled"),a),mi()&&(b.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 wg(r){switch(r){case"f":return Xt.HIGH;case"h":return Xt.MEDIUM;case"q":return Xt.LOW;default:return Xt.HIGH}}function X0(r,e,t,n){if(!t)return[new Mr({quality:Xt.HIGH,width:r,height:e,bitrate:0,ssrc:0})];if(n){const i=t[0].scalabilityMode,s=new yg(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 Mr({quality:Math.min(Xt.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=wg((a=i.rid)!==null&&a!==void 0?a:"");return new Mr({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 J0="_lossy",j0="_reliable",Y0="_data_track",I2=2*1e3,Cc="leave-reconnect",Q2=3e4,M2=8*1024,_2=256*1024,R2=3,P2=3;var en;(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"})(en||(en={}));var pe;(function(r){r[r.RELIABLE=0]="RELIABLE",r[r.LOSSY=1]="LOSSY",r[r.DATA_TRACK_LOSSY=2]="DATA_TRACK_LOSSY"})(pe||(pe={}));const Z0=64e3;class D2 extends zt.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=au.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.latestRemoteOfferId=0,this.subscriberPrimary=!1,this.pcState=en.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=fe,this.reliableDataSequence=1,this.reliableMessageBuffer=new L0,this.reliableReceivedState=new s2(Q2),this.lossyDataStatCurrentBytes=0,this.lossyDataStatByterate=0,this.lossyDataDropCount=0,this.midToTrackId={},this.isWaitingForNetworkReconnect=!1,this.bufferStatusLowClosingFuture=new ft,this.handleDataChannel=n=>T(this,[n],void 0,function(i){var s=this;let a=i.channel;return function*(){if(!a)return;let A;if(a.label===j0)s.reliableDCSub=a,A=s.handleDataMessage;else if(a.label===J0)s.lossyDCSub=a,A=s.handleDataMessage;else if(a.label===Y0)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=>T(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=Ct.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(z.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=jp.fromBinary(u.payload),m=new Ct({value:h.value,participantIdentity:d.participantIdentity,participantSid:d.participantSid});((A=m.value)===null||A===void 0?void 0:A.case)==="user"&&eh(m,m.value.value),this.emit(z.DataPacketReceived,m,d.value.value.encryptionType)}else((o=d.value)===null||o===void 0?void 0:o.case)==="user"&&eh(d,d.value.value),this.emit(z.DataPacketReceived,d,Qe.NONE)}finally{c()}}),this.handleDataTrackMessage=n=>T(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(pe[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(z.Disconnected),this.close()},a=Date.now()-this.reconnectStart;let A=this.getNextRetryDelay({elapsedMs:a,retryCount:this.reconnectAttempts});if(A===null){s(a);return}n===Cc&&(A=0),this.log.debug("reconnecting in ".concat(A,"ms")),this.clearReconnectTimeout(),this.token&&this.emit(z.TokenRefreshed,this.token),this.reconnectTimeout=it.setTimeout(()=>this.attemptReconnect(i).finally(()=>this.reconnectTimeout=void 0),A)},this.waitForRestarted=()=>new Promise((n,i)=>{this.pcState===en.Connected&&n();const s=()=>{this.off(z.Disconnected,a),n()},a=()=>{this.off(z.Restarted,s),i()};this.once(z.Restarted,s),this.once(z.Disconnected,a)}),this.updateAndEmitDCBufferStatus=n=>{if(n===pe.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(z.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();B4(a)&&i.set(s.payload,a)}),this.emit(z.RTPVideoMapUpdate,i)},this.handleBrowserOnLine=()=>T(this,void 0,void 0,function*(){!this.url||!(yield fetch(Zs(this.url),{method:"HEAD"}).then(i=>i.ok).catch(()=>!1))||(this.log.info("detected network reconnected"),(this.client.currentState===Fe.RECONNECTING||this.isWaitingForNetworkReconnect&&this.client.currentState===Fe.CONNECTED)&&(this.clearReconnectTimeout(),this.attemptReconnect(Yr.RR_SIGNAL_DISCONNECTED),this.isWaitingForNetworkReconnect=!1))}),this.handleBrowserOffline=()=>T(this,void 0,void 0,function*(){if(this.url)try{yield Promise.race([fetch(Zs(this.url),{method:"HEAD"}),Tt(4e3).then(()=>Promise.reject())])}catch{window.navigator.onLine===!1&&(this.log.info("detected network interruption"),this.isWaitingForNetworkReconnect=!0)}}),this.log=Kt((t=e.loggerName)!==null&&t!==void 0?t:pt.Engine,()=>this.logContext),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new ru(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.closingLock=new wt,this.dataProcessLock=new wt,this.dcBufferStatus=new Map([[pe.RELIABLE,!0],[pe.LOSSY,!0],[pe.DATA_TRACK_LOSSY,!0]]),this.client.onParticipantUpdate=n=>this.emit(z.ParticipantUpdate,n),this.client.onConnectionQuality=n=>this.emit(z.ConnectionQualityUpdate,n),this.client.onRoomUpdate=n=>this.emit(z.RoomUpdate,n),this.client.onSubscriptionError=n=>this.emit(z.SubscriptionError,n),this.client.onSubscriptionPermissionUpdate=n=>this.emit(z.SubscriptionPermissionUpdate,n),this.client.onSpeakersChanged=n=>this.emit(z.SpeakersChanged,n),this.client.onStreamStateUpdate=n=>this.emit(z.StreamStateChanged,n),this.client.onRequestResponse=n=>this.emit(z.SignalRequestResponse,n),this.client.onParticipantUpdate=n=>this.emit(z.ParticipantUpdate,n),this.client.onJoined=n=>this.emit(z.Joined,n),this.on(z.Closing,()=>{var n,i;(i=(n=this.bufferStatusLowClosingFuture).reject)===null||i===void 0||i.call(n,new Ke("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 T(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 m=!l&&F4();let g;if(m){c.pcManager||(yield c.configure(),c.applyInitialPublisherLayout());const B=yield(d=c.pcManager)===null||d===void 0?void 0:d.publisher.createInitialOffer();B&&(g=ni(B.offer,B.offerId))}if(o!=null&&o.aborted)throw se.cancelled("Connection aborted");if(!l&&c.shouldFailOnV1Path)throw c.shouldFailOnV1Path=!1,se.serviceNotFound("Simulated v1 path failure","v0-rtc");const y=yield c.client.join(s,a,A,o,l,g);c._isClosed=!1,c.latestJoinResponse=y,c.participantSid=(u=y.participant)===null||u===void 0?void 0:u.sid,c.subscriberPrimary=y.subscriberPrimary,m?(h=c.pcManager)===null||h===void 0||h.updateConfiguration(c.makeRTCConfiguration(y)):(c.pcManager||(yield c.configure(y,!l),l||c.applyInitialPublisherLayout()),(!c.subscriberPrimary||y.fastPublish)&&c.negotiate().catch(B=>{c.log.error(B)})),c.registerOnLineListener(),c.clientConfiguration=y.clientConfiguration,c.emit(z.SignalConnected,y);let b=y.serverInfo;return b||(b={version:y.serverVersion,region:y.serverRegion}),c.log.info("connected to Livekit Server ".concat(Object.entries(b).map(B=>{let U=ie(B,2),w=U[0],C=U[1];return"".concat(w,": ").concat(C)}).join(", "))),{joinResponse:y,serverInfo:b}}catch(m){if(m instanceof se){if(m.reason===Ie.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(m.reason===Ie.ServiceNotFound)return c.log.warn("Initial connection failed: ".concat(m.message," – Retrying")),c.pcManager&&(c.pcManager.onStateChange=void 0,yield c.cleanupPeerConnections()),c.join(s,a,A,o,!0)}throw m}}()})}close(){return T(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(z.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),this.cleanupLossyDataStats(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return T(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 L0,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 T(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 or("a track with the same ID has already been published");return new Promise((t,n)=>{const i=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],n(se.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 T(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 T(this,void 0,void 0,function*(){var n;if(!(this.pcManager&&this.pcManager.currentState!==Ve.NEW)){if(e){this.participantSid=(n=e.participant)===null||n===void 0?void 0:n.sid;const i=this.makeRTCConfiguration(e);this.pcManager=new G0(t?"publisher-only":e.subscriberPrimary?"subscriber-primary":"publisher-primary",this.loggerOptions,i)}else{const i=this.makeRTCConfiguration();this.pcManager=new G0("publisher-only",this.loggerOptions,i)}this.emit(z.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)=>T(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===Ve.CONNECTED){const c=this.pcState===en.New;this.pcState=en.Connected,c&&this.emit(z.Connected,this.latestJoinResponse)}else i===Ve.FAILED&&(this.pcState===en.Connected||this.pcState===en.Reconnecting)&&(this.pcState=en.Disconnected,this.handleDisconnect("peerconnection failed",a==="failed"?Yr.RR_SUBSCRIBER_FAILED:Yr.RR_PUBLISHER_FAILED));const A=this.client.isDisconnected||this.client.currentState===Fe.RECONNECTING,o=[Ve.FAILED,Ve.CLOSING,Ve.CLOSED].includes(i);A&&o&&!this._isClosed&&this.emit(z.Offline)}),this.pcManager.onTrack=i=>{i.streams.length!==0&&this.emit(z.MediaTrackAdded,i.track,i.streams[0],i.receiver)}}})}setupSignalClientCallbacks(){this.client.onAnswer=(e,t,n)=>T(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)=>T(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(z.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(z.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{this.token=e,this.emit(z.TokenRefreshed,e)},this.client.onRemoteMuteChanged=(e,t)=>{this.emit(z.RemoteMute,e,t)},this.client.onSubscribedQualityUpdate=e=>{this.emit(z.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(z.RoomMoved,e)},this.client.onMediaSectionsRequirement=e=>{this.addMediaSections(e.numAudios,e.numVideos),this.negotiate()},this.client.onPublishDataTrackResponse=e=>{this.emit(z.PublishDataTrackResponse,e)},this.client.onUnPublishDataTrackResponse=e=>{this.emit(z.UnPublishDataTrackResponse,e)},this.client.onDataTrackSubscriberHandles=e=>{this.emit(z.DataTrackSubscriberHandles,e)},this.client.onClose=()=>{this.handleDisconnect("signal",Yr.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(z.ServerRegionsReported,e.regions)),e.action){case Di.DISCONNECT:this.emit(z.Disconnected,e==null?void 0:e.reason),this.close();break;case Di.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(Cc);break;case Di.RESUME:this.handleDisconnect(Cc)}}}makeRTCConfiguration(e){var t;const n=Object.assign({},this.rtcConfig);if((((t=this.signalOpts)===null||t===void 0?void 0:t.e2eeEnabled)||this.frameMetadataWorker&&!ea())&&jd()&&(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===$s.ENABLED&&(n.iceTransportPolicy="relay"),n}applyInitialPublisherLayout(){this.createDataChannels(),xn()||this.addMediaSections(R2,P2)}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(J0,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(j0,{ordered:!0}),this.dataTrackDC=this.pcManager.createPublisherDataChannel(Y0,{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(pe.LOSSY),this.reliableDC.onclose=this.handleDataChannelClose(pe.RELIABLE),this.dataTrackDC.onclose=this.handleDataChannelClose(pe.DATA_TRACK_LOSSY),this.lossyDC.bufferedAmountLowThreshold=65535,this.reliableDC.bufferedAmountLowThreshold=65535,this.dataTrackDC.bufferedAmountLowThreshold=65535,this.lossyDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(pe.LOSSY),this.reliableDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(pe.RELIABLE),this.dataTrackDC.onbufferedamountlow=()=>this.handleBufferedAmountLow(pe.DATA_TRACK_LOSSY),this.cleanupLossyDataStats(),this.lossyDataStatInterval=setInterval(()=>{this.lossyDataStatByterate=this.lossyDataStatCurrentBytes,this.lossyDataStatCurrentBytes=0;const e=this.dataChannelForKind(pe.LOSSY);if(e){const t=this.lossyDataStatByterate/10;e.bufferedAmountLowThreshold=Math.min(Math.max(t,M2),_2)}},1e3))}createSender(e,t,n){return T(this,void 0,void 0,function*(){let i;if(Dl())i=yield this.createTransceiverRTCRtpSender(e,t,n);else if(Ll())this.log.warn("using add-track fallback"),i=yield this.createRTCRtpSender(e.mediaStreamTrack);else throw new Ke("Required webRTC APIs not supported on this device");return this.setupFrameMetadataSender(i,t),i})}createSimulcastSender(e,t,n,i){return T(this,void 0,void 0,function*(){let s;if(Dl())s=yield this.createSimulcastTransceiverSender(e,t,n,i);else if(Ll())this.log.debug("using add-track fallback"),s=yield this.createRTCRtpSender(e.mediaStreamTrack);else throw new Ke("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=HA(A);if(ea()){o&&(e.transform=new RTCRtpScriptTransform(a,{kind:"encode",packetTrailer:A}));return}if(!ta((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 T(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ke("publisher is closed");const i=[];e.mediaStream&&i.push(e.mediaStream),ur(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 T(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ke("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 T(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ke("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return T(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)===$s.DISABLED||((i=(n=this.pcManager)===null||n===void 0?void 0:n.currentState)!==null&&i!==void 0?i:Ve.NEW)===Ve.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 Ke?(this.log.debug("received unrecoverable error",{error:s}),a=!1):s instanceof Ci||(this.fullReconnectOnNext=!0),a?this.handleDisconnect("reconnect",Yr.RR_UNKNOWN):(this.log.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up")),this.emit(z.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 T(this,void 0,void 0,function*(){var t,n,i;try{if(!this.url||!this.token)throw new Ke("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts)),this.emit(z.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 Ci;s=(yield this.join(e??this.url,this.token,this.signalOpts,void 0,!this.options.singlePeerConnection)).joinResponse}catch(a){throw a instanceof se&&a.reason===Ie.NotAllowed?new Ke("could not reconnect, token might be expired"):new Ci}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(z.SignalRestarted,s),yield this.waitForPCReconnected(),this.client.currentState!==Fe.CONNECTED)throw new Ci("Signal connection got severed during reconnect");(t=this.regionStrategy)===null||t===void 0||t.resetAttempts(),this.emit(z.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 T(this,void 0,void 0,function*(){var t;if(!this.url||!this.token)throw new Ke("could not reconnect, url or token not saved");if(!this.pcManager)throw new Ke("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts)),this.emit(z.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 se&&i.reason===Ie.NotAllowed?new Ke("could not reconnect, token might be expired"):i instanceof se&&i.reason===Ie.LeaveRequest?i:new Ci(s)}if(this.emit(z.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!==Fe.CONNECTED)throw new Ci("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(z.Resumed)})}waitForPCInitialConnection(e,t){return T(this,void 0,void 0,function*(){if(!this.pcManager)throw new Ke("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(t,e)})}waitForPCReconnected(){return T(this,void 0,void 0,function*(){this.pcState=en.Reconnecting,this.log.debug("waiting for peer connection to reconnect");try{if(yield Tt(I2),!this.pcManager)throw new Ke("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=en.Connected}catch(e){throw this.pcState=en.Disconnected,se.internal("could not establish PC connection, ".concat(e.message))}})}publishRpcAck(e,t){return T(this,void 0,void 0,function*(){const n=new Ct({destinationIdentities:[e],kind:_r.RELIABLE,value:{case:"rpcAck",value:new po({requestId:t})}});yield this.sendDataPacket(n,pe.RELIABLE)})}sendDataPacket(e,t){return T(this,void 0,void 0,function*(){var n,i;if(yield this.ensurePublisherConnected(t),this.e2eeManager&&this.e2eeManager.isDataChannelEncryptionEnabled){const A=H4(e);if(A){const o=yield this.e2eeManager.encryptData(A.toBinary());e.value={case:"encryptedPacket",value:new Jp({encryptedValue:o.payload,iv:o.iv,keyIndex:o.keyIndex})}}}t===pe.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:Z0,Z0);if(typeof a<"u"&&a!==0&&s.byteLength>a)throw new jb("cannot publish data packet larger than ".concat(a," bytes (got ").concat(s.byteLength,")"));switch(t){case pe.LOSSY:case pe.DATA_TRACK_LOSSY:return this.sendLossyBytes(s,t);case pe.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 T(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 T(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(pe.RELIABLE);const t=this.dataChannelForKind(pe.RELIABLE);t&&(this.reliableMessageBuffer.popToSequence(e),this.reliableMessageBuffer.getAll().forEach(n=>{t.send(n.data)})),this.updateAndEmitDCBufferStatus(pe.RELIABLE)})}waitForBufferStatusLow(e){return T(this,void 0,void 0,function*(){return new Ft((t,n)=>T(this,void 0,void 0,function*(){if(this.isClosed&&n(new Ke("engine closed")),this.isBufferStatusLow(e))t();else{const i=this.dataChannelForKind(e);if(!i){n(new Ke("DataChannel not found, kind: ".concat(e)));return}this.bufferStatusLowClosingFuture.promise.catch(s=>n(s)),i.addEventListener("bufferedamountlow",()=>t(),{once:!0})}}))})}ensureDataTransportConnected(e){return T(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 Ke("PC manager is closed");const a=i?n.pcManager.subscriber:n.pcManager.publisher,A=i?"Subscriber":"Publisher";if(!a)throw se.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 Tt(50)}throw se.internal("could not establish ".concat(A," connection, state: ").concat(a.getICEConnectionState()))}()})}ensurePublisherConnected(e){return T(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!(!this.pcManager||![Ve.CONNECTING,Ve.CONNECTED].includes(this.pcManager.currentState)||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return T(this,void 0,void 0,function*(){return new Ft((e,t)=>T(this,void 0,void 0,function*(){if(!this.pcManager){t(new ci("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 ci("cannot negotiate on closed engine")),this.on(z.Closing,i),this.on(z.Restarting,i),this.pcManager.publisher.off(Fr.RTPVideoPayloadTypes,this.onRtpMapAvailable),this.pcManager.publisher.once(Fr.RTPVideoPayloadTypes,this.onRtpMapAvailable);try{yield this.pcManager.negotiate(n),e()}catch(s){if(n.signal.aborted){e();return}s instanceof ci&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",Yr.RR_UNKNOWN),s instanceof Error?t(s):t(new Error(String(s)))}finally{this.off(z.Closing,i),this.off(z.Restarting,i)}}))})}dataChannelForKind(e,t){switch(e){case pe.RELIABLE:return t?this.reliableDCSub:this.reliableDC;case pe.LOSSY:return t?this.lossyDCSub:this.lossyDC;case pe.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,m=new Array;e.forEach(g=>{g.isDesired!==u&&h.push(g.trackSid),g.isEnabled||m.push(g.trackSid)}),this.client.sendSyncState(new qd({answer:this.pcManager.mode==="publisher-only"?c?ni({sdp:c.sdp,type:c.type}):void 0:d?ni({sdp:d.sdp,type:d.type}):void 0,offer:this.pcManager.mode==="publisher-only"?o?ni({sdp:o.sdp,type:o.type}):void 0:l?ni({sdp:l.sdp,type:l.type}):void 0,subscription:new vo({trackSids:h,subscribe:!u,participantTracks:[]}),publishTracks:i4(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:m,datachannelReceiveStates:this.reliableReceivedState.map((g,y)=>new ym({publisherSid:y,lastSeq:g})),publishDataTracks:n.map(g=>new Hd({info:NA.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 wm({label:n.label,id:n.id,target:i}))};return t(this.dataChannelForKind(pe.LOSSY),yn.PUBLISHER),t(this.dataChannelForKind(pe.RELIABLE),yn.PUBLISHER),t(this.dataChannelForKind(pe.LOSSY,!0),yn.SUBSCRIBER),t(this.dataChannelForKind(pe.RELIABLE,!0),yn.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&it.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){Ht()&&(window.addEventListener("online",this.handleBrowserOnLine),window.addEventListener("offline",this.handleBrowserOffline))}deregisterOnLineListener(){Ht()&&(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=>ie(s,1)[0]===n);if(i)return i[1]}}}function eh(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 Gl=5e3,L2=3e4;class Be{static fetchRegionSettings(e,t,n){return T(this,void 0,void 0,function*(){const i=yield Be.fetchLock.lock();try{const s=yield fetch("".concat(O2(e),"/regions"),{headers:{authorization:"Bearer ".concat(t)},signal:n});if(s.ok){const a=U4(s.headers),A=a?a*1e3:Gl;return{regionSettings:yield s.json(),updatedAtInMs:Date.now(),maxAgeInMs:A}}else throw s.status===401?se.notAllowed("Could not fetch region settings: ".concat(s.statusText),s.status):se.internal("Could not fetch region settings: ".concat(s.statusText))}catch(s){throw s instanceof se?s:n!=null&&n.aborted?se.cancelled("Region fetching was aborted"):se.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 T(this,void 0,void 0,function*(){const i=Be.settingsTimeouts.get(e.hostname);clearTimeout(i),Be.settingsTimeouts.set(e.hostname,setTimeout(()=>T(this,void 0,void 0,function*(){try{const s=yield Be.fetchRegionSettings(e,t);Be.updateCachedRegionSettings(e,t,s)}catch(s){if(s instanceof se&&s.reason===Ie.NotAllowed){fe.debug("token is not valid, cancelling auto region refresh");return}fe.debug("auto refetching of region settings failed",{error:s}),Be.scheduleRefetch(e,t,n)}}),n))})}static updateCachedRegionSettings(e,t,n){Be.cache.set(e.hostname,n),Be.scheduleRefetch(e,t,n.maxAgeInMs)}static stopRefetch(e){const t=Be.settingsTimeouts.get(e);t&&(clearTimeout(t),Be.settingsTimeouts.delete(e))}static scheduleCleanup(e){let t=Be.connectionTrackers.get(e);t&&(t.cleanupTimeout&&clearTimeout(t.cleanupTimeout),t.cleanupTimeout=setTimeout(()=>{const n=Be.connectionTrackers.get(e);n&&n.connectionCount===0&&(fe.debug("stopping region refetch after disconnect delay",{hostname:e}),Be.stopRefetch(e)),n&&(n.cleanupTimeout=void 0)},L2))}static cancelCleanup(e){const t=Be.connectionTrackers.get(e);t!=null&&t.cleanupTimeout&&(clearTimeout(t.cleanupTimeout),t.cleanupTimeout=void 0)}notifyConnected(){const e=this.serverUrl.hostname;let t=Be.connectionTrackers.get(e);t||(t={connectionCount:0},Be.connectionTrackers.set(e,t)),t.connectionCount++,Be.cancelCleanup(e)}notifyDisconnected(){const e=this.serverUrl.hostname,t=Be.connectionTrackers.get(e);t&&(t.connectionCount=Math.max(0,t.connectionCount-1),t.connectionCount===0&&Be.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=Be.cache.get(n.hostname);Be.scheduleRefetch(this.serverUrl,this.token,(t=i==null?void 0:i.maxAgeInMs)!==null&&t!==void 0?t:Gl)}isCloud(){return ji(this.serverUrl)}getServerUrl(){return this.serverUrl}fetchRegionSettings(e){return T(this,void 0,void 0,function*(){return Be.fetchRegionSettings(this.serverUrl,this.token,e)})}getNextBestRegionUrl(e){return T(this,void 0,void 0,function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");let t=Be.cache.get(this.serverUrl.hostname);(!t||Date.now()-t.updatedAtInMs>t.maxAgeInMs)&&(t=yield this.fetchRegionSettings(e),Be.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),fe.debug("next region: ".concat(i.region)),i.url}else return null})}resetAttempts(){this.attemptedRegions=[]}setServerReportedRegions(e){Be.updateCachedRegionSettings(this.serverUrl,this.token,e)}}Be.cache=new Map;Be.settingsTimeouts=new Map;Be.connectionTrackers=new Map;Be.fetchLock=new wt;function O2(r){return"".concat(r.protocol.replace("ws","http"),"//").concat(r.host,"/settings")}class bg{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 tn("Not enough chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, only received ").concat(this.bytesReceived," bytes"),Et.Incomplete);if(this.bytesReceived>this.totalByteSize)throw new tn("Extra chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, received ").concat(this.bytesReceived," bytes"),Et.LengthExceeded)}}constructor(e,t,n){this.reader=t,this.totalByteSize=n,this._info=e,this.bytesReceived=0}}class H2 extends bg{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:()=>T(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 T(this,void 0,void 0,function*(){return t(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return T(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=wn(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 N2 extends bg{constructor(e,t,n){super(e,t,n),this.receivedChunks=new Map}handleChunkReceived(e){var t;const n=pA(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:()=>T(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 tn("Cannot decode datastream chunk ".concat(s.value.chunkIndex," as text: ").concat(A),Et.DecodeFailed)}return{done:!1,value:a}}}catch(s){throw i(),s}}),return(){return T(this,void 0,void 0,function*(){return i(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return T(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=wn(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 K2{constructor(){this.log=fe,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 tn('A text stream handler for topic "'.concat(e,'" has already been set.'),Et.HandlerAlreadyRegistered);this.textStreamHandlers.set(e,t)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,t){if(this.byteStreamHandlers.has(e))throw new tn('A byte stream handler for topic "'.concat(e,'" has already been set.'),Et.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 tn("Participant ".concat(e," unexpectedly disconnected in the middle of sending data"),Et.AbnormalEnd);for(const A of n){var i=ie(A,2);const o=i[0];i[1].controller.error(a),this.byteStreamControllers.delete(o)}for(const A of t){var s=ie(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:pA(e.timestamp),attributes:e.attributes,encryptionType:n},o=new ReadableStream({start:c=>{if(a=c,this.textStreamControllers.has(e.streamId))throw new tn("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),Et.AlreadyOpened);this.byteStreamControllers.set(e.streamId,{info:A,controller:a,startTime:Date.now(),sendingParticipantIdentity:t})}});s(new H2(A,o,pA(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 tn("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),Et.AlreadyOpened);this.textStreamControllers.set(e.streamId,{info:A,controller:a,startTime:Date.now(),sendingParticipantIdentity:t})}});s(new N2(A,o,pA(e.totalLength)),{identity:t})}}handleStreamChunk(e,t){const n=this.byteStreamControllers.get(e.streamId);n&&(n.info.encryptionType!==t?(n.controller.error(new tn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(n.info.encryptionType),Et.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 tn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(i.info.encryptionType),Et.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 tn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(n.info.encryptionType),Et.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 tn("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(i.info.encryptionType),Et.EncryptionTypeMismatch)):(i.info.attributes=Object.assign(Object.assign({},i.info.attributes),e.attributes),i.controller.close()),this.byteStreamControllers.delete(e.streamId))}}class Bg{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 T(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 V2 extends Bg{}class z2 extends Bg{}const th=15e3;class G2{constructor(e,t){this.engine=e,this.log=t}setupEngine(e){this.engine=e}sendText(e,t){return T(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 m=o.reduce((g,y)=>g+y,0);(h=t==null?void 0:t.onProgress)===null||h===void 0||h.call(t,m)},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)=>T(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 T(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?Qe.GCM:Qe.NONE,attachedStreamIds:e==null?void 0:e.attachedStreamIds},A=new RA({streamId:s,mimeType:a.mimeType,topic:a.topic,timestamp:Zr(a.timestamp),totalLength:Zr(a.size),attributes:a.attributes,contentHeader:{case:"textHeader",value:new cm({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"?bl.UPDATE:bl.CREATE})}}),o=e==null?void 0:e.destinationIdentities,c=new Ct({destinationIdentities:o,value:{case:"streamHeader",value:A}});yield this.engine.sendDataPacket(c,pe.RELIABLE);let l=0;const d=this.engine,u=new WritableStream({write(g){return T(this,void 0,void 0,function*(){for(const y of E4(g,th)){const b=new PA({content:y,streamId:s,chunkIndex:Zr(l)}),B=new Ct({destinationIdentities:o,value:{case:"streamChunk",value:b}});yield d.sendDataPacket(B,pe.RELIABLE),l+=1}})},close(){return T(this,void 0,void 0,function*(){const g=new DA({streamId:s}),y=new Ct({destinationIdentities:o,value:{case:"streamTrailer",value:g}});yield d.sendDataPacket(y,pe.RELIABLE)})},abort(g){}});let h=()=>T(this,void 0,void 0,function*(){yield m.close()});d.once(z.Closing,h);const m=new V2(u,a,()=>this.engine.off(z.Closing,h));return m})}sendFile(e,t){return T(this,void 0,void 0,function*(){const n=crypto.randomUUID();return yield this._sendFile(n,e,t),{id:n}})}_sendFile(e,t,n){return T(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 T(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?Qe.GCM:Qe.NONE},l=new RA({totalLength:Zr(c.size),mimeType:c.mimeType,streamId:A,topic:c.topic,timestamp:Zr(Date.now()),attributes:c.attributes,contentHeader:{case:"byteHeader",value:new lm({name:c.name})}}),d=new Ct({destinationIdentities:o,value:{case:"streamHeader",value:l}});yield this.engine.sendDataPacket(d,pe.RELIABLE);let u=0;const h=new wt,m=this.engine,g=this.log,y=new WritableStream({write(B){return T(this,void 0,void 0,function*(){const U=yield h.lock();let w=0;try{for(;w<B.byteLength;){const C=B.slice(w,w+th),E=new Ct({destinationIdentities:o,value:{case:"streamChunk",value:new PA({content:C,streamId:A,chunkIndex:Zr(u)})}});yield m.sendDataPacket(E,pe.RELIABLE),u+=1,w+=C.byteLength}}finally{U()}})},close(){return T(this,void 0,void 0,function*(){const B=new DA({streamId:A}),U=new Ct({destinationIdentities:o,value:{case:"streamTrailer",value:B}});yield m.sendDataPacket(U,pe.RELIABLE)})},abort(B){g.error("Sink error:",B)}});return new z2(y,c)})}}function Cg(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 Sg(r){const e=new AbortController;return setTimeout(()=>{e.abort(new DOMException("signal timed out after ".concat(r," ms"),"TimeoutError"))},r),e.signal}const $e=1,Jn=2,nh=4,q2=8,rh=0,ih=12,sh=5,W2=7,ah=3,$2=3,Ah=2,oh=1,ch=0,lh=3,Sa=2,dh=2,X2=1,J2=0;var tr;(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"})(tr||(tr={}));class Ut extends dn{constructor(e,t,n){super(19,e,n),this.name="DataTrackDeserializeError",this.reason=t,this.reasonName=tr[t]}static tooShort(){return new Ut("Too short to contain a valid header",tr.TooShort)}static headerOverrun(){return new Ut("Header exceeds total packet length",tr.HeaderOverrun)}static missingExtWords(){return new Ut("Extension word indicator is missing",tr.MissingExtWords)}static unsupportedVersion(e){return new Ut("Unsupported version ".concat(e),tr.UnsupportedVersion)}static invalidHandle(e){return new Ut("invalid track handle: ".concat(e.message),tr.InvalidHandle,{cause:e})}static malformedExt(e){return new Ut("Extension with tag ".concat(e," is malformed"),tr.MalformedExt)}}var Ds;(function(r){r[r.TooSmallForHeader=0]="TooSmallForHeader",r[r.TooSmallForPayload=1]="TooSmallForPayload"})(Ds||(Ds={}));class na extends dn{constructor(e,t,n){super(19,e,n),this.name="DataTrackSerializeError",this.reason=t,this.reasonName=Ds[t]}static tooSmallForHeader(){return new na("Buffer cannot fit header",Ds.TooSmallForHeader)}static tooSmallForPayload(){return new na("Buffer cannot fit payload",Ds.TooSmallForPayload)}}class Bo{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 Zi;(function(r){r[r.UserTimestamp=2]="UserTimestamp",r[r.E2ee=1]="E2ee"})(Zi||(Zi={}));class Tg extends Bo{}class Bn extends Tg{constructor(e){super(),this.timestamp=e}toBinaryLengthBytes(){return $e+$e+Bn.lengthBytes}toBinaryInto(e){let t=0;e.setUint8(t,Bn.tag),t+=$e,e.setUint8(t,Bn.lengthBytes),t+=$e,e.setBigUint64(t,this.timestamp),t+=q2;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:Bn.tag,lengthBytes:Bn.lengthBytes,timestamp:this.timestamp}}}Bn.tag=Zi.UserTimestamp;Bn.lengthBytes=8;class Cn extends Tg{constructor(e,t){super(),this.keyIndex=e,this.iv=t}toBinaryLengthBytes(){return $e+$e+Cn.lengthBytes}toBinaryInto(e){let t=0;e.setUint8(t,Cn.tag),t+=$e,e.setUint8(t,Cn.lengthBytes),t+=$e,e.setUint8(t,this.keyIndex),t+=$e;for(let i=0;i<this.iv.length;i+=1)e.setUint8(t,this.iv[i]),t+=$e;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:Cn.tag,lengthBytes:Cn.lengthBytes,keyIndex:this.keyIndex,iv:this.iv}}}Cn.tag=Zi.E2ee;Cn.lengthBytes=13;class Vi extends Bo{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=nu(e);let n,i,s=0;for(;t.byteLength-s>=$e+$e;){const a=t.getUint8(s);s+=$e;const A=t.getUint8(s);if(s+=$e,a!==J2)switch(a){case Zi.UserTimestamp:if(t.byteLength-s<Bn.lengthBytes)throw Ut.malformedExt(a);n=new Bn(t.getBigUint64(s)),s+=A;break;case Zi.E2ee:if(t.byteLength-s<Cn.lengthBytes)throw Ut.malformedExt(a);const o=t.getUint8(s),c=new Uint8Array(12);for(let l=0;l<c.length;l+=1){let d=s;d+=$e,d+=l*$e,c[l]=t.getUint8(d)}i=new Cn(o,c),s+=A;break;default:if(t.byteLength-s<A)throw Ut.malformedExt(a);s+=A;break}}return[new Vi({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 kg={from(r){return{payload:r.payload,extensions:new Vi({userTimestamp:r.userTimestamp?new Bn(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}}},xg=Symbol.for("lk.track"),Eg=Symbol.for("lk.data-track");class Ug{constructor(e,t,n){this.trackSymbol=xg,this.isLocal=!1,this.typeSymbol=Eg,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=ie(t,2),i=n[0];return n[1].catch(()=>{}),i}catch(t){throw t}}setPipelineOptions(e){this.manager.setPipelineOptions(this.info.sid,e)}}class ra extends Bo{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 Vi}extensionsMetrics(){const e=this.extensions.toBinaryLengthBytes(),t=Math.ceil((Sa+e)/4),n=t*4-Sa-e;return{lengthBytes:e,lengthWords:t,paddingLengthBytes:n}}toBinaryLengthBytes(){const e=this.extensionsMetrics(),t=e.lengthBytes,n=e.paddingLengthBytes;let i=ih;return t>0&&(i+=Sa+t+n),i}toBinaryInto(e){if(e.byteLength<this.toBinaryLengthBytes())throw na.tooSmallForHeader();let t=rh<<sh,n;switch(this.marker){case De.Inter:n=ch;break;case De.Final:n=oh;break;case De.Start:n=Ah;break;case De.Single:n=lh;break}t|=n<<ah;const i=this.extensionsMetrics(),s=i.lengthBytes,a=i.lengthWords,A=i.paddingLengthBytes;s>0&&(t|=1<<dh);let o=0;if(e.setUint8(o,t),o+=$e,e.setUint8(o,0),o+=$e,e.setUint16(o,this.trackHandle),o+=Jn,e.setUint16(o,this.sequence.value),o+=Jn,e.setUint16(o,this.frameNumber.value),o+=Jn,e.setUint32(o,this.timestamp.asTicks()),o+=nh,s>0){const l=a-1;e.setUint16(o,l),o+=Jn;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+=$e}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=nu(e);if(t.byteLength<ih)throw Ut.tooShort();let n=0;const i=t.getUint8(n);n+=$e;const s=i>>sh&W2;if(s>rh)throw Ut.unsupportedVersion(s);let a;switch(i>>ah&$2){case Ah:a=De.Start;break;case oh:a=De.Final;break;case lh:a=De.Single;break;case ch:default:a=De.Inter;break}const A=(i>>dh&X2)>0;n+=$e;let o;try{o=J4.fromNumber(t.getUint16(n))}catch(h){throw h instanceof Yi&&(h.isReason(di.Reserved)||h.isReason(di.TooLarge))?Ut.invalidHandle(h):h}n+=Jn;const c=Tn.u16(t.getUint16(n));n+=Jn;const l=Tn.u16(t.getUint16(n));n+=Jn;const d=Ki.fromRtpTicks(t.getUint32(n));n+=nh;let u=new Vi;if(A){if(t.byteLength-n<Jn)throw Ut.missingExtWords();let h=t.getUint16(n);n+=Jn;let g=4*(h+1)-Sa;if(n+g>t.byteLength)throw Ut.headerOverrun();let y=new DataView(t.buffer,t.byteOffset+n,g);const b=Vi.fromBinary(y),B=ie(b,2),U=B[0],w=B[1];u=U,n+=w}return[new ra({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 De;(function(r){r[r.Start=0]="Start",r[r.Inter=1]="Inter",r[r.Final=2]="Final",r[r.Single=3]="Single"})(De||(De={}));class Co extends Bo{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 na.tooSmallForPayload();for(let s=0;s<this.payload.length;s+=1)e.setUint8(t,this.payload[s]),t+=$e;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=nu(e),n=ra.fromBinary(t),i=ie(n,2),s=i[0],a=i[1],A=t.buffer.slice(t.byteOffset+a,t.byteOffset+t.byteLength);return[new Co(s,new Uint8Array(A)),t.byteLength]}toJSON(){return{header:this.header.toJSON(),payload:this.payload}}}const Sc=Kt(pt.DataTracks);class Dn extends dn{constructor(e,t,n,i){super(19,"Frame ".concat(n," dropped: ").concat(e),i),this.name="DataTrackDepacketizerDropError",this.reason=t,this.reasonName=ri[t],this.frameNumber=n}static interrupted(e,t){return new Dn("Interrupted by the start of a new frame ".concat(t),ri.Interrupted,e)}static unknownFrame(e){return new Dn("Initial packet was never received.",ri.UnknownFrame,e)}static bufferFull(e){return new Dn("Reorder buffer is full.",ri.BufferFull,e)}static incomplete(e,t,n){return new Dn("Not all packets received before final packet. Received ".concat(t," packets, expected ").concat(n," packets."),ri.Incomplete,e)}}var ri;(function(r){r[r.Interrupted=0]="Interrupted",r[r.UnknownFrame=1]="UnknownFrame",r[r.BufferFull=2]="BufferFull",r[r.Incomplete=3]="Incomplete"})(ri||(ri={}));class So{constructor(){this.partials=new Map}push(e,t){switch(e.header.marker){case De.Single:return this.frameFromSingle(e,t);case De.Start:return this.beginPartial(e,t);case De.Inter:case De.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!==De.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 Dn.interrupted(s,e.header.frameNumber.value);Sc.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!==De.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 Dn.interrupted(o,s);Sc.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!==De.Inter&&e.header.marker!==De.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),Dn.unknownFrame(t);if(n.payloads.size>=So.MAX_BUFFER_PACKETS)throw this.partials.delete(t),Dn.bufferFull(t);return n.payloads.has(e.header.sequence.value)&&Sc.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===De.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),Dn.incomplete(e,i,n-t.startSequence.value+1)}}So.MAX_BUFFER_PACKETS=128;var ii;(function(r){r[r.Unpublished=0]="Unpublished",r[r.Timeout=1]="Timeout",r[r.Disconnected=2]="Disconnected",r[r.Cancelled=4]="Cancelled"})(ii||(ii={}));class Dt extends dn{constructor(e,t,n){super(22,e,n),this.name="DataTrackSubscribeError",this.reason=t,this.reasonName=ii[t]}static unpublished(){return new Dt("The track has been unpublished and is no longer available",ii.Unpublished)}static timeout(){return new Dt("Request to subscribe to data track timed-out",ii.Timeout)}static disconnected(){return new Dt("Cannot subscribe to data track when disconnected",ii.Disconnected)}static cancelled(){return new Dt("Subscription to data track cancelled by caller",ii.Cancelled)}}const Tc=Kt(pt.DataTracks);class j2{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 So;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 T(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 Tc.warn("Data frame depacketize error: ".concat(n)),null}return t}decryptIfNeeded(e){return T(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 Tc.error("Missing E2EE meta"),null;let a;try{a=yield i.handleEncryptedData(e.payload,s.iv,this.publisherIdentity,s.keyIndex)}catch(A){return Tc.error("Error decrypting packet: ".concat(A)),null}return e.payload=a.payload,e})}}const gt=Kt(pt.DataTracks),Y2=1e4,Z2=16;class eB extends zt.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){gt.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]:Z2,i=null;const s=new ft,a=()=>{t==null||t.removeEventListener("abort",o)},A=()=>{if(a(),!i){gt.warn("ReadableStream subscribed to ".concat(e," was not started."));return}const l=this.descriptors.get(e);if(!l){gt.warn("Unknown track ".concat(e,", skipping cancel..."));return}if(l.subscription.type!=="active"){gt.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(Dt.cancelled()),(l=s.reject)===null||l===void 0||l.call(s,Dt.cancelled()),A()};return[new ReadableStream({start:l=>{i=l,this.subscribeRequest(e,t).then(()=>T(this,void 0,void 0,function*(){var d,u,h;const m=this.descriptors.get(e);if(!m){gt.error("Unknown track ".concat(e));const g=Dt.disconnected();l.error(g),(d=s.reject)===null||d===void 0||d.call(s,g);return}if(m.subscription.type!=="active"){gt.error("Subscription for track ".concat(e," is not active"));const g=Dt.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),m.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 T(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)=>T(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=Cg([a,A].filter(d=>typeof d<"u")),c=new ft;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,Dt.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 ft,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?Dt.timeout():Dt.cancelled()))}},this.emit("sfuUpdateSubscription",{sid:e,subscribe:!0});const s=Sg(Y2);yield i(n,t,s);return}case"pending":{n.subscription.pendingRequestCount+=1,yield i(n,t);return}case"active":return}})}querySubscribed(){return T(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"){gt.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=ie(i,2);const s=n[0],a=n[1];a();try{s.close()}catch(A){gt.warn("Failed to close readable stream for track ".concat(t,": ").concat(A))}}}receiveSfuPublicationUpdates(e){return T(this,void 0,void 0,function*(){if(e.size===0)return;const t=new Map;for(const s of e.entries()){var n=ie(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=ie(s,2);const a=i[0],A=i[1];let c=Array.from(this.descriptors.entries()).filter(l=>{let d=ie(l,2);return d[0],d[1].publisherIdentity===a}).map(l=>ie(l,1)[0]).filter(l=>!A.has(l));for(const l of c)this.handleTrackUnpublished(l)}})}queryPublications(){return T(this,void 0,void 0,function*(){return Array.from(this.descriptors.values()).map(e=>e.info)})}handleTrackPublished(e,t){return T(this,void 0,void 0,function*(){if(this.descriptors.has(t.sid)){gt.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 Ug(n.info,this,{publisherIdentity:e});this.emit("trackPublished",{track:i})})}handleTrackUnpublished(e){const t=this.descriptors.get(e);if(!t){gt.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=ie(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){gt.error("Unknown track ".concat(t));return}switch(s.subscription.type){case"none":{gt.warn("No subscription for ".concat(t));return}case"active":{s.subscription.subcriptionHandle=e,this.subscriptionHandles.set(e,t);return}case"pending":{const a=new j2({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 T(this,void 0,void 0,function*(){let t;try{var n=Co.fromBinary(e),i=ie(n,1);t=i[0]}catch(o){gt.error("Failed to deserialize packet: ".concat(o));return}const s=this.subscriptionHandles.get(t.header.trackHandle);if(!s){gt.warn("Unknown subscriber handle ".concat(t.header.trackHandle));return}const a=this.descriptors.get(s);if(!a){gt.error("Missing descriptor for track ".concat(s));return}if(a.subscription.type!=="active"){gt.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){gt.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=kg.lossyIntoFrame(A);o.enqueue(c)}})}resendSubscriptionUpdates(){for(const t of this.descriptors){var e=ie(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,Dt.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,Dt.disconnected())),n.subscription.type==="active"&&this.closeStreamControllers(n.subscription.streamControllers,n.info.sid);this.descriptors.clear(),this.subscriptionHandles.clear()}}class To extends dn{constructor(e,t,n){super(19,e,n),this.name="DataTrackPacketizerError",this.reason=t,this.reasonName=GA[t]}static mtuTooShort(){return new To("MTU is too short to send frame",GA.MtuTooShort)}}var GA;(function(r){r[r.MtuTooShort=0]="MtuTooShort"})(GA||(GA={}));class ou{constructor(e,t){this.sequence=Tn.u16(0),this.frameNumber=Tn.u16(0),this.clock=ti.rtpStartingNow(Ki.rtpRandom()),this.handle=e,this.mtuSizeBytes=t}static computeFrameMarker(e,t){return t<=1?De.Single:e===0?De.Start:e===t-1?De.Final:De.Inter}*packetize(e,t){var n;const i=this.frameNumber.getThenIncrement(),s={marker:De.Inter,trackHandle:this.handle,sequence:Tn.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 ra(s).toBinaryLengthBytes();if(a>=this.mtuSizeBytes)throw To.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 ra(Object.assign(Object.assign({},s),{marker:ou.computeFrameMarker(l,o),sequence:u})),m=Math.min(A,e.payload.byteLength-d),g=new Uint8Array(e.payload.buffer,e.payload.byteOffset+d,m);yield new Co(h,g)}}}var pn;(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"})(pn||(pn={}));class ct extends dn{constructor(e,t,n){super(21,e,n),this.name="DataTrackPublishError",this.reason=t,this.reasonName=pn[t],this.rawMessage=n==null?void 0:n.rawMessage}static notAllowed(e){return new ct("Data track publishing unauthorized",pn.NotAllowed,{rawMessage:e})}static duplicateName(e){return new ct("Track name already taken",pn.DuplicateName,{rawMessage:e})}static invalidName(e){return new ct("Track name is invalid",pn.InvalidName,{rawMessage:e})}static timeout(){return new ct("Publish data track timed-out. Does the LiveKit server support data tracks?",pn.Timeout)}static limitReached(e){return new ct("Data track publication limit reached",pn.LimitReached,{rawMessage:e})}static unknown(e,t){return new ct("Received RequestResponse for publishDataTrack, but reason was unrecognised (".concat(e,", ").concat(t,")"),pn.Unknown)}static disconnected(){return new ct("Room disconnected",pn.Disconnected)}static cancelled(){return new ct("Publish data track cancelled by caller",pn.Cancelled)}}var Ls;(function(r){r[r.TrackUnpublished=0]="TrackUnpublished",r[r.Dropped=1]="Dropped"})(Ls||(Ls={}));class Ir extends dn{constructor(e,t,n){super(22,e,n),this.name="DataTrackPushFrameError",this.reason=t,this.reasonName=Ls[t]}static trackUnpublished(){return new Ir("Track is no longer published",Ls.TrackUnpublished)}static dropped(e){return new Ir("Frame was dropped",Ls.Dropped,{cause:e})}}var Os;(function(r){r[r.Packetizer=0]="Packetizer",r[r.Encryption=1]="Encryption"})(Os||(Os={}));class ia extends dn{constructor(e,t,n){super(21,e,n),this.name="DataTrackOutgoingPipelineError",this.reason=t,this.reasonName=Os[t]}static packetizer(e){return new ia("Error packetizing frame",Os.Packetizer,{cause:e})}static encryption(e){return new ia("Error encrypting frame",Os.Encryption,{cause:e})}}class ko{constructor(e,t){this.trackSymbol=xg,this.isLocal=!0,this.typeSymbol=Eg,this.handle=null,this.log=fe,this.flushedFuture=new ft,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 ft)},this.options=e,this.manager=t,this.log=Kt(pt.DataTracks),this.manager.on("packetsFlushedChange",this.handleManagerPacketsFlushedChange),this.manager.on("reset",this.handleManagerReset)}static withExplicitHandle(e,t,n){const i=new ko(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 T(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 Ir.trackUnpublished();const t=kg.from(e);try{return this.manager.tryProcessAndSend(this.handle,t)}catch(n){throw n}}flush(){return T(this,void 0,void 0,function*(){if(!this.isFlushed)return this.flushedFuture.promise})}unpublish(){return T(this,void 0,void 0,function*(){if(!this.handle){fe.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 xo{constructor(e){this.e2eeManager=e.e2eeManager,this.packetizer=new ou(e.info.pubHandle,xo.TRANSPORT_MTU_BYTES)}updateE2eeManager(e){this.e2eeManager=e}processFrame(e){return Qb(this,arguments,function*(){const n=yield Ji(this.encryptIfNeeded(e));try{yield Ji(yield*Mb(wn(this.packetizer.packetize(n))))}catch(i){throw i instanceof To?ia.packetizer(i):i}})}encryptIfNeeded(e){return T(this,void 0,void 0,function*(){if(!this.e2eeManager)return e;let t;try{t=yield this.e2eeManager.encryptData(e.payload)}catch(n){throw ia.encryption(n)}return e.payload=t.payload,e.extensions.e2ee=new Cn(t.keyIndex,t.iv),e})}}xo.TRANSPORT_MTU_BYTES=16e3;const In=Kt(pt.DataTracks),uh={pending(){return{type:"pending",completionFuture:new ft}},active(r,e){return{type:"active",info:r,publishState:"published",pipeline:new xo({info:r,e2eeManager:e}),unpublishingFuture:new ft}}},tB=1e4;class cu extends zt.EventEmitter{constructor(e){var t;super(),this.handleAllocator=new j4,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 T(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 Ir.trackUnpublished();if(o.publishState==="republishing")throw Ir.dropped("Data track republishing");try{try{for(var c=!0,l=wn(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 Ir.dropped(u)}})}handlePacketSendComplete(e){var t;let i=((t=this.inFlightPacketCounter.get(e))!==null&&t!==void 0?t:0)-1;i<0&&(In.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 T(this,void 0,void 0,function*(){const n=this.handleAllocator.get();if(!n)throw ct.limitReached();const i=Sg(tB),s=t?Cg([t,i]):i;if(this.descriptors.has(n))throw new Error("Descriptor for handle already exists");const a=uh.pending();this.descriptors.set(n,a);const A=()=>{var o,c;const l=this.descriptors.get(n);if(!l){In.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?ct.timeout():ct.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:ko.withExplicitHandle(e,this,n)}),n)})}queryPublished(){return Array.from(this.descriptors.values()).filter(t=>t.type==="active").map(t=>t.info)}unpublishRequest(e){return T(this,void 0,void 0,function*(){const t=this.descriptors.get(e);if(!t){In.warn("No descriptor for ".concat(e));return}if(t.type!=="active"){In.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){In.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,uh.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"){In.warn("Track ".concat(e," already active"));return}if(t.type==="error"){In.warn("Republish failed for track ".concat(e));return}In.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){In.warn("No descriptor for ".concat(e));return}if(this.descriptors.delete(e),i.type!=="active"){In.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=ie(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,ct.disconnected());break;case"active":a.publishState="republishing",this.emit("sfuPublishRequest",{handle:a.info.pubHandle,name:a.info.name,usesE2ee:a.info.usesE2ee})}}}reset(){return T(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,ct.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 xe extends Error{constructor(e,t,n,i){super(t),this.code=e,this.message=hh(t,xe.MAX_MESSAGE_BYTES),this.data=n?hh(n,xe.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 xe(e.code,e.message,e.data)}toProto(){return new em({code:this.code,message:this.message,data:this.data})}static builtIn(e,t,n){return new xe(xe.ErrorCode[e],xe.ErrorMessage[e],t,n)}}xe.MAX_MESSAGE_BYTES=256;xe.MAX_DATA_BYTES=15360;xe.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};xe.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 Fg=15360,Ig="lk.rpc_request",Qg="lk.rpc_response";var vt;(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"})(vt||(vt={}));const nB=1,Mg=2;function lu(r){return new TextEncoder().encode(r).length}function hh(r,e){if(lu(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 rB extends zt.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 T(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(lu(a)>Fg&&d<LA)throw xe.builtIn("REQUEST_PAYLOAD_TOO_LARGE");const h=n.getServerVersion();if(h&&Vn(h,"1.8.0")<0)throw xe.builtIn("UNSUPPORTED_SERVER");const m=Math.max(o,8e3),g=crypto.randomUUID(),y=new ft;let b=null;const B=setTimeout(()=>{var w;n.pendingAcks.delete(g),(w=y.reject)===null||w===void 0||w.call(y,xe.builtIn("CONNECTION_TIMEOUT")),n.pendingResponses.delete(g),b!==null&&clearTimeout(b)},7e3);n.pendingAcks.set(g,{resolve:()=>{clearTimeout(B)},participantIdentity:i}),n.pendingResponses.set(g,{completionFuture:y,participantIdentity:i}),yield n.publishRpcRequest(i,g,s,a,m,d),b=setTimeout(()=>{var w;n.pendingResponses.delete(g),(w=y.reject)===null||w===void 0||w.call(y,xe.builtIn("RESPONSE_TIMEOUT"))},o);const U=y.promise.finally(()=>{clearTimeout(b),n.pendingAcks.has(g)&&(n.log.warn("RPC response received before ack",g),n.pendingAcks.delete(g),clearTimeout(B))});return[g,U]}()})}publishRpcRequest(e,t,n,i,s,a){return T(this,void 0,void 0,function*(){if(a>=LA){const A=yield this.outgoingDataStreamManager.streamText({topic:Ig,destinationIdentities:[e],attributes:{[vt.RPC_REQUEST_ID]:t,[vt.RPC_REQUEST_METHOD]:n,[vt.RPC_REQUEST_RESPONSE_TIMEOUT_MS]:"".concat(s),[vt.RPC_REQUEST_VERSION]:"".concat(Mg)}});yield A.write(i),yield A.close();return}this.emit("sendDataPacket",{packet:new Ct({destinationIdentities:[e],kind:_r.RELIABLE,value:{case:"rpcRequest",value:new Dd({id:t,method:n,payload:i,responseTimeoutMs:s,version:nB})}})})})}handleIncomingDataStream(e,t,n){return T(this,void 0,void 0,function*(){const i=n[vt.RPC_REQUEST_ID];if(!i){this.log.warn("RPC data stream malformed: ".concat(vt.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,xe.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=ie(a,2);const A=n[0];n[1].participantIdentity===e&&this.pendingAcks.delete(A)}for(const a of this.pendingResponses){var i=ie(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,xe.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(A))}}}class iB extends zt.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 T(this,void 0,void 0,function*(){var n;if(this.publishRpcAck(e,t.id),t.version!==1){this.publishRpcResponsePacket(e,t.id,null,xe.builtIn("UNSUPPORTED_VERSION"));return}const i=this.rpcHandlers.get(t.method);if(!i){this.publishRpcResponsePacket(e,t.id,null,xe.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 xe?A=a:(this.log.warn("Uncaught error returned by RPC handler for ".concat(t.method,". Returning APPLICATION_ERROR instead."),a),A=xe.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 T(this,void 0,void 0,function*(){const i=n[vt.RPC_REQUEST_ID],s=n[vt.RPC_REQUEST_METHOD],a=parseInt(n[vt.RPC_REQUEST_RESPONSE_TIMEOUT_MS],10),A=parseInt(n[vt.RPC_REQUEST_VERSION],10);if(!i||!s||Number.isNaN(a)||Number.isNaN(A)){this.log.warn("RPC data stream malformed: ".concat(vt.RPC_REQUEST_ID," / ").concat(vt.RPC_REQUEST_METHOD," / ").concat(vt.RPC_REQUEST_RESPONSE_TIMEOUT_MS," / ").concat(vt.RPC_REQUEST_VERSION," not set.")),this.publishRpcResponsePacket(t,i,null,xe.builtIn("APPLICATION_ERROR","RPC data stream malformed"));return}if(this.publishRpcAck(t,i),A!==Mg){this.publishRpcResponsePacket(t,i,null,xe.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,xe.builtIn("APPLICATION_ERROR","Error reading RPC request payload",{cause:d}));return}const c=this.rpcHandlers.get(s);if(!c){this.publishRpcResponsePacket(t,i,null,xe.builtIn("UNSUPPORTED_METHOD"));return}let l;try{l=yield c({requestId:i,callerIdentity:t,payload:o,responseTimeout:a})}catch(d){let u;d instanceof xe?u=d:(this.log.warn("Uncaught error returned by RPC handler for ".concat(s,". Returning APPLICATION_ERROR instead."),d),u=xe.builtIn("APPLICATION_ERROR")),this.publishRpcResponsePacket(t,i,null,u);return}yield this.publishRpcResponse(t,i,l??"")})}publishRpcAck(e,t){this.emit("sendDataPacket",{packet:new Ct({destinationIdentities:[e],kind:_r.RELIABLE,value:{case:"rpcAck",value:new po({requestId:t})}})})}publishRpcResponsePacket(e,t,n,i){this.emit("sendDataPacket",{packet:new Ct({destinationIdentities:[e],kind:_r.RELIABLE,value:{case:"rpcResponse",value:new Ld({requestId:t,value:i?{case:"error",value:i.toProto()}:{case:"payload",value:n??""}})}})})}publishRpcResponse(e,t,n){return T(this,void 0,void 0,function*(){if(this.getRemoteParticipantClientProtocol(e)>=LA){const a=yield this.outgoingDataStreamManager.streamText({topic:Qg,destinationIdentities:[e],attributes:{[vt.RPC_REQUEST_ID]:t}});yield a.write(n),yield a.close();return}if(lu(n)>Fg){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,xe.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"));return}this.publishRpcResponsePacket(e,t,n,null)})}}class sB extends hg{constructor(e,t,n,i,s,a){super(e,t,H.Kind.Audio,n,a),this.monitorReceiver=()=>T(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=bo(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;xn()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(xn())return 1;let e=0;return this.attachedElements.forEach(t=>{t.volume>e&&(e=t.volume)}),e}setSinkId(e){return T(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(t=>{if(Ol(t))return t.setSinkId(e)}))})}attach(e){const t=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&Ol(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 T(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 ir extends zt.EventEmitter{constructor(e,t,n,i){var s;super(),this.metadataMuted=!1,this.encryption=Qe.NONE,this.log=fe,this.handleMuted=()=>{this.emit($.Muted)},this.handleUnmuted=()=>{this.emit($.Unmuted)},this.log=Kt((s=i==null?void 0:i.loggerName)!==null&&s!==void 0?s:pt.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=t,this.trackName=n,this.source=H.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)),ve(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==Qe.NONE}get audioTrack(){if(Hn(this.track))return this.track}get videoTrack(){if(ur(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=H.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===H.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={}))})(ir||(ir={}));class ql extends ir{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&&ur(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 T(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.mute()})}unmute(){return T(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.unmute()})}pauseUpstream(){return T(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.pauseUpstream()})}resumeUpstream(){return T(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if(Hn(this.track)){const t=this.track.getSourceTrackSettings(),n=new Set;return t.autoGainControl&&n.add(ut.TF_AUTO_GAIN_CONTROL),t.echoCancellation&&n.add(ut.TF_ECHO_CANCELLATION),t.noiseSuppression&&n.add(ut.TF_NOISE_SUPPRESSION),t.channelCount&&t.channelCount>1&&n.add(ut.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||n.add(ut.TF_NO_DTX),this.track.enhancedNoiseCancellation&&n.add(ut.TF_ENHANCED_NOISE_CANCELLATION),Array.from(n.values())}else return[]}}function Eo(r,e){return T(this,void 0,void 0,function*(){r??(r={});let t=!1;const n=Ag(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=ig(a,pg,mg),l=Xd(c),d=navigator.mediaDevices.getUserMedia(l);a.audio&&(ht.userMediaPromiseMap.set("audioinput",d),d.catch(()=>ht.userMediaPromiseMap.delete("audioinput"))),a.video&&(ht.userMediaPromiseMap.set("videoinput",d),d.catch(()=>ht.userMediaPromiseMap.delete("videoinput")));try{const u=yield d;return yield Promise.all(u.getTracks().map(h=>T(this,void 0,void 0,function*(){const m=h.kind==="audio";let g;const y=m?l.audio:l.video;typeof y!="boolean"&&(g=y);const b=h.getSettings().deviceId;g!=null&&g.deviceId&&li(g.deviceId)!==b?g.deviceId=b:g||(g={deviceId:b});const B=w2(h,g,e);return B.kind===H.Kind.Video?B.source=H.Source.Camera:B.kind===H.Kind.Audio&&(B.source=H.Source.Microphone),B.mediaStream=u,Hn(B)&&i?yield B.setProcessor(i):ur(B)&&s&&(yield B.setProcessor(s)),B})))}catch(u){if(!t)throw u;return Eo(Object.assign(Object.assign({},r),{audio:A,video:o}),e)}})}function aB(r){return T(this,void 0,void 0,function*(){return(yield Eo({audio:!1,video:!0}))[0]})}function AB(r){return T(this,void 0,void 0,function*(){return(yield Eo({audio:!0,video:!1}))[0]})}var Er;(function(r){r.Excellent="excellent",r.Good="good",r.Poor="poor",r.Lost="lost",r.Unknown="unknown"})(Er||(Er={}));function oB(r){switch(r){case bs.EXCELLENT:return Er.Excellent;case bs.GOOD:return Er.Good;case bs.POOR:return Er.Poor;case bs.LOST:return Er.Lost;default:return Er.Unknown}}class _g extends zt.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===Xs.AGENT}get isActive(){var e;return((e=this.participantInfo)===null||e===void 0?void 0:e.state)===Pi.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]:Xs.STANDARD;var o;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=Er.Unknown,this.log=fe,this.loggerOptions=a,this.log=Kt((o=a==null?void 0:a.loggerName)!==null&&o!==void 0?o:pt.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=ie(n,2);const i=t[1];if(i.source===e)return i}}getTrackPublicationByName(e){for(const n of this.trackPublications){var t=ie(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 ft,this.once(J.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(H.Source.Camera);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const t=this.getTrackPublication(H.Source.Microphone);return!(!((e=t==null?void 0:t.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(H.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===Pi.ACTIVE&&((t=this.participantInfo)===null||t===void 0?void 0:t.state)!==Pi.ACTIVE&&this.emit(J.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(J.ParticipantMetadataChanged,n)}_setName(e){const t=this.name!==e;this.name=e,t&&this.emit(J.ParticipantNameChanged,e)}_setAttributes(e){const t=a4(this.attributes,e);this._attributes=e,Object.keys(t).length>0&&this.emit(J.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(J.ParticipantPermissionsChanged,o),c}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(J.IsSpeakingChanged,e))}setConnectionQuality(e){const t=this._connectionQuality;this._connectionQuality=oB(e),t!==this._connectionQuality&&this.emit(J.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=>Hn(t.track)&&t.track.setAudioContext(e))}addTrackPublication(e){e.on($.Muted,()=>{this.emit(J.TrackMuted,e)}),e.on($.Unmuted,()=>{this.emit(J.TrackUnmuted,e)});const t=e;switch(t.track&&(t.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case H.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case H.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function cB(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 gm({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 lB extends _g{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=Qe.NONE,this.e2eeStateMutex=new wt,this.enabledPublishVideoCodecs=[],this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new ft)},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,m;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),(m=(h=this.activeAgentFuture)===null||h===void 0?void 0:h.reject)===null||m===void 0||m.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 ft),(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!==ei.OK&&h.reject(new S0(u,d)),this.pendingSignalRequests.delete(l)),c.request.case){case"publishDataTrack":{let m;switch(c.reason){case ei.NOT_ALLOWED:m=ct.notAllowed(c.message);break;case ei.DUPLICATE_NAME:m=ct.duplicateName(c.message);break;case ei.INVALID_NAME:m=ct.invalidName(c.message);break;case ei.LIMIT_EXCEEDED:m=ct.limitReached(c.message);break;default:m=ct.unknown(c.reason,c.message);break}this.roomOutgoingDataTrackManager.receivedSfuPublishResponse(c.request.value.pubHandle,{type:"error",error:m});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=>cB(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",ve(c));return}this.engine.updateMuteStatus(c.sid,l)},this.onTrackUpstreamPaused=c=>{this.log.debug("upstream paused",ve(c)),this.onTrackMuted(c,!0)},this.onTrackUpstreamResumed=c=>{this.log.debug("upstream resumed",ve(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",ve(l)),this.emit(J.LocalTrackCpuConstrained,c,l)},this.handleSubscribedQualityUpdate=c=>T(this,void 0,void 0,function*(){var l,d,u,h,m;if(!(!((m=this.roomOptions)===null||m===void 0)&&m.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 y=yield g.videoTrack.setPublishingCodecs(c.subscribedCodecs);try{for(var b=!0,B=wn(y),U;U=yield B.next(),l=U.done,!l;b=!0){h=U.value,b=!1;const w=h;t4(w)&&(this.log.debug("publish ".concat(w," for ").concat(g.videoTrack.sid),ve(g)),yield this.publishAdditionalCodecForTrack(g.videoTrack,w,g.options))}}catch(w){d={error:w}}finally{try{!b&&!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=>T(this,void 0,void 0,function*(){if(c.source===H.Source.ScreenShare||c.source===H.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",ve(c)),this.unpublishTrack(c);else if(c.isUserProvided)yield c.mute();else if(er(c)||Fn(c))try{if(Ht())try{const l=yield navigator==null?void 0:navigator.permissions.query({name:c.source===H.Source.Camera?"camera":"microphone"});if(l&&l.state==="denied")throw this.log.warn("user has revoked access to ".concat(c.source),ve(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",ve(c)),er(c)?yield c.restartTrack({deviceId:"default"}):yield c.restartTrack())}catch{this.log.warn("could not restart track, muting instead",ve(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!==Qe.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(z.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(z.Connected,this.handleReconnected).on(z.SignalConnected,this.handleSignalConnected).on(z.SignalRestarted,this.handleReconnected).on(z.SignalResumed,this.handleReconnected).on(z.Restarting,this.handleReconnecting).on(z.Resuming,this.handleReconnecting).on(z.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(z.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(z.Closing,this.handleClosing).on(z.SignalRequestResponse,this.handleSignalRequestResponse)}setMetadata(e){return T(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return T(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return T(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return T(this,arguments,void 0,function(t){var n=this;let i=t.metadata,s=t.name,a=t.attributes;return function*(){return new Ft((A,o)=>T(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:m=>{o(m),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(m=>{let g=ie(m,2),y=g[0],b=g[1];return this.attributes[y]===b||b===""&&!this.attributes[y]}))){this.pendingSignalRequests.delete(u),A();return}yield Tt(50)}o(new S0("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(H.Source.Camera,e,t,n)}setMicrophoneEnabled(e,t,n){return this.setTrackEnabled(H.Source.Microphone,e,t,n)}setScreenShareEnabled(e,t,n){return this.setTrackEnabled(H.Source.ScreenShare,e,t,n)}setE2EEEnabled(e){return T(this,void 0,void 0,function*(){const t=yield this.e2eeStateMutex.lock();try{if(this.encryptionType=e?Qe.GCM:Qe.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 T(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 H.Source.Camera:d=yield this.createTracks({video:(s=n)!==null&&s!==void 0?s:!0});break;case H.Source.Microphone:d=yield this.createTracks({audio:(a=n)!==null&&a!==void 0?a:!0});break;case H.Source.ScreenShare:d=yield this.createScreenTracks(Object.assign({},n));break;default:throw new or(e)}}catch(u){throw d==null||d.forEach(h=>{h.stop()}),u instanceof Error&&this.emit(J.MediaDevicesError,u,Pl(e)),this.pendingPublishing.delete(e),u}for(const u of d){const h=Object.assign(Object.assign({},this.roomOptions.publishDefaults),n);e===H.Source.Microphone&&Hn(u)&&h.preConnectBuffer&&(this.log.info("starting preconnect buffer for microphone"),u.startPreConnectBuffer())}try{const u=[];for(const m of d)this.log.info("publishing track",ve(m)),u.push(this.publishTrack(m,i));const h=yield Promise.all(u);var o=ie(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===H.Source.ScreenShare){const d=[this.unpublishTrack(A.track)],u=this.getTrackPublication(H.Source.ScreenShareAudio);u&&u.track&&d.push(this.unpublishTrack(u.track));var c=yield Promise.all(d),l=ie(c,1);A=l[0]}else yield A.mute();return A})}enableCameraAndMicrophone(){return T(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(H.Source.Camera)||this.pendingPublishing.has(H.Source.Microphone))){this.pendingPublishing.add(H.Source.Camera),this.pendingPublishing.add(H.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(H.Source.Camera),this.pendingPublishing.delete(H.Source.Microphone)}}})}createTracks(e){return T(this,void 0,void 0,function*(){var t,n;e??(e={});const i=ig(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 Eo(i,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext})).map(A=>(Hn(A)&&(this.microphoneError=void 0,A.setAudioContext(this.audioContext),A.source=H.Source.Microphone,this.emit(J.AudioStreamAcquired)),ur(A)&&(this.cameraError=void 0,A.source=H.Source.Camera),A))}catch(s){throw s instanceof Error&&(e.audio&&(this.microphoneError=s),e.video&&(this.cameraError=s)),s}})}createScreenTracks(e){return T(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new Wd("getDisplayMedia not supported");e.resolution===void 0&&!m4()&&(e.resolution=$d.h1080fps30.resolution);const t=r4(e),n=yield navigator.mediaDevices.getDisplayMedia(t),i=n.getVideoTracks();if(i.length===0)throw new or("no video track found");const s=new zA(i[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});s.source=H.Source.ScreenShare,e.contentHint&&(s.mediaStreamTrack.contentHint=e.contentHint);const a=[s];if(n.getAudioTracks().length>0){this.emit(J.AudioStreamAcquired);const A=new KA(n.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});A.source=H.Source.ScreenShareAudio,a.push(A)}return a})}publishTrack(e,t){return T(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(z.Restarted,s),this.engine.off(z.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(z.Restarted,s),this.engine.once(z.Closing,a)})}publishOrRepublishTrack(e,t){return T(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;er(n)&&n.setAudioContext(s.audioContext),yield(o=s.reconnectFuture)===null||o===void 0?void 0:o.promise,s.republishPromise&&!a&&(yield s.republishPromise),Hi(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 H.Source.Microphone:B="audioinput";break;case H.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 KA(n,u,!0,s.audioContext,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;case"video":n=new zA(n,u,!0,{loggerName:s.roomOptions.loggerName,loggerContextCb:()=>s.logContext});break;default:throw new or("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",ve(h)),h;const m=Object.assign(Object.assign({},s.roomOptions.publishDefaults),i),g="channelCount"in n.mediaStreamTrack.getSettings()&&n.mediaStreamTrack.getSettings().channelCount===2||n.mediaStreamTrack.getConstraints().channelCount===2,y=(c=m.forceStereo)!==null&&c!==void 0?c:g;y&&(m.dtx===void 0&&s.log.debug("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",ve(n)),m.red===void 0&&s.log.debug("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(l=m.dtx)!==null&&l!==void 0||(m.dtx=!1),(d=m.red)!==null&&d!==void 0||(m.red=!1)),!v4()&&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"),m.simulcast=!1),m.source&&(n.source=m.source);const b=new Promise((B,U)=>T(s,void 0,void 0,function*(){try{if(this.engine.client.currentState!==Fe.CONNECTED){this.log.debug("deferring track publication until signal is connected",{track:ve(n)});let w=!1;const C=setTimeout(()=>{w=!0,n.stop(),U(new C0("publishing rejected as engine not connected within timeout",408))},15e3);if(yield this.waitUntilEngineConnected(),clearTimeout(C),w)return;const E=yield this.publish(n,m,y);B(E)}else try{const w=yield this.publish(n,m,y);B(w)}catch(w){U(w)}}catch(w){U(w)}}));s.pendingPublishPromises.set(n,b);try{return yield b}catch(B){if(!A&&B instanceof ci)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 ft),this.signalConnectedFuture.promise}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",ve(e)),!1;const t=this.permissions,n=t.canPublish,i=t.canPublishSources;return n&&(i.length===0||i.map(s=>A4(s)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",ve(e)),!1)}publish(e,t,n){return T(this,void 0,void 0,function*(){var i,s,a,A,o,c,l,d,u,h;if(!this.hasPermissionsToPublish(e))throw new C0("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(L=>Hi(e)&&L.source===e.source)&&e.source!==H.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),ve(e)),t.stopMicTrackOnMute&&Hn(e)&&(e.stopOnMute=!0),e.source===H.Source.ScreenShare&&mi()&&(t.simulcast=!1),t.videoCodec==="av1"&&!u4()&&(t.videoCodec=void 0),t.videoCodec==="vp9"&&!h4()&&(t.videoCodec=void 0),t.videoCodec===void 0&&(t.videoCodec=Vl),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(L=>t.videoCodec===Rs(L.mime))||(t.videoCodec=Rs(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 y=[],b=!(!((i=t.dtx)!==null&&i!==void 0)||i),B=e.getSourceTrackSettings();B.autoGainControl&&y.push(ut.TF_AUTO_GAIN_CONTROL),B.echoCancellation&&y.push(ut.TF_ECHO_CANCELLATION),B.noiseSuppression&&y.push(ut.TF_NOISE_SUPPRESSION),B.channelCount&&B.channelCount>1&&y.push(ut.TF_STEREO),b&&y.push(ut.TF_NO_DTX),er(e)&&e.hasPreConnectBuffer&&y.push(ut.TF_PRECONNECT_BUFFER);const U=this.normalizeRequestedFrameMetadataOptions(e,t),w=new Js({cid:e.mediaStreamTrack.id,name:t.name,type:H.kindToProto(e.kind),muted:e.isMuted,source:H.sourceToProto(e.source),disableDtx:b,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:y,packetTrailerFeatures:U});let C;if(e.kind===H.Kind.Video){let L;try{L=yield e.waitForDimensions()}catch{const q=(A=(a=this.roomOptions.videoCaptureDefaults)===null||a===void 0?void 0:a.resolution)!==null&&A!==void 0?A:js.h720.resolution;L={width:q.width,height:q.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign({},ve(e)),{dims:L}))}w.width=L.width,w.height=L.height,Fn(e)&&(bn(g)&&(e.source===H.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",ve(e)))),t.scalabilityMode=(o=t.scalabilityMode)!==null&&o!==void 0?o:"L3T3_KEY"),w.simulcastCodecs=[new Cl({codec:g,cid:e.mediaStreamTrack.id})],t.backupCodec===!0&&(t.backupCodec={codec:Vl}),t.backupCodec&&g!==t.backupCodec.codec&&w.encryption===Qe.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),w.simulcastCodecs.push(new Cl({codec:t.backupCodec.codec,cid:""})))),C=VA(e.source===H.Source.ScreenShare,w.width,w.height,t),w.layers=X0(w.width,w.height,C,bn(t.videoCodec))}else e.kind===H.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 Ke("cannot publish track when not connected");const E=()=>T(this,void 0,void 0,function*(){var L,O,q;if(!this.engine.pcManager)throw new Ke("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,t,C),Fn(e)&&(e.publishOptions=t),this.emit(J.LocalSenderCreated,e.sender,e),Fn(e)&&((L=t.degradationPreference)!==null&&L!==void 0||(t.degradationPreference=U2(e)),e.setDegradationPreference(t.degradationPreference)),C)if(mi()&&e.kind===H.Kind.Audio){let ue;for(const ce of this.engine.pcManager.publisher.getTransceivers())if(ce.sender===e.sender){ue=ce;break}ue&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:ue,codec:"opus",maxbr:!((O=C[0])===null||O===void 0)&&O.maxBitrate?C[0].maxBitrate/1e3:0})}else e.codec&&bn(e.codec)&&(!((q=C[0])===null||q===void 0)&&q.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:w.cid,codec:e.codec,maxbr:C[0].maxBitrate/1e3});yield this.engine.negotiate()});let I;const _=new Promise((L,O)=>T(this,void 0,void 0,function*(){var q;try{I=yield this.engine.addTrack(w),L(I)}catch(ue){if(e.sender&&(!((q=this.engine.pcManager)===null||q===void 0)&&q.publisher)){try{this.engine.pcManager.publisher.removeTrack(e.sender)}catch(ce){this.log.error(ce)}yield this.engine.negotiate().catch(ce=>{this.log.error("failed to negotiate after removing track due to failed add track request",Object.assign(Object.assign({},ve(e)),{error:ce}))})}O(ue)}}));if(this.enabledPublishVideoCodecs.length>0&&U.length===0)I=(yield Promise.all([_,E()]))[0];else{I=yield _;let L;if(I.codecs.forEach(O=>{L===void 0&&(L=O.mimeType)}),L&&e.kind===H.Kind.Video){const O=Rs(L);O!==g&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign({},ve(e)),{codec:O})),t.videoCodec=O,C=VA(e.source===H.Source.ScreenShare,w.width,w.height,t))}yield E()}const P=new ql(e.kind,I,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(P.on($.CpuConstrained,L=>this.onTrackCpuConstrained(L,P)),P.options=t,e.sid=I.sid,Fn(e)&&(e.publishOptions=t,w.width&&w.height&&(e.lastEncodedDimensions={width:w.width,height:w.height})),this.log.debug("publishing ".concat(e.kind," with encodings"),{encodings:C,trackInfo:I}),Fn(e)?e.startMonitor(this.engine.client):er(e)&&e.startMonitor(),this.addTrackPublication(P),this.emit(J.LocalTrackPublished,P),er(e)&&I.audioFeatures.includes(ut.TF_PRECONNECT_BUFFER)){const L=e.getPreConnectBuffer(),O=e.getPreConnectBufferMimeType();this.on(J.LocalTrackSubscribed,q=>{if(q.trackSid===I.sid){if(!e.hasPreConnectBuffer){this.log.warn("subscribe event came to late, buffer already closed");return}this.log.debug("finished recording preconnect buffer",ve(e)),e.stopPreConnectBuffer()}}),L&&new Promise((ue,ce)=>T(this,void 0,void 0,function*(){var ne,re,he,Se,Re,Je;try{this.log.debug("waiting for agent",ve(e));const Un=setTimeout(()=>{ce(new Error("agent not active within 10 seconds"))},1e4),Xn=yield this.waitUntilActiveAgentPresent();clearTimeout(Un),this.log.debug("sending preconnect buffer",ve(e));const Yt=yield this.streamBytes({name:"preconnect-buffer",mimeType:O,topic:"lk.agent.pre-connect-audio-buffer",destinationIdentities:[Xn.identity],attributes:{trackId:P.trackSid,sampleRate:String((Re=B.sampleRate)!==null&&Re!==void 0?Re:"48000"),channels:String((Je=B.channelCount)!==null&&Je!==void 0?Je:"1")}});try{for(var mt=!0,At=wn(L),qt;qt=yield At.next(),ne=qt.done,!ne;mt=!0){Se=qt.value,mt=!1;const kt=Se;yield Yt.write(kt)}}catch(kt){re={error:kt}}finally{try{!mt&&!ne&&(he=At.return)&&(yield he.call(At))}finally{if(re)throw re.error}}yield Yt.close(),ue()}catch(Un){ce(Un)}})).then(()=>{this.log.debug("preconnect buffer sent successfully",ve(e))}).catch(ue=>{this.log.error("error sending preconnect buffer",Object.assign(Object.assign({},ve(e)),{error:ue}))})}return P})}canPublishFrameMetadata(){var e;return!!(this.roomOptions.e2ee||this.roomOptions.encryption||ta((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!==H.Kind.Video||!HA(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),ve(e))),t.frameMetadata=void 0,t.packetTrailer=void 0,[];const s=N4(i),a=K4(s);return t.frameMetadata=a,t.packetTrailer=a,s}get isLocal(){return!0}publishAdditionalCodecForTrack(e,t,n){return T(this,void 0,void 0,function*(){var i;if(this.encryptionType!==Qe.NONE)return;let s;if(this.trackPublications.forEach(m=>{m.track&&m.track===e&&(s=m)}),!s)throw new or("track is not published");if(!Fn(e))throw new or("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=vg(e,t,a);if(!A){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",ve(e));return}const o=e.addSimulcastTrack(t,A);if(!o)return;const c=this.normalizeRequestedFrameMetadataOptions(e,a),l=new Js({cid:o.mediaStreamTrack.id,type:H.kindToProto(e.kind),muted:e.isMuted,source:H.sourceToProto(e.source),sid:e.sid,packetTrailerFeatures:c,simulcastCodecs:[{codec:a.videoCodec,cid:o.mediaStreamTrack.id}]});if(l.layers=X0(l.width,l.height,A),!this.engine||this.engine.isClosed)throw new Ke("cannot publish track when not connected");const d=()=>T(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 T(this,void 0,void 0,function*(){var n,i;if(Hi(e)){const l=this.pendingPublishPromises.get(e);l&&(this.log.debug("awaiting publish promise before attempting to unpublish",ve(e)),yield l)}const s=this.getPublicationForTrack(e),a=s?ve(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<Ve.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(Fn(e)){for(const l of e.simulcastCodecs){var c=ie(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 H.Kind.Audio:this.audioTrackPublications.delete(s.trackSid);break;case H.Kind.Video:this.videoTrackPublications.delete(s.trackSid);break}return this.emit(J.LocalTrackUnpublished,s),s.setTrack(void 0),A&&(yield this.engine.negotiate()),s})}unpublishTracks(e){return T(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>this.unpublishTrack(n)))).filter(n=>!!n)})}republishAllTracks(e){return T(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 Ft((s,a)=>T(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=>T(this,void 0,void 0,function*(){const c=o.track;yield this.unpublishTrack(c,!1),i&&!c.isMuted&&c.source!==H.Source.ScreenShare&&c.source!==H.Source.ScreenShareAudio&&(er(c)||Fn(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 T(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?pe.RELIABLE:pe.LOSSY,a=i.reliable?_r.RELIABLE:_r.LOSSY,A=i.destinationIdentities,o=i.topic;let c=new Pd({participantIdentity:n.identity,payload:t,destinationIdentities:A,topic:o});const l=new Ct({kind:a,value:{case:"user",value:c}});yield n.engine.sendDataPacket(l,s)}()})}publishDtmf(e,t){return T(this,void 0,void 0,function*(){const n=new Ct({kind:_r.RELIABLE,value:{case:"sipDtmf",value:new Zp({code:e,digit:t})}});yield this.engine.sendDataPacket(n,pe.RELIABLE)})}sendChatMessage(e,t){return T(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 Ct({value:{case:"chatMessage",value:new _A(Object.assign(Object.assign({},n),{timestamp:Le.parse(n.timestamp)}))}});return yield this.engine.sendDataPacket(i,pe.RELIABLE),this.emit(J.ChatMessage,n),n})}editChatMessage(e,t){return T(this,void 0,void 0,function*(){const n=Object.assign(Object.assign({},t),{message:e,editTimestamp:Date.now()}),i=new Ct({value:{case:"chatMessage",value:new _A(Object.assign(Object.assign({},n),{timestamp:Le.parse(n.timestamp),editTimestamp:Le.parse(n.editTimestamp)}))}});return yield this.engine.sendDataPacket(i,pe.RELIABLE),this.emit(J.ChatMessage,n),n})}sendText(e,t){return T(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendText(e,t)})}streamText(e){return T(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamText(e)})}sendFile(e,t){return T(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendFile(e,t)})}streamBytes(e){return T(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamBytes(e)})}performRpc(e){return this.rpcClientManager.performRpc(e).then(t=>{let n=ie(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({},ve(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 ft),this.activeAgentFuture.promise)}getPublicationForTrack(e){let t;return this.trackPublications.forEach(n=>{const i=n.track;i&&(e instanceof MediaStreamTrack?(er(i)||Fn(i))&&i.mediaStreamTrack===e&&(t=n):e===i&&(t=n))}),t}waitForPendingPublicationOfSource(e){return T(this,void 0,void 0,function*(){const n=Date.now();for(;Date.now()<n+1e4;){const i=Array.from(this.pendingPublishPromises.entries()).find(s=>ie(s,1)[0].source===e);if(i)return i[1];yield Tt(20)}})}publishDataTrack(e){return T(this,void 0,void 0,function*(){const t=new ko(e,this.roomOutgoingDataTrackManager);return yield t.publish(),t})}}class fh extends DOMException{constructor(e,t){super(e,"AbortError"),this.reason=t}}class dB 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 T(this,void 0,void 0,function*(){const n=this.get(e);if(typeof n<"u")return n;if(t!=null&&t.aborted)throw new fh("The operation was aborted.",t.reason);const i=new ft(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 fh("The operation was aborted.",t.reason))};t.addEventListener("abort",a,{once:!0}),i.promise.finally(()=>{t.removeEventListener("abort",a)})}return i.promise})}}class uB extends ir{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 vo({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new tm({participantSid:"",trackSids:[this.trackSid]})]});this.emit($.UpdateSubscription,i),this.emitSubscriptionUpdateIfChanged(t),this.emitPermissionUpdateIfChanged(n)}get subscriptionStatus(){return this.subscribed===!1?ir.SubscriptionStatus.Unsubscribed:super.isSubscribed?ir.SubscriptionStatus.Subscribed:ir.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?ir.PermissionStatus.Allowed:ir.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||(mc(this.track)&&(this.requestedVideoDimensions=e),this.requestedMaxQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&mc(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){var e;return(e=this.requestedMaxQuality)!==null&&e!==void 0?e:Xt.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 mc(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new hm({trackSids:[this.trackSid],disabled:!this.isEnabled,fps:this.fps});if(this.kind===H.Kind.Video){let t=this.requestedVideoDimensions;if(this.videoDimensionsAdaptiveStream!==void 0)if(t)k0(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=o4(this.trackInfo,this.requestedMaxQuality);n&&k0(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:Xt.HIGH})),e.quality=Xt.HIGH)}this.emit($.UpdateSettings,e)}}class qA extends _g{static fromParticipantInfo(e,t,n,i){return new qA(e,t.sid,t.identity,t.name,t.metadata,t.attributes,n,t.kind,t.dataTracks.map(s=>{const a=NA.from(s);return new Ug(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]:Xs.STANDARD,c=arguments.length>8&&arguments[8]!==void 0?arguments[8]:[],l=arguments.length>9&&arguments[9]!==void 0?arguments[9]:ng;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 dB(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),ve(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(J.TrackSubscriptionPermissionChanged,e,t)}),e.on($.SubscriptionStatusChanged,t=>{this.emit(J.TrackSubscriptionStatusChanged,e,t)}),e.on($.Subscribed,t=>{this.emit(J.TrackSubscribed,t,e)}),e.on($.Unsubscribed,t=>{this.emit(J.TrackUnsubscribed,t,e)}),e.on($.SubscriptionFailed,t=>{this.emit(J.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]:H.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]:H.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(J.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),ve(A))),this.emit(J.TrackSubscriptionFailed,t);return}const o=e.kind==="video";let c;return o?c=new eu(e,t,i,s):c=new sB(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)&&Nl(c)&&Hn(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=H.kindFromProto(i.type);if(!o)return;A=new uB(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!==H.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:ve(c),newTrack:ve(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),ve(i))),this.unpublishTrack(i.trackSid,!0))}),n.forEach(i=>{this.emit(J.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 H.Kind.Audio:this.audioTrackPublications.delete(e);break;case H.Kind.Video:this.videoTrackPublications.delete(e);break}t&&this.emit(J.TrackUnpublished,n)}setAudioOutput(e){return T(this,void 0,void 0,function*(){this.audioOutput=e;const t=[];this.audioTrackPublications.forEach(n=>{var i;Hn(n.track)&&Nl(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=ie(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 Te;(function(r){r.Disconnected="disconnected",r.Connecting="connecting",r.Connected="connected",r.Reconnecting="reconnecting",r.SignalReconnecting="signalReconnecting"})(Te||(Te={}));const hB=4*1e3;class es extends zt.EventEmitter{get hasE2EESetup(){return this.e2eeManager!==void 0}constructor(e){var t,n,i,s,a,A,o;if(super(),t=this,this.state=Te.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.e2eeStateMutex=new wt,this.isVideoPlaybackBlocked=!1,this.log=fe,this.bufferedEvents=[],this.isResuming=!1,this.connect=(c,l,d)=>T(this,void 0,void 0,function*(){var u;if(!f4())throw xn()?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===Te.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(Te.Connecting),((u=this.regionUrlProvider)===null||u===void 0?void 0:u.getServerUrl().toString())!==ug(c)&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),ji(new URL(c))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new Be(c,l):this.regionUrlProvider.updateToken(l),this.regionUrlProvider.fetchRegionSettings().then(y=>{var b;(b=this.regionUrlProvider)===null||b===void 0||b.setServerReportedRegions(y)}).catch(y=>{this.log.warn("could not fetch region settings",{error:y})}));const m=(y,b,B)=>T(this,void 0,void 0,function*(){var U,w;this.abortController&&this.abortController.abort();const C=new AbortController;this.abortController=C,h==null||h();try{if(yield Ni.getInstance().getBackOffPromise(c),C.signal.aborted)throw se.cancelled("Connection attempt aborted");yield this.attemptConnection(B??c,l,d,C),this.abortController=void 0,y()}catch(E){if(this.regionUrlProvider&&E instanceof se&&E.reason!==Ie.Cancelled&&E.reason!==Ie.NotAllowed){let I=null;try{this.log.debug("Fetching next region"),I=yield this.regionUrlProvider.getNextBestRegionUrl((U=this.abortController)===null||U===void 0?void 0:U.signal)}catch(_){if(_ instanceof se&&(_.status===401||_.reason===Ie.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),b(_);return}}[Ie.InternalError,Ie.ServerUnreachable,Ie.Timeout].includes(E.reason)&&(this.log.debug("Adding failed connection attempt to back off"),Ni.getInstance().addFailedConnectionAttempt(c)),I&&!(!((w=this.abortController)===null||w===void 0)&&w.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(E.message,". Retrying with another region: ").concat(I)),this.recreateEngine(!0),yield m(y,b,I)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,Q0(E)),b(E))}else{let I=Sn.UNKNOWN_REASON;E instanceof se&&(I=Q0(E)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,I),b(E)}}}),g=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new ft((y,b)=>{m(y,b,g)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(c,l,d,u,h,m)=>T(this,void 0,void 0,function*(){var g;const y=yield d.join(c,l,{autoSubscribe:u.autoSubscribe,adaptiveStream:typeof h.adaptiveStream=="object"?!0:h.adaptiveStream,clientInfoCapabilities:ta((g=h.frameMetadata)!==null&&g!==void 0?g:h.packetTrailer)||this.e2eeManager?[am.CAP_PACKET_TRAILER]:void 0,maxRetries:u.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:u.websocketTimeout},m.signal,!h.singlePeerConnection),b=y.joinResponse,B=y.serverInfo;if(this.serverInfo=B,!B.version)throw new Jb("unknown server version");return B.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version"),h.dynacast=!1),b}),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)=>T(this,void 0,void 0,function*(){var h,m;this.state===Te.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(),!((m=this.regionUrlProvider)===null||m===void 0)&&m.isCloud()&&this.engine.setRegionStrategy(this.createRegionStrategy()),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},au),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(K.SignalConnected)}catch(g){yield this.engine.close(),this.recreateEngine();const y=u.signal.aborted?se.cancelled("Signal connection aborted"):se.serverUnreachable("could not establish signal connection");throw g instanceof Error&&(y.message="".concat(y.message,": ").concat(g.message)),g instanceof se&&(y.reason=g.reason,y.status=g.status),this.log.debug("error trying to establish signal connection",{error:g}),y}if(u.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),se.cancelled("Connection attempt aborted");try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,u)}catch(g){throw yield this.engine.close(),this.recreateEngine(),g}Ht()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),Ht()&&window.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(Te.Connected),this.emit(K.Connected),Ni.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 T(t,[...l],void 0,function(){var u=this;let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var m,g,y;const b=yield u.disconnectLock.lock();try{if(u.state===Te.Disconnected){u.log.debug("already disconnected");return}if(u.log.info("disconnect from room"),u.state===Te.Connecting||u.state===Te.Reconnecting||u.isResuming){const B="Abort connection attempt due to user initiated disconnect";u.log.warn(B),(m=u.abortController)===null||m===void 0||m.abort(B),(y=(g=u.connectFuture)===null||g===void 0?void 0:g.reject)===null||y===void 0||y.call(g,se.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,Sn.CLIENT_INITIATED),u.engine=void 0}finally{b()}}()})},this.onPageLeave=()=>T(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting"),yield this.disconnect()}),this.startAudio=()=>T(this,void 0,void 0,function*(){const c=[],l=Qt();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=pc();h.enabled=!0;const m=new MediaStream([h]);u.srcObject=m,document.addEventListener("visibilitychange",()=>{u&&(u.srcObject=document.hidden?null:m,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(K.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=()=>T(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(Te.Reconnecting)&&this.emit(K.Reconnecting)},this.handleRestarted=()=>{this.outgoingDataTrackManager.sfuWillRepublishTracks(),this.incomingDataTrackManager.resendSubscriptionUpdates()},this.handleSignalRestarted=c=>T(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(Te.Connected),this.emit(K.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===Pi.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=>NA.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(K.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(K.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=H.streamStateFromProto(l.state);u.track.setStreamState(h),h!==u.track.streamState&&(d.emit(J.TrackStreamStateChanged,u,u.track.streamState),this.emitWhenConnected(K.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,xe.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(K.DataReceived,l.payload,c,d,l.topic,u),c==null||c.emit(J.DataReceived,l.payload,d,u)},this.handleSipDtmf=(c,l)=>{this.emit(K.SipDTMFReceived,l,c),c==null||c.emit(J.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=S4(l,this.transcriptionReceivedTimes);u==null||u.emit($.TranscriptionReceived,h),d==null||d.emit(J.TranscriptionReceived,h,u),this.emit(K.TranscriptionReceived,h,d,u)},this.handleChatMessage=(c,l)=>{const d=T4(l);this.emit(K.ChatMessage,d,c)},this.handleMetrics=(c,l)=>{this.emit(K.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(K.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=c=>{this.log.warn("could not playback audio",{error:c}),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(K.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(K.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(K.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>T(this,void 0,void 0,function*(){var c;((c=Qt())===null||c===void 0?void 0:c.os)!=="iOS"&&(yield this.selectDefaultDevices()),this.emit(K.MediaDevicesChanged)}),this.handleRoomUpdate=c=>{const l=this.roomInfo;this.roomInfo=c,l&&l.metadata!==c.metadata&&this.emitWhenConnected(K.RoomMetadataChanged,c.metadata),(l==null?void 0:l.activeRecording)!==c.activeRecording&&this.emitWhenConnected(K.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:ng},this.onLocalParticipantMetadataChanged=c=>{this.emit(K.ParticipantMetadataChanged,c,this.localParticipant)},this.onLocalParticipantNameChanged=c=>{this.emit(K.ParticipantNameChanged,c,this.localParticipant)},this.onLocalAttributesChanged=c=>{this.emit(K.ParticipantAttributesChanged,c,this.localParticipant)},this.onLocalTrackMuted=c=>{this.emit(K.TrackMuted,c,this.localParticipant)},this.onLocalTrackUnmuted=c=>{this.emit(K.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=>T(this,void 0,void 0,function*(){var l,d,u,h,m,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),(m=(h=(u=c.track)===null||u===void 0?void 0:u.getProcessor())===null||h===void 0?void 0:h.onPublish)===null||m===void 0||m.call(h,this),this.emit(K.LocalTrackPublished,c,this.localParticipant),er(c.track)&&(yield c.track.checkForSilence())&&this.emit(K.LocalAudioSilenceDetected,c);const y=yield(g=c.track)===null||g===void 0?void 0:g.getDeviceId(!1),b=Pl(c.source);b&&y&&y!==this.localParticipant.activeDeviceMap.get(b)&&(this.localParticipant.activeDeviceMap.set(b,y),this.emit(K.ActiveDeviceChanged,b,y))}),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(K.LocalTrackUnpublished,c,this.localParticipant)},this.onLocalTrackRestarted=c=>T(this,void 0,void 0,function*(){const l=yield c.getDeviceId(!1),d=Pl(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(K.ActiveDeviceChanged,d,l))}),this.onLocalConnectionQualityChanged=c=>{this.emit(K.ConnectionQualityChanged,c,this.localParticipant)},this.onMediaDevicesError=(c,l)=>{this.emit(K.MediaDevicesError,c,l)},this.onLocalParticipantPermissionsChanged=c=>{this.emit(K.ParticipantPermissionsChanged,c,this.localParticipant)},this.onLocalChatMessageSent=c=>{this.emit(K.ChatMessage,c,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},h2),e),this.log=Kt((n=this.options.loggerName)!==null&&n!==void 0?n:pt.Room,()=>this.logContext),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},pg),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},mg),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},u2),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.incomingDataStreamManager=new K2,this.outgoingDataStreamManager=new G2(this.engine,this.log),this.incomingDataTrackManager=new eB({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(K.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(K.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(K.LocalDataTrackPublished,c.track)}).on("trackUnpublished",c=>{this.emit(K.LocalDataTrackUnpublished,c.sid)}).on("packetAvailable",c=>{let l=c.handle,d=c.bytes;this.engine.sendLossyBytes(d,pe.DATA_TRACK_LOSSY,"wait").finally(()=>this.outgoingDataTrackManager.handlePacketSendComplete(l))}),this.registerRpcDataStreamHandler(),this.rpcClientManager=new rB(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,pe.RELIABLE)}),this.rpcServerManager=new iB(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,pe.RELIABLE)}),this.disconnectLock=new wt,this.localParticipant=new lB("","",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",li(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",li(this.options.audioCaptureDefaults.deviceId)),!((a=this.options.audioOutput)===null||a===void 0)&&a.deviceId&&this.switchActiveDevice("audiooutput",li(this.options.audioOutput.deviceId)).catch(c=>this.log.warn("Could not set audio output: ".concat(c.message))),Ht()){const c=new AbortController;let l;if(es.cleanupRegistry){const d=new WeakRef(this);l=()=>{const u=d.deref();u&&u.handleDeviceChange()},es.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 T(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 z4(i,n),this.e2eeManager.on(Ur.ParticipantEncryptionStatusChanged,(s,a)=>{x4(a)&&(this.isE2EEEnabled=s),this.emit(K.ParticipantEncryptionStatusChanged,s,a)}),this.e2eeManager.on(Ur.EncryptionError,(s,a)=>{const A=a?this.getParticipantByIdentity(a):void 0;this.emit(K.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 W4(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===Te.Disconnected?Ft.resolve(""):this.roomInfo&&this.roomInfo.sid!==""?Ft.resolve(this.roomInfo.sid):new Ft((e,t)=>{const n=i=>{i.sid!==""&&(this.engine.off(z.RoomUpdate,n),e(i.sid))};this.engine.on(z.RoomUpdate,n),this.once(K.Disconnected,()=>{this.engine.off(z.RoomUpdate,n),t(new Ke("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 D2(this.options),this.engine.e2eeManager=this.e2eeManager,this.engine.on(z.ParticipantUpdate,this.handleParticipantUpdates).on(z.RoomUpdate,this.handleRoomUpdate).on(z.SpeakersChanged,this.handleSpeakersChanged).on(z.StreamStateChanged,this.handleStreamStateUpdate).on(z.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(z.SubscriptionError,this.handleSubscriptionError).on(z.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(z.MediaTrackAdded,(e,t,n)=>{this.onTrackAdded(e,t,n)}).on(z.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(z.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(z.DataPacketReceived,this.handleDataPacket).on(z.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.debug("Resuming signal connection"),this.setAndEmitConnectionState(Te.SignalReconnecting)&&this.emit(K.SignalReconnecting)}).on(z.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.debug("Resumed signal connection"),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(Te.Connected)&&this.emit(K.Reconnected)}).on(z.SignalResumed,()=>{this.bufferedEvents=[],(this.state===Te.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(z.Restarting,this.handleRestarting).on(z.Restarted,this.handleRestarted).on(z.SignalRestarted,this.handleSignalRestarted).on(z.Offline,()=>{this.setAndEmitConnectionState(Te.Reconnecting)&&this.emit(K.Reconnecting)}).on(z.DCBufferStatusChanged,(e,t)=>{this.emit(K.DCBufferStatusChanged,e,t)}).on(z.LocalTrackSubscribed,e=>{this.handleLocalTrackSubscribed(e)}).on(z.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(K.Moved,e.room.name),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}).on(z.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!==Qe.NONE}})}).on(z.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(z.DataTrackSubscriberHandles,e=>{const t=new Map(Object.entries(e.subHandles).map(n=>{let i=ie(n,2),s=i[0],a=i[1];return[parseInt(s,10),a.trackSid]}));this.incomingDataTrackManager.receivedSfuSubscriberHandles(t)}).on(z.DataTrackPacketReceived,e=>{try{this.incomingDataTrackManager.packetReceived(e)}catch(t){throw t}}).on(z.Joined,e=>{const t=new Map(e.otherParticipants.map(n=>[n.identity,n.dataTracks.map(i=>NA.from(i))]));this.incomingDataTrackManager.receiveSfuPublicationUpdates(t)}).on(z.TokenRefreshed,e=>{var t;(t=this.regionUrlProvider)===null||t===void 0||t.updateToken(e)}).on(z.ServerRegionsReported,e=>{var t;(t=this.regionUrlProvider)===null||t===void 0||t.setServerReportedRegions({regionSettings:e,updatedAtInMs:Date.now(),maxAgeInMs:Gl})}),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=>T(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 ht.getInstance().getDevices(e,t)}prepareConnection(e,t){return T(this,void 0,void 0,function*(){if(this.state===Te.Disconnected){this.log.debug("prepareConnection to ".concat(e));try{if(ji(new URL(e))&&t){this.regionUrlProvider=new Be(e,t);const n=yield this.regionUrlProvider.getNextBestRegionUrl();n&&this.state===Te.Disconnected&&(this.regionUrl=n,yield fetch(Zs(n),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(n)))}else yield fetch(Zs(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 T(this,void 0,void 0,function*(){let n=()=>T(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 Mn({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":i=new Mn({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":i=new Mn({scenario:{case:"serverLeave",value:!0}});break;case"migration":i=new Mn({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=()=>T(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),i=new Mn({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":n=()=>T(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),i=new Mn({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 Mn({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),n=()=>T(this,void 0,void 0,function*(){const s=this.engine.client.onLeave;s&&s(new yo({reason:Sn.CLIENT_INITIATED,action:Di.RECONNECT}))});break;case"subscriber-bandwidth":if(t===void 0||typeof t!="number")throw new Error("subscriber-bandwidth requires a number as argument");i=new Mn({scenario:{case:"subscriberBandwidth",value:Zr(t)}});break;case"leave-full-reconnect":i=new Mn({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 T(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 m=!0,g=!1;const y=a?{exact:i}:i;if(n==="audioinput"){g=s.localParticipant.audioTrackPublications.size===0;const b=(A=s.getActiveDevice(n))!==null&&A!==void 0?A:s.options.audioCaptureDefaults.deviceId;s.options.audioCaptureDefaults.deviceId=y;const B=Array.from(s.localParticipant.audioTrackPublications.values()).filter(w=>w.source===H.Source.Microphone);try{m=(yield Promise.all(B.map(w=>{var C;return(C=w.audioTrack)===null||C===void 0?void 0:C.setDeviceId(y)}))).every(w=>w===!0)}catch(w){throw s.options.audioCaptureDefaults.deviceId=b,w}const U=B.some(w=>{var C,E;return(E=(C=w.track)===null||C===void 0?void 0:C.isMuted)!==null&&E!==void 0?E:!1});m&&U&&(g=!0)}else if(n==="videoinput"){g=s.localParticipant.videoTrackPublications.size===0;const b=(o=s.getActiveDevice(n))!==null&&o!==void 0?o:s.options.videoCaptureDefaults.deviceId;s.options.videoCaptureDefaults.deviceId=y;const B=Array.from(s.localParticipant.videoTrackPublications.values()).filter(w=>w.source===H.Source.Camera);try{m=(yield Promise.all(B.map(w=>{var C;return(C=w.videoTrack)===null||C===void 0?void 0:C.setDeviceId(y)}))).every(w=>w===!0)}catch(w){throw s.options.videoCaptureDefaults.deviceId=b,w}const U=B.some(w=>{var C,E;return(E=(C=w.track)===null||C===void 0?void 0:C.isMuted)!==null&&E!==void 0?E:!1});m&&U&&(g=!0)}else if(n==="audiooutput"){if(g=!0,!Ol()&&!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 ht.getInstance().normalizeDeviceId("audiooutput",i))!==null&&c!==void 0?c:""),(l=(h=s.options).audioOutput)!==null&&l!==void 0||(h.audioOutput={});const b=(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=b,B}}return g&&(s.localParticipant.activeDeviceMap.set(n,i),s.emit(K.ActiveDeviceChanged,n,i)),m}()})}setupLocalParticipantEvents(){this.localParticipant.on(J.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(J.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(J.AttributesChanged,this.onLocalAttributesChanged).on(J.TrackMuted,this.onLocalTrackMuted).on(J.TrackUnmuted,this.onLocalTrackUnmuted).on(J.LocalTrackPublished,this.onLocalTrackPublished).on(J.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(J.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(J.MediaDevicesError,this.onMediaDevicesError).on(J.AudioStreamAcquired,this.startAudio).on(J.ChatMessage,this.onLocalChatMessageSent).on(J.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===Te.Connecting||this.state===Te.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(K.Reconnected,d),this.off(K.Connected,d),this.off(K.Disconnected,u)};this.once(K.Reconnected,d),this.once(K.Connected,d),this.once(K.Disconnected,u);return}if(this.state===Te.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=d4(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(K.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(J.LocalTrackPublished,a),this.off(K.Disconnected,A)};this.localParticipant.on(J.LocalTrackPublished,a),this.once(K.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(J.LocalTrackSubscribed,e),this.emitWhenConnected(K.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!==Te.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(J.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(J.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(J.AttributesChanged,this.onLocalAttributesChanged).off(J.TrackMuted,this.onLocalTrackMuted).off(J.TrackUnmuted,this.onLocalTrackUnmuted).off(J.LocalTrackPublished,this.onLocalTrackPublished).off(J.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(J.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(J.MediaDevicesError,this.onMediaDevicesError).off(J.AudioStreamAcquired,this.startAudio).off(J.ChatMessage,this.onLocalChatMessageSent).off(J.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),Ht()&&(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(Te.Disconnected),this.emit(K.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(K.ParticipantDisconnected,t),t.setDisconnected(),this.rpcClientManager.handleParticipantDisconnected(t.identity))}selectDefaultDevices(){return T(this,void 0,void 0,function*(){var e,t,n;const i=ht.getInstance().previousDevices,s=yield ht.getInstance().getDevices(void 0,!1),a=Qt();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(K.ActiveDeviceChanged,o.kind,o.deviceId)}const A=["audiooutput","audioinput","videoinput"];for(let o of A){const c=n4(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"&&!Ys()||o==="videoinput"||d.length>0&&!d.find(h=>h.deviceId===this.getActiveDevice(o))&&(o!=="audiooutput"||!Ys())&&(yield this.switchActiveDevice(o,d[0].deviceId))}})}acquireAudioContext(){return T(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=ag())!==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(),Tt(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(K.AudioPlaybackStatusChanged,n))})}createParticipant(e,t){var n;let i;return t?i=qA.fromParticipantInfo(this.engine.client,t,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName},this.incomingDataTrackManager):i=new qA(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(K.ParticipantConnected,n),n.on(J.TrackPublished,i=>{this.emitWhenConnected(K.TrackPublished,i,n)}).on(J.TrackSubscribed,(i,s)=>{i.kind===H.Kind.Audio?(i.on($.AudioPlaybackStarted,this.handleAudioPlaybackStarted),i.on($.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):i.kind===H.Kind.Video&&(i.on($.VideoPlaybackFailed,this.handleVideoPlaybackFailed),i.on($.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emitWhenConnected(K.TrackSubscribed,i,s,n)}).on(J.TrackUnpublished,i=>{this.emit(K.TrackUnpublished,i,n)}).on(J.TrackUnsubscribed,(i,s)=>{this.emit(K.TrackUnsubscribed,i,s,n)}).on(J.TrackMuted,i=>{this.emitWhenConnected(K.TrackMuted,i,n)}).on(J.TrackUnmuted,i=>{this.emitWhenConnected(K.TrackUnmuted,i,n)}).on(J.ParticipantMetadataChanged,i=>{this.emitWhenConnected(K.ParticipantMetadataChanged,i,n)}).on(J.ParticipantNameChanged,i=>{this.emitWhenConnected(K.ParticipantNameChanged,i,n)}).on(J.AttributesChanged,i=>{this.emitWhenConnected(K.ParticipantAttributesChanged,i,n)}).on(J.ConnectionQualityChanged,i=>{this.emitWhenConnected(K.ConnectionQualityChanged,i,n)}).on(J.ParticipantPermissionsChanged,i=>{this.emitWhenConnected(K.ParticipantPermissionsChanged,i,n)}).on(J.TrackSubscriptionStatusChanged,(i,s)=>{this.emitWhenConnected(K.TrackSubscriptionStatusChanged,i,s,n)}).on(J.TrackSubscriptionFailed,(i,s)=>{this.emit(K.TrackSubscriptionFailed,i,n,s)}).on(J.TrackSubscriptionPermissionChanged,(i,s)=>{this.emitWhenConnected(K.TrackSubscriptionPermissionChanged,i,s,n)}).on(J.Active,()=>{this.emitWhenConnected(K.ParticipantActive,n),n.kind===Xs.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&&k4(t)&&t.emitTrackUpdate()}getRemoteParticipantBySid(e){const t=this.sidToIdentity.get(e);if(t)return this.remoteParticipants.get(t)}registerRpcDataStreamHandler(){this.incomingDataStreamManager.registerTextStreamHandler(Ig,(e,t)=>T(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(Qg,(e,t)=>T(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=it.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,Sn.STATE_MISMATCH))):e=0},hB)}clearConnectionReconcile(){this.connectionReconcileInterval&&it.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===Te.Connected),this.emit(K.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let t=ie(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===Te.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,n]);else if(this.state===Te.Connected)return this.emit(e,...n);return!1}simulateParticipants(e){return T(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 ho({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:Le.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new pi({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(K.SignalConnected),this.emit(K.Connected),this.setAndEmitConnectionState(Te.Connected),a.video){const o=new ql(H.Kind.Video,new Mi({source:nt.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:vn.AUDIO,name:"video-dummy"}),new zA(a.useRealTracks&&(!((t=window.navigator.mediaDevices)===null||t===void 0)&&t.getUserMedia)?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:I0(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(J.LocalTrackPublished,o)}if(a.audio){const o=new ql(H.Kind.Audio,new Mi({source:nt.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:vn.AUDIO}),new KA(a.useRealTracks&&(!((i=navigator.mediaDevices)===null||i===void 0)&&i.getUserMedia)?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:pc(),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(J.LocalTrackPublished,o)}for(let o=0;o<A.count-1;o+=1){let c=new pi({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(o),state:Pi.ACTIVE,tracks:[],joinedAt:Le.parse(Date.now())});const l=this.getOrCreateParticipant(c.identity,c);if(A.video){const d=I0(160*((s=A.aspectRatios[o%A.aspectRatios.length])!==null&&s!==void 0?s:1),160,!1,!0),u=new Mi({source:nt.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:vn.AUDIO});l.addSubscribedMediaTrack(d,u.sid,new MediaStream([d]),new RTCRtpReceiver),c.tracks=[...c.tracks,u]}if(A.audio){const d=pc(),u=new Mi({source:nt.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:vn.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!==K.ActiveSpeakersChanged&&e!==K.TranscriptionReceived){const s=Rg(n).filter(a=>a!==void 0);(e===K.TrackSubscribed||e===K.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)}}es.cleanupRegistry=typeof FinalizationRegistry<"u"&&typeof WeakRef<"u"&&new FinalizationRegistry(r=>{r()});function Rg(r){return r.map(e=>{if(e)return Array.isArray(e)?Rg(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var mn;(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"})(mn||(mn={}));class zr extends zt.EventEmitter{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=mn.IDLE,this.logs=[],this.options={},this.url=e,this.token=t,this.name=this.constructor.name,this.room=new es(n.roomOptions),this.connectOptions=n.connectOptions,this.options=n}run(e){return T(this,void 0,void 0,function*(){if(this.status!==mn.IDLE)throw Error("check is running already");this.setStatus(mn.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!==mn.SKIPPED&&this.setStatus(this.isSuccess()?mn.SUCCESS:mn.FAILED),e&&e(),this.getInfo()})}isSuccess(){return!this.logs.some(e=>e.level==="error")}connect(e){return T(this,void 0,void 0,function*(){return this.room.state===Te.Connected?this.room:(e||(e=this.url),yield this.room.connect(e,this.token,this.connectOptions),this.room)})}disconnect(){return T(this,void 0,void 0,function*(){this.room&&this.room.state!==Te.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(mn.SKIPPED)}switchProtocol(e){return T(this,void 0,void 0,function*(){let t=!1,n=!1;if(this.room.on(K.Reconnecting,()=>{t=!0}),this.room.once(K.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 Tt(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 fB extends zr{get description(){return"Cloud regions"}perform(){return T(this,void 0,void 0,function*(){const e=new Be(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 T(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 m=0;m<o;m++)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(m=>{m.type==="candidate-pair"&&m.nominated&&(h.rtt=m.currentRoundTripTime*1e3)}),yield this.disconnect(),h})}}const kc=1e4;class pB extends zr{get description(){return"Connection via UDP vs TCP"}perform(){return T(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/(kc/1e3)*100).toFixed(2),"%")),n.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((n.qualityLimitationDurations.cpu/(kc/1e3)*100).toFixed(2),"%"))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkConnectionProtocol(e){return T(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(()=>T(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,kc)),clearInterval(d),A.stop(),t.remove(),yield this.disconnect(),l})}}class mB extends zr{get description(){return"Can publish audio"}perform(){return T(this,void 0,void 0,function*(){var e;const t=yield this.connect(),n=yield AB();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 gB extends zr{get description(){return"Can publish video"}perform(){return T(this,void 0,void 0,function*(){var e;const t=yield this.connect(),n=yield aB();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 T(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 y=!0;for(let b=0;b<g.length;b+=4)if(g[b]!==0||g[b+1]!==0||g[b+2]!==0){y=!1;break}y?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 vB extends zr{get description(){return"Resuming connection after interruption"}perform(){return T(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(K.SignalReconnecting,A).on(K.Reconnecting,A).on(K.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!==Te.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 yB extends zr{get description(){return"Can connect via TURN"}perform(){return T(this,void 0,void 0,function*(){var e,t,n;ji(new URL(this.url))&&(this.appendMessage("Using region specific url"),this.url=(e=yield new Be(this.url,this.token).getNextBestRegionUrl())!==null&&e!==void 0?e:this.url);const i=new ru,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 wB extends zr{get description(){return"Establishing WebRTC connection"}perform(){return T(this,void 0,void 0,function*(){let e=!1,t=!1;this.room.on(K.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&&(bB(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(),fe.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 bB(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 BB extends zr{get description(){return"Connecting to signal connection via WebSocket"}perform(){return T(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 ru,s;try{s=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3},void 0,!0)}catch(a){if(ji(new URL(this.url))){this.appendMessage("Initial connection failed with error ".concat(a.message,". Retrying with region fallback"));const o=yield new Be(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)===rm.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 aU extends zt.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:mn.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!==mn.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return T(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 T(this,void 0,void 0,function*(){return this.createAndRunCheck(BB)})}checkWebRTC(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(wB)})}checkTURN(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(yB)})}checkReconnect(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(vB)})}checkPublishAudio(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(mB)})}checkPublishVideo(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(gB)})}checkConnectionProtocol(){return T(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(pB);if(e.data&&"protocol"in e.data){const t=e.data;this.options.protocol=t.protocol}return e})}checkCloudRegion(){return T(this,void 0,void 0,function*(){return this.createAndRunCheck(fB)})}}new TextEncoder;new TextDecoder;class Mt extends Error{constructor(e,t){var n;super(e,t),ye(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,(n=Error.captureStackTrace)===null||n===void 0||n.call(Error,this,this.constructor)}}ye(Mt,"code","ERR_JOSE_GENERIC");class CB extends Mt{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}}),ye(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),ye(this,"claim",void 0),ye(this,"reason",void 0),ye(this,"payload",void 0),this.claim=n,this.reason=i,this.payload=t}}ye(CB,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class SB extends Mt{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}}),ye(this,"code","ERR_JWT_EXPIRED"),ye(this,"claim",void 0),ye(this,"reason",void 0),ye(this,"payload",void 0),this.claim=n,this.reason=i,this.payload=t}}ye(SB,"code","ERR_JWT_EXPIRED");class TB extends Mt{constructor(){super(...arguments),ye(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}ye(TB,"code","ERR_JOSE_ALG_NOT_ALLOWED");class kB extends Mt{constructor(){super(...arguments),ye(this,"code","ERR_JOSE_NOT_SUPPORTED")}}ye(kB,"code","ERR_JOSE_NOT_SUPPORTED");class xB extends Mt{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),ye(this,"code","ERR_JWE_DECRYPTION_FAILED")}}ye(xB,"code","ERR_JWE_DECRYPTION_FAILED");class EB extends Mt{constructor(){super(...arguments),ye(this,"code","ERR_JWE_INVALID")}}ye(EB,"code","ERR_JWE_INVALID");class UB extends Mt{constructor(){super(...arguments),ye(this,"code","ERR_JWS_INVALID")}}ye(UB,"code","ERR_JWS_INVALID");class FB extends Mt{constructor(){super(...arguments),ye(this,"code","ERR_JWT_INVALID")}}ye(FB,"code","ERR_JWT_INVALID");class IB extends Mt{constructor(){super(...arguments),ye(this,"code","ERR_JWK_INVALID")}}ye(IB,"code","ERR_JWK_INVALID");class QB extends Mt{constructor(){super(...arguments),ye(this,"code","ERR_JWKS_INVALID")}}ye(QB,"code","ERR_JWKS_INVALID");class MB extends Mt{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),ye(this,"code","ERR_JWKS_NO_MATCHING_KEY")}}ye(MB,"code","ERR_JWKS_NO_MATCHING_KEY");class _B extends Mt{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),ye(this,Symbol.asyncIterator,void 0),ye(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}}ye(_B,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class RB extends Mt{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),ye(this,"code","ERR_JWKS_TIMEOUT")}}ye(RB,"code","ERR_JWKS_TIMEOUT");class PB extends Mt{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),ye(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}ye(PB,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const DB="core-bridge-";function LB(r){return r.replace(/\/$/,"")}function OB(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`call-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}class HB{constructor(e){D(this,"serverUrl");D(this,"agentId");D(this,"callId");D(this,"authToken");D(this,"continuedCallId");D(this,"bridgePrefix");D(this,"onConnected");D(this,"onDisconnected");D(this,"onError");D(this,"room",null);D(this,"audioElements",[]);D(this,"connected",!1);D(this,"disconnecting",!1);if(!e.serverUrl)throw new Error("serverUrl is required");if(!e.agentId)throw new Error("agentId is required");this.serverUrl=LB(e.serverUrl),this.agentId=e.agentId,this.callId=e.callId??OB(),this.authToken=e.token,this.continuedCallId=e.continuedCallId,this.bridgePrefix=e.bridgeIdentityPrefix??DB,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!==H.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(K.TrackSubscribed,(t,n,i)=>{i.identity.startsWith(this.bridgePrefix)&&this.attachRemoteAudio(t)}),e.on(K.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 es({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 St{constructor(e,t,n,i){this.left=e,this.top=t,this.width=n,this.height=i}add(e,t,n,i){return new St(this.left+e,this.top+t,this.width+n,this.height+i)}static fromClientRect(e,t){return new St(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 St(i.left+e.windowBounds.left,i.top+e.windowBounds.top,i.width,i.height):St.EMPTY}}St.EMPTY=new St(0,0,0,0);const Uo=(r,e)=>St.fromClientRect(r,e.getBoundingClientRect()),NB=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 St(0,0,n,i)};var Fo=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},Ye=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},ph="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",KB=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Ta=0;Ta<ph.length;Ta++)KB[ph.charCodeAt(Ta)]=Ta;var mh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var ka=0;ka<mh.length;ka++)Cs[mh.charCodeAt(ka)]=ka;var VB=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=Cs[r.charCodeAt(n)],a=Cs[r.charCodeAt(n+1)],A=Cs[r.charCodeAt(n+2)],o=Cs[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},zB=function(r){for(var e=r.length,t=[],n=0;n<e;n+=2)t.push(r[n+1]<<8|r[n]);return t},GB=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},ui=5,du=11,xc=2,qB=du-ui,Pg=65536>>ui,WB=1<<ui,Ec=WB-1,$B=1024>>ui,XB=Pg+$B,JB=XB,jB=32,YB=JB+jB,ZB=65536>>du,eC=1<<qB,tC=eC-1,gh=function(r,e,t){return r.slice?r.slice(e,t):new Uint16Array(Array.prototype.slice.call(r,e,t))},nC=function(r,e,t){return r.slice?r.slice(e,t):new Uint32Array(Array.prototype.slice.call(r,e,t))},rC=function(r,e){var t=VB(r),n=Array.isArray(t)?GB(t):new Uint32Array(t),i=Array.isArray(t)?zB(t):new Uint16Array(t),s=24,a=gh(i,s/2,n[4]/2),A=n[5]===2?gh(i,(s+n[4])/2):nC(n,Math.ceil((s+n[4])/4));return new iC(n[0],n[1],n[2],n[3],a,A)},iC=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>>ui],t=(t<<xc)+(e&Ec),this.data[t];if(e<=65535)return t=this.index[Pg+(e-55296>>ui)],t=(t<<xc)+(e&Ec),this.data[t];if(e<this.highStart)return t=YB-ZB+(e>>du),t=this.index[t],t+=e>>ui&tC,t=this.index[t],t=(t<<xc)+(e&Ec),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},r}(),vh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",sC=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var xa=0;xa<vh.length;xa++)sC[vh.charCodeAt(xa)]=xa;var aC="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==",yh=50,AC=1,Dg=2,Lg=3,oC=4,cC=5,wh=7,Og=8,bh=9,Qr=10,Wl=11,Bh=12,$l=13,lC=14,Ss=15,Xl=16,Ea=17,hs=18,dC=19,Ch=20,Jl=21,fs=22,Uc=23,Si=24,Wt=25,Ts=26,ks=27,Ti=28,uC=29,si=30,hC=31,Ua=32,Fa=33,jl=34,Yl=35,Zl=36,sa=37,ed=38,mA=39,gA=40,Fc=41,Hg=42,fC=43,pC=[9001,65288],Ng="!",we="×",Ia="÷",td=rC(aC),jn=[si,Zl],nd=[AC,Dg,Lg,cC],Kg=[Qr,Og],Sh=[ks,Ts],mC=nd.concat(Kg),Th=[ed,mA,gA,jl,Yl],gC=[Ss,$l],vC=function(r,e){e===void 0&&(e="strict");var t=[],n=[],i=[];return r.forEach(function(s,a){var A=td.get(s);if(A>yh?(i.push(!0),A-=yh):i.push(!1),["normal","auto","loose"].indexOf(e)!==-1&&[8208,8211,12316,12448].indexOf(s)!==-1)return n.push(a),t.push(Xl);if(A===oC||A===Wl){if(a===0)return n.push(a),t.push(si);var o=t[a-1];return mC.indexOf(o)===-1?(n.push(n[a-1]),t.push(o)):(n.push(a),t.push(si))}if(n.push(a),A===hC)return t.push(e==="strict"?Jl:sa);if(A===Hg||A===uC)return t.push(si);if(A===fC)return s>=131072&&s<=196605||s>=196608&&s<=262141?t.push(sa):t.push(si);t.push(A)}),[n,t,i]},Ic=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!==Qr)break}if(i===Qr)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!==Qr)break}if(A!==Qr)break}return!1},kh=function(r,e){for(var t=r;t>=0;){var n=e[t];if(n===Qr)t--;else return n}return 0},yC=function(r,e,t,n,i){if(t[n]===0)return we;var s=n-1;if(Array.isArray(i)&&i[s]===!0)return we;var a=s-1,A=s+1,o=e[s],c=a>=0?e[a]:0,l=e[A];if(o===Dg&&l===Lg)return we;if(nd.indexOf(o)!==-1)return Ng;if(nd.indexOf(l)!==-1||Kg.indexOf(l)!==-1)return we;if(kh(s,e)===Og)return Ia;if(td.get(r[s])===Wl||(o===Ua||o===Fa)&&td.get(r[A])===Wl||o===wh||l===wh||o===bh||[Qr,$l,Ss].indexOf(o)===-1&&l===bh||[Ea,hs,dC,Si,Ti].indexOf(l)!==-1||kh(s,e)===fs||Ic(Uc,fs,s,e)||Ic([Ea,hs],Jl,s,e)||Ic(Bh,Bh,s,e))return we;if(o===Qr)return Ia;if(o===Uc||l===Uc)return we;if(l===Xl||o===Xl)return Ia;if([$l,Ss,Jl].indexOf(l)!==-1||o===lC||c===Zl&&gC.indexOf(o)!==-1||o===Ti&&l===Zl||l===Ch||jn.indexOf(l)!==-1&&o===Wt||jn.indexOf(o)!==-1&&l===Wt||o===ks&&[sa,Ua,Fa].indexOf(l)!==-1||[sa,Ua,Fa].indexOf(o)!==-1&&l===Ts||jn.indexOf(o)!==-1&&Sh.indexOf(l)!==-1||Sh.indexOf(o)!==-1&&jn.indexOf(l)!==-1||[ks,Ts].indexOf(o)!==-1&&(l===Wt||[fs,Ss].indexOf(l)!==-1&&e[A+1]===Wt)||[fs,Ss].indexOf(o)!==-1&&l===Wt||o===Wt&&[Wt,Ti,Si].indexOf(l)!==-1)return we;if([Wt,Ti,Si,Ea,hs].indexOf(l)!==-1)for(var d=s;d>=0;){var u=e[d];if(u===Wt)return we;if([Ti,Si].indexOf(u)!==-1)d--;else break}if([ks,Ts].indexOf(l)!==-1)for(var d=[Ea,hs].indexOf(o)!==-1?a:s;d>=0;){var u=e[d];if(u===Wt)return we;if([Ti,Si].indexOf(u)!==-1)d--;else break}if(ed===o&&[ed,mA,jl,Yl].indexOf(l)!==-1||[mA,jl].indexOf(o)!==-1&&[mA,gA].indexOf(l)!==-1||[gA,Yl].indexOf(o)!==-1&&l===gA||Th.indexOf(o)!==-1&&[Ch,Ts].indexOf(l)!==-1||Th.indexOf(l)!==-1&&o===ks||jn.indexOf(o)!==-1&&jn.indexOf(l)!==-1||o===Si&&jn.indexOf(l)!==-1||jn.concat(Wt).indexOf(o)!==-1&&l===fs&&pC.indexOf(r[A])===-1||jn.concat(Wt).indexOf(l)!==-1&&o===hs)return we;if(o===Fc&&l===Fc){for(var h=t[s],m=1;h>0&&(h--,e[h]===Fc);)m++;if(m%2!==0)return we}return o===Ua&&l===Fa?we:Ia},wC=function(r,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=vC(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[Wt,si,Hg].indexOf(A)!==-1?sa: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]},bC=function(){function r(e,t,n,i){this.codePoints=e,this.required=t===Ng,this.start=n,this.end=i}return r.prototype.slice=function(){return Ye.apply(void 0,this.codePoints.slice(this.start,this.end))},r}(),BC=function(r,e){var t=Fo(r),n=wC(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=we;c<A&&(l=yC(t,s,i,++c,a))===we;);if(l!==we||c===A){var d=new bC(t,l,o,c);return o=c,{value:d,done:!1}}return{done:!0,value:null}}}};const CC=1,SC=2,ns=4,xh=8,WA=10,Eh=47,Hs=92,TC=9,kC=32,Qa=34,ps=61,xC=35,EC=36,UC=37,Ma=39,_a=40,ms=41,FC=95,Lt=45,IC=33,QC=60,MC=62,_C=64,RC=91,PC=93,DC=61,LC=123,Ra=63,OC=125,Uh=124,HC=126,NC=128,Fh=65533,Qc=42,ai=43,KC=44,VC=58,zC=59,aa=46,GC=0,qC=8,WC=11,$C=14,XC=31,JC=127,Qn=-1,Vg=48,zg=97,Gg=101,jC=102,YC=117,ZC=122,qg=65,Wg=69,$g=70,e3=85,t3=90,Bt=r=>r>=Vg&&r<=57,n3=r=>r>=55296&&r<=57343,ki=r=>Bt(r)||r>=qg&&r<=$g||r>=zg&&r<=jC,r3=r=>r>=zg&&r<=ZC,i3=r=>r>=qg&&r<=t3,s3=r=>r3(r)||i3(r),a3=r=>r>=NC,Pa=r=>r===WA||r===TC||r===kC,$A=r=>s3(r)||a3(r)||r===FC,Ih=r=>$A(r)||Bt(r)||r===Lt,A3=r=>r>=GC&&r<=qC||r===WC||r>=$C&&r<=XC||r===JC,kr=(r,e)=>r!==Hs?!1:e!==WA,Da=(r,e,t)=>r===Lt?$A(e)||kr(e,t):$A(r)?!0:!!(r===Hs&&kr(r,e)),Mc=(r,e,t)=>r===ai||r===Lt?Bt(e)?!0:e===aa&&Bt(t):Bt(r===aa?e:r),o3=r=>{let e=0,t=1;(r[e]===ai||r[e]===Lt)&&(r[e]===Lt&&(t=-1),e++);const n=[];for(;Bt(r[e]);)n.push(r[e++]);const i=n.length?parseInt(Ye(...n),10):0;r[e]===aa&&e++;const s=[];for(;Bt(r[e]);)s.push(r[e++]);const a=s.length,A=a?parseInt(Ye(...s),10):0;(r[e]===Wg||r[e]===Gg)&&e++;let o=1;(r[e]===ai||r[e]===Lt)&&(r[e]===Lt&&(o=-1),e++);const c=[];for(;Bt(r[e]);)c.push(r[e++]);const l=c.length?parseInt(Ye(...c),10):0;return t*(i+A*Math.pow(10,-a))*Math.pow(10,o*l)},c3={type:2},l3={type:3},d3={type:4},u3={type:13},h3={type:8},f3={type:21},p3={type:9},m3={type:10},g3={type:11},v3={type:12},y3={type:14},La={type:23},w3={type:1},b3={type:25},B3={type:24},C3={type:26},S3={type:27},T3={type:28},k3={type:29},x3={type:31},rd={type:32};class Xg{constructor(){this._value=[]}write(e){this._value=this._value.concat(Fo(e))}read(){const e=[];let t=this.consumeToken();for(;t!==rd;)e.push(t),t=this.consumeToken();return e}consumeToken(){const e=this.consumeCodePoint();switch(e){case Qa:return this.consumeStringToken(Qa);case xC:const t=this.peekCodePoint(0),n=this.peekCodePoint(1),i=this.peekCodePoint(2);if(Ih(t)||kr(n,i)){const h=Da(t,n,i)?SC:CC;return{type:5,value:this.consumeName(),flags:h}}break;case EC:if(this.peekCodePoint(0)===ps)return this.consumeCodePoint(),u3;break;case Ma:return this.consumeStringToken(Ma);case _a:return c3;case ms:return l3;case Qc:if(this.peekCodePoint(0)===ps)return this.consumeCodePoint(),y3;break;case ai:if(Mc(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case KC:return d3;case Lt:const s=e,a=this.peekCodePoint(0),A=this.peekCodePoint(1);if(Mc(s,a,A))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Da(s,a,A))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(a===Lt&&A===MC)return this.consumeCodePoint(),this.consumeCodePoint(),B3;break;case aa:if(Mc(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Eh:if(this.peekCodePoint(0)===Qc)for(this.consumeCodePoint();;){let h=this.consumeCodePoint();if(h===Qc&&(h=this.consumeCodePoint(),h===Eh))return this.consumeToken();if(h===Qn)return this.consumeToken()}break;case VC:return C3;case zC:return S3;case QC:if(this.peekCodePoint(0)===IC&&this.peekCodePoint(1)===Lt&&this.peekCodePoint(2)===Lt)return this.consumeCodePoint(),this.consumeCodePoint(),b3;break;case _C:const o=this.peekCodePoint(0),c=this.peekCodePoint(1),l=this.peekCodePoint(2);if(Da(o,c,l))return{type:7,value:this.consumeName()};break;case RC:return T3;case Hs:if(kr(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case PC:return k3;case DC:if(this.peekCodePoint(0)===ps)return this.consumeCodePoint(),h3;break;case LC:return g3;case OC:return v3;case YC:case e3:const d=this.peekCodePoint(0),u=this.peekCodePoint(1);return d===ai&&(ki(u)||u===Ra)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case Uh:if(this.peekCodePoint(0)===ps)return this.consumeCodePoint(),p3;if(this.peekCodePoint(0)===Uh)return this.consumeCodePoint(),f3;break;case HC:if(this.peekCodePoint(0)===ps)return this.consumeCodePoint(),m3;break;case Qn:return rd}return Pa(e)?(this.consumeWhiteSpace(),x3):Bt(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):$A(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:Ye(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(;ki(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();let n=!1;for(;t===Ra&&e.length<6;)e.push(t),t=this.consumeCodePoint(),n=!0;if(n){const s=parseInt(Ye(...e.map(A=>A===Ra?Vg:A)),16),a=parseInt(Ye(...e.map(A=>A===Ra?$g:A)),16);return{type:30,start:s,end:a}}const i=parseInt(Ye(...e),16);if(this.peekCodePoint(0)===Lt&&ki(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();const s=[];for(;ki(t)&&s.length<6;)s.push(t),t=this.consumeCodePoint();const a=parseInt(Ye(...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)===_a?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===_a?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}}consumeUrlToken(){const e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Qn)return{type:22,value:""};const t=this.peekCodePoint(0);if(t===Ma||t===Qa){const n=this.consumeStringToken(this.consumeCodePoint());return n.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Qn||this.peekCodePoint(0)===ms)?(this.consumeCodePoint(),{type:22,value:n.value}):(this.consumeBadUrlRemnants(),La)}for(;;){const n=this.consumeCodePoint();if(n===Qn||n===ms)return{type:22,value:Ye(...e)};if(Pa(n))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Qn||this.peekCodePoint(0)===ms?(this.consumeCodePoint(),{type:22,value:Ye(...e)}):(this.consumeBadUrlRemnants(),La);if(n===Qa||n===Ma||n===_a||A3(n))return this.consumeBadUrlRemnants(),La;if(n===Hs)if(kr(n,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),La;else e.push(n)}}consumeWhiteSpace(){for(;Pa(this.peekCodePoint(0));)this.consumeCodePoint()}consumeBadUrlRemnants(){for(;;){const e=this.consumeCodePoint();if(e===ms||e===Qn)return;kr(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}}consumeStringSlice(e){let n="";for(;e>0;){const i=Math.min(5e4,e);n+=Ye(...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===Qn||i===void 0||i===e)return t+=this.consumeStringSlice(n),{type:0,value:t};if(i===WA)return this._value.splice(0,n),w3;if(i===Hs){const s=this._value[n+1];s!==Qn&&s!==void 0&&(s===WA?(t+=this.consumeStringSlice(n),n=-1,this._value.shift()):kr(i,s)&&(t+=this.consumeStringSlice(n),t+=Ye(this.consumeEscapedCodePoint()),n=-1))}n++}while(!0)}consumeNumber(){const e=[];let t=ns,n=this.peekCodePoint(0);for((n===ai||n===Lt)&&e.push(this.consumeCodePoint());Bt(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);let i=this.peekCodePoint(1);if(n===aa&&Bt(i))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=xh;Bt(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0),i=this.peekCodePoint(1);const s=this.peekCodePoint(2);if((n===Wg||n===Gg)&&((i===ai||i===Lt)&&Bt(s)||Bt(i)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=xh;Bt(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[o3(e),t]}consumeNumericToken(){const[e,t]=this.consumeNumber(),n=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(Da(n,i,s)){const a=this.consumeName();return{type:15,number:e,flags:t,unit:a}}return n===UC?(this.consumeCodePoint(),{type:16,number:e,flags:t}):{type:17,number:e,flags:t}}consumeEscapedCodePoint(){const e=this.consumeCodePoint();if(ki(e)){let t=Ye(e);for(;ki(this.peekCodePoint(0))&&t.length<6;)t+=Ye(this.consumeCodePoint());Pa(this.peekCodePoint(0))&&this.consumeCodePoint();const n=parseInt(t,16);return n===0||n3(n)||n>1114111?Fh:n}return e===Qn?Fh:e}consumeName(){let e="";for(;;){const t=this.consumeCodePoint();if(Ih(t))e+=Ye(t);else if(kr(t,this.peekCodePoint(0)))e+=Ye(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}}}let Jg=class vA{constructor(e){this._tokens=e}static create(e){const t=new Xg;return t.write(e),new vA(t.read())}static parseValue(e){return vA.create(e).parseComponentValue()}static parseValues(e){return vA.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||U3(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"?rd:e}reconsumeToken(e){this._tokens.unshift(e)}};const zn=r=>r.type===15,rt=r=>r.type===17,me=r=>r.type===20,E3=r=>r.type===0,Aa=(r,e)=>me(r)&&r.value===e,Io=r=>r.type!==31,bt=r=>r.type!==31&&r.type!==4,En=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},U3=(r,e)=>e===11&&r.type===12||e===28&&r.type===29?!0:e===2&&r.type===3,Xe=(r,e,t)=>Math.min(Math.max(r,e),t),Vt=(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]],Gr=r=>Vt([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],r),id=r=>Vt([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],r),yi=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}),sd=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}),F3=r=>{const[e,t,n]=yi(Gr([r[0],r[1],r[2]]));return[e,t,n,r[3]]},I3=r=>{const[e,t,n]=Gr([r[0],r[1],r[2]]);return[Xe(Math.round(e*255),0,255),Xe(Math.round(t*255),0,255),Xe(Math.round(n*255),0,255),r[3]]},Hr=r=>r.type===17||r.type===15,Ee=r=>r.type===16||Hr(r),Q3=r=>r.type===18&&r.name==="calc",M3=(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:ns}}catch{return null}return null},jg=r=>r.length>1?[r[0],r[1]]:[r[0]],st={type:17,number:0,flags:ns},Ai={type:16,number:50,flags:ns},Ln={type:16,number:100,flags:ns},xs=(r,e,t)=>{const[n,i]=r;return[de(n,e),de(typeof i<"u"?i:n,t)]},de=(r,e)=>{if(r.type===16)return r.number/100*e;if(zn(r))switch(r.unit){case"rem":case"em":return 16*r.number;case"px":default:return r.number}return r.number},Yg="deg",Zg="grad",e1="rad",t1="turn",rs={name:"angle",parse:(r,e)=>{if(e.type===15)switch(e.unit){case Yg:return Math.PI*e.number/180;case Zg:return Math.PI/200*e.number;case e1:return e.number;case t1:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},n1=r=>r.type===15&&(r.unit===Yg||r.unit===Zg||r.unit===e1||r.unit===t1),r1=r=>{switch(r.filter(me).map(t=>t.value).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[st,st];case"to top":case"bottom":return sn(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[st,Ln];case"to right":case"left":return sn(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Ln,Ln];case"to bottom":case"top":return sn(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Ln,st];case"to left":case"right":return sn(270)}return 0},sn=r=>Math.PI*r/180,Pr=r=>(255&r)===0,_e=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})`},kn=(r,e,t,n)=>(r<<24|e<<16|t<<8|Math.round(n*255)<<0)>>>0,xr=(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},wi=r=>(r[0].type===20?r[0].value:"unknown")==="from",_3=r=>kn(Xe(Math.round(r[0]*255),0,255),Xe(Math.round(r[1]*255),0,255),Xe(Math.round(r[2]*255),0,255),Xe(r[3],0,1)),uu=([r,e,t,n])=>{const i=yi([r,e,t]);return kn(Xe(Math.round(i[0]*255),0,255),Xe(Math.round(i[1]*255),0,255),Xe(Math.round(i[2]*255),0,255),n)},pa=r=>{const e=Gr([r[0],r[1],r[2]]);return uu([e[0],e[1],e[2],r[3]])},R3=(r,e)=>{if(wi(e.filter(bt)))throw new Error("Relative color not supported for lab()");const[t,n,i,s]=Qo(e),a=yi(Gr(Ro([t,n,i])));return kn(Xe(Math.round(a[0]*255),0,255),Xe(Math.round(a[1]*255),0,255),Xe(Math.round(a[2]*255),0,255),s)},P3=(r,e)=>{if(wi(e.filter(bt)))throw new Error("Relative color not supported for oklab()");const[t,n,i,s]=Qo(e),a=yi(Gr(_o([t,n,i])));return kn(Xe(Math.round(a[0]*255),0,255),Xe(Math.round(a[1]*255),0,255),Xe(Math.round(a[2]*255),0,255),s)},D3=(r,e)=>{if(wi(e.filter(bt)))throw new Error("Relative color not supported for oklch()");const[t,n,i,s]=a1(e),a=yi(Gr(_o(Mo([t,n,i]))));return kn(Xe(Math.round(a[0]*255),0,255),Xe(Math.round(a[1]*255),0,255),Xe(Math.round(a[2]*255),0,255),s)},L3=(r,e)=>{if(wi(e.filter(bt)))throw new Error("Relative color not supported for lch()");const[t,n,i,s]=s1(e),a=yi(Gr(Ro(Mo([t,n,i]))));return kn(Xe(Math.round(a[0]*255),0,255),Xe(Math.round(a[1]*255),0,255),Xe(Math.round(a[2]*255),0,255),s)},i1=(r,e)=>{const t=e.filter(bt),[n,i,s,a]=t,A=(n.type===17?sn(n.number):rs.parse(r,n))/(Math.PI*2),o=Ee(i)?i.number/100:0,c=Ee(s)?s.number/100:0,l=typeof a<"u"&&Ee(a)?de(a,1):1;return[A,o,c,l]},Qh=(r,e)=>{if(wi(e))throw new Error("Relative color not supported for hsl()");const[t,n,i,s]=i1(r,e),a=o1([t,n,i]);return kn(a[0]*255,a[1]*255,a[2]*255,n===0?1:s)},s1=r=>{const e=r.filter(bt),t=Ee(e[0])?e[0].number:0,n=Ee(e[1])?e[1].number:0,i=rt(e[2])||zn(e[2])?e[2].number:0,s=typeof e[4]<"u"&&Ee(e[4])?de(e[4],1):1;return[t,n,i,s]},Qo=r=>{const e=r.filter(bt),t=e[0].type===16?e[0].number/100:rt(e[0])?e[0].number:0,n=e[1].type===16?e[1].number/100:rt(e[1])?e[1].number:0,i=rt(e[2])||zn(e[2])?e[2].number:0,s=typeof e[4]<"u"&&Ee(e[4])?de(e[4],1):1;return[t,n,i,s]},a1=r=>{const e=r.filter(bt),t=e[0].type===16?e[0].number/100:rt(e[0])?e[0].number:0,n=e[1].type===16?e[1].number/100:rt(e[1])?e[1].number:0,i=rt(e[2])||zn(e[2])?e[2].number:0,s=typeof e[4]<"u"&&Ee(e[4])?de(e[4],1):1;return[t,n,i,s]},A1=r=>Vt([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],r),hu=r=>Vt([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],r),_c=(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),o1=([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=_c(i,n,r+1/3),a=_c(i,n,r),A=_c(i,n,r-1/3);return[s,a,A]},Mo=([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)]),_o=r=>{const e=Vt([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],r),t=e.map(n=>n**3);return Vt([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],t)},Ro=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 hu([a[0],a[1],a[2]])},O3=(r,e)=>{const t=e.filter(bt);if(t.length===3){const[n,i,s]=t.map(xr),a=sd([n/255,i/255,s/255]),[A,o,c]=id([a[0],a[1],a[2]]);return[A,o,c,1]}if(t.length===4){const[n,i,s,a]=t.map(xr),A=sd([n/255,i/255,s/255]),[o,c,l]=id([A[0],A[1],A[2]]);return[o,c,l,a]}return[0,0,0,1]},H3=(r,e)=>{const[t,n,i,s]=i1(r,e),a=sd(o1([t,n,i])),[A,o,c]=id([a[0],a[1],a[2]]);return[A,o,c,s]},N3=(r,e)=>{const[t,n,i,s]=Qo(e),[a,A,o]=Ro([t,n,i]);return[a,A,o,s]},K3=(r,e)=>{const[t,n,i,s]=s1(e),[a,A,o]=Ro(Mo([t,n,i]));return[a,A,o,s]},V3=(r,e)=>{const[t,n,i,s]=a1(e),[a,A,o]=_o(Mo([t,n,i]));return[a,A,o,s]},z3=(r,e)=>{const[t,n,i,s]=Qo(e),[a,A,o]=_o([t,n,i]);return[a,A,o,s]},G3=r=>hu([r[0],r[1],r[2]]),Mh=r=>r,q3=r=>{const[e,t,n]=A1([r[0],r[2],r[3]]);return[e,t,n,r[3]]},_h=r=>pa([r[0],r[1],r[2],r[3]]),W3=r=>{const e=G3([r[0],r[1],r[2]]);return pa([e[0],e[1],e[2],r[3]])},$3=r=>Vt([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],r),X3=r=>Vt([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],r),J3=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}),j3=r=>yi(r),Y3=r=>{const e=J3([r[0],r[1],r[2]]);return $3([e[0],e[1],e[2]])},Z3=r=>{const[e,t,n]=j3(X3([r[0],r[1],r[2]]));return[e,t,n,r[3]]},e5=r=>{const e=Y3([r[0],r[1],r[2]]);return pa([e[0],e[1],e[2],r[3]])},t5=r=>Vt([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],r),n5=r=>Vt([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],r),r5=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]]},i5=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]]},s5=r=>{const[e,t,n]=i5(t5([r[0],r[1],r[2]]));return[e,t,n,r[3]]},a5=r=>{const e=Gr(n5(r5([r[0],r[1],r[2]])));return uu([e[0],e[1],e[2],r[3]])},A5=r=>Vt([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],r),o5=r=>Vt([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],r),c5=r=>r.map(e=>e<16/512?e/16:e**1.8),l5=r=>r.map(e=>e>1/512?e**(1/1.8):e*16),d5=r=>{const e=c5([r[0],r[1],r[2]]);return hu(A5([e[0],e[1],e[2]]))},u5=r=>{const[e,t,n]=l5(o5(A1([r[0],r[1],r[2]])));return[e,t,n,r[3]]},h5=r=>{const e=d5([r[0],r[1],r[2]]);return pa([e[0],e[1],e[2],r[3]])},XA=1.09929682680944,c1=.018053968510807,f5=r=>r.map(function(e){return e<c1*4.5?e/4.5:Math.pow((e+XA-1)/XA,1/.45)}),p5=r=>r.map(function(e){return e>=c1?XA*Math.pow(e,.45)-(XA-1):4.5*e}),m5=r=>Vt([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],r),g5=r=>Vt([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],r),v5=r=>{const e=f5([r[0],r[1],r[2]]);return m5([e[0],e[1],e[2]])},y5=r=>{const[e,t,n]=p5(g5([r[0],r[1],r[2]]));return[e,t,n,r[3]]},w5=r=>{const e=v5([r[0],r[1],r[2]]);return pa([e[0],e[1],e[2],r[3]])},Dr={name:"color",parse:(r,e)=>{if(e.type===18){const t=S5[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]=l1(e);return kn(t,n,i,s)}if(e.type===20){const t=Nn[e.value.toUpperCase()];if(typeof t<"u")return t}return Nn.TRANSPARENT}},l1=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]},Rh=(r,e)=>{const t=e.filter(bt);if(wi(t))throw new Error("Relative color not supported for rgb()");if(t.length===3){const[n,i,s]=t.map(xr);return kn(n,i,s,1)}if(t.length===4){const[n,i,s,a]=t.map(xr);return kn(n,i,s,a)}if(t.length===5&&t[3].type===6&&t[3].value==="/"){const n=xr(t[0],0),i=xr(t[1],1),s=xr(t[2],2),a=xr(t[4],3);return kn(n,i,s,a)}return 0},b5=(r,e)=>{const t=e.filter(bt),n=t[0].type===20?t[0].value:"unknown";if(!wi(t)){const s=n,a=Ph[s];if(typeof a>"u")throw new Error(`Attempting to parse an unsupported color space "${s}" for color() function`);const A=rt(t[1])?t[1].number:0,o=rt(t[2])?t[2].number:0,c=rt(t[3])?t[3].number:0,l=t.length>4&&t[4].type===6&&t[4].value==="/"&&rt(t[5])?t[5].number:1;return a([A,o,c,l])}else{const s=(B,U)=>{if(rt(U))return U.number;const w=E=>E==="r"||E==="x"?0:E==="g"||E==="y"?1:2;if(me(U)){const E=w(U.value);return B[E]}const C=E=>{const I=E.filter(bt);let _="(";for(const P of I)_+=P.type===18&&P.name==="calc"?C(P.values):rt(P)?P.number:P.type===6||me(P)?P.value:"";return _+=")",_};if(U.type===18){const E=U.values.filter(bt);if(U.name==="calc"){const I=C(E).replace(/r|x/,B[0].toString()).replace(/g|y/,B[1].toString()).replace(/b|z/,B[2].toString());return new Function("return "+I)()}}return null},a=t[1].type===18?t[1].name:me(t[1])||t[1].type===5?"rgb":"unknown",A=me(t[2])?t[2].value:"unknown";let o=t[1].type===18?t[1].values:me(t[1])?[t[1]]:[];if(me(t[1])){if(typeof Nn[t[1].value.toUpperCase()]>"u")throw new Error("Attempting to use unknown color in relative color 'from'");{const U=zi(r,t[1].value),w=255&U,C=255&U>>8,E=255&U>>16;o=[{type:17,number:255&U>>24,flags:1},{type:17,number:E,flags:1},{type:17,number:C,flags:1},{type:17,number:w>1?w/255:w,flags:1}]}}else if(t[1].type===5){const[B,U,w,C]=l1(t[1]);o=[{type:17,number:B,flags:1},{type:17,number:U,flags:1},{type:17,number:w,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=B5[a],l=C5[A],d=Ph[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),m=s(h,t[3]),g=s(h,t[4]),y=s(h,t[5]),b=t.length>6&&t[6].type===6&&t[6].value==="/"&&rt(t[7])?t[7].number:1;if(m===null||g===null||y===null)throw new Error("Invalid relative color in color() function");return d([m,g,y,b])}},Ph={srgb:_3,"srgb-linear":uu,"display-p3":e5,"a98-rgb":a5,"prophoto-rgb":h5,xyz:_h,"xyz-d50":W3,"xyz-d65":_h,rec2020:w5},B5={rgb:O3,hsl:H3,lab:N3,lch:K3,oklab:z3,oklch:V3},C5={srgb:F3,"srgb-linear":I3,"display-p3":Z3,"a98-rgb":s5,"prophoto-rgb":u5,xyz:Mh,"xyz-d50":q3,"xyz-d65":Mh,rec2020:y5},S5={hsl:Qh,hsla:Qh,rgb:Rh,rgba:Rh,lch:L3,oklch:D3,oklab:P3,lab:R3,color:b5},zi=(r,e)=>Dr.parse(r,Jg.create(e).parseComponentValue()),Nn={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},T5={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:(r,e)=>e.map(t=>{if(me(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})},k5={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Po=(r,e)=>{const t=Dr.parse(r,e[0]),n=e[1];return n&&Ee(n)?{color:t,stop:n}:{color:t,stop:null}},Dh=(r,e)=>{const t=r[0],n=r[r.length-1];t.stop===null&&(t.stop=st),n.stop===null&&(n.stop=Ln);const i=[];let s=0;for(let A=0;A<r.length;A++){const o=r[A].stop;if(o!==null){const c=de(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)}))},x5=(r,e,t)=>{const n=e/2,i=t/2,s=de(r[0],e)-n,a=i-de(r[1],t);return(Math.atan2(a,s)+Math.PI*2)%(Math.PI*2)},E5=(r,e,t)=>{const n=typeof r=="number"?r:x5(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]},fn=(r,e)=>Math.sqrt(r*r+e*e),Lh=(r,e,t,n,i)=>[[0,0],[0,e],[r,0],[r,e]].reduce((a,A)=>{const[o,c]=A,l=fn(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,U5=(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(fn(e,t),fn(e,t-i),fn(e-n,t),fn(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]=Lh(n,i,e,t,!0);s=fn(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(fn(e,t),fn(e,t-i),fn(e-n,t),fn(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]=Lh(n,i,e,t,!1);s=fn(o-e,(c-t)/A),a=A*s}break}return Array.isArray(r.size)&&(s=de(r.size[0],n),a=r.size.length===2?de(r.size[1],i):s),[s,a]},F5=(r,e)=>{let t=sn(180);const n=[];return En(e).forEach((i,s)=>{if(s===0){const A=i[0];if(A.type===20&&A.value==="to"){t=r1(i);return}else if(n1(A)){t=rs.parse(r,A);return}}const a=Po(r,i);n.push(a)}),{angle:t,stops:n,type:1}},Oa=(r,e)=>{let t=sn(180);const n=[];return En(e).forEach((i,s)=>{if(s===0){const A=i[0];if(A.type===20&&["top","left","right","bottom"].indexOf(A.value)!==-1){t=r1(i);return}else if(n1(A)){t=(rs.parse(r,A)+sn(270))%sn(360);return}}const a=Po(r,i);n.push(a)}),{angle:t,stops:n,type:1}},I5=(r,e)=>{const t=sn(180),n=[];let i=1;const s=0,a=3,A=[];return En(e).forEach((o,c)=>{const l=o[0];if(c===0){if(me(l)&&l.value==="linear"){i=1;return}else if(me(l)&&l.value==="radial"){i=2;return}}if(l.type===18){if(l.name==="from"){const d=Dr.parse(r,l.values[0]);n.push({stop:st,color:d})}else if(l.name==="to"){const d=Dr.parse(r,l.values[0]);n.push({stop:Ln,color:d})}else if(l.name==="color-stop"){const d=l.values.filter(bt);if(d.length===2){const u=Dr.parse(r,d[1]),h=d[0];rt(h)&&n.push({stop:{type:16,number:h.number*100,flags:h.flags},color:u})}}}}),i===1?{angle:(t+sn(180))%sn(360),stops:n,type:i}:{size:a,shape:s,stops:n,position:A,type:i}},d1="closest-side",u1="farthest-side",h1="closest-corner",f1="farthest-corner",p1="circle",m1="ellipse",g1="cover",v1="contain",Q5=(r,e)=>{let t=0,n=3;const i=[],s=[];return En(e).forEach((a,A)=>{let o=!0;if(A===0){let c=!1;o=a.reduce((l,d)=>{if(c)if(me(d))switch(d.value){case"center":return s.push(Ai),l;case"top":case"left":return s.push(st),l;case"right":case"bottom":return s.push(Ln),l}else(Ee(d)||Hr(d))&&s.push(d);else if(me(d))switch(d.value){case p1:return t=0,!1;case m1:return t=1,!1;case"at":return c=!0,!1;case d1:return n=0,!1;case g1:case u1:return n=1,!1;case v1:case h1:return n=2,!1;case f1:return n=3,!1}else if(Hr(d)||Ee(d))return Array.isArray(n)||(n=[]),n.push(d),!1;return l},o)}if(o){const c=Po(r,a);i.push(c)}}),{size:n,shape:t,stops:i,position:s,type:2}},Ha=(r,e)=>{let t=0,n=3;const i=[],s=[];return En(e).forEach((a,A)=>{let o=!0;if(A===0?o=a.reduce((c,l)=>{if(me(l))switch(l.value){case"center":return s.push(Ai),!1;case"top":case"left":return s.push(st),!1;case"right":case"bottom":return s.push(Ln),!1}else if(Ee(l)||Hr(l))return s.push(l),!1;return c},o):A===1&&(o=a.reduce((c,l)=>{if(me(l))switch(l.value){case p1:return t=0,!1;case m1:return t=1,!1;case v1:case d1:return n=0,!1;case u1:return n=1,!1;case h1:return n=2,!1;case g1:case f1:return n=3,!1}else if(Hr(l)||Ee(l))return Array.isArray(n)||(n=[]),n.push(l),!1;return c},o)),o){const c=Po(r,a);i.push(c)}}),{size:n,shape:t,stops:i,position:s,type:2}},M5=r=>r.type===1,_5=r=>r.type===2,fu={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=y1[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 R5(r){return!(r.type===20&&r.value==="none")&&(r.type!==18||!!y1[r.name])}const y1={"linear-gradient":F5,"-moz-linear-gradient":Oa,"-ms-linear-gradient":Oa,"-o-linear-gradient":Oa,"-webkit-linear-gradient":Oa,"radial-gradient":Q5,"-moz-radial-gradient":Ha,"-ms-radial-gradient":Ha,"-o-radial-gradient":Ha,"-webkit-radial-gradient":Ha,"-webkit-gradient":I5},P5={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=>bt(n)&&R5(n)).map(n=>fu.parse(r,n))}},D5={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:(r,e)=>e.map(t=>{if(me(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})},L5={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:(r,e)=>En(e).map(t=>t.map(n=>Q3(n)?M3(n,0):Ee(n)?n:null).filter(n=>n!==null)).map(jg)},O5={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:(r,e)=>En(e).map(t=>t.filter(me).map(n=>n.value).join(" ")).map(H5)},H5=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 Gi;(function(r){r.AUTO="auto",r.CONTAIN="contain",r.COVER="cover"})(Gi||(Gi={}));const N5={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:(r,e)=>En(e).map(t=>t.filter(K5))},K5=r=>me(r)||Ee(r),Do=r=>({name:`border-${r}-color`,initialValue:"transparent",prefix:!1,type:3,format:"color"}),V5=Do("top"),z5=Do("right"),G5=Do("bottom"),q5=Do("left"),Lo=r=>({name:`border-radius-${r}`,initialValue:"0 0",prefix:!1,type:1,parse:(e,t)=>jg(t.filter(Ee))}),W5=Lo("top-left"),$5=Lo("top-right"),X5=Lo("bottom-right"),J5=Lo("bottom-left"),Oo=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}}),j5=Oo("top"),Y5=Oo("right"),Z5=Oo("bottom"),eS=Oo("left"),Ho=r=>({name:`border-${r}-width`,initialValue:"0",type:0,prefix:!1,parse:(e,t)=>zn(t)?t.number:0}),tS=Ho("top"),nS=Ho("right"),rS=Ho("bottom"),iS=Ho("left"),ad={type:0},Ad=r=>{const[e]=r;return e?me(e)?e.value==="farthest-side"?"farthest-side":"closest-side":Ee(e)?e:"closest-side":"closest-side"},w1=r=>{let e=null,t=null;for(const n of r)if(me(n))switch(n.value){case"left":e=st;break;case"right":e=Ln;break;case"top":t=st;break;case"bottom":t=Ln;break;case"center":e===null?e=Ai:t===null&&(t=Ai);break}else Ee(n)&&(e===null?e=n:t===null&&(t=n));return{cx:e??Ai,cy:t??Ai}},sS=r=>{const e=[];for(const a of r)if(a.type!==31){if(me(a)&&a.value==="round")break;Ee(a)&&e.push(a)}const t=e[0]??st,n=e[1]??t,i=e[2]??t,s=e[3]??n;return{type:1,top:t,right:n,bottom:i,left:s}},aS=r=>{const e=r.filter(Io),t=e.findIndex(s=>Aa(s,"at")),n=t===-1?e:e.slice(0,t),i=t===-1?[]:e.slice(t+1);return{type:2,radius:Ad(n),...w1(i)}},AS=r=>{const e=r.filter(Io),t=e.findIndex(s=>Aa(s,"at")),n=t===-1?e:e.slice(0,t),i=t===-1?[]:e.slice(t+1);return{type:3,rx:Ad(n.slice(0,1)),ry:Ad(n.slice(1,2)),...w1(i)}},oS=r=>{const e=En(r),t=[];for(const n of e){if(n.length===1&&me(n[0]))continue;const i=n.filter(Ee);i.length>=2&&t.push([i[0],i[1]])}return{type:4,points:t}},cS=r=>{const e=r.find(t=>t.type===0);return e?{type:5,d:e.value}:ad},lS={name:"clip-path",initialValue:"none",prefix:!1,type:0,parse:(r,e)=>{if(me(e)&&e.value==="none")return ad;if(e.type===18)switch(e.name){case"inset":return sS(e.values);case"circle":return aS(e.values);case"ellipse":return AS(e.values);case"polygon":return oS(e.values);case"path":return cS(e.values)}return ad}},dS={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},uS={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"rtl":return 1;case"ltr":default:return 0}}},hS={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:(r,e)=>e.filter(me).reduce((t,n)=>t|fS(n.value),0)},fS=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},pS={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}},mS={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 JA;(function(r){r.NORMAL="normal",r.STRICT="strict"})(JA||(JA={}));const gS={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"strict":return JA.STRICT;case"normal":default:return JA.NORMAL}}},vS={name:"line-height",initialValue:"normal",prefix:!1,type:4},Oh=(r,e)=>me(r)&&r.value==="normal"?1.2*e:r.type===17?e*r.number:Ee(r)?de(r,e):e,yS={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:(r,e)=>e.type===20&&e.value==="none"?null:fu.parse(r,e)},wS={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"inside":return 0;case"outside":default:return 1}}},od={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}}},No=r=>({name:`margin-${r}`,initialValue:"0",prefix:!1,type:4}),bS=No("top"),BS=No("right"),CS=No("bottom"),SS=No("left"),TS={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:(r,e)=>e.filter(me).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}})},kS={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"}}},Ko=r=>({name:`padding-${r}`,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}),xS=Ko("top"),ES=Ko("right"),US=Ko("bottom"),FS=Ko("left"),IS={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}}},QS={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}},MS={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>e.length===1&&Aa(e[0],"none")?[]:En(e).map(t=>{const n={color:Nn.TRANSPARENT,offsetX:st,offsetY:st,blur:st};let i=0;for(let s=0;s<t.length;s++){const a=t[s];Hr(a)?(i===0?n.offsetX=a:i===1?n.offsetY=a:n.blur=a,i++):n.color=Dr.parse(r,a)}return n})},_S={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}},RS={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=OS[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}},PS=(r,e)=>{const t=e.filter(n=>n.type===17).map(n=>n.number);return t.length===6?t:null},DS=(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},LS=(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=rs.parse(r,t);else return null;const i=Math.cos(n),s=Math.sin(n);return[i,s,-s,i,0,0]},OS={matrix:PS,matrix3d:DS,rotate:LS},Hh={type:16,number:50,flags:ns},HS=[Hh,Hh],NS={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:(r,e)=>{const t=e.filter(Ee);return t.length!==2?HS:[t[0],t[1]]}},KS={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?rs.parse(r,e)*180/Math.PI:null},VS={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 Ns;(function(r){r.NORMAL="normal",r.BREAK_ALL="break-all",r.KEEP_ALL="keep-all"})(Ns||(Ns={}));const zS={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"break-all":return Ns.BREAK_ALL;case"keep-all":return Ns.KEEP_ALL;case"normal":default:return Ns.NORMAL}}},_n=r=>r!==0,GS=r=>r===3||r===4,qS={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}}},WS={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:(r,e)=>{if(e.type===20)return{auto:!0,order:0};if(rt(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},b1={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")}},$S={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:(r,e)=>rt(e)?e.number:1},XS={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},JS={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:(r,e)=>e.filter(me).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)},jS={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}}},YS={name:"text-decoration-thickness",initialValue:"auto",prefix:!1,type:0,parse:(r,e)=>{if(me(e))switch(e.value){case"auto":return"auto";case"from-font":return"from-font"}return zn(e)?e.number:"auto"}},ZS={name:"text-underline-offset",initialValue:"auto",prefix:!1,type:0,parse:(r,e)=>me(e)&&e.value==="auto"?"auto":zn(e)?e.number:"auto"},e6={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}'`)}},t6={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},n6={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:(r,e)=>{if(rt(e))return e.number;if(me(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},r6={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>e.filter(me).map(t=>t.value)},i6={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"}}},ze=(r,e)=>(r&e)!==0,s6={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}},a6={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(Io);for(let s=0;s<i.length;s++){const a=i[s],A=i[s+1];if(a.type===20){const o=A&&rt(A)?A.number:1;n.push({counter:a.value,increment:o})}}return n}},A6={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:(r,e)=>{if(e.length===0)return[];const t=[],n=e.filter(Io);for(let i=0;i<n.length;i++){const s=n[i],a=n[i+1];if(me(s)&&s.value!=="none"){const A=a&&rt(a)?a.number:0;t.push({counter:s.value,reset:A})}}return t}},o6={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:(r,e)=>e.filter(zn).map(t=>b1.parse(r,t))},c6={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(E3);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}},Nh=(r,e,t)=>{if(!r)return"";const n=r[Math.min(e,r.length-1)];return n?t?n.open:n.close:""},l6={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:(r,e)=>e.length===1&&Aa(e[0],"none")?[]:En(e).map(t=>{const n={color:255,offsetX:st,offsetY:st,blur:st,spread:st,inset:!1};let i=0;for(let s=0;s<t.length;s++){const a=t[s];Aa(a,"inset")?n.inset=!0:Hr(a)?(i===0?n.offsetX=a:i===1?n.offsetY=a:i===2?n.blur=a:n.spread=a,i++):n.color=Dr.parse(r,a)}return n})},d6={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:(r,e)=>{const t=[0,1,2],n=[];return e.filter(me).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}},u6={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},h6={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:(r,e)=>zn(e)?e.number:0},f6={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},p6={name:"objectFit",initialValue:"fill",prefix:!1,type:1,parse:(r,e)=>e.filter(me).reduce((t,n)=>t|m6(n.value),0)},m6=r=>{switch(r){case"contain":return 2;case"cover":return 4;case"none":return 8;case"scale-down":return 16}return 0},g6={name:"text-overflow",initialValue:"clip",prefix:!1,type:2,parse:(r,e)=>{switch(e){case"ellipsis":return 1;case"clip":default:return 0}}};var Jt;(function(r){r[r.AUTO=0]="AUTO",r[r.CRISP_EDGES=1]="CRISP_EDGES",r[r.PIXELATED=2]="PIXELATED",r[r.SMOOTH=3]="SMOOTH"})(Jt||(Jt={}));const v6={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 Jt.CRISP_EDGES;case"pixelated":case"-webkit-optimize-contrast":return Jt.PIXELATED;case"smooth":case"high-quality":return Jt.SMOOTH;case"auto":default:return Jt.AUTO}}};class y6{constructor(e,t){this.animationDuration=j(e,o6,t.animationDuration),this.backgroundClip=j(e,T5,t.backgroundClip),this.backgroundColor=j(e,k5,t.backgroundColor),this.backgroundImage=j(e,P5,t.backgroundImage),this.backgroundOrigin=j(e,D5,t.backgroundOrigin),this.backgroundPosition=j(e,L5,t.backgroundPosition),this.backgroundRepeat=j(e,O5,t.backgroundRepeat),this.backgroundSize=j(e,N5,t.backgroundSize),this.borderTopColor=j(e,V5,t.borderTopColor),this.borderRightColor=j(e,z5,t.borderRightColor),this.borderBottomColor=j(e,G5,t.borderBottomColor),this.borderLeftColor=j(e,q5,t.borderLeftColor),this.borderTopLeftRadius=j(e,W5,t.borderTopLeftRadius),this.borderTopRightRadius=j(e,$5,t.borderTopRightRadius),this.borderBottomRightRadius=j(e,X5,t.borderBottomRightRadius),this.borderBottomLeftRadius=j(e,J5,t.borderBottomLeftRadius),this.borderTopStyle=j(e,j5,t.borderTopStyle),this.borderRightStyle=j(e,Y5,t.borderRightStyle),this.borderBottomStyle=j(e,Z5,t.borderBottomStyle),this.borderLeftStyle=j(e,eS,t.borderLeftStyle),this.borderTopWidth=j(e,tS,t.borderTopWidth),this.borderRightWidth=j(e,nS,t.borderRightWidth),this.borderBottomWidth=j(e,rS,t.borderBottomWidth),this.borderLeftWidth=j(e,iS,t.borderLeftWidth),this.boxShadow=j(e,l6,t.boxShadow),this.clipPath=j(e,lS,t.clipPath),this.color=j(e,dS,t.color),this.direction=j(e,uS,t.direction),this.display=j(e,hS,t.display),this.float=j(e,pS,t.cssFloat),this.fontFamily=j(e,e6,t.fontFamily),this.fontSize=j(e,t6,t.fontSize),this.fontStyle=j(e,i6,t.fontStyle),this.fontVariant=j(e,r6,t.fontVariant),this.fontWeight=j(e,n6,t.fontWeight),this.letterSpacing=j(e,mS,t.letterSpacing),this.lineBreak=j(e,gS,t.lineBreak),this.lineHeight=j(e,vS,t.lineHeight),this.listStyleImage=j(e,yS,t.listStyleImage),this.listStylePosition=j(e,wS,t.listStylePosition),this.listStyleType=j(e,od,t.listStyleType),this.marginTop=j(e,bS,t.marginTop),this.marginRight=j(e,BS,t.marginRight),this.marginBottom=j(e,CS,t.marginBottom),this.marginLeft=j(e,SS,t.marginLeft),this.opacity=j(e,$S,t.opacity);const n=j(e,TS,t.overflow);this.overflowX=n[0],this.overflowY=n[n.length>1?1:0],this.overflowWrap=j(e,kS,t.overflowWrap),this.paddingTop=j(e,xS,t.paddingTop),this.paddingRight=j(e,ES,t.paddingRight),this.paddingBottom=j(e,US,t.paddingBottom),this.paddingLeft=j(e,FS,t.paddingLeft),this.paintOrder=j(e,d6,t.paintOrder),this.position=j(e,QS,t.position),this.textAlign=j(e,IS,t.textAlign),this.textDecorationColor=j(e,XS,t.textDecorationColor??t.color),this.textDecorationLine=j(e,JS,t.textDecorationLine??t.textDecoration),this.textDecorationStyle=j(e,jS,t.textDecorationStyle),this.textDecorationThickness=j(e,YS,t.textDecorationThickness),this.textUnderlineOffset=j(e,ZS,t.textUnderlineOffset),this.textShadow=j(e,MS,t.textShadow),this.textTransform=j(e,_S,t.textTransform),this.textOverflow=j(e,g6,t.textOverflow),this.transform=j(e,RS,t.transform),this.transformOrigin=j(e,NS,t.transformOrigin),this.rotate=j(e,KS,t.rotate),this.visibility=j(e,VS,t.visibility),this.webkitTextStrokeColor=j(e,u6,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=j(e,h6,t.webkitTextStrokeWidth),this.webkitLineClamp=j(e,f6,t.webkitLineClamp),this.wordBreak=j(e,zS,t.wordBreak),this.writingMode=j(e,qS,t.writingMode),this.zIndex=j(e,WS,t.zIndex),this.objectFit=j(e,p6,t.objectFit),this.imageRendering=j(e,v6,t.imageRendering)}isVisible(){return this.display>0&&this.opacity>0&&this.visibility===0}isTransparent(){return Pr(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 ze(this.display,4)||ze(this.display,33554432)||ze(this.display,268435456)||ze(this.display,536870912)||ze(this.display,67108864)||ze(this.display,134217728)}}class w6{constructor(e,t){this.content=j(e,s6,t.content),this.quotes=j(e,c6,t.quotes)}}class Kh{constructor(e,t){this.counterIncrement=j(e,a6,t.counterIncrement),this.counterReset=j(e,A6,t.counterReset)}}const j=(r,e,t)=>{const n=new Xg,i=t!==null&&typeof t<"u"?t.toString():e.initialValue;n.write(i);const s=new Jg(n.read());switch(e.type){case 2:const a=s.parseComponentValue();return e.parse(r,me(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 rs.parse(r,s.parseComponentValue());case"color":return Dr.parse(r,s.parseComponentValue());case"image":return fu.parse(r,s.parseComponentValue());case"length":const A=s.parseComponentValue();return Hr(A)?A:st;case"length-percentage":const o=s.parseComponentValue();return Ee(o)?o:st;case"time":return b1.parse(r,s.parseComponentValue())}break}},nr=r=>r.nodeType===Node.ELEMENT_NODE,B1=r=>r.nodeType===Node.TEXT_NODE,Ri=r=>typeof r.className=="object",oa=r=>nr(r)&&typeof r.style<"u"&&!Ri(r),b6=r=>r.tagName==="LI",B6=r=>r.tagName==="OL",Vh=r=>!Ri(r)&&r.tagName.indexOf("-")>0,C6="data-html2canvas-debug",S6=r=>{if(typeof r.getAttribute!="function")return 0;switch(r.getAttribute(C6)){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},cd=(r,e)=>{const t=S6(r);return t===1||e===t};class zh{static normalizeElement(e,t){const n={};return oa(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){oa(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 Gn{constructor(e,t,n={}){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,cd(t,3),this.styles=new y6(e,e.config.window.getComputedStyle(t,null)),n.normalizeDom!==!1&&oa(t)&&(this.originalStyles=zh.normalizeElement(t,this.styles),this.originalElement=t),this.bounds=Uo(this.context,t),cd(t,4)&&(this.flags|=16)}restore(){this.originalStyles&&this.originalElement&&(zh.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 T6="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",Gh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Es=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Na=0;Na<Gh.length;Na++)Es[Gh.charCodeAt(Na)]=Na;var k6=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=Es[r.charCodeAt(n)],a=Es[r.charCodeAt(n+1)],A=Es[r.charCodeAt(n+2)],o=Es[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},x6=function(r){for(var e=r.length,t=[],n=0;n<e;n+=2)t.push(r[n+1]<<8|r[n]);return t},E6=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},hi=5,pu=11,Rc=2,U6=pu-hi,C1=65536>>hi,F6=1<<hi,Pc=F6-1,I6=1024>>hi,Q6=C1+I6,M6=Q6,_6=32,R6=M6+_6,P6=65536>>pu,D6=1<<U6,L6=D6-1,qh=function(r,e,t){return r.slice?r.slice(e,t):new Uint16Array(Array.prototype.slice.call(r,e,t))},O6=function(r,e,t){return r.slice?r.slice(e,t):new Uint32Array(Array.prototype.slice.call(r,e,t))},H6=function(r,e){var t=k6(r),n=Array.isArray(t)?E6(t):new Uint32Array(t),i=Array.isArray(t)?x6(t):new Uint16Array(t),s=24,a=qh(i,s/2,n[4]/2),A=n[5]===2?qh(i,(s+n[4])/2):O6(n,Math.ceil((s+n[4])/4));return new N6(n[0],n[1],n[2],n[3],a,A)},N6=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>>hi],t=(t<<Rc)+(e&Pc),this.data[t];if(e<=65535)return t=this.index[C1+(e-55296>>hi)],t=(t<<Rc)+(e&Pc),this.data[t];if(e<this.highStart)return t=R6-P6+(e>>pu),t=this.index[t],t+=e>>hi&L6,t=this.index[t],t=(t<<Rc)+(e&Pc),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},r}(),Wh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",K6=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Ka=0;Ka<Wh.length;Ka++)K6[Wh.charCodeAt(Ka)]=Ka;var V6=1,Dc=2,Lc=3,$h=4,Xh=5,z6=7,Jh=8,Oc=9,Hc=10,jh=11,Yh=12,Zh=13,ef=14,Nc=15,G6=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},q6=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},W6=H6(T6),nn="×",Kc="÷",$6=function(r){return W6.get(r)},X6=function(r,e,t){var n=t-2,i=e[n],s=e[t-1],a=e[t];if(s===Dc&&a===Lc)return nn;if(s===Dc||s===Lc||s===$h||a===Dc||a===Lc||a===$h)return Kc;if(s===Jh&&[Jh,Oc,jh,Yh].indexOf(a)!==-1||(s===jh||s===Oc)&&(a===Oc||a===Hc)||(s===Yh||s===Hc)&&a===Hc||a===Zh||a===Xh||a===z6||s===V6)return nn;if(s===Zh&&a===ef){for(;i===Xh;)i=e[--n];if(i===ef)return nn}if(s===Nc&&a===Nc){for(var A=0;i===Nc;)A++,i=e[--n];if(A%2===0)return nn}return Kc},J6=function(r){var e=G6(r),t=e.length,n=0,i=0,s=e.map($6);return{next:function(){if(n>=t)return{done:!0,value:null};for(var a=nn;n<t&&(a=X6(e,s,++n))===nn;);if(a!==nn||n===t){var A=q6.apply(null,e.slice(i,n));return i=n,{value:A,done:!1}}return{done:!0,value:null}}}},j6=function(r){for(var e=J6(r),t=[],n;!(n=e.next()).done;)n.value&&t.push(n.value.slice());return t};const Y6=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},Z6=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=Fo(n.data).map(o=>Ye(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},eT=()=>typeof new Image().crossOrigin<"u",tT=()=>typeof new XMLHttpRequest().responseType=="string",nT=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},tf=r=>r[0]===0&&r[1]===255&&r[2]===0&&r[3]===255,rT=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=ld(t,t,0,0,i);return n.fillStyle="red",n.fillRect(0,0,t,t),nf(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`,tf(o)?nf(ld(t,t,0,0,c)):Promise.reject(!1)}).then(A=>(n.drawImage(A,0,0),tf(n.getImageData(0,0,t,t).data))).catch(()=>!1)},ld=(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},nf=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))}`}),yt={get SUPPORT_RANGE_BOUNDS(){const r=Y6(document);return Object.defineProperty(yt,"SUPPORT_RANGE_BOUNDS",{value:r}),r},get SUPPORT_WORD_BREAKING(){const r=yt.SUPPORT_RANGE_BOUNDS&&Z6(document);return Object.defineProperty(yt,"SUPPORT_WORD_BREAKING",{value:r}),r},get SUPPORT_SVG_DRAWING(){const r=nT(document);return Object.defineProperty(yt,"SUPPORT_SVG_DRAWING",{value:r}),r},get SUPPORT_FOREIGNOBJECT_DRAWING(){const r=typeof Array.from=="function"&&typeof window.fetch=="function"?rT(document):Promise.resolve(!1);return Object.defineProperty(yt,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:r}),r},get SUPPORT_CORS_IMAGES(){const r=eT();return Object.defineProperty(yt,"SUPPORT_CORS_IMAGES",{value:r}),r},get SUPPORT_RESPONSE_TYPE(){const r=tT();return Object.defineProperty(yt,"SUPPORT_RESPONSE_TYPE",{value:r}),r},get SUPPORT_CORS_XHR(){const r="withCredentials"in new XMLHttpRequest;return Object.defineProperty(yt,"SUPPORT_CORS_XHR",{value:r}),r},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){const r=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(yt,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:r}),r}};class fi{constructor(e,t){this.text=e,this.bounds=t}}const iT=(r,e,t,n)=>{const i=AT(e,t),s=[];let a=0;return i.forEach(A=>{if(t.textDecorationLine.length||A.trim().length>0)if(yt.SUPPORT_RANGE_BOUNDS){const o=rf(n,a,A.length).getClientRects();if(o.length>1){const c=qi(A);let l=0;c.forEach(d=>{s.push(new fi(d,St.fromDOMRectList(r,rf(n,l+a,d.length).getClientRects()))),l+=d.length})}else s.push(new fi(A,St.fromDOMRectList(r,o)))}else{const o=n.splitText(A.length);s.push(new fi(A,sT(r,n))),n=o}else yt.SUPPORT_RANGE_BOUNDS||(n=n.splitText(A.length));a+=A.length}),s},sT=(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=Uo(r,n);return n.firstChild&&i.replaceChild(n.firstChild,n),s}}return St.EMPTY},rf=(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},qi=r=>{if(yt.SUPPORT_NATIVE_TEXT_SEGMENTATION){const e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(r)).map(t=>t.segment)}return j6(r)},aT=(r,e)=>{if(yt.SUPPORT_NATIVE_TEXT_SEGMENTATION){const t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(r)).map(n=>n.segment)}return cT(r,e)},AT=(r,e)=>_n(e.writingMode)||e.letterSpacing!==0?qi(r):aT(r,e),oT=[32,160,4961,65792,65793,4153,4241],cT=(r,e)=>{const t=BC(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=Fo(s);let A="";a.forEach(o=>{oT.indexOf(o)===-1?A+=Ye(o):(A.length&&n.push(A),n.push(Ye(o)),A="")}),A.length&&n.push(A)}return n};class lT{constructor(e,t,n){this.text=dT(t.data,n.textTransform),this.text.length!==t.data.length&&(t.data=this.text),this.textBounds=iT(e,this.text,n,t)}}const dT=(r,e)=>{switch(e){case 1:return r.toLowerCase();case 3:return r.replace(uT,hT);case 2:return r.toUpperCase();default:return r}},uT=/(^|\s|:|-|\(|\))([a-z])/g,hT=(r,e,t)=>r.length>0?e+t.toUpperCase():r;class S1 extends Gn{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 T1 extends Gn{constructor(e,t){super(e,t),this.canvas=t,this.intrinsicWidth=t.width,this.intrinsicHeight=t.height}}class k1 extends Gn{constructor(e,t){super(e,t);const n=new XMLSerializer,i=Uo(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 x1 extends Gn{constructor(e,t){super(e,t),this.value=t.value}}class dd extends Gn{constructor(e,t){super(e,t),this.start=t.start,this.reversed=typeof t.reversed=="boolean"&&t.reversed===!0}}const fT=[{type:15,flags:0,unit:"px",number:3}],pT=[{type:16,flags:0,number:50}],mT=r=>r.width>r.height?new St(r.left+(r.width-r.height)/2,r.top,r.height,r.height):r.width<r.height?new St(r.left,r.top+(r.height-r.width)/2,r.width,r.width):r,gT=r=>{const e=r.type===yT?new Array(r.value.length+1).join("•"):r.value;return e.length===0?r.placeholder||"":e},vT=r=>r.value.length===0&&!!r.placeholder,jA="checkbox",YA="radio",yT="password",sf=707406591,wT=1970632191;class Ks extends Gn{constructor(e,t){switch(super(e,t),this.type=t.type.toLowerCase(),this.checked=t.checked,this.value=gT(t),this.isPlaceholder=vT(t),(this.type===jA||this.type===YA)&&(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=mT(this.bounds)),this.type){case jA:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=fT;break;case YA:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=pT;break}}}class E1 extends Gn{constructor(e,t){super(e,t);const n=t.options[t.selectedIndex||0];this.value=n&&n.text||""}}class U1 extends Gn{constructor(e,t){super(e,t),this.value=t.value}}class F1 extends Gn{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):Nn.TRANSPARENT,s=t.contentWindow.document.body?zi(e,getComputedStyle(t.contentWindow.document.body).backgroundColor):Nn.TRANSPARENT;this.backgroundColor=Pr(i)?Pr(s)?this.styles.backgroundColor:s:i}}catch{}}}const bT=["OL","UL","MENU"],yA=(r,e,t,n)=>{for(let i=e.firstChild,s;i;i=s)if(s=i.nextSibling,B1(i)&&i.data.length>0)t.textNodes.push(new lT(r,i,t.styles));else if(nr(i))if(Us(i)&&i.assignedNodes)i.assignedNodes().forEach(a=>yA(r,a,t,n));else{const a=I1(r,i);a.styles.isVisible()&&(BT(i,a,n)?a.flags|=4:CT(a.styles)&&(a.flags|=2),bT.indexOf(i.tagName)!==-1&&(a.flags|=8),t.elements.push(a),i.slot,i.shadowRoot?yA(r,i.shadowRoot,a,n):!ZA(i)&&!M1(i)&&!eo(i)&&yA(r,i,a,n))}},I1=(r,e)=>ud(e)?new S1(r,e):_1(e)?new T1(r,e):M1(e)?new k1(r,e):b6(e)?new x1(r,e):B6(e)?new dd(r,e):ST(e)?new Ks(r,e):eo(e)?new E1(r,e):ZA(e)?new U1(r,e):R1(e)?new F1(r,e,Q1):new Gn(r,e),Q1=(r,e)=>{const t=I1(r,e);return t.flags|=4,yA(r,e,t,t),t},BT=(r,e,t)=>e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||mu(r)&&t.styles.isTransparent(),CT=r=>r.isPositioned()||r.isFloating()?!0:ze(r.display,268435456)||ze(r.display,33554432)||ze(r.display,536870912)||ze(r.display,134217728),ST=r=>r.tagName==="INPUT",TT=r=>r.tagName==="HTML",M1=r=>r.tagName==="svg",mu=r=>r.tagName==="BODY",_1=r=>r.tagName==="CANVAS",af=r=>r.tagName==="VIDEO",ud=r=>r.tagName==="IMG",R1=r=>r.tagName==="IFRAME",Vc=r=>r.tagName==="STYLE",Af=r=>r.tagName==="SCRIPT",ZA=r=>r.tagName==="TEXTAREA",eo=r=>r.tagName==="SELECT",Us=r=>r.tagName==="SLOT";class kT{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 of={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"]},cf={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:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},xT={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:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},ET={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:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},xi=(r,e,t,n,i,s)=>r<e||r>t?ca(r,i,s.length>0):n.integers.reduce((a,A,o)=>{for(;r>=A;)r-=A,a+=n.values[o];return a},"")+s,P1=(r,e,t,n)=>{let i="";do t||r--,i=n(r)+i,r/=e;while(r*e>=e);return i},je=(r,e,t,n,i)=>{const s=t-e+1;return(r<0?"-":"")+(P1(Math.abs(r),s,n,a=>Ye(Math.floor(a%s)+e))+i)},Wr=(r,e,t=". ")=>{const n=e.length;return P1(Math.abs(r),n,!1,i=>e[Math.floor(i%n)])+t},Ii=1,Cr=2,Sr=4,Fs=8,Yn=(r,e,t,n,i,s)=>{if(r<-9999||r>9999)return ca(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&&ze(s,Ii)&&A!==""?A=e[c]+A:c>1||c===1&&o===0||c===1&&o===1&&ze(s,Cr)||c===1&&o===1&&ze(s,Sr)&&r>100||c===1&&o>1&&ze(s,Fs)?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},lf="十百千萬",df="拾佰仟萬",uf="マイナス",zc="마이너스",ca=(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=je(r,48,57,!0,n);return A.length<4?`0${A}`:A;case 4:return Wr(r,"〇一二三四五六七八九",i);case 6:return xi(r,1,3999,of,3,n).toLowerCase();case 7:return xi(r,1,3999,of,3,n);case 8:return je(r,945,969,!1,n);case 9:return je(r,97,122,!1,n);case 10:return je(r,65,90,!1,n);case 11:return je(r,1632,1641,!0,n);case 12:case 49:return xi(r,1,9999,cf,3,n);case 35:return xi(r,1,9999,cf,3,n).toLowerCase();case 13:return je(r,2534,2543,!0,n);case 14:case 30:return je(r,6112,6121,!0,n);case 15:return Wr(r,"子丑寅卯辰巳午未申酉戌亥",i);case 16:return Wr(r,"甲乙丙丁戊己庚辛壬癸",i);case 17:case 48:return Yn(r,"零一二三四五六七八九",lf,"負",i,Cr|Sr|Fs);case 47:return Yn(r,"零壹貳參肆伍陸柒捌玖",df,"負",i,Ii|Cr|Sr|Fs);case 42:return Yn(r,"零一二三四五六七八九",lf,"负",i,Cr|Sr|Fs);case 41:return Yn(r,"零壹贰叁肆伍陆柒捌玖",df,"负",i,Ii|Cr|Sr|Fs);case 26:return Yn(r,"〇一二三四五六七八九","十百千万",uf,i,0);case 25:return Yn(r,"零壱弐参四伍六七八九","拾百千万",uf,i,Ii|Cr|Sr);case 31:return Yn(r,"영일이삼사오육칠팔구","십백천만",zc,s,Ii|Cr|Sr);case 33:return Yn(r,"零一二三四五六七八九","十百千萬",zc,s,0);case 32:return Yn(r,"零壹貳參四五六七八九","拾百千",zc,s,Ii|Cr|Sr);case 18:return je(r,2406,2415,!0,n);case 20:return xi(r,1,19999,ET,3,n);case 21:return je(r,2790,2799,!0,n);case 22:return je(r,2662,2671,!0,n);case 52:return xi(r,1,10999,xT,3,n);case 23:return Wr(r,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return Wr(r,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return je(r,3302,3311,!0,n);case 28:return Wr(r,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",i);case 29:return Wr(r,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",i);case 34:return je(r,3792,3801,!0,n);case 37:return je(r,6160,6169,!0,n);case 38:return je(r,4160,4169,!0,n);case 39:return je(r,2918,2927,!0,n);case 40:return je(r,1776,1785,!0,n);case 43:return je(r,3046,3055,!0,n);case 44:return je(r,3174,3183,!0,n);case 45:return je(r,3664,3673,!0,n);case 46:return je(r,3872,3881,!0,n);case 3:default:return je(r,48,57,!0,n)}},hd="data-html2canvas-ignore",UT=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 hf{constructor(e,t,n){if(this.context=e,this.options=n,this.scrolledElements=[],this.referenceElement=t,this.counters=new kT,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");if(!this.options.iframeContainer){const i=UT(t);i&&(this.options.iframeContainer=i)}this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}toIFrame(e,t){var u,h;const n=FT(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=MT(n).then(async()=>{this.scrolledElements.forEach(DT),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 m=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 QT(A),typeof m=="function"?Promise.resolve().then(()=>m(A,g)).then(()=>n):n}),c=e.baseURI;A.open();const l=RT(document.doctype)+"<html></html>";try{const m=(u=this.referenceElement.ownerDocument)==null?void 0:u.defaultView,g=m&&m.trustedTypes;let y=(h=g==null?void 0:g.getPolicy)==null?void 0:h.call(g,"html2canvas-pro");!y&&g&&(y=g.createPolicy("html2canvas-pro",{createHTML:b=>b})),y?A.write(y.createHTML(l)):A.write(l)}catch{A.write(l)}PT(this.referenceElement.ownerDocument,i,s),A.close();const d=A.adoptNode(this.documentElement);return KT(d,c),A.replaceChild(d,A.documentElement),o}createElementClone(e){if(cd(e,2),_1(e))return this.createCanvasClone(e);if(af(e))return this.createVideoClone(e);if(Vc(e))return this.createStyleClone(e);const t=e.cloneNode(!1);return ud(t)&&(ud(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager")),Vh(t)&&!Ri(t)?this.createCustomElementClone(t):t}createCustomElementClone(e){const t=document.createElement("div");if(t.className=e.className,Gc(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){(!nr(t)||!Af(t)&&!t.hasAttribute(hd)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(t)))&&(!this.options.copyStyles||!nr(t)||!Vc(t))&&e.appendChild(this.cloneNode(t,n))}shouldCloneChild(e){return!nr(e)||!Af(e)&&!e.hasAttribute(hd)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(e))}shouldCloneStyleElement(e){return!this.options.copyStyles||!nr(e)||!Vc(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(!Us(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)nr(i)&&Us(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(!Us(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)nr(i)&&Us(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(B1(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);const n=e.ownerDocument.defaultView;if(n&&nr(e)&&(oa(e)||Ri(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&&oa(i)&&(this.clonedReferenceElement=i),mu(i)&&HT(i,this.options.cspNonce);const o=this.counters.parse(new Kh(this.context,s)),c=this.resolvePseudoContent(e,i,a,Vs.BEFORE);Vh(e)&&(t=!0),af(e)||this.cloneChildNodes(e,i,t),c&&i.insertBefore(c,i.firstChild);const l=this.resolvePseudoContent(e,i,A,Vs.AFTER);return l&&i.appendChild(l),this.counters.pop(o),(s&&(this.options.copyStyles||Ri(e))&&!R1(e)||t)&&Gc(s,i),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([i,e.scrollLeft,e.scrollTop]),(ZA(e)||eo(e))&&(ZA(i)||eo(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 Kh(this.context,n));const A=new w6(this.context,n),o=a.createElement("html2canvaspseudoelement");Gc(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(me);d.length&&o.appendChild(a.createTextNode(e.getAttribute(d[0].value)||""))}else if(l.name==="counter"){const[d,u]=l.values.filter(bt);if(d&&me(d)){const h=this.counters.getCounterValue(d.value),m=u&&me(u)?od.parse(this.context,u.value):3;o.appendChild(a.createTextNode(ca(h,m,!1)))}}else if(l.name==="counters"){const[d,u,h]=l.values.filter(bt);if(d&&me(d)){const m=this.counters.getCounterValues(d.value),g=h&&me(h)?od.parse(this.context,h.value):3,y=u&&u.type===0?u.value:"",b=m.map(B=>ca(B,g,!1)).join(y);o.appendChild(a.createTextNode(b))}}}else if(l.type===20)switch(l.value){case"open-quote":o.appendChild(a.createTextNode(Nh(A.quotes,this.quoteDepth++,!0)));break;case"close-quote":o.appendChild(a.createTextNode(Nh(A.quotes,--this.quoteDepth,!1)));break;default:o.appendChild(a.createTextNode(l.value))}}),o.className=`${fd} ${pd}`;const c=i===Vs.BEFORE?` ${fd}`:` ${pd}`;return Ri(t)?t.className.baseValue+=c:t.className+=c,o}static destroy(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1}}var Vs;(function(r){r[r.BEFORE=0]="BEFORE",r[r.AFTER=1]="AFTER"})(Vs||(Vs={}));const FT=(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(hd,"true"),(t||r.body).appendChild(n),n},IT=r=>new Promise(e=>{if(r.complete){e();return}if(!r.src){e();return}r.onload=e,r.onerror=e}),QT=r=>Promise.all([].slice.call(r.images,0).map(IT)),MT=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)}}),_T=["all","d","content"],Gc=(r,e)=>{for(let t=r.length-1;t>=0;t--){const n=r.item(t);_T.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},PT=(r,e,t)=>{r&&r.defaultView&&(e!==r.defaultView.pageXOffset||t!==r.defaultView.pageYOffset)&&r.defaultView.scrollTo(e,t)},DT=([r,e,t])=>{r.scrollLeft=e,r.scrollTop=t},LT=":before",OT=":after",fd="___html2canvas___pseudoelement_before",pd="___html2canvas___pseudoelement_after",ff=`{
|
|
40
|
+
content: "" !important;
|
|
41
|
+
display: none !important;
|
|
42
|
+
}`,HT=(r,e)=>{NT(r,`.${fd}${LT}${ff}
|
|
43
|
+
.${pd}${OT}${ff}`,e)},NT=(r,e,t)=>{const n=r.ownerDocument;if(n){const i=n.createElement("style");i.textContent=e,t&&(i.nonce=t),r.appendChild(i)}},KT=(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 Ei=(r,e,t)=>new Y(r.x+(e.x-r.x)*t,r.y+(e.y-r.y)*t);class cr{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=Ei(this.start,this.startControl,e),i=Ei(this.startControl,this.endControl,e),s=Ei(this.endControl,this.end,e),a=Ei(n,i,e),A=Ei(i,s,e),o=Ei(a,A,e);return t?new cr(this.start,n,a,o):new cr(o,A,s,this.end)}add(e,t){return new cr(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))}reverse(){return new cr(this.end,this.endControl,this.startControl,this.start)}}const Nt=r=>r.type===1;class VT{constructor(e){const t=e.styles,n=e.bounds;let[i,s]=xs(t.borderTopLeftRadius,n.width,n.height),[a,A]=xs(t.borderTopRightRadius,n.width,n.height),[o,c]=xs(t.borderBottomRightRadius,n.width,n.height),[l,d]=xs(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 m=n.width-a,g=n.height-c,y=n.width-o,b=n.height-d,B=t.borderTopWidth,U=t.borderRightWidth,w=t.borderBottomWidth,C=t.borderLeftWidth,E=de(t.paddingTop,e.bounds.width),I=de(t.paddingRight,e.bounds.width),_=de(t.paddingBottom,e.bounds.width),P=de(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=i>0||s>0?Pe(n.left+C/3,n.top+B/3,i-C/3,s-B/3,ke.TOP_LEFT):new Y(n.left+C/3,n.top+B/3),this.topRightBorderDoubleOuterBox=i>0||s>0?Pe(n.left+m,n.top+B/3,a-U/3,A-B/3,ke.TOP_RIGHT):new Y(n.left+n.width-U/3,n.top+B/3),this.bottomRightBorderDoubleOuterBox=o>0||c>0?Pe(n.left+y,n.top+g,o-U/3,c-w/3,ke.BOTTOM_RIGHT):new Y(n.left+n.width-U/3,n.top+n.height-w/3),this.bottomLeftBorderDoubleOuterBox=l>0||d>0?Pe(n.left+C/3,n.top+b,l-C/3,d-w/3,ke.BOTTOM_LEFT):new Y(n.left+C/3,n.top+n.height-w/3),this.topLeftBorderDoubleInnerBox=i>0||s>0?Pe(n.left+C*2/3,n.top+B*2/3,i-C*2/3,s-B*2/3,ke.TOP_LEFT):new Y(n.left+C*2/3,n.top+B*2/3),this.topRightBorderDoubleInnerBox=i>0||s>0?Pe(n.left+m,n.top+B*2/3,a-U*2/3,A-B*2/3,ke.TOP_RIGHT):new Y(n.left+n.width-U*2/3,n.top+B*2/3),this.bottomRightBorderDoubleInnerBox=o>0||c>0?Pe(n.left+y,n.top+g,o-U*2/3,c-w*2/3,ke.BOTTOM_RIGHT):new Y(n.left+n.width-U*2/3,n.top+n.height-w*2/3),this.bottomLeftBorderDoubleInnerBox=l>0||d>0?Pe(n.left+C*2/3,n.top+b,l-C*2/3,d-w*2/3,ke.BOTTOM_LEFT):new Y(n.left+C*2/3,n.top+n.height-w*2/3),this.topLeftBorderStroke=i>0||s>0?Pe(n.left+C/2,n.top+B/2,i-C/2,s-B/2,ke.TOP_LEFT):new Y(n.left+C/2,n.top+B/2),this.topRightBorderStroke=i>0||s>0?Pe(n.left+m,n.top+B/2,a-U/2,A-B/2,ke.TOP_RIGHT):new Y(n.left+n.width-U/2,n.top+B/2),this.bottomRightBorderStroke=o>0||c>0?Pe(n.left+y,n.top+g,o-U/2,c-w/2,ke.BOTTOM_RIGHT):new Y(n.left+n.width-U/2,n.top+n.height-w/2),this.bottomLeftBorderStroke=l>0||d>0?Pe(n.left+C/2,n.top+b,l-C/2,d-w/2,ke.BOTTOM_LEFT):new Y(n.left+C/2,n.top+n.height-w/2),this.topLeftBorderBox=i>0||s>0?Pe(n.left,n.top,i,s,ke.TOP_LEFT):new Y(n.left,n.top),this.topRightBorderBox=a>0||A>0?Pe(n.left+m,n.top,a,A,ke.TOP_RIGHT):new Y(n.left+n.width,n.top),this.bottomRightBorderBox=o>0||c>0?Pe(n.left+y,n.top+g,o,c,ke.BOTTOM_RIGHT):new Y(n.left+n.width,n.top+n.height),this.bottomLeftBorderBox=l>0||d>0?Pe(n.left,n.top+b,l,d,ke.BOTTOM_LEFT):new Y(n.left,n.top+n.height),this.topLeftPaddingBox=i>0||s>0?Pe(n.left+C,n.top+B,Math.max(0,i-C),Math.max(0,s-B),ke.TOP_LEFT):new Y(n.left+C,n.top+B),this.topRightPaddingBox=a>0||A>0?Pe(n.left+Math.min(m,n.width-U),n.top+B,m>n.width+U?0:Math.max(0,a-U),Math.max(0,A-B),ke.TOP_RIGHT):new Y(n.left+n.width-U,n.top+B),this.bottomRightPaddingBox=o>0||c>0?Pe(n.left+Math.min(y,n.width-C),n.top+Math.min(g,n.height-w),Math.max(0,o-U),Math.max(0,c-w),ke.BOTTOM_RIGHT):new Y(n.left+n.width-U,n.top+n.height-w),this.bottomLeftPaddingBox=l>0||d>0?Pe(n.left+C,n.top+Math.min(b,n.height-w),Math.max(0,l-C),Math.max(0,d-w),ke.BOTTOM_LEFT):new Y(n.left+C,n.top+n.height-w),this.topLeftContentBox=i>0||s>0?Pe(n.left+C+P,n.top+B+E,Math.max(0,i-(C+P)),Math.max(0,s-(B+E)),ke.TOP_LEFT):new Y(n.left+C+P,n.top+B+E),this.topRightContentBox=a>0||A>0?Pe(n.left+Math.min(m,n.width+C+P),n.top+B+E,m>n.width+C+P?0:a-C+P,A-(B+E),ke.TOP_RIGHT):new Y(n.left+n.width-(U+I),n.top+B+E),this.bottomRightContentBox=o>0||c>0?Pe(n.left+Math.min(y,n.width-(C+P)),n.top+Math.min(g,n.height+B+E),Math.max(0,o-(U+I)),c-(w+_),ke.BOTTOM_RIGHT):new Y(n.left+n.width-(U+I),n.top+n.height-(w+_)),this.bottomLeftContentBox=l>0||d>0?Pe(n.left+C+P,n.top+b,Math.max(0,l-(C+P)),d-(w+_),ke.BOTTOM_LEFT):new Y(n.left+C+P,n.top+n.height-(w+_))}}var ke;(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"})(ke||(ke={}));const Pe=(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 ke.TOP_LEFT:return new cr(new Y(r,c),new Y(r,c-A),new Y(o-a,e),new Y(o,e));case ke.TOP_RIGHT:return new cr(new Y(r,e),new Y(r+a,e),new Y(o,c-A),new Y(o,c));case ke.BOTTOM_RIGHT:return new cr(new Y(o,e),new Y(o,e+A),new Y(r+a,c),new Y(r,c));case ke.BOTTOM_LEFT:default:return new cr(new Y(o,c),new Y(o-a,c),new Y(r,e+A),new Y(r,e))}},to=r=>[r.topLeftBorderBox,r.topRightBorderBox,r.bottomRightBorderBox,r.bottomLeftBorderBox],zT=r=>[r.topLeftContentBox,r.topRightContentBox,r.bottomRightContentBox,r.bottomLeftContentBox],no=r=>[r.topLeftPaddingBox,r.topRightPaddingBox,r.bottomRightPaddingBox,r.bottomLeftPaddingBox];class pf{constructor(e,t,n){this.offsetX=e,this.offsetY=t,this.matrix=n,this.type=0,this.target=6}}class Va{constructor(e,t){this.path=e,this.target=t,this.type=1}}class GT{constructor(e){this.opacity=e,this.type=2,this.target=6}}class gs{constructor(e){this.applyClip=e,this.type=3,this.target=6}}const qT=r=>r.type===0,D1=r=>r.type===1,WT=r=>r.type===2,$T=r=>r.type===3,mf=(r,e)=>r.length===e.length?r.some((t,n)=>t===e[n]):!1,XT=(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 L1{constructor(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}}class O1{constructor(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new VT(this.container),this.container.styles.opacity<1&&this.effects.push(new GT(this.container.styles.opacity)),this.container.styles.rotate!==null){const n=this.container.styles.transformOrigin,i=this.container.bounds.left+de(n[0],this.container.bounds.width),s=this.container.bounds.top+de(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 pf(i,s,l))}if(this.container.styles.transform!==null){const n=this.container.styles.transformOrigin,i=this.container.bounds.left+de(n[0],this.container.bounds.width),s=this.container.bounds.top+de(n[1],this.container.bounds.height),a=this.container.styles.transform;this.effects.push(new pf(i,s,a))}if(this.container.styles.overflowX!==0){const n=to(this.curves),i=no(this.curves);mf(n,i)?this.effects.push(new Va(n,6)):(this.effects.push(new Va(n,2)),this.effects.push(new Va(i,4)))}if(this.container.styles.clipPath.type!==0){const n=JT(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=>!D1(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=to(n.curves),A=no(n.curves);mf(a,A)||i.unshift(new Va(A,6))}i.unshift(...s)}else i.unshift(...s);n=n.parent}return i.filter(s=>ze(s.target,e))}}const gf=(r,e,t,n,i)=>r==="closest-side"?Math.min(e-t,n-e):r==="farthest-side"?Math.max(e-t,n-e):de(r,i),JT=(r,e)=>{const{left:t,top:n,width:i,height:s}=e;switch(r.type){case 1:{const a=de(r.left,i),A=de(r.top,s),o=t+a,c=n+A,l=Math.max(0,i-a-de(r.right,i)),d=Math.max(0,s-A-de(r.bottom,s));return new gs(u=>{u.beginPath(),u.rect(o,c,l,d),u.clip()})}case 2:{const a=t+de(r.cx,i),A=n+de(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=de(r.radius,Math.sqrt(i*i+s*s)/Math.SQRT2),new gs(c=>{c.beginPath(),c.arc(a,A,Math.max(0,o),0,Math.PI*2),c.clip()})}case 3:{const a=t+de(r.cx,i),A=n+de(r.cy,s),o=gf(r.rx,a,t,t+i,i),c=gf(r.ry,A,n,n+s,s);return new gs(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+de(A,i),n+de(o,s)]);return new gs(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 gs(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}},md=(r,e,t,n)=>{r.container.elements.forEach(i=>{const s=ze(i.flags,4),a=ze(i.flags,2),A=new O1(i,r);ze(i.styles.display,2048)&&n.push(A);const o=ze(i.flags,8)?[]:n;if(s||a){const c=s||i.styles.isPositioned()?t:e,l=new L1(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,m)=>d>h.element.container.styles.zIndex.order?(u=m,!1):u>0),c.negativeZIndex.splice(u,0,l)}else if(d>0){let u=0;c.positiveZIndex.some((h,m)=>d>=h.element.container.styles.zIndex.order?(u=m+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);md(A,l,s?l:t,o)}else i.styles.isInlineLevel()?e.inlineLevel.push(A):e.nonInlineLevel.push(A),md(A,e,t,o);ze(i.flags,8)&&H1(i,o)})},H1=(r,e)=>{let t=r instanceof dd?r.start:1;const n=r instanceof dd?r.reversed:!1;for(let i=0;i<e.length;i++){const s=e[i];s.container instanceof x1&&typeof s.container.value=="number"&&s.container.value!==0&&(t=s.container.value),s.listValue=ca(t,s.container.styles.listStyleType,!0),t+=n?-1:1}},jT=r=>{const e=new O1(r,null),t=new L1(e),n=[];return md(e,t,t,n),H1(e.container,n),t},N1=r=>{const e=r.bounds,t=r.styles;return e.add(t.borderLeftWidth,t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth),-(t.borderTopWidth+t.borderBottomWidth))},zs=r=>{const e=r.styles,t=r.bounds,n=de(e.paddingLeft,t.width),i=de(e.paddingRight,t.width),s=de(e.paddingTop,t.width),a=de(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))},YT=(r,e)=>r===0?e.bounds:r===2?zs(e):N1(e),ZT=(r,e)=>r===0?e.bounds:r===2?zs(e):N1(e),qc=(r,e,t)=>{const n=YT(Qi(r.styles.backgroundOrigin,e),r),i=ZT(Qi(r.styles.backgroundClip,e),r),s=ek(Qi(r.styles.backgroundSize,e),t,n);let[a,A]=s;const o=xs(Qi(r.styles.backgroundPosition,e),n.width-a,n.height-A),c=tk(Qi(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]},Ui=r=>me(r)&&r.value===Gi.AUTO,za=r=>typeof r=="number",ek=(r,[e,t,n],i)=>{const[s,a]=r;if(!s)return[0,0];if(Ee(s)&&a&&Ee(a))return[de(s,i.width),de(a,i.height)];const A=za(n);if(me(s)&&(s.value===Gi.CONTAIN||s.value===Gi.COVER))return za(n)?i.width/i.height<n!=(s.value===Gi.COVER)?[i.width,i.width/n]:[i.height*n,i.height]:[i.width,i.height];const o=za(e),c=za(t),l=o||c;if(Ui(s)&&(!a||Ui(a))){if(o&&c)return[e,t];if(!A&&!l)return[i.width,i.height];if(l&&A){const g=o?e:t*n,y=c?t:e/n;return[g,y]}const h=o?e:i.width,m=c?t:i.height;return[h,m]}if(A){let h=0,m=0;return Ee(s)?h=de(s,i.width):Ee(a)&&(m=de(a,i.height)),Ui(s)?h=m*n:(!a||Ui(a))&&(m=h/n),[h,m]}let d=null,u=null;if(Ee(s)?d=de(s,i.width):a&&Ee(a)&&(u=de(a,i.height)),d!==null&&(!a||Ui(a))&&(u=o&&c?d/e*t:i.height),u!==null&&Ui(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")},Qi=(r,e)=>{const t=r[e];return typeof t>"u"?r[0]:t},tk=(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))]}},nk="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",vf="Hidden Text";class rk{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=nk,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(vf)),n.appendChild(s),n.appendChild(i);const A=i.offsetTop-s.offsetTop+2;n.removeChild(s),n.appendChild(this._document.createTextNode(vf)),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 K1{constructor(e,t){this.context=e,this.options=t}}class ik{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):M5(n)?this.renderLinearGradient(e,n,t):_5(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]=qc(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]=qc(e,n,[null,null,null]),[c,l,d,u,h]=E5(t.angle,A,o),g=(this.canvas.ownerDocument??document).createElement("canvas");g.width=A,g.height=o;const y=g.getContext("2d"),b=y.createLinearGradient(l,u,d,h);if(Dh(t.stops,c||1).forEach(B=>b.addColorStop(B.stop,_e(B.color))),y.fillStyle=b,y.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]=qc(e,n,[null,null,null]),c=t.position.length===0?[Ai]:t.position,l=de(c[0],A),d=de(c[c.length-1],o);let[u,h]=U5(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 m=this.ctx.createRadialGradient(s+l,a+d,0,s+l,a+d,u);if(Dh(t.stops,u*2).forEach(g=>m.addColorStop(g.stop,_e(g.color))),this.path(i),this.ctx.fillStyle=m,u!==h){const g=e.bounds.left+.5*e.bounds.width,y=e.bounds.top+.5*e.bounds.height,b=h/u,B=1/b;this.ctx.save(),this.ctx.translate(g,y),this.ctx.transform(1,0,0,b,0,0),this.ctx.translate(-g,-y),this.ctx.fillRect(s,B*(a-y)+y,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===Jt.PIXELATED||i===Jt.CRISP_EDGES?(this.context.logger.debug("Disabling image smoothing for background image due to CSS image-rendering"),A.imageSmoothingEnabled=!1):i===Jt.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=Nt(t)?t.start:t;n===0?this.ctx.moveTo(i.x,i.y):this.ctx.lineTo(i.x,i.y),Nt(t)&&this.ctx.bezierCurveTo(t.startControl.x,t.startControl.y,t.endControl.x,t.endControl.y,t.end.x,t.end.y)})}}const yf=(r,e)=>{switch(e){case 0:return an(r.topLeftBorderBox,r.topLeftPaddingBox,r.topRightBorderBox,r.topRightPaddingBox);case 1:return an(r.topRightBorderBox,r.topRightPaddingBox,r.bottomRightBorderBox,r.bottomRightPaddingBox);case 2:return an(r.bottomRightBorderBox,r.bottomRightPaddingBox,r.bottomLeftBorderBox,r.bottomLeftPaddingBox);case 3:default:return an(r.bottomLeftBorderBox,r.bottomLeftPaddingBox,r.topLeftBorderBox,r.topLeftPaddingBox)}},sk=(r,e)=>{switch(e){case 0:return an(r.topLeftBorderBox,r.topLeftBorderDoubleOuterBox,r.topRightBorderBox,r.topRightBorderDoubleOuterBox);case 1:return an(r.topRightBorderBox,r.topRightBorderDoubleOuterBox,r.bottomRightBorderBox,r.bottomRightBorderDoubleOuterBox);case 2:return an(r.bottomRightBorderBox,r.bottomRightBorderDoubleOuterBox,r.bottomLeftBorderBox,r.bottomLeftBorderDoubleOuterBox);case 3:default:return an(r.bottomLeftBorderBox,r.bottomLeftBorderDoubleOuterBox,r.topLeftBorderBox,r.topLeftBorderDoubleOuterBox)}},ak=(r,e)=>{switch(e){case 0:return an(r.topLeftBorderDoubleInnerBox,r.topLeftPaddingBox,r.topRightBorderDoubleInnerBox,r.topRightPaddingBox);case 1:return an(r.topRightBorderDoubleInnerBox,r.topRightPaddingBox,r.bottomRightBorderDoubleInnerBox,r.bottomRightPaddingBox);case 2:return an(r.bottomRightBorderDoubleInnerBox,r.bottomRightPaddingBox,r.bottomLeftBorderDoubleInnerBox,r.bottomLeftPaddingBox);case 3:default:return an(r.bottomLeftBorderDoubleInnerBox,r.bottomLeftPaddingBox,r.topLeftBorderDoubleInnerBox,r.topLeftPaddingBox)}},Ak=(r,e)=>{switch(e){case 0:return Ga(r.topLeftBorderStroke,r.topRightBorderStroke);case 1:return Ga(r.topRightBorderStroke,r.bottomRightBorderStroke);case 2:return Ga(r.bottomRightBorderStroke,r.bottomLeftBorderStroke);case 3:default:return Ga(r.bottomLeftBorderStroke,r.topLeftBorderStroke)}},Ga=(r,e)=>{const t=[];return Nt(r)?t.push(r.subdivide(.5,!1)):t.push(r),Nt(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},an=(r,e,t,n)=>{const i=[];return Nt(r)?i.push(r.subdivide(.5,!1)):i.push(r),Nt(t)?i.push(t.subdivide(.5,!0)):i.push(t),Nt(n)?i.push(n.subdivide(.5,!0).reverse()):i.push(n),Nt(e)?i.push(e.subdivide(.5,!1).reverse()):i.push(e),i};class ok{constructor(e,t){this.ctx=e.ctx,this.pathCallbacks=t}async renderSolidBorder(e,t,n){this.pathCallbacks.path(yf(n,t)),this.ctx.fillStyle=_e(e),this.ctx.fill()}async renderDoubleBorder(e,t,n,i){if(t<3){await this.renderSolidBorder(e,n,i);return}const s=sk(i,n);this.pathCallbacks.path(s),this.ctx.fillStyle=_e(e),this.ctx.fill();const a=ak(i,n);this.pathCallbacks.path(a),this.ctx.fill()}async renderDashedDottedBorder(e,t,n,i,s){this.ctx.save();const a=Ak(i,n),A=yf(i,n);s===2&&(this.pathCallbacks.path(A),this.ctx.clip());let o,c,l,d;Nt(A[0])?(o=A[0].start.x,c=A[0].start.y):(o=A[0].x,c=A[0].y),Nt(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,m=t<3?t*2:t;s===3&&(h=t,m=t);let g=!0;if(u<=h*2)g=!1;else if(u<=h*2+m){const y=u/(2*h+m);h*=y,m*=y}else{const y=Math.floor((u+m)/(h+m)),b=(u-y*h)/(y-1),B=(u-(y+1)*h)/y;m=B<=0||Math.abs(m-b)<Math.abs(m-B)?b:B}if(g&&(s===3?this.ctx.setLineDash([0,h+m]):this.ctx.setLineDash([h,m])),s===3?(this.ctx.lineCap="round",this.ctx.lineWidth=t):this.ctx.lineWidth=t*2+1.1,this.ctx.strokeStyle=_e(e),this.ctx.stroke(),this.ctx.setLineDash([]),s===2){if(Nt(A[0])){const y=A[3],b=A[0];this.ctx.beginPath(),this.pathCallbacks.formatPath([new Y(y.end.x,y.end.y),new Y(b.start.x,b.start.y)]),this.ctx.stroke()}if(Nt(A[1])){const y=A[1],b=A[2];this.ctx.beginPath(),this.pathCallbacks.formatPath([new Y(y.end.x,y.end.y),new Y(b.start.x,b.start.y)]),this.ctx.stroke()}}this.ctx.restore()}}class ck{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(),WT(e)?this.ctx.globalAlpha=e.opacity:qT(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)):D1(e)?(this.pathCallback.path(e.path),this.ctx.clip()):$T(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 lk=["-apple-system","system-ui"],dk=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,Wc=r=>dk.test(r),uk=()=>{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},hk=r=>{const e=uk();return e!==null&&e>=15&&e<17?r.map(t=>lk.indexOf(t)!==-1?'-apple-system, "Helvetica Neue", Arial, sans-serif':t):r};class fk{constructor(e){this.ctx=e.ctx,this.options=e.options}iterateLettersWithLetterSpacing(e,t,n,i,s){if(_n(i)){this.iterateVerticalGlyphs(e,t,n,i,s);return}const a=qi(e.text),A=e.bounds.top+n;let o=e.bounds.left;for(const c of a){if(Wc(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=qi(e.text);let A=e.bounds.top;for(const o of a){if(GS(i)||!Wc(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;Wc(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&&!_n(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=_e(t.color),this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode);break;case 1:t.webkitTextStrokeWidth&&e.text.trim().length&&(this.ctx.strokeStyle=_e(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",t.letterSpacing===0&&!_n(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=_e(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=qi(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=hk(e.fontFamily).join(", "),i=zn(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 m=t.webkitLineClamp;if(d.length>m){for(let y=0;y<m-1;y++)d[y].forEach(b=>{this.renderTextBoundWithPaintOrder(b,t,s)});const g=d[m-1];if(g&&g.length>0&&n){const y=g.map(C=>C.text).join(""),b=g[0],B=n.width-(b.bounds.left-n.left),U=this.truncateTextWithEllipsis(y,B,t.letterSpacing),w=new fi(U,b.bounds);s.forEach(C=>{switch(C){case 0:this.ctx.fillStyle=_e(t.color),t.letterSpacing===0&&!_n(t.writingMode)?this.ctx.fillText(U,b.bounds.left,b.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(w,t.letterSpacing,t.fontSize.number,t.writingMode,(E,I,_)=>this.ctx.fillText(E,I,_));break;case 1:t.webkitTextStrokeWidth&&U.trim().length&&(this.ctx.strokeStyle=_e(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",t.letterSpacing===0&&!_n(t.writingMode)?this.ctx.strokeText(U,b.bounds.left,b.bounds.top+t.fontSize.number):this.iterateLettersWithLetterSpacing(w,t.letterSpacing,t.fontSize.number,t.writingMode,(E,I,_)=>this.ctx.strokeText(E,I,_)),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(y=>y.text).join("");h=h.replace(/\s+/g," ").trim();const m=this.ctx.measureText(h).width,g=n.width;m>g&&(c=!0,l=this.truncateTextWithEllipsis(h,g,t.letterSpacing))}}if(c){const d=e.textBounds[0],u=new fi(l,d.bounds);s.forEach(h=>{switch(h){case 0:{this.ctx.fillStyle=_e(t.color),t.letterSpacing===0&&!_n(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,y,b)=>this.ctx.fillText(g,y,b));const m=t.textShadow;m.length&&l.trim().length&&(m.slice(0).reverse().forEach(g=>{this.ctx.shadowColor=_e(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&&!_n(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,(y,b,B)=>this.ctx.fillText(y,b,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=_e(t.webkitTextStrokeColor),this.ctx.lineWidth=t.webkitTextStrokeWidth,this.ctx.lineJoin=typeof window<"u"&&window.chrome?"miter":"round",t.letterSpacing===0&&!_n(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,(m,g,y)=>this.ctx.strokeText(m,g,y)),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=_e(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(m=>{this.ctx.shadowColor=_e(m.color),this.ctx.shadowOffsetX=m.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=m.offsetY.number*this.options.scale,this.ctx.shadowBlur=m.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=_e(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&&!_n(t.writingMode)?this.ctx.strokeText(d.text,d.bounds.left,d.bounds.top+h):this.iterateLettersWithLetterSpacing(d,t.letterSpacing,h,t.writingMode,(m,g,y)=>this.ctx.strokeText(m,g,y)),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter"}break}}})})}}const pk=1e4;class gu extends K1{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 rk(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 ik({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:t.width,height:t.height,scale:t.scale}}),this.borderRenderer=new ok({ctx:this.ctx},{path:n=>this.path(n),formatPath:n=>this.formatPath(n)}),this.effectsRenderer=new ck({ctx:this.ctx},{path:n=>this.path(n)}),this.textRenderer=new fk({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){ze(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=zs(e),A=no(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,m=a.width,g=a.height;const{objectFit:y}=e.styles,b=m/g,B=l/d;if(y===2)B>b?(g=m/B,h+=(a.height-g)/2):(m=g*B,u+=(a.width-m)/2);else if(y===4)B>b?(l=d*b,o+=(i-l)/2):(d=l/b,c+=(s-d)/2);else if(y===8)l>m?(o+=(l-m)/2,l=m):(u+=(m-l)/2,m=l),d>g?(c+=(d-g)/2,d=g):(h+=(g-d)/2,g=d);else if(y===16){const U=B>b?m:g*B,w=l>m?l:m;U<w?B>b?(g=m/B,h+=(a.height-g)/2):(m=g*B,u+=(a.width-m)/2):(l>m?(o+=(l-m)/2,l=m):(u+=(m-l)/2,m=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,m,g),this.ctx.restore()}}async renderNodeContent(e){this.effectsRenderer.applyEffects(e.getEffects(4));const t=e.container,n=e.curves,i=t.styles,s=zs(t);for(const a of t.textNodes)await this.textRenderer.renderTextNode(a,i,s);if(t instanceof S1)try{const a=await this.context.cache.match(t.src),A=this.ctx.imageSmoothingEnabled;i.imageRendering===Jt.PIXELATED||i.imageRendering===Jt.CRISP_EDGES?(this.context.logger.debug(`Disabling image smoothing for ${t.src} due to CSS image-rendering: ${i.imageRendering===Jt.PIXELATED?"pixelated":"crisp-edges"}`),this.ctx.imageSmoothingEnabled=!1):i.imageRendering===Jt.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 T1&&this.renderReplacedElement(t,n,t.canvas),t instanceof k1)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 F1&&t.tree){const A=await new gu(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 Ks){const a=Math.min(t.bounds.width,t.bounds.height);t.type===jA?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=_e(sf),this.ctx.fill(),this.ctx.restore()):t.type===YA&&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=_e(sf),this.ctx.fill(),this.ctx.restore())}if(mk(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 Ks&&t.isPlaceholder;this.ctx.fillStyle=_e(l?wT:i.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=vk(t.styles.textAlign);const d=zs(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 Ks){const g=de(i.fontSize,0);h=(d.height-g)/2}const m=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 fi(t.value,m),i.letterSpacing,c,i.writingMode),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(ze(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=_e(i.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right";const A=new St(t.bounds.left,t.bounds.top+de(t.styles.paddingTop,t.bounds.width),t.bounds.width,Oh(i.lineHeight,i.fontSize.number)/2+1);this.textRenderer.renderTextWithLetterSpacing(new fi(e.listValue,A),i.letterSpacing,Oh(i.lineHeight,i.fontSize.number)/2+2,i.writingMode),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"}}}async renderStackContent(e){ze(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=Nt(t)?t.start:t;n===0?this.ctx.moveTo(i.x,i.y):this.ctx.lineTo(i.x,i.y),Nt(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=!Pr(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=gk(Qi(t.backgroundClip,0),e.curves);(n||t.boxShadow.length)&&(this.ctx.save(),this.path(s),this.ctx.clip(),Pr(t.backgroundColor)||(this.ctx.fillStyle=_e(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=to(e.curves),c=A.inset?0:pk,l=XT(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=_e(A.color),this.ctx.shadowBlur=A.blur.number,this.ctx.fillStyle=A.inset?_e(A.color):"rgba(0,0,0,1)",this.ctx.fill(),this.ctx.restore()}));let a=0;for(const A of i)A.style!==0&&!Pr(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=_e(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));const t=jT(e);return await this.renderStack(t),this.effectsRenderer.applyEffects([]),this.canvas}}const mk=r=>r instanceof U1||r instanceof E1?!0:r instanceof Ks&&r.type!==YA&&r.type!==jA,gk=(r,e)=>{switch(r){case 0:return to(e);case 2:return zT(e);case 1:default:return no(e)}},vk=r=>{switch(r){case 1:return"center";case 2:return"right";case 0:default:return"left"}};class yk extends K1{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=ld(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),n=await wk(t);return this.options.backgroundColor&&(this.ctx.fillStyle=_e(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 wk=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 V1{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))}}V1.instances={};class bk{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(Xc(e)||Tk(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=!$c(e)&&this._options.useCORS===!0&&yt.SUPPORT_CORS_IMAGES&&!i,a=!$c(e)&&!i&&!Xc(e)&&typeof this._options.proxy=="string"&&yt.SUPPORT_CORS_XHR&&!s;if(!i&&this._options.allowTaint===!1&&!$c(e)&&!Xc(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,(kk(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=yt.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 Bk=/^data:image\/svg\+xml/i,Ck=/^data:image\/.*;base64,/i,Sk=/^data:image\/.*/i,Tk=r=>yt.SUPPORT_SVG_DRAWING||!xk(r),$c=r=>Sk.test(r),kk=r=>Ck.test(r),Xc=r=>r.substr(0,4)==="blob",xk=r=>r.substr(-3).toLowerCase()==="svg"||Bk.test(r);class Ek{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 Vo{constructor(e,t,n){this.windowBounds=t,this.instanceName=`#${Vo.instanceCount++}`,this.config=n,this.logger=new V1({id:this.instanceName,enabled:e.logging}),this.originChecker=new Ek(n.window),this.cache=e.cache??n.cache??new bk(this,e)}}Vo.instanceCount=1;class la{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 la({window:i,...t})}clone(e={}){return new la({window:e.window||this.window,cspNonce:e.cspNonce??this.cspNonce,cache:e.cache??this.cache})}}class Uk{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 Fk(r={}){return new Uk({allowDataUrls:!0,maxImageTimeout:3e5,...r})}class Ik{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 z1=(r,e={},t)=>{const n=t||la.fromElement(r,{cspNonce:e.cspNonce,cache:e.cache});return _k(r,e,n)},Qk=r=>{typeof window<"u"&&(new la({window,cspNonce:r}),void 0)};z1.setCspNonce=Qk;const Mk=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)}})},_k=async(r,e,t)=>{if(Mk(e),!e.skipValidation){const ue=e.validator||Fk(),ce=ue.validateElement(r);if(!ce.valid)throw new Error(ce.error);const ne=ue.validateOptions(e);if(!ne.valid)throw new Error(`Invalid options: ${ne.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 St(d.scrollX,d.scrollY,d.windowWidth,d.windowHeight),h=new Vo(a,u,t),m=e.enablePerformanceMonitoring??e.logging??!1,g=new Ik(h,m);g.start("total",{width:d.windowWidth,height:d.windowHeight});const y=e.foreignObjectRendering??!1,b={allowTaint:e.allowTaint??!1,onclone:e.onclone,ignoreElements:e.ignoreElements,iframeContainer:e.iframeContainer,inlineImages:y,copyStyles:y,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 hf(h,r,b),U=B.clonedReferenceElement;if(!U)throw new Error("Unable to find element in cloned iframe");const w=await B.toIFrame(n,u);g.end("clone");const{width:C,height:E,left:I,top:_}=mu(U)||TT(U)?NB(U.ownerDocument):Uo(h,U),P=Rk(h,U,e.backgroundColor),L={canvas:e.canvas,backgroundColor:P,scale:e.scale??i.devicePixelRatio??1,x:(e.x??0)+I,y:(e.y??0)+_,width:e.width??Math.ceil(C),height:e.height??Math.ceil(E),imageSmoothing:e.imageSmoothing,imageSmoothingQuality:e.imageSmoothingQuality};let O,q;try{return y?(h.logger.debug("Document cloned, using foreign object rendering"),g.start("render-foreignobject"),O=await new yk(h,L).render(U),g.end("render-foreignobject")):(h.logger.debug(`Document cloned, element located at ${I},${_} with size ${C}x${E} using computed rendering`),h.logger.debug("Starting DOM parsing"),g.start("parse"),q=Q1(h,U),g.end("parse"),P===q.styles.backgroundColor&&(q.styles.backgroundColor=Nn.TRANSPARENT),h.logger.debug(`Starting renderer for element at ${L.x},${L.y} with size ${L.width}x${L.height}`),g.start("render"),O=await new gu(h,L).render(q),g.end("render")),g.start("cleanup"),(e.removeContainer??!0)&&(hf.destroy(w)||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"),m&&g.logSummary(),O}finally{q&&q.restoreTree()}},Rk=(r,e,t)=>{const n=e.ownerDocument,i=n.documentElement?zi(r,getComputedStyle(n.documentElement).backgroundColor):Nn.TRANSPARENT,s=n.body?zi(r,getComputedStyle(n.body).backgroundColor):Nn.TRANSPARENT,a=typeof t=="string"?zi(r,t):t===null?Nn.TRANSPARENT:4294967295;return e===n.documentElement?Pr(i)?Pr(s)?a:s:i:a},Pk="vnr-clip-overlay";function is(){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 Dk(r){var e;return((e=r.classList)==null?void 0:e.contains(Pk))??!1}function Lk(r){var t;return((t=r.tagName)==null?void 0:t.toLowerCase())==="vanira-convai"?!0:typeof r.closest=="function"&&!!r.closest("vanira-convai")}function G1(r){var e,t;return Dk(r)||Lk(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 Ok(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 q1(r){const e=window.scrollX+r.left,t=window.scrollY+r.top;return z1(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=>G1(n),logging:!1})}async function W1(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 Hk="vanira:clip-region-active";function gd(r){typeof window>"u"||window.dispatchEvent(new CustomEvent(Hk,{detail:{active:r}}))}const wA="vnr-clip-overlay",wf="2147483647",Nk="rgba(0, 0, 0, 0.28)";function Kk(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=ne=>{i||(i=!0,ue(),n(ne))},h=document.createElement("div");h.className=wA,h.style.cssText=["position:fixed","inset:0",`z-index:${wf}`,"cursor:crosshair","user-select:none","touch-action:none","background:transparent","font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"].join(";");const m=document.createElement("div");m.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 y=document.createElement("div");y.className=wA,y.style.cssText=["position:fixed","top:16px","left:50%","transform:translateX(-50%)",`z-index:${wf}`,"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 b=document.createElement("span");b.style.cssText="flex:1;font-size:13px;color:#e2e8f0;line-height:1.4",b.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(";"),y.appendChild(b),y.appendChild(B);const U=ne=>{ne.key==="Escape"&&!s&&u(null)},w=()=>l&&c.width>=e&&c.height>=e,C=()=>{l=!1,c={left:0,top:0,width:0,height:0},E()},E=()=>{if(!l||c.width<1||c.height<1){m.style.display="none",g.style.display="none";return}m.style.display="block",m.style.left=`${c.left}px`,m.style.top=`${c.top}px`,m.style.width=`${c.width}px`,m.style.height=`${c.height}px`,m.style.boxShadow=`0 0 0 9999px ${Nk}`,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`},I=ne=>{const re=ne instanceof Error?ne.message:"Capture failed";b.textContent=re.length>120?`${re.slice(0,117)}…`:re,b.style.color="#fca5a5",window.setTimeout(()=>{b.textContent=t,b.style.color="#e2e8f0"},4500)},_=async ne=>{if(!(s||i)){s=!0,B.disabled=!0,b.textContent="Clipping…",b.style.color="#e2e8f0",h.style.visibility="hidden",y.style.visibility="hidden";try{const re=await q1(ne),he=await W1(re),Se=document.documentElement.clientWidth,Re=document.documentElement.clientHeight;u({blob:he,region:{x:ne.left/Se,y:ne.top/Re,w:ne.width/Se,h:ne.height/Re},viewport:{width:Se,height:Re},pixelSize:{width:re.width,height:re.height}})}catch(re){s=!1,B.disabled=!1,h.style.visibility="visible",y.style.visibility="visible",I(re),C()}}},P=ne=>{const re=ne??d;if(re!==null)try{h.releasePointerCapture(re)}catch{}d=null},L=ne=>{if(!(!o||s)){if(o=!1,P(ne==null?void 0:ne.pointerId),w()){_({...c});return}C()}},O=ne=>{s||ne.target.closest(`.${wA}`)!==y&&(o=!0,l=!0,a=ne.clientX,A=ne.clientY,c={left:a,top:A,width:0,height:0},d=ne.pointerId,h.setPointerCapture(ne.pointerId),E())},q=ne=>{if(!o||s)return;const re=Math.min(a,ne.clientX),he=Math.min(A,ne.clientY),Se=Math.max(a,ne.clientX),Re=Math.max(A,ne.clientY);c={left:re,top:he,width:Se-re,height:Re-he},E()},ue=()=>{gd(!1),document.removeEventListener("keydown",U),window.removeEventListener("pointerup",ce,!0),window.removeEventListener("pointercancel",ce,!0),h.removeEventListener("pointerdown",O),h.removeEventListener("pointermove",q),h.removeEventListener("pointerup",L),h.removeEventListener("pointercancel",L),P(),h.remove(),y.remove()},ce=ne=>L(ne);B.addEventListener("click",()=>u(null)),gd(!0),h.appendChild(m),h.appendChild(g),document.body.appendChild(h),document.body.appendChild(y),document.addEventListener("keydown",U),window.addEventListener("pointerup",ce,!0),window.addEventListener("pointercancel",ce,!0),h.addEventListener("pointerdown",O),h.addEventListener("pointermove",q),h.addEventListener("pointerup",L),h.addEventListener("pointercancel",L)})}function Jc(){document.querySelectorAll(`.${wA}`).forEach(r=>r.remove()),gd(!1)}const Vk=["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(", "),zk='[id]:not([id=""]), svg[id], polygon[id]',Gk="svg[id], polygon[id], svg[data-vanira-static-diagram], svg[data-vanira-static-diagram] polygon",$1=new Set(["root","app","__next"]);function bf(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 qk(r,e,t){if(r instanceof SVGPolygonElement){const n=bf(r,e,t);return n.length>=2?n:void 0}if(r instanceof SVGSVGElement){const n=r.querySelector("polygon");if(!n)return;const i=bf(n,e,t);return i.length>=2?i:void 0}}function Bf(r){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/([^\w-])/g,"\\$1")}function Wk(r){if(r.id){const i=`#${Bf(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=>`.${Bf(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 X1(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 $k(r,e,t){var A;const n=((A=r.id)==null?void 0:A.toLowerCase())??"";if($1.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 J1(r){return G1(r)?!0:typeof r.closest!="function"?!1:!!r.closest("script, style, noscript, template, head")}function Xk(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 Jk(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 jk(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 Yk(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 Cf(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&&$1.has(r.id.toLowerCase())&&(e-=50),e}function ro(r,e,t,n,i){if(J1(r)||$k(r,n,i)||!X1(r,n,i))return;const s=Jk(r),a=jk(r),A=qk(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=Wk(r);if(t.has(l))return;t.add(l);const d=Yk(r.getBoundingClientRect(),n,i);e.push({tag:r.tagName.toLowerCase(),kind:Xk(r,c??""),role:c,label:s||a||o||l,value:a,id:o,css_selector:l,stroke_points:A,...d})}function Zk(r,e,t,n){for(const i of document.querySelectorAll(Gk))ro(i,r,e,t,n);for(const i of document.querySelectorAll("svg"))if(!(J1(i)||!X1(i,t,n)))for(const s of i.querySelectorAll("polygon"))ro(s,r,e,t,n)}function vu(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=[];Zk(s,i,t,n);for(const A of document.querySelectorAll(Vk))ro(A,s,i,t,n);for(const A of document.querySelectorAll(zk))ro(A,s,i,t,n);s.sort((A,o)=>Cf(o)-Cf(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 Sf(r,e,t){const n=Math.max(1,e),i=Math.max(1,t);return Math.round(r/n*i)}function Tf(r){return r.replace(/\s+/g," ").trim().toLowerCase()}function ex(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 tx(){return!!document.querySelector('[role="dialog"], dialog[open], [aria-modal="true"]')}function nx(r,e){const t=Tf(e),n=Tf(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 zo(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:Sf(s.px.center_x,n,e),screenshot_y:Sf(s.px.center_y,i,t),viewport_x:s.px.center_x,viewport_y:s.px.center_y,in_modal:ex(s.css_selector)}))}function rx(r,e,t,n=45){const i=zo(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 ix(r){const e=Number(r);return!Number.isFinite(e)||e<=0||e===960?0:Math.round(e)}function j1(r,e){const t=e.trim().toLowerCase();return!t||!(r!=null&&r.length)?null:r.find(n=>n.element_id.toLowerCase()===t)??null}function sx(r){const e=r.trim();if(!e)return null;const t=is(),n=vu({maxElements:100}),i=zo(n,t.width,t.height);return j1(i,e)}function yu(r,e){if(!(r!=null&&r.length)||!e.trim())return null;const t=tx();let n=null,i=0;for(const s of r){let a=nx(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 Y1(r){const e=is(),t=vu({maxElements:100}),n=zo(t,e.width,e.height),i=yu(n,r);return i?{element:i,viewportWidth:e.width,viewportHeight:e.height}:null}function kf(r){const e=is(),t=e.width,n=e.height;if(r.label){const o=Y1(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=yu(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 ax(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 Ax(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 ox(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 cx(r,e){const t=is();let n=await q1({left:0,top:0,width:t.width,height:t.height});return r>0&&n.width>r&&(n=Ok(n,r)),{blob:await W1(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 lx(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 Ax(i);const c=await ax(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:ox(d),displaySurface:d,isPrimary:!0},release:s}}catch(c){throw s(),c}}async function dx(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 cx(n,t),release:()=>{}}:lx(r)}const vd="#3380FF",ux=3,Z1=null,ev=1e3,hx=8e3,fx=24;let px=0;function te(r){const e=Number(r);return Number.isFinite(e)?e:null}function mx(r,e=1){const t=r.stroke??vd,n=r.stroke_width??ux,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 be(r,e,t){return wu({x:r,y:e},t.screenshotWidth,t.screenshotHeight,t.viewportWidthCss,t.viewportHeightCss)}function gx(r){const e=r.trim();return!e||e.length>4e3||!/^[MLHVCSQTAZmlhvcsqtaz0-9.,\s+\-eE]+$/.test(e)?null:e}function xf(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=te(t[0]),i=te(t[1]);if(n===null||i===null)return null;e.push([n,i]);continue}if(t&&typeof t=="object"){const n=te(t.x),i=te(t.y);if(n===null||i===null)return null;e.push([n,i]);continue}return null}return e.length>=2?e:null}function yd(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 Ef(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=te(r);return e!==null?Math.round(e):null}function vx(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 tv(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:te(i.stroke_width??i.strokeWidth)??void 0,fill:typeof i.fill=="string"?i.fill:void 0,opacity:te(i.opacity)??void 0};if(s==="line"){const A=te(i.x1),o=te(i.y1),c=te(i.x2),l=te(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=xf(i.points);A&&A.length>=3&&t.push({op:"polygon",points:A,...a})}else if(s==="regular_polygon"){const A=te(i.cx),o=te(i.cy),c=te(i.radius??i.r),l=te(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:te(i.rotation_deg??i.rotationDeg)??0,...a})}else if(s==="circle"){const A=te(i.cx),o=te(i.cy),c=te(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=te(i.cx),o=te(i.cy),c=te(i.rx),l=te(i.ry);A!==null&&o!==null&&c!==null&&l!==null&&t.push({op:"ellipse",cx:A,cy:o,rx:c,ry:l,rotation_deg:te(i.rotation_deg??i.rotationDeg)??0,...a})}else if(s==="arrow"){const A=te(i.x1),o=te(i.y1),c=te(i.x2),l=te(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=te(i.x),o=te(i.y),c=te(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=te(i.x),o=te(i.y),c=te(i.width??i.w),l=te(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:te(i.rx)??void 0,fill:typeof i.fill=="string"?i.fill:"rgba(59,130,246,0.14)",...a})}else if(s==="label"){const A=te(i.x),o=te(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:te(i.font_size??i.fontSize)??void 0,...a})}else if(s==="parabola"){const A=te(i.h),o=te(i.k),c=te(i.a),l=te(i.x_min??i.xMin),d=te(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:te(i.samples)??void 0,...a})}else if(s==="hyperbola"){const A=te(i.cx),o=te(i.cy),c=te(i.a),l=te(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:te(i.t_min??i.tMin)??-2.5,t_max:te(i.t_max??i.tMax)??2.5,samples:te(i.samples)??void 0,...a})}else if(s==="bezier"){const A=xf(i.points);A&&A.length>=3&&t.push({op:"bezier",points:A,closed:i.closed===!0,...a})}else if(s==="path"){const A=gx(String(i.d??""));A&&t.push({op:"path",d:A,...a})}else if(s==="vertex_labels"){const A=te(i.cx),o=te(i.cy),c=te(i.radius??i.r),l=te(i.sides);if(A!==null&&o!==null&&c!==null&&l!==null&&l>=3){const d=Math.min(64,Math.round(l)),u=te(i.rotation_deg??i.rotationDeg)??0,h=te(i.label_offset??i.offset)??28,m=yd(A,o,c,d,u),g=vx(i.labels,d);for(let y=0;y<d;y++){const[b,B]=m[y],U=b-A,w=B-o,C=Math.hypot(U,w)||1;t.push({op:"label",x:b+U/C*h,y:B+w/C*h,text:g[y].slice(0,12),font_size:te(i.font_size??i.fontSize)??void 0,...a})}}}else if(s==="vertex_line"){const A=te(i.cx),o=te(i.cy),c=te(i.radius??i.r),l=te(i.sides);let d=Ef(i.from_vertex??i.fromVertex??i.from_label??i.fromLabel),u=Ef(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)),m=te(i.rotation_deg??i.rotationDeg)??0,g=yd(A,o,c,h,m),y=g[(d%h+h)%h],b=g[(u%h+h)%h];y&&b&&t.push({op:"line",x1:y[0],y1:y[1],x2:b[0],y2:b[1],...a})}}}return t.slice(0,fx)}function da(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 yx(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(be(s,a,e))}return da(n)}function wx(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(be(r.cx+r.a*c,r.cy+r.b*l,e)),a.push(be(r.cx-r.a*c,r.cy+r.b*l,e))}return`${da(s)} ${da(a)}`}function nv(r){return yd(r.cx,r.cy,r.radius,r.sides,r.rotation_deg??0)}function bx(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 Bx(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Cx(r){return 1-(1-r)**3}function Sx(r,e){if(r.op==="line"||r.op==="arrow"){const t=be(r.x1,r.y1,e),n=be(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=be(r.x,r.y,e),n=be(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=be(r.x,r.y,e),n=be(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=be(r.cx,r.cy,e),n=be(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=be(r.cx,r.cy,e),n=be(r.cx+r.rx,r.cy,e),i=be(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])=>be(i,s,e)):nv(r).map(([i,s])=>be(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=be(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=be(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])=>be(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 Tx(r,e,t){const n=Cx(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 kx(r,e,t=1){const n=`${mx(r,t)} stroke-linecap="round" stroke-linejoin="round"`;if(r.op==="line"){const i=be(r.x1,r.y1,e),s=be(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=be(r.x1,r.y1,e),s=be(r.x2,r.y2,e);return[`<line x1="${i.x}" y1="${i.y}" x2="${s.x}" y2="${s.y}" ${n}/>`,bx(i.x,i.y,s.x,s.y,n)].join("")}if(r.op==="underline"){const i=be(r.x,r.y,e),s=be(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=be(r.x,r.y,e),s=be(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??vd;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=be(r.cx,r.cy,e),s=be(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=be(r.cx,r.cy,e),s=be(r.cx+r.rx,r.cy,e),a=be(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])=>be(s,a,e));return`<path d="${da(i,!0)}" ${n}/>`}if(r.op==="regular_polygon"){const i=nv(r).map(([s,a])=>be(s,a,e));return`<path d="${da(i,!0)}" ${n}/>`}if(r.op==="parabola")return`<path d="${yx(r,e)}" ${n} fill="none"/>`;if(r.op==="hyperbola")return`<path d="${wx(r,e)}" ${n} fill="none"/>`;if(r.op==="bezier"){const i=r.points.map(([a,A])=>be(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=be(r.x,r.y,e),s=r.font_size??11,a=r.stroke??vd,A=Bx(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 xx(r,e,t){const n=(t==null?void 0:t.born)??performance.now(),i=(t==null?void 0:t.ttlMs)!==void 0?t.ttlMs:Z1,s=Math.max(200,Math.min(hx,(t==null?void 0:t.animateMs)??ev)),a=[];return r.forEach((A,o)=>{const c=kx(A,e);c&&a.push({id:`draw-${++px}`,svg:c,born:n+o*s,ttl:i,animateMs:s,pathLength:Sx(A,e),isLabel:A.op==="label"})}),a}const Ex=`
|
|
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.`,Ux=/\[POINT:(?:none|(\d+)\s*,\s*(\d+)(?::([^\]:\s][^\]:]*?))?(?::screen(\d+))?)\]\s*$/;function Fx(r){var c;const e=r.match(Ux);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 wu(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 Ix(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.
|
|
74
|
+
|
|
75
|
+
${n}`:"";return`${i}
|
|
76
|
+
|
|
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)."}
|
|
80
|
+
|
|
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.
|
|
86
88
|
|
|
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.
|
|
89
|
+
The blue buddy cursor flies to the coordinate visually — it does not click.
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
|
|
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.
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
font-size: 28px;
|
|
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=`
|
|
96
|
+
${Ex}`}function Qx(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 Mx(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=sx(t);return o||j1(r.staleLayoutElements,t)}const n=(A=r.label)==null?void 0:A.trim();if(n){const o=Y1(n);return o?o.element:yu(r.staleLayoutElements,n)}return null}function _x(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=is(),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 Uf(r){const e=Mx(r);if(!(e!=null&&e.css_selector))return null;const t=Number.isFinite(r.padding)?Math.max(0,r.padding):8,n=_x(e.css_selector,t);if(!n)return null;const i=is(),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=Qx({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 tt=8,io=new Set(["line","arrow"]);function Rx(r,e){return r.x<e.x+e.w+tt&&r.x+r.w+tt>e.x&&r.y<e.y+e.h+tt&&r.y+r.h+tt>e.y}function dt(r,e,t){return wu({x:r,y:e},t.screenshotWidth,t.screenshotHeight,t.viewportWidthCss,t.viewportHeightCss)}function $r(r,e=tt){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 rv(r,e){if(r.op==="line"||r.op==="arrow")return $r([dt(r.x1,r.y1,e),dt(r.x2,r.y2,e)],12);if(r.op==="underline")return $r([dt(r.x,r.y,e),dt(r.x+r.width,r.y,e)],10);if(r.op==="highlight_box"){const t=dt(r.x,r.y,e),n=dt(r.x+r.width,r.y+r.height,e),i=Math.min(t.x,n.x)-tt,s=Math.min(t.y,n.y)-tt;return{x:i,y:s,w:Math.abs(n.x-t.x)+tt*2,h:Math.abs(n.y-t.y)+tt*2}}if(r.op==="circle"){const t=dt(r.cx,r.cy,e),n=dt(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-tt,y:t.y-i-tt,w:i*2+tt*2,h:i*2+tt*2}}if(r.op==="ellipse"){const t=dt(r.cx,r.cy,e),n=dt(r.cx+r.rx,r.cy,e),i=dt(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-tt,y:t.y-a-tt,w:s*2+tt*2,h:a*2+tt*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(dt(r.cx+r.radius*Math.cos(s),r.cy+r.radius*Math.sin(s),e))}return $r(n)}if(r.op==="polygon")return $r(r.points.map(([t,n])=>dt(t,n,e)));if(r.op==="label"){const t=dt(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-tt,w:i+tt,h:s+tt*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(dt(s,a,e))}return $r(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(dt(r.cx+r.a*Math.cosh(a),r.cy+r.b*Math.sinh(a),e)),t.push(dt(r.cx-r.a*Math.cosh(a),r.cy+r.b*Math.sinh(a),e))}return $r(t)}return r.op==="bezier"?$r(r.points.map(([t,n])=>dt(t,n,e))):null}function Px(r,e){return!(io.has(r)||io.has(e)||r==="label"&&e!=="label"||e==="label"&&r!=="label")}function iv(r,e){const t=[];for(const n of r){if(io.has(n.op))continue;const i=rv(n,e);i&&t.push(i)}return t}function Dx(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=rv(a,e);if(!A||io.has(a.op)){A&&n.push({bounds:A,index:s,op:a.op});continue}for(const o of n)Px(a.op,o.op)&&Rx(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:iv(r,e)}}function Lx(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 Ox{constructor(){D(this,"svg",null);D(this,"items",[]);D(this,"occupiedBounds",[]);D(this,"frameId",null);D(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=tv(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=Dx(n,i,this.occupiedBounds);if(!A.ok){const o=Lx(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=iv(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??ev,s=n.ttlMs!==void 0?n.ttlMs:Z1,a=xx(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=Tx(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 Hx(){const r=window.innerWidth,e=window.innerHeight,t=Math.round(r*.5),n=Math.round(e*.45);Tr().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 Nx(){typeof window>"u"||(window.__vnrDrawDemo=Hx)}const Ff="#3b82f6",If=["right here!","this one!","over here!","look here!"];class Kx{constructor(){D(this,"root",null);D(this,"buddy",null);D(this,"bubble",null);D(this,"spinner",null);D(this,"waveform",null);D(this,"visible",!1);D(this,"voiceState","idle");D(this,"buddyMode","following");D(this,"position",{x:120,y:120});D(this,"followTimer",null);D(this,"animTimer",null);D(this,"returnTimer",null);D(this,"lastCapture",null);D(this,"opacity",0);D(this,"drawLayer",new Ox)}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 ${Ff};
|
|
102
|
+
filter:drop-shadow(0 0 8px ${Ff});
|
|
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=wu({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 m=(n==null?void 0:n.bubbleText)||(n!=null&&n.label?n.label:If[Math.floor(Math.random()*If.length)]);this.showBubble(m),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 Vx(){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 jc=null;function Tr(){return jc||(jc=new Kx,Vx(),Nx()),jc}const zx="vanira:board-active";function Yc(r,e=!1){typeof window>"u"||window.dispatchEvent(new CustomEvent(zx,{detail:{active:r,reduced:e}}))}class $t{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 $t(e.loc.lexer,e.loc.start,t.loc.end):e&&e.loc}}class on{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 on(t,$t.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 Gx=function(e,t){return e.indexOf(t)!==-1},qx=function(e,t){return e===void 0?t:e},Wx=/([A-Z])/g,$x=function(e){return e.replace(Wx,"-$1").toLowerCase()},Xx={"&":"&",">":">","<":"<",'"':""","'":"'"},Jx=/[&><"']/g;function jx(r){return String(r).replace(Jx,e=>Xx[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},Yx=function(e){var t=sv(e);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},Zx=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},e7=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"},ae={contains:Gx,deflt:qx,escape:jx,hyphenate:$x,getBaseElem:sv,isCharacterBox:Yx,protocolFromUrl:e7},bA={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 t7(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 bu{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 bA)if(bA.hasOwnProperty(t)){var n=bA[t];this[t]=e[t]!==void 0?n.processor?n.processor(e[t]):e[t]:t7(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=ae.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 br{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 Pn[n7[this.id]]}sub(){return Pn[r7[this.id]]}fracNum(){return Pn[i7[this.id]]}fracDen(){return Pn[s7[this.id]]}cramp(){return Pn[a7[this.id]]}text(){return Pn[A7[this.id]]}isTight(){return this.size>=2}}var Bu=0,so=1,Wi=2,lr=3,ua=4,An=5,ts=6,It=7,Pn=[new br(Bu,0,!1),new br(so,0,!0),new br(Wi,1,!1),new br(lr,1,!0),new br(ua,2,!1),new br(An,2,!0),new br(ts,3,!1),new br(It,3,!0)],n7=[ua,An,ua,An,ts,It,ts,It],r7=[An,An,An,An,It,It,It,It],i7=[Wi,lr,ua,An,ts,It,ts,It],s7=[lr,lr,An,An,It,It,It,It],a7=[so,so,lr,lr,An,An,It,It],A7=[Bu,so,Wi,lr,Wi,lr,Wi,lr],oe={DISPLAY:Pn[Bu],TEXT:Pn[Wi],SCRIPT:Pn[ua],SCRIPTSCRIPT:Pn[ts]},wd=[{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 o7(r){for(var e=0;e<wd.length;e++)for(var t=wd[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 BA=[];wd.forEach(r=>r.blocks.forEach(e=>BA.push(...e)));function av(r){for(var e=0;e<BA.length;e+=2)if(r>=BA[e]&&r<=BA[e+1])return!0;return!1}var Fi=80,c7=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"},l7=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"},d7=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"},u7=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"},h7=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"},f7=function(e){var t=e/2;return"M400000 "+e+" H0 L"+t+" 0 l65 45 L145 "+(e-80)+" H400000z"},p7=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"},m7=function(e,t,n){t=1e3*t;var i="";switch(e){case"sqrtMain":i=c7(t,Fi);break;case"sqrtSize1":i=l7(t,Fi);break;case"sqrtSize2":i=d7(t,Fi);break;case"sqrtSize3":i=u7(t,Fi);break;case"sqrtSize4":i=h7(t,Fi);break;case"sqrtTall":i=p7(t,Fi,n)}return i},g7=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""}},Qf={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`},v7=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 ma{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 ae.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 On={"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]}},qa={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]},Mf={Å:"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 y7(r,e){On[r]=e}function Cu(r,e,t){if(!On[e])throw new Error("Font metrics not found for font: "+e+".");var n=r.charCodeAt(0),i=On[e][n];if(!i&&r[0]in Mf&&(n=Mf[r[0]].charCodeAt(0),i=On[e][n]),!i&&t==="text"&&av(n)&&(i=On[e][77]),i)return{depth:i[0],height:i[1],italic:i[2],skew:i[3],width:i[4]}}var Zc={};function w7(r){var e;if(r>=5?e=0:r>=3?e=1:e=2,!Zc[e]){var t=Zc[e]={cssEmPerMu:qa.quad[e]/18};for(var n in qa)qa.hasOwnProperty(n)&&(t[n]=qa[n][e])}return Zc[e]}var b7=[[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]],_f=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Rf=function(e,t){return t.size<2?e:b7[e-1][t.size-1]};class sr{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||sr.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=_f[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 sr(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:Rf(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:_f[e-1]})}havingBaseStyle(e){e=e||this.style.text();var t=Rf(sr.BASESIZE,e);return this.size===t&&this.textSize===sr.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!==sr.BASESIZE?["sizing","reset-size"+this.size,"size"+sr.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=w7(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}sr.BASESIZE=6;var bd={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},B7={ex:!0,em:!0,mu:!0},Av=function(e){return typeof e!="string"&&(e=e.unit),e in bd||e in B7||e==="ex"},Ge=function(e,t){var n;if(e.unit in bd)n=bd[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)},X=function(e){return+e.toFixed(4)+"em"},Nr=function(e){return e.filter(t=>t).join(" ")},ov=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)}},cv=function(e){var t=document.createElement(e);t.className=Nr(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},lv=function(e){var t="<"+e;this.classes.length&&(t+=' class="'+ae.escape(Nr(this.classes))+'"');var n="";for(var i in this.style)this.style.hasOwnProperty(i)&&(n+=ae.hyphenate(i)+":"+this.style[i]+";");n&&(t+=' style="'+ae.escape(n)+'"');for(var s in this.attributes)this.attributes.hasOwnProperty(s)&&(t+=" "+s+'="'+ae.escape(this.attributes[s])+'"');t+=">";for(var a=0;a<this.children.length;a++)t+=this.children[a].toMarkup();return t+="</"+e+">",t};class ga{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,ov.call(this,e,n,i),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return ae.contains(this.classes,e)}toNode(){return cv.call(this,"span")}toMarkup(){return lv.call(this,"span")}}class Su{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,ov.call(this,t,i),this.children=n||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return ae.contains(this.classes,e)}toNode(){return cv.call(this,"a")}toMarkup(){return lv.call(this,"a")}}class C7{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 ae.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="'+ae.escape(this.src)+'"'+(' alt="'+ae.escape(this.alt)+'"'),t="";for(var n in this.style)this.style.hasOwnProperty(n)&&(t+=ae.hyphenate(n)+":"+this.style[n]+";");return t&&(e+=' style="'+ae.escape(t)+'"'),e+="'/>",e}}var S7={î:"ı̂",ï:"ı̈",í:"ı́",ì:"ı̀"};class cn{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=o7(this.text.charCodeAt(0));c&&this.classes.push(c+"_fallback"),/[îïíì]/.test(this.text)&&(this.text=S7[this.text])}hasClass(e){return ae.contains(this.classes,e)}toNode(){var e=document.createTextNode(this.text),t=null;this.italic>0&&(t=document.createElement("span"),t.style.marginRight=X(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=Nr(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+=ae.escape(Nr(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+=ae.hyphenate(i)+":"+this.style[i]+";");n&&(e=!0,t+=' style="'+ae.escape(n)+'"');var s=ae.escape(this.text);return e?(t+=">",t+=s,t+="</span>",t):s}}class hr{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+'="'+ae.escape(this.attributes[t])+'"');e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</svg>",e}}class Kr{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",Qf[this.pathName]),t}toMarkup(){return this.alternate?'<path d="'+ae.escape(this.alternate)+'"/>':'<path d="'+ae.escape(Qf[this.pathName])+'"/>'}}class Bd{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+'="'+ae.escape(this.attributes[t])+'"');return e+="/>",e}}function Pf(r){if(r instanceof cn)return r;throw new Error("Expected symbolNode but got "+String(r)+".")}function T7(r){if(r instanceof ga)return r;throw new Error("Expected span<HtmlDomNode> but got "+String(r)+".")}var k7={bin:1,close:1,inner:1,open:1,punct:1,rel:1},x7={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1},Oe={math:{},text:{}};function f(r,e,t,n,i,s){Oe[r][i]={font:e,group:t,replace:n},s&&n&&(Oe[r][n]=Oe[r][i])}var p="math",V="text",v="main",k="ams",He="accent-token",ee="bin",_t="close",ss="inner",Ae="mathord",at="op-token",jt="open",Go="punct",x="rel",gr="spacing",F="textord";f(p,v,x,"≡","\\equiv",!0);f(p,v,x,"≺","\\prec",!0);f(p,v,x,"≻","\\succ",!0);f(p,v,x,"∼","\\sim",!0);f(p,v,x,"⊥","\\perp");f(p,v,x,"⪯","\\preceq",!0);f(p,v,x,"⪰","\\succeq",!0);f(p,v,x,"≃","\\simeq",!0);f(p,v,x,"∣","\\mid",!0);f(p,v,x,"≪","\\ll",!0);f(p,v,x,"≫","\\gg",!0);f(p,v,x,"≍","\\asymp",!0);f(p,v,x,"∥","\\parallel");f(p,v,x,"⋈","\\bowtie",!0);f(p,v,x,"⌣","\\smile",!0);f(p,v,x,"⊑","\\sqsubseteq",!0);f(p,v,x,"⊒","\\sqsupseteq",!0);f(p,v,x,"≐","\\doteq",!0);f(p,v,x,"⌢","\\frown",!0);f(p,v,x,"∋","\\ni",!0);f(p,v,x,"∝","\\propto",!0);f(p,v,x,"⊢","\\vdash",!0);f(p,v,x,"⊣","\\dashv",!0);f(p,v,x,"∋","\\owns");f(p,v,Go,".","\\ldotp");f(p,v,Go,"⋅","\\cdotp");f(p,v,F,"#","\\#");f(V,v,F,"#","\\#");f(p,v,F,"&","\\&");f(V,v,F,"&","\\&");f(p,v,F,"ℵ","\\aleph",!0);f(p,v,F,"∀","\\forall",!0);f(p,v,F,"ℏ","\\hbar",!0);f(p,v,F,"∃","\\exists",!0);f(p,v,F,"∇","\\nabla",!0);f(p,v,F,"♭","\\flat",!0);f(p,v,F,"ℓ","\\ell",!0);f(p,v,F,"♮","\\natural",!0);f(p,v,F,"♣","\\clubsuit",!0);f(p,v,F,"℘","\\wp",!0);f(p,v,F,"♯","\\sharp",!0);f(p,v,F,"♢","\\diamondsuit",!0);f(p,v,F,"ℜ","\\Re",!0);f(p,v,F,"♡","\\heartsuit",!0);f(p,v,F,"ℑ","\\Im",!0);f(p,v,F,"♠","\\spadesuit",!0);f(p,v,F,"§","\\S",!0);f(V,v,F,"§","\\S");f(p,v,F,"¶","\\P",!0);f(V,v,F,"¶","\\P");f(p,v,F,"†","\\dag");f(V,v,F,"†","\\dag");f(V,v,F,"†","\\textdagger");f(p,v,F,"‡","\\ddag");f(V,v,F,"‡","\\ddag");f(V,v,F,"‡","\\textdaggerdbl");f(p,v,_t,"⎱","\\rmoustache",!0);f(p,v,jt,"⎰","\\lmoustache",!0);f(p,v,_t,"⟯","\\rgroup",!0);f(p,v,jt,"⟮","\\lgroup",!0);f(p,v,ee,"∓","\\mp",!0);f(p,v,ee,"⊖","\\ominus",!0);f(p,v,ee,"⊎","\\uplus",!0);f(p,v,ee,"⊓","\\sqcap",!0);f(p,v,ee,"∗","\\ast");f(p,v,ee,"⊔","\\sqcup",!0);f(p,v,ee,"◯","\\bigcirc",!0);f(p,v,ee,"∙","\\bullet",!0);f(p,v,ee,"‡","\\ddagger");f(p,v,ee,"≀","\\wr",!0);f(p,v,ee,"⨿","\\amalg");f(p,v,ee,"&","\\And");f(p,v,x,"⟵","\\longleftarrow",!0);f(p,v,x,"⇐","\\Leftarrow",!0);f(p,v,x,"⟸","\\Longleftarrow",!0);f(p,v,x,"⟶","\\longrightarrow",!0);f(p,v,x,"⇒","\\Rightarrow",!0);f(p,v,x,"⟹","\\Longrightarrow",!0);f(p,v,x,"↔","\\leftrightarrow",!0);f(p,v,x,"⟷","\\longleftrightarrow",!0);f(p,v,x,"⇔","\\Leftrightarrow",!0);f(p,v,x,"⟺","\\Longleftrightarrow",!0);f(p,v,x,"↦","\\mapsto",!0);f(p,v,x,"⟼","\\longmapsto",!0);f(p,v,x,"↗","\\nearrow",!0);f(p,v,x,"↩","\\hookleftarrow",!0);f(p,v,x,"↪","\\hookrightarrow",!0);f(p,v,x,"↘","\\searrow",!0);f(p,v,x,"↼","\\leftharpoonup",!0);f(p,v,x,"⇀","\\rightharpoonup",!0);f(p,v,x,"↙","\\swarrow",!0);f(p,v,x,"↽","\\leftharpoondown",!0);f(p,v,x,"⇁","\\rightharpoondown",!0);f(p,v,x,"↖","\\nwarrow",!0);f(p,v,x,"⇌","\\rightleftharpoons",!0);f(p,k,x,"≮","\\nless",!0);f(p,k,x,"","\\@nleqslant");f(p,k,x,"","\\@nleqq");f(p,k,x,"⪇","\\lneq",!0);f(p,k,x,"≨","\\lneqq",!0);f(p,k,x,"","\\@lvertneqq");f(p,k,x,"⋦","\\lnsim",!0);f(p,k,x,"⪉","\\lnapprox",!0);f(p,k,x,"⊀","\\nprec",!0);f(p,k,x,"⋠","\\npreceq",!0);f(p,k,x,"⋨","\\precnsim",!0);f(p,k,x,"⪹","\\precnapprox",!0);f(p,k,x,"≁","\\nsim",!0);f(p,k,x,"","\\@nshortmid");f(p,k,x,"∤","\\nmid",!0);f(p,k,x,"⊬","\\nvdash",!0);f(p,k,x,"⊭","\\nvDash",!0);f(p,k,x,"⋪","\\ntriangleleft");f(p,k,x,"⋬","\\ntrianglelefteq",!0);f(p,k,x,"⊊","\\subsetneq",!0);f(p,k,x,"","\\@varsubsetneq");f(p,k,x,"⫋","\\subsetneqq",!0);f(p,k,x,"","\\@varsubsetneqq");f(p,k,x,"≯","\\ngtr",!0);f(p,k,x,"","\\@ngeqslant");f(p,k,x,"","\\@ngeqq");f(p,k,x,"⪈","\\gneq",!0);f(p,k,x,"≩","\\gneqq",!0);f(p,k,x,"","\\@gvertneqq");f(p,k,x,"⋧","\\gnsim",!0);f(p,k,x,"⪊","\\gnapprox",!0);f(p,k,x,"⊁","\\nsucc",!0);f(p,k,x,"⋡","\\nsucceq",!0);f(p,k,x,"⋩","\\succnsim",!0);f(p,k,x,"⪺","\\succnapprox",!0);f(p,k,x,"≆","\\ncong",!0);f(p,k,x,"","\\@nshortparallel");f(p,k,x,"∦","\\nparallel",!0);f(p,k,x,"⊯","\\nVDash",!0);f(p,k,x,"⋫","\\ntriangleright");f(p,k,x,"⋭","\\ntrianglerighteq",!0);f(p,k,x,"","\\@nsupseteqq");f(p,k,x,"⊋","\\supsetneq",!0);f(p,k,x,"","\\@varsupsetneq");f(p,k,x,"⫌","\\supsetneqq",!0);f(p,k,x,"","\\@varsupsetneqq");f(p,k,x,"⊮","\\nVdash",!0);f(p,k,x,"⪵","\\precneqq",!0);f(p,k,x,"⪶","\\succneqq",!0);f(p,k,x,"","\\@nsubseteqq");f(p,k,ee,"⊴","\\unlhd");f(p,k,ee,"⊵","\\unrhd");f(p,k,x,"↚","\\nleftarrow",!0);f(p,k,x,"↛","\\nrightarrow",!0);f(p,k,x,"⇍","\\nLeftarrow",!0);f(p,k,x,"⇏","\\nRightarrow",!0);f(p,k,x,"↮","\\nleftrightarrow",!0);f(p,k,x,"⇎","\\nLeftrightarrow",!0);f(p,k,x,"△","\\vartriangle");f(p,k,F,"ℏ","\\hslash");f(p,k,F,"▽","\\triangledown");f(p,k,F,"◊","\\lozenge");f(p,k,F,"Ⓢ","\\circledS");f(p,k,F,"®","\\circledR");f(V,k,F,"®","\\circledR");f(p,k,F,"∡","\\measuredangle",!0);f(p,k,F,"∄","\\nexists");f(p,k,F,"℧","\\mho");f(p,k,F,"Ⅎ","\\Finv",!0);f(p,k,F,"⅁","\\Game",!0);f(p,k,F,"‵","\\backprime");f(p,k,F,"▲","\\blacktriangle");f(p,k,F,"▼","\\blacktriangledown");f(p,k,F,"■","\\blacksquare");f(p,k,F,"⧫","\\blacklozenge");f(p,k,F,"★","\\bigstar");f(p,k,F,"∢","\\sphericalangle",!0);f(p,k,F,"∁","\\complement",!0);f(p,k,F,"ð","\\eth",!0);f(V,v,F,"ð","ð");f(p,k,F,"╱","\\diagup");f(p,k,F,"╲","\\diagdown");f(p,k,F,"□","\\square");f(p,k,F,"□","\\Box");f(p,k,F,"◊","\\Diamond");f(p,k,F,"¥","\\yen",!0);f(V,k,F,"¥","\\yen",!0);f(p,k,F,"✓","\\checkmark",!0);f(V,k,F,"✓","\\checkmark");f(p,k,F,"ℶ","\\beth",!0);f(p,k,F,"ℸ","\\daleth",!0);f(p,k,F,"ℷ","\\gimel",!0);f(p,k,F,"ϝ","\\digamma",!0);f(p,k,F,"ϰ","\\varkappa");f(p,k,jt,"┌","\\@ulcorner",!0);f(p,k,_t,"┐","\\@urcorner",!0);f(p,k,jt,"└","\\@llcorner",!0);f(p,k,_t,"┘","\\@lrcorner",!0);f(p,k,x,"≦","\\leqq",!0);f(p,k,x,"⩽","\\leqslant",!0);f(p,k,x,"⪕","\\eqslantless",!0);f(p,k,x,"≲","\\lesssim",!0);f(p,k,x,"⪅","\\lessapprox",!0);f(p,k,x,"≊","\\approxeq",!0);f(p,k,ee,"⋖","\\lessdot");f(p,k,x,"⋘","\\lll",!0);f(p,k,x,"≶","\\lessgtr",!0);f(p,k,x,"⋚","\\lesseqgtr",!0);f(p,k,x,"⪋","\\lesseqqgtr",!0);f(p,k,x,"≑","\\doteqdot");f(p,k,x,"≓","\\risingdotseq",!0);f(p,k,x,"≒","\\fallingdotseq",!0);f(p,k,x,"∽","\\backsim",!0);f(p,k,x,"⋍","\\backsimeq",!0);f(p,k,x,"⫅","\\subseteqq",!0);f(p,k,x,"⋐","\\Subset",!0);f(p,k,x,"⊏","\\sqsubset",!0);f(p,k,x,"≼","\\preccurlyeq",!0);f(p,k,x,"⋞","\\curlyeqprec",!0);f(p,k,x,"≾","\\precsim",!0);f(p,k,x,"⪷","\\precapprox",!0);f(p,k,x,"⊲","\\vartriangleleft");f(p,k,x,"⊴","\\trianglelefteq");f(p,k,x,"⊨","\\vDash",!0);f(p,k,x,"⊪","\\Vvdash",!0);f(p,k,x,"⌣","\\smallsmile");f(p,k,x,"⌢","\\smallfrown");f(p,k,x,"≏","\\bumpeq",!0);f(p,k,x,"≎","\\Bumpeq",!0);f(p,k,x,"≧","\\geqq",!0);f(p,k,x,"⩾","\\geqslant",!0);f(p,k,x,"⪖","\\eqslantgtr",!0);f(p,k,x,"≳","\\gtrsim",!0);f(p,k,x,"⪆","\\gtrapprox",!0);f(p,k,ee,"⋗","\\gtrdot");f(p,k,x,"⋙","\\ggg",!0);f(p,k,x,"≷","\\gtrless",!0);f(p,k,x,"⋛","\\gtreqless",!0);f(p,k,x,"⪌","\\gtreqqless",!0);f(p,k,x,"≖","\\eqcirc",!0);f(p,k,x,"≗","\\circeq",!0);f(p,k,x,"≜","\\triangleq",!0);f(p,k,x,"∼","\\thicksim");f(p,k,x,"≈","\\thickapprox");f(p,k,x,"⫆","\\supseteqq",!0);f(p,k,x,"⋑","\\Supset",!0);f(p,k,x,"⊐","\\sqsupset",!0);f(p,k,x,"≽","\\succcurlyeq",!0);f(p,k,x,"⋟","\\curlyeqsucc",!0);f(p,k,x,"≿","\\succsim",!0);f(p,k,x,"⪸","\\succapprox",!0);f(p,k,x,"⊳","\\vartriangleright");f(p,k,x,"⊵","\\trianglerighteq");f(p,k,x,"⊩","\\Vdash",!0);f(p,k,x,"∣","\\shortmid");f(p,k,x,"∥","\\shortparallel");f(p,k,x,"≬","\\between",!0);f(p,k,x,"⋔","\\pitchfork",!0);f(p,k,x,"∝","\\varpropto");f(p,k,x,"◀","\\blacktriangleleft");f(p,k,x,"∴","\\therefore",!0);f(p,k,x,"∍","\\backepsilon");f(p,k,x,"▶","\\blacktriangleright");f(p,k,x,"∵","\\because",!0);f(p,k,x,"⋘","\\llless");f(p,k,x,"⋙","\\gggtr");f(p,k,ee,"⊲","\\lhd");f(p,k,ee,"⊳","\\rhd");f(p,k,x,"≂","\\eqsim",!0);f(p,v,x,"⋈","\\Join");f(p,k,x,"≑","\\Doteq",!0);f(p,k,ee,"∔","\\dotplus",!0);f(p,k,ee,"∖","\\smallsetminus");f(p,k,ee,"⋒","\\Cap",!0);f(p,k,ee,"⋓","\\Cup",!0);f(p,k,ee,"⩞","\\doublebarwedge",!0);f(p,k,ee,"⊟","\\boxminus",!0);f(p,k,ee,"⊞","\\boxplus",!0);f(p,k,ee,"⋇","\\divideontimes",!0);f(p,k,ee,"⋉","\\ltimes",!0);f(p,k,ee,"⋊","\\rtimes",!0);f(p,k,ee,"⋋","\\leftthreetimes",!0);f(p,k,ee,"⋌","\\rightthreetimes",!0);f(p,k,ee,"⋏","\\curlywedge",!0);f(p,k,ee,"⋎","\\curlyvee",!0);f(p,k,ee,"⊝","\\circleddash",!0);f(p,k,ee,"⊛","\\circledast",!0);f(p,k,ee,"⋅","\\centerdot");f(p,k,ee,"⊺","\\intercal",!0);f(p,k,ee,"⋒","\\doublecap");f(p,k,ee,"⋓","\\doublecup");f(p,k,ee,"⊠","\\boxtimes",!0);f(p,k,x,"⇢","\\dashrightarrow",!0);f(p,k,x,"⇠","\\dashleftarrow",!0);f(p,k,x,"⇇","\\leftleftarrows",!0);f(p,k,x,"⇆","\\leftrightarrows",!0);f(p,k,x,"⇚","\\Lleftarrow",!0);f(p,k,x,"↞","\\twoheadleftarrow",!0);f(p,k,x,"↢","\\leftarrowtail",!0);f(p,k,x,"↫","\\looparrowleft",!0);f(p,k,x,"⇋","\\leftrightharpoons",!0);f(p,k,x,"↶","\\curvearrowleft",!0);f(p,k,x,"↺","\\circlearrowleft",!0);f(p,k,x,"↰","\\Lsh",!0);f(p,k,x,"⇈","\\upuparrows",!0);f(p,k,x,"↿","\\upharpoonleft",!0);f(p,k,x,"⇃","\\downharpoonleft",!0);f(p,v,x,"⊶","\\origof",!0);f(p,v,x,"⊷","\\imageof",!0);f(p,k,x,"⊸","\\multimap",!0);f(p,k,x,"↭","\\leftrightsquigarrow",!0);f(p,k,x,"⇉","\\rightrightarrows",!0);f(p,k,x,"⇄","\\rightleftarrows",!0);f(p,k,x,"↠","\\twoheadrightarrow",!0);f(p,k,x,"↣","\\rightarrowtail",!0);f(p,k,x,"↬","\\looparrowright",!0);f(p,k,x,"↷","\\curvearrowright",!0);f(p,k,x,"↻","\\circlearrowright",!0);f(p,k,x,"↱","\\Rsh",!0);f(p,k,x,"⇊","\\downdownarrows",!0);f(p,k,x,"↾","\\upharpoonright",!0);f(p,k,x,"⇂","\\downharpoonright",!0);f(p,k,x,"⇝","\\rightsquigarrow",!0);f(p,k,x,"⇝","\\leadsto");f(p,k,x,"⇛","\\Rrightarrow",!0);f(p,k,x,"↾","\\restriction");f(p,v,F,"‘","`");f(p,v,F,"$","\\$");f(V,v,F,"$","\\$");f(V,v,F,"$","\\textdollar");f(p,v,F,"%","\\%");f(V,v,F,"%","\\%");f(p,v,F,"_","\\_");f(V,v,F,"_","\\_");f(V,v,F,"_","\\textunderscore");f(p,v,F,"∠","\\angle",!0);f(p,v,F,"∞","\\infty",!0);f(p,v,F,"′","\\prime");f(p,v,F,"△","\\triangle");f(p,v,F,"Γ","\\Gamma",!0);f(p,v,F,"Δ","\\Delta",!0);f(p,v,F,"Θ","\\Theta",!0);f(p,v,F,"Λ","\\Lambda",!0);f(p,v,F,"Ξ","\\Xi",!0);f(p,v,F,"Π","\\Pi",!0);f(p,v,F,"Σ","\\Sigma",!0);f(p,v,F,"Υ","\\Upsilon",!0);f(p,v,F,"Φ","\\Phi",!0);f(p,v,F,"Ψ","\\Psi",!0);f(p,v,F,"Ω","\\Omega",!0);f(p,v,F,"A","Α");f(p,v,F,"B","Β");f(p,v,F,"E","Ε");f(p,v,F,"Z","Ζ");f(p,v,F,"H","Η");f(p,v,F,"I","Ι");f(p,v,F,"K","Κ");f(p,v,F,"M","Μ");f(p,v,F,"N","Ν");f(p,v,F,"O","Ο");f(p,v,F,"P","Ρ");f(p,v,F,"T","Τ");f(p,v,F,"X","Χ");f(p,v,F,"¬","\\neg",!0);f(p,v,F,"¬","\\lnot");f(p,v,F,"⊤","\\top");f(p,v,F,"⊥","\\bot");f(p,v,F,"∅","\\emptyset");f(p,k,F,"∅","\\varnothing");f(p,v,Ae,"α","\\alpha",!0);f(p,v,Ae,"β","\\beta",!0);f(p,v,Ae,"γ","\\gamma",!0);f(p,v,Ae,"δ","\\delta",!0);f(p,v,Ae,"ϵ","\\epsilon",!0);f(p,v,Ae,"ζ","\\zeta",!0);f(p,v,Ae,"η","\\eta",!0);f(p,v,Ae,"θ","\\theta",!0);f(p,v,Ae,"ι","\\iota",!0);f(p,v,Ae,"κ","\\kappa",!0);f(p,v,Ae,"λ","\\lambda",!0);f(p,v,Ae,"μ","\\mu",!0);f(p,v,Ae,"ν","\\nu",!0);f(p,v,Ae,"ξ","\\xi",!0);f(p,v,Ae,"ο","\\omicron",!0);f(p,v,Ae,"π","\\pi",!0);f(p,v,Ae,"ρ","\\rho",!0);f(p,v,Ae,"σ","\\sigma",!0);f(p,v,Ae,"τ","\\tau",!0);f(p,v,Ae,"υ","\\upsilon",!0);f(p,v,Ae,"ϕ","\\phi",!0);f(p,v,Ae,"χ","\\chi",!0);f(p,v,Ae,"ψ","\\psi",!0);f(p,v,Ae,"ω","\\omega",!0);f(p,v,Ae,"ε","\\varepsilon",!0);f(p,v,Ae,"ϑ","\\vartheta",!0);f(p,v,Ae,"ϖ","\\varpi",!0);f(p,v,Ae,"ϱ","\\varrho",!0);f(p,v,Ae,"ς","\\varsigma",!0);f(p,v,Ae,"φ","\\varphi",!0);f(p,v,ee,"∗","*",!0);f(p,v,ee,"+","+");f(p,v,ee,"−","-",!0);f(p,v,ee,"⋅","\\cdot",!0);f(p,v,ee,"∘","\\circ",!0);f(p,v,ee,"÷","\\div",!0);f(p,v,ee,"±","\\pm",!0);f(p,v,ee,"×","\\times",!0);f(p,v,ee,"∩","\\cap",!0);f(p,v,ee,"∪","\\cup",!0);f(p,v,ee,"∖","\\setminus",!0);f(p,v,ee,"∧","\\land");f(p,v,ee,"∨","\\lor");f(p,v,ee,"∧","\\wedge",!0);f(p,v,ee,"∨","\\vee",!0);f(p,v,F,"√","\\surd");f(p,v,jt,"⟨","\\langle",!0);f(p,v,jt,"∣","\\lvert");f(p,v,jt,"∥","\\lVert");f(p,v,_t,"?","?");f(p,v,_t,"!","!");f(p,v,_t,"⟩","\\rangle",!0);f(p,v,_t,"∣","\\rvert");f(p,v,_t,"∥","\\rVert");f(p,v,x,"=","=");f(p,v,x,":",":");f(p,v,x,"≈","\\approx",!0);f(p,v,x,"≅","\\cong",!0);f(p,v,x,"≥","\\ge");f(p,v,x,"≥","\\geq",!0);f(p,v,x,"←","\\gets");f(p,v,x,">","\\gt",!0);f(p,v,x,"∈","\\in",!0);f(p,v,x,"","\\@not");f(p,v,x,"⊂","\\subset",!0);f(p,v,x,"⊃","\\supset",!0);f(p,v,x,"⊆","\\subseteq",!0);f(p,v,x,"⊇","\\supseteq",!0);f(p,k,x,"⊈","\\nsubseteq",!0);f(p,k,x,"⊉","\\nsupseteq",!0);f(p,v,x,"⊨","\\models");f(p,v,x,"←","\\leftarrow",!0);f(p,v,x,"≤","\\le");f(p,v,x,"≤","\\leq",!0);f(p,v,x,"<","\\lt",!0);f(p,v,x,"→","\\rightarrow",!0);f(p,v,x,"→","\\to");f(p,k,x,"≱","\\ngeq",!0);f(p,k,x,"≰","\\nleq",!0);f(p,v,gr," ","\\ ");f(p,v,gr," ","\\space");f(p,v,gr," ","\\nobreakspace");f(V,v,gr," ","\\ ");f(V,v,gr," "," ");f(V,v,gr," ","\\space");f(V,v,gr," ","\\nobreakspace");f(p,v,gr,null,"\\nobreak");f(p,v,gr,null,"\\allowbreak");f(p,v,Go,",",",");f(p,v,Go,";",";");f(p,k,ee,"⊼","\\barwedge",!0);f(p,k,ee,"⊻","\\veebar",!0);f(p,v,ee,"⊙","\\odot",!0);f(p,v,ee,"⊕","\\oplus",!0);f(p,v,ee,"⊗","\\otimes",!0);f(p,v,F,"∂","\\partial",!0);f(p,v,ee,"⊘","\\oslash",!0);f(p,k,ee,"⊚","\\circledcirc",!0);f(p,k,ee,"⊡","\\boxdot",!0);f(p,v,ee,"△","\\bigtriangleup");f(p,v,ee,"▽","\\bigtriangledown");f(p,v,ee,"†","\\dagger");f(p,v,ee,"⋄","\\diamond");f(p,v,ee,"⋆","\\star");f(p,v,ee,"◃","\\triangleleft");f(p,v,ee,"▹","\\triangleright");f(p,v,jt,"{","\\{");f(V,v,F,"{","\\{");f(V,v,F,"{","\\textbraceleft");f(p,v,_t,"}","\\}");f(V,v,F,"}","\\}");f(V,v,F,"}","\\textbraceright");f(p,v,jt,"{","\\lbrace");f(p,v,_t,"}","\\rbrace");f(p,v,jt,"[","\\lbrack",!0);f(V,v,F,"[","\\lbrack",!0);f(p,v,_t,"]","\\rbrack",!0);f(V,v,F,"]","\\rbrack",!0);f(p,v,jt,"(","\\lparen",!0);f(p,v,_t,")","\\rparen",!0);f(V,v,F,"<","\\textless",!0);f(V,v,F,">","\\textgreater",!0);f(p,v,jt,"⌊","\\lfloor",!0);f(p,v,_t,"⌋","\\rfloor",!0);f(p,v,jt,"⌈","\\lceil",!0);f(p,v,_t,"⌉","\\rceil",!0);f(p,v,F,"\\","\\backslash");f(p,v,F,"∣","|");f(p,v,F,"∣","\\vert");f(V,v,F,"|","\\textbar",!0);f(p,v,F,"∥","\\|");f(p,v,F,"∥","\\Vert");f(V,v,F,"∥","\\textbardbl");f(V,v,F,"~","\\textasciitilde");f(V,v,F,"\\","\\textbackslash");f(V,v,F,"^","\\textasciicircum");f(p,v,x,"↑","\\uparrow",!0);f(p,v,x,"⇑","\\Uparrow",!0);f(p,v,x,"↓","\\downarrow",!0);f(p,v,x,"⇓","\\Downarrow",!0);f(p,v,x,"↕","\\updownarrow",!0);f(p,v,x,"⇕","\\Updownarrow",!0);f(p,v,at,"∐","\\coprod");f(p,v,at,"⋁","\\bigvee");f(p,v,at,"⋀","\\bigwedge");f(p,v,at,"⨄","\\biguplus");f(p,v,at,"⋂","\\bigcap");f(p,v,at,"⋃","\\bigcup");f(p,v,at,"∫","\\int");f(p,v,at,"∫","\\intop");f(p,v,at,"∬","\\iint");f(p,v,at,"∭","\\iiint");f(p,v,at,"∏","\\prod");f(p,v,at,"∑","\\sum");f(p,v,at,"⨂","\\bigotimes");f(p,v,at,"⨁","\\bigoplus");f(p,v,at,"⨀","\\bigodot");f(p,v,at,"∮","\\oint");f(p,v,at,"∯","\\oiint");f(p,v,at,"∰","\\oiiint");f(p,v,at,"⨆","\\bigsqcup");f(p,v,at,"∫","\\smallint");f(V,v,ss,"…","\\textellipsis");f(p,v,ss,"…","\\mathellipsis");f(V,v,ss,"…","\\ldots",!0);f(p,v,ss,"…","\\ldots",!0);f(p,v,ss,"⋯","\\@cdots",!0);f(p,v,ss,"⋱","\\ddots",!0);f(p,v,F,"⋮","\\varvdots");f(p,v,He,"ˊ","\\acute");f(p,v,He,"ˋ","\\grave");f(p,v,He,"¨","\\ddot");f(p,v,He,"~","\\tilde");f(p,v,He,"ˉ","\\bar");f(p,v,He,"˘","\\breve");f(p,v,He,"ˇ","\\check");f(p,v,He,"^","\\hat");f(p,v,He,"⃗","\\vec");f(p,v,He,"˙","\\dot");f(p,v,He,"˚","\\mathring");f(p,v,Ae,"","\\@imath");f(p,v,Ae,"","\\@jmath");f(p,v,F,"ı","ı");f(p,v,F,"ȷ","ȷ");f(V,v,F,"ı","\\i",!0);f(V,v,F,"ȷ","\\j",!0);f(V,v,F,"ß","\\ss",!0);f(V,v,F,"æ","\\ae",!0);f(V,v,F,"œ","\\oe",!0);f(V,v,F,"ø","\\o",!0);f(V,v,F,"Æ","\\AE",!0);f(V,v,F,"Œ","\\OE",!0);f(V,v,F,"Ø","\\O",!0);f(V,v,He,"ˊ","\\'");f(V,v,He,"ˋ","\\`");f(V,v,He,"ˆ","\\^");f(V,v,He,"˜","\\~");f(V,v,He,"ˉ","\\=");f(V,v,He,"˘","\\u");f(V,v,He,"˙","\\.");f(V,v,He,"¸","\\c");f(V,v,He,"˚","\\r");f(V,v,He,"ˇ","\\v");f(V,v,He,"¨",'\\"');f(V,v,He,"˝","\\H");f(V,v,He,"◯","\\textcircled");var dv={"--":!0,"---":!0,"``":!0,"''":!0};f(V,v,F,"–","--",!0);f(V,v,F,"–","\\textendash");f(V,v,F,"—","---",!0);f(V,v,F,"—","\\textemdash");f(V,v,F,"‘","`",!0);f(V,v,F,"‘","\\textquoteleft");f(V,v,F,"’","'",!0);f(V,v,F,"’","\\textquoteright");f(V,v,F,"“","``",!0);f(V,v,F,"“","\\textquotedblleft");f(V,v,F,"”","''",!0);f(V,v,F,"”","\\textquotedblright");f(p,v,F,"°","\\degree",!0);f(V,v,F,"°","\\degree");f(V,v,F,"°","\\textdegree",!0);f(p,v,F,"£","\\pounds");f(p,v,F,"£","\\mathsterling",!0);f(V,v,F,"£","\\pounds");f(V,v,F,"£","\\textsterling",!0);f(p,k,F,"✠","\\maltese");f(V,k,F,"✠","\\maltese");var Df='0123456789/@."';for(var el=0;el<Df.length;el++){var Lf=Df.charAt(el);f(p,v,F,Lf,Lf)}var Of='0123456789!@*()-=+";:?/.,';for(var tl=0;tl<Of.length;tl++){var Hf=Of.charAt(tl);f(V,v,F,Hf,Hf)}var ao="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(var nl=0;nl<ao.length;nl++){var Wa=ao.charAt(nl);f(p,v,Ae,Wa,Wa),f(V,v,F,Wa,Wa)}f(p,k,F,"C","ℂ");f(V,k,F,"C","ℂ");f(p,k,F,"H","ℍ");f(V,k,F,"H","ℍ");f(p,k,F,"N","ℕ");f(V,k,F,"N","ℕ");f(p,k,F,"P","ℙ");f(V,k,F,"P","ℙ");f(p,k,F,"Q","ℚ");f(V,k,F,"Q","ℚ");f(p,k,F,"R","ℝ");f(V,k,F,"R","ℝ");f(p,k,F,"Z","ℤ");f(V,k,F,"Z","ℤ");f(p,v,Ae,"h","ℎ");f(V,v,Ae,"h","ℎ");var le="";for(var xt=0;xt<ao.length;xt++){var qe=ao.charAt(xt);le=String.fromCharCode(55349,56320+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56372+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56424+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56580+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56684+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56736+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56788+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56840+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56944+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),xt<26&&(le=String.fromCharCode(55349,56632+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le),le=String.fromCharCode(55349,56476+xt),f(p,v,Ae,qe,le),f(V,v,F,qe,le))}le="𝕜";f(p,v,Ae,"k",le);f(V,v,F,"k",le);for(var Xr=0;Xr<10;Xr++){var Br=Xr.toString();le=String.fromCharCode(55349,57294+Xr),f(p,v,Ae,Br,le),f(V,v,F,Br,le),le=String.fromCharCode(55349,57314+Xr),f(p,v,Ae,Br,le),f(V,v,F,Br,le),le=String.fromCharCode(55349,57324+Xr),f(p,v,Ae,Br,le),f(V,v,F,Br,le),le=String.fromCharCode(55349,57334+Xr),f(p,v,Ae,Br,le),f(V,v,F,Br,le)}var Cd="ÐÞþ";for(var rl=0;rl<Cd.length;rl++){var $a=Cd.charAt(rl);f(p,v,Ae,$a,$a),f(V,v,F,$a,$a)}var Xa=[["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"]],Nf=[["mathbf","textbf","Main-Bold"],["","",""],["mathsf","textsf","SansSerif-Regular"],["mathboldsf","textboldsf","SansSerif-Bold"],["mathtt","texttt","Typewriter-Regular"]],E7=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[Xa[A][2],Xa[A][a]]}else if(120782<=s&&s<=120831){var o=Math.floor((s-120782)/10);return[Nf[o][2],Nf[o][a]]}else{if(s===120485||s===120486)return[Xa[0][2],Xa[0][a]];if(120486<s&&s<120782)return["",""];throw new W("Unsupported character: "+e)}},qo=function(e,t,n){return Oe[n][e]&&Oe[n][e].replace&&(e=Oe[n][e].replace),{value:e,metrics:Cu(e,t,n)}},gn=function(e,t,n,i,s){var a=qo(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 cn(e,A.height,A.depth,c,A.skew,A.width,s)}else typeof console<"u",o=new cn(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},U7=function(e,t,n,i){return i===void 0&&(i=[]),n.font==="boldsymbol"&&qo(e,"Main-Bold",t).metrics?gn(e,"Main-Bold",t,n,i.concat(["mathbf"])):e==="\\"||Oe[t][e].font==="main"?gn(e,"Main-Regular",t,n,i):gn(e,"AMS-Regular",t,n,i.concat(["amsrm"]))},F7=function(e,t,n,i,s){return s!=="textord"&&qo(e,"Math-BoldItalic",t).metrics?{fontName:"Math-BoldItalic",fontClass:"boldsymbol"}:{fontName:"Main-Bold",fontClass:"mathbf"}},I7=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]=E7(s,i)),c.length>0)return gn(s,c,i,t,a.concat(l));if(o){var d,u;if(o==="boldsymbol"){var h=F7(s,i,t,a,n);d=h.fontName,u=[h.fontClass]}else A?(d=fv[o].fontName,u=[o]):(d=Ja(o,t.fontWeight,t.fontShape),u=[o,t.fontWeight,t.fontShape]);if(qo(s,d,i).metrics)return gn(s,d,i,t,a.concat(u));if(dv.hasOwnProperty(s)&&d.slice(0,10)==="Typewriter"){for(var m=[],g=0;g<s.length;g++)m.push(gn(s[g],d,i,t,a.concat(u)));return hv(m)}}if(n==="mathord")return gn(s,"Math-Italic",i,t,a.concat(["mathnormal"]));if(n==="textord"){var y=Oe[i][s]&&Oe[i][s].font;if(y==="ams"){var b=Ja("amsrm",t.fontWeight,t.fontShape);return gn(s,b,i,t,a.concat("amsrm",t.fontWeight,t.fontShape))}else if(y==="main"||!y){var B=Ja("textrm",t.fontWeight,t.fontShape);return gn(s,B,i,t,a.concat(t.fontWeight,t.fontShape))}else{var U=Ja(y,t.fontWeight,t.fontShape);return gn(s,U,i,t,a.concat(U,t.fontWeight,t.fontShape))}}else throw new Error("unexpected type: "+n+" in makeOrd")},Q7=(r,e)=>{if(Nr(r.classes)!==Nr(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},M7=r=>{for(var e=0;e<r.length-1;e++){var t=r[e],n=r[e+1];t instanceof cn&&n instanceof cn&&Q7(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},Tu=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},Pt=function(e,t,n,i){var s=new ga(e,t,n,i);return Tu(s),s},uv=(r,e,t,n)=>new ga(r,e,t,n),_7=function(e,t,n){var i=Pt([e],[],t);return i.height=Math.max(n||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),i.style.borderBottomWidth=X(i.height),i.maxFontSize=1,i},R7=function(e,t,n,i){var s=new Su(e,t,n,i);return Tu(s),s},hv=function(e){var t=new ma(e);return Tu(t),t},P7=function(e,t){return e instanceof ma?Pt([],[e],t):e},D7=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}},L7=function(e,t){for(var{children:n,depth:i}=D7(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=Pt(["pstrut"],[]);c.style.height=X(s);for(var l=[],d=i,u=i,h=i,m=0;m<n.length;m++){var g=n[m];if(g.type==="kern")h+=g.size;else{var y=g.elem,b=g.wrapperClasses||[],B=g.wrapperStyle||{},U=Pt(b,[c,y],void 0,B);U.style.top=X(-s-h-y.depth),g.marginLeft&&(U.style.marginLeft=g.marginLeft),g.marginRight&&(U.style.marginRight=g.marginRight),l.push(U),h+=y.height+y.depth}d=Math.min(d,h),u=Math.max(u,h)}var w=Pt(["vlist"],l);w.style.height=X(u);var C;if(d<0){var E=Pt([],[]),I=Pt(["vlist"],[E]);I.style.height=X(-d);var _=Pt(["vlist-s"],[new cn("")]);C=[Pt(["vlist-r"],[w,_]),Pt(["vlist-r"],[I])]}else C=[Pt(["vlist-r"],[w])];var P=Pt(["vlist-t"],C);return C.length===2&&P.classes.push("vlist-t2"),P.height=u,P.depth=-d,P},O7=(r,e)=>{var t=Pt(["mspace"],[],e),n=Ge(r,e);return t.style.marginRight=X(n),t},Ja=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},fv={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"}},pv={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},H7=function(e,t){var[n,i,s]=pv[e],a=new Kr(n),A=new hr([a],{width:X(i),height:X(s),style:"width:"+X(i),viewBox:"0 0 "+1e3*i+" "+1e3*s,preserveAspectRatio:"xMinYMin"}),o=uv(["overlay"],[A],t);return o.height=s,o.style.height=X(s),o.style.width=X(i),o},M={fontMap:fv,makeSymbol:gn,mathsym:U7,makeSpan:Pt,makeSvgSpan:uv,makeLineSpan:_7,makeAnchor:R7,makeFragment:hv,wrapFragment:P7,makeVList:L7,makeOrd:I7,makeGlue:O7,staticSvg:H7,svgData:pv,tryCombineChars:M7},Ne={number:3,unit:"mu"},Jr={number:4,unit:"mu"},Zn={number:5,unit:"mu"},N7={mord:{mop:Ne,mbin:Jr,mrel:Zn,minner:Ne},mop:{mord:Ne,mop:Ne,mrel:Zn,minner:Ne},mbin:{mord:Jr,mop:Jr,mopen:Jr,minner:Jr},mrel:{mord:Zn,mop:Zn,mopen:Zn,minner:Zn},mopen:{},mclose:{mop:Ne,mbin:Jr,mrel:Zn,minner:Ne},mpunct:{mord:Ne,mop:Ne,mrel:Zn,mopen:Ne,mclose:Ne,mpunct:Ne,minner:Ne},minner:{mord:Ne,mop:Ne,mbin:Jr,mrel:Zn,mopen:Ne,mpunct:Ne,minner:Ne}},K7={mord:{mop:Ne},mop:{mord:Ne,mop:Ne},mbin:{},mrel:{},mopen:{},mclose:{mop:Ne},mpunct:{},minner:{mop:Ne}},mv={},Ao={},oo={};function Z(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)mv[t[o]]=A;e&&(s&&(Ao[e]=s),a&&(oo[e]=a))}function bi(r){var{type:e,htmlBuilder:t,mathmlBuilder:n}=r;Z({type:e,names:[],props:{numArgs:0},handler(){throw new Error("Should never be called.")},htmlBuilder:t,mathmlBuilder:n})}var co=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},et=function(e){return e.type==="ordgroup"?e.body:[e]},fr=M.makeSpan,V7=["leftmost","mbin","mopen","mrel","mop","mpunct"],z7=["rightmost","mrel","mclose","mpunct"],G7={display:oe.DISPLAY,text:oe.TEXT,script:oe.SCRIPT,scriptscript:oe.SCRIPTSCRIPT},q7={mord:"mord",mop:"mop",mbin:"mbin",mrel:"mrel",mopen:"mopen",mclose:"mclose",mpunct:"mpunct",minner:"minner"},lt=function(e,t,n,i){i===void 0&&(i=[null,null]);for(var s=[],a=0;a<e.length;a++){var A=Ce(e[a],t);if(A instanceof ma){var o=A.children;s.push(...o)}else s.push(A)}if(M.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(G7[l.style]))}var d=fr([i[0]||"leftmost"],[],t),u=fr([i[1]||"rightmost"],[],t),h=n==="root";return Kf(s,(m,g)=>{var y=g.classes[0],b=m.classes[0];y==="mbin"&&ae.contains(z7,b)?g.classes[0]="mord":b==="mbin"&&ae.contains(V7,y)&&(m.classes[0]="mord")},{node:d},u,h),Kf(s,(m,g)=>{var y=Sd(g),b=Sd(m),B=y&&b?m.hasClass("mtight")?K7[y][b]:N7[y][b]:null;if(B)return M.makeGlue(B,c)},{node:d},u,h),s},Kf=function r(e,t,n,i,s){i&&e.push(i);for(var a=0;a<e.length;a++){var A=e[a],o=gv(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=fr(["leftmost"])),n.insertAfter=(d=>u=>{e.splice(d+1,0,u),a++})(a)}i&&e.pop()},gv=function(e){return e instanceof ma||e instanceof Su||e instanceof ga&&e.hasClass("enclosing")?e:null},W7=function r(e,t){var n=gv(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},Sd=function(e,t){return e?(t&&(e=W7(e,t)),q7[e.classes[0]]||null):null},ha=function(e,t){var n=["nulldelimiter"].concat(e.baseSizingClasses());return fr(t.concat(n))},Ce=function(e,t,n){if(!e)return fr();if(Ao[e.type]){var i=Ao[e.type](e,t);if(n&&t.size!==n.size){i=fr(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 ja(r,e){var t=fr(["base"],r,e),n=fr(["strut"]);return n.style.height=X(t.height+t.depth),t.depth&&(n.style.verticalAlign=X(-t.depth)),t.children.unshift(n),t}function Td(r,e){var t=null;r.length===1&&r[0].type==="tag"&&(t=r[0].tag,r=r[0].body);var n=lt(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(ja(a,e)),a=[])}else n[A].hasClass("newline")&&(a.pop(),a.length>0&&(s.push(ja(a,e)),a=[]),s.push(n[A]));a.length>0&&s.push(ja(a,e));var c;t?(c=ja(lt(t,e,!0)),c.classes=["tag"],s.push(c)):i&&s.push(i);var l=fr(["katex-html"],s);if(l.setAttribute("aria-hidden","true"),c){var d=c.children[0];d.style.height=X(l.height+l.depth),l.depth&&(d.style.verticalAlign=X(-l.depth))}return l}function vv(r){return new ma(r)}class rn{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=Nr(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+=ae.escape(this.attributes[t]),e+='"');this.classes.length>0&&(e+=' class ="'+ae.escape(Nr(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 Gs{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return ae.escape(this.toText())}toText(){return this.text}}class $7{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",X(this.width)),e}toMarkup(){return this.character?"<mtext>"+this.character+"</mtext>":'<mspace width="'+X(this.width)+'"/>'}toText(){return this.character?this.character:" "}}var G={MathNode:rn,TextNode:Gs,SpaceNode:$7,newDocumentFragment:vv},ln=function(e,t,n){return Oe[t][e]&&Oe[t][e].replace&&e.charCodeAt(0)!==55349&&!(dv.hasOwnProperty(e)&&n&&(n.fontFamily&&n.fontFamily.slice(4,6)==="tt"||n.font&&n.font.slice(4,6)==="tt"))&&(e=Oe[t][e].replace),new G.TextNode(e)},ku=function(e){return e.length===1?e[0]:new G.MathNode("mrow",e)},xu=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(ae.contains(["\\imath","\\jmath"],s))return null;Oe[i][s]&&Oe[i][s].replace&&(s=Oe[i][s].replace);var a=M.fontMap[n].fontName;return Cu(s,a,i)?M.fontMap[n].variant:null},Gt=function(e,t,n){if(e.length===1){var i=Me(e[0],t);return n&&i instanceof rn&&i.type==="mo"&&(i.setAttribute("lspace","0em"),i.setAttribute("rspace","0em")),[i]}for(var s=[],a,A=0;A<e.length;A++){var o=Me(e[A],t);if(o instanceof rn&&a instanceof rn){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 Gs&&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 Gs&&l.text==="̸"&&(o.type==="mo"||o.type==="mi"||o.type==="mn")){var d=o.children[0];d instanceof Gs&&d.text.length>0&&(d.text=d.text.slice(0,1)+"̸"+d.text.slice(1),s.pop())}}}s.push(o),a=o}return s},Vr=function(e,t,n){return ku(Gt(e,t,n))},Me=function(e,t){if(!e)return new G.MathNode("mrow");if(oo[e.type]){var n=oo[e.type](e,t);return n}else throw new W("Got group of unknown type: '"+e.type+"'")};function Vf(r,e,t,n,i){var s=Gt(r,t),a;s.length===1&&s[0]instanceof rn&&ae.contains(["mrow","mtable"],s[0].type)?a=s[0]:a=new G.MathNode("mrow",s);var A=new G.MathNode("annotation",[new G.TextNode(e)]);A.setAttribute("encoding","application/x-tex");var o=new G.MathNode("semantics",[a,A]),c=new G.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 M.makeSpan([l],[c])}var yv=function(e){return new sr({style:e.displayMode?oe.DISPLAY:oe.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},wv=function(e,t){if(t.displayMode){var n=["katex-display"];t.leqno&&n.push("leqno"),t.fleqn&&n.push("fleqn"),e=M.makeSpan(n,[e])}return e},X7=function(e,t,n){var i=yv(n),s;if(n.output==="mathml")return Vf(e,t,i,n.displayMode,!0);if(n.output==="html"){var a=Td(e,i);s=M.makeSpan(["katex"],[a])}else{var A=Vf(e,t,i,n.displayMode,!1),o=Td(e,i);s=M.makeSpan(["katex"],[A,o])}return wv(s,n)},J7=function(e,t,n){var i=yv(n),s=Td(e,i),a=M.makeSpan(["katex"],[s]);return wv(a,n)},j7={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":"="},Y7=function(e){var t=new G.MathNode("mo",[new G.TextNode(j7[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},Z7={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]},e8=function(e){return e.type==="ordgroup"?e.body.length:1},t8=function(e,t){function n(){var A=4e5,o=e.label.slice(1);if(ae.contains(["widehat","widecheck","widetilde","utilde"],o)){var c=e,l=e8(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 m=[1,1,2,2,3,3][l];o==="widehat"||o==="widecheck"?(A=[0,1062,2364,2364,2364][m],d=[0,239,300,360,420][m],h=[0,.24,.3,.3,.36,.42][m],u=o+m):(A=[0,600,1033,2339,2340][m],d=[0,260,286,306,312][m],h=[0,.26,.286,.3,.306,.34][m],u="tilde"+m)}var g=new Kr(u),y=new hr([g],{width:"100%",height:X(h),viewBox:"0 0 "+A+" "+d,preserveAspectRatio:"none"});return{span:M.makeSvgSpan([],[y],t),minWidth:0,height:h}}else{var b=[],B=Z7[o],[U,w,C]=B,E=C/1e3,I=U.length,_,P;if(I===1){var L=B[3];_=["hide-tail"],P=[L]}else if(I===2)_=["halfarrow-left","halfarrow-right"],P=["xMinYMin","xMaxYMin"];else if(I===3)_=["brace-left","brace-center","brace-right"],P=["xMinYMin","xMidYMin","xMaxYMin"];else throw new Error(`Correct katexImagesData or update code here to support
|
|
367
|
+
`+I+" children.");for(var O=0;O<I;O++){var q=new Kr(U[O]),ue=new hr([q],{width:"400em",height:X(E),viewBox:"0 0 "+A+" "+C,preserveAspectRatio:P[O]+" slice"}),ce=M.makeSvgSpan([_[O]],[ue],t);if(I===1)return{span:ce,minWidth:w,height:E};ce.style.height=X(E),b.push(ce)}return{span:M.makeSpan(["stretchy"],b,t),minWidth:w,height:E}}}var{span:i,minWidth:s,height:a}=n();return i.height=a,i.style.height=X(a),s>0&&(i.style.minWidth=X(s)),i},n8=function(e,t,n,i,s){var a,A=e.height+e.depth+n+i;if(/fbox|color|angl/.test(t)){if(a=M.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 Bd({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&c.push(new Bd({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var l=new hr(c,{width:"100%",height:X(A)});a=M.makeSvgSpan([],[l],s)}return a.height=A,a.style.height=X(A),a},pr={encloseSpan:n8,mathMLnode:Y7,svgSpan:t8};function ge(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 Eu(r){var e=Wo(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 Wo(r){return r&&(r.type==="atom"||x7.hasOwnProperty(r.type))?r:null}var Uu=(r,e)=>{var t,n,i;r&&r.type==="supsub"?(n=ge(r.base,"accent"),t=n.base,r.base=t,i=T7(Ce(r,e)),r.base=n):(n=ge(r,"accent"),t=n.base);var s=Ce(t,e.havingCrampedStyle()),a=n.isShifty&&ae.isCharacterBox(t),A=0;if(a){var o=ae.getBaseElem(t),c=Ce(o,e.havingCrampedStyle());A=Pf(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=pr.svgSpan(n,e),u=M.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:u,wrapperClasses:["svg-align"],wrapperStyle:A>0?{width:"calc(100% - "+X(2*A)+")",marginLeft:X(2*A)}:void 0}]},e);else{var h,m;n.label==="\\vec"?(h=M.staticSvg("vec",e),m=M.svgData.vec[1]):(h=M.makeOrd({mode:n.mode,text:n.label},e,"textord"),h=Pf(h),h.italic=0,m=h.width,l&&(d+=h.depth)),u=M.makeSpan(["accent-body"],[h]);var g=n.label==="\\textcircled";g&&(u.classes.push("accent-full"),d=s.height);var y=A;g||(y-=m/2),u.style.left=X(y),n.label==="\\textcircled"&&(u.style.top=".2em"),u=M.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-d},{type:"elem",elem:u}]},e)}var b=M.makeSpan(["mord","accent"],[u],e);return i?(i.children[0]=b,i.height=Math.max(b.height,i.height),i.classes[0]="mord",i):b},bv=(r,e)=>{var t=r.isStretchy?pr.mathMLnode(r.label):new G.MathNode("mo",[ln(r.label,r.mode)]),n=new G.MathNode("mover",[Me(r.base,e),t]);return n.setAttribute("accent","true"),n},r8=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(r=>"\\"+r).join("|"));Z({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=co(e[0]),n=!r8.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:Uu,mathmlBuilder:bv});Z({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:Uu,mathmlBuilder:bv});Z({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=Ce(r.base,e),n=pr.svgSpan(r,e),i=r.label==="\\utilde"?.12:0,s=M.makeVList({positionType:"top",positionData:t.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:i},{type:"elem",elem:t}]},e);return M.makeSpan(["mord","accentunder"],[s],e)},mathmlBuilder:(r,e)=>{var t=pr.mathMLnode(r.label),n=new G.MathNode("munder",[Me(r.base,e),t]);return n.setAttribute("accentunder","true"),n}});var Ya=r=>{var e=new G.MathNode("mpadded",r?[r]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};Z({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=M.wrapFragment(Ce(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=M.wrapFragment(Ce(r.below,n,e),e),a.classes.push(s+"-arrow-pad"));var A=pr.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=M.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=M.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"),M.makeSpan(["mrel","x-arrow"],[l],e)},mathmlBuilder(r,e){var t=pr.mathMLnode(r.label);t.setAttribute("minsize",r.label.charAt(0)==="x"?"1.75em":"3.0em");var n;if(r.body){var i=Ya(Me(r.body,e));if(r.below){var s=Ya(Me(r.below,e));n=new G.MathNode("munderover",[t,s,i])}else n=new G.MathNode("mover",[t,i])}else if(r.below){var a=Ya(Me(r.below,e));n=new G.MathNode("munder",[t,a])}else n=Ya(),n=new G.MathNode("mover",[t,n]);return n}});var i8=M.makeSpan;function Bv(r,e){var t=lt(r.body,e,!0);return i8([r.mclass],t,e)}function Cv(r,e){var t,n=Gt(r.body,e);return r.mclass==="minner"?t=new G.MathNode("mpadded",n):r.mclass==="mord"?r.isCharacterBox?(t=n[0],t.type="mi"):t=new G.MathNode("mi",n):(r.isCharacterBox?(t=n[0],t.type="mo"):t=new G.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}Z({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:et(i),isCharacterBox:ae.isCharacterBox(i)}},htmlBuilder:Bv,mathmlBuilder:Cv});var $o=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"};Z({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(r,e){var{parser:t}=r;return{type:"mclass",mode:t.mode,mclass:$o(e[0]),body:et(e[1]),isCharacterBox:ae.isCharacterBox(e[1])}}});Z({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=$o(i):a="mrel";var A={type:"op",mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:n!=="\\stackrel",body:et(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:ae.isCharacterBox(o)}},htmlBuilder:Bv,mathmlBuilder:Cv});Z({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(r,e){var{parser:t}=r;return{type:"pmb",mode:t.mode,mclass:$o(e[0]),body:et(e[0])}},htmlBuilder(r,e){var t=lt(r.body,e,!0),n=M.makeSpan([r.mclass],t,e);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(r,e){var t=Gt(r.body,e),n=new G.MathNode("mstyle",t);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});var s8={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},zf=()=>({type:"styling",body:[],mode:"math",style:"display"}),Gf=r=>r.type==="textord"&&r.text==="@",a8=(r,e)=>(r.type==="mathord"||r.type==="atom")&&r.text===e;function A8(r,e,t){var n=s8[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 o8(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=zf(),o=0;o<a.length;o++)if(!Gf(a[o]))A.body.push(a[o]);else{n.push(A),o+=1;var c=Eu(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(a8(a[h],c)){u=!1,o=h;break}if(Gf(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 m=A8(c,l,r),g={type:"styling",body:[m],mode:"math",style:"display"};n.push(g),A=zf()}s%2===0?n.push(A):n.shift(),n=[],i.push(n)}r.gullet.endGroup(),r.gullet.endGroup();var y=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:y,colSeparationType:"CD",hLinesBeforeRow:new Array(i.length+1).fill([])}}Z({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=M.wrapFragment(Ce(r.label,t,e),e);return n.classes.push("cd-label-"+r.side),n.style.bottom=X(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(r,e){var t=new G.MathNode("mrow",[Me(r.label,e)]);return t=new G.MathNode("mpadded",[t]),t.setAttribute("width","0"),r.side==="left"&&t.setAttribute("lspace","-1width"),t.setAttribute("voffset","0.7em"),t=new G.MathNode("mstyle",[t]),t.setAttribute("displaystyle","false"),t.setAttribute("scriptlevel","1"),t}});Z({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=M.wrapFragment(Ce(r.fragment,e),e);return t.classes.push("cd-vert-arrow"),t},mathmlBuilder(r,e){return new G.MathNode("mrow",[Me(r.fragment,e)])}});Z({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(r,e){for(var{parser:t}=r,n=ge(e[0],"ordgroup"),i=n.body,s="",a=0;a<i.length;a++){var A=ge(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 Sv=(r,e)=>{var t=lt(r.body,e.withColor(r.color),!1);return M.makeFragment(t)},Tv=(r,e)=>{var t=Gt(r.body,e.withColor(r.color)),n=new G.MathNode("mstyle",t);return n.setAttribute("mathcolor",r.color),n};Z({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(r,e){var{parser:t}=r,n=ge(e[0],"color-token").color,i=e[1];return{type:"color",mode:t.mode,color:n,body:et(i)}},htmlBuilder:Sv,mathmlBuilder:Tv});Z({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(r,e){var{parser:t,breakOnTokenText:n}=r,i=ge(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:Sv,mathmlBuilder:Tv});Z({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&&ge(i,"size").value}},htmlBuilder(r,e){var t=M.makeSpan(["mspace"],[],e);return r.newLine&&(t.classes.push("newline"),r.size&&(t.style.marginTop=X(Ge(r.size,e)))),t},mathmlBuilder(r,e){var t=new G.MathNode("mspace");return r.newLine&&(t.setAttribute("linebreak","newline"),r.size&&t.setAttribute("height",X(Ge(r.size,e)))),t}});var kd={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},kv=r=>{var e=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(e))throw new W("Expected a control sequence",r);return e},c8=r=>{var e=r.gullet.popToken();return e.text==="="&&(e=r.gullet.popToken(),e.text===" "&&(e=r.gullet.popToken())),e},xv=(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)};Z({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(kd[n.text])return(t==="\\global"||t==="\\\\globallong")&&(n.text=kd[n.text]),ge(e.parseFunction(),"internal");throw new W("Invalid token after macro prefix",n)}});Z({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===kd[t]),{type:"internal",mode:e.mode}}});Z({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(r){var{parser:e,funcName:t}=r,n=kv(e.gullet.popToken());e.gullet.consumeSpaces();var i=c8(e);return xv(e,n,i,t==="\\\\globallet"),{type:"internal",mode:e.mode}}});Z({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(r){var{parser:e,funcName:t}=r,n=kv(e.gullet.popToken()),i=e.gullet.popToken(),s=e.gullet.popToken();return xv(e,n,s,t==="\\\\globalfuture"),e.gullet.pushToken(s),e.gullet.pushToken(i),{type:"internal",mode:e.mode}}});var Is=function(e,t,n){var i=Oe.math[e]&&Oe.math[e].replace,s=Cu(i||e,t,n);if(!s)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return s},Fu=function(e,t,n,i){var s=n.havingBaseStyle(t),a=M.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},Ev=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=X(s),e.height-=s,e.depth+=s},l8=function(e,t,n,i,s,a){var A=M.makeSymbol(e,"Main-Regular",s,i),o=Fu(A,t,i,a);return n&&Ev(o,i,t),o},d8=function(e,t,n,i){return M.makeSymbol(e,"Size"+t+"-Regular",n,i)},Uv=function(e,t,n,i,s,a){var A=d8(e,t,s,i),o=Fu(M.makeSpan(["delimsizing","size"+t],[A],i),oe.TEXT,i,a);return n&&Ev(o,i,oe.TEXT),o},il=function(e,t,n){var i;t==="Size1-Regular"?i="delim-size1":i="delim-size4";var s=M.makeSpan(["delimsizinginner",i],[M.makeSpan([],[M.makeSymbol(e,t,n)])]);return{type:"elem",elem:s}},sl=function(e,t,n){var i=On["Size4-Regular"][e.charCodeAt(0)]?On["Size4-Regular"][e.charCodeAt(0)][4]:On["Size1-Regular"][e.charCodeAt(0)][4],s=new Kr("inner",g7(e,Math.round(1e3*t))),a=new hr([s],{width:X(i),height:X(t),style:"width:"+X(i),viewBox:"0 0 "+1e3*i+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),A=M.makeSvgSpan([],[a],n);return A.height=t,A.style.height=X(t),A.style.width=X(i),{type:"elem",elem:A}},xd=.008,Za={type:"kern",size:-1*xd},u8=["|","\\lvert","\\rvert","\\vert"],h8=["\\|","\\lVert","\\rVert","\\Vert"],Fv=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"):ae.contains(u8,e)?(c="∣",d="vert",u=333):ae.contains(h8,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 m=Is(A,h,s),g=m.height+m.depth,y=Is(c,h,s),b=y.height+y.depth,B=Is(l,h,s),U=B.height+B.depth,w=0,C=1;if(o!==null){var E=Is(o,h,s);w=E.height+E.depth,C=2}var I=g+U+w,_=Math.max(0,Math.ceil((t-I)/(C*b))),P=I+_*C*b,L=i.fontMetrics().axisHeight;n&&(L*=i.sizeMultiplier);var O=P/2-L,q=[];if(d.length>0){var ue=P-g-U,ce=Math.round(P*1e3),ne=v7(d,Math.round(ue*1e3)),re=new Kr(d,ne),he=(u/1e3).toFixed(3)+"em",Se=(ce/1e3).toFixed(3)+"em",Re=new hr([re],{width:he,height:Se,viewBox:"0 0 "+u+" "+ce}),Je=M.makeSvgSpan([],[Re],i);Je.height=ce/1e3,Je.style.width=he,Je.style.height=Se,q.push({type:"elem",elem:Je})}else{if(q.push(il(l,h,s)),q.push(Za),o===null){var mt=P-g-U+2*xd;q.push(sl(c,mt,i))}else{var At=(P-g-U-w)/2+2*xd;q.push(sl(c,At,i)),q.push(Za),q.push(il(o,h,s)),q.push(Za),q.push(sl(c,At,i))}q.push(Za),q.push(il(A,h,s))}var qt=i.havingBaseStyle(oe.TEXT),Un=M.makeVList({positionType:"bottom",positionData:O,children:q},qt);return Fu(M.makeSpan(["delimsizing","mult"],[Un],qt),oe.TEXT,i,a)},al=80,Al=.08,ol=function(e,t,n,i,s){var a=m7(e,i,n),A=new Kr(e,a),o=new hr([A],{width:"400em",height:X(t),viewBox:"0 0 400000 "+n,preserveAspectRatio:"xMinYMin slice"});return M.makeSvgSpan(["hide-tail"],[o],s)},f8=function(e,t){var n=t.havingBaseSizing(),i=_v("\\surd",e*n.sizeMultiplier,Mv,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+al,e<1?s=1:e<1.4&&(s=.7),o=(1+a+Al)/s,c=(1+a)/s,A=ol("sqrtMain",o,l,a,t),A.style.minWidth="0.853em",d=.833/s):i.type==="large"?(l=(1e3+al)*qs[i.size],c=(qs[i.size]+a)/s,o=(qs[i.size]+a+Al)/s,A=ol("sqrtSize"+i.size,o,l,a,t),A.style.minWidth="1.02em",d=1/s):(o=e+a+Al,c=e+a,l=Math.floor(1e3*e+a)+al,A=ol("sqrtTall",o,l,a,t),A.style.minWidth="0.742em",d=1.056),A.height=c,A.style.height=X(o),{span:A,advanceWidth:d,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*s}},Iv=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","\\surd"],p8=["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱"],Qv=["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],qs=[0,1.2,1.8,2.4,3],m8=function(e,t,n,i,s){if(e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle"),ae.contains(Iv,e)||ae.contains(Qv,e))return Uv(e,t,!1,n,i,s);if(ae.contains(p8,e))return Fv(e,qs[t],!1,n,i,s);throw new W("Illegal delimiter: '"+e+"'")},g8=[{type:"small",style:oe.SCRIPTSCRIPT},{type:"small",style:oe.SCRIPT},{type:"small",style:oe.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],v8=[{type:"small",style:oe.SCRIPTSCRIPT},{type:"small",style:oe.SCRIPT},{type:"small",style:oe.TEXT},{type:"stack"}],Mv=[{type:"small",style:oe.SCRIPTSCRIPT},{type:"small",style:oe.SCRIPT},{type:"small",style:oe.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],y8=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.")},_v=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=Is(e,y8(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]},Rv=function(e,t,n,i,s,a){e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle");var A;ae.contains(Qv,e)?A=g8:ae.contains(Iv,e)?A=Mv:A=v8;var o=_v(e,t,A,i);return o.type==="small"?l8(e,o.style,n,i,s,a):o.type==="large"?Uv(e,o.size,n,i,s,a):Fv(e,t,n,i,s,a)},w8=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 Rv(e,d,!0,i,s,a)},dr={sqrtImage:f8,sizedDelim:m8,sizeToMaxHeight:qs,customSizedDelim:Rv,leftRightDelim:w8},qf={"\\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}},b8=["(","\\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 Xo(r,e){var t=Wo(r);if(t&&ae.contains(b8,t.text))return t;throw t?new W("Invalid delimiter '"+t.text+"' after '"+e.funcName+"'",r):new W("Invalid delimiter type '"+r.type+"'",r)}Z({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=Xo(e[0],r);return{type:"delimsizing",mode:r.parser.mode,size:qf[r.funcName].size,mclass:qf[r.funcName].mclass,delim:t.text}},htmlBuilder:(r,e)=>r.delim==="."?M.makeSpan([r.mclass]):dr.sizedDelim(r.delim,r.size,e,r.mode,[r.mclass]),mathmlBuilder:r=>{var e=[];r.delim!=="."&&e.push(ln(r.delim,r.mode));var t=new G.MathNode("mo",e);r.mclass==="mopen"||r.mclass==="mclose"?t.setAttribute("fence","true"):t.setAttribute("fence","false"),t.setAttribute("stretchy","true");var n=X(dr.sizeToMaxHeight[r.size]);return t.setAttribute("minsize",n),t.setAttribute("maxsize",n),t}});function Wf(r){if(!r.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}Z({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:Xo(e[0],r).text,color:t}}});Z({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(r,e)=>{var t=Xo(e[0],r),n=r.parser;++n.leftrightDepth;var i=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);var s=ge(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:i,left:t.text,right:s.delim,rightColor:s.color}},htmlBuilder:(r,e)=>{Wf(r);for(var t=lt(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=ha(e,["mopen"]):A=dr.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]=dr.leftRightDelim(l.delim,n,i,l.options,r.mode,[]))}var d;if(r.right===".")d=ha(e,["mclose"]);else{var u=r.rightColor?e.withColor(r.rightColor):e;d=dr.leftRightDelim(r.right,n,i,u,r.mode,["mclose"])}return t.push(d),M.makeSpan(["minner"],t,e)},mathmlBuilder:(r,e)=>{Wf(r);var t=Gt(r.body,e);if(r.left!=="."){var n=new G.MathNode("mo",[ln(r.left,r.mode)]);n.setAttribute("fence","true"),t.unshift(n)}if(r.right!=="."){var i=new G.MathNode("mo",[ln(r.right,r.mode)]);i.setAttribute("fence","true"),r.rightColor&&i.setAttribute("mathcolor",r.rightColor),t.push(i)}return ku(t)}});Z({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(r,e)=>{var t=Xo(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=ha(e,[]);else{t=dr.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==="|"?ln("|","text"):ln(r.delim,r.mode),n=new G.MathNode("mo",[t]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});var Iu=(r,e)=>{var t=M.wrapFragment(Ce(r.body,e),e),n=r.label.slice(1),i=e.sizeMultiplier,s,a=0,A=ae.isCharacterBox(r.body);if(n==="sout")s=M.makeSpan(["stretchy","sout"]),s.height=e.fontMetrics().defaultRuleThickness/i,a=-.5*e.fontMetrics().xHeight;else if(n==="phase"){var o=Ge({number:.6,unit:"pt"},e),c=Ge({number:.35,unit:"ex"},e),l=e.havingBaseSizing();i=i/l.sizeMultiplier;var d=t.height+t.depth+o+c;t.style.paddingLeft=X(d/2+o);var u=Math.floor(1e3*d*i),h=f7(u),m=new hr([new Kr("phase",h)],{width:"400em",height:X(u/1e3),viewBox:"0 0 400000 "+u,preserveAspectRatio:"xMinYMin slice"});s=M.makeSvgSpan(["hide-tail"],[m],e),s.style.height=X(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,y=0,b=0;/box/.test(n)?(b=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness),g=e.fontMetrics().fboxsep+(n==="colorbox"?0:b),y=g):n==="angl"?(b=Math.max(e.fontMetrics().defaultRuleThickness,e.minRuleThickness),g=4*b,y=Math.max(0,.25-t.depth)):(g=A?.2:0,y=g),s=pr.encloseSpan(t,n,g,y,e),/fbox|boxed|fcolorbox/.test(n)?(s.style.borderStyle="solid",s.style.borderWidth=X(b)):n==="angl"&&b!==.049&&(s.style.borderTopWidth=X(b),s.style.borderRightWidth=X(b)),a=t.depth+y,r.backgroundColor&&(s.style.backgroundColor=r.backgroundColor,r.borderColor&&(s.style.borderColor=r.borderColor))}var B;if(r.backgroundColor)B=M.makeVList({positionType:"individualShift",children:[{type:"elem",elem:s,shift:a},{type:"elem",elem:t,shift:0}]},e);else{var U=/cancel|phase/.test(n)?["svg-align"]:[];B=M.makeVList({positionType:"individualShift",children:[{type:"elem",elem:t,shift:0},{type:"elem",elem:s,shift:a,wrapperClasses:U}]},e)}return/cancel/.test(n)&&(B.height=t.height,B.depth=t.depth),/cancel/.test(n)&&!A?M.makeSpan(["mord","cancel-lap"],[B],e):M.makeSpan(["mord"],[B],e)},Qu=(r,e)=>{var t=0,n=new G.MathNode(r.label.indexOf("colorbox")>-1?"mpadded":"menclose",[Me(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};Z({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","text"]},handler(r,e,t){var{parser:n,funcName:i}=r,s=ge(e[0],"color-token").color,a=e[1];return{type:"enclose",mode:n.mode,label:i,backgroundColor:s,body:a}},htmlBuilder:Iu,mathmlBuilder:Qu});Z({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","text"]},handler(r,e,t){var{parser:n,funcName:i}=r,s=ge(e[0],"color-token").color,a=ge(e[1],"color-token").color,A=e[2];return{type:"enclose",mode:n.mode,label:i,backgroundColor:a,borderColor:s,body:A}},htmlBuilder:Iu,mathmlBuilder:Qu});Z({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]}}});Z({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:Iu,mathmlBuilder:Qu});Z({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 Pv={};function qn(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)Pv[t[o]]=A;s&&(Ao[e]=s),a&&(oo[e]=a)}var Dv={};function S(r,e){Dv[r]=e}function $f(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 Jo=r=>{var e=r.parser.settings;if(!e.displayMode)throw new W("{"+r.envName+"} can be used only in display mode.")};function Mu(r){if(r.indexOf("ed")===-1)return r.indexOf("*")===-1}function qr(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 m=[],g=[m],y=[],b=[],B=o!=null?[]:void 0;function U(){o&&r.gullet.macros.set("\\@eqnsw","1",!0)}function w(){B&&(r.gullet.macros.get("\\df@tag")?(B.push(r.subparse([new on("\\df@tag")])),r.gullet.macros.set("\\df@tag",void 0,!0)):B.push(!!o&&r.gullet.macros.get("\\@eqnsw")==="1"))}for(U(),b.push($f(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]}),m.push(C);var E=r.fetch().text;if(E==="&"){if(d&&m.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(E==="\\end"){w(),m.length===1&&C.type==="styling"&&C.body[0].body.length===0&&(g.length>1||!l)&&g.pop(),b.length<g.length+1&&b.push([]);break}else if(E==="\\\\"){r.consume();var I=void 0;r.gullet.future().text!==" "&&(I=r.parseSizeGroup(!0)),y.push(I?I.value:null),w(),b.push($f(r)),m=[],g.push(m),U()}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:y,hskipBeforeAndAfter:n,hLinesBeforeRow:b,colSeparationType:A,tags:B,leqno:u}}function _u(r){return r.slice(0,1)==="d"?"display":"text"}var Wn=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(oe.SCRIPT).sizeMultiplier;u=.2778*(h/t.sizeMultiplier)}var m=e.colSeparationType==="CD"?Ge({number:3,unit:"ex"},t):12*d,g=3*d,y=e.arraystretch*m,b=.7*y,B=.3*y,U=0;function w(ya){for(var wa=0;wa<ya.length;++wa)wa>0&&(U+=.25),c.push({pos:U,isDashed:ya[wa]})}for(w(a[0]),n=0;n<e.body.length;++n){var C=e.body[n],E=b,I=B;A<C.length&&(A=C.length);var _=new Array(C.length);for(i=0;i<C.length;++i){var P=Ce(C[i],t);I<P.depth&&(I=P.depth),E<P.height&&(E=P.height),_[i]=P}var L=e.rowGaps[n],O=0;L&&(O=Ge(L,t),O>0&&(O+=B,I<O&&(I=O),O=0)),e.addJot&&(I+=g),_.height=E,_.depth=I,U+=E,_.pos=U,U+=I+O,o[n]=_,w(a[n+1])}var q=U/2+t.fontMetrics().axisHeight,ue=e.cols||[],ce=[],ne,re,he=[];if(e.tags&&e.tags.some(ya=>ya))for(n=0;n<s;++n){var Se=o[n],Re=Se.pos-q,Je=e.tags[n],mt=void 0;Je===!0?mt=M.makeSpan(["eqn-num"],[],t):Je===!1?mt=M.makeSpan([],[],t):mt=M.makeSpan([],lt(Je,t,!0),t),mt.depth=Se.depth,mt.height=Se.height,he.push({type:"elem",elem:mt,shift:Re})}for(i=0,re=0;i<A||re<ue.length;++i,++re){for(var At=ue[re]||{},qt=!0;At.type==="separator";){if(qt||(ne=M.makeSpan(["arraycolsep"],[]),ne.style.width=X(t.fontMetrics().doubleRuleSep),ce.push(ne)),At.separator==="|"||At.separator===":"){var Un=At.separator==="|"?"solid":"dashed",Xn=M.makeSpan(["vertical-separator"],[],t);Xn.style.height=X(U),Xn.style.borderRightWidth=X(l),Xn.style.borderRightStyle=Un,Xn.style.margin="0 "+X(-l/2);var Yt=U-q;Yt&&(Xn.style.verticalAlign=X(-Yt)),ce.push(Xn)}else throw new W("Invalid separator type: "+At.separator);re++,At=ue[re]||{},qt=!1}if(!(i>=A)){var kt=void 0;(i>0||e.hskipBeforeAndAfter)&&(kt=ae.deflt(At.pregap,u),kt!==0&&(ne=M.makeSpan(["arraycolsep"],[]),ne.style.width=X(kt),ce.push(ne)));var un=[];for(n=0;n<s;++n){var ot=o[n],vr=ot[i];if(vr){var Zo=ot.pos-q;vr.depth=ot.depth,vr.height=ot.height,un.push({type:"elem",elem:vr,shift:Zo})}}un=M.makeVList({positionType:"individualShift",children:un},t),un=M.makeSpan(["col-align-"+(At.align||"c")],[un]),ce.push(un),(i<A-1||e.hskipBeforeAndAfter)&&(kt=ae.deflt(At.postgap,u),kt!==0&&(ne=M.makeSpan(["arraycolsep"],[]),ne.style.width=X(kt),ce.push(ne)))}}if(o=M.makeSpan(["mtable"],ce),c.length>0){for(var ec=M.makeLineSpan("hline",t,l),uy=M.makeLineSpan("hdashline",t,l),tc=[{type:"elem",elem:o,shift:0}];c.length>0;){var Nu=c.pop(),Ku=Nu.pos-q;Nu.isDashed?tc.push({type:"elem",elem:uy,shift:Ku}):tc.push({type:"elem",elem:ec,shift:Ku})}o=M.makeVList({positionType:"individualShift",children:tc},t)}if(he.length===0)return M.makeSpan(["mord"],[o],t);var nc=M.makeVList({positionType:"individualShift",children:he},t);return nc=M.makeSpan(["tag"],[nc],t),M.makeFragment([o,nc])},B8={c:"center ",l:"left ",r:"right "},$n=function(e,t){for(var n=[],i=new G.MathNode("mtd",[],["mtr-glue"]),s=new G.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 G.MathNode("mtd",[Me(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 G.MathNode("mtr",o))}var l=new G.MathNode("mtable",n),d=e.arraystretch===.5?.1:.16+e.arraystretch-1+(e.addJot?.09:0);l.setAttribute("rowspacing",X(d));var u="",h="";if(e.cols&&e.cols.length>0){var m=e.cols,g="",y=!1,b=0,B=m.length;m[0].type==="separator"&&(u+="top ",b=1),m[m.length-1].type==="separator"&&(u+="bottom ",B-=1);for(var U=b;U<B;U++)m[U].type==="align"?(h+=B8[m[U].align],y&&(g+="none "),y=!0):m[U].type==="separator"&&y&&(g+=m[U].separator==="|"?"solid ":"dashed ",y=!1);l.setAttribute("columnalign",h.trim()),/[sd]/.test(g)&&l.setAttribute("columnlines",g.trim())}if(e.colSeparationType==="align"){for(var w=e.cols||[],C="",E=1;E<w.length;E++)C+=E%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 I="",_=e.hLinesBeforeRow;u+=_[0].length>0?"left ":"",u+=_[_.length-1].length>0?"right ":"";for(var P=1;P<_.length-1;P++)I+=_[P].length===0?"none ":_[P][0]?"dashed ":"solid ";return/[sd]/.test(I)&&l.setAttribute("rowlines",I.trim()),u!==""&&(l=new G.MathNode("menclose",[l]),l.setAttribute("notation",u.trim())),e.arraystretch&&e.arraystretch<1&&(l=new G.MathNode("mstyle",[l]),l.setAttribute("scriptlevel","1")),l},Lv=function(e,t){e.envName.indexOf("ed")===-1&&Jo(e);var n=[],i=e.envName.indexOf("at")>-1?"alignat":"align",s=e.envName==="split",a=qr(e.parser,{cols:n,addJot:!0,autoTag:s?void 0:Mu(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=ge(t[0].body[d],"textord");l+=u.text}A=Number(l),o=A*2}var h=!o;a.body.forEach(function(b){for(var B=1;B<b.length;B+=2){var U=ge(b[B],"styling"),w=ge(U.body[0],"ordgroup");w.body.unshift(c)}if(h)o<b.length&&(o=b.length);else{var C=b.length/2;if(A<C)throw new W("Too many math in a row: "+("expected "+A+", but got "+C),b[0])}});for(var m=0;m<o;++m){var g="r",y=0;m%2===1?g="l":m>0&&h&&(y=1),n[m]={type:"align",align:g,pregap:y,postgap:0}}return a.colSeparationType=h?"align":"alignat",a};qn({type:"array",names:["array","darray"],props:{numArgs:1},handler(r,e){var t=Wo(e[0]),n=t?[e[0]]:ge(e[0],"ordgroup").body,i=n.map(function(a){var A=Eu(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 qr(r.parser,s,_u(r.envName))},htmlBuilder:Wn,mathmlBuilder:$n});qn({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=qr(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:Wn,mathmlBuilder:$n});qn({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(r){var e={arraystretch:.5},t=qr(r.parser,e,"script");return t.colSeparationType="small",t},htmlBuilder:Wn,mathmlBuilder:$n});qn({type:"array",names:["subarray"],props:{numArgs:1},handler(r,e){var t=Wo(e[0]),n=t?[e[0]]:ge(e[0],"ordgroup").body,i=n.map(function(a){var A=Eu(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=qr(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:Wn,mathmlBuilder:$n});qn({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=qr(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:Wn,mathmlBuilder:$n});qn({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:Lv,htmlBuilder:Wn,mathmlBuilder:$n});qn({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(r){ae.contains(["gather","gather*"],r.envName)&&Jo(r);var e={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:Mu(r.envName),emptySingleRow:!0,leqno:r.parser.settings.leqno};return qr(r.parser,e,"display")},htmlBuilder:Wn,mathmlBuilder:$n});qn({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:Lv,htmlBuilder:Wn,mathmlBuilder:$n});qn({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(r){Jo(r);var e={autoTag:Mu(r.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:r.parser.settings.leqno};return qr(r.parser,e,"display")},htmlBuilder:Wn,mathmlBuilder:$n});qn({type:"array",names:["CD"],props:{numArgs:0},handler(r){return Jo(r),o8(r.parser)},htmlBuilder:Wn,mathmlBuilder:$n});S("\\nonumber","\\gdef\\@eqnsw{0}");S("\\notag","\\nonumber");Z({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 Xf=Pv;Z({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+=ge(i.body[a],"textord").text;if(n==="\\begin"){if(!Xf.hasOwnProperty(s))throw new W("No such environment: "+s,i);var A=Xf[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=ge(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 Ov=(r,e)=>{var t=r.font,n=e.withFont(t);return Ce(r.body,n)},Hv=(r,e)=>{var t=r.font,n=e.withFont(t);return Me(r.body,n)},Jf={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};Z({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=co(e[0]),s=n;return s in Jf&&(s=Jf[s]),{type:"font",mode:t.mode,font:s.slice(1),body:i}},htmlBuilder:Ov,mathmlBuilder:Hv});Z({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(r,e)=>{var{parser:t}=r,n=e[0],i=ae.isCharacterBox(n);return{type:"mclass",mode:t.mode,mclass:$o(n),body:[{type:"font",mode:t.mode,font:"boldsymbol",body:n}],isCharacterBox:i}}});Z({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:Ov,mathmlBuilder:Hv});var Nv=(r,e)=>{var t=e;return r==="display"?t=t.id>=oe.SCRIPT.id?t.text():oe.DISPLAY:r==="text"&&t.size===oe.DISPLAY.size?t=oe.TEXT:r==="script"?t=oe.SCRIPT:r==="scriptscript"&&(t=oe.SCRIPTSCRIPT),t},Ru=(r,e)=>{var t=Nv(r.size,e.style),n=t.fracNum(),i=t.fracDen(),s;s=e.havingStyle(n);var a=Ce(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=Ce(r.denom,s,e),l,d,u;r.hasBarLine?(r.barSize?(d=Ge(r.barSize,e),l=M.makeLineSpan("frac-line",e,d)):l=M.makeLineSpan("frac-line",e),d=l.height,u=l.height):(l=null,d=0,u=e.fontMetrics().defaultRuleThickness);var h,m,g;t.size===oe.DISPLAY.size||r.size==="display"?(h=e.fontMetrics().num1,d>0?m=3*u:m=7*u,g=e.fontMetrics().denom1):(d>0?(h=e.fontMetrics().num2,m=u):(h=e.fontMetrics().num3,m=3*u),g=e.fontMetrics().denom2);var y;if(l){var B=e.fontMetrics().axisHeight;h-a.depth-(B+.5*d)<m&&(h+=m-(h-a.depth-(B+.5*d))),B-.5*d-(c.height-g)<m&&(g+=m-(B-.5*d-(c.height-g)));var U=-(B-.5*d);y=M.makeVList({positionType:"individualShift",children:[{type:"elem",elem:c,shift:g},{type:"elem",elem:l,shift:U},{type:"elem",elem:a,shift:-h}]},e)}else{var b=h-a.depth-(c.height-g);b<m&&(h+=.5*(m-b),g+=.5*(m-b)),y=M.makeVList({positionType:"individualShift",children:[{type:"elem",elem:c,shift:g},{type:"elem",elem:a,shift:-h}]},e)}s=e.havingStyle(t),y.height*=s.sizeMultiplier/e.sizeMultiplier,y.depth*=s.sizeMultiplier/e.sizeMultiplier;var w;t.size===oe.DISPLAY.size?w=e.fontMetrics().delim1:t.size===oe.SCRIPTSCRIPT.size?w=e.havingStyle(oe.SCRIPT).fontMetrics().delim2:w=e.fontMetrics().delim2;var C,E;return r.leftDelim==null?C=ha(e,["mopen"]):C=dr.customSizedDelim(r.leftDelim,w,!0,e.havingStyle(t),r.mode,["mopen"]),r.continued?E=M.makeSpan([]):r.rightDelim==null?E=ha(e,["mclose"]):E=dr.customSizedDelim(r.rightDelim,w,!0,e.havingStyle(t),r.mode,["mclose"]),M.makeSpan(["mord"].concat(s.sizingClasses(e)),[C,M.makeSpan(["mfrac"],[y]),E],e)},Pu=(r,e)=>{var t=new G.MathNode("mfrac",[Me(r.numer,e),Me(r.denom,e)]);if(!r.hasBarLine)t.setAttribute("linethickness","0px");else if(r.barSize){var n=Ge(r.barSize,e);t.setAttribute("linethickness",X(n))}var i=Nv(r.size,e.style);if(i.size!==e.style.size){t=new G.MathNode("mstyle",[t]);var s=i.size===oe.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 G.MathNode("mo",[new G.TextNode(r.leftDelim.replace("\\",""))]);A.setAttribute("fence","true"),a.push(A)}if(a.push(t),r.rightDelim!=null){var o=new G.MathNode("mo",[new G.TextNode(r.rightDelim.replace("\\",""))]);o.setAttribute("fence","true"),a.push(o)}return ku(a)}return t};Z({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:Ru,mathmlBuilder:Pu});Z({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}}});Z({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 jf=["display","text","script","scriptscript"],Yf=function(e){var t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};Z({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=co(e[0]),a=s.type==="atom"&&s.family==="open"?Yf(s.text):null,A=co(e[1]),o=A.type==="atom"&&A.family==="close"?Yf(A.text):null,c=ge(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 m=ge(h.body[0],"textord");u=jf[Number(m.text)]}}else h=ge(h,"textord"),u=jf[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:Ru,mathmlBuilder:Pu});Z({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:ge(e[0],"size").value,token:i}}});Z({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(r,e)=>{var{parser:t,funcName:n}=r,i=e[0],s=Zx(ge(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:Ru,mathmlBuilder:Pu});var Kv=(r,e)=>{var t=e.style,n,i;r.type==="supsub"?(n=r.sup?Ce(r.sup,e.havingStyle(t.sup()),e):Ce(r.sub,e.havingStyle(t.sub()),e),i=ge(r.base,"horizBrace")):i=ge(r,"horizBrace");var s=Ce(i.base,e.havingBaseStyle(oe.DISPLAY)),a=pr.svgSpan(i,e),A;if(i.isOver?(A=M.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=M.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=M.makeSpan(["mord",i.isOver?"mover":"munder"],[A],e);i.isOver?A=M.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:.2},{type:"elem",elem:n}]},e):A=M.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 M.makeSpan(["mord",i.isOver?"mover":"munder"],[A],e)},C8=(r,e)=>{var t=pr.mathMLnode(r.label);return new G.MathNode(r.isOver?"mover":"munder",[Me(r.base,e),t])};Z({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:Kv,mathmlBuilder:C8});Z({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(r,e)=>{var{parser:t}=r,n=e[1],i=ge(e[0],"url").url;return t.settings.isTrusted({command:"\\href",url:i})?{type:"href",mode:t.mode,href:i,body:et(n)}:t.formatUnsupportedCmd("\\href")},htmlBuilder:(r,e)=>{var t=lt(r.body,e,!1);return M.makeAnchor(r.href,[],t,e)},mathmlBuilder:(r,e)=>{var t=Vr(r.body,e);return t instanceof rn||(t=new rn("mrow",[t])),t.setAttribute("href",r.href),t}});Z({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(r,e)=>{var{parser:t}=r,n=ge(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:et(A)}}});Z({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:et(e[0])}},htmlBuilder(r,e){var t=lt(r.body,e,!1);return M.makeFragment(t)},mathmlBuilder(r,e){return new G.MathNode("mrow",Gt(r.body,e))}});Z({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=ge(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:et(a)}:t.formatUnsupportedCmd(n)},htmlBuilder:(r,e)=>{var t=lt(r.body,e,!1),n=["enclosing"];r.attributes.class&&n.push(...r.attributes.class.trim().split(/\s+/));var i=M.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)=>Vr(r.body,e)});Z({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInText:!0},handler:(r,e)=>{var{parser:t}=r;return{type:"htmlmathml",mode:t.mode,html:et(e[0]),mathml:et(e[1])}},htmlBuilder:(r,e)=>{var t=lt(r.html,e,!1);return M.makeFragment(t)},mathmlBuilder:(r,e)=>Vr(r.mathml,e)});var cl=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(!Av(n))throw new W("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n};Z({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=ge(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=cl(u);break;case"height":s=cl(u);break;case"totalheight":a=cl(u);break;default:throw new W("Invalid key: '"+d[0]+"' in \\includegraphics.")}}}var h=ge(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=Ge(r.height,e),n=0;r.totalheight.number>0&&(n=Ge(r.totalheight,e)-t);var i=0;r.width.number>0&&(i=Ge(r.width,e));var s={height:X(t+n)};i>0&&(s.width=X(i)),n>0&&(s.verticalAlign=X(-n));var a=new C7(r.src,r.alt,s);return a.height=t,a.depth=n,a},mathmlBuilder:(r,e)=>{var t=new G.MathNode("mglyph",[]);t.setAttribute("alt",r.alt);var n=Ge(r.height,e),i=0;if(r.totalheight.number>0&&(i=Ge(r.totalheight,e)-n,t.setAttribute("valign",X(-i))),t.setAttribute("height",X(n+i)),r.width.number>0){var s=Ge(r.width,e);t.setAttribute("width",X(s))}return t.setAttribute("src",r.src),t}});Z({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=ge(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 M.makeGlue(r.dimension,e)},mathmlBuilder(r,e){var t=Ge(r.dimension,e);return new G.SpaceNode(t)}});Z({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=M.makeSpan([],[Ce(r.body,e)]),t=M.makeSpan(["inner"],[t],e)):t=M.makeSpan(["inner"],[Ce(r.body,e)]);var n=M.makeSpan(["fix"],[]),i=M.makeSpan([r.alignment],[t,n],e),s=M.makeSpan(["strut"]);return s.style.height=X(i.height+i.depth),i.depth&&(s.style.verticalAlign=X(-i.depth)),i.children.unshift(s),i=M.makeSpan(["thinbox"],[i],e),M.makeSpan(["mord","vbox"],[i],e)},mathmlBuilder:(r,e)=>{var t=new G.MathNode("mpadded",[Me(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}});Z({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}}});Z({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(r,e){throw new W("Mismatched "+r.funcName)}});var Zf=(r,e)=>{switch(e.style.size){case oe.DISPLAY.size:return r.display;case oe.TEXT.size:return r.text;case oe.SCRIPT.size:return r.script;case oe.SCRIPTSCRIPT.size:return r.scriptscript;default:return r.text}};Z({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(r,e)=>{var{parser:t}=r;return{type:"mathchoice",mode:t.mode,display:et(e[0]),text:et(e[1]),script:et(e[2]),scriptscript:et(e[3])}},htmlBuilder:(r,e)=>{var t=Zf(r,e),n=lt(t,e,!1);return M.makeFragment(n)},mathmlBuilder:(r,e)=>{var t=Zf(r,e);return Vr(t,e)}});var Vv=(r,e,t,n,i,s,a)=>{r=M.makeSpan([],[r]);var A=t&&ae.isCharacterBox(t),o,c;if(e){var l=Ce(e,n.havingStyle(i.sup()),n);c={elem:l,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-l.depth)}}if(t){var d=Ce(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=M.makeVList({positionType:"bottom",positionData:h,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:o.elem,marginLeft:X(-s)},{type:"kern",size:o.kern},{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:X(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}else if(o){var m=r.height-a;u=M.makeVList({positionType:"top",positionData:m,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:o.elem,marginLeft:X(-s)},{type:"kern",size:o.kern},{type:"elem",elem:r}]},n)}else if(c){var g=r.depth+a;u=M.makeVList({positionType:"bottom",positionData:g,children:[{type:"elem",elem:r},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:X(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}else return r;var y=[u];if(o&&s!==0&&!A){var b=M.makeSpan(["mspace"],[],n);b.style.marginRight=X(s),y.unshift(b)}return M.makeSpan(["mop","op-limits"],y,n)},zv=["\\smallint"],as=(r,e)=>{var t,n,i=!1,s;r.type==="supsub"?(t=r.sup,n=r.sub,s=ge(r.base,"op"),i=!0):s=ge(r,"op");var a=e.style,A=!1;a.size===oe.DISPLAY.size&&s.symbol&&!ae.contains(zv,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=M.makeSymbol(s.name,c,"math",e,["mop","op-symbol",A?"large-op":"small-op"]),l.length>0){var d=o.italic,u=M.staticSvg(l+"Size"+(A?"2":"1"),e);o=M.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=lt(s.body,e,!0);h.length===1&&h[0]instanceof cn?(o=h[0],o.classes[0]="mop"):o=M.makeSpan(["mop"],h,e)}else{for(var m=[],g=1;g<s.name.length;g++)m.push(M.mathsym(s.name[g],s.mode,e));o=M.makeSpan(["mop"],m,e)}var y=0,b=0;return(o instanceof cn||s.name==="\\oiint"||s.name==="\\oiiint")&&!s.suppressBaseShift&&(y=(o.height-o.depth)/2-e.fontMetrics().axisHeight,b=o.italic),i?Vv(o,t,n,e,a,b,y):(y&&(o.style.position="relative",o.style.top=X(y)),o)},va=(r,e)=>{var t;if(r.symbol)t=new rn("mo",[ln(r.name,r.mode)]),ae.contains(zv,r.name)&&t.setAttribute("largeop","false");else if(r.body)t=new rn("mo",Gt(r.body,e));else{t=new rn("mi",[new Gs(r.name.slice(1))]);var n=new rn("mo",[ln("","text")]);r.parentIsSupSub?t=new rn("mrow",[t,n]):t=vv([t,n])}return t},S8={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨆":"\\bigsqcup"};Z({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=S8[i]),{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:i}},htmlBuilder:as,mathmlBuilder:va});Z({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:et(n)}},htmlBuilder:as,mathmlBuilder:va});var T8={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint"};Z({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:as,mathmlBuilder:va});Z({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:as,mathmlBuilder:va});Z({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=T8[n]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:as,mathmlBuilder:va});var Gv=(r,e)=>{var t,n,i=!1,s;r.type==="supsub"?(t=r.sup,n=r.sub,s=ge(r.base,"operatorname"),i=!0):s=ge(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=lt(A,e.withFont("mathrm"),!0),c=0;c<o.length;c++){var l=o[c];l instanceof cn&&(l.text=l.text.replace(/\u2212/,"-").replace(/\u2217/,"*"))}a=M.makeSpan(["mop"],o,e)}else a=M.makeSpan(["mop"],[],e);return i?Vv(a,t,n,e,e.style,0,0):a},k8=(r,e)=>{for(var t=Gt(r.body,e.withFont("mathrm")),n=!0,i=0;i<t.length;i++){var s=t[i];if(!(s instanceof G.SpaceNode))if(s instanceof G.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 G.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 G.TextNode(A)]}var o=new G.MathNode("mi",t);o.setAttribute("mathvariant","normal");var c=new G.MathNode("mo",[ln("","text")]);return r.parentIsSupSub?new G.MathNode("mrow",[o,c]):G.newDocumentFragment([o,c])};Z({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:et(i),alwaysHandleSupSub:n==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1}},htmlBuilder:Gv,mathmlBuilder:k8});S("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@");bi({type:"ordgroup",htmlBuilder(r,e){return r.semisimple?M.makeFragment(lt(r.body,e,!1)):M.makeSpan(["mord"],lt(r.body,e,!0),e)},mathmlBuilder(r,e){return Vr(r.body,e,!0)}});Z({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=Ce(r.body,e.havingCrampedStyle()),n=M.makeLineSpan("overline-line",e),i=e.fontMetrics().defaultRuleThickness,s=M.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t},{type:"kern",size:3*i},{type:"elem",elem:n},{type:"kern",size:i}]},e);return M.makeSpan(["mord","overline"],[s],e)},mathmlBuilder(r,e){var t=new G.MathNode("mo",[new G.TextNode("‾")]);t.setAttribute("stretchy","true");var n=new G.MathNode("mover",[Me(r.body,e),t]);return n.setAttribute("accent","true"),n}});Z({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:et(n)}},htmlBuilder:(r,e)=>{var t=lt(r.body,e.withPhantom(),!1);return M.makeFragment(t)},mathmlBuilder:(r,e)=>{var t=Gt(r.body,e);return new G.MathNode("mphantom",t)}});Z({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=M.makeSpan([],[Ce(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=M.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t}]},e),M.makeSpan(["mord"],[t],e)},mathmlBuilder:(r,e)=>{var t=Gt(et(r.body),e),n=new G.MathNode("mphantom",t),i=new G.MathNode("mpadded",[n]);return i.setAttribute("height","0px"),i.setAttribute("depth","0px"),i}});Z({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=M.makeSpan(["inner"],[Ce(r.body,e.withPhantom())]),n=M.makeSpan(["fix"],[]);return M.makeSpan(["mord","rlap"],[t,n],e)},mathmlBuilder:(r,e)=>{var t=Gt(et(r.body),e),n=new G.MathNode("mphantom",t),i=new G.MathNode("mpadded",[n]);return i.setAttribute("width","0px"),i}});Z({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(r,e){var{parser:t}=r,n=ge(e[0],"size").value,i=e[1];return{type:"raisebox",mode:t.mode,dy:n,body:i}},htmlBuilder(r,e){var t=Ce(r.body,e),n=Ge(r.dy,e);return M.makeVList({positionType:"shift",positionData:-n,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(r,e){var t=new G.MathNode("mpadded",[Me(r.body,e)]),n=r.dy.number+r.dy.unit;return t.setAttribute("voffset",n),t}});Z({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler(r){var{parser:e}=r;return{type:"internal",mode:e.mode}}});Z({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=ge(e[0],"size"),a=ge(e[1],"size");return{type:"rule",mode:n.mode,shift:i&&ge(i,"size").value,width:s.value,height:a.value}},htmlBuilder(r,e){var t=M.makeSpan(["mord","rule"],[],e),n=Ge(r.width,e),i=Ge(r.height,e),s=r.shift?Ge(r.shift,e):0;return t.style.borderRightWidth=X(n),t.style.borderTopWidth=X(i),t.style.bottom=X(s),t.width=n,t.height=i+s,t.depth=-s,t.maxFontSize=i*1.125*e.sizeMultiplier,t},mathmlBuilder(r,e){var t=Ge(r.width,e),n=Ge(r.height,e),i=r.shift?Ge(r.shift,e):0,s=e.color&&e.getColor()||"black",a=new G.MathNode("mspace");a.setAttribute("mathbackground",s),a.setAttribute("width",X(t)),a.setAttribute("height",X(n));var A=new G.MathNode("mpadded",[a]);return i>=0?A.setAttribute("height",X(i)):(A.setAttribute("height",X(i)),A.setAttribute("depth",X(-i))),A.setAttribute("voffset",X(i)),A}});function qv(r,e,t){for(var n=lt(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 M.makeFragment(n)}var ep=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],x8=(r,e)=>{var t=e.havingSize(r.size);return qv(r.body,t,e)};Z({type:"sizing",names:ep,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:ep.indexOf(n)+1,body:s}},htmlBuilder:x8,mathmlBuilder:(r,e)=>{var t=e.havingSize(r.size),n=Gt(r.body,t),i=new G.MathNode("mstyle",n);return i.setAttribute("mathsize",X(t.sizeMultiplier)),i}});Z({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]&&ge(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=M.makeSpan([],[Ce(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=M.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t}]},e);return M.makeSpan(["mord"],[s],e)},mathmlBuilder:(r,e)=>{var t=new G.MathNode("mpadded",[Me(r.body,e)]);return r.smashHeight&&t.setAttribute("height","0px"),r.smashDepth&&t.setAttribute("depth","0px"),t}});Z({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=Ce(r.body,e.havingCrampedStyle());t.height===0&&(t.height=e.fontMetrics().xHeight),t=M.wrapFragment(t,e);var n=e.fontMetrics(),i=n.defaultRuleThickness,s=i;e.style.id<oe.TEXT.id&&(s=e.fontMetrics().xHeight);var a=i+s/4,A=t.height+t.depth+a+i,{span:o,ruleWidth:c,advanceWidth:l}=dr.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=X(l);var h=M.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 m=e.havingStyle(oe.SCRIPTSCRIPT),g=Ce(r.index,m,e),y=.6*(h.height-h.depth),b=M.makeVList({positionType:"shift",positionData:-y,children:[{type:"elem",elem:g}]},e),B=M.makeSpan(["root"],[b]);return M.makeSpan(["mord","sqrt"],[B,h],e)}else return M.makeSpan(["mord","sqrt"],[h],e)},mathmlBuilder(r,e){var{body:t,index:n}=r;return n?new G.MathNode("mroot",[Me(t,e),Me(n,e)]):new G.MathNode("msqrt",[Me(t,e)])}});var tp={display:oe.DISPLAY,text:oe.TEXT,script:oe.SCRIPT,scriptscript:oe.SCRIPTSCRIPT};Z({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=tp[r.style],n=e.havingStyle(t).withFont("");return qv(r.body,n,e)},mathmlBuilder(r,e){var t=tp[r.style],n=e.havingStyle(t),i=Gt(r.body,n),s=new G.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 E8=function(e,t){var n=e.base;if(n)if(n.type==="op"){var i=n.limits&&(t.style.size===oe.DISPLAY.size||n.alwaysHandleSupSub);return i?as:null}else if(n.type==="operatorname"){var s=n.alwaysHandleSupSub&&(t.style.size===oe.DISPLAY.size||n.limits);return s?Gv:null}else{if(n.type==="accent")return ae.isCharacterBox(n.base)?Uu:null;if(n.type==="horizBrace"){var a=!e.sub;return a===n.isOver?Kv:null}else return null}else return null};bi({type:"supsub",htmlBuilder(r,e){var t=E8(r,e);if(t)return t(r,e);var{base:n,sup:i,sub:s}=r,a=Ce(n,e),A,o,c=e.fontMetrics(),l=0,d=0,u=n&&ae.isCharacterBox(n);if(i){var h=e.havingStyle(e.style.sup());A=Ce(i,h,e),u||(l=a.height-h.fontMetrics().supDrop*h.sizeMultiplier/e.sizeMultiplier)}if(s){var m=e.havingStyle(e.style.sub());o=Ce(s,m,e),u||(d=a.depth+m.fontMetrics().subDrop*m.sizeMultiplier/e.sizeMultiplier)}var g;e.style===oe.DISPLAY?g=c.sup1:e.style.cramped?g=c.sup3:g=c.sup2;var y=e.sizeMultiplier,b=X(.5/c.ptPerEm/y),B=null;if(o){var U=r.base&&r.base.type==="op"&&r.base.name&&(r.base.name==="\\oiint"||r.base.name==="\\oiiint");(a instanceof cn||U)&&(B=X(-a.italic))}var w;if(A&&o){l=Math.max(l,g,A.depth+.25*c.xHeight),d=Math.max(d,c.sub2);var C=c.defaultRuleThickness,E=4*C;if(l-A.depth-(o.height-d)<E){d=E-(l-A.depth)+o.height;var I=.8*c.xHeight-(l-A.depth);I>0&&(l+=I,d-=I)}var _=[{type:"elem",elem:o,shift:d,marginRight:b,marginLeft:B},{type:"elem",elem:A,shift:-l,marginRight:b}];w=M.makeVList({positionType:"individualShift",children:_},e)}else if(o){d=Math.max(d,c.sub1,o.height-.8*c.xHeight);var P=[{type:"elem",elem:o,marginLeft:B,marginRight:b}];w=M.makeVList({positionType:"shift",positionData:d,children:P},e)}else if(A)l=Math.max(l,g,A.depth+.25*c.xHeight),w=M.makeVList({positionType:"shift",positionData:-l,children:[{type:"elem",elem:A,marginRight:b}]},e);else throw new Error("supsub must have either sup or sub.");var L=Sd(a,"right")||"mord";return M.makeSpan([L],[a,M.makeSpan(["msupsub"],[w])],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=[Me(r.base,e)];r.sub&&s.push(Me(r.sub,e)),r.sup&&s.push(Me(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===oe.DISPLAY||c&&c.type==="operatorname"&&c.alwaysHandleSupSub&&(e.style===oe.DISPLAY||c.limits)?a="munderover":a="msubsup"}else{var o=r.base;o&&o.type==="op"&&o.limits&&(e.style===oe.DISPLAY||o.alwaysHandleSupSub)||o&&o.type==="operatorname"&&o.alwaysHandleSupSub&&(o.limits||e.style===oe.DISPLAY)?a="munder":a="msub"}else{var A=r.base;A&&A.type==="op"&&A.limits&&(e.style===oe.DISPLAY||A.alwaysHandleSupSub)||A&&A.type==="operatorname"&&A.alwaysHandleSupSub&&(A.limits||e.style===oe.DISPLAY)?a="mover":a="msup"}return new G.MathNode(a,s)}});bi({type:"atom",htmlBuilder(r,e){return M.mathsym(r.text,r.mode,e,["m"+r.family])},mathmlBuilder(r,e){var t=new G.MathNode("mo",[ln(r.text,r.mode)]);if(r.family==="bin"){var n=xu(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 Wv={mi:"italic",mn:"normal",mtext:"normal"};bi({type:"mathord",htmlBuilder(r,e){return M.makeOrd(r,e,"mathord")},mathmlBuilder(r,e){var t=new G.MathNode("mi",[ln(r.text,r.mode,e)]),n=xu(r,e)||"italic";return n!==Wv[t.type]&&t.setAttribute("mathvariant",n),t}});bi({type:"textord",htmlBuilder(r,e){return M.makeOrd(r,e,"textord")},mathmlBuilder(r,e){var t=ln(r.text,r.mode,e),n=xu(r,e)||"normal",i;return r.mode==="text"?i=new G.MathNode("mtext",[t]):/[0-9]/.test(r.text)?i=new G.MathNode("mn",[t]):r.text==="\\prime"?i=new G.MathNode("mo",[t]):i=new G.MathNode("mi",[t]),n!==Wv[i.type]&&i.setAttribute("mathvariant",n),i}});var ll={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},dl={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};bi({type:"spacing",htmlBuilder(r,e){if(dl.hasOwnProperty(r.text)){var t=dl[r.text].className||"";if(r.mode==="text"){var n=M.makeOrd(r,e,"textord");return n.classes.push(t),n}else return M.makeSpan(["mspace",t],[M.mathsym(r.text,r.mode,e)],e)}else{if(ll.hasOwnProperty(r.text))return M.makeSpan(["mspace",ll[r.text]],[],e);throw new W('Unknown type of space "'+r.text+'"')}},mathmlBuilder(r,e){var t;if(dl.hasOwnProperty(r.text))t=new G.MathNode("mtext",[new G.TextNode(" ")]);else{if(ll.hasOwnProperty(r.text))return new G.MathNode("mspace");throw new W('Unknown type of space "'+r.text+'"')}return t}});var np=()=>{var r=new G.MathNode("mtd",[]);return r.setAttribute("width","50%"),r};bi({type:"tag",mathmlBuilder(r,e){var t=new G.MathNode("mtable",[new G.MathNode("mtr",[np(),new G.MathNode("mtd",[Vr(r.body,e)]),np(),new G.MathNode("mtd",[Vr(r.tag,e)])])]);return t.setAttribute("width","100%"),t}});var rp={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},ip={"\\textbf":"textbf","\\textmd":"textmd"},U8={"\\textit":"textit","\\textup":"textup"},sp=(r,e)=>{var t=r.font;if(t){if(rp[t])return e.withTextFontFamily(rp[t]);if(ip[t])return e.withTextFontWeight(ip[t]);if(t==="\\emph")return e.fontShape==="textit"?e.withTextFontShape("textup"):e.withTextFontShape("textit")}else return e;return e.withTextFontShape(U8[t])};Z({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:et(i),font:n}},htmlBuilder(r,e){var t=sp(r,e),n=lt(r.body,t,!0);return M.makeSpan(["mord","text"],n,t)},mathmlBuilder(r,e){var t=sp(r,e);return Vr(r.body,t)}});Z({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=Ce(r.body,e),n=M.makeLineSpan("underline-line",e),i=e.fontMetrics().defaultRuleThickness,s=M.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 M.makeSpan(["mord","underline"],[s],e)},mathmlBuilder(r,e){var t=new G.MathNode("mo",[new G.TextNode("‾")]);t.setAttribute("stretchy","true");var n=new G.MathNode("munder",[Me(r.body,e),t]);return n.setAttribute("accentunder","true"),n}});Z({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=Ce(r.body,e),n=e.fontMetrics().axisHeight,i=.5*(t.height-n-(t.depth+n));return M.makeVList({positionType:"shift",positionData:i,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(r,e){return new G.MathNode("mpadded",[Me(r.body,e)],["vcenter"])}});Z({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=ap(r),n=[],i=e.havingStyle(e.style.text()),s=0;s<t.length;s++){var a=t[s];a==="~"&&(a="\\textasciitilde"),n.push(M.makeSymbol(a,"Typewriter-Regular",r.mode,i,["mord","texttt"]))}return M.makeSpan(["mord","text"].concat(i.sizingClasses(e)),M.tryCombineChars(n),i)},mathmlBuilder(r,e){var t=new G.TextNode(ap(r)),n=new G.MathNode("mtext",[t]);return n.setAttribute("mathvariant","monospace"),n}});var ap=r=>r.body.replace(/ /g,r.star?"␣":" "),oi=mv,$v=`[ \r
|
|
368
|
+
]`,F8="\\\\[a-zA-Z@]+",I8="\\\\[^\uD800-\uDFFF]",Q8="("+F8+")"+$v+"*",M8=`\\\\(
|
|
369
|
+
|[ \r ]+
|
|
370
|
+
?)[ \r ]*`,Ed="[̀-ͯ]",_8=new RegExp(Ed+"+$"),R8="("+$v+"+)|"+(M8+"|")+"([!-\\[\\]-‧-豈-]"+(Ed+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(Ed+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+Q8)+("|"+I8+")");class Ap{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(R8,"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 on("EOF",new $t(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new W("Unexpected character: '"+e[t]+"'",new on(e[t],new $t(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 on(i,new $t(this,t,this.tokenRegex.lastIndex))}}class P8{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 D8=Dv;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 op={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=op[e.text],n==null||n>=t)throw new W("Invalid base-"+t+" digit "+e.text);for(var i;(i=op[r.future().text])!=null&&i<t;)n*=t,n+=i,r.popToken()}return"\\@char{"+n+"}"});var Du=(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=>Du(r,!1,!0));S("\\renewcommand",r=>Du(r,!0,!1));S("\\providecommand",r=>Du(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 cp={",":"\\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 cp?e=cp[t]:(t.slice(0,4)==="\\not"||t in Oe.math&&ae.contains(["bin","rel"],Oe.math[t].group))&&(e="\\dotsb"),e});var Lu={")":!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 Lu?"\\ldots\\,":"\\ldots"});S("\\dotsc",function(r){var e=r.future().text;return e in Lu&&e!==","?"\\ldots\\,":"\\ldots"});S("\\cdots",function(r){var e=r.future().text;return e in Lu?"\\@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 Xv=X(On["Main-Regular"][84][1]-.7*On["Main-Regular"][65][1]);S("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+Xv+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");S("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+Xv+"}{\\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 Jv=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 m=u.future();m.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",Jv(!1));S("\\bra@set",Jv(!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 jv={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class L8{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 P8(D8,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Ap(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 on("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 on(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 Ap(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)||oi.hasOwnProperty(e)||Oe.math.hasOwnProperty(e)||Oe.text.hasOwnProperty(e)||jv.hasOwnProperty(e)}isExpandable(e){var t=this.macros.get(e);return t!=null?typeof t=="string"||typeof t=="function"||!t.unexpandable:oi.hasOwnProperty(e)&&!oi[e].primitive}}var lp=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,eA=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","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),ul={"́":{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"}},dp={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"};class jo{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 L8(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 on("}")),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(jo.endOfExpression.indexOf(i.text)!==-1||t&&i.text===t||e&&oi[i.text]&&oi[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(eA[s.text]){var c=lp.test(s.text),l=[];for(l.push(new on(eA[s.text])),this.consume();;){var d=this.fetch().text;if(!eA[d]||lp.test(d)!==c)break;l.unshift(new on(eA[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=oi[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=oi[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(!Av(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:$t.range(n,o),body:A,semisimple:i==="\\begingroup"||void 0}}else if(s=this.parseFunction(t,e)||this.parseSymbol(),s==null&&i[0]==="\\"&&!jv.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:$t.range(i,e[n+2]),text:"---"}),t-=2):(e.splice(n,2,{type:"textord",mode:"text",loc:$t.range(i,e[n+1]),text:"--"}),t-=1)),(s==="'"||s==="`")&&e[n+1].text===s&&(e.splice(n,2,{type:"textord",mode:"text",loc:$t.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}}dp.hasOwnProperty(t[0])&&!Oe[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=dp[t[0]]+t.slice(1));var s=_8.exec(t);s&&(t=t.substring(0,s.index),t==="i"?t="ı":t==="j"&&(t="ȷ"));var a;if(Oe[this.mode][t]){this.settings.strict&&this.mode==="math"&&Cd.indexOf(t)>=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var A=Oe[this.mode][t].group,o=$t.range(e),c;if(k7.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&&(av(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:$t.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(!ul[u])throw new W("Unknown accent ' "+u+"'",e);var h=ul[u][this.mode]||ul[u].text;if(!h)throw new W("Accent "+u+" unsupported in "+this.mode+" mode",e);a={type:"accent",mode:this.mode,loc:$t.range(e),label:h,isStretchy:!1,isShifty:!0,base:a}}return a}}jo.endOfExpression=["}","\\endgroup","\\end","\\right","&"];var Ou=function(e,t){if(!(typeof e=="string"||e instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var n=new jo(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 on("\\df@tag")])}]}return i},Yv=function(e,t,n){t.textContent="";var i=Hu(e,n).toNode();t.appendChild(i)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u",Yv=function(){throw new W("KaTeX doesn't work in quirks mode.")});var O8=function(e,t){var n=Hu(e,t).toMarkup();return n},H8=function(e,t){var n=new bu(t);return Ou(e,n)},Zv=function(e,t,n){if(n.throwOnError||!(e instanceof W))throw e;var i=M.makeSpan(["katex-error"],[new cn(t)]);return i.setAttribute("title",e.toString()),i.setAttribute("style","color:"+n.errorColor),i},Hu=function(e,t){var n=new bu(t);try{var i=Ou(e,n);return X7(i,e,n)}catch(s){return Zv(s,e,n)}},N8=function(e,t){var n=new bu(t);try{var i=Ou(e,n);return J7(i,e,n)}catch(s){return Zv(s,e,n)}},fa={version:"0.16.11",render:Yv,renderToString:O8,ParseError:W,SETTINGS_SCHEMA:bA,__parse:H8,__renderToDomTree:Hu,__renderToHTMLTree:N8,__setFontMetrics:y7,__defineSymbol:f,__defineFunction:Z,__defineMacro:S,__domTree:{Span:ga,Anchor:Su,SymbolNode:cn,SvgNode:hr,PathNode:Kr,LineNode:Bd}},K8=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},V8=function(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")},z8=/^\\begin{/,G8=function(e,t){for(var n,i=[],s=new RegExp("("+t.map(c=>V8(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=K8(t[a].right,e,t[a].left.length),n===-1)break;var A=e.slice(0,n+t[a].right.length),o=z8.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},q8=function(e,t){var n=G8(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)),fa.render(A,a,t)}catch(o){if(!(o instanceof fa.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},W8=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=q8(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)}()}},$8=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||{},W8(e,n)};function X8(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 J8(r){if(!r||/\$/.test(r)||ey(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 j8(r){return/\$\$[\s\S]+\$\$/.test(r)||/\$[^$\n]+\$/.test(r)||/\\\([\s\S]+\\\)/.test(r)||/\\\[[\s\S]+\\\]/.test(r)}const Y8=/\\(?: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 ey(r){const e=r.trim();return!e||j8(e)?!1:Y8.test(e)||/^\\[a-zA-Z]+/.test(e)}function Yo(r){if(!r)return r;const e=X8(r);if(!e.includes("\\")&&!e.includes("_"))return e;const t=e.split(`
|
|
373
|
+
`),n=[];let i=[];const s=()=>{if(i.length===0)return;const a=i.join(`
|
|
374
|
+
`).trim();a&&n.push(`$$${a}$$`),i=[]};for(const a of t){const A=J8(a);if(ey(A)){i.push(A);continue}s(),n.push(A)}return s(),n.join(`
|
|
375
|
+
`)}function Z8(r,e){return r.trim()?Yo(r):r}const eE="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css",ty=[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1}];function tE(){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=eE,r.crossOrigin="anonymous",document.head.appendChild(r)}function up(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 CA(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 lo(r){const e=Yo(r),t=[];let n=0;for(;n<e.length;){let i=null;for(const A of ty){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 nE(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 rE(r,e){try{return fa.renderToString(r,{displayMode:e,throwOnError:!1,strict:"ignore"})}catch{return fa.renderToString(String.raw`\text{?}`,{displayMode:e,throwOnError:!1})}}function hp(r){const e=document.createElement("span");e.className="vnr-chalk-cursor",e.setAttribute("aria-hidden","true"),e.textContent="|",r.appendChild(e)}function ny(r,e,t){const n=lo(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",hp(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"?nE(o,s.text):o.innerHTML=rE(s.latex,s.display),i.appendChild(o)}),t!=null&&t.showCursor&&hp(i),r.appendChild(i),n}function iE(r,e,t=!1){const n=Yo(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{$8(e,{delimiters:[...ty],throwOnError:!1,errorColor:"#ff8a8a",strict:"ignore"})}catch{}}const sE=1.75;function aE(r,e){return Math.max(180,r.latex.length*e*sE)}function AE(r){for(let e=r.length-1;e>=0;e--)if(r[e].kind==="math")return e;return-1}function oE(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,m)=>{const g=CA(h);ny(e,g,{showCursor:!0,revealingSegmentIndex:m==null?void 0:m.segmentIndex,revealMs:m==null?void 0:m.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=CA(l),g=lo(h).filter(U=>U.kind==="math").length;l+=n[c],c+=1,A(c);const y=CA(l),b=lo(y);if(b.filter(U=>U.kind==="math").length>g){const U=AE(b),w=b[U];if((w==null?void 0:w.kind)==="math"){const C=aE(w,i);d(l,{segmentIndex:U,revealMs:C}),s(u,C);return}}d(l),s(u,i)};d(l),s(u,i)}const cE="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.",lE=/\\[a-zA-Z]+/;function dE(r){let e=0,t=!1;for(;e<r.length;){if(r.startsWith("$$",e)){t=!t,e+=2;continue}e+=1}return t}function uE(r){try{return fa.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 hE(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=[];dE(e)&&t.push({code:"unclosed_delimiter",message:"Unclosed $$ delimiter — every $$ must be paired",snippet:e.slice(0,160)});const n=Yo(e),i=lo(e);for(const s of i){if(s.kind==="plain"){lE.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=uE(s);a&&t.push(a)}return{ok:t.length===0,normalized:n,errors:t,agent_message:t.length>0?`${cE} Errors: ${t.map(s=>s.message).join("; ")}`:""}}function fE(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 fp="vanira:agent-playback-ended",pE="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 mE(r){return!!r.has_notes_on_board}class gE{constructor(e,t){D(this,"active",!1);D(this,"sendContext",null);D(this,"getSnapshot");D(this,"isBoardBusy");D(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(fp,this.onAgentTurnEnd)}stop(){this.active&&(this.active=!1,this.sendContext=null,window.removeEventListener(fp,this.onAgentTurnEnd))}checkAfterAgentTurn(){if(!this.active||!this.sendContext||this.isBoardBusy())return;const e=this.getSnapshot();if(mE(e))return;const t={board_turn_check:{has_whiteboard:!1,...e,message:pE}};try{this.sendContext(t)}catch{}}}function vE(){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:rc&&rc.tagName.toUpperCase()==="SCRIPT"&&rc.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 hl=null;function ry(){return hl===null&&(hl=vE()),hl}function iy(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 vs(r,e,t){ry()&&iy(r,e,t)}function yE(r,e,t){ry()&&iy(r,`WARN ${e}`,t)}function Ws(r){return r.toLowerCase().replace(/[^a-z0-9]/g,"_")}function wE(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=wE(e);return n||(t.length>0?"select":r.includes("email")?"email":r.includes("phone")?"phone":r.includes("date")&&!r.includes("update")?"date":"text")}function bE(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 BE(r){const e=r.value??r.default??r.defaultValue??r.prefill;if(!(e==null||e===""))return String(e)}function fl(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??Ws(e)),n=bE(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:BE(r),options:n}}function pp(r){const e=r.trim(),t=Ws(e);return{id:t,label:e,type:sy(t),required:!0,placeholder:`Enter your ${e.toLowerCase()}`,options:[]}}function SA(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 CE(r){let e=r.trim();for(let t=0;t<3&&typeof e=="string";t++){const n=e.trim();if(!SA(n))break;try{e=JSON.parse(n)}catch{break}}return e}function TA(r){const e=CE(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 SE(r){return r.length<2?!1:r.every(e=>typeof e=="string"&&(e.includes('"')||e.includes("{")||e.includes("[")))}function TE(r){return TA(r.map(e=>e.trim()).join(","))}function Qs(r){if(r==null)return[];if(typeof r=="string"){const e=r.trim();if(!e)return[];if(SA(e)){const t=TA(e);return t!==null?Qs(t):[]}return e.split(",").map(t=>t.trim()).filter(Boolean).map(pp)}if(Array.isArray(r)){if(r.length===1&&typeof r[0]=="string"){const t=r[0].trim();if(SA(t)){const n=TA(t);if(n!==null)return Qs(n)}}if(SE(r)){const t=TE(r);if(t!==null)return Qs(t)}const e=[];for(const t of r){if(typeof t=="string"){const n=t.trim();if(n.startsWith("{"))try{const i=fl(JSON.parse(n));if(i){e.push(i);continue}}catch{}if(SA(n)){const i=TA(n);if(i!==null){e.push(...Qs(i));continue}}e.push(pp(t));continue}if(t&&typeof t=="object"){const n=fl(t);n&&e.push(n)}}return e}if(typeof r=="object"){const e=fl(r);return e?[e]:[]}return[]}const kE=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,xE=/^\+?[0-9\s\-().]{7,20}$/,EE=/^\d{4}-\d{2}-\d{2}$/;function ay(r,e){const t=r[e.id];return e.type==="checkbox"?t===!0||t==="true"?"true":"false":String(t??"").trim()}function UE(r,e){const t={};for(const n of r){const i=ay(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=FE(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 FE(r,e,t){switch(r){case"email":return kE.test(e)?null:`Enter a valid ${t}`;case"phone":return xE.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 EE.test(e)?Number.isNaN(Date.parse(e))?`Enter a valid ${t}`:null:`${t} must be YYYY-MM-DD`;default:return null}}function IE(r,e){const t={};for(const n of r)t[n.id]=ay(e,n);return t}function Ay(r){if(r==null)return{};if(typeof r=="string"){const e=r.trim();if(!e)return{};try{return Ay(JSON.parse(e))}catch{return{}}}return typeof r=="object"&&!Array.isArray(r)?r:{}}function QE(r,e){const t=r.prefill??r.values??r.initial_values??r.defaults??e.prefill??e.values??e.initial_values??e.defaults;return Ay(t)}function Ud(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 ME(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 Ud(r,s)}const n=Ws(r.label);for(const[i,s]of Object.entries(e))if(!(s==null||s==="")&&(i===n||Ws(i)===n||Ws(i)===r.id))return Ud(r,s)}function _E(r,e={}){const t={};for(const n of r){if(n.value!==void 0){t[n.id]=Ud(n,n.value);continue}const i=ME(n,e);t[n.id]=i!==void 0?i:n.type==="checkbox"?!1:""}return t}const mp="vanira:board_abort";function pl(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 RE(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=U=>{var w;return(w=o.find(C=>C.type===U))==null?void 0:w.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),m=parseInt(c("minute")||"0",10),g=parseInt(c("second")||"0",10),y=h===24?0:h,B=Date.UTC(l,d,u,y,m,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 PE(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=I=>{var _;return((_=n.find(P=>P.type===I))==null?void 0:_.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),m=parseInt(a,10)-1,g=parseInt(A,10),b=Date.UTC(h,m,g,o,parseInt(l,10),parseInt(d,10),r.getMilliseconds())-r.getTime(),B=Math.round(b/6e4),U=B>=0?"+":"-",w=Math.abs(B),C=String(Math.floor(w/60)).padStart(2,"0"),E=String(w%60).padStart(2,"0");return`${s}-${a}-${A}T${c}:${l}:${d}.${u}${U}${C}:${E}`}catch{return r.toISOString()}}const DE=`
|
|
115
377
|
.vnr-overlay {
|
|
116
378
|
position: fixed; inset: 0; z-index: 2147483647;
|
|
117
379
|
background: rgba(0,0,0,0.45);
|
|
@@ -132,11 +394,13 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
132
394
|
pointer-events: auto;
|
|
133
395
|
}
|
|
134
396
|
.vnr-overlay.vnr-whiteboard-overlay-expanded {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
397
|
+
display: flex;
|
|
398
|
+
align-items: flex-end;
|
|
399
|
+
justify-content: center;
|
|
400
|
+
padding: max(48px, calc(24px + env(safe-area-inset-top, 0px))) 16px max(104px, calc(72px + env(safe-area-inset-bottom, 0px)));
|
|
401
|
+
}
|
|
402
|
+
.vnr-overlay.vnr-whiteboard-overlay-expanded .vnr-whiteboard-modal {
|
|
403
|
+
translate: 0 20px;
|
|
140
404
|
}
|
|
141
405
|
.vnr-overlay.vnr-whiteboard-overlay-reduced {
|
|
142
406
|
display: block;
|
|
@@ -254,6 +518,7 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
254
518
|
flex-shrink: 0;
|
|
255
519
|
box-sizing: border-box;
|
|
256
520
|
transition: width 0.2s ease, max-width 0.2s ease, height 0.2s ease, max-height 0.2s ease;
|
|
521
|
+
background-color: #0a1810;
|
|
257
522
|
}
|
|
258
523
|
.vnr-overlay.vnr-whiteboard-overlay-reduced .vnr-whiteboard-modal {
|
|
259
524
|
box-shadow: 0 20px 52px rgba(0,0,0,0.6) !important;
|
|
@@ -268,8 +533,8 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
268
533
|
justify-content: flex-end;
|
|
269
534
|
gap: 6px;
|
|
270
535
|
padding: 8px 10px;
|
|
271
|
-
background: linear-gradient(180deg, #
|
|
272
|
-
border-bottom: 1px solid rgba(255,255,255,0.
|
|
536
|
+
background: linear-gradient(180deg, #122a1c 0%, #0a1810 100%);
|
|
537
|
+
border-bottom: 1px solid rgba(255,255,255,0.06);
|
|
273
538
|
z-index: 30;
|
|
274
539
|
}
|
|
275
540
|
.vnr-overlay.vnr-whiteboard-overlay-reduced .vnr-whiteboard-header {
|
|
@@ -301,9 +566,63 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
301
566
|
color: #fecaca;
|
|
302
567
|
}
|
|
303
568
|
.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=`
|
|
569
|
+
.vnr-whiteboard-action-btn:disabled {
|
|
570
|
+
opacity: 0.4;
|
|
571
|
+
cursor: not-allowed;
|
|
572
|
+
}
|
|
573
|
+
.vnr-whiteboard-textarea {
|
|
574
|
+
overflow-y: auto;
|
|
575
|
+
overflow-x: hidden;
|
|
576
|
+
}
|
|
577
|
+
.vnr-whiteboard-textarea:empty::before,
|
|
578
|
+
.vnr-whiteboard-textarea[data-empty="true"]::before {
|
|
579
|
+
content: 'Notes appear here…';
|
|
580
|
+
color: rgba(255,255,255,0.35);
|
|
581
|
+
font-style: italic;
|
|
582
|
+
}
|
|
583
|
+
.vnr-whiteboard-textarea .katex {
|
|
584
|
+
color: #ffffff;
|
|
585
|
+
font-size: 1.08em;
|
|
586
|
+
}
|
|
587
|
+
.vnr-whiteboard-textarea .katex-display {
|
|
588
|
+
margin: 0.6em 0;
|
|
589
|
+
overflow-x: auto;
|
|
590
|
+
overflow-y: hidden;
|
|
591
|
+
}
|
|
592
|
+
.vnr-chalk-board-content {
|
|
593
|
+
white-space: pre-wrap;
|
|
594
|
+
word-break: break-word;
|
|
595
|
+
}
|
|
596
|
+
.vnr-chalk-segment.vnr-chalk-math-display {
|
|
597
|
+
display: block;
|
|
598
|
+
margin: 0.5em 0;
|
|
599
|
+
}
|
|
600
|
+
.vnr-chalk-segment.vnr-chalk-revealing {
|
|
601
|
+
display: inline-block;
|
|
602
|
+
overflow: hidden;
|
|
603
|
+
max-width: 100%;
|
|
604
|
+
vertical-align: bottom;
|
|
605
|
+
clip-path: inset(0 100% 0 0);
|
|
606
|
+
animation: vnr-chalk-equation-reveal var(--vnr-chalk-reveal-ms, 600ms) linear forwards;
|
|
607
|
+
}
|
|
608
|
+
.vnr-chalk-segment.vnr-chalk-revealing.vnr-chalk-math-display {
|
|
609
|
+
display: block;
|
|
610
|
+
}
|
|
611
|
+
@keyframes vnr-chalk-equation-reveal {
|
|
612
|
+
from { clip-path: inset(0 100% 0 0); }
|
|
613
|
+
to { clip-path: inset(0 0 0 0); }
|
|
614
|
+
}
|
|
615
|
+
.vnr-chalk-cursor {
|
|
616
|
+
display: inline-block;
|
|
617
|
+
color: rgba(255, 255, 255, 0.95);
|
|
618
|
+
font-weight: 300;
|
|
619
|
+
margin-left: 1px;
|
|
620
|
+
animation: vnr-chalk-cursor-blink 1s step-end infinite;
|
|
621
|
+
}
|
|
622
|
+
@keyframes vnr-chalk-cursor-blink {
|
|
623
|
+
50% { opacity: 0; }
|
|
624
|
+
}
|
|
625
|
+
`,LE='<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>',OE='<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>',gp='<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>',HE='<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>',oy="vanira:board-size",ys=["small","medium","large"],NE=1.2,KE={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)"}},VE="#3d2817",zE=20,GE=["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(", "),qE=["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 ml(r){r.style.backgroundColor="#0a1810",r.style.backgroundImage=GE,r.style.backgroundRepeat="no-repeat",r.style.backgroundSize="cover",r.style.border=`${zE}px solid ${VE}`,r.style.boxShadow=qE}function WE(){try{const r=localStorage.getItem(oy);if(r==="small"||r==="medium"||r==="large")return r}catch{}return"medium"}function $E(r){try{localStorage.setItem(oy,r)}catch{}}function vp(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 yp(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 tA(r,e=8e3){return await r.play().catch(()=>{}),r.videoWidth>0&&r.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&await wp(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 wp(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 wp(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 nA(r,e){if(e){const t=e.querySelector("video");if(t&&t.videoWidth>0)return t}return r}function cy(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 XE(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),cy(A,a.width,a.height))?null:await new Promise(o=>{a.toBlob(c=>o(c),"image/jpeg",t)})}async function Fd(r,e,t,n=.75){const i=await XE(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(),cy(u,c,l)?null:await new Promise(h=>{d.toBlob(m=>h(m),"image/jpeg",n)})):(A.close(),null)}catch(a){return yE("[LiveCapture]",`ImageCapture failed: ${a instanceof Error?a.message:String(a)}`),null}}async function bp(r,e,t,n=20,i=250){for(let s=0;s<n;s++){if(await Fd(r,e,t,.6))return!0;await new Promise(A=>setTimeout(A,i))}return!1}class JE{constructor(e){D(this,"overlay",null);D(this,"styleInjected",!1);D(this,"chalkboardContent","");D(this,"calViewYear",0);D(this,"calViewMonth",0);D(this,"calSelectedTs",null);D(this,"calSelectedTime",null);D(this,"lvSessionId",null);D(this,"lvStream",null);D(this,"lvCaptureInterval",null);D(this,"lvAutoStopTimeout",null);D(this,"lvFrameSeq",0);D(this,"lvVideo",null);D(this,"lvCanvas",null);D(this,"lvPip",null);D(this,"lvPermissionBanner",null);D(this,"lsSessionId",null);D(this,"lsStream",null);D(this,"lsCaptureInterval",null);D(this,"lsAutoStopTimeout",null);D(this,"lsFrameSeq",0);D(this,"lsVideo",null);D(this,"lsCanvas",null);D(this,"lsPip",null);D(this,"lsPermissionBanner",null);D(this,"captureActive",!1);D(this,"captureStream",null);D(this,"captureLivenessInterval",null);D(this,"activePresetGeneration",0);D(this,"boardQueue",[]);D(this,"boardQueueActive",null);D(this,"boardAnimTimer",null);D(this,"settledBoardToolCallIds",new Set);D(this,"activeNavigate",null);D(this,"settledNavigateToolCallIds",new Set);D(this,"activeModalPreset",null);D(this,"boardClient",null);D(this,"boardTurnMonitor",new gE(()=>this.buildBoardVerification(),()=>this.boardQueueActive!==null||this.boardQueue.length>0||this.activeBoardProgress!==null));D(this,"activeBoardProgress",null);D(this,"boardSizePreset",WE());D(this,"boardViewMode","expanded");D(this,"boardDragPosition",null);D(this,"boardDragWiredModal",null)}resetChalkboard(){this.chalkboardContent=""}resetBoardSession(){this.boardTurnMonitor.stop(),this.boardDragPosition=null,this.boardDragWiredModal=null,this.activePresetGeneration++,Yc(!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?CA(t):t,s=(n==null?void 0:n.showCursor)===!0;up(t)||up(i)?ny(e,i,{showCursor:s}):iE(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:R.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:R.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||!Vu(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=Id(o,A,s.name||s.tool_name);if(!c||!Kn(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(Vu(c)?u||this.dismissNonBoardUi():Sy(c)||this.dismiss(),c){case R.Calendar:return this.renderCalendar(d,t,n),!0;case R.Form:return this.renderForm(d,t,n),!0;case R.Camera:return this.renderCamera(d,t,n,i),!0;case R.Upload:return this.renderUpload(d,t,n,i),!0;case R.ClipRegion:return this.renderClipRegion(d,t,n,i),!0;case R.ScreenVision:return this.renderScreenVision(d,t,n,i),!0;case R.PointAt:return this.renderPointAt(d,t,n),!0;case R.DrawOnScreen:return this.renderDrawOnScreen(d,t,n),!0;case R.ClearScreenDraw:return this.renderClearScreenDraw(d,t,n),!0;case R.HighlightOnScreen:return this.renderHighlightOnScreen(d,t,n),!0;case R.Navigate:return this.renderNavigate(d,t,n),!0;case R.HighlightElement:return this.renderHighlight(d,t,n),!0;case R.ClickElement:return this.renderClickElement(d,t,n),!0;case R.SelectOption:return this.renderSelectOption(d,t,n),!0;case R.SetDate:return this.renderSetDate(d,t,n),!0;case R.TypeText:return this.enqueueBoardCommand({ctx:d,presetId:R.TypeText,onComplete:t,onCancel:n},i),!0;case R.WriteLatexText:return this.enqueueBoardCommand({ctx:d,presetId:R.WriteLatexText,onComplete:t,onCancel:n},i),!0;case R.EraseText:return this.enqueueBoardCommand({ctx:d,presetId:R.EraseText,onComplete:t,onCancel:n},i),!0;case R.LiveVision:return this.handleOpenLiveCamera(l,i,d.toolCallId),t({status:"success",preset_id:R.LiveVision,message:"Live camera session started"}),!0;case R.CloseLiveCamera:return this.handleCloseLiveCamera(i),t({status:"success",preset_id:R.CloseLiveCamera,message:"Live camera stopped"}),!0;case R.LiveScreen:return this.handleOpenLiveScreen(l,i,d.toolCallId),t({status:"success",preset_id:R.LiveScreen,message:"Live screen share started"}),!0;case R.CloseLiveScreen:return this.handleCloseLiveScreen(i),t({status:"success",preset_id:R.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),Jc(),Tr().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),vs("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,vs("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===R.TypeText?this.renderTypeText(e.ctx,n,i):e.presetId===R.WriteLatexText?this.renderWriteLatexText(e.ctx,n,i):this.renderEraseText(e.ctx,n,i)}closeBoardUi(){this.boardTurnMonitor.stop(),this.boardViewMode="expanded",Yc(!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),Yc(!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),Jc(),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;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=`
|
|
307
626
|
<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
627
|
<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
628
|
<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 +637,43 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
318
637
|
${t.onDismiss?'<button type="button" id="vnr-cam-perm-dismiss" class="vnr-cancel-btn">Cancel</button>':""}
|
|
319
638
|
</div>
|
|
320
639
|
</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
|
|
640
|
+
`,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
641
|
<p style="margin:0 0 6px;font-size:13px;font-weight:700;color:#f87171">Camera access blocked</p>
|
|
323
642
|
<p style="margin:0 0 12px;font-size:12px;color:#94a3b8;line-height:1.5">${this.getBrowserPermissionHint()}</p>
|
|
324
643
|
<div style="display:flex;gap:8px">
|
|
325
644
|
<button type="button" id="vnr-lv-perm-retry" style="flex:1;padding:9px 14px;border:none;border-radius:10px;background:#6366f1;color:#fff;font-size:13px;font-weight:600;cursor:pointer">Try Again</button>
|
|
326
645
|
<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
646
|
</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">${
|
|
647
|
+
`,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,yp(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(U=>U.stop());return}if((B=this.lvPermissionBanner)==null||B.remove(),this.lvPermissionBanner=null,this.lvStream=g,u.srcObject=g,this.lvPip){const U=this.lvPip.querySelector("video");U&&(U.srcObject=g,await tA(U))}await tA(u);const y=nA(u,this.lvPip)??u;await bp(y,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 b=Math.round(1e3/s);this.lvCaptureInterval=setInterval(()=>{this.captureAndSendFrame(t,d,a,A)},b),i==="timed"&&o>0&&(this.lvAutoStopTimeout=setTimeout(()=>{this.handleCloseLiveCamera(t)},o*1e3))}).catch(g=>{var y,b;this.lvSessionId=null,(y=this.lvStream)==null||y.getTracks().forEach(B=>B.stop()),this.lvStream=null,(b=this.lvPip)==null||b.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=`
|
|
648
|
+
<p style="margin:0 0 6px;font-size:13px;font-weight:700;color:#60a5fa">${i}</p>
|
|
649
|
+
<p style="margin:0 0 12px;font-size:12px;color:#94a3b8;line-height:1.5">${s}</p>
|
|
331
650
|
<div style="display:flex;gap:8px">
|
|
332
651
|
<button type="button" id="vnr-ls-perm-retry" style="flex:1;padding:9px 14px;border:none;border-radius:10px;background:#6366f1;color:#fff;font-size:13px;font-weight:600;cursor:pointer">Try Again</button>
|
|
333
652
|
<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
653
|
</div>
|
|
335
|
-
`,
|
|
654
|
+
`,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,yp(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 y=c?{displaySurface:"browser"}:!0;navigator.mediaDevices.getDisplayMedia({video:y,audio:!1}).then(async b=>{var E,I;if(!this.lsSessionId){b.getTracks().forEach(_=>_.stop());return}(E=this.lsPermissionBanner)==null||E.remove(),this.lsPermissionBanner=null,this.lsStream=b,u.srcObject=b;const B=b.getVideoTracks()[0];if(B&&(B.onended=()=>{this.handleCloseLiveScreen(t)}),this.lsPip){const _=this.lsPip.querySelector("video");_&&(_.srcObject=b,await tA(_))}await tA(u);const U=nA(u,this.lsPip)??u;await bp(U,b,a,12,200);const w=((I=B==null?void 0:B.getSettings)==null?void 0:I.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:w,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(b=>{var U,w;const B=this.classifyLiveScreenShareFailure(b);this.lsSessionId=null,(U=this.lsStream)==null||U.getTracks().forEach(C=>C.stop()),this.lsStream=null,(w=this.lsPip)==null||w.remove(),this.lsPip=null,u.remove(),this.lsVideo=null,h.remove(),this.lsCanvas=null,this.emitLiveScreenShareFailure(t,d,n,B,b),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=nA(this.lsVideo,this.lsPip);if(!s||s.readyState<2||s.videoWidth===0)return;let a;try{a=await Fd(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 m=++this.lsFrameSeq;await this.sendClientEvent(e,"client_media_frame",{data:{session_id:t,source:"screen",frame_seq:m,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
655
|
<video autoplay playsinline muted style="width:100%;height:100%;object-fit:contain;display:block;background:#020617"></video>
|
|
337
656
|
<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
657
|
<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
658
|
SCREEN
|
|
340
659
|
</div>
|
|
341
660
|
<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
|
|
661
|
+
`,!document.getElementById("vnr-pip-style")){const n=document.createElement("style");n.id="vnr-pip-style",n.textContent=`
|
|
343
662
|
@keyframes vnr-pip-pulse{0%,100%{opacity:1;transform:scale(1);}50%{opacity:.5;transform:scale(1.2);}}
|
|
344
663
|
#vnr-live-screen-pip:hover { transform: scale(1.02); }
|
|
345
664
|
#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;${
|
|
665
|
+
`,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=nA(this.lvVideo,this.lvPip);if(!s||s.readyState<2||s.videoWidth===0)return;let a;try{a=await Fd(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 m=++this.lvFrameSeq;await this.sendClientEvent(e,"client_media_frame",{data:{session_id:t,frame_seq:m,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=`
|
|
666
|
+
<video autoplay playsinline muted style="width:100%;height:100%;object-fit:cover;display:block;${i?"transform:scaleX(-1);":""}"></video>
|
|
348
667
|
<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
668
|
<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
669
|
REC
|
|
351
670
|
</div>
|
|
352
671
|
<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
|
|
672
|
+
`,!document.getElementById("vnr-pip-style")){const s=document.createElement("style");s.id="vnr-pip-style",s.textContent=`
|
|
354
673
|
@keyframes vnr-pip-pulse{0%,100%{opacity:1;transform:scale(1);}50%{opacity:.5;transform:scale(1.2);}}
|
|
355
674
|
#vnr-live-pip:hover { transform: scale(1.02); }
|
|
356
675
|
#vnr-pip-stop:hover { background: rgba(239,68,68,0.9) !important; transform: scale(1.1); }
|
|
357
|
-
`,document.head.appendChild(
|
|
676
|
+
`,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=DE,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
677
|
<button class="vnr-close-btn" aria-label="Close">
|
|
359
678
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
360
679
|
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
@@ -365,40 +684,40 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
365
684
|
<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
685
|
<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
686
|
</svg>
|
|
368
|
-
<span>${
|
|
687
|
+
<span>${n}</span>
|
|
369
688
|
</div>
|
|
370
|
-
`,e.appendChild(
|
|
689
|
+
`,e.appendChild(i),i}renderCalendar(e,t,n){this.bindActiveModalPreset(e,R.Calendar,t,n);const i=y=>{this.clearActiveModalPreset(),t({status:"success",preset_id:R.Calendar,...y})},s=y=>{this.clearActiveModalPreset(),n(y,{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
690
|
<button class="vnr-cancel-btn">Cancel</button>
|
|
372
691
|
<button class="vnr-confirm-btn" disabled>
|
|
373
692
|
<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
693
|
Confirm
|
|
375
694
|
</button>
|
|
376
|
-
`,
|
|
695
|
+
`,l.appendChild(h);const m=h.querySelector(".vnr-confirm-btn");h.querySelector(".vnr-cancel-btn").addEventListener("click",()=>{this.dismiss(),s("User cancelled")}),m.addEventListener("click",()=>{if(!this.calSelectedTs||!this.calSelectedTime)return;const y=new Date(this.calSelectedTs),b=pl(this.calSelectedTime),B=y.getFullYear(),U=String(y.getMonth()+1).padStart(2,"0"),w=String(y.getDate()).padStart(2,"0"),C=`${B}-${U}-${w}`,E=e.clientFields.timezone||"";let I=typeof this.calSelectedTime=="object"?{...this.calSelectedTime}:void 0;if(I){for(const _ of["start","startTime","end","endTime"])if(I[_]&&typeof I[_]=="string"&&(I[_].includes("T")||!isNaN(Date.parse(I[_]))))try{I[_]=PE(new Date(I[_]),E)}catch{}}this.dismiss(),i({date:C,time:b,timestamp:this.calSelectedTs,formatted:`${y.toLocaleDateString("en-US",{weekday:"long",month:"short",day:"numeric"})} at ${b}`,slot_data:I})});const g=()=>{const y=new Date;y.setHours(0,0,0,0);const b=new Date(this.calViewYear,this.calViewMonth,1).getDay(),B=new Date(this.calViewYear,this.calViewMonth+1,0).getDate(),U=new Date(this.calViewYear,this.calViewMonth,1).toLocaleDateString("en-US",{month:"long",year:"numeric"}),w=this.calViewYear===y.getFullYear()&&this.calViewMonth===y.getMonth();d.innerHTML=`
|
|
377
696
|
<div class="vnr-month-nav">
|
|
378
697
|
<button class="vnr-nav-btn" id="vnr-prev" ${w?"disabled":""}>
|
|
379
698
|
<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
699
|
</button>
|
|
381
|
-
<span class="vnr-month-label">${
|
|
700
|
+
<span class="vnr-month-label">${U}</span>
|
|
382
701
|
<button class="vnr-nav-btn" id="vnr-next">
|
|
383
702
|
<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
703
|
</button>
|
|
385
704
|
</div>
|
|
386
705
|
<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--,
|
|
706
|
+
`,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(E=>{const I=document.createElement("div");I.className="vnr-wd",I.textContent=E,C.appendChild(I)});for(let E=0;E<b;E++){const I=document.createElement("div");C.appendChild(I)}for(let E=1;E<=B;E++){const I=new Date(this.calViewYear,this.calViewMonth,E).getTime(),_=I<y.getTime(),P=I===y.getTime(),L=this.calSelectedTs===I,O=document.createElement("div");O.style.textAlign="center";const q=document.createElement("button");q.className="vnr-day-btn",_&&q.classList.add("vnr-day-past"),P&&!L&&q.classList.add("vnr-day-today"),L&&q.classList.add("vnr-day-sel"),q.disabled=_,q.textContent=String(E),q.addEventListener("click",()=>{this.calSelectedTs=I,this.calSelectedTime=null,m.disabled=!0,g(),this.loadSlots(e,u,m)}),O.appendChild(q),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=RE(a,s.getMonth(),s.getDate(),l),u=d.start,h=d.end,m=w=>{if(typeof w!="string")return w;let C=w.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(([E,I])=>{if(I!=null){const _=E.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),P=new RegExp(`\\{\\{${_}\\}\\}`,"g");C=C.replace(P,String(I))}}),C},g=(e.clientFields.slots_api_method||"GET").toUpperCase();let y={"Content-Type":"application/json"};try{Object.entries(JSON.parse(e.clientFields.slots_api_headers||"{}")).forEach(([w,C])=>{y[w]=m(String(C))})}catch{}let b={};try{Object.entries(JSON.parse(e.clientFields.slots_api_body||"{}")).forEach(([w,C])=>{b[w]=m(String(C))})}catch{}let B=m(i);const U={method:g,headers:y};if(g==="GET"){const w=new URLSearchParams(Object.entries(b).map(([C,E])=>[C,String(E)])).toString();w&&(B+=(B.includes("?")?"&":"?")+w)}else U.body=JSON.stringify(b);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,U).then(w=>{if(!w.ok)throw new Error(`HTTP ${w.status}`);return w.json()}).then(w=>{let C=[];if(Array.isArray(w))C=w;else if(w&&typeof w=="object"){for(const E of["slots","free_slots","times","data","available_slots"])if(Array.isArray(w[E])){C=w[E];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=>pl(A).length>8)?2:3;if(e.style.display="block",e.innerHTML=`
|
|
388
707
|
<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
|
|
708
|
+
<div class="vnr-section-label">${i}</div>
|
|
709
|
+
${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>`}
|
|
710
|
+
`,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=pl(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 m=document.createElement("input");m.type="radio",m.name=`vnr_${t.id}`,m.id=`vnr_${t.id}_${u}`;const g=a(d);m.value=g,l&&l===g&&(m.checked=!0);const y=document.createElement("span");y.textContent=A(d),h.appendChild(m),h.appendChild(y),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,R.Form,t,n);const i=y=>{this.clearActiveModalPreset(),t({status:"success",preset_id:R.Form,...y})},s=y=>{this.clearActiveModalPreset(),n(y,{status:"cancelled"})},a=e.args.title||e.clientFields.title||"Please fill out this form",A=e.args.reason||"Please provide the following information.",o=Qs(e.args.fields??e.clientFields.fields),c=_E(o,QE(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 y=document.createElement("p");y.className="vnr-form-error",y.style.color="#dc2626",y.style.fontSize="13px",y.textContent="No form fields configured.",u.appendChild(y)}else o.forEach(y=>this.appendFormFieldElement(u,y,c[y.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 m=document.createElement("div");m.className="vnr-actions",m.style.marginTop="16px",m.innerHTML=`
|
|
392
711
|
<button class="vnr-cancel-btn">Cancel</button>
|
|
393
712
|
<button class="vnr-confirm-btn">
|
|
394
713
|
<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
714
|
Submit
|
|
396
715
|
</button>
|
|
397
|
-
`,d.appendChild(
|
|
716
|
+
`,d.appendChild(m),m.querySelector(".vnr-cancel-btn").addEventListener("click",()=>{this.dismiss(),s("User cancelled")});const g=m.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 y=this.collectFormFieldValues(d,o),b=UE(o,y);if(Object.keys(b).length>0){this.showFormFieldErrors(d,b),h.textContent="Please fix the highlighted fields.",h.style.display="block";const U=Object.keys(b)[0],w=d.querySelector(`[data-field-id="${U}"]`),C=w==null?void 0:w.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=IE(o,y);setTimeout(()=>{this.dismiss(),i(B)},300)})}renderCamera(e,t,n,i){this.bindActiveModalPreset(e,R.Camera,t,n);const s=re=>{this.clearActiveModalPreset(),t({status:"success",preset_id:R.Camera,...re})},a=(re,he="cancelled")=>{this.clearActiveModalPreset(),n(re,{status:he})},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,m=null;this.stopCaptureCamera(),this.captureActive=!0;const g=this.createOverlay(),y=document.createElement("div");y.className="vnr-modal",y.style.cssText="position:relative;max-width:480px;width:100%",y.innerHTML=`
|
|
398
717
|
<button class="vnr-close-btn" aria-label="Close">
|
|
399
718
|
<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
719
|
</button>
|
|
401
|
-
<h2 class="vnr-title" style="padding-right:32px">${
|
|
720
|
+
<h2 class="vnr-title" style="padding-right:32px">${o}</h2>
|
|
402
721
|
<p style="margin:0 0 14px;font-size:13px;color:#6b7280;line-height:1.5">${c}</p>
|
|
403
722
|
|
|
404
723
|
<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">
|
|
@@ -441,20 +760,15 @@ ${p}`;e({status:"success",preset_id:m.PageScan,viewport:d.viewport,element_count
|
|
|
441
760
|
Capture & Send
|
|
442
761
|
</button>
|
|
443
762
|
</div>
|
|
444
|
-
`,
|
|
763
|
+
`,g.appendChild(y);const b=y.querySelector("#vnr-cam-video"),B=y.querySelector("#vnr-cam-canvas"),U=y.querySelector("#vnr-cam-overlay"),w=y.querySelector("#vnr-cam-status"),C=y.querySelector("#vnr-cam-capture"),E=y.querySelector("#vnr-cam-liveness-toggle"),I=y.querySelector("#vnr-liveness-progress-container"),_=y.querySelector("#vnr-liveness-bar"),P=y.querySelector("#vnr-liveness-pct"),L=y.querySelector("#vnr-cam-guide"),O=y.querySelector("#vnr-cam-guide-text"),q=()=>{m&&(clearInterval(m),m=null),this.captureLivenessInterval=null,h==null||h.getTracks().forEach(re=>re.stop()),h=null,A.captureStream=null,b.srcObject=null};y.querySelector(".vnr-close-btn").addEventListener("click",()=>{q(),this.captureActive=!1,this.dismiss(),a("User closed")}),y.querySelector("#vnr-cam-cancel").addEventListener("click",()=>{q(),this.captureActive=!1,this.dismiss(),a("User cancelled")});const ue=()=>{this.captureActive&&(U.style.display="flex",U.innerHTML=`
|
|
445
764
|
<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
765
|
<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=`
|
|
766
|
+
`,C.disabled=!0,navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:l}},audio:!1}).then(re=>{if(!this.captureActive){re.getTracks().forEach(he=>he.stop());return}return h=re,A.captureStream=re,b.srcObject=re,b.play().catch(()=>{})}).then(()=>{if(!(!this.captureActive||!h)){if(U.style.display="none",!y.querySelector(".vnr-live-badge")){const re=document.createElement("div");re.className="vnr-live-badge",re.innerHTML='<span class="vnr-live-dot"></span>LIVE',y.querySelector("#vnr-cam-wrap").appendChild(re)}E.checked=u,ce()}}).catch(()=>{this.captureActive&&(this.notifyCameraPermissionDenied(i,e.toolCallId),this.fillCameraPermissionPrompt(U,{onRetry:ue,onDismiss:()=>{q(),this.captureActive=!1,this.dismiss(),a("Camera permission denied","cancelled")}}))}))};ue();function ce(){m&&(clearInterval(m),m=null,A.captureLivenessInterval=null),E.checked?(I.style.display="block",L.style.display="block",C.disabled=!0,ne()):(I.style.display="none",L.style.display="none",C.disabled=!1)}E.addEventListener("change",ce);function ne(){let re=null;const he=[];let Se=1,Re=0,Je=0,mt=0,At=!1;const qt=document.createElement("canvas"),Un=qt.getContext("2d");qt.width=80,qt.height=60,_.style.width="0%",_.style.backgroundColor="#6366f1",P.style.color="#6366f1",P.innerText="0%",L.style.borderColor="rgba(255,255,255,0.45)",L.style.boxShadow="0 0 0 9999px rgba(15,23,42,0.6)",O.innerText="Align your face in center",O.style.color="#fff",m=setInterval(()=>{if(!h||b.paused||b.ended)return;Un.drawImage(b,0,0,80,60);const Yt=Un.getImageData(0,0,80,60).data;if(re){let kt=0;for(let ot=0;ot<Yt.length;ot+=4)kt+=Math.abs(Yt[ot]-re[ot]),kt+=Math.abs(Yt[ot+1]-re[ot+1]),kt+=Math.abs(Yt[ot+2]-re[ot+2]);const un=kt/(Yt.length/4*3);if(Je===0){mt++,he.push(un);const ot=Math.min(100,Math.round(mt/15*100));_.style.width=`${ot*.3}%`,P.innerText=`${Math.round(ot*.3)}%`,O.innerText="Hold still to calibrate…",O.style.color="#a5b4fc",mt>=15&&(Se=he.reduce((Zo,ec)=>Zo+ec,0)/he.length,Se<.2&&(Se=.2),Je=1,mt=0,_.style.width="30%",P.innerText="30%")}else if(Je===1){O.innerText="Now blink or turn head slightly",O.style.color="#ffd2d2";const ot=Math.max(3,Se*3.5);if(un>ot&&un<30){Re+=15,Re>70&&(Re=70,At=!0);const vr=30+Re;_.style.width=`${vr}%`,P.innerText=`${vr}%`}else At&&un<=ot*1.5&&(Je=2,_.style.width="100%",_.style.backgroundColor="#10b981",P.innerText="100%",P.style.color="#10b981",O.innerText="✓ Liveness Verified! Click Capture & Send.",O.style.color="#10b981",L.style.borderColor="#10b981",L.style.boxShadow="0 0 0 9999px rgba(16,185,129,0.2)",C.disabled=!1,m&&(clearInterval(m),m=null,A.captureLivenessInterval=null))}}re=Yt},100),A.captureLivenessInterval=m}C.addEventListener("click",async()=>{if(!h||b.videoWidth===0)return;B.width=b.videoWidth,B.height=b.videoHeight,B.getContext("2d").drawImage(b,0,0),q(),y.querySelector("#vnr-cam-wrap").setAttribute("style","display:none"),y.querySelector(".vnr-liveness-toggle-wrap")&&(y.querySelector(".vnr-liveness-toggle-wrap").style.display="none"),I.style.display="none",C.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 he=await new Promise(Re=>B.toBlob(Je=>Re(Je),"image/jpeg",.85));if(!he)throw new Error("Capture failed");const Se=new File([he],`capture-${Date.now()}.jpg`,{type:"image/jpeg"});if(i&&typeof i.uploadMedia=="function"){const{media_id:Re,url:Je}=await i.uploadMedia(Se,d,"User captured a photo via camera");w.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ Photo sent!</div>',setTimeout(()=>{this.dismiss(),s({file_name:Se.name,file_type:Se.type,file_size:Se.size,media_id:Re,url:Je,message:"User captured and sent a photo."})},400)}else{const Re=B.toDataURL("image/jpeg",.85);w.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ Photo ready!</div>',setTimeout(()=>{this.dismiss(),s({file_name:Se.name,data_url:Re,message:"User captured a photo."})},400)}}catch(he){w.innerHTML=`<div class="vnr-center" style="color:#ef4444">${(he==null?void 0:he.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=>{Jc(),n(d,{status:"cancelled"})};if(typeof document>"u"){l("Page clip is only available in browser environments");return}Kk({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:R.ClipRegion,region:d.region,viewport:d.viewport,pixel_size:d.pixelSize,prompt:A||void 0,message:h},t)}catch(m){const g=m instanceof Error?m.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=ix(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=Tr();h.setVoiceState("processing"),h.dismissPointing(),h.hide(),(async()=>{let m=()=>{};try{const g=u&&this.lsStream?this.lsStream:null,y=u&&this.lsVideo?this.lsVideo:null,b=Number.isFinite(c)?Math.min(1,Math.max(.4,c)):.72,{capture:B,release:U}=await dx({maxWidth:o,quality:b,mode:g?"display":d,existingStream:g,existingVideo:y});m=U;const w=vu({maxElements:80}),C=zo(w,B.widthPx,B.heightPx),E=rx(w,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 I=Ix({prompt:A||void 0,captures:[{label:B.label,widthPx:B.widthPx,heightPx:B.heightPx,viewportWidthCss:B.viewportWidthCss,viewportHeightCss:B.viewportHeightCss,isPrimary:B.isPrimary}],layoutSummary:E});h.setVoiceState("idle"),h.show();const _={preset_id:R.ScreenVision,message:I,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:b,display_surface:B.displaySurface,capture_label:B.label,page_layout:C};if(!i){t({status:"success",..._});return}await this.completeBlockingMediaTool(i,B.blob,a,_,t,{notifyVision:{message:I,contentType:"image/jpeg"}})}catch(g){h.setVoiceState("idle");const y=g instanceof Error?g.message:"Screen vision capture failed";n(y,{status:"cancelled"})}finally{m()}})()}renderPointAt(e,t,n){const i=e.args??{},s=e.clientFields??{},a=Tr(),A=a.getCaptureContext(),o=String(i.point_tag??s.point_tag??"").trim();if(o){const m=Fx(o);if(m.coordinate){const g=kf({label:m.elementLabel??void 0,modelX:m.coordinate.x,modelY:m.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||m.elementLabel||void 0,screenshotWidth:g.screenshotWidth,screenshotHeight:g.screenshotHeight,viewportWidthCss:g.viewportWidthCss,viewportHeightCss:g.viewportHeightCss}),t({status:"success",preset_id:R.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:R.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=kf({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:R.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=Tr(),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=tv(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 b=Number(d);u=Number.isFinite(b)&&b>0?b:null}const h=i.animate_ms??s.animate_ms,m=Number(h),g=i.allow_overlap===!0||s.allow_overlap===!0,y=a.drawOnScreen(l,{clear:o,ttlMs:u,animateMs:Number.isFinite(m)&&m>0?m: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(y.rejected||y.overlapDetected){t({status:"error",overlap_detected:!0,preset_id:R.DrawOnScreen,drawn:0,message:y.message??"Draw rejected: overlap detected",conflicts:y.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:R.DrawOnScreen,drawn:y.drawn,message:`Drew ${y.drawn} shape(s) on screen (${l.map(b=>b.op).join(", ")})`})}renderClearScreenDraw(e,t,n){Tr().clearDrawings(),t({status:"success",preset_id:R.ClearScreenDraw,message:"Screen annotations cleared"})}renderHighlightOnScreen(e,t,n){const i=e.args??{},s=e.clientFields??{},a=Tr(),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=Uf({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 w=document.querySelector(d.css_selector);w==null||w.scrollIntoView({behavior:"smooth",block:"center"})}catch{}const u=i.clear===!0||s.clear===!0,h=i.ttl_ms??s.ttl_ms;let m;if(h!=null&&h!==""){const w=Number(h);m=Number.isFinite(w)&&w>0?w:null}const g=i.animate_ms??s.animate_ms,y=Number(g),b=i.allow_overlap===!0||s.allow_overlap===!0,B=i.point_at!==!1&&s.point_at!==!1,U=a.drawOnScreen([d.command],{clear:u,ttlMs:m,animateMs:Number.isFinite(y)&&y>0?y:void 0,allowOverlap:b,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(U.rejected||U.overlapDetected){t({status:"error",overlap_detected:!0,preset_id:R.HighlightOnScreen,drawn:0,message:U.message??"Highlight rejected: overlap detected",conflicts:U.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:R.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,R.Upload,t,n);const s=w=>{this.clearActiveModalPreset(),t({status:"success",preset_id:R.Upload,...w})},a=w=>{this.clearActiveModalPreset(),n(w,{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
767
|
<button class="vnr-close-btn" aria-label="Close">
|
|
454
768
|
<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
769
|
</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">${
|
|
770
|
+
<h2 class="vnr-title" style="padding-right:32px">${A}</h2>
|
|
771
|
+
<p style="margin:0 0 14px;font-size:13px;color:#6b7280;line-height:1.5">${o}</p>
|
|
458
772
|
<div class="vnr-dropzone" id="vnr-drop-zone">
|
|
459
773
|
<div style="font-size:32px;margin-bottom:8px">📁</div>
|
|
460
774
|
<p style="margin:0 0 4px;font-weight:600;color:#374151;font-size:14px">Drag & drop here</p>
|
|
@@ -462,7 +776,7 @@ ${d}`,f={layout:u,elements:u.elements,element_count:u.elements.length,layout_sum
|
|
|
462
776
|
<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
777
|
<p style="margin:12px 0 0;font-size:11px;color:#9ca3af">Images, PDF, CSV, Docs · Max 10 MB</p>
|
|
464
778
|
</div>
|
|
465
|
-
<input id="vnr-file-input" type="file" accept="${
|
|
779
|
+
<input id="vnr-file-input" type="file" accept="${l}" style="display:none">
|
|
466
780
|
<div id="vnr-file-preview" style="display:none;border:1px solid #e5e7eb;border-radius:12px;padding:14px;background:#f9fafb"></div>
|
|
467
781
|
<div id="vnr-upload-status" style="display:none"></div>
|
|
468
782
|
<div class="vnr-actions" style="margin-top:14px">
|
|
@@ -472,18 +786,17 @@ ${d}`,f={layout:u,elements:u.elements,element_count:u.elements.length,layout_sum
|
|
|
472
786
|
Upload & Send
|
|
473
787
|
</button>
|
|
474
788
|
</div>
|
|
475
|
-
`,
|
|
789
|
+
`,u.appendChild(h);const m=h.querySelector("#vnr-drop-zone"),g=h.querySelector("#vnr-file-input"),y=h.querySelector("#vnr-file-preview"),b=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 U=w=>{d=w,m.style.display="none";const C=w.type.startsWith("image/")?"🖼️":w.type.includes("pdf")?"📄":"📁",E=(w.size/1024).toFixed(1);y.style.display="block",y.innerHTML=`
|
|
476
790
|
<div style="display:flex;align-items:center;gap:10px">
|
|
477
|
-
<span style="font-size:28px">${
|
|
791
|
+
<span style="font-size:28px">${C}</span>
|
|
478
792
|
<div style="flex:1;min-width:0">
|
|
479
793
|
<p style="margin:0;font-weight:600;font-size:13px;color:#111;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${w.name}</p>
|
|
480
|
-
<p style="margin:3px 0 0;font-size:11px;color:#6b7280">${w.type||"unknown"} · ${
|
|
794
|
+
<p style="margin:3px 0 0;font-size:11px;color:#6b7280">${w.type||"unknown"} · ${E} KB</p>
|
|
481
795
|
</div>
|
|
482
796
|
<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
797
|
<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
798
|
</button>
|
|
485
799
|
</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;
|
|
800
|
+
`,y.querySelector("#vnr-remove-file").addEventListener("click",()=>{d=null,y.style.display="none",m.style.display="block",B.disabled=!0}),B.disabled=!1};m.addEventListener("click",()=>g.click()),m.addEventListener("dragover",w=>{w.preventDefault(),m.classList.add("drag")}),m.addEventListener("dragleave",()=>m.classList.remove("drag")),m.addEventListener("drop",w=>{var E;w.preventDefault(),m.classList.remove("drag");const C=(E=w.dataTransfer)==null?void 0:E.files[0];C&&U(C)}),g.addEventListener("change",()=>{var C;const w=(C=g.files)==null?void 0:C[0];w&&U(w)}),B.addEventListener("click",async()=>{if(!d)return;const w=d;m.style.display="none",y.style.display="none",b.style.display="block",b.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:E}=await i.uploadMedia(w,c,`User uploaded: ${w.name}`);b.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ File sent!</div>',setTimeout(()=>{this.dismiss(),s({file_name:w.name,file_type:w.type,file_size:w.size,media_id:C,url:E,message:`User uploaded: ${w.name}`})},400)}else{const C=new FileReader;C.onload=E=>{b.innerHTML='<div class="vnr-center" style="color:#22c55e">✓ File ready!</div>',setTimeout(()=>{this.dismiss(),s({file_name:w.name,file_type:w.type,file_size:w.size,data_url:E.target.result,message:`User uploaded: ${w.name}`})},400)},C.readAsDataURL(w)}}catch(C){b.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){Ep(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:R.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 b=Tr().getCaptureContext(),B=Uf({label:A||void 0,element_id:o||void 0,staleLayoutElements:b==null?void 0:b.layoutElements,captureCtx:b});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,m=d.style.boxShadow,g=d.style.transition,y=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=m,d.style.transition=g,d.style.scrollMarginTop=y},l),t({status:"success",preset_id:R.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)},R.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:R.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)},R.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 m=A.querySelector("select");if(m instanceof HTMLSelectElement){if(!this.setNativeSelectValue(m,t,n)){a(`No matching option in #${e} select`);return}o=m.value,c=((h=(u=m.options[m.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:R.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)},R.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:R.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=KE[this.boardSizePreset],n=this.boardViewMode==="reduced"?.5:1,i=NE*n,s=vp(t.maxWidth,i),a=vp(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===ys[ys.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=ys.indexOf(this.boardSizePreset);t<0||t>=ys.length-1||(this.boardSizePreset=ys[t+1],$E(this.boardSizePreset),this.applyBoardSizeToModal(e),this.applyBoardLayoutMode(this.getBoardOverlay(),e))}syncBoardResizeButton(e){if(!e)return;const t=this.boardViewMode==="reduced";e.innerHTML=t?OE:LE,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=gp;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=gp,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=HE,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)}ml(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&&(ml(a),this.wireChalkboardChrome(a,e),this.revealBoardUi(a)),t}if(tE(),!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",ml(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===R.WriteLatexText){const s=String(n.latex_text||i.latex_text||n.text_to_type||i.text_to_type||n.text||i.text||"");return Z8(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:R.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:R.TypeText})};if(!A){o({navigated:!1});return}this.withElementRoute(A,this.parseDomTarget(a),n,o,R.TypeText)}executeTypeText(e,t,n,i,s,a){const A=e.args||{},o=e.clientFields||{},c=(a==null?void 0:a.resultPresetId)??R.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),m=_=>{const P={..._,...s.route?{route:s.route}:{},...s.navigated?{navigated_to_route:s.route}:{}};document.querySelector(".vnr-whiteboard-modal")&&(P.board_snapshot=this.getBoardSnapshot()),t(P)};if(c===R.WriteLatexText){const _=String(A.latex_text||o.latex_text||A.text_to_type||o.text_to_type||""),P=hE(_);if(!P.ok){vs("Board:LaTeX","Validation failed — board not updated",P.errors),m(fE(P.errors,P.agent_message,this.chalkboardContent.length));return}d=P.normalized}let g=null;i&&(g=this.findDomTarget(this.parseDomTarget(i)));const y=()=>{vs("Board:Type",l?"Writing LaTeX on chalkboard":"Using chalkboard fallback",{toolCallId:e.toolCallId,textPreview:d.slice(0,80),sessionChars:this.chalkboardContent.length});const _=this.ensureChalkboardTextarea(()=>n("User dismissed typing popup"));if(!_){m({status:"error",message:"Could not open chalkboard"});return}_.focus();const P=d;let L=this.chalkboardContent||"";const O=L?`
|
|
801
|
+
${P}`:P,q=L+O,ue=this.activePresetGeneration,ce=u<=0,ne=()=>{this.chalkboardContent=q,this.paintChalkboardSurface(_,q),m({status:"success",preset_id:c,typing_mode:"append",message:c===R.WriteLatexText?"Wrote LaTeX on chalkboard":"Typed on chalkboard",whiteboard_content:this.chalkboardContent,text_written:this.chalkboardContent,latex_written:c===R.WriteLatexText?this.chalkboardContent:void 0,...this.buildBoardVerification()})};this.activeBoardProgress={ctx:e,mode:"type",textAtStart:L,plannedUnits:O.length,unitsDone:0},ce?(this.paintChalkboardSurface(_,q),this.syncBoardProgressUnits(O.length),vs("Board:Type","Chalkboard typed (instant)",{chars:this.chalkboardContent.length,preview:this.chalkboardContent.slice(0,120)}),ne()):oE({surface:_,initialText:L,appendText:O,delayMs:u,schedule:(re,he)=>this.scheduleBoardAnim(re,he),shouldContinue:()=>ue===this.activePresetGeneration&&document.body.contains(_),onSourceChar:re=>{this.chalkboardContent=L+O.slice(0,re),this.syncBoardProgressUnits(re)},onComplete:()=>{ue===this.activePresetGeneration&&(this.chalkboardContent=q,this.syncBoardProgressUnits(O.length),ne())}})};if(l||!g){y();return}if(g.focus(),!(g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||"value"in g)){g.textContent=d,m({status:"success"});return}const B=g;let U=B.value||"";if(h==="replace"&&U&&(this.setNativeInputValue(B,""),U=""),u<=0){B.value=U+d,this.dispatchInputChange(B),m({status:"success",preset_id:R.TypeText,typing_mode:h,message:`Typed into ${i||"input"}`});return}let w=U,C=0;const E=this.activePresetGeneration,I=()=>{E===this.activePresetGeneration&&document.body.contains(B)&&(C<d.length?(w+=d[C],B.value=w,B.dispatchEvent(new Event("input",{bubbles:!0})),C++,this.scheduleBoardAnim(I,u)):(B.dispatchEvent(new Event("change",{bubbles:!0})),m({status:"success",preset_id:R.TypeText,typing_mode:h,message:`Typed into ${i||"input"}`})))};I()}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,R.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=w=>{t({...w,...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 w=this.eraseChalkboardInMemory(o,c);this.chalkboardContent=w;const C=this.getChalkboardSurface();C&&this.paintChalkboardSurface(C,w),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 w=u.closest(".vnr-whiteboard-modal");w&&this.wireChalkboardCloseButton(w,()=>n("User dismissed chalkboard"));const C=u,E=this.chalkboardContent,I=o==="words"?this.eraseLastWords(E,c):"";if(l<=0){this.paintChalkboardSurface(C,I);const q=Math.max(0,E.length-I.length);this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:E,plannedUnits:q,unitsDone:q},d({status:"success"});return}const _=this.activePresetGeneration,P=Math.max(0,E.length-I.length);this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:E,plannedUnits:P,unitsDone:0};let L=E;const O=()=>{_===this.activePresetGeneration&&document.body.contains(C)&&(L.length>I.length?(L=L.slice(0,-1),this.paintChalkboardSurface(C,L),this.syncBoardProgressUnits(E.length-L.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 w=u.textContent||"";u.textContent=this.eraseLastWords(w,c)}else u.textContent="";d({status:"success"});return}const h=u,m=h.value||"";let g="";if(o==="words"?g=this.eraseLastWords(m,c):g="",l<=0){if(h.value=g,h.classList.contains("vnr-whiteboard-textarea")){this.chalkboardContent=g;const w=Math.max(0,m.length-g.length);this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:m,plannedUnits:w,unitsDone:w}}h.dispatchEvent(new Event("input",{bubbles:!0})),h.dispatchEvent(new Event("change",{bubbles:!0})),d({status:"success"});return}const y=this.activePresetGeneration,b=h.classList.contains("vnr-whiteboard-textarea"),B=Math.max(0,m.length-g.length);b&&(this.activeBoardProgress={ctx:e,mode:"erase",textAtStart:m,plannedUnits:B,unitsDone:0});const U=()=>{y===this.activePresetGeneration&&document.body.contains(h)&&(h.value.length>g.length?(h.value=h.value.slice(0,-1),b&&(this.chalkboardContent=h.value,this.syncBoardProgressUnits(m.length-h.value.length)),h.dispatchEvent(new Event("input",{bubbles:!0})),h.classList.contains("vnr-whiteboard-textarea")&&(h.scrollTop=h.scrollHeight),this.scheduleBoardAnim(U,Math.max(10,l/2))):(h.dispatchEvent(new Event("change",{bubbles:!0})),d({status:"success"})))};U()}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(`
|
|
802
|
+
`),o=Math.max(a,A);if(o===-1){i="";break}else i=i.slice(0,o).trimEnd()}return i}}function Bp(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 jE=Rt.forwardRef(function({client:e,toolCall:t=null,onCustomTool:n},i){const s=Rt.useRef(null),a=Rt.useRef(new Set),A=Rt.useRef(new Set),o=Rt.useRef([]),c=Rt.useRef(!1);Rt.useEffect(()=>(s.current=new JE(null),()=>{var h;(h=s.current)==null||h.resetBoardSession()}),[]),Rt.useEffect(()=>{const h=m=>{var y;const g=m.detail||{};(y=s.current)==null||y.abortBoardTools(g.reason||"Server interrupted",g.toolCallId)};return window.addEventListener(mp,h),()=>window.removeEventListener(mp,h)},[]);const l=Rt.useCallback(()=>{if(c.current||!s.current||!e)return;const h=o.current.shift();if(!h)return;c.current=!0;const m=h.data||h,g=m.arguments||m.args,y=m.client_fields||{},b=Id(y,g,m.name||m.tool_name),B=Bp(h),U=()=>{c.current=!1,o.current.length>0&&l()};if(!b||!Kn(b)){n&&n(h),U();return}!by(b)&&e.sendContextUpdate&&B&&(e.sendToolResult(B,{status:"popup_shown",message:`The UI preset ${b} 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:b})),s.current.handle(h,C=>{var I,_;if(!B){U();return}const E=typeof C=="string"?{response:C}:C;if(gl(b)){U();return}if(Gu(b)){(E==null?void 0:E.status)!=="cancelled"&&!a.current.has(B)&&(a.current.add(B),e.sendToolResult(B,E)),U();return}if(vl(b)){if((E==null?void 0:E.status)==="cancelled"){U();return}(I=e.triggerActionInterrupt)==null||I.call(e);const P=zu(b,m.name||m.tool_name||"",y);(_=e.sendActionTrigger)==null||_.call(e,P,E),U();return}e.triggerActionInterrupt&&e.triggerActionInterrupt(),e.sendActionTrigger?e.sendActionTrigger(zu(b,m.name||m.tool_name||"",y),E):e.sendToolResult(B,E),U()},(C,E)=>{var I,_;if(!B){U();return}if(Gu(b)){const P=(E==null?void 0:E.status)??"cancelled",L=String(y.target_url||(typeof g=="object"&&g?g.target_url:"")||"");a.current.has(B)||(a.current.add(B),e.sendToolResult(B,b===R.Navigate?((I=s.current)==null?void 0:I.getNavigateTerminalResult(P,C,L||void 0))??{status:P,reason:C||"Navigation cancelled",preset_id:b,target_url:L||void 0}:((_=s.current)==null?void 0:_.getBoardTerminalResult(P,C,b))??{status:P,reason:C||"User dismissed",preset_id:b})),U();return}if(gl(b))try{e.sendToolResult(B,{status:"cancelled",reason:C||"User dismissed",preset_id:b})}catch{}else if(vl(b))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:b})}catch{}else typeof e.sendToolError=="function"&&e.sendToolError(B,C||"User cancelled the action");U()},e)||(n&&n(h),U())},[e,n]),d=Rt.useCallback(h=>{const m=Bp(h);if(m){if(A.current.has(m))return;A.current.add(m)}o.current.push(h),l()},[l]),u=Rt.useCallback(()=>{var h,m;o.current=[],c.current=!1,A.current.clear(),a.current.clear(),(h=s.current)!=null&&h.hasActiveBoardSession()||(m=s.current)==null||m.dismiss()},[]);return Rt.useImperativeHandle(i,()=>({enqueueToolCall:d,clearQueue:u}),[d,u]),Rt.useEffect(()=>{t&&d(t)},[t,d]),Rt.useEffect(()=>{e||u()},[e,u]),null});class YE{constructor(e){D(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 ZE{createRemotePlayer(e){return new YE(e)}}class eU{async getUserAudio(e){return navigator.mediaDevices.getUserMedia({audio:e})}stopStream(e){e.getTracks().forEach(t=>t.stop())}}class tU{create(e){return new RTCPeerConnection({iceServers:e.iceServers,iceTransportPolicy:e.iceTransportPolicy??"all"})}}class nU{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);xp(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 Cp;const ly={supportsAudioEndedEvent:!0,supportsScreenShare:typeof navigator<"u"&&typeof((Cp=navigator.mediaDevices)==null?void 0:Cp.getDisplayMedia)=="function",supportsDom:typeof document<"u",supportsHtmlAudio:typeof Audio<"u",supportsCustomElements:typeof customElements<"u",supportsLocalStorage:typeof localStorage<"u",supportsBroadcastChannel:typeof BroadcastChannel<"u"},dy={name:"browser",callType:"web",runtimeName:"browser",callIdPrefix:"web_",capabilities:ly,audio:new ZE,media:new eU,peer:new tU,dataChannel:new nU};function rU(r){return new FA({...r,runtime:dy})}exports.LiveKitVoiceClient=HB;exports.PresetRenderer=jE;exports.RouteContextTracker=Up;exports.VaniraClient=FA;exports.browserCapabilities=ly;exports.browserRuntime=dy;exports.createBrowserClient=rU;exports.getCurrentPageRoute=ws;exports.hasContinueSession=Ey;exports.loadContinueSession=UA;exports.markAgentNavigation=Ep;exports.normalizePageRoute=Qd;exports.saveCallSession=kp;
|