termdock 1.4.143 → 1.4.144

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.
Files changed (66) hide show
  1. package/dist/client/assets/{ModelPreview-CxvutFIK.js → ModelPreview-WiyzRLKE.js} +1 -1
  2. package/dist/client/assets/{abnfDiagram-VRR7QNED-DHcASV7X.js → abnfDiagram-VRR7QNED--xrezCcc.js} +1 -1
  3. package/dist/client/assets/{arc-Bg35j3Cb.js → arc-rO2e2Jz9.js} +1 -1
  4. package/dist/client/assets/{architectureDiagram-ZJ3FMSHR-D_VdG4Mw.js → architectureDiagram-ZJ3FMSHR-4HkjAWvC.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-677ZJIJ3-0Vz1QVcO.js → blockDiagram-677ZJIJ3-CmN9efDw.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-LMCZKHZV-BMXJjuu6.js → c4Diagram-LMCZKHZV-DvOXzeUj.js} +1 -1
  7. package/dist/client/assets/channel-DsyBSNEX.js +1 -0
  8. package/dist/client/assets/{chunk-2Q5K7J3B-CbjbBkfO.js → chunk-2Q5K7J3B-DJk4NA7U.js} +1 -1
  9. package/dist/client/assets/{chunk-32BRIVSS-BpVntjBJ.js → chunk-32BRIVSS-uwKjA2pz.js} +1 -1
  10. package/dist/client/assets/{chunk-5VM5RSS4-C6hs24gE.js → chunk-5VM5RSS4-DAqZVdCz.js} +1 -1
  11. package/dist/client/assets/{chunk-EX3LRPZG-KwROs64d.js → chunk-EX3LRPZG-C3NMPQMe.js} +1 -1
  12. package/dist/client/assets/{chunk-JWPE2WC7-BmoUFQXA.js → chunk-JWPE2WC7-BT9lSTXn.js} +1 -1
  13. package/dist/client/assets/{chunk-MOJQB5TN-Df1Oz5Nr.js → chunk-MOJQB5TN-3dxfcwps.js} +1 -1
  14. package/dist/client/assets/{chunk-RYQCIY6F-CHUd3mxO.js → chunk-RYQCIY6F-CifNU8fz.js} +1 -1
  15. package/dist/client/assets/{chunk-V7JOEXUC-YVvBLcl5.js → chunk-V7JOEXUC-DCUd3gO9.js} +1 -1
  16. package/dist/client/assets/{chunk-VR4S4FIN-CLqquFUE.js → chunk-VR4S4FIN-RHjufAkn.js} +1 -1
  17. package/dist/client/assets/{chunk-XXDRQBXY-BAgiiEOc.js → chunk-XXDRQBXY-BELkcUP_.js} +1 -1
  18. package/dist/client/assets/classDiagram-OUVF2IWQ-CQQXrpB6.js +1 -0
  19. package/dist/client/assets/classDiagram-v2-EOCWNBFH-CQQXrpB6.js +1 -0
  20. package/dist/client/assets/{cose-bilkent-JH36ORCC-BmZCOXiQ.js → cose-bilkent-JH36ORCC-Bnsb2K69.js} +1 -1
  21. package/dist/client/assets/{cynefin-VYW2F7L2-CC5TyhBj.js → cynefin-VYW2F7L2-cuW4drBu.js} +1 -1
  22. package/dist/client/assets/{cynefinDiagram-TSTJHNR4-aEhSla3t.js → cynefinDiagram-TSTJHNR4-DuriyFz2.js} +1 -1
  23. package/dist/client/assets/{dagre-VKFMJZFB-BrEaTd0w.js → dagre-VKFMJZFB-JIqvZV52.js} +1 -1
  24. package/dist/client/assets/{diagram-FQU43EPY-CNmIY5Q9.js → diagram-FQU43EPY-CVIRa53c.js} +1 -1
  25. package/dist/client/assets/{diagram-G47NLZAW-62RfSsyi.js → diagram-G47NLZAW-CFDHe4mS.js} +1 -1
  26. package/dist/client/assets/{diagram-NH7WQ7WH-XQRc7b4a.js → diagram-NH7WQ7WH-DkTviK51.js} +1 -1
  27. package/dist/client/assets/{diagram-OA4YK3LP-cmV3HDEG.js → diagram-OA4YK3LP-BS-6GpKd.js} +1 -1
  28. package/dist/client/assets/{diagram-WEI45ONY-DagWK4e8.js → diagram-WEI45ONY-Dr8dnpg4.js} +1 -1
  29. package/dist/client/assets/{ebnfDiagram-CCIWWBDH-Dg94UDMX.js → ebnfDiagram-CCIWWBDH-CitYeg8f.js} +1 -1
  30. package/dist/client/assets/{erDiagram-Q63AITRT-Dq-zxfcJ.js → erDiagram-Q63AITRT-DDyaUz01.js} +1 -1
  31. package/dist/client/assets/{flowDiagram-23GEKE2U-BAUtnuYa.js → flowDiagram-23GEKE2U-B-bshT5O.js} +1 -1
  32. package/dist/client/assets/{ganttDiagram-NO4QXBWP-G5ULaEaU.js → ganttDiagram-NO4QXBWP-CLkMRAzX.js} +1 -1
  33. package/dist/client/assets/{gitGraphDiagram-IHSO6WYX-BkH5zmj9.js → gitGraphDiagram-IHSO6WYX-B7J5UD_K.js} +1 -1
  34. package/dist/client/assets/{index-DbrBXfGs.js → index-KjydEHPX.js} +5 -5
  35. package/dist/client/assets/{infoDiagram-FWYZ7A6U-Bu9KYuWQ.js → infoDiagram-FWYZ7A6U-CVVyUUnA.js} +1 -1
  36. package/dist/client/assets/{ishikawaDiagram-FXEZZL3T-DT9n54-L.js → ishikawaDiagram-FXEZZL3T-D68cTzA2.js} +1 -1
  37. package/dist/client/assets/{journeyDiagram-5HDEW3XC-CLipZnVY.js → journeyDiagram-5HDEW3XC-DPSaFh2W.js} +1 -1
  38. package/dist/client/assets/{kanban-definition-HUTT4EX6-Dl0TVRt6.js → kanban-definition-HUTT4EX6-BIr6IxUk.js} +1 -1
  39. package/dist/client/assets/{linear-CkdmNGao.js → linear-C6Wd81uO.js} +1 -1
  40. package/dist/client/assets/{mermaid.core-HyKj4scx.js → mermaid.core-mk9uZjla.js} +4 -4
  41. package/dist/client/assets/{mindmap-definition-LN4V7U3C-C5XCP9N4.js → mindmap-definition-LN4V7U3C-BE8Mui6f.js} +1 -1
  42. package/dist/client/assets/{pegDiagram-2B236MQR-B4bKVm0_.js → pegDiagram-2B236MQR-gngyknJa.js} +1 -1
  43. package/dist/client/assets/{pieDiagram-ENE6RG2P-U1DfEPYu.js → pieDiagram-ENE6RG2P-Djz2XpYO.js} +1 -1
  44. package/dist/client/assets/{quadrantDiagram-ABIIQ3AL-CLaBBQqD.js → quadrantDiagram-ABIIQ3AL-D0egu-tM.js} +1 -1
  45. package/dist/client/assets/{railroadDiagram-RFXS5EU6-C3QQz0HH.js → railroadDiagram-RFXS5EU6-Cre6bOW5.js} +1 -1
  46. package/dist/client/assets/{requirementDiagram-TGXJPOKE-C8X5ZWaN.js → requirementDiagram-TGXJPOKE-sAdER6o1.js} +1 -1
  47. package/dist/client/assets/{sankeyDiagram-HTMAVEWB-DwSNvnR7.js → sankeyDiagram-HTMAVEWB-CymO2Qww.js} +1 -1
  48. package/dist/client/assets/{sequenceDiagram-DBY2YBRQ-CzgTOnAe.js → sequenceDiagram-DBY2YBRQ-CHuEMDi2.js} +1 -1
  49. package/dist/client/assets/{sizeCapture-X5ZJPWSS-BV3APpvt.js → sizeCapture-X5ZJPWSS-BNRhvlMZ.js} +1 -1
  50. package/dist/client/assets/{stateDiagram-2N3HPSRC-C4h9ebFf.js → stateDiagram-2N3HPSRC-KcCNL5S8.js} +1 -1
  51. package/dist/client/assets/stateDiagram-v2-6OUMAXLB-Bc6_Hb4G.js +1 -0
  52. package/dist/client/assets/{swimlanes-5IMT3BWC-CL_sIV2X.js → swimlanes-5IMT3BWC-CDCHb6ke.js} +2 -2
  53. package/dist/client/assets/swimlanesDiagram-G3AALYLV-D6EIq196.js +8 -0
  54. package/dist/client/assets/{timeline-definition-FHXFAJF6-Dksvv2uR.js → timeline-definition-FHXFAJF6-CtX6T2hZ.js} +1 -1
  55. package/dist/client/assets/{vennDiagram-L72KCM5P-3ALKiaL0.js → vennDiagram-L72KCM5P-DPEUQoP-.js} +1 -1
  56. package/dist/client/assets/{wardleyDiagram-EHGQE667-DCkQmkab.js → wardleyDiagram-EHGQE667-T4sp_0HX.js} +1 -1
  57. package/dist/client/assets/{xychartDiagram-FW5EYKEG-OI_37JBk.js → xychartDiagram-FW5EYKEG-ZnSTg1Q0.js} +1 -1
  58. package/dist/client/index.html +1 -1
  59. package/dist/client/sw.js +1 -1
  60. package/package.json +1 -1
  61. package/runtime-manifest.json +1 -1
  62. package/dist/client/assets/channel-Cb-5EBFH.js +0 -1
  63. package/dist/client/assets/classDiagram-OUVF2IWQ-BMAMeit_.js +0 -1
  64. package/dist/client/assets/classDiagram-v2-EOCWNBFH-BMAMeit_.js +0 -1
  65. package/dist/client/assets/stateDiagram-v2-6OUMAXLB-DR2cNRUD.js +0 -1
  66. package/dist/client/assets/swimlanesDiagram-G3AALYLV-nZ2rfZS2.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Ca-rq7yX.js","assets/react-XDCjal2T.js","assets/ModelPreview-CxvutFIK.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-HyKj4scx.js","assets/purify.es-CC4Brkr_.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Ca-rq7yX.js","assets/react-XDCjal2T.js","assets/ModelPreview-WiyzRLKE.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-mk9uZjla.js","assets/purify.es-CC4Brkr_.js"])))=>i.map(i=>d[i]);
2
2
  import{r as $g,a as j_,g as wS}from"./react-XDCjal2T.js";import{b as x,R as D,r as fi,a as P_}from"./dnd-BCFAPC0L.js";import{L as B_,l as F_}from"./terminal-C7X98Amf.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var q1={exports:{}},xf={};var g5;function O_(){if(g5)return xf;g5=1;var e=$g(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(c,u,f){var p,g={},y=null,v=null;f!==void 0&&(y=""+f),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(v=u.ref);for(p in u)r.call(u,p)&&!i.hasOwnProperty(p)&&(g[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)g[p]===void 0&&(g[p]=u[p]);return{$$typeof:t,type:c,key:y,ref:v,props:g,_owner:s.current}}return xf.Fragment=n,xf.jsx=a,xf.jsxs=a,xf}var x5;function Q_(){return x5||(x5=1,q1.exports=O_()),q1.exports}var o=Q_(),Rp={},b5;function $_(){if(b5)return Rp;b5=1;var e=j_();return Rp.createRoot=e.createRoot,Rp.hydrateRoot=e.hydrateRoot,Rp}var H_=$_();const z_=wS(H_);function y5(e){return e!==null&&typeof e=="object"&&"constructor"in e&&e.constructor===Object}function Ny(e={},t={}){const n=["__proto__","constructor","prototype"];Object.keys(t).filter(r=>n.indexOf(r)<0).forEach(r=>{typeof e[r]>"u"?e[r]=t[r]:y5(t[r])&&y5(e[r])&&Object.keys(t[r]).length>0&&Ny(e[r],t[r])})}const SS={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector(){return null},querySelectorAll(){return[]},getElementById(){return null},createEvent(){return{initEvent(){}}},createElement(){return{children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName(){return[]}}},createElementNS(){return{}},importNode(){return null},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function ud(){const e=typeof document<"u"?document:{};return Ny(e,SS),e}const U_={document:SS,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle(){return{getPropertyValue(){return""}}},Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia(){return{}},requestAnimationFrame(e){return typeof setTimeout>"u"?(e(),null):setTimeout(e,0)},cancelAnimationFrame(e){typeof setTimeout>"u"||clearTimeout(e)}};function da(){const e=typeof window<"u"?window:{};return Ny(e,U_),e}function G_(e=""){return e.trim().split(" ").filter(t=>!!t.trim())}function W_(e){const t=e;Object.keys(t).forEach(n=>{try{t[n]=null}catch{}try{delete t[n]}catch{}})}function AS(e,t=0){return setTimeout(e,t)}function Jm(){return Date.now()}function V_(e){const t=da();let n;return t.getComputedStyle&&(n=t.getComputedStyle(e,null)),!n&&e.currentStyle&&(n=e.currentStyle),n||(n=e.style),n}function q_(e,t="x"){const n=da();let r,s,i;const a=V_(e);return n.WebKitCSSMatrix?(s=a.transform||a.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(c=>c.replace(",",".")).join(", ")),i=new n.WebKitCSSMatrix(s==="none"?"":s)):(i=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),r=i.toString().split(",")),t==="x"&&(n.WebKitCSSMatrix?s=i.m41:r.length===16?s=parseFloat(r[12]):s=parseFloat(r[4])),t==="y"&&(n.WebKitCSSMatrix?s=i.m42:r.length===16?s=parseFloat(r[13]):s=parseFloat(r[5])),s||0}function Np(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"}function K_(e){return typeof window<"u"&&typeof window.HTMLElement<"u"?e instanceof HTMLElement:e&&(e.nodeType===1||e.nodeType===11)}function Ua(...e){const t=Object(e[0]);for(let n=1;n<e.length;n+=1){const r=e[n];if(r!=null&&!K_(r)){const s=Object.keys(Object(r)).filter(i=>i!=="__proto__"&&i!=="constructor"&&i!=="prototype");for(let i=0,a=s.length;i<a;i+=1){const c=s[i],u=Object.getOwnPropertyDescriptor(r,c);u!==void 0&&u.enumerable&&(Np(t[c])&&Np(r[c])?r[c].__swiper__?t[c]=r[c]:Ua(t[c],r[c]):!Np(t[c])&&Np(r[c])?(t[c]={},r[c].__swiper__?t[c]=r[c]:Ua(t[c],r[c])):t[c]=r[c])}}}return t}function Od(e,t,n){e.style.setProperty(t,n)}function TS({swiper:e,targetPosition:t,side:n}){const r=da(),s=-e.translate;let i=null,a;const c=e.params.speed;e.wrapperEl.style.scrollSnapType="none",r.cancelAnimationFrame(e.cssModeFrameID);const u=t>s?"next":"prev",f=(g,y)=>u==="next"&&g>=y||u==="prev"&&g<=y,p=()=>{a=new Date().getTime(),i===null&&(i=a);const g=Math.max(Math.min((a-i)/c,1),0),y=.5-Math.cos(g*Math.PI)/2;let v=s+y*(t-s);if(f(v,t)&&(v=t),e.wrapperEl.scrollTo({[n]:v}),f(v,t)){e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[n]:v})}),r.cancelAnimationFrame(e.cssModeFrameID);return}e.cssModeFrameID=r.requestAnimationFrame(p)};p()}function Bc(e,t=""){const n=da(),r=[...e.children];return n.HTMLSlotElement&&e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter(s=>s.matches(t)):r}function Y_(e,t){const n=[t];for(;n.length>0;){const r=n.shift();if(e===r)return!0;n.push(...r.children,...r.shadowRoot?r.shadowRoot.children:[],...r.assignedElements?r.assignedElements():[])}}function X_(e,t){const n=da();let r=t.contains(e);return!r&&n.HTMLSlotElement&&t instanceof HTMLSlotElement&&(r=[...t.assignedElements()].includes(e),r||(r=Y_(e,t))),r}function eg(e){try{console.warn(e);return}catch{}}function Vb(e,t=[]){const n=document.createElement(e);return n.classList.add(...Array.isArray(t)?t:G_(t)),n}function Z_(e,t){const n=[];for(;e.previousElementSibling;){const r=e.previousElementSibling;t?r.matches(t)&&n.push(r):n.push(r),e=r}return n}function J_(e,t){const n=[];for(;e.nextElementSibling;){const r=e.nextElementSibling;t?r.matches(t)&&n.push(r):n.push(r),e=r}return n}function uu(e,t){return da().getComputedStyle(e,null).getPropertyValue(t)}function v5(e){let t=e,n;if(t){for(n=0;(t=t.previousSibling)!==null;)t.nodeType===1&&(n+=1);return n}}function eL(e,t){const n=[];let r=e.parentElement;for(;r;)n.push(r),r=r.parentElement;return n}function w5(e,t,n){const r=da();return e[t==="width"?"offsetWidth":"offsetHeight"]+parseFloat(r.getComputedStyle(e,null).getPropertyValue(t==="width"?"margin-right":"margin-top"))+parseFloat(r.getComputedStyle(e,null).getPropertyValue(t==="width"?"margin-left":"margin-bottom"))}function S5(e,t=""){typeof trustedTypes<"u"?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:n=>n}).createHTML(t):e.innerHTML=t}let K1;function tL(){const e=da(),t=ud();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}function CS(){return K1||(K1=tL()),K1}let Y1;function nL({userAgent:e}={}){const t=CS(),n=da(),r=n.navigator.platform,s=e||n.navigator.userAgent,i={ios:!1,android:!1},a=n.screen.width,c=n.screen.height,u=s.match(/(Android);?[\s\/]+([\d.]+)?/);let f=s.match(/(iPad)(?!\1).*OS\s([\d_]+)/);const p=s.match(/(iPod)(.*OS\s([\d_]+))?/),g=!f&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),y=r==="Win32";let v=r==="MacIntel";const S=["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"];return!f&&v&&t.touch&&S.indexOf(`${a}x${c}`)>=0&&(f=s.match(/(Version)\/([\d.]+)/),f||(f=[0,1,"13_0_0"]),v=!1),u&&!y&&(i.os="android",i.android=!0),(f||g||p)&&(i.os="ios",i.ios=!0),i}function kS(e={}){return Y1||(Y1=nL(e)),Y1}let X1;function rL(){const e=da(),t=kS();let n=!1;function r(){const c=e.navigator.userAgent.toLowerCase();return c.indexOf("safari")>=0&&c.indexOf("chrome")<0&&c.indexOf("android")<0}if(r()){const c=String(e.navigator.userAgent);if(c.includes("Version/")){const[u,f]=c.split("Version/")[1].split(" ")[0].split(".").map(p=>Number(p));n=u<16||u===16&&f<2}}const s=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),i=r(),a=i||s&&t.ios;return{isSafari:n||i,needPerspectiveFix:n,need3dFix:a,isWebView:s}}function _S(){return X1||(X1=rL()),X1}function sL({swiper:e,on:t,emit:n}){const r=da();let s=null,i=null;const a=()=>{!e||e.destroyed||!e.initialized||(n("beforeResize"),n("resize"))},c=()=>{!e||e.destroyed||!e.initialized||(s=new ResizeObserver(p=>{i=r.requestAnimationFrame(()=>{const{width:g,height:y}=e;let v=g,S=y;p.forEach(({contentBoxSize:A,contentRect:C,target:L})=>{L&&L!==e.el||(v=C?C.width:(A[0]||A).inlineSize,S=C?C.height:(A[0]||A).blockSize)}),(v!==g||S!==y)&&a()})}),s.observe(e.el))},u=()=>{i&&r.cancelAnimationFrame(i),s&&s.unobserve&&e.el&&(s.unobserve(e.el),s=null)},f=()=>{!e||e.destroyed||!e.initialized||n("orientationchange")};t("init",()=>{if(e.params.resizeObserver&&typeof r.ResizeObserver<"u"){c();return}r.addEventListener("resize",a),r.addEventListener("orientationchange",f)}),t("destroy",()=>{u(),r.removeEventListener("resize",a),r.removeEventListener("orientationchange",f)})}function iL({swiper:e,extendParams:t,on:n,emit:r}){const s=[],i=da(),a=(f,p={})=>{const g=i.MutationObserver||i.WebkitMutationObserver,y=new g(v=>{if(e.__preventObserver__)return;if(v.length===1){r("observerUpdate",v[0]);return}const S=function(){r("observerUpdate",v[0])};i.requestAnimationFrame?i.requestAnimationFrame(S):i.setTimeout(S,0)});y.observe(f,{attributes:typeof p.attributes>"u"?!0:p.attributes,childList:e.isElement||(typeof p.childList>"u"?!0:p).childList,characterData:typeof p.characterData>"u"?!0:p.characterData}),s.push(y)},c=()=>{if(e.params.observer){if(e.params.observeParents){const f=eL(e.hostEl);for(let p=0;p<f.length;p+=1)a(f[p])}a(e.hostEl,{childList:e.params.observeSlideChildren}),a(e.wrapperEl,{attributes:!1})}},u=()=>{s.forEach(f=>{f.disconnect()}),s.splice(0,s.length)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),n("init",c),n("destroy",u)}var oL={on(e,t,n){const r=this;if(!r.eventsListeners||r.destroyed||typeof t!="function")return r;const s=n?"unshift":"push";return e.split(" ").forEach(i=>{r.eventsListeners[i]||(r.eventsListeners[i]=[]),r.eventsListeners[i][s](t)}),r},once(e,t,n){const r=this;if(!r.eventsListeners||r.destroyed||typeof t!="function")return r;function s(...i){r.off(e,s),s.__emitterProxy&&delete s.__emitterProxy,t.apply(r,i)}return s.__emitterProxy=t,r.on(e,s,n)},onAny(e,t){const n=this;if(!n.eventsListeners||n.destroyed||typeof e!="function")return n;const r=t?"unshift":"push";return n.eventsAnyListeners.indexOf(e)<0&&n.eventsAnyListeners[r](e),n},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed||!t.eventsAnyListeners)return t;const n=t.eventsAnyListeners.indexOf(e);return n>=0&&t.eventsAnyListeners.splice(n,1),t},off(e,t){const n=this;return!n.eventsListeners||n.destroyed||!n.eventsListeners||e.split(" ").forEach(r=>{typeof t>"u"?n.eventsListeners[r]=[]:n.eventsListeners[r]&&n.eventsListeners[r].forEach((s,i)=>{(s===t||s.__emitterProxy&&s.__emitterProxy===t)&&n.eventsListeners[r].splice(i,1)})}),n},emit(...e){const t=this;if(!t.eventsListeners||t.destroyed||!t.eventsListeners)return t;let n,r,s;return typeof e[0]=="string"||Array.isArray(e[0])?(n=e[0],r=e.slice(1,e.length),s=t):(n=e[0].events,r=e[0].data,s=e[0].context||t),r.unshift(s),(Array.isArray(n)?n:n.split(" ")).forEach(a=>{t.eventsAnyListeners&&t.eventsAnyListeners.length&&t.eventsAnyListeners.forEach(c=>{c.apply(s,[a,...r])}),t.eventsListeners&&t.eventsListeners[a]&&t.eventsListeners[a].forEach(c=>{c.apply(s,r)})}),t}};function aL(){const e=this;let t,n;const r=e.el;typeof e.params.width<"u"&&e.params.width!==null?t=e.params.width:t=r.clientWidth,typeof e.params.height<"u"&&e.params.height!==null?n=e.params.height:n=r.clientHeight,!(t===0&&e.isHorizontal()||n===0&&e.isVertical())&&(t=t-parseInt(uu(r,"padding-left")||0,10)-parseInt(uu(r,"padding-right")||0,10),n=n-parseInt(uu(r,"padding-top")||0,10)-parseInt(uu(r,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(n)&&(n=0),Object.assign(e,{width:t,height:n,size:e.isHorizontal()?t:n}))}function lL(){const e=this;function t(Z,V){return parseFloat(Z.getPropertyValue(e.getDirectionLabel(V))||0)}const n=e.params,{wrapperEl:r,slidesEl:s,rtlTranslate:i,wrongRTL:a}=e,c=e.virtual&&n.virtual.enabled,u=c?e.virtual.slides.length:e.slides.length,f=Bc(s,`.${e.params.slideClass}, swiper-slide`),p=c?e.virtual.slides.length:f.length;let g=[];const y=[],v=[];let S=n.slidesOffsetBefore;typeof S=="function"&&(S=n.slidesOffsetBefore.call(e));let A=n.slidesOffsetAfter;typeof A=="function"&&(A=n.slidesOffsetAfter.call(e));const C=e.snapGrid.length,L=e.slidesGrid.length,E=e.size-S-A;let M=n.spaceBetween,P=-S,F=0,j=0;if(typeof E>"u")return;typeof M=="string"&&M.indexOf("%")>=0?M=parseFloat(M.replace("%",""))/100*E:typeof M=="string"&&(M=parseFloat(M)),e.virtualSize=-M-S-A,f.forEach(Z=>{i?Z.style.marginLeft="":Z.style.marginRight="",Z.style.marginBottom="",Z.style.marginTop=""}),n.centeredSlides&&n.cssMode&&(Od(r,"--swiper-centered-offset-before",""),Od(r,"--swiper-centered-offset-after","")),n.cssMode&&(Od(r,"--swiper-slides-offset-before",`${S}px`),Od(r,"--swiper-slides-offset-after",`${A}px`));const T=n.grid&&n.grid.rows>1&&e.grid;T?e.grid.initSlides(f):e.grid&&e.grid.unsetSlides();let Q;const $=n.slidesPerView==="auto"&&n.breakpoints&&Object.keys(n.breakpoints).filter(Z=>typeof n.breakpoints[Z].slidesPerView<"u").length>0;for(let Z=0;Z<p;Z+=1){Q=0;const V=f[Z];if(!(V&&(T&&e.grid.updateSlide(Z,V,f),uu(V,"display")==="none"))){if(c&&n.slidesPerView==="auto")n.virtual.slidesPerViewAutoSlideSize&&(Q=n.virtual.slidesPerViewAutoSlideSize),Q&&V&&(n.roundLengths&&(Q=Math.floor(Q)),V.style[e.getDirectionLabel("width")]=`${Q}px`);else if(n.slidesPerView==="auto"){$&&(V.style[e.getDirectionLabel("width")]="");const fe=getComputedStyle(V),X=V.style.transform,ge=V.style.webkitTransform;if(X&&(V.style.transform="none"),ge&&(V.style.webkitTransform="none"),n.roundLengths)Q=e.isHorizontal()?w5(V,"width"):w5(V,"height");else{const be=t(fe,"width"),Te=t(fe,"padding-left"),ie=t(fe,"padding-right"),U=t(fe,"margin-left"),G=t(fe,"margin-right"),ae=fe.getPropertyValue("box-sizing");if(ae&&ae==="border-box")Q=be+U+G;else{const{clientWidth:ve,offsetWidth:pe}=V;Q=be+Te+ie+U+G+(pe-ve)}}X&&(V.style.transform=X),ge&&(V.style.webkitTransform=ge),n.roundLengths&&(Q=Math.floor(Q))}else Q=(E-(n.slidesPerView-1)*M)/n.slidesPerView,n.roundLengths&&(Q=Math.floor(Q)),V&&(V.style[e.getDirectionLabel("width")]=`${Q}px`);V&&(V.swiperSlideSize=Q),v.push(Q),n.centeredSlides?(P=P+Q/2+F/2+M,F===0&&Z!==0&&(P=P-E/2-M),Z===0&&(P=P-E/2-M),Math.abs(P)<1/1e3&&(P=0),n.roundLengths&&(P=Math.floor(P)),j%n.slidesPerGroup===0&&g.push(P),y.push(P)):(n.roundLengths&&(P=Math.floor(P)),(j-Math.min(e.params.slidesPerGroupSkip,j))%e.params.slidesPerGroup===0&&g.push(P),y.push(P),P=P+Q+M),e.virtualSize+=Q+M,F=Q,j+=1}}if(e.virtualSize=Math.max(e.virtualSize,E)+A,i&&a&&(n.effect==="slide"||n.effect==="coverflow")&&(r.style.width=`${e.virtualSize+M}px`),n.setWrapperSize&&(r.style[e.getDirectionLabel("width")]=`${e.virtualSize+M}px`),T&&e.grid.updateWrapperSize(Q,g),!n.centeredSlides){const Z=n.slidesPerView!=="auto"&&n.slidesPerView%1!==0,V=n.snapToSlideEdge&&!n.loop&&(n.slidesPerView==="auto"||Z);let fe=g.length;if(V){let ge;if(n.slidesPerView==="auto"){ge=1;let be=0;for(let Te=v.length-1;Te>=0&&(be+=v[Te]+(Te<v.length-1?M:0),be<=E);Te-=1)ge=v.length-Te}else ge=Math.floor(n.slidesPerView);fe=Math.max(p-ge,0)}const X=[];for(let ge=0;ge<g.length;ge+=1){let be=g[ge];n.roundLengths&&(be=Math.floor(be)),V?ge<=fe&&X.push(be):g[ge]<=e.virtualSize-E&&X.push(be)}g=X,Math.floor(e.virtualSize-E)-Math.floor(g[g.length-1])>1&&(V||g.push(e.virtualSize-E))}if(c&&n.loop){const Z=v[0]+M;if(n.slidesPerGroup>1){const V=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/n.slidesPerGroup),fe=Z*n.slidesPerGroup;for(let X=0;X<V;X+=1)g.push(g[g.length-1]+fe)}for(let V=0;V<e.virtual.slidesBefore+e.virtual.slidesAfter;V+=1)n.slidesPerGroup===1&&g.push(g[g.length-1]+Z),y.push(y[y.length-1]+Z),e.virtualSize+=Z}if(g.length===0&&(g=[0]),M!==0){const Z=e.isHorizontal()&&i?"marginLeft":e.getDirectionLabel("marginRight");f.filter((V,fe)=>!n.cssMode||n.loop?!0:fe!==f.length-1).forEach(V=>{V.style[Z]=`${M}px`})}if(n.centeredSlides&&n.centeredSlidesBounds){let Z=0;v.forEach(fe=>{Z+=fe+(M||0)}),Z-=M;const V=Z>E?Z-E:0;g=g.map(fe=>fe<=0?-S:fe>V?V+A:fe)}if(n.centerInsufficientSlides){let Z=0;if(v.forEach(V=>{Z+=V+(M||0)}),Z-=M,Z<E){const V=(E-Z)/2;g.forEach((fe,X)=>{g[X]=fe-V}),y.forEach((fe,X)=>{y[X]=fe+V})}}if(Object.assign(e,{slides:f,snapGrid:g,slidesGrid:y,slidesSizesGrid:v}),n.centeredSlides&&n.cssMode&&!n.centeredSlidesBounds){Od(r,"--swiper-centered-offset-before",`${-g[0]}px`),Od(r,"--swiper-centered-offset-after",`${e.size/2-v[v.length-1]/2}px`);const Z=-e.snapGrid[0],V=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(fe=>fe+Z),e.slidesGrid=e.slidesGrid.map(fe=>fe+V)}if(p!==u&&e.emit("slidesLengthChange"),g.length!==C&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),y.length!==L&&e.emit("slidesGridLengthChange"),n.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!c&&!n.cssMode&&(n.effect==="slide"||n.effect==="fade")){const Z=`${n.containerModifierClass}backface-hidden`,V=e.el.classList.contains(Z);p<=n.maxBackfaceHiddenSlides?V||e.el.classList.add(Z):V&&e.el.classList.remove(Z)}}function cL(e){const t=this,n=[],r=t.virtual&&t.params.virtual.enabled;let s=0,i;typeof e=="number"?t.setTransition(e):e===!0&&t.setTransition(t.params.speed);const a=c=>r?t.slides[t.getSlideIndexByData(c)]:t.slides[c];if(t.params.slidesPerView!=="auto"&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(c=>{n.push(c)});else for(i=0;i<Math.ceil(t.params.slidesPerView);i+=1){const c=t.activeIndex+i;if(c>t.slides.length&&!r)break;n.push(a(c))}else n.push(a(t.activeIndex));for(i=0;i<n.length;i+=1)if(typeof n[i]<"u"){const c=n[i].offsetHeight;s=c>s?c:s}(s||s===0)&&(t.wrapperEl.style.height=`${s}px`)}function uL(){const e=this,t=e.slides,n=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let r=0;r<t.length;r+=1)t[r].swiperSlideOffset=(e.isHorizontal()?t[r].offsetLeft:t[r].offsetTop)-n-e.cssOverflowAdjustment()}const A5=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};function dL(e=this&&this.translate||0){const t=this,n=t.params,{slides:r,rtlTranslate:s,snapGrid:i}=t;if(r.length===0)return;typeof r[0].swiperSlideOffset>"u"&&t.updateSlidesOffset();let a=-e;s&&(a=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let c=n.spaceBetween;typeof c=="string"&&c.indexOf("%")>=0?c=parseFloat(c.replace("%",""))/100*t.size:typeof c=="string"&&(c=parseFloat(c));for(let u=0;u<r.length;u+=1){const f=r[u];let p=f.swiperSlideOffset;n.cssMode&&n.centeredSlides&&(p-=r[0].swiperSlideOffset);const g=(a+(n.centeredSlides?t.minTranslate():0)-p)/(f.swiperSlideSize+c),y=(a-i[0]+(n.centeredSlides?t.minTranslate():0)-p)/(f.swiperSlideSize+c),v=-(a-p),S=v+t.slidesSizesGrid[u],A=v>=0&&v<=t.size-t.slidesSizesGrid[u],C=v>=0&&v<t.size-1||S>1&&S<=t.size||v<=0&&S>=t.size;C&&(t.visibleSlides.push(f),t.visibleSlidesIndexes.push(u)),A5(f,C,n.slideVisibleClass),A5(f,A,n.slideFullyVisibleClass),f.progress=s?-g:g,f.originalProgress=s?-y:y}}function fL(e){const t=this;if(typeof e>"u"){const p=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*p||0}const n=t.params,r=t.maxTranslate()-t.minTranslate();let{progress:s,isBeginning:i,isEnd:a,progressLoop:c}=t;const u=i,f=a;if(r===0)s=0,i=!0,a=!0;else{s=(e-t.minTranslate())/r;const p=Math.abs(e-t.minTranslate())<1,g=Math.abs(e-t.maxTranslate())<1;i=p||s<=0,a=g||s>=1,p&&(s=0),g&&(s=1)}if(n.loop){const p=t.getSlideIndexByData(0),g=t.getSlideIndexByData(t.slides.length-1),y=t.slidesGrid[p],v=t.slidesGrid[g],S=t.slidesGrid[t.slidesGrid.length-1],A=Math.abs(e);A>=y?c=(A-y)/S:c=(A+S-v)/S,c>1&&(c-=1)}Object.assign(t,{progress:s,progressLoop:c,isBeginning:i,isEnd:a}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),i&&!u&&t.emit("reachBeginning toEdge"),a&&!f&&t.emit("reachEnd toEdge"),(u&&!i||f&&!a)&&t.emit("fromEdge"),t.emit("progress",s)}const Z1=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};function hL(){const e=this,{slides:t,params:n,slidesEl:r,activeIndex:s}=e,i=e.virtual&&n.virtual.enabled,a=e.grid&&n.grid&&n.grid.rows>1,c=g=>Bc(r,`.${n.slideClass}${g}, swiper-slide${g}`)[0];let u,f,p;if(i)if(n.loop){let g=s-e.virtual.slidesBefore;g<0&&(g=e.virtual.slides.length+g),g>=e.virtual.slides.length&&(g-=e.virtual.slides.length),u=c(`[data-swiper-slide-index="${g}"]`)}else u=c(`[data-swiper-slide-index="${s}"]`);else a?(u=t.find(g=>g.column===s),p=t.find(g=>g.column===s+1),f=t.find(g=>g.column===s-1)):u=t[s];u&&(a||(p=J_(u,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!p&&(p=t[0]),f=Z_(u,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!f===0&&(f=t[t.length-1]))),t.forEach(g=>{Z1(g,g===u,n.slideActiveClass),Z1(g,g===p,n.slideNextClass),Z1(g,g===f,n.slidePrevClass)}),e.emitSlidesClasses()}const km=(e,t)=>{if(!e||e.destroyed||!e.params)return;const n=()=>e.isElement?"swiper-slide":`.${e.params.slideClass}`,r=t.closest(n());if(r){let s=r.querySelector(`.${e.params.lazyPreloaderClass}`);!s&&e.isElement&&(r.shadowRoot?s=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{r.shadowRoot&&(s=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),s&&!s.lazyPreloaderManaged&&s.remove())})),s&&!s.lazyPreloaderManaged&&s.remove()}},J1=(e,t)=>{if(!e.slides[t])return;const n=e.slides[t].querySelector('[loading="lazy"]');n&&n.removeAttribute("loading")},qb=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const n=e.slides.length;if(!n||!t||t<0)return;t=Math.min(t,n);const r=e.params.slidesPerView==="auto"?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),s=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const a=s,c=[a-t];c.push(...Array.from({length:t}).map((u,f)=>a+r+f)),e.slides.forEach((u,f)=>{c.includes(u.column)&&J1(e,f)});return}const i=s+r-1;if(e.params.rewind||e.params.loop)for(let a=s-t;a<=i+t;a+=1){const c=(a%n+n)%n;(c<s||c>i)&&J1(e,c)}else for(let a=Math.max(s-t,0);a<=Math.min(i+t,n-1);a+=1)a!==s&&(a>i||a<s)&&J1(e,a)};function pL(e){const{slidesGrid:t,params:n}=e,r=e.rtlTranslate?e.translate:-e.translate;let s;for(let i=0;i<t.length;i+=1)typeof t[i+1]<"u"?r>=t[i]&&r<t[i+1]-(t[i+1]-t[i])/2?s=i:r>=t[i]&&r<t[i+1]&&(s=i+1):r>=t[i]&&(s=i);return n.normalizeSlideIndex&&(s<0||typeof s>"u")&&(s=0),s}function mL(e){const t=this,n=t.rtlTranslate?t.translate:-t.translate,{snapGrid:r,params:s,activeIndex:i,realIndex:a,snapIndex:c}=t;let u=e,f;const p=v=>{let S=v-t.virtual.slidesBefore;return S<0&&(S=t.virtual.slides.length+S),S>=t.virtual.slides.length&&(S-=t.virtual.slides.length),S};if(typeof u>"u"&&(u=pL(t)),r.indexOf(n)>=0)f=r.indexOf(n);else{const v=Math.min(s.slidesPerGroupSkip,u);f=v+Math.floor((u-v)/s.slidesPerGroup)}if(f>=r.length&&(f=r.length-1),u===i&&!t.params.loop){f!==c&&(t.snapIndex=f,t.emit("snapIndexChange"));return}if(u===i&&t.params.loop&&t.virtual&&t.params.virtual.enabled){t.realIndex=p(u);return}const g=t.grid&&s.grid&&s.grid.rows>1;let y;if(t.virtual&&s.virtual.enabled)s.loop?y=p(u):y=u;else if(g){const v=t.slides.find(A=>A.column===u);let S=parseInt(v.getAttribute("data-swiper-slide-index"),10);Number.isNaN(S)&&(S=Math.max(t.slides.indexOf(v),0)),y=Math.floor(S/s.grid.rows)}else if(t.slides[u]){const v=t.slides[u].getAttribute("data-swiper-slide-index");v?y=parseInt(v,10):y=u}else y=u;Object.assign(t,{previousSnapIndex:c,snapIndex:f,previousRealIndex:a,realIndex:y,previousIndex:i,activeIndex:u}),t.initialized&&qb(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(a!==y&&t.emit("realIndexChange"),t.emit("slideChange"))}function gL(e,t){const n=this,r=n.params;let s=e.closest(`.${r.slideClass}, swiper-slide`);!s&&n.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(c=>{!s&&c.matches&&c.matches(`.${r.slideClass}, swiper-slide`)&&(s=c)});let i=!1,a;if(s){for(let c=0;c<n.slides.length;c+=1)if(n.slides[c]===s){i=!0,a=c;break}}if(s&&i)n.clickedSlide=s,n.virtual&&n.params.virtual.enabled?n.clickedIndex=parseInt(s.getAttribute("data-swiper-slide-index"),10):n.clickedIndex=a;else{n.clickedSlide=void 0,n.clickedIndex=void 0;return}r.slideToClickedSlide&&n.clickedIndex!==void 0&&n.clickedIndex!==n.activeIndex&&n.slideToClickedSlide()}var xL={updateSize:aL,updateSlides:lL,updateAutoHeight:cL,updateSlidesOffset:uL,updateSlidesProgress:dL,updateProgress:fL,updateSlidesClasses:hL,updateActiveIndex:mL,updateClickedSlide:gL};function bL(e=this.isHorizontal()?"x":"y"){const t=this,{params:n,rtlTranslate:r,translate:s,wrapperEl:i}=t;if(n.virtualTranslate)return r?-s:s;if(n.cssMode)return s;let a=q_(i,e);return a+=t.cssOverflowAdjustment(),r&&(a=-a),a||0}function yL(e,t){const n=this,{rtlTranslate:r,params:s,wrapperEl:i,progress:a}=n;let c=0,u=0;const f=0;n.isHorizontal()?c=r?-e:e:u=e,s.roundLengths&&(c=Math.floor(c),u=Math.floor(u)),n.previousTranslate=n.translate,n.translate=n.isHorizontal()?c:u,s.cssMode?i[n.isHorizontal()?"scrollLeft":"scrollTop"]=n.isHorizontal()?-c:-u:s.virtualTranslate||(n.isHorizontal()?c-=n.cssOverflowAdjustment():u-=n.cssOverflowAdjustment(),i.style.transform=`translate3d(${c}px, ${u}px, ${f}px)`);let p;const g=n.maxTranslate()-n.minTranslate();g===0?p=0:p=(e-n.minTranslate())/g,p!==a&&n.updateProgress(e),n.emit("setTranslate",n.translate,t)}function vL(){return-this.snapGrid[0]}function wL(){return-this.snapGrid[this.snapGrid.length-1]}function SL(e=0,t=this.params.speed,n=!0,r=!0,s){const i=this,{params:a,wrapperEl:c}=i;if(i.animating&&a.preventInteractionOnTransition)return!1;const u=i.minTranslate(),f=i.maxTranslate();let p;if(r&&e>u?p=u:r&&e<f?p=f:p=e,i.updateProgress(p),a.cssMode){const g=i.isHorizontal();if(t===0)c[g?"scrollLeft":"scrollTop"]=-p;else{if(!i.support.smoothScroll)return TS({swiper:i,targetPosition:-p,side:g?"left":"top"}),!0;c.scrollTo({[g?"left":"top"]:-p,behavior:"smooth"})}return!0}return t===0?(i.setTransition(0),i.setTranslate(p),n&&(i.emit("beforeTransitionStart",t,s),i.emit("transitionEnd"))):(i.setTransition(t),i.setTranslate(p),n&&(i.emit("beforeTransitionStart",t,s),i.emit("transitionStart")),i.animating||(i.animating=!0,i.onTranslateToWrapperTransitionEnd||(i.onTranslateToWrapperTransitionEnd=function(y){!i||i.destroyed||y.target===this&&(i.wrapperEl.removeEventListener("transitionend",i.onTranslateToWrapperTransitionEnd),i.onTranslateToWrapperTransitionEnd=null,delete i.onTranslateToWrapperTransitionEnd,i.animating=!1,n&&i.emit("transitionEnd"))}),i.wrapperEl.addEventListener("transitionend",i.onTranslateToWrapperTransitionEnd))),!0}var AL={getTranslate:bL,setTranslate:yL,minTranslate:vL,maxTranslate:wL,translateTo:SL};function TL(e,t){const n=this;n.params.cssMode||(n.wrapperEl.style.transitionDuration=`${e}ms`,n.wrapperEl.style.transitionDelay=e===0?"0ms":""),n.emit("setTransition",e,t)}function LS({swiper:e,runCallbacks:t,direction:n,step:r}){const{activeIndex:s,previousIndex:i}=e;let a=n;a||(s>i?a="next":s<i?a="prev":a="reset"),e.emit(`transition${r}`),t&&a==="reset"?e.emit(`slideResetTransition${r}`):t&&s!==i&&(e.emit(`slideChangeTransition${r}`),a==="next"?e.emit(`slideNextTransition${r}`):e.emit(`slidePrevTransition${r}`))}function CL(e=!0,t){const n=this,{params:r}=n;r.cssMode||(r.autoHeight&&n.updateAutoHeight(),LS({swiper:n,runCallbacks:e,direction:t,step:"Start"}))}function kL(e=!0,t){const n=this,{params:r}=n;n.animating=!1,!r.cssMode&&(n.setTransition(0),LS({swiper:n,runCallbacks:e,direction:t,step:"End"}))}var _L={setTransition:TL,transitionStart:CL,transitionEnd:kL};function LL(e=0,t,n=!0,r,s){typeof e=="string"&&(e=parseInt(e,10));const i=this;let a=e;a<0&&(a=0);const{params:c,snapGrid:u,slidesGrid:f,previousIndex:p,activeIndex:g,rtlTranslate:y,wrapperEl:v,enabled:S}=i;if(!S&&!r&&!s||i.destroyed||i.animating&&c.preventInteractionOnTransition)return!1;typeof t>"u"&&(t=i.params.speed);const A=Math.min(i.params.slidesPerGroupSkip,a);let C=A+Math.floor((a-A)/i.params.slidesPerGroup);C>=u.length&&(C=u.length-1);const L=-u[C];if(c.normalizeSlideIndex)for(let T=0;T<f.length;T+=1){const Q=-Math.floor(L*100),$=Math.floor(f[T]*100),Z=Math.floor(f[T+1]*100);typeof f[T+1]<"u"?Q>=$&&Q<Z-(Z-$)/2?a=T:Q>=$&&Q<Z&&(a=T+1):Q>=$&&(a=T)}if(i.initialized&&a!==g&&(!i.allowSlideNext&&(y?L>i.translate&&L>i.minTranslate():L<i.translate&&L<i.minTranslate())||!i.allowSlidePrev&&L>i.translate&&L>i.maxTranslate()&&(g||0)!==a))return!1;a!==(p||0)&&n&&i.emit("beforeSlideChangeStart"),i.updateProgress(L);let E;a>g?E="next":a<g?E="prev":E="reset";const M=i.virtual&&i.params.virtual.enabled;if(!(M&&s)&&(y&&-L===i.translate||!y&&L===i.translate))return i.updateActiveIndex(a),c.autoHeight&&i.updateAutoHeight(),i.updateSlidesClasses(),c.effect!=="slide"&&i.setTranslate(L),E!=="reset"&&(i.transitionStart(n,E),i.transitionEnd(n,E)),!1;if(c.cssMode){const T=i.isHorizontal(),Q=y?L:-L;if(t===0)M&&(i.wrapperEl.style.scrollSnapType="none",i._immediateVirtual=!0),M&&!i._cssModeVirtualInitialSet&&i.params.initialSlide>0?(i._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{v[T?"scrollLeft":"scrollTop"]=Q})):v[T?"scrollLeft":"scrollTop"]=Q,M&&requestAnimationFrame(()=>{i.wrapperEl.style.scrollSnapType="",i._immediateVirtual=!1});else{if(!i.support.smoothScroll)return TS({swiper:i,targetPosition:Q,side:T?"left":"top"}),!0;v.scrollTo({[T?"left":"top"]:Q,behavior:"smooth"})}return!0}const j=_S().isSafari;return M&&!s&&j&&i.isElement&&i.virtual.update(!1,!1,a),i.setTransition(t),i.setTranslate(L),i.updateActiveIndex(a),i.updateSlidesClasses(),i.emit("beforeTransitionStart",t,r),i.transitionStart(n,E),t===0?i.transitionEnd(n,E):i.animating||(i.animating=!0,i.onSlideToWrapperTransitionEnd||(i.onSlideToWrapperTransitionEnd=function(Q){!i||i.destroyed||Q.target===this&&(i.wrapperEl.removeEventListener("transitionend",i.onSlideToWrapperTransitionEnd),i.onSlideToWrapperTransitionEnd=null,delete i.onSlideToWrapperTransitionEnd,i.transitionEnd(n,E))}),i.wrapperEl.addEventListener("transitionend",i.onSlideToWrapperTransitionEnd)),!0}function EL(e=0,t,n=!0,r){typeof e=="string"&&(e=parseInt(e,10));const s=this;if(s.destroyed)return;typeof t>"u"&&(t=s.params.speed);const i=s.grid&&s.params.grid&&s.params.grid.rows>1;let a=e;if(s.params.loop)if(s.virtual&&s.params.virtual.enabled)a=a+s.virtual.slidesBefore;else{let c;if(i){const A=a*s.params.grid.rows;c=s.slides.find(C=>C.getAttribute("data-swiper-slide-index")*1===A).column}else c=s.getSlideIndexByData(a);const u=i?Math.ceil(s.slides.length/s.params.grid.rows):s.slides.length,{centeredSlides:f,slidesOffsetBefore:p,slidesOffsetAfter:g}=s.params,y=f||!!p||!!g;let v=s.params.slidesPerView;v==="auto"?v=s.slidesPerViewDynamic():(v=Math.ceil(parseFloat(s.params.slidesPerView,10)),y&&v%2===0&&(v=v+1));let S=u-c<v;if(y&&(S=S||c<Math.ceil(v/2)),r&&y&&s.params.slidesPerView!=="auto"&&!i&&(S=!1),S){const A=y?c<s.activeIndex?"prev":"next":c-s.activeIndex-1<s.params.slidesPerView?"next":"prev";s.loopFix({direction:A,slideTo:!0,activeSlideIndex:A==="next"?c+1:c-u+1,slideRealIndex:A==="next"?s.realIndex:void 0})}if(i){const A=a*s.params.grid.rows;a=s.slides.find(C=>C.getAttribute("data-swiper-slide-index")*1===A).column}else a=s.getSlideIndexByData(a)}return requestAnimationFrame(()=>{s.slideTo(a,t,n,r)}),s}function IL(e,t=!0,n){const r=this,{enabled:s,params:i,animating:a}=r;if(!s||r.destroyed)return r;typeof e>"u"&&(e=r.params.speed);let c=i.slidesPerGroup;i.slidesPerView==="auto"&&i.slidesPerGroup===1&&i.slidesPerGroupAuto&&(c=Math.max(r.slidesPerViewDynamic("current",!0),1));const u=r.activeIndex<i.slidesPerGroupSkip?1:c,f=r.virtual&&i.virtual.enabled;if(i.loop){if(a&&!f&&i.loopPreventsSliding)return!1;if(r.loopFix({direction:"next"}),r._clientLeft=r.wrapperEl.clientLeft,r.activeIndex===r.slides.length-1&&i.cssMode)return requestAnimationFrame(()=>{r.slideTo(r.activeIndex+u,e,t,n)}),!0}return i.rewind&&r.isEnd?r.slideTo(0,e,t,n):r.slideTo(r.activeIndex+u,e,t,n)}function RL(e,t=!0,n){const r=this,{params:s,snapGrid:i,slidesGrid:a,rtlTranslate:c,enabled:u,animating:f}=r;if(!u||r.destroyed)return r;typeof e>"u"&&(e=r.params.speed);const p=r.virtual&&s.virtual.enabled;if(s.loop){if(f&&!p&&s.loopPreventsSliding)return!1;r.loopFix({direction:"prev"}),r._clientLeft=r.wrapperEl.clientLeft}const g=c?r.translate:-r.translate;function y(E){return E<0?-Math.floor(Math.abs(E)):Math.floor(E)}const v=y(g),S=i.map(E=>y(E)),A=s.freeMode&&s.freeMode.enabled;let C=i[S.indexOf(v)-1];if(typeof C>"u"&&(s.cssMode||A)){let E;i.forEach((M,P)=>{v>=M&&(E=P)}),typeof E<"u"&&(C=A?i[E]:i[E>0?E-1:E])}let L=0;if(typeof C<"u"&&(L=a.indexOf(C),L<0&&(L=r.activeIndex-1),s.slidesPerView==="auto"&&s.slidesPerGroup===1&&s.slidesPerGroupAuto&&(L=L-r.slidesPerViewDynamic("previous",!0)+1,L=Math.max(L,0))),s.rewind&&r.isBeginning){const E=r.params.virtual&&r.params.virtual.enabled&&r.virtual?r.virtual.slides.length-1:r.slides.length-1;return r.slideTo(E,e,t,n)}else if(s.loop&&r.activeIndex===0&&s.cssMode)return requestAnimationFrame(()=>{r.slideTo(L,e,t,n)}),!0;return r.slideTo(L,e,t,n)}function NL(e,t=!0,n){const r=this;if(!r.destroyed)return typeof e>"u"&&(e=r.params.speed),r.slideTo(r.activeIndex,e,t,n)}function ML(e,t=!0,n,r=.5){const s=this;if(s.destroyed)return;typeof e>"u"&&(e=s.params.speed);let i=s.activeIndex;const a=Math.min(s.params.slidesPerGroupSkip,i),c=a+Math.floor((i-a)/s.params.slidesPerGroup),u=s.rtlTranslate?s.translate:-s.translate;if(u>=s.snapGrid[c]){const f=s.snapGrid[c],p=s.snapGrid[c+1];u-f>(p-f)*r&&(i+=s.params.slidesPerGroup)}else{const f=s.snapGrid[c-1],p=s.snapGrid[c];u-f<=(p-f)*r&&(i-=s.params.slidesPerGroup)}return i=Math.max(i,0),i=Math.min(i,s.slidesGrid.length-1),s.slideTo(i,e,t,n)}function DL(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:n}=e,r=t.slidesPerView==="auto"?e.slidesPerViewDynamic():t.slidesPerView;let s=e.getSlideIndexWhenGrid(e.clickedIndex),i;const a=e.isElement?"swiper-slide":`.${t.slideClass}`,c=e.grid&&e.params.grid&&e.params.grid.rows>1;if(t.loop){if(e.animating)return;i=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?e.slideToLoop(i):s>(c?(e.slides.length-r)/2-(e.params.grid.rows-1):e.slides.length-r)?(e.loopFix(),s=e.getSlideIndex(Bc(n,`${a}[data-swiper-slide-index="${i}"]`)[0]),AS(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}var jL={slideTo:LL,slideToLoop:EL,slideNext:IL,slidePrev:RL,slideReset:NL,slideToClosest:ML,slideToClickedSlide:DL};function PL(e,t){const n=this,{params:r,slidesEl:s}=n;if(!r.loop||n.virtual&&n.params.virtual.enabled)return;const i=()=>{Bc(s,`.${r.slideClass}, swiper-slide`).forEach((S,A)=>{S.setAttribute("data-swiper-slide-index",A)})},a=()=>{const v=Bc(s,`.${r.slideBlankClass}`);v.forEach(S=>{S.remove()}),v.length>0&&(n.recalcSlides(),n.updateSlides())},c=n.grid&&r.grid&&r.grid.rows>1;r.loopAddBlankSlides&&(r.slidesPerGroup>1||c)&&a();const u=r.slidesPerGroup*(c?r.grid.rows:1),f=n.slides.length%u!==0,p=c&&n.slides.length%r.grid.rows!==0,g=v=>{for(let S=0;S<v;S+=1){const A=n.isElement?Vb("swiper-slide",[r.slideBlankClass]):Vb("div",[r.slideClass,r.slideBlankClass]);n.slidesEl.append(A)}};if(f){if(r.loopAddBlankSlides){const v=u-n.slides.length%u;g(v),n.recalcSlides(),n.updateSlides()}else eg("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");i()}else if(p){if(r.loopAddBlankSlides){const v=r.grid.rows-n.slides.length%r.grid.rows;g(v),n.recalcSlides(),n.updateSlides()}else eg("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");i()}else i();const y=r.centeredSlides||!!r.slidesOffsetBefore||!!r.slidesOffsetAfter;n.loopFix({slideRealIndex:e,direction:y?void 0:"next",initial:t})}function BL({slideRealIndex:e,slideTo:t=!0,direction:n,setTranslate:r,activeSlideIndex:s,initial:i,byController:a,byMousewheel:c}={}){const u=this;if(!u.params.loop)return;u.emit("beforeLoopFix");const{slides:f,allowSlidePrev:p,allowSlideNext:g,slidesEl:y,params:v}=u,{centeredSlides:S,slidesOffsetBefore:A,slidesOffsetAfter:C,initialSlide:L}=v,E=S||!!A||!!C;if(u.allowSlidePrev=!0,u.allowSlideNext=!0,u.virtual&&v.virtual.enabled){t&&(!E&&u.snapIndex===0?u.slideTo(u.virtual.slides.length,0,!1,!0):E&&u.snapIndex<v.slidesPerView?u.slideTo(u.virtual.slides.length+u.snapIndex,0,!1,!0):u.snapIndex===u.snapGrid.length-1&&u.slideTo(u.virtual.slidesBefore,0,!1,!0)),u.allowSlidePrev=p,u.allowSlideNext=g,u.emit("loopFix");return}let M=v.slidesPerView;M==="auto"?M=u.slidesPerViewDynamic():(M=Math.ceil(parseFloat(v.slidesPerView,10)),E&&M%2===0&&(M=M+1));const P=v.slidesPerGroupAuto?M:v.slidesPerGroup;let F=E?Math.max(P,Math.ceil(M/2)):P;F%P!==0&&(F+=P-F%P),F+=v.loopAdditionalSlides,u.loopedSlides=F;const j=u.grid&&v.grid&&v.grid.rows>1;f.length<M+F||u.params.effect==="cards"&&f.length<M+F*2?eg("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):j&&v.grid.fill==="row"&&eg("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const T=[],Q=[],$=j?Math.ceil(f.length/v.grid.rows):f.length,Z=i&&$-L<M&&!E;let V=Z?L:u.activeIndex;typeof s>"u"?s=u.getSlideIndex(f.find(U=>U.classList.contains(v.slideActiveClass))):V=s;const fe=n==="next"||!n,X=n==="prev"||!n;let ge=0,be=0;const ie=(j?f[s].column:s)+(E&&typeof r>"u"?-M/2+.5:0);if(ie<F){ge=Math.max(F-ie,P);for(let U=0;U<F-ie;U+=1){const G=U-Math.floor(U/$)*$;if(j){const ae=$-G-1;for(let ve=f.length-1;ve>=0;ve-=1)f[ve].column===ae&&T.push(ve)}else T.push($-G-1)}}else if(ie+M>$-F){be=Math.max(ie-($-F*2),P),Z&&(be=Math.max(be,M-$+L+1));for(let U=0;U<be;U+=1){const G=U-Math.floor(U/$)*$;j?f.forEach((ae,ve)=>{ae.column===G&&Q.push(ve)}):Q.push(G)}}if(u.__preventObserver__=!0,requestAnimationFrame(()=>{u.__preventObserver__=!1}),u.params.effect==="cards"&&f.length<M+F*2&&(Q.includes(s)&&Q.splice(Q.indexOf(s),1),T.includes(s)&&T.splice(T.indexOf(s),1)),X&&T.forEach(U=>{f[U].swiperLoopMoveDOM=!0,y.prepend(f[U]),f[U].swiperLoopMoveDOM=!1}),fe&&Q.forEach(U=>{f[U].swiperLoopMoveDOM=!0,y.append(f[U]),f[U].swiperLoopMoveDOM=!1}),u.recalcSlides(),v.slidesPerView==="auto"?u.updateSlides():j&&(T.length>0&&X||Q.length>0&&fe)&&u.slides.forEach((U,G)=>{u.grid.updateSlide(G,U,u.slides)}),v.watchSlidesProgress&&u.updateSlidesOffset(),t){if(T.length>0&&X){if(typeof e>"u"){const U=u.slidesGrid[V],ae=u.slidesGrid[V+ge]-U;c?u.setTranslate(u.translate-ae):(u.slideTo(V+Math.ceil(ge),0,!1,!0),r&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-ae,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-ae))}else if(r){const U=j?T.length/v.grid.rows:T.length;u.slideTo(u.activeIndex+U,0,!1,!0),u.touchEventsData.currentTranslate=u.translate}}else if(Q.length>0&&fe)if(typeof e>"u"){const U=u.slidesGrid[V],ae=u.slidesGrid[V-be]-U;c?u.setTranslate(u.translate-ae):(u.slideTo(V-be,0,!1,!0),r&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-ae,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-ae))}else{const U=j?Q.length/v.grid.rows:Q.length;u.slideTo(u.activeIndex-U,0,!1,!0)}}if(u.allowSlidePrev=p,u.allowSlideNext=g,u.controller&&u.controller.control&&!a){const U={slideRealIndex:e,direction:n,setTranslate:r,activeSlideIndex:s,byController:!0};Array.isArray(u.controller.control)?u.controller.control.forEach(G=>{!G.destroyed&&G.params.loop&&G.loopFix({...U,slideTo:G.params.slidesPerView===v.slidesPerView?t:!1})}):u.controller.control instanceof u.constructor&&u.controller.control.params.loop&&u.controller.control.loopFix({...U,slideTo:u.controller.control.params.slidesPerView===v.slidesPerView?t:!1})}u.emit("loopFix")}function FL(){const e=this,{params:t,slidesEl:n}=e;if(!t.loop||!n||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const r=[];e.slides.forEach(s=>{const i=typeof s.swiperSlideIndex>"u"?s.getAttribute("data-swiper-slide-index")*1:s.swiperSlideIndex;r[i]=s}),e.slides.forEach(s=>{s.removeAttribute("data-swiper-slide-index")}),r.forEach(s=>{n.append(s)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}var OL={loopCreate:PL,loopFix:BL,loopDestroy:FL};function QL(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const n=t.params.touchEventsTarget==="container"?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),n.style.cursor="move",n.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})}function $L(){const e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e[e.params.touchEventsTarget==="container"?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}var HL={setGrabCursor:QL,unsetGrabCursor:$L};function zL(e,t=this){function n(r){if(!r||r===ud()||r===da())return null;r.assignedSlot&&(r=r.assignedSlot);const s=r.closest(e);return!s&&!r.getRootNode?null:s||n(r.getRootNode().host)}return n(t)}function T5(e,t,n){const r=da(),{params:s}=e,i=s.edgeSwipeDetection,a=s.edgeSwipeThreshold;return i&&(n<=a||n>=r.innerWidth-a)?i==="prevent"?(t.preventDefault(),!0):!1:!0}function UL(e){const t=this;if(t.destroyed)return;const n=ud();let r=e;r.originalEvent&&(r=r.originalEvent);const s=t.touchEventsData;if(r.type==="pointerdown"){if(s.pointerId!==null&&s.pointerId!==r.pointerId)return;s.pointerId=r.pointerId}else r.type==="touchstart"&&r.targetTouches.length===1&&(s.touchId=r.targetTouches[0].identifier);if(r.type==="touchstart"){T5(t,r,r.targetTouches[0].pageX);return}const{params:i,touches:a,enabled:c}=t;if(!c||!i.simulateTouch&&r.pointerType==="mouse"||t.animating&&i.preventInteractionOnTransition)return;!t.animating&&i.cssMode&&i.loop&&t.loopFix();let u=r.target;if(i.touchEventsTarget==="wrapper"&&!X_(u,t.wrapperEl)||"which"in r&&r.which===3||"button"in r&&r.button>0||s.isTouched&&s.isMoved)return;const f=!!i.noSwipingClass&&i.noSwipingClass!=="",p=r.composedPath?r.composedPath():r.path;f&&r.target&&r.target.shadowRoot&&p&&(u=p[0]);const g=i.noSwipingSelector?i.noSwipingSelector:`.${i.noSwipingClass}`,y=!!(r.target&&r.target.shadowRoot);if(i.noSwiping&&(y?zL(g,u):u.closest(g))){t.allowClick=!0;return}if(i.swipeHandler&&!u.closest(i.swipeHandler))return;a.currentX=r.pageX,a.currentY=r.pageY;const v=a.currentX,S=a.currentY;if(!T5(t,r,v))return;Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=v,a.startY=S,s.touchStartTime=Jm(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,i.threshold>0&&(s.allowThresholdMove=!1);let A=!0;u.matches(s.focusableElements)&&(A=!1,u.nodeName==="SELECT"&&(s.isTouched=!1)),n.activeElement&&n.activeElement.matches(s.focusableElements)&&n.activeElement!==u&&(r.pointerType==="mouse"||r.pointerType!=="mouse"&&!u.matches(s.focusableElements))&&n.activeElement.blur();const C=A&&t.allowTouchMove&&i.touchStartPreventDefault;(i.touchStartForcePreventDefault||C)&&!u.isContentEditable&&r.preventDefault(),i.freeMode&&i.freeMode.enabled&&t.freeMode&&t.animating&&!i.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",r)}function GL(e){const t=ud(),n=this;if(n.destroyed)return;const r=n.touchEventsData,{params:s,touches:i,rtlTranslate:a,enabled:c}=n;if(!c||!s.simulateTouch&&e.pointerType==="mouse")return;let u=e;if(u.originalEvent&&(u=u.originalEvent),u.type==="pointermove"&&(r.touchId!==null||u.pointerId!==r.pointerId))return;let f;if(u.type==="touchmove"){if(f=[...u.changedTouches].find(F=>F.identifier===r.touchId),!f||f.identifier!==r.touchId)return}else f=u;if(!r.isTouched){r.startMoving&&r.isScrolling&&n.emit("touchMoveOpposite",u);return}const p=f.pageX,g=f.pageY;if(u.preventedByNestedSwiper){i.startX=p,i.startY=g;return}if(!n.allowTouchMove){u.target.matches(r.focusableElements)||(n.allowClick=!1),r.isTouched&&(Object.assign(i,{startX:p,startY:g,currentX:p,currentY:g}),r.touchStartTime=Jm());return}if(s.touchReleaseOnEdges&&!s.loop)if(n.isVertical()){if(g<i.startY&&n.translate<=n.maxTranslate()||g>i.startY&&n.translate>=n.minTranslate()){r.isTouched=!1,r.isMoved=!1;return}}else{if(a&&(p>i.startX&&-n.translate<=n.maxTranslate()||p<i.startX&&-n.translate>=n.minTranslate()))return;if(!a&&(p<i.startX&&n.translate<=n.maxTranslate()||p>i.startX&&n.translate>=n.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(r.focusableElements)&&t.activeElement!==u.target&&u.pointerType!=="mouse"&&t.activeElement.blur(),t.activeElement&&u.target===t.activeElement&&u.target.matches(r.focusableElements)){r.isMoved=!0,n.allowClick=!1;return}r.allowTouchCallbacks&&n.emit("touchMove",u),i.previousX=i.currentX,i.previousY=i.currentY,i.currentX=p,i.currentY=g;const y=i.currentX-i.startX,v=i.currentY-i.startY;if(n.params.threshold&&Math.sqrt(y**2+v**2)<n.params.threshold)return;if(typeof r.isScrolling>"u"){let F;n.isHorizontal()&&i.currentY===i.startY||n.isVertical()&&i.currentX===i.startX?r.isScrolling=!1:y*y+v*v>=25&&(F=Math.atan2(Math.abs(v),Math.abs(y))*180/Math.PI,r.isScrolling=n.isHorizontal()?F>s.touchAngle:90-F>s.touchAngle)}if(r.isScrolling&&n.emit("touchMoveOpposite",u),typeof r.startMoving>"u"&&(i.currentX!==i.startX||i.currentY!==i.startY)&&(r.startMoving=!0),r.isScrolling||u.type==="touchmove"&&r.preventTouchMoveFromPointerMove){r.isTouched=!1;return}if(!r.startMoving)return;n.allowClick=!1,!s.cssMode&&u.cancelable&&u.preventDefault(),s.touchMoveStopPropagation&&!s.nested&&u.stopPropagation();let S=n.isHorizontal()?y:v,A=n.isHorizontal()?i.currentX-i.previousX:i.currentY-i.previousY;s.oneWayMovement&&(S=Math.abs(S)*(a?1:-1),A=Math.abs(A)*(a?1:-1)),i.diff=S,S*=s.touchRatio,a&&(S=-S,A=-A);const C=n.touchesDirection;n.swipeDirection=S>0?"prev":"next",n.touchesDirection=A>0?"prev":"next";const L=n.params.loop&&!s.cssMode,E=n.touchesDirection==="next"&&n.allowSlideNext||n.touchesDirection==="prev"&&n.allowSlidePrev;if(!r.isMoved){if(L&&E&&n.loopFix({direction:n.swipeDirection}),r.startTranslate=n.getTranslate(),n.setTransition(0),n.animating){const F=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});n.wrapperEl.dispatchEvent(F)}r.allowMomentumBounce=!1,s.grabCursor&&(n.allowSlideNext===!0||n.allowSlidePrev===!0)&&n.setGrabCursor(!0),n.emit("sliderFirstMove",u)}if(new Date().getTime(),s._loopSwapReset!==!1&&r.isMoved&&r.allowThresholdMove&&C!==n.touchesDirection&&L&&E&&Math.abs(S)>=1){Object.assign(i,{startX:p,startY:g,currentX:p,currentY:g,startTranslate:r.currentTranslate}),r.loopSwapReset=!0,r.startTranslate=r.currentTranslate;return}n.emit("sliderMove",u),r.isMoved=!0,r.currentTranslate=S+r.startTranslate;let M=!0,P=s.resistanceRatio;if(s.touchReleaseOnEdges&&(P=0),S>0?(L&&E&&r.allowThresholdMove&&r.currentTranslate>(s.centeredSlides?n.minTranslate()-n.slidesSizesGrid[n.activeIndex+1]-(s.slidesPerView!=="auto"&&n.slides.length-s.slidesPerView>=2?n.slidesSizesGrid[n.activeIndex+1]+n.params.spaceBetween:0)-n.params.spaceBetween:n.minTranslate())&&n.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),r.currentTranslate>n.minTranslate()&&(M=!1,s.resistance&&(r.currentTranslate=n.minTranslate()-1+(-n.minTranslate()+r.startTranslate+S)**P))):S<0&&(L&&E&&r.allowThresholdMove&&r.currentTranslate<(s.centeredSlides?n.maxTranslate()+n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween+(s.slidesPerView!=="auto"&&n.slides.length-s.slidesPerView>=2?n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween:0):n.maxTranslate())&&n.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:n.slides.length-(s.slidesPerView==="auto"?n.slidesPerViewDynamic():Math.ceil(parseFloat(s.slidesPerView,10)))}),r.currentTranslate<n.maxTranslate()&&(M=!1,s.resistance&&(r.currentTranslate=n.maxTranslate()+1-(n.maxTranslate()-r.startTranslate-S)**P))),M&&(u.preventedByNestedSwiper=!0),!n.allowSlideNext&&n.swipeDirection==="next"&&r.currentTranslate<r.startTranslate&&(r.currentTranslate=r.startTranslate),!n.allowSlidePrev&&n.swipeDirection==="prev"&&r.currentTranslate>r.startTranslate&&(r.currentTranslate=r.startTranslate),!n.allowSlidePrev&&!n.allowSlideNext&&(r.currentTranslate=r.startTranslate),s.threshold>0)if(Math.abs(S)>s.threshold||r.allowThresholdMove){if(!r.allowThresholdMove){r.allowThresholdMove=!0,i.startX=i.currentX,i.startY=i.currentY,r.currentTranslate=r.startTranslate,i.diff=n.isHorizontal()?i.currentX-i.startX:i.currentY-i.startY;return}}else{r.currentTranslate=r.startTranslate;return}!s.followFinger||s.cssMode||((s.freeMode&&s.freeMode.enabled&&n.freeMode||s.watchSlidesProgress)&&(n.updateActiveIndex(),n.updateSlidesClasses()),s.freeMode&&s.freeMode.enabled&&n.freeMode&&n.freeMode.onTouchMove(),n.updateProgress(r.currentTranslate),n.setTranslate(r.currentTranslate))}function WL(e){const t=this;if(t.destroyed)return;const n=t.touchEventsData;let r=e;r.originalEvent&&(r=r.originalEvent);let s;if(r.type==="touchend"||r.type==="touchcancel"){if(s=[...r.changedTouches].find(F=>F.identifier===n.touchId),!s||s.identifier!==n.touchId)return}else{if(n.touchId!==null||r.pointerId!==n.pointerId)return;s=r}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(r.type)&&!(["pointercancel","contextmenu"].includes(r.type)&&(t.browser.isSafari||t.browser.isWebView)))return;n.pointerId=null,n.touchId=null;const{params:a,touches:c,rtlTranslate:u,slidesGrid:f,enabled:p}=t;if(!p||!a.simulateTouch&&r.pointerType==="mouse")return;if(n.allowTouchCallbacks&&t.emit("touchEnd",r),n.allowTouchCallbacks=!1,!n.isTouched){n.isMoved&&a.grabCursor&&t.setGrabCursor(!1),n.isMoved=!1,n.startMoving=!1;return}a.grabCursor&&n.isMoved&&n.isTouched&&(t.allowSlideNext===!0||t.allowSlidePrev===!0)&&t.setGrabCursor(!1);const g=Jm(),y=g-n.touchStartTime;if(t.allowClick){const F=r.path||r.composedPath&&r.composedPath();t.updateClickedSlide(F&&F[0]||r.target,F),t.emit("tap click",r),y<300&&g-n.lastClickTime<300&&t.emit("doubleTap doubleClick",r)}if(n.lastClickTime=Jm(),AS(()=>{t.destroyed||(t.allowClick=!0)}),!n.isTouched||!n.isMoved||!t.swipeDirection||c.diff===0&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset){n.isTouched=!1,n.isMoved=!1,n.startMoving=!1;return}n.isTouched=!1,n.isMoved=!1,n.startMoving=!1;let v;if(a.followFinger?v=u?t.translate:-t.translate:v=-n.currentTranslate,a.cssMode)return;if(a.freeMode&&a.freeMode.enabled){t.freeMode.onTouchEnd({currentPos:v});return}const S=v>=-t.maxTranslate()&&!t.params.loop;let A=0,C=t.slidesSizesGrid[0];for(let F=0;F<f.length;F+=F<a.slidesPerGroupSkip?1:a.slidesPerGroup){const j=F<a.slidesPerGroupSkip-1?1:a.slidesPerGroup;typeof f[F+j]<"u"?(S||v>=f[F]&&v<f[F+j])&&(A=F,C=f[F+j]-f[F]):(S||v>=f[F])&&(A=F,C=f[f.length-1]-f[f.length-2])}let L=null,E=null;a.rewind&&(t.isBeginning?E=a.virtual&&a.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(L=0));const M=(v-f[A])/C,P=A<a.slidesPerGroupSkip-1?1:a.slidesPerGroup;if(y>a.longSwipesMs){if(!a.longSwipes){t.slideTo(t.activeIndex);return}t.swipeDirection==="next"&&(M>=a.longSwipesRatio?t.slideTo(a.rewind&&t.isEnd?L:A+P):t.slideTo(A)),t.swipeDirection==="prev"&&(M>1-a.longSwipesRatio?t.slideTo(A+P):E!==null&&M<0&&Math.abs(M)>a.longSwipesRatio?t.slideTo(E):t.slideTo(A))}else{if(!a.shortSwipes){t.slideTo(t.activeIndex);return}t.navigation&&(r.target===t.navigation.nextEl||r.target===t.navigation.prevEl)?r.target===t.navigation.nextEl?t.slideTo(A+P):t.slideTo(A):(t.swipeDirection==="next"&&t.slideTo(L!==null?L:A+P),t.swipeDirection==="prev"&&t.slideTo(E!==null?E:A))}}function C5(){const e=this,{params:t,el:n}=e;if(n&&n.offsetWidth===0)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:r,allowSlidePrev:s,snapGrid:i}=e,a=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const c=a&&t.loop;if((t.slidesPerView==="auto"||t.slidesPerView>1)&&e.isEnd&&!e.isBeginning&&!e.params.centeredSlides&&!c){const u=a?e.virtual.slides:e.slides;e.slideTo(u.length-1,0,!1,!0)}else e.params.loop&&!a?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0);e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=s,e.allowSlideNext=r,e.params.watchOverflow&&i!==e.snapGrid&&e.checkOverflow()}function VL(e){const t=this;t.destroyed||t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function qL(){const e=this;if(e.destroyed)return;const{wrapperEl:t,rtlTranslate:n,enabled:r}=e;if(!r)return;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,e.translate===0&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();let s;const i=e.maxTranslate()-e.minTranslate();i===0?s=0:s=(e.translate-e.minTranslate())/i,s!==e.progress&&e.updateProgress(n?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function KL(e){const t=this;t.destroyed||(km(t,e.target),!(t.params.cssMode||t.params.slidesPerView!=="auto"&&!t.params.autoHeight)&&t.update())}function YL(){const e=this;e.destroyed||e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const ES=(e,t)=>{const n=ud(),{params:r,el:s,wrapperEl:i,device:a}=e,c=!!r.nested,u=t==="on"?"addEventListener":"removeEventListener",f=t;!s||typeof s=="string"||(n[u]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:c}),s[u]("touchstart",e.onTouchStart,{passive:!1}),s[u]("pointerdown",e.onTouchStart,{passive:!1}),n[u]("touchmove",e.onTouchMove,{passive:!1,capture:c}),n[u]("pointermove",e.onTouchMove,{passive:!1,capture:c}),n[u]("touchend",e.onTouchEnd,{passive:!0}),n[u]("pointerup",e.onTouchEnd,{passive:!0}),n[u]("pointercancel",e.onTouchEnd,{passive:!0}),n[u]("touchcancel",e.onTouchEnd,{passive:!0}),n[u]("pointerout",e.onTouchEnd,{passive:!0}),n[u]("pointerleave",e.onTouchEnd,{passive:!0}),n[u]("contextmenu",e.onTouchEnd,{passive:!0}),(r.preventClicks||r.preventClicksPropagation)&&s[u]("click",e.onClick,!0),r.cssMode&&i[u]("scroll",e.onScroll),r.updateOnWindowResize?e[f](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",C5,!0):e[f]("observerUpdate",C5,!0),s[u]("load",e.onLoad,{capture:!0}))};function XL(){const e=this,{params:t}=e;e.onTouchStart=UL.bind(e),e.onTouchMove=GL.bind(e),e.onTouchEnd=WL.bind(e),e.onDocumentTouchStart=YL.bind(e),t.cssMode&&(e.onScroll=qL.bind(e)),e.onClick=VL.bind(e),e.onLoad=KL.bind(e),ES(e,"on")}function ZL(){ES(this,"off")}var JL={attachEvents:XL,detachEvents:ZL};const k5=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;function eE(){const e=this,{realIndex:t,initialized:n,params:r,el:s}=e,i=r.breakpoints;if(!i||i&&Object.keys(i).length===0)return;const a=ud(),c=r.breakpointsBase==="window"||!r.breakpointsBase?r.breakpointsBase:"container",u=["window","container"].includes(r.breakpointsBase)||!r.breakpointsBase?e.el:a.querySelector(r.breakpointsBase),f=e.getBreakpoint(i,c,u);if(!f||e.currentBreakpoint===f)return;const g=(f in i?i[f]:void 0)||e.originalParams,y=k5(e,r),v=k5(e,g),S=e.params.grabCursor,A=g.grabCursor,C=r.enabled;y&&!v?(s.classList.remove(`${r.containerModifierClass}grid`,`${r.containerModifierClass}grid-column`),e.emitContainerClasses()):!y&&v&&(s.classList.add(`${r.containerModifierClass}grid`),(g.grid.fill&&g.grid.fill==="column"||!g.grid.fill&&r.grid.fill==="column")&&s.classList.add(`${r.containerModifierClass}grid-column`),e.emitContainerClasses()),S&&!A?e.unsetGrabCursor():!S&&A&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(j=>{if(typeof g[j]>"u")return;const T=r[j]&&r[j].enabled,Q=g[j]&&g[j].enabled;T&&!Q&&e[j].disable(),!T&&Q&&e[j].enable()});const L=g.direction&&g.direction!==r.direction,E=r.loop&&(g.slidesPerView!==r.slidesPerView||L),M=r.loop;L&&n&&e.changeDirection(),Ua(e.params,g);const P=e.params.enabled,F=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),C&&!P?e.disable():!C&&P&&e.enable(),e.currentBreakpoint=f,e.emit("_beforeBreakpoint",g),n&&(E?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!M&&F?(e.loopCreate(t),e.updateSlides()):M&&!F&&e.loopDestroy()),e.emit("breakpoint",g)}function tE(e,t="window",n){if(!e||t==="container"&&!n)return;let r=!1;const s=da(),i=t==="window"?s.innerHeight:n.clientHeight,a=Object.keys(e).map(c=>{if(typeof c=="string"&&c.indexOf("@")===0){const u=parseFloat(c.substr(1));return{value:i*u,point:c}}return{value:c,point:c}});a.sort((c,u)=>parseInt(c.value,10)-parseInt(u.value,10));for(let c=0;c<a.length;c+=1){const{point:u,value:f}=a[c];t==="window"?s.matchMedia(`(min-width: ${f}px)`).matches&&(r=u):f<=n.clientWidth&&(r=u)}return r||"max"}var nE={setBreakpoint:eE,getBreakpoint:tE};function rE(e,t){const n=[];return e.forEach(r=>{typeof r=="object"?Object.keys(r).forEach(s=>{r[s]&&n.push(t+s)}):typeof r=="string"&&n.push(t+r)}),n}function sE(){const e=this,{classNames:t,params:n,rtl:r,el:s,device:i}=e,a=rE(["initialized",n.direction,{"free-mode":e.params.freeMode&&n.freeMode.enabled},{autoheight:n.autoHeight},{rtl:r},{grid:n.grid&&n.grid.rows>1},{"grid-column":n.grid&&n.grid.rows>1&&n.grid.fill==="column"},{android:i.android},{ios:i.ios},{"css-mode":n.cssMode},{centered:n.cssMode&&n.centeredSlides},{"watch-progress":n.watchSlidesProgress}],n.containerModifierClass);t.push(...a),s.classList.add(...t),e.emitContainerClasses()}function iE(){const e=this,{el:t,classNames:n}=e;!t||typeof t=="string"||(t.classList.remove(...n),e.emitContainerClasses())}var oE={addClasses:sE,removeClasses:iE};function aE(){const e=this,{isLocked:t,params:n}=e,{slidesOffsetBefore:r}=n;if(r){const s=e.slides.length-1,i=e.slidesGrid[s]+e.slidesSizesGrid[s]+r*2;e.isLocked=e.size>i}else e.isLocked=e.snapGrid.length===1;n.allowSlideNext===!0&&(e.allowSlideNext=!e.isLocked),n.allowSlidePrev===!0&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}var lE={checkOverflow:aE},Kb={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,snapToSlideEdge:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function cE(e,t){return function(r={}){const s=Object.keys(r)[0],i=r[s];if(typeof i!="object"||i===null){Ua(t,r);return}if(e[s]===!0&&(e[s]={enabled:!0}),s==="navigation"&&e[s]&&e[s].enabled&&!e[s].prevEl&&!e[s].nextEl&&(e[s].auto=!0),["pagination","scrollbar"].indexOf(s)>=0&&e[s]&&e[s].enabled&&!e[s].el&&(e[s].auto=!0),!(s in e&&"enabled"in i)){Ua(t,r);return}typeof e[s]=="object"&&!("enabled"in e[s])&&(e[s].enabled=!0),e[s]||(e[s]={enabled:!1}),Ua(t,r)}}const ex={eventsEmitter:oL,update:xL,translate:AL,transition:_L,slide:jL,loop:OL,grabCursor:HL,events:JL,breakpoints:nE,checkOverflow:lE,classes:oE},tx={};let My=class Dc{constructor(...t){let n,r;t.length===1&&t[0].constructor&&Object.prototype.toString.call(t[0]).slice(8,-1)==="Object"?r=t[0]:[n,r]=t,r||(r={}),r=Ua({},r),n&&!r.el&&(r.el=n);const s=ud();if(r.el&&typeof r.el=="string"&&s.querySelectorAll(r.el).length>1){const u=[];return s.querySelectorAll(r.el).forEach(f=>{const p=Ua({},r,{el:f});u.push(new Dc(p))}),u}const i=this;i.__swiper__=!0,i.support=CS(),i.device=kS({userAgent:r.userAgent}),i.browser=_S(),i.eventsListeners={},i.eventsAnyListeners=[],i.modules=[...i.__modules__],r.modules&&Array.isArray(r.modules)&&r.modules.forEach(u=>{typeof u=="function"&&i.modules.indexOf(u)<0&&i.modules.push(u)});const a={};i.modules.forEach(u=>{u({params:r,swiper:i,extendParams:cE(r,a),on:i.on.bind(i),once:i.once.bind(i),off:i.off.bind(i),emit:i.emit.bind(i)})});const c=Ua({},Kb,a);return i.params=Ua({},c,tx,r),i.originalParams=Ua({},i.params),i.passedParams=Ua({},r),i.params&&i.params.on&&Object.keys(i.params.on).forEach(u=>{i.on(u,i.params.on[u])}),i.params&&i.params.onAny&&i.onAny(i.params.onAny),Object.assign(i,{enabled:i.params.enabled,el:n,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal(){return i.params.direction==="horizontal"},isVertical(){return i.params.direction==="vertical"},activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:i.params.allowSlideNext,allowSlidePrev:i.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:i.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:i.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),i.emit("_swiper"),i.params.init&&i.init(),i}getDirectionLabel(t){return this.isHorizontal()?t:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[t]}getSlideIndex(t){const{slidesEl:n,params:r}=this,s=Bc(n,`.${r.slideClass}, swiper-slide`),i=v5(s[0]);return v5(t)-i}getSlideIndexByData(t){return this.getSlideIndex(this.slides.find(n=>n.getAttribute("data-swiper-slide-index")*1===t))}getSlideIndexWhenGrid(t){return this.grid&&this.params.grid&&this.params.grid.rows>1&&(this.params.grid.fill==="column"?t=Math.floor(t/this.params.grid.rows):this.params.grid.fill==="row"&&(t=t%Math.ceil(this.slides.length/this.params.grid.rows))),t}recalcSlides(){const t=this,{slidesEl:n,params:r}=t;t.slides=Bc(n,`.${r.slideClass}, swiper-slide`)}enable(){const t=this;t.enabled||(t.enabled=!0,t.params.grabCursor&&t.setGrabCursor(),t.emit("enable"))}disable(){const t=this;t.enabled&&(t.enabled=!1,t.params.grabCursor&&t.unsetGrabCursor(),t.emit("disable"))}setProgress(t,n){const r=this;t=Math.min(Math.max(t,0),1);const s=r.minTranslate(),a=(r.maxTranslate()-s)*t+s;r.translateTo(a,typeof n>"u"?0:n),r.updateActiveIndex(),r.updateSlidesClasses()}emitContainerClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const n=t.el.className.split(" ").filter(r=>r.indexOf("swiper")===0||r.indexOf(t.params.containerModifierClass)===0);t.emit("_containerClasses",n.join(" "))}getSlideClasses(t){const n=this;return n.destroyed?"":t.className.split(" ").filter(r=>r.indexOf("swiper-slide")===0||r.indexOf(n.params.slideClass)===0).join(" ")}emitSlidesClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const n=[];t.slides.forEach(r=>{const s=t.getSlideClasses(r);n.push({slideEl:r,classNames:s}),t.emit("_slideClass",r,s)}),t.emit("_slideClasses",n)}slidesPerViewDynamic(t="current",n=!1){const r=this,{params:s,slides:i,slidesGrid:a,slidesSizesGrid:c,size:u,activeIndex:f}=r;let p=1;if(typeof s.slidesPerView=="number")return s.slidesPerView;if(s.centeredSlides){let g=i[f]?Math.ceil(i[f].swiperSlideSize):0,y;for(let v=f+1;v<i.length;v+=1)i[v]&&!y&&(g+=Math.ceil(i[v].swiperSlideSize),p+=1,g>u&&(y=!0));for(let v=f-1;v>=0;v-=1)i[v]&&!y&&(g+=i[v].swiperSlideSize,p+=1,g>u&&(y=!0))}else if(t==="current")for(let g=f+1;g<i.length;g+=1)(n?a[g]+c[g]-a[f]<u:a[g]-a[f]<u)&&(p+=1);else for(let g=f-1;g>=0;g-=1)a[f]-a[g]<u&&(p+=1);return p}update(){const t=this;if(!t||t.destroyed)return;const{snapGrid:n,params:r}=t;r.breakpoints&&t.setBreakpoint(),[...t.el.querySelectorAll('[loading="lazy"]')].forEach(a=>{a.complete&&km(t,a)}),t.updateSize(),t.updateSlides(),t.updateProgress(),t.updateSlidesClasses();function s(){const a=t.rtlTranslate?t.translate*-1:t.translate,c=Math.min(Math.max(a,t.maxTranslate()),t.minTranslate());t.setTranslate(c),t.updateActiveIndex(),t.updateSlidesClasses()}let i;if(r.freeMode&&r.freeMode.enabled&&!r.cssMode)s(),r.autoHeight&&t.updateAutoHeight();else{if((r.slidesPerView==="auto"||r.slidesPerView>1)&&t.isEnd&&!r.centeredSlides){const a=t.virtual&&r.virtual.enabled?t.virtual.slides:t.slides;i=t.slideTo(a.length-1,0,!1,!0)}else i=t.slideTo(t.activeIndex,0,!1,!0);i||s()}r.watchOverflow&&n!==t.snapGrid&&t.checkOverflow(),t.emit("update")}changeDirection(t,n=!0){const r=this,s=r.params.direction;return t||(t=s==="horizontal"?"vertical":"horizontal"),t===s||t!=="horizontal"&&t!=="vertical"||(r.el.classList.remove(`${r.params.containerModifierClass}${s}`),r.el.classList.add(`${r.params.containerModifierClass}${t}`),r.emitContainerClasses(),r.params.direction=t,r.slides.forEach(i=>{t==="vertical"?i.style.width="":i.style.height=""}),r.emit("changeDirection"),n&&r.update()),r}changeLanguageDirection(t){const n=this;n.rtl&&t==="rtl"||!n.rtl&&t==="ltr"||(n.rtl=t==="rtl",n.rtlTranslate=n.params.direction==="horizontal"&&n.rtl,n.rtl?(n.el.classList.add(`${n.params.containerModifierClass}rtl`),n.el.dir="rtl"):(n.el.classList.remove(`${n.params.containerModifierClass}rtl`),n.el.dir="ltr"),n.update())}mount(t){const n=this;if(n.mounted)return!0;let r=t||n.params.el;if(typeof r=="string"&&(r=document.querySelector(r)),!r)return!1;r.swiper=n,r.parentNode&&r.parentNode.host&&r.parentNode.host.nodeName===n.params.swiperElementNodeName.toUpperCase()&&(n.isElement=!0);const s=()=>`.${(n.params.wrapperClass||"").trim().split(" ").join(".")}`;let a=r&&r.shadowRoot&&r.shadowRoot.querySelector?r.shadowRoot.querySelector(s()):Bc(r,s())[0];return!a&&n.params.createElements&&(a=Vb("div",n.params.wrapperClass),r.append(a),Bc(r,`.${n.params.slideClass}`).forEach(c=>{a.append(c)})),Object.assign(n,{el:r,wrapperEl:a,slidesEl:n.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:a,hostEl:n.isElement?r.parentNode.host:r,mounted:!0,rtl:r.dir.toLowerCase()==="rtl"||uu(r,"direction")==="rtl",rtlTranslate:n.params.direction==="horizontal"&&(r.dir.toLowerCase()==="rtl"||uu(r,"direction")==="rtl"),wrongRTL:uu(a,"display")==="-webkit-box"}),!0}init(t){const n=this;if(n.initialized||n.mount(t)===!1)return n;n.emit("beforeInit"),n.params.breakpoints&&n.setBreakpoint(),n.addClasses(),n.updateSize(),n.updateSlides(),n.params.watchOverflow&&n.checkOverflow(),n.params.grabCursor&&n.enabled&&n.setGrabCursor(),n.params.loop&&n.virtual&&n.params.virtual.enabled?n.slideTo(n.params.initialSlide+n.virtual.slidesBefore,0,n.params.runCallbacksOnInit,!1,!0):n.slideTo(n.params.initialSlide,0,n.params.runCallbacksOnInit,!1,!0),n.params.loop&&n.loopCreate(void 0,!0),n.attachEvents();const s=[...n.el.querySelectorAll('[loading="lazy"]')];return n.isElement&&s.push(...n.hostEl.querySelectorAll('[loading="lazy"]')),s.forEach(i=>{i.complete?km(n,i):i.addEventListener("load",a=>{km(n,a.target)})}),qb(n),n.initialized=!0,qb(n),n.emit("init"),n.emit("afterInit"),n}destroy(t=!0,n=!0){const r=this,{params:s,el:i,wrapperEl:a,slides:c}=r;return typeof r.params>"u"||r.destroyed||(r.emit("beforeDestroy"),r.initialized=!1,r.detachEvents(),s.loop&&r.loopDestroy(),n&&(r.removeClasses(),i&&typeof i!="string"&&i.removeAttribute("style"),a&&a.removeAttribute("style"),c&&c.length&&c.forEach(u=>{u.classList.remove(s.slideVisibleClass,s.slideFullyVisibleClass,s.slideActiveClass,s.slideNextClass,s.slidePrevClass),u.removeAttribute("style"),u.removeAttribute("data-swiper-slide-index")})),r.emit("destroy"),Object.keys(r.eventsListeners).forEach(u=>{r.off(u)}),t!==!1&&(r.el&&typeof r.el!="string"&&(r.el.swiper=null),W_(r)),r.destroyed=!0),null}static extendDefaults(t){Ua(tx,t)}static get extendedDefaults(){return tx}static get defaults(){return Kb}static installModule(t){Dc.prototype.__modules__||(Dc.prototype.__modules__=[]);const n=Dc.prototype.__modules__;typeof t=="function"&&n.indexOf(t)<0&&n.push(t)}static use(t){return Array.isArray(t)?(t.forEach(n=>Dc.installModule(n)),Dc):(Dc.installModule(t),Dc)}};Object.keys(ex).forEach(e=>{Object.keys(ex[e]).forEach(t=>{My.prototype[t]=ex[e][t]})});My.use([sL,iL]);const IS=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","breakpointsBase","_spaceBetween","_slidesPerView","maxBackfaceHiddenSlides","_grid","_slidesPerGroup","_slidesPerGroupSkip","_slidesPerGroupAuto","_centeredSlides","_centeredSlidesBounds","_slidesOffsetBefore","_slidesOffsetAfter","normalizeSlideIndex","_centerInsufficientSlides","_snapToSlideEdge","_watchOverflow","roundLengths","touchRatio","touchAngle","simulateTouch","_shortSwipes","_longSwipes","longSwipesRatio","longSwipesMs","_followFinger","allowTouchMove","_threshold","touchMoveStopPropagation","touchStartPreventDefault","touchStartForcePreventDefault","touchReleaseOnEdges","uniqueNavElements","_resistance","_resistanceRatio","_watchSlidesProgress","_grabCursor","preventClicks","preventClicksPropagation","_slideToClickedSlide","_loop","loopAdditionalSlides","loopAddBlankSlides","loopPreventsSliding","_rewind","_allowSlidePrev","_allowSlideNext","_swipeHandler","_noSwiping","noSwipingClass","noSwipingSelector","passiveListeners","containerModifierClass","slideClass","slideActiveClass","slideVisibleClass","slideFullyVisibleClass","slideNextClass","slidePrevClass","slideBlankClass","wrapperClass","lazyPreloaderClass","lazyPreloadPrevNext","runCallbacksOnInit","observer","observeParents","observeSlideChildren","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function sd(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"&&!e.__swiper__}function m0(e,t){const n=["__proto__","constructor","prototype"];Object.keys(t).filter(r=>n.indexOf(r)<0).forEach(r=>{typeof e[r]>"u"?e[r]=t[r]:sd(t[r])&&sd(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:m0(e[r],t[r]):e[r]=t[r]})}function RS(e={}){return e.navigation&&typeof e.navigation.nextEl>"u"&&typeof e.navigation.prevEl>"u"}function NS(e={}){return e.pagination&&typeof e.pagination.el>"u"}function MS(e={}){return e.scrollbar&&typeof e.scrollbar.el>"u"}function DS(e=""){const t=e.split(" ").map(r=>r.trim()).filter(r=>!!r),n=[];return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n.join(" ")}function uE(e=""){return e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function dE({swiper:e,slides:t,passedParams:n,changedParams:r,nextEl:s,prevEl:i,scrollbarEl:a,paginationEl:c}){const u=r.filter(Q=>Q!=="children"&&Q!=="direction"&&Q!=="wrapperClass"),{params:f,pagination:p,navigation:g,scrollbar:y,virtual:v,thumbs:S}=e;let A,C,L,E,M,P,F,j;r.includes("thumbs")&&n.thumbs&&n.thumbs.swiper&&!n.thumbs.swiper.destroyed&&f.thumbs&&(!f.thumbs.swiper||f.thumbs.swiper.destroyed)&&(A=!0),r.includes("controller")&&n.controller&&n.controller.control&&f.controller&&!f.controller.control&&(C=!0),r.includes("pagination")&&n.pagination&&(n.pagination.el||c)&&(f.pagination||f.pagination===!1)&&p&&!p.el&&(L=!0),r.includes("scrollbar")&&n.scrollbar&&(n.scrollbar.el||a)&&(f.scrollbar||f.scrollbar===!1)&&y&&!y.el&&(E=!0),r.includes("navigation")&&n.navigation&&(n.navigation.prevEl||i)&&(n.navigation.nextEl||s)&&(f.navigation||f.navigation===!1)&&g&&!g.prevEl&&!g.nextEl&&(M=!0);const T=Q=>{e[Q]&&(e[Q].destroy(),Q==="navigation"?(e.isElement&&(e[Q].prevEl.remove(),e[Q].nextEl.remove()),f[Q].prevEl=void 0,f[Q].nextEl=void 0,e[Q].prevEl=void 0,e[Q].nextEl=void 0):(e.isElement&&e[Q].el.remove(),f[Q].el=void 0,e[Q].el=void 0))};r.includes("loop")&&e.isElement&&(f.loop&&!n.loop?P=!0:!f.loop&&n.loop?F=!0:j=!0),u.forEach(Q=>{if(sd(f[Q])&&sd(n[Q]))Object.assign(f[Q],n[Q]),(Q==="navigation"||Q==="pagination"||Q==="scrollbar")&&"enabled"in n[Q]&&!n[Q].enabled&&T(Q);else{const $=n[Q];($===!0||$===!1)&&(Q==="navigation"||Q==="pagination"||Q==="scrollbar")?$===!1&&T(Q):f[Q]=n[Q]}}),u.includes("controller")&&!C&&e.controller&&e.controller.control&&f.controller&&f.controller.control&&(e.controller.control=f.controller.control),r.includes("children")&&t&&v&&f.virtual.enabled?(v.slides=t,v.update(!0)):r.includes("virtual")&&v&&f.virtual.enabled&&(t&&(v.slides=t),v.update(!0)),r.includes("children")&&t&&f.loop&&(j=!0),A&&S.init()&&S.update(!0),C&&(e.controller.control=f.controller.control),L&&(e.isElement&&(!c||typeof c=="string")&&(c=document.createElement("div"),c.classList.add("swiper-pagination"),c.part.add("pagination"),e.el.appendChild(c)),c&&(f.pagination.el=c),p.init(),p.render(),p.update()),E&&(e.isElement&&(!a||typeof a=="string")&&(a=document.createElement("div"),a.classList.add("swiper-scrollbar"),a.part.add("scrollbar"),e.el.appendChild(a)),a&&(f.scrollbar.el=a),y.init(),y.updateSize(),y.setTranslate()),M&&(e.isElement&&((!s||typeof s=="string")&&(s=document.createElement("div"),s.classList.add("swiper-button-next"),S5(s,e.navigation.arrowSvg),s.part.add("button-next"),e.el.appendChild(s)),(!i||typeof i=="string")&&(i=document.createElement("div"),i.classList.add("swiper-button-prev"),S5(i,e.navigation.arrowSvg),i.part.add("button-prev"),e.el.appendChild(i))),s&&(f.navigation.nextEl=s),i&&(f.navigation.prevEl=i),g.init(),g.update()),r.includes("allowSlideNext")&&(e.allowSlideNext=n.allowSlideNext),r.includes("allowSlidePrev")&&(e.allowSlidePrev=n.allowSlidePrev),r.includes("direction")&&e.changeDirection(n.direction,!1),(P||j)&&e.loopDestroy(),(F||j)&&e.loopCreate(),e.update()}function fE(e={},t=!0){const n={on:{}},r={},s={};m0(n,Kb),n._emitClasses=!0,n.init=!1;const i={},a=IS.map(u=>u.replace(/_/,"")),c=Object.assign({},e);return Object.keys(c).forEach(u=>{typeof e[u]>"u"||(a.indexOf(u)>=0?sd(e[u])?(n[u]={},s[u]={},m0(n[u],e[u]),m0(s[u],e[u])):(n[u]=e[u],s[u]=e[u]):u.search(/on[A-Z]/)===0&&typeof e[u]=="function"?t?r[`${u[2].toLowerCase()}${u.substr(3)}`]=e[u]:n.on[`${u[2].toLowerCase()}${u.substr(3)}`]=e[u]:i[u]=e[u])}),["navigation","pagination","scrollbar"].forEach(u=>{n[u]===!0&&(n[u]={}),n[u]===!1&&delete n[u]}),{params:n,passedParams:s,rest:i,events:r}}function hE({el:e,nextEl:t,prevEl:n,paginationEl:r,scrollbarEl:s,swiper:i},a){RS(a)&&t&&n&&(i.params.navigation.nextEl=t,i.originalParams.navigation.nextEl=t,i.params.navigation.prevEl=n,i.originalParams.navigation.prevEl=n),NS(a)&&r&&(i.params.pagination.el=r,i.originalParams.pagination.el=r),MS(a)&&s&&(i.params.scrollbar.el=s,i.originalParams.scrollbar.el=s),i.init(e)}function pE(e,t,n,r,s){const i=[];if(!t)return i;const a=u=>{i.indexOf(u)<0&&i.push(u)};if(n&&r){const u=r.map(s),f=n.map(s);u.join("")!==f.join("")&&a("children"),r.length!==n.length&&a("children")}return IS.filter(u=>u[0]==="_").map(u=>u.replace(/_/,"")).forEach(u=>{if(u in e&&u in t)if(sd(e[u])&&sd(t[u])){const f=Object.keys(e[u]),p=Object.keys(t[u]);f.length!==p.length?a(u):(f.forEach(g=>{e[u][g]!==t[u][g]&&a(u)}),p.forEach(g=>{e[u][g]!==t[u][g]&&a(u)}))}else e[u]!==t[u]&&a(u)}),i}const mE=e=>{!e||e.destroyed||!e.params.virtual||e.params.virtual&&!e.params.virtual.enabled||(e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),e.emit("_virtualUpdated"),e.parallax&&e.params.parallax&&e.params.parallax.enabled&&e.parallax.setTranslate())};function tg(){return tg=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},tg.apply(this,arguments)}function jS(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function PS(e){const t=[];return D.Children.toArray(e).forEach(n=>{jS(n)?t.push(n):n.props&&n.props.children&&PS(n.props.children).forEach(r=>t.push(r))}),t}function gE(e){const t=[],n={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return D.Children.toArray(e).forEach(r=>{if(jS(r))t.push(r);else if(r.props&&r.props.slot&&n[r.props.slot])n[r.props.slot].push(r);else if(r.props&&r.props.children){const s=PS(r.props.children);s.length>0?s.forEach(i=>t.push(i)):n["container-end"].push(r)}else n["container-end"].push(r)}),{slides:t,slots:n}}function xE(e,t,n){if(!n)return null;const r=p=>{let g=p;return p<0?g=t.length+p:g>=t.length&&(g=g-t.length),g},s=e.isHorizontal()?{[e.rtlTranslate?"right":"left"]:`${n.offset}px`}:{top:`${n.offset}px`},{from:i,to:a}=n,c=e.params.loop?-t.length:0,u=e.params.loop?t.length*2:t.length,f=[];for(let p=c;p<u;p+=1)p>=i&&p<=a&&f.push(t[r(p)]);return f.map((p,g)=>D.cloneElement(p,{swiper:e,style:s,key:p.props.virtualIndex||p.key||`slide-${g}`}))}function oh(e,t){return typeof window>"u"?x.useEffect(e,t):x.useLayoutEffect(e,t)}const _5=x.createContext(null),bE=x.createContext(null),$h=x.forwardRef(({className:e,tag:t="div",wrapperTag:n="div",children:r,onSwiper:s,...i}={},a)=>{let c=!1;const[u,f]=x.useState("swiper"),[p,g]=x.useState(null),[y,v]=x.useState(!1),S=x.useRef(!1),A=x.useRef(null),C=x.useRef(null),L=x.useRef(null),E=x.useRef(null),M=x.useRef(null),P=x.useRef(null),F=x.useRef(null),j=x.useRef(null),{params:T,passedParams:Q,rest:$,events:Z}=fE(i),{slides:V,slots:fe}=gE(r),X=()=>{v(!y)};Object.assign(T.on,{_containerClasses(U,G){f(G)}});const ge=()=>{Object.assign(T.on,Z),c=!0;const U={...T};if(delete U.wrapperClass,C.current=new My(U),C.current.virtual&&C.current.params.virtual.enabled){C.current.virtual.slides=V;const G={cache:!1,slides:V,renderExternal:g,renderExternalUpdate:!1};m0(C.current.params.virtual,G),m0(C.current.originalParams.virtual,G)}};A.current||ge(),C.current&&C.current.on("_beforeBreakpoint",X);const be=()=>{c||!Z||!C.current||Object.keys(Z).forEach(U=>{C.current.on(U,Z[U])})},Te=()=>{!Z||!C.current||Object.keys(Z).forEach(U=>{C.current.off(U,Z[U])})};x.useEffect(()=>()=>{C.current&&C.current.off("_beforeBreakpoint",X)}),x.useEffect(()=>{!S.current&&C.current&&(C.current.emitSlidesClasses(),S.current=!0)}),oh(()=>{if(a&&(a.current=A.current),!!A.current)return C.current.destroyed&&ge(),hE({el:A.current,nextEl:M.current,prevEl:P.current,paginationEl:F.current,scrollbarEl:j.current,swiper:C.current},T),s&&!C.current.destroyed&&s(C.current),()=>{C.current&&!C.current.destroyed&&C.current.destroy(!0,!1)}},[]),oh(()=>{be();const U=pE(Q,L.current,V,E.current,G=>G.key);return L.current=Q,E.current=V,U.length&&C.current&&!C.current.destroyed&&dE({swiper:C.current,slides:V,passedParams:Q,changedParams:U,nextEl:M.current,prevEl:P.current,scrollbarEl:j.current,paginationEl:F.current}),()=>{Te()}}),oh(()=>{mE(C.current)},[p]);function ie(){return T.virtual?xE(C.current,V,p):V.map((U,G)=>D.cloneElement(U,{swiper:C.current,swiperSlideIndex:G}))}return D.createElement(t,tg({ref:A,className:DS(`${u}${e?` ${e}`:""}`)},$),D.createElement(bE.Provider,{value:C.current},fe["container-start"],D.createElement(n,{className:uE(T.wrapperClass)},fe["wrapper-start"],ie(),fe["wrapper-end"]),RS(T)&&D.createElement(D.Fragment,null,D.createElement("div",{ref:P,className:"swiper-button-prev"}),D.createElement("div",{ref:M,className:"swiper-button-next"})),MS(T)&&D.createElement("div",{ref:j,className:"swiper-scrollbar"}),NS(T)&&D.createElement("div",{ref:F,className:"swiper-pagination"}),fe["container-end"]))});$h.displayName="Swiper";const id=x.forwardRef(({tag:e="div",children:t,className:n="",swiper:r,zoom:s,lazy:i,virtualIndex:a,swiperSlideIndex:c,...u}={},f)=>{const p=x.useRef(null),[g,y]=x.useState("swiper-slide"),[v,S]=x.useState(!1);function A(M,P,F){P===p.current&&y(F)}oh(()=>{if(typeof c<"u"&&(p.current.swiperSlideIndex=c),f&&(f.current=p.current),!(!p.current||!r)){if(r.destroyed){g!=="swiper-slide"&&y("swiper-slide");return}return r.on("_slideClass",A),()=>{r&&r.off("_slideClass",A)}}}),oh(()=>{r&&p.current&&!r.destroyed&&y(r.getSlideClasses(p.current))},[r]);const C={isActive:g.indexOf("swiper-slide-active")>=0,isVisible:g.indexOf("swiper-slide-visible")>=0,isFullyVisible:g.indexOf("swiper-slide-fully-visible")>=0,isPrev:g.indexOf("swiper-slide-prev")>=0,isNext:g.indexOf("swiper-slide-next")>=0},L=()=>typeof t=="function"?t(C):t,E=()=>{S(!0)};return D.createElement(e,tg({ref:p,className:DS(`${g}${n?` ${n}`:""}`),"data-swiper-slide-index":a,onLoad:E},u),s&&D.createElement(_5.Provider,{value:C},D.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":typeof s=="number"?s:void 0},L(),i&&!v&&D.createElement("div",{className:"swiper-lazy-preloader",ref:M=>{M&&(M.lazyPreloaderManaged=!0)}}))),!s&&D.createElement(_5.Provider,{value:C},L(),i&&!v&&D.createElement("div",{className:"swiper-lazy-preloader",ref:M=>{M&&(M.lazyPreloaderManaged=!0)}})))});id.displayName="SwiperSlide";const xo=[];for(let e=0;e<256;++e)xo.push((e+256).toString(16).slice(1));function yE(e,t=0){return(xo[e[t+0]]+xo[e[t+1]]+xo[e[t+2]]+xo[e[t+3]]+"-"+xo[e[t+4]]+xo[e[t+5]]+"-"+xo[e[t+6]]+xo[e[t+7]]+"-"+xo[e[t+8]]+xo[e[t+9]]+"-"+xo[e[t+10]]+xo[e[t+11]]+xo[e[t+12]]+xo[e[t+13]]+xo[e[t+14]]+xo[e[t+15]]).toLowerCase()}let nx;const vE=new Uint8Array(16);function wE(){if(!nx){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");nx=crypto.getRandomValues.bind(crypto)}return nx(vE)}const SE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),L5={randomUUID:SE};function AE(e,t,n){e=e||{};const r=e.random??e.rng?.()??wE();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,yE(r)}function TE(e,t,n){return L5.randomUUID&&!e?L5.randomUUID():AE(e)}const CE={},E5=e=>{let t;const n=new Set,r=(p,g)=>{const y=typeof p=="function"?p(t):p;if(!Object.is(y,t)){const v=t;t=g??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(S=>S(t,v))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(CE?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(r,s,u);return u},kE=e=>e?E5(e):E5;var rx={exports:{}},sx={},ix={exports:{}},ox={};var I5;function _E(){if(I5)return ox;I5=1;var e=$g();function t(g,y){return g===y&&(g!==0||1/g===1/y)||g!==g&&y!==y}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function c(g,y){var v=y(),S=r({inst:{value:v,getSnapshot:y}}),A=S[0].inst,C=S[1];return i(function(){A.value=v,A.getSnapshot=y,u(A)&&C({inst:A})},[g,v,y]),s(function(){return u(A)&&C({inst:A}),g(function(){u(A)&&C({inst:A})})},[g]),a(v),v}function u(g){var y=g.getSnapshot;g=g.value;try{var v=y();return!n(g,v)}catch{return!0}}function f(g,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return ox.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,ox}var R5;function LE(){return R5||(R5=1,ix.exports=_E()),ix.exports}var N5;function EE(){if(N5)return sx;N5=1;var e=$g(),t=LE();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,c=e.useMemo,u=e.useDebugValue;return sx.useSyncExternalStoreWithSelector=function(f,p,g,y,v){var S=i(null);if(S.current===null){var A={hasValue:!1,value:null};S.current=A}else A=S.current;S=c(function(){function L(j){if(!E){if(E=!0,M=j,j=y(j),v!==void 0&&A.hasValue){var T=A.value;if(v(T,j))return P=T}return P=j}if(T=P,r(M,j))return T;var Q=y(j);return v!==void 0&&v(T,Q)?(M=j,T):(M=j,P=Q)}var E=!1,M,P,F=g===void 0?null:g;return[function(){return L(p())},F===null?void 0:function(){return L(F())}]},[p,g,y,v]);var C=s(f,S[0],S[1]);return a(function(){A.hasValue=!0,A.value=C},[C]),u(C),C},sx}var M5;function IE(){return M5||(M5=1,rx.exports=EE()),rx.exports}var RE=IE();const NE=wS(RE),BS={},{useDebugValue:ME}=D,{useSyncExternalStoreWithSelector:DE}=NE;let D5=!1;const jE=e=>e;function PE(e,t=jE,n){(BS?"production":void 0)!=="production"&&n&&!D5&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),D5=!0);const r=DE(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return ME(r),r}const j5=e=>{(BS?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?kE(e):e,n=(r,s)=>PE(t,r,s);return Object.assign(n,t),n},FS=e=>e?j5(e):j5,yh="auth:unauthorized";let Ku=null;class Xa extends Error{constructor(t,n,r){super(t),this.status=n,this.code=r,this.name="TerminalApiError"}status;code}async function BE(){const e=await fetch("/api/terminal/update");if(!e.ok)throw new Xa("Failed to load update state",e.status);return e.json()}async function FE(){const e=await hr(),t=await fetch("/api/terminal/update/check",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new Xa("Failed to check for updates",t.status);return t.json()}async function OE(){const e=await hr(),t=await fetch("/api/terminal/update/restart",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok){const n=await t.json().catch(()=>({error:"Failed to restart Termdock"}));throw new Xa(n.error||"Failed to restart Termdock",t.status)}return t.json()}async function QE(){const e=await fetch("/api/terminal/quota");if(!e.ok)throw new Xa("Failed to fetch quota",e.status);return e.json()}async function $E(){const e=await hr(),t=await fetch("/api/terminal/quota/refresh",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new Xa("Failed to refresh quota",t.status);return t.json()}const Au=8e3,HE=32e3,vc=1e4,g0=45e3,zE=8e3,UE=8e3,GE=15e3,WE=1e4,T0=5e3;let VE=0;const _m=[];let ax=!1;function tu(e,t={}){if(typeof window>"u")return;const n=JSON.stringify({level:e==="error"||e==="timeout_or_abort"||e==="response_body_timeout"||e==="response_body_parse_error"?"warn":"info",message:`DIFF_API ${e}`,data:{seq:++VE,ts:Date.now(),...t}});_m.push(n),qE()}async function qE(){if(!ax){ax=!0;try{for(;_m.length>0;){const e=_m[0];try{await fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}),_m.shift()}catch{break}}}finally{ax=!1}}}function KE(e,t,n){const r=new AbortController;let s=setTimeout(()=>{r.abort(new DOMException(n,"TimeoutError"))},t);const i=()=>r.abort(e?.reason);return e&&(e.aborted?i():e.addEventListener("abort",i,{once:!0})),{signal:r.signal,cleanup:()=>{s&&(clearTimeout(s),s=null),e?.removeEventListener("abort",i)}}}async function ks(e,t,n,r){const{signal:s,cleanup:i}=KE(t?.signal??void 0,n,r);try{return await fetch(e,{...t,signal:s})}catch(a){throw a instanceof DOMException&&a.name==="TimeoutError"?new Error(r):a}finally{i()}}async function OS(e,t,n){let r=null;const s=new Promise((i,a)=>{r=setTimeout(()=>a(new Error(n)),t)});try{return await Promise.race([e.text(),s])}finally{r&&clearTimeout(r)}}async function C0(e,t,n){const r=await OS(e,t,n);return JSON.parse(r)}if(typeof window<"u"&&!window.__termdockFetchPatched){window.__termdockFetchPatched=!0;const e=window.fetch.bind(window);window.fetch=async(...t)=>{const n=await e(...t);if(n.status===401){Ku=null;try{window.dispatchEvent(new CustomEvent(yh))}catch{}}return n}}async function hr(){if(Ku)return Ku;const e=await ks("/api/csrf-token",void 0,zE,"CSRF token request timed out");if(!e.ok)throw new Error("Failed to get CSRF token");const t=await C0(e,T0,"CSRF token response timed out");if(!t.csrfToken)throw new Error("Invalid CSRF token response");return Ku=t.csrfToken,Ku}function QS(){Ku=null}const YE=2e4,P5=8e3,XE=1500,Co=new Map,ZE=24,JE=40,eI=40;function tI(e){return e.retryState.retryCount>=2||e.pendingInputs.length>=eI?"congested":e.retryState.retryCount>=1||e.pendingInputs.length>=8?"degraded":"good"}function B5(e){if(e.pendingInputs.length===0||e.ws.readyState!==WebSocket.OPEN)return;const t=e.pendingInputs.splice(0);for(const n of t)try{e.ws.send(JSON.stringify({type:"input",data:n}))}catch{}}function $S(e){if(e.ws.readyState!==WebSocket.OPEN)return;const t=tI(e);if(t==="good"){B5(e);return}if(e.inputFlushTimer)return;const n=t==="congested"?JE:ZE;e.inputFlushTimer=setTimeout(()=>{e.inputFlushTimer=null,B5(e)},n)}const ah=new Map;function nI(e,t,n,r){const s=ah.get(e);s&&(ah.delete(e),t?s.resolve({success:!0,layout:n}):s.reject(new Error(r||"Tmux action failed")))}function rI(e,t){const r=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/terminal/${e}/ws`;return t>0?`${r}?since=${t}`:r}const F5=new Map;async function sI(e){const t=await hr(),n=await fetch("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({cols:e.cols||80,rows:e.rows||24,mode:e.mode||"shell",tmuxSessionName:e.tmuxSessionName,cwd:e.cwd,termType:e.termType})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(r.error||"Failed to create terminal session")}return n.json()}function iI(e,t,n,r={}){const{maxRetries:s=10,initialRetryDelay:i=1e3,maxRetryDelay:a=2e4,connectionTimeout:c=15e3}=r,u={maxRetries:s,initialDelayMs:i,maxDelayMs:a,connectionTimeoutMs:c,retryCount:0,retryTimeout:null,connectionTimeoutId:null,isClosed:!1,isSuspended:!1};let f=null,p=F5.get(e)??0;F5.delete(e);const g=[];let y=!1,v=null;const S=new WeakSet,A=()=>{u.retryTimeout&&(clearTimeout(u.retryTimeout),u.retryTimeout=null),u.connectionTimeoutId&&(clearTimeout(u.connectionTimeoutId),u.connectionTimeoutId=null),v&&(clearTimeout(v),v=null)},C=F=>{F.heartbeatTimer&&(clearInterval(F.heartbeatTimer),F.heartbeatTimer=null),F.pongTimer&&(clearTimeout(F.pongTimer),F.pongTimer=null),F.inputFlushTimer&&(clearTimeout(F.inputFlushTimer),F.inputFlushTimer=null)},L=F=>{C(F),F.heartbeatTimer=setInterval(()=>{if(F.ws.readyState===WebSocket.OPEN){try{F.ws.send(JSON.stringify({type:"ping"}))}catch{}F.pongTimer&&clearTimeout(F.pongTimer),F.pongTimer=setTimeout(()=>{if(Date.now()-F.lastInboundAt>=P5)try{F.ws.close()}catch{}},P5)}},YE)},E=()=>{if(u.isClosed=!0,A(),f){C(f),Co.delete(e);try{f.ws.close()}catch{}f=null}},M=()=>{if(u.isClosed)return;if(f){S.add(f.ws),C(f);try{f.ws.close()}catch{}}const F=rI(e,p),j=new WebSocket(F);y=!1,u.connectionTimeoutId=setTimeout(()=>{j.readyState!==WebSocket.OPEN&&(y=!0,j.close(),P(new Error("WebSocket connection timeout"),!1))},c);const T={ws:j,onEvent:t,onError:n,reconnectNow:()=>{if(!u.isClosed&&(u.isSuspended=!1,!v)){if(A(),f){S.add(f.ws),C(f);try{f.ws.close()}catch{}}t({type:"reconnecting",attempt:Math.min(u.retryCount+1,s),maxAttempts:s}),u.retryCount=Math.min(u.retryCount+1,s),y=!0,v=setTimeout(()=>{v=null,y=!1,M()},0)}},suspendReconnect:()=>{u.isClosed||(u.isSuspended=!0,u.retryTimeout&&(clearTimeout(u.retryTimeout),u.retryTimeout=null))},retryState:u,lastSeq:p,pendingInputs:g,inputFlushTimer:null,heartbeatTimer:null,pongTimer:null,lastInboundAt:Date.now(),inboundSequence:0};j.onopen=()=>{A(),u.retryCount=0,T.lastInboundAt=Date.now(),T.inboundSequence+=1,L(T),$S(T)},j.onmessage=Q=>{T.lastInboundAt=Date.now(),T.inboundSequence+=1;try{const $=JSON.parse(Q.data);if($.type==="pong"){T.pongTimer&&(clearTimeout(T.pongTimer),T.pongTimer=null);return}if($.type==="tmux-result"&&$.reqId){nI($.reqId,$.success!==!1,$.layout,$.error);return}if($.type==="tmux-layout"&&$.layout){t({type:"tmux-layout",layout:$.layout});return}if($.type==="tmux-screen-sync"&&Array.isArray($.chunks)){t({type:"tmux-screen-sync",chunks:$.chunks.filter(V=>typeof V=="string"),cols:typeof $.cols=="number"?$.cols:void 0,rows:typeof $.rows=="number"?$.rows:void 0,generation:typeof $.generation=="number"?$.generation:void 0});return}if($.type==="active-program"){t({type:"active-program",activeProgram:$.activeProgram,activeProgramRaw:$.activeProgramRaw,activeProgramSource:$.activeProgramSource});return}if($.type==="cwd"){t({type:"cwd",cwd:$.cwd});return}if($.type==="agent-status"){t({type:"agent-status",agentStatus:$.agentStatus??null,agentIndicator:$.agentIndicator??null,agentStatusDetail:$.agentStatusDetail??null,agent:$.agent??null,agentMessage:$.agentMessage??null,agentNativeSessionId:$.agentNativeSessionId??null,agentResumeRecovered:$.agentResumeRecovered===!0,agentRich:$.agentRich===!0,agentActivity:typeof $.agentActivity=="number"?$.agentActivity:0,agentCwd:$.agentCwd??null,reviewed:typeof $.reviewed=="boolean"?$.reviewed:null});return}if($.type==="git-status"){t({type:"git-status",gitStatus:$.gitStatus??null});return}if($.type==="quota-status"&&Array.isArray($.providers)){window.dispatchEvent(new CustomEvent("termdock:quota-update",{detail:$.providers}));return}if($.type==="focus-mode"){t({type:"focus-mode",focusTrackingRequested:$.focusTrackingRequested===!0});return}if($.type==="resize-ack"){t({type:"resize-ack",seq:typeof $.seq=="number"?$.seq:void 0,cols:typeof $.cols=="number"?$.cols:void 0,rows:typeof $.rows=="number"?$.rows:void 0,ok:$.ok!==!1,error:typeof $.error=="string"?$.error:void 0});return}if($.type==="pty-size"){t({type:"pty-size",cols:typeof $.cols=="number"?$.cols:void 0,rows:typeof $.rows=="number"?$.rows:void 0,source:typeof $.source=="string"?$.source:void 0});return}if($.type==="shell-title"){t({type:"shell-title",title:typeof $.title=="string"?$.title:""});return}if($.type==="prompt-state"){t({type:"prompt-state",state:$.state==="running"?"running":"idle",exitCode:typeof $.exitCode=="number"?$.exitCode:void 0});return}const Z=$;if(Z.type==="connected"){typeof Z.replayLastSeq=="number"&&Z.replayLastSeq>0&&(p=Z.replayLastSeq,T.lastSeq=p),t(Z);return}if(Z.type==="exit"){E(),t(Z);return}t(Z),Z.type==="data"&&typeof Z.seq=="number"&&Number.isFinite(Z.seq)&&Z.seq>p&&(p=Z.seq,T.lastSeq=p)}catch($){n?.($,!1)}},j.onerror=()=>{S.has(j)||(A(),C(T),y||(y=!0,P(new Error("WebSocket connection error"),!1)))},j.onclose=Q=>{if(!S.has(j)&&(A(),C(T),!u.isClosed&&!y)){if(y=!0,Q.code===4001){console.warn("[Terminal] WS 4001: Session not found on server",{code:Q.code,reason:Q.reason,stack:new Error().stack}),P(new Error("Session not found on server"),!0);return}if(Q.code===4003||Q.code===4401){try{window.dispatchEvent(new CustomEvent(yh))}catch{}P(new Error("Authentication required"),!0);return}P(new Error("WebSocket connection closed"),!1)}},f=T,Co.set(e,f)},P=(F,j)=>{if(!u.isClosed)if(j)n?.(F,!0),E();else{u.retryCount=Math.min(u.retryCount+1,Math.max(1,s));const T=Math.min(i*Math.pow(2,u.retryCount-1),a);if(t({type:"reconnecting",attempt:u.retryCount,maxAttempts:s}),u.isSuspended)return;u.retryTimeout=setTimeout(()=>{u.isClosed||M()},T)}};return M(),E}async function HS(e,t){const n=Co.get(e);if(n){if(n.ws.readyState===WebSocket.OPEN){n.pendingInputs.push(t),$S(n);return}if(n.ws.readyState===WebSocket.CONNECTING){n.pendingInputs.push(t);return}}const r=await hr(),s=await fetch(`/api/terminal/${e}/input`,{method:"POST",headers:{"Content-Type":"text/plain","X-XSRF-TOKEN":r},body:t});if(!s.ok){const i=await s.json().catch(()=>({error:"Failed to send input"}));throw new Error(i.error||"Failed to send terminal input")}}function oI(e,t){const n=Co.get(e);if(!n)return!1;if(n.retryState.isSuspended=!1,n.ws.readyState!==WebSocket.OPEN)return n.reconnectNow(),!0;const r=n.inboundSequence;try{n.ws.send(JSON.stringify({type:"ping"}))}catch{}return setTimeout(()=>{Co.get(e)!==n||n.retryState.isClosed||(n.inboundSequence<=r?n.reconnectNow():t?.())},XE),!0}function aI(e){const t=Co.get(e);return t?(t.reconnectNow(),!0):!1}function O5(){for(const e of Co.values())e.suspendReconnect()}function Q5(e,t,n){const r=Co.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"focus",focused:t,reason:n}))}catch{}}function $5(e,t,n){const r=Co.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"viewing",viewing:t,reason:n}))}catch{}}function H5(e){const t=Co.get(e);if(!(!t||t.ws.readyState!==WebSocket.OPEN))try{t.ws.send(JSON.stringify({type:"agent-review-ack"}))}catch{}}function z5(e,t,n){const r=Co.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"flow-control",paused:t,reason:n}))}catch{}}async function lI(e,t,n,r){const s=Co.get(e);if(s&&s.ws.readyState===WebSocket.OPEN)try{s.ws.send(JSON.stringify({type:"resize",cols:t,rows:n,seq:r}));return}catch{}const i=await hr(),a=await fetch(`/api/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":i},body:JSON.stringify({cols:t,rows:n,seq:r})});if(!a.ok){const u=await a.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(u.error||"Failed to resize terminal")}const c=await a.json().catch(()=>({success:!0}));if(c?.success===!1||c?.ok===!1)throw new Error(c?.error||"Failed to resize terminal")}async function cI(e,t){const n=Co.get(e);if(n&&n.ws.readyState===WebSocket.OPEN)return t.action==="scroll"?(n.ws.send(JSON.stringify({type:"tmux",...t})),{success:!0}):new Promise((i,a)=>{const c=Math.random().toString(36).substring(7);ah.set(c,{resolve:i,reject:a}),n.ws.send(JSON.stringify({type:"tmux",reqId:c,...t})),setTimeout(()=>{ah.has(c)&&(ah.delete(c),a(new Error("Tmux action timed out")))},3e4)});const r=await hr(),s=await fetch(`/api/terminal/${e}/tmux`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify(t)});if(!s.ok){const i=await s.json().catch(()=>({error:"Failed to execute tmux action"}));throw new Error(i.error||"Failed to execute tmux action")}return s.json()}async function zS(e){const t=Co.get(e);if(t){t.retryState.isClosed=!0;try{t.ws.close()}catch{}Co.delete(e)}const n=await hr(),r=await fetch(`/api/terminal/${e}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":n}});if(r.status!==404&&!r.ok){const s=await r.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(s.error||"Failed to close terminal")}}async function uI(e,t){const n=Co.get(e);if(n){n.retryState.isClosed=!0;try{n.ws.close()}catch{}Co.delete(e)}const r=await hr(),s=await fetch(`/api/terminal/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify({...t.cwd?{cwd:t.cwd}:{},cols:t.cols??80,rows:t.rows??24,mode:t.mode,tmuxSessionName:t.tmuxSessionName})});if(!s.ok){const i=await s.json().catch(()=>({error:"Failed to restart terminal"}));throw new Error(i.error||"Failed to restart terminal session")}return s.json()}async function dI(e){const t=await ks(`/api/terminal/${e}/health`,{method:"GET"},UE,"Terminal health check timed out");if(!t.ok){if(t.status===404)return{healthy:!1,sessionId:e};const n=await C0(t,T0,"Terminal health error response timed out").catch(()=>({error:"Failed to check terminal health"}));throw new Error(n.error||"Failed to check terminal health")}return C0(t,T0,"Terminal health response timed out")}async function fI(e){const t=await hr(),n=await ks("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)},WE,"Terminal force-kill request timed out");if(!n.ok){const r=await C0(n,T0,"Terminal force-kill error response timed out").catch(()=>({error:"Failed to force kill terminal"}));throw new Error(r.error||"Failed to force kill terminal")}}async function Yb(){const e=await fetch("/api/terminal/tmux/sessions",{method:"GET"});if(!e.ok){const n=await e.json().catch(()=>({error:"Failed to list tmux sessions"}));throw new Error(n.error||"Failed to list tmux sessions")}const t=await e.json();return Array.isArray(t.sessions)?t.sessions:[]}async function Xb(){const e=await fetch("/api/terminal/tmux/status",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to get tmux status"}));throw new Error(t.error||"Failed to get tmux status")}return e.json()}async function US(e){const t=e.trim();if(!t)throw new Error("tmux session name is required");const n=await hr(),r=await fetch(`/api/terminal/tmux/sessions/${encodeURIComponent(t)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":n}});if(!r.ok){const i=await r.json().catch(()=>({error:"Failed to kill tmux session"}));throw new Error(i.error||"Failed to kill tmux session")}const s=await r.json();return{cleanedSessions:Array.isArray(s.cleanedSessions)?s.cleanedSessions:[],alreadyGone:!!s.alreadyGone}}async function hI(){const e=await hr(),t=await fetch("/api/terminal/tmux/recovery/restore-all",{method:"POST",headers:{"X-XSRF-TOKEN":e}}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Xa(n.error||"Failed to restore tmux Agent sessions",t.status);return n}async function pI(){const e=await hr(),t=await fetch("/api/terminal/tmux/recovery",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new Xa("Failed to dismiss tmux recovery",t.status)}const Mp=new Map;function mI(e){return JSON.stringify({preferredFrontendSessionId:e.preferredFrontendSessionId??null,mode:e.mode??null,tmuxSessionName:e.tmuxSessionName??null,cwd:e.cwd??null,termType:e.termType??null,createIfEmpty:e.createIfEmpty===!0,requireExisting:e.requireExisting===!0})}async function gI(){const e=await fetch("/api/terminal/session-inventory",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load session inventory"}));throw new Error(t.error||"Failed to load session inventory")}return e.json()}async function GS(e){const t=mI(e),n=Mp.get(t);if(n)return n;const r=await hr(),s=ks("/api/terminal/session-inventory/open",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify(e)},GE,"Terminal session open request timed out").then(async i=>{if(!i.ok){const a=await C0(i,T0,"Terminal session open error response timed out").catch(()=>({error:"Failed to open session"}));throw new Xa(a.error||"Failed to open session",i.status,typeof a.code=="string"?a.code:void 0)}return C0(i,T0,"Terminal session open response timed out")}).finally(()=>{Mp.get(t)===s&&Mp.delete(t)});return Mp.set(t,s),s}async function Lm(e,t){const n=await hr(),r=await fetch(`/api/terminal/session-inventory/sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":n},body:JSON.stringify(t)});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed to update session"}));throw new Error(s.error||"Failed to update session")}return r.json()}async function xI(e){const t=await hr(),n=await fetch("/api/terminal/session-inventory/reorder",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({sessionIds:e})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to reorder sessions"}));throw new Error(r.error||"Failed to reorder sessions")}return n.json()}async function bI(e){const t=await hr(),n=await fetch(`/api/terminal/session-inventory/sessions/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to remove session"}));throw new Error(r.error||"Failed to remove session")}}async function yI(){const e=await hr(),t=await fetch("/api/terminal/session-inventory/sessions",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok){const n=await t.json().catch(()=>({error:"Failed to clear sessions"}));throw new Error(n.error||"Failed to clear sessions")}}async function U5(){const e=await fetch("/api/terminal/toolbar-presets",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load toolbar presets"}));throw new Error(t.error||"Failed to load toolbar presets")}return e.json()}async function vI(e){const t=await hr(),n=await fetch("/api/terminal/toolbar-presets",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save toolbar presets"})),s=new Error(r.error||"Failed to save toolbar presets");throw s.current=r.current,s.code=r.code,s}return n.json()}async function k0(){const e=await fetch("/api/terminal/settings",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load settings"}));throw new Error(t.error||"Failed to load settings")}return e.json()}async function So(e){const t=await hr(),n=await fetch("/api/terminal/settings",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to update settings"}));throw new Error(r.error||"Failed to update settings")}return n.json()}async function bf(e=!1){const t=await fetch(`/api/terminal/auto-title/catalog${e?"?refresh=1":""}`);if(!t.ok)throw new Error("Failed to discover title models");const n=await t.json();return Array.isArray(n?.namers)?n.namers:[]}async function wI(){const e=await fetch("/api/terminal/context-draft",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load context draft"}));throw new Error(t.error||"Failed to load context draft")}return e.json()}async function SI(e,t){const n=await hr(),r=await fetch("/api/terminal/context-draft",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":n},body:JSON.stringify({text:e,origin:t})});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed to update context draft"}));throw new Error(s.error||"Failed to update context draft")}return r.json()}async function AI(){const e=await fetch("/api/auth/status");if(!e.ok)throw new Error("Failed to query auth status");return e.json()}async function TI(e){const t=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(t.ok)return QS(),{ok:!0};const n=await t.json().catch(()=>null);return t.status===429?{ok:!1,rateLimited:!0,retryAfterMs:typeof n?.retryAfterMs=="number"?n.retryAfterMs:void 0,error:n?.error||"Too many failed attempts. Please wait and try again."}:{ok:!1,error:n?.error||"Login failed"}}async function CI(){const e=await hr();await fetch("/api/auth/logout",{method:"POST",headers:{"X-XSRF-TOKEN":e}}),QS()}async function WS(){const e=await fetch("/api/terminal/agent-launchers");if(!e.ok)throw new Error("Failed to detect agent launchers");const t=await e.json();return Array.isArray(t?.agents)?t.agents:[]}async function kI(){const e=await fetch("/api/terminal/agent-hooks");if(!e.ok)throw new Error("Failed to get agent hooks");const t=await e.json();return Array.isArray(t?.agents)?t.agents:[]}async function _I(e){const t=await hr(),n=await fetch(`/api/terminal/agent-hooks/${encodeURIComponent(e)}/install`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to install agent hooks");return{summary:r.summary??"Installed",devMode:r.devMode===!0}}async function LI(e){const t=await hr(),n=await fetch(`/api/terminal/agent-hooks/${encodeURIComponent(e)}/uninstall`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to uninstall agent hooks");return r.summary??"Removed"}class Dy extends Error{constructor(t,n,r){super(t),this.code=n,this.migration=r,this.name="AgentPluginManifestError"}code;migration}async function EI(){const e=await fetch("/api/terminal/agent-plugins");if(!e.ok)throw new Error("Failed to get agent plugins");return await e.json()}async function II(e){const t=await hr(),n=await fetch("/api/terminal/agent-plugins",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Dy(r.error||"Failed to create agent plugin",r.code,r.migration);return r}async function RI(e){const t=await hr(),n=await fetch("/api/terminal/agent-plugins/install",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({source:e})}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Dy(r.error||"Failed to install agent plugin",r.code,r.migration);return r}async function NI(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}/check-update`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to check plugin updates");return r}async function MI(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}/update`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to update plugin");return r}async function DI(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}/doctor`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to diagnose plugin");return r}async function jI(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete agent plugin")}}async function PI(e){const t=await hr(),n=await fetch(`/api/terminal/${encodeURIComponent(e)}/agent-resume`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Xa(r.error||"Failed to resume agent session",n.status,typeof r.code=="string"?r.code:void 0);return{command:r.command??""}}async function G5(){const e=await fetch("/api/terminal/agent-resume-history",{method:"GET"});if(!e.ok)throw new Error("Failed to load Agent resume history");const t=await e.json().catch(()=>({entries:[]}));return Array.isArray(t.entries)?t.entries:[]}async function VS(e){const t=await hr(),n=await fetch(`/api/terminal/agent-resume-history/${encodeURIComponent(e)}/prepare`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Xa(r.error||"Failed to prepare Agent session resume",n.status,typeof r.code=="string"?r.code:void 0);return r}async function BI(e){const t=await hr(),n=await fetch(`/api/terminal/agent-resume-history/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!n.ok&&n.status!==404)throw new Error("Failed to remove Agent resume history")}async function Qd(e){const t=await hr(),n=await fetch("/api/terminal/program-rules",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to update program rules"}));throw new Error(r.error||"Failed to update program rules")}return n.json()}async function FI(){const e=await hr(),t=await fetch("/api/terminal/program-rules",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new Error("Failed to reset program rules");return t.json()}async function OI(){const e=await fetch("/api/terminal/program-detection");if(!e.ok)throw new Error("Failed to get program detection config");return e.json()}async function W5(e){const t=await hr(),n=await fetch("/api/terminal/program-detection",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok)throw new Error("Failed to save program detection config");return n.json()}async function QI(){const e=await hr(),t=await fetch("/api/terminal/program-detection",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new Error("Failed to reset program detection config");return t.json()}const $I={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".bmp":"image/bmp",".ico":"image/x-icon",".svg":"image/svg+xml",".heic":"image/heic",".heif":"image/heif"};function jy(e){const t=e.lastIndexOf(".");return t<0?null:$I[e.slice(t).toLowerCase()]??null}function Py(e){return jy(e)!==null}function qS(e){const t=jy(e);return t==="image/heic"||t==="image/heif"}const HI={".mp4":"video/mp4",".m4v":"video/x-m4v",".webm":"video/webm",".mov":"video/quicktime",".ogv":"video/ogg",".mpeg":"video/mpeg",".mpg":"video/mpeg"};function KS(e){const t=e.lastIndexOf(".");return t<0?null:HI[e.slice(t).toLowerCase()]??null}function YS(e){return KS(e)!==null}function zI(e){return`/api/terminal/fs/video?path=${encodeURIComponent(e)}&action=view_file`}const UI=[".stl",".glb",".gltf"];function XS(e){const t=e.lastIndexOf(".");if(t<0)return null;const n=e.slice(t).toLowerCase();return UI.includes(n)?n:null}function ZS(e){return XS(e)!==null}function JS(e){const t=e.toLowerCase();return t.endsWith(".kicad_sch")?".kicad_sch":t.endsWith(".kicad_pcb")?".kicad_pcb":null}function GI(e){return JS(e)!==null}function WI(e){return JS(e)===".kicad_pcb"?"pcb-front":"schematic"}const VI=[".html",".htm"];function yf(e){const t=e.lastIndexOf(".");if(t<0)return!1;const n=e.slice(t).toLowerCase();return VI.includes(n)}function qI(e){return`/api/terminal/fs/preview/${e.split(/[\\/]+/).filter(Boolean).map(n=>encodeURIComponent(n)).join("/")}`}const KI={".stl":"model/stl",".glb":"model/gltf-binary",".gltf":"model/gltf+json"};async function By(e,t,n,r="list_directory",s,i="name"){const a=new URLSearchParams({path:e});n&&a.set("showHidden","true"),i!=="name"&&a.set("sort",i),a.set("action",r),s&&a.set("requestSlotId",s);const c=await ks(`/api/terminal/fs/list?${a}`,{signal:t},Au,"Directory listing took too long. The folder may be on slow storage or blocked by another process.");if(!c.ok){const u=await c.json().catch(()=>({error:"Failed to list directory"}));throw new Error(u.error||"Failed to list directory")}return c.json()}async function YI(e,t,n,r,s,i="name",a,c={}){const u=new URLSearchParams({path:e,query:t,stream:"true"});s&&u.set("showHidden","true"),i==="content"&&u.set("mode","content"),a&&u.set("requestSlotId",a);for(const S of c.excludePatterns??[])u.append("exclude",S);c.caseSensitive&&u.set("caseSensitive","true"),c.wholeWord&&u.set("wholeWord","true"),c.regex&&u.set("regex","true");const f=await fetch(`/api/terminal/fs/search?${u}`,{signal:r});if(!f.ok||!f.body){const S=await f.json().catch(()=>({error:"Failed to search files"}));throw new Error(S.error||"Failed to search files")}const p=f.body.getReader(),g=new TextDecoder;let y="";const v=S=>{if(!S.trim())return;const A=JSON.parse(S);if(A.type==="meta")n({path:A.path,query:A.query,engine:A.engine,mode:A.mode,limited:A.limited});else if(A.type==="batch")n({entries:A.entries??[]});else if(A.type==="content-batch")n({contentEntries:A.contentEntries??[]});else{if(A.type==="error")throw new Error(A.message||"Search failed");A.type==="done"&&n({total:A.total,truncated:A.truncated,limited:A.limited,engine:A.engine,mode:A.mode,done:!0})}};for(;;){const{value:S,done:A}=await p.read();if(A)break;y+=g.decode(S,{stream:!0});let C=y.indexOf(`
3
3
  `);for(;C>=0;)v(y.slice(0,C)),y=y.slice(C+1),C=y.indexOf(`
4
4
  `)}y+=g.decode(),v(y)}async function XI(e,t,n){const r=new URLSearchParams;r.set("roots",e.join("|"));const s=await fetch(`/api/terminal/fs/watch?${r}`,{signal:n});if(!s.ok||!s.body){const p=await s.json().catch(()=>({error:"Failed to watch files"}));throw new Error(p.error||"Failed to watch files")}const i=s.body.getReader(),a=new TextDecoder;let c="",u=null;const f=p=>{if(!p.trim())return;const g=JSON.parse(p);if(g.type==="events"&&g.events?.length){t(g.events);const y=g.events.find(v=>v.type==="rescan-required"&&v.reason!=="event-storm"&&v.reason!=="reconnected");y?.reason&&(u=y.reason)}};for(;;){const{value:p,done:g}=await i.read();if(g)break;c+=a.decode(p,{stream:!0});let y=c.indexOf(`
@@ -64,7 +64,7 @@ void main() {
64
64
  }`,pc=8,px=pc*Float32Array.BYTES_PER_ELEMENT,Yj=20*pc,Aw=class{constructor(){this.attributes=new Float32Array(Yj),this.count=0}},Ic=0,Tw=0,Cw=0,kw=0,_w=0,Lw=0,Ew=0,Xj=class extends dd{constructor(t,n,r,s,i){super(),this._terminal=t,this._gl=n,this._dimensions=r,this._themeService=s,this._logService=i,this._vertices=new Aw,this._verticesCursor=new Aw;let a=this._gl;this._program=Ai(B8(a,qj,Kj,this._logService)),this._register(Mi(()=>a.deleteProgram(this._program))),this._projectionLocation=Ai(a.getUniformLocation(this._program,"u_projection"));let c=this._vertexArrayObject=a.createVertexArray();this._register(Mi(()=>a.deleteVertexArray(c))),a.bindVertexArray(c);let u=new Float32Array([0,0,1,0,0,1,1,1]),f=a.createBuffer();this._register(Mi(()=>a.deleteBuffer(f))),a.bindBuffer(a.ARRAY_BUFFER,f),a.bufferData(a.ARRAY_BUFFER,u,a.STATIC_DRAW),a.enableVertexAttribArray(3),a.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let p=new Uint8Array([0,1,2,3]),g=a.createBuffer();this._register(Mi(()=>a.deleteBuffer(g))),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,g),a.bufferData(a.ELEMENT_ARRAY_BUFFER,p,a.STATIC_DRAW),this._attributesBuffer=Ai(a.createBuffer()),this._register(Mi(()=>a.deleteBuffer(this._attributesBuffer))),a.bindBuffer(a.ARRAY_BUFFER,this._attributesBuffer),a.enableVertexAttribArray(0),a.vertexAttribPointer(0,2,a.FLOAT,!1,px,0),a.vertexAttribDivisor(0,1),a.enableVertexAttribArray(1),a.vertexAttribPointer(1,2,a.FLOAT,!1,px,2*Float32Array.BYTES_PER_ELEMENT),a.vertexAttribDivisor(1,1),a.enableVertexAttribArray(2),a.vertexAttribPointer(2,4,a.FLOAT,!1,px,4*Float32Array.BYTES_PER_ELEMENT),a.vertexAttribDivisor(2,1),this._updateCachedColors(s.colors),this._register(this._themeService.onChangeColors(y=>{this._updateCachedColors(y),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let n=this._gl;n.useProgram(this._program),n.bindVertexArray(this._vertexArrayObject),n.uniformMatrix4fv(this._projectionLocation,!1,P8),n.bindBuffer(n.ARRAY_BUFFER,this._attributesBuffer),n.bufferData(n.ARRAY_BUFFER,t.attributes,n.DYNAMIC_DRAW),n.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,n.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let n=this._terminal,r=this._vertices,s=1,i,a,c,u,f,p,g,y,v,S,A;for(i=0;i<n.rows;i++){for(c=-1,u=0,f=0,p=!1,a=0;a<n.cols;a++)g=(i*n.cols+a)*4,y=t.cells[g+1],v=t.cells[g+2],S=!!(v&67108864),(y!==u||v!==f&&(p||S))&&((u!==0||p&&f!==0)&&(A=s++*pc,this._updateRectangle(r,A,f,u,c,a,i)),c=a,u=y,f=v,p=S);(u!==0||p&&f!==0)&&(A=s++*pc,this._updateRectangle(r,A,f,u,c,n.cols,i))}r.count=s}updateCursor(t){let n=this._verticesCursor,r=t.cursor;if(!r||r.style==="block"){n.count=0;return}let s,i=0;(r.style==="bar"||r.style==="outline")&&(s=i++*pc,this._addRectangleFloat(n.attributes,s,r.x*this._dimensions.device.cell.width,r.y*this._dimensions.device.cell.height,r.style==="bar"?r.dpr*r.cursorWidth:r.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(r.style==="underline"||r.style==="outline")&&(s=i++*pc,this._addRectangleFloat(n.attributes,s,r.x*this._dimensions.device.cell.width,(r.y+1)*this._dimensions.device.cell.height-r.dpr,r.width*this._dimensions.device.cell.width,r.dpr,this._cursorFloat)),r.style==="outline"&&(s=i++*pc,this._addRectangleFloat(n.attributes,s,r.x*this._dimensions.device.cell.width,r.y*this._dimensions.device.cell.height,r.width*this._dimensions.device.cell.width,r.dpr,this._cursorFloat),s=i++*pc,this._addRectangleFloat(n.attributes,s,(r.x+r.width)*this._dimensions.device.cell.width-r.dpr,r.y*this._dimensions.device.cell.height,r.dpr,this._dimensions.device.cell.height,this._cursorFloat)),n.count=i}_updateRectangle(t,n,r,s,i,a,c){if(r&67108864)switch(r&50331648){case 16777216:case 33554432:Ic=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:Ic=(r&16777215)<<8;break;default:Ic=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:Ic=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:Ic=(s&16777215)<<8;break;default:Ic=this._themeService.colors.background.rgba}t.attributes.length<n+pc&&(t.attributes=Oj(t.attributes,(this._terminal.rows*this._terminal.cols+1)*pc)),Tw=i*this._dimensions.device.cell.width,Cw=c*this._dimensions.device.cell.height,kw=(Ic>>24&255)/255,_w=(Ic>>16&255)/255,Lw=(Ic>>8&255)/255,Ew=1,this._addRectangle(t.attributes,n,Tw,Cw,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,kw,_w,Lw,Ew)}_addRectangle(t,n,r,s,i,a,c,u,f,p){t[n]=r/this._dimensions.device.canvas.width,t[n+1]=s/this._dimensions.device.canvas.height,t[n+2]=i/this._dimensions.device.canvas.width,t[n+3]=a/this._dimensions.device.canvas.height,t[n+4]=c,t[n+5]=u,t[n+6]=f,t[n+7]=p}_addRectangleFloat(t,n,r,s,i,a,c){t[n]=r/this._dimensions.device.canvas.width,t[n+1]=s/this._dimensions.device.canvas.height,t[n+2]=i/this._dimensions.device.canvas.width,t[n+3]=a/this._dimensions.device.canvas.height,t[n+4]=c[0],t[n+5]=c[1],t[n+6]=c[2],t[n+7]=c[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},Zj=class extends dd{constructor(e,t,n,r,s,i,a,c){super(),this._container=t,this._alpha=s,this._coreBrowserService=i,this._optionsService=a,this._themeService=c,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(u=>{this._refreshCharAtlas(e,u),this.reset(e)})),this._register(Mi(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Ai(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=D8(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=C8,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?"italic":""} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},Jj=class extends Zj{constructor(t,n,r,s,i,a,c){super(r,t,"link",n,!0,i,a,c),this._register(s.onShowLinkUnderline(u=>this._handleShowLinkUnderline(u))),this._register(s.onHideLinkUnderline(u=>this._handleHideLinkUnderline(u)))}resize(t,n){super.resize(t,n),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&Dj(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let n=t.y1+1;n<t.y2;n++)this._fillBottomLineAtCells(0,n,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},eP=class{constructor(t,n,r,s){this._node=t,this._type=n,this._handler=r,this._options=s,t.addEventListener(n,r,s)}dispose(){!this._node||!this._handler||(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function mx(e,t,n,r){return new eP(e,t,n,r)}var tP=class extends dd{constructor(e,t,n,r,s,i,a,c,u,f=!0,p){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=s,this._decorationService=i,this._logService=a,this._optionsService=c,this._themeService=u,this._customGlyphs=f,this._cursorBlinkStateManager=this._register(new vf),this._charAtlasDisposable=this._register(new vf),this._observerDisposable=this._register(new vf),this._model=new Vj,this._rowHasBlinkingCells=[],this._rowHasBlinkingCellsCount=0,this._workCell=new Bj,this._rectangleRenderer=this._register(new vf),this._glyphRenderer=this._register(new vf),this._onChangeTextureAtlas=this._register(new Hl),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Hl),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Hl),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Hl),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Hl),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let g={antialias:!1,depth:!1,preserveDrawingBuffer:p};if(this._gl=this._canvas.getContext("webgl2",g),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new gj(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Jj(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,c,this._themeService)],this.dimensions=fj(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(c.onOptionChange(()=>this._handleOptionsChanged())),this._textBlinkStateManager=this._register(new Fj(()=>this._requestRedrawViewport(),this._coreBrowserService,this._optionsService)),this._resetBlinkingRowState(),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(mx(this._canvas,"webglcontextlost",y=>{this._logService.debug("webglcontextlost event received"),y.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,this._logService.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(y)},3e3)})),this._register(mx(this._canvas,"webglcontextrestored",y=>{this._logService.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,vw(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=ww(this._canvas,this._coreBrowserService.window,(y,v)=>this._setCanvasDevicePixelDimensions(y,v)),this._register(this._coreBrowserService.onWindowChange(y=>{this._observerDisposable.value=ww(this._canvas,y,(v,S)=>this._setCanvasDevicePixelDimensions(v,S))})),this._register(mx(this._coreBrowserService.mainDocument,"mousedown",()=>this._cursorBlinkStateManager.value?.restartBlinkAnimation())),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Mi(()=>{clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0;for(let y of this._renderLayers)y.dispose();this._canvas.parentElement?.removeChild(this._canvas),vw(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows),this._resetBlinkingRowState();for(let n of this._renderLayers)n.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1),this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1,sync:!0})}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleViewportVisibilityChange(e){this._textBlinkStateManager.setViewportVisible(e)}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new Xj(this._terminal,this._gl,this.dimensions,this._themeService,this._logService),this._glyphRenderer.value=new zj(this._terminal,this._gl,this.dimensions,this._optionsService,this._logService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=D8(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize,this._customGlyphs);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=tj(Xu.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Xu.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._resetBlinkingRowState(),this._textBlinkStateManager.setNeedsBlinkInViewport(!1),this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let s of this._renderLayers)s.handleGridChanged(this._terminal,e,t);if(!this._glyphRenderer.value||!this._rectangleRenderer.value)return;this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t);let n=!1,r=0;for(;this._charAtlas&&this._glyphRenderer.value.beginFrame()&&r++<32;)n=!0,this._clearModel(!0),this._updateModel(0,this._terminal.rows-1);n&&this._glyphRenderer.value.invalidateAtlasTextures(),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor()}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new jj(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,s,i,a,c,u,f,p,g,y,v,S,A,C,L,E,M,P;e=Iw(e,n.rows-1,0),t=Iw(t,n.rows-1,0);let F=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??"block",j=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,T=j-n.buffer.ydisp,Q=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),$=-1,Z=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let V=!1;for(i=e;i<=t;i++){a=i+n.buffer.ydisp;let fe=n.buffer.lines.get(a);if(!fe){for(this._model.lineLengths[i]=0,M=0;M<n.cols;M++)P=(i*n.cols+M)*4,V=!0,this._nullModelCell(M,i,P,0,0,0);this._setRowBlinkState(i,!1);continue}c=fe;let X=!1;for(this._model.lineLengths[i]=0,S=j===a,p=0,u=this._characterJoinerService.getJoinedCharacters(a),M=0;M<n.cols;M++){if(s=this._cellColorResolver.result.bg,c.loadCell(M,r),M===0&&(s=this._cellColorResolver.result.bg),f=!1,g=M>=p,y=M,u.length>0&&M===u[0][0]&&g){v=u.shift();let ge=this._model.selection.isCellSelected(this._terminal,v[0],a);for(E=v[0]+1;E<v[1];E++)g&&=ge===this._model.selection.isCellSelected(this._terminal,E,a);g&&=!S||Q<v[0]||Q>=v[1],g?(f=!0,r=new nP(r,c.translateToString(!0,v[0],v[1]),v[1]-v[0]),y=v[1]-1):p=v[1]}if(A=r.getChars(),C=r.getCode(),E=(i*n.cols+M)*4,!X&&r.isBlink()&&(X=!0),this._cellColorResolver.resolve(r,M,a,this.dimensions.device.cell.width,this.dimensions.device.cell.height),Z&&a===j&&(M===Q&&(this._model.cursor={x:Q,y:T,width:r.getWidth(),style:this._coreBrowserService.isFocused?F:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},$=Q+r.getWidth()-1),M>=Q&&M<=$&&(this._coreBrowserService.isFocused&&F==="block"||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),this._textBlinkStateManager.isEnabled&&!this._textBlinkStateManager.isBlinkOn&&r.isBlink()&&(this._cellColorResolver.result.fg|=1073741824),C!==0&&(this._model.lineLengths[i]=M+1),!(this._model.cells[E]===C&&this._model.cells[E+1]===this._cellColorResolver.result.bg&&this._model.cells[E+2]===this._cellColorResolver.result.fg&&this._model.cells[E+3]===this._cellColorResolver.result.ext)&&(V=!0,A.length>1&&(C|=Wj),this._model.cells[E]=C,this._model.cells[E+1]=this._cellColorResolver.result.bg,this._model.cells[E+2]=this._cellColorResolver.result.fg,this._model.cells[E+3]=this._cellColorResolver.result.ext,L=r.getWidth(),this._glyphRenderer.value.updateCell(M,i,C,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,A,L,s),f)){for(r=this._workCell,M++;M<=y;M++)P=(i*n.cols+M)*4,this._nullModelCell(M,i,P,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext);M--}}this._setRowBlinkState(i,X)}V&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model),this._updateTextBlinkState()}_nullModelCell(e,t,n,r,s,i){this._glyphRenderer.value.updateCell(e,t,0,r,s,i,"",0,0),this._model.cells[n]=0,this._model.cells[n+1]=r,this._model.cells[n+2]=s,this._model.cells[n+3]=i}_resetBlinkingRowState(){this._rowHasBlinkingCells=new Array(this._terminal.rows).fill(!1),this._rowHasBlinkingCellsCount=0}_setRowBlinkState(e,t){this._rowHasBlinkingCells[e]!==t&&(this._rowHasBlinkingCells[e]=t,this._rowHasBlinkingCellsCount+=t?1:-1)}_updateTextBlinkState(){this._textBlinkStateManager.setNeedsBlinkInViewport(this._rowHasBlinkingCellsCount>0)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1,sync:!0}))}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},nP=class extends f0{constructor(t,n,r){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=n,this._width=r}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Iw(e,t,n=0){return Math.max(Math.min(e,t),n)}var rP=class extends dd{constructor(e){if(A8&&ij()<16){let t={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",t))throw new Error("WebGL2 is only supported on Safari 16 and above")}super(),this._onChangeTextureAtlas=this._register(new Hl),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Hl),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Hl),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Hl),this.onContextLoss=this._onContextLoss.event,this._customGlyphs=e?.customGlyphs??!0,this._preserveDrawingBuffer=e?.preserveDrawingBuffer}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,s=t,i=s._renderService,a=s._characterJoinerService,c=s._charSizeService,u=s._coreBrowserService,f=s._decorationService,p=s._logService,g=s._themeService;this._renderer=this._register(new tP(e,a,c,u,n,f,p,r,g,this._customGlyphs,this._preserveDrawingBuffer)),this._register(Xu.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Xu.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Xu.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Xu.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),i.setRenderer(this._renderer),this._register(Mi(()=>{if(this._terminal._core._store._isDisposed)return;let y=this._terminal._core._renderService;y.setRenderer(this._terminal._core._createRenderer()),y.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};var sP=class{constructor(t,n,r,s={}){this._terminal=t,this._regex=n,this._handler=r,this._options=s}provideLinks(t,n){let r=oP.computeLink(t,this._regex,this._terminal,this._handler);n(this._addCallbacks(r))}_addCallbacks(t){return t.map(n=>(n.leave=this._options.leave,n.hover=(r,s)=>{if(this._options.hover){let{range:i}=n;this._options.hover(r,s,i)}},n))}};function iP(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var oP=class Rm{static computeLink(t,n,r,s){let i=n.flags.includes("g")?n.flags:`${n.flags}g`,a=new RegExp(n.source,i),[c,u]=Rm._getWindowedLineStrings(t-1,r),f=c.join(""),p,g=[];for(;p=a.exec(f);){let y=p[0];if(!iP(y))continue;let[v,S]=Rm._mapStrIdx(r,u,0,p.index),[A,C]=Rm._mapStrIdx(r,v,S,y.length);if(v===-1||S===-1||A===-1||C===-1)continue;let L={start:{x:S+1,y:v+1},end:{x:C,y:A+1}};g.push({range:L,text:y,activate:s})}return g}static _getWindowedLineStrings(t,n){let r,s=t,i=t,a,c,u=[];if(r=n.buffer.active.getLine(t)){let f=r.translateToString(!0);if(r.isWrapped&&f[0]!==" "){for(a=0;(r=n.buffer.active.getLine(--s))&&a<2048&&(c=r.translateToString(!0),a+=c.length,u.push(c),!(!r.isWrapped||c.indexOf(" ")!==-1)););u.reverse()}for(u.push(f),a=0;(r=n.buffer.active.getLine(++i))&&r.isWrapped&&a<2048&&(c=r.translateToString(!0),a+=c.length,u.push(c),c.indexOf(" ")===-1););}return[u,s]}static _mapStrIdx(t,n,r,s){let i=t.buffer.active,a=i.getNullCell(),c=r;for(;s;){let u=i.getLine(n);if(!u)return[-1,-1];for(let f=c;f<u.length;++f){u.getCell(f,a);let p=a.getChars();if(a.getWidth()&&(s-=p.length||1,f===u.length-1&&p==="")){let g=i.getLine(n+1);g&&g.isWrapped&&(g.getCell(0,a),a.getWidth()===2&&(s+=1))}if(s<0)return[n,f]}n++,c=0}return[n,c]}},aP=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function lP(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var cP=class{constructor(t=lP,n={}){this._handler=t,this._options=n}activate(t){this._terminal=t;let n=this._options,r=n.urlRegex??aP;this._linkProvider=this._terminal.registerLinkProvider(new sP(this._terminal,r,this._handler,n))}dispose(){this._linkProvider?.dispose()}};function Rw(e){return{dispose:e}}var uP=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},dP=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,n,r)=>{if(this._disposed)return Rw(()=>{});let s={fn:t,thisArgs:n};this._listeners.push(s);let i=Rw(()=>{let a=this._listeners.indexOf(s);a!==-1&&this._listeners.splice(a,1)});return r&&(Array.isArray(r)?r.push(i):r.add(i)),i},this._event)}fire(t){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:n,thisArgs:r}=this._listeners[0];n.call(r,t);return}default:{let n=this._listeners.slice();for(let{fn:r,thisArgs:s}of n)r.call(s,t)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},fP;(e=>{function t(i,a){return i(c=>a.fire(c))}e.forward=t;function n(i,a){return(c,u,f)=>i(p=>c.call(u,a(p)),void 0,f)}e.map=n;function r(...i){return(a,c,u)=>{let f=new uP;for(let p of i)f.add(p(g=>a.call(c,g)));return u&&(Array.isArray(u)?u.push(f):u.add(f)),f}}e.any=r;function s(i,a,c){return a(c),i(u=>a(u))}e.runAndSubscribe=s})(fP||={});var Nw=class Nm{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new dP,this.onChange=this._onChange.event}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t,this._active||(this.activeVersion=t.version)}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,s=t.length;for(let i=0;i<s;++i){let a=t.charCodeAt(i);if(55296<=a&&a<=56319){if(++i>=s)return n+this.wcwidth(a);let f=t.charCodeAt(i);56320<=f&&f<=57343?a=(a-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let c=this.charProperties(a,r),u=Nm.extractWidth(c);Nm.extractShouldJoin(c)&&(u-=Nm.extractWidth(r)),n+=u,r=c}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},gx=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],hP=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],xx=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],pP=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],Rc;function Mw(e,t){let n=0,r=t.length-1,s;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(s=n+r>>1,e>t[s][1])n=s+1;else if(e<t[s][0])r=s-1;else return!0;return!1}var mP=class{constructor(){if(this.version="11",!Rc){Rc=new Uint8Array(65536),Rc.fill(1),Rc[0]=0,Rc.fill(0,1,32),Rc.fill(0,127,160);for(let e=0;e<gx.length;++e)Rc.fill(0,gx[e][0],gx[e][1]+1);for(let e=0;e<xx.length;++e)Rc.fill(2,xx[e][0],xx[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Rc[e]:Mw(e,hP)?0:Mw(e,pP)?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let s=Nw.extractWidth(t);s===0?r=!1:s>n&&(n=s)}return Nw.createPropertyValue(0,n,r)}},gP=class{activate(e){e.unicode.register(new mP)}dispose(){}};function ad(e){return{dispose:e}}function Mm(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function xP(...e){return ad(()=>Mm(e))}var F8=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(t){return this._isDisposed?t.dispose():this._disposables.add(t),t}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let t of this._disposables)t.dispose();this._disposables.clear()}}clear(){for(let t of this._disposables)t.dispose();this._disposables.clear()}},zh=class{constructor(){this._store=new F8}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};zh.None=Object.freeze({dispose(){}});var rg=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},c2=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,n)=>{if(this._disposed)return ad(()=>{});let r={fn:e,thisArgs:t};this._listeners.push(r);let s=ad(()=>{let i=this._listeners.indexOf(r);i!==-1&&this._listeners.splice(i,1)});return n&&(Array.isArray(n)?n.push(s):n.add(s)),s},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:n}=this._listeners[0];t.call(n,e);return}default:{let t=this._listeners.slice();for(let{fn:n,thisArgs:r}of t)n.call(r,e)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},bP;(e=>{function t(i,a){return i(c=>a.fire(c))}e.forward=t;function n(i,a){return(c,u,f)=>i(p=>c.call(u,a(p)),void 0,f)}e.map=n;function r(...i){return(a,c,u)=>{let f=new F8;for(let p of i)f.add(p(g=>a.call(c,g)));return u&&(Array.isArray(u)?u.push(f):u.add(f)),f}}e.any=r;function s(i,a,c){return a(c),i(u=>a(u))}e.runAndSubscribe=s})(bP||={});function O8(e,t=0,n){let r=setTimeout(()=>{e()},t);return ad(()=>{clearTimeout(r)})}var yP=class extends zh{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new rg),this._linesCacheDisposables=this._register(new rg),this._lastAccessTimestamp=0,this._register(ad(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=xP(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._lastAccessTimestamp=Date.now(),this._linesCacheTimeout.value||this._scheduleLinesCacheTimeout(15e3)}_destroyLinesCache(){this._linesCache=void 0,this._lastAccessTimestamp=0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}_scheduleLinesCacheTimeout(e){this._linesCacheTimeout.value=O8(()=>{if(!this._linesCache)return;let t=Date.now()-this._lastAccessTimestamp;if(t>=15e3){this._destroyLinesCache();return}this._scheduleLinesCacheTimeout(15e3-t)},e)}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],s=this._terminal.buffer.active.getLine(e);for(;s;){let i=this._terminal.buffer.active.getLine(e+1),a=i?i.isWrapped:!1,c=s.translateToString(!a&&t);if(a&&i){let u=s.getCell(s.length-1);u&&u.getCode()===0&&u.getWidth()===1&&i.getCell(0)?.getWidth()===2&&(c=c.slice(0,-1))}if(n.push(c),a)r.push(r[r.length-1]+c.length);else break;e++,s=i}return[n.join(""),r]}},vP=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(t){this._cachedSearchTerm=t}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(t){this._lastSearchOptions=t}isValidSearchTerm(t){return!!(t&&t.length>0)}didOptionsChange(t){return this._lastSearchOptions?t?this._lastSearchOptions.caseSensitive!==t.caseSensitive||this._lastSearchOptions.regex!==t.regex||this._lastSearchOptions.wholeWord!==t.wholeWord:!1:!0}shouldUpdateHighlighting(t,n){return n?.decorations?this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||this.didOptionsChange(n):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},wP=class{constructor(t,n){this._terminal=t,this._lineCache=n}find(t,n,r,s){if(!t||t.length===0){this._terminal.clearSelection();return}if(r>=this._terminal.cols)throw new Error(`Invalid col: ${r} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:n,startCol:r},a=this._findInLine(t,i,s);if(!a)for(let c=n+1;c<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=c,i.startCol=0,a=this._findInLine(t,i,s),!a);c++);return a}findNextWithSelection(t,n,r){if(!t||t.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;s&&(r===t?(i=s.end.x,a=s.end.y):(i=s.start.x,a=s.start.y)),this._lineCache.initLinesCache();let c={startRow:a,startCol:i},u=this._findInLine(t,c,n);if(!u)for(let f=a+1;f<this._terminal.buffer.active.baseY+this._terminal.rows&&(c.startRow=f,c.startCol=0,u=this._findInLine(t,c,n),!u);f++);if(!u&&a!==0)for(let f=0;f<a&&(c.startRow=f,c.startCol=0,u=this._findInLine(t,c,n),!u);f++);return!u&&s&&(c.startRow=s.start.y,c.startCol=0,u=this._findInLine(t,c,n)),u}findPreviousWithSelection(t,n,r){if(!t||t.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols,c=!0;this._lineCache.initLinesCache();let u={startRow:i,startCol:a},f;if(s&&(u.startRow=i=s.start.y,u.startCol=s.start.x,r!==t&&(f=this._findInLine(t,u,n,!1),f||(u.startRow=i=s.end.y,u.startCol=s.end.x))),f??=this._findInLine(t,u,n,c),!f){u.startCol=Math.max(u.startCol,this._terminal.cols);for(let p=i-1;p>=0&&(u.startRow=p,f=this._findInLine(t,u,n,c),!f);p--);}if(!f&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let p=this._terminal.buffer.active.baseY+this._terminal.rows-1;p>=i&&(u.startRow=p,f=this._findInLine(t,u,n,c),!f);p--);return f}_isWholeWord(t,n,r){return(t===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(n[t-1]))&&(t+r.length===n.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(n[t+r.length]))}_findInLine(t,n,r={},s=!1){let i=n.startRow,a=n.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(s){n.startCol+=this._terminal.cols;return}return n.startRow--,n.startCol+=this._terminal.cols,this._findInLine(t,n,r)}let c=this._lineCache.getLineFromCache(i);c||(c=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,c));let[u,f]=c,p=this._bufferColsToStringOffset(i,a),g=t,y=u;r.regex||(g=r.caseSensitive?t:t.toLowerCase(),y=r.caseSensitive?u:u.toLowerCase());let v=-1;if(r.regex){let S=RegExp(g,r.caseSensitive?"g":"gi"),A;if(s)for(;A=S.exec(y.slice(0,p));)v=S.lastIndex-A[0].length,t=A[0],S.lastIndex-=t.length-1;else A=S.exec(y.slice(p)),A&&A[0].length>0&&(v=p+(S.lastIndex-A[0].length),t=A[0])}else s?p-g.length>=0&&(v=y.lastIndexOf(g,p-g.length)):v=y.indexOf(g,p);if(v>=0){if(r.wholeWord&&!this._isWholeWord(v,y,t))return;let S=0;for(;S<f.length-1&&v>=f[S+1];)S++;let A=S;for(;A<f.length-1&&v+t.length>=f[A+1];)A++;let C=v-f[S],L=v+t.length-f[A],E=this._stringLengthToBufferSize(i+S,C),M=this._stringLengthToBufferSize(i+A,L)-E+this._terminal.cols*(A-S);return{term:t,col:E,row:i+S,size:M}}}_stringLengthToBufferSize(t,n){let r=this._terminal.buffer.active.getLine(t);if(!r)return 0;for(let s=0;s<n;s++){let i=r.getCell(s);if(!i)break;let a=i.getChars();a.length>1&&(n-=a.length-1);let c=r.getCell(s+1);c&&c.getWidth()===0&&n++}return n}_bufferColsToStringOffset(t,n){let r=t,s=0,i=this._terminal.buffer.active.getLine(r);for(;n>0&&i;){for(let a=0;a<n&&a<this._terminal.cols;a++){let c=i.getCell(a);if(!c)break;c.getWidth()&&(s+=c.getCode()===0?1:c.getChars().length)}if(r++,i=this._terminal.buffer.active.getLine(r),i&&!i.isWrapped)break;n-=this._terminal.cols}return s}},SP=class extends zh{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ad(()=>this.clearHighlightDecorations()))}createHighlightDecorations(t,n){this.clearHighlightDecorations();for(let r of t){let s=this._createResultDecorations(r,n,!1);if(s)for(let i of s)this._storeDecoration(i,r)}}createActiveDecoration(t,n){let r=this._createResultDecorations(t,n,!0);if(r)return{decorations:r,match:t,dispose(){Mm(r)}}}clearHighlightDecorations(){Mm(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,n){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:n,dispose(){t.dispose()}})}_applyStyles(t,n,r){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),n&&(t.style.outline=`1px solid ${n}`)),r&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,n,r){let s=[],i=t.col,a=t.size,c=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;a>0;){let f=Math.min(this._terminal.cols-i,a);s.push([c,i,f]),i=0,a-=f,c++}let u=[];for(let f of s){let p=this._terminal.registerMarker(f[0]),g=this._terminal.registerDecoration({marker:p,x:f[1],width:f[2],layer:r?"top":"bottom",backgroundColor:r?n.activeMatchBackground:n.matchBackground,overviewRulerOptions:this._highlightedLines.has(p.line)?void 0:{color:r?n.activeMatchColorOverviewRuler:n.matchOverviewRuler,position:"center"}});if(g){let y=[];y.push(p),y.push(g.onRender(v=>this._applyStyles(v,r?n.activeMatchBorder:n.matchBorder,!1))),y.push(g.onDispose(()=>Mm(y))),u.push(g)}}return u.length===0?void 0:u}},AP=class extends zh{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new c2)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,n){this._searchResults=t.slice(0,n)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let n=0;n<this._searchResults.length;n++){let r=this._searchResults[n];if(r.row===t.row&&r.col===t.col&&r.size===t.size)return n}return-1}fireResultsChanged(t){if(!t)return;let n=-1;this._selectedDecoration&&(n=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:n,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},TP=class extends zh{constructor(t){super(),this._highlightTimeout=this._register(new rg),this._lineCache=this._register(new rg),this._state=new vP,this._resultTracker=this._register(new AP),this._onAfterSearch=this._register(new c2),this.onAfterSearch=this._onAfterSearch.event,this._onBeforeSearch=this._register(new c2),this.onBeforeSearch=this._onBeforeSearch.event,this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new yP(t),this._engine=new wP(t,this._lineCache.value),this._decorationManager=new SP(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ad(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=O8(()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,n,r){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=n,this._state.shouldUpdateHighlighting(t,n)&&this._highlightAllMatches(t,n);let s=this._findNextAndSelect(t,n,r);return this._fireResults(n),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),s}_highlightAllMatches(t,n){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t)){this.clearDecorations();return}this.clearDecorations(!0);let r=[],s,i=this._engine.find(t,0,0,n);for(;i&&(s?.row!==i.row||s?.col!==i.col)&&!(r.length>=this._highlightLimit);){s=i,r.push(s);let a=this._terminal.cols,c=s.col+s.size,u=s.row;c>=a&&(u+=Math.floor(c/a),c=c%a),i=this._engine.find(t,u,c,n)}this._resultTracker.updateResults(r,this._highlightLimit),n.decorations&&this._decorationManager.createHighlightDecorations(r,n.decorations)}_findNextAndSelect(t,n,r){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(t,n,this._state.cachedSearchTerm);return this._selectResult(s,n?.decorations,r?.noScroll)}findPrevious(t,n,r){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=n,this._state.shouldUpdateHighlighting(t,n)&&this._highlightAllMatches(t,n);let s=this._findPreviousAndSelect(t,n,r);return this._fireResults(n),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),s}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,n,r){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(t,n,this._state.cachedSearchTerm);return this._selectResult(s,n?.decorations,r?.noScroll)}_selectResult(t,n,r){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),n){let s=this._decorationManager.createActiveDecoration(t,n);s&&(this._resultTracker.selectedDecoration=s)}if(!r&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let s=t.row-this._terminal.buffer.active.viewportY;s-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(s)}return!0}};var Vi=0,qi=0,Ki=0,ti=0,$o;(e=>{function t(s,i,a,c){return c!==void 0?`#${Pu(s)}${Pu(i)}${Pu(a)}${Pu(c)}`:`#${Pu(s)}${Pu(i)}${Pu(a)}`}e.toCss=t;function n(s,i,a,c=255){return(s<<24|i<<16|a<<8|c)>>>0}e.toRgba=n;function r(s,i,a,c){return{css:e.toCss(s,i,a,c),rgba:e.toRgba(s,i,a,c)}}e.toColor=r})($o||={});var CP;(e=>{function t(u,f){if(ti=(f.rgba&255)/255,ti===1)return{css:f.css,rgba:f.rgba};let p=f.rgba>>24&255,g=f.rgba>>16&255,y=f.rgba>>8&255,v=u.rgba>>24&255,S=u.rgba>>16&255,A=u.rgba>>8&255;Vi=v+Math.round((p-v)*ti),qi=S+Math.round((g-S)*ti),Ki=A+Math.round((y-A)*ti);let C=$o.toCss(Vi,qi,Ki),L=$o.toRgba(Vi,qi,Ki);return{css:C,rgba:L}}e.blend=t;function n(u){return(u.rgba&255)===255}e.isOpaque=n;function r(u,f,p){let g=Dm.ensureContrastRatio(u.rgba,f.rgba,p);if(g)return $o.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=r;function s(u){let f=(u.rgba|255)>>>0;return[Vi,qi,Ki]=Dm.toChannels(f),{css:$o.toCss(Vi,qi,Ki),rgba:f}}e.opaque=s;function i(u,f){return ti=Math.round(f*255),[Vi,qi,Ki]=Dm.toChannels(u.rgba),{css:$o.toCss(Vi,qi,Ki,ti),rgba:$o.toRgba(Vi,qi,Ki,ti)}}e.opacity=i;function a(u,f){return ti=u.rgba&255,i(u,ti*f/255)}e.multiplyOpacity=a;function c(u){return[u.rgba>>24&255,u.rgba>>16&255,u.rgba>>8&255]}e.toColorRGB=c})(CP||={});var bo;(e=>{let t,n;try{let s=document.createElement("canvas");s.width=1,s.height=1;let i=s.getContext("2d",{willReadFrequently:!0});i&&(t=i,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Vi=parseInt(s.slice(1,2).repeat(2),16),qi=parseInt(s.slice(2,3).repeat(2),16),Ki=parseInt(s.slice(3,4).repeat(2),16),$o.toColor(Vi,qi,Ki);case 5:return Vi=parseInt(s.slice(1,2).repeat(2),16),qi=parseInt(s.slice(2,3).repeat(2),16),Ki=parseInt(s.slice(3,4).repeat(2),16),ti=parseInt(s.slice(4,5).repeat(2),16),$o.toColor(Vi,qi,Ki,ti);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let i=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(i)return Vi=parseInt(i[1],10),qi=parseInt(i[2],10),Ki=parseInt(i[3],10),ti=Math.round((i[5]===void 0?1:parseFloat(i[5]))*255),$o.toColor(Vi,qi,Ki,ti);if(s==="transparent")return{css:"transparent",rgba:0};if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=s,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Vi,qi,Ki,ti]=t.getImageData(0,0,1,1).data,ti!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:$o.toRgba(Vi,qi,Ki,ti),css:s}}e.toColor=r})(bo||={});var oa;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,s,i){let a=r/255,c=s/255,u=i/255,f=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4);return f*.2126+p*.7152+g*.0722}e.relativeLuminance2=n})(oa||={});var Dm;(e=>{function t(a,c){if(ti=(c&255)/255,ti===1)return c;let u=c>>24&255,f=c>>16&255,p=c>>8&255,g=a>>24&255,y=a>>16&255,v=a>>8&255;return Vi=g+Math.round((u-g)*ti),qi=y+Math.round((f-y)*ti),Ki=v+Math.round((p-v)*ti),$o.toRgba(Vi,qi,Ki)}e.blend=t;function n(a,c,u){let f=oa.relativeLuminance(a>>8),p=oa.relativeLuminance(c>>8);if(Nc(f,p)<u){if(p<f){let v=r(a,c,u),S=Nc(f,oa.relativeLuminance(v>>8));if(S<u){let A=s(a,c,u),C=Nc(f,oa.relativeLuminance(A>>8));return S>C?v:A}return v}let g=s(a,c,u),y=Nc(f,oa.relativeLuminance(g>>8));if(y<u){let v=r(a,c,u),S=Nc(f,oa.relativeLuminance(v>>8));return y>S?g:v}return g}}e.ensureContrastRatio=n;function r(a,c,u){let f=a>>24&255,p=a>>16&255,g=a>>8&255,y=c>>24&255,v=c>>16&255,S=c>>8&255,A=Nc(oa.relativeLuminance2(y,v,S),oa.relativeLuminance2(f,p,g));for(;A<u&&(y>0||v>0||S>0);)y-=Math.max(0,Math.ceil(y*.1)),v-=Math.max(0,Math.ceil(v*.1)),S-=Math.max(0,Math.ceil(S*.1)),A=Nc(oa.relativeLuminance2(y,v,S),oa.relativeLuminance2(f,p,g));return(y<<24|v<<16|S<<8|255)>>>0}e.reduceLuminance=r;function s(a,c,u){let f=a>>24&255,p=a>>16&255,g=a>>8&255,y=c>>24&255,v=c>>16&255,S=c>>8&255,A=Nc(oa.relativeLuminance2(y,v,S),oa.relativeLuminance2(f,p,g));for(;A<u&&(y<255||v<255||S<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),A=Nc(oa.relativeLuminance2(y,v,S),oa.relativeLuminance2(f,p,g));return(y<<24|v<<16|S<<8|255)>>>0}e.increaseLuminance=s;function i(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=i})(Dm||={});function Pu(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Nc(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var kP=Object.freeze((()=>{let e=[bo.toColor("#2e3436"),bo.toColor("#cc0000"),bo.toColor("#4e9a06"),bo.toColor("#c4a000"),bo.toColor("#3465a4"),bo.toColor("#75507b"),bo.toColor("#06989a"),bo.toColor("#d3d7cf"),bo.toColor("#555753"),bo.toColor("#ef2929"),bo.toColor("#8ae234"),bo.toColor("#fce94f"),bo.toColor("#729fcf"),bo.toColor("#ad7fa8"),bo.toColor("#34e2e2"),bo.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],s=t[n/6%6|0],i=t[n%6];e.push({css:$o.toCss(r,s,i),rgba:$o.toRgba(r,s,i)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:$o.toCss(r,r,r),rgba:$o.toRgba(r,r,r)})}return e})());function Dw(e,t,n){return Math.max(t,Math.min(e,n))}function _P(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var Q8=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),r=this._buffer.getNullCell(),s=n,i=e.start.y,a=e.end.y,c=e.start.x,u=e.end.x;this._beforeSerialize(a-i,i,a);for(let f=i;f<=a;f++){let p=this._buffer.getLine(f);if(p){let g=f===e.start.y?c:0,y=f===e.end.y?u:p.length;for(let v=g;v<y;v++){let S=p.getCell(v,s===n?r:n);if(!S){console.warn(`Can't get cell at row=${f}, col=${v}`);continue}this._nextCell(S,s,f,v),s=S}}this._rowEnd(f,f===a)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,n,r){}_rowEnd(e,t){}_beforeSerialize(e,t,n){}_afterSerialize(){}_serializeString(e){return""}};function Vy(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function mc(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function $8(e,t){if(!e.isUnderline()&&!t.isUnderline())return!0;if(e.getUnderlineStyle()!==t.getUnderlineStyle())return!1;let n=e.isUnderlineColorDefault(),r=t.isUnderlineColorDefault();return n&&r?!0:n!==r?!1:e.getUnderlineColor()===t.getUnderlineColor()&&e.getUnderlineColorMode()===t.getUnderlineColorMode()}function qy(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&$8(e,t)&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}function H8(e,t){let n=e;return typeof n.attributesEquals=="function"?n.attributesEquals(t):Vy(e,t)&&mc(e,t)&&qy(e,t)}var LP=class extends Q8{constructor(t,n){super(t),this._terminal=n,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(t,n,r){this._allRows=new Array(t),this._lastContentCursorRow=n,this._lastCursorRow=n,this._firstRow=n}_rowEnd(t,n){this._nullCellCount>0&&!mc(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let r="";if(!n){t-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let s=this._buffer.getLine(t),i=this._buffer.getLine(t+1);if(!i.isWrapped)r=`\r
65
65
  `,this._lastCursorRow=t+1,this._lastCursorCol=0;else{r="";let a=s.getCell(s.length-1,this._thisRowLastChar),c=s.getCell(s.length-2,this._thisRowLastSecondChar),u=i.getCell(0,this._nextRowFirstChar),f=u.getWidth()>1,p=!1;(u.getChars()&&f?this._nullCellCount<=1:this._nullCellCount<=0)&&((a.getChars()||a.getWidth()===0)&&mc(a,u)&&(p=!0),f&&(c.getChars()||c.getWidth()===0)&&mc(a,u)&&mc(c,u)&&(p=!0)),p||(r="-".repeat(this._nullCellCount+1),r+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(r+="\x1B[A",r+=`\x1B[${s.length-this._nullCellCount}C`,r+=`\x1B[${this._nullCellCount}X`,r+=`\x1B[${s.length-this._nullCellCount}D`,r+="\x1B[B"),this._lastContentCursorRow=t+1,this._lastContentCursorCol=0,this._lastCursorRow=t+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=r,this._currentRow="",this._nullCellCount=0}_diffStyle(t,n){let r=[];if(H8(t,n))return r;let s=!Vy(t,n),i=!mc(t,n),a=!qy(t,n);if(s||i||a)if(t.isAttributeDefault())n.isAttributeDefault()||r.push(0);else{if(s){let c=t.getFgColor();t.isFgRGB()?r.push(38,2,c>>>16&255,c>>>8&255,c&255):t.isFgPalette()?c>=16?r.push(38,5,c):r.push(c&8?90+(c&7):30+(c&7)):r.push(39)}if(i){let c=t.getBgColor();t.isBgRGB()?r.push(48,2,c>>>16&255,c>>>8&255,c&255):t.isBgPalette()?c>=16?r.push(48,5,c):r.push(c&8?100+(c&7):40+(c&7)):r.push(49)}if(a){if(t.isInverse()!==n.isInverse()&&r.push(t.isInverse()?7:27),t.isBold()!==n.isBold()&&r.push(t.isBold()?1:22),$8(t,n))t.isUnderline()!==n.isUnderline()&&r.push(t.isUnderline()?4:24);else{let c=t.getUnderlineStyle();if(c===0)r.push(24);else if(c===1&&t.isUnderlineColorDefault())r.push(4);else if(r.push("4:"+c),!t.isUnderlineColorDefault()){let u=t.getUnderlineColor();t.isUnderlineColorRGB()?r.push("58:2::"+(u>>>16&255)+":"+(u>>>8&255)+":"+(u&255)):r.push("58:5:"+u)}}t.isOverline()!==n.isOverline()&&r.push(t.isOverline()?53:55),t.isBlink()!==n.isBlink()&&r.push(t.isBlink()?5:25),t.isInvisible()!==n.isInvisible()&&r.push(t.isInvisible()?8:28),t.isItalic()!==n.isItalic()&&r.push(t.isItalic()?3:23),t.isDim()!==n.isDim()&&r.push(t.isDim()?2:22),t.isStrikethrough()!==n.isStrikethrough()&&r.push(t.isStrikethrough()?9:29)}}return r}_nextCell(t,n,r,s){if(t.getWidth()===0)return;let i=t.getChars()==="",a=this._diffStyle(t,this._cursorStyle);if(i?!mc(this._cursorStyle,t):a.length>0){this._nullCellCount>0&&(mc(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=r,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${a.join(";")}m`;let c=this._buffer.getLine(r);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=r,this._cursorStyleCol=s)}i?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(mc(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=r,this._lastContentCursorCol=this._lastCursorCol=s+t.getWidth())}_serializeString(t){let n=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(n=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let r="";for(let a=0;a<n;a++)r+=this._allRows[a],a+1<n&&(r+=this._allRowSeparators[a]);if(!t){let a=this._buffer.baseY+this._buffer.cursorY,c=this._buffer.cursorX,u=a!==this._lastCursorRow||c!==this._lastCursorCol,f=p=>{p>0?r+=`\x1B[${p}C`:p<0&&(r+=`\x1B[${-p}D`)};u&&((p=>{p>0?r+=`\x1B[${p}B`:p<0&&(r+=`\x1B[${-p}A`)})(a-this._lastCursorRow),f(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(s,this._cursorStyle);return i.length>0&&(r+=`\x1B[${i.join(";")}m`),r}},EP=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,n,r){let s=n.length,i=r===void 0?s:Dw(r+t.rows,0,s);return this._serializeBufferByRange(t,n,{start:s-i,end:s-1},!1)}_serializeBufferByRange(t,n,r,s){return new LP(n,t).serialize({start:{x:0,y:typeof r.start=="number"?r.start:r.start.line},end:{x:t.cols,y:typeof r.end=="number"?r.end:r.end.line}},s)}_serializeBufferAsHTML(t,n){let r=t.buffer.active,s=new IP(r,t,n),i=n.onlySelection??!1,a=n.range;if(a)return s.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:t.cols,y:(a.endLine,a.endLine)}});if(!i){let u=r.length,f=n.scrollback,p=f===void 0?u:Dw(f+t.rows,0,u);return s.serialize({start:{x:0,y:u-p},end:{x:t.cols,y:u-1}})}let c=this._terminal?.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeScrollRegion(t){let n=t._core.buffer,r=n.scrollTop,s=n.scrollBottom;return r!==0||s!==t.rows-1?`\x1B[${r+1};${s+1}r`:""}_serializeModes(t){let n="",r=t.modes;if(r.applicationCursorKeysMode&&(n+="\x1B[?1h"),r.applicationKeypadMode&&(n+="\x1B[?66h"),r.bracketedPasteMode&&(n+="\x1B[?2004h"),r.insertMode&&(n+="\x1B[4h"),r.originMode&&(n+="\x1B[?6h"),r.reverseWraparoundMode&&(n+="\x1B[?45h"),r.sendFocusMode&&(n+="\x1B[?1004h"),r.wraparoundMode===!1&&(n+="\x1B[?7l"),r.mouseTrackingMode!=="none")switch(r.mouseTrackingMode){case"x10":n+="\x1B[?9h";break;case"vt200":n+="\x1B[?1000h";break;case"drag":n+="\x1B[?1002h";break;case"any":n+="\x1B[?1003h";break}return r.showCursor||(n+="\x1B[?25l"),n}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let n=t?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t?.scrollback);if(!t?.excludeAltBuffer&&this._terminal.buffer.active.type==="alternate"){let r=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);n+=`\x1B[?1049h\x1B[H${r}`}return t?.excludeModes||(n+=this._serializeModes(this._terminal),n+=this._serializeScrollRegion(this._terminal)),n}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t??{})}dispose(){}},IP=class extends Q8{constructor(t,n,r){super(t),this._terminal=n,this._options=r,this._currentRow="",this._htmlContent="",n._core._themeService?this._ansiColors=n._core._themeService.colors.ansi:this._ansiColors=kP}_beforeSerialize(t,n,r){this._htmlContent+="<html><body><!--StartFragment--><pre>";let s="#000000",i="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=this._terminal.options.theme?.foreground??"#ffffff",i=this._terminal.options.theme?.background??"#000000");let a=[];a.push("color: "+s+";"),a.push("background-color: "+i+";"),a.push("font-family: "+this._terminal.options.fontFamily+";"),a.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+a.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(t,n){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,n){let r=n?t.getFgColor():t.getBgColor();if(n?t.isFgRGB():t.isBgRGB())return"#"+[r>>16&255,r>>8&255,r&255].map(s=>s.toString(16).padStart(2,"0")).join("");if(n?t.isFgPalette():t.isBgPalette())return this._ansiColors[r].css}_getUnderlineColor(t){if(t.isUnderlineColorDefault())return;let n=t.getUnderlineColor();return t.isUnderlineColorRGB()?"#"+[n>>16&255,n>>8&255,n&255].map(r=>r.toString(16).padStart(2,"0")).join(""):this._ansiColors[n].css}_getUnderlineStyle(t){switch(t.getUnderlineStyle()){case 1:return"underline";case 2:return"underline double";case 3:return"underline wavy";case 4:return"underline dotted";case 5:return"underline dashed";default:return"underline"}}_diffStyle(t,n){let r=[];if(H8(t,n))return;let s=!Vy(t,n),i=!mc(t,n),a=!qy(t,n);if(s||i||a){let c=this._getHexColor(t,!0);c&&r.push("color: "+c+";");let u=this._getHexColor(t,!1);u&&r.push("background-color: "+u+";"),t.isInverse()&&r.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&r.push("font-weight: bold;");let f=[];if(t.isUnderline()&&f.push(this._getUnderlineStyle(t)),t.isOverline()&&f.push("overline"),t.isStrikethrough()&&f.push("line-through"),t.isBlink()&&f.push("blink"),f.length>0&&r.push("text-decoration: "+f.join(" ")+";"),t.isUnderline()){let p=this._getUnderlineColor(t);p&&r.push("text-decoration-color: "+p+";")}return t.isInvisible()&&r.push("visibility: hidden;"),t.isItalic()&&r.push("font-style: italic;"),t.isDim()&&r.push("opacity: 0.5;"),r}}_nextCell(t,n,r,s){if(t.getWidth()===0)return;let i=t.getChars()==="",a=this._diffStyle(t,n);a&&(this._currentRow+=a.length===0?"</span><span>":"</span><span style='"+a.join(" ")+"'>"),i?this._currentRow+=" ":this._currentRow+=_P(t.getChars())}_serializeString(){return this._htmlContent}};var RP=class{constructor(e=new NP,t=new z8){this._base64=e,this._provider=t}activate(e){this._terminal=e,this._disposable=e.parser.registerOscHandler(52,t=>this._setOrReportClipboard(t))}dispose(){return this._disposable?.dispose()}_readText(e,t){let n=this._base64.encodeText(t);this._terminal?.input(`\x1B]52;${e};${n}\x07`,!1)}_setOrReportClipboard(e){let t=e.split(";");if(t.length<2)return!0;let n=t[0],r=t[1];if(r==="?"){let a=this._provider.readText(n);return a instanceof Promise?a.then(c=>(this._readText(n,c),!0)):(this._readText(n,a),!0)}let s="";try{s=this._base64.decodeText(r)}catch{}let i=this._provider.writeText(n,s);return i instanceof Promise?i.then(()=>!0):!0}},z8=class{readText(e){return navigator.clipboard.readText()}writeText(e,t){return navigator.clipboard.writeText(t)}},NP=class{encodeText(t){let n=new TextEncoder().encode(t);if(n.toBase64!==void 0)return n.toBase64();let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return btoa(r)}decodeText(t){if(Uint8Array.fromBase64!==void 0){try{return new TextDecoder().decode(Uint8Array.fromBase64(t))}catch{}return""}try{let n=atob(t),r=new Uint8Array(n.length);for(let s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return new TextDecoder().decode(r)}catch{}return""}};var MP=Object.create,U8=Object.defineProperty,DP=Object.getOwnPropertyDescriptor,jP=Object.getOwnPropertyNames,PP=Object.getPrototypeOf,BP=Object.prototype.hasOwnProperty,$0=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},FP=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of jP(t))!BP.call(e,s)&&s!==n&&U8(e,s,{get:()=>t[s],enumerable:!(r=DP(t,s))||r.enumerable});return e},H0=(e,t,n)=>(n=e!=null?MP(PP(e)):{},FP(!e||!e.__esModule?U8(n,"default",{value:e,enumerable:!0}):n,e)),Ky=$0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn("BE platform detected. This version of node-sixel works only on LE properly.");function t(v){return v&255}e.red=t;function n(v){return v>>>8&255}e.green=n;function r(v){return v>>>16&255}e.blue=r;function s(v){return v>>>24&255}e.alpha=s;function i(v,S,A,C=255){return((C&255)<<24|(A&255)<<16|(S&255)<<8|v&255)>>>0}e.toRGBA8888=i;function a(v){return[v&255,v>>8&255,v>>16&255,v>>>24]}e.fromRGBA8888=a;function c(v,S){let A=t(v),C=n(v),L=r(v),E=Number.MAX_SAFE_INTEGER,M=-1;for(let P=0;P<S.length;++P){let F=A-S[P][0],j=C-S[P][1],T=L-S[P][2],Q=F*F+j*j+T*T;if(!Q)return P;Q<E&&(E=Q,M=P)}return M}e.nearestColorIndex=c;function u(v,S,A){return Math.max(v,Math.min(A,S))}function f(v,S,A){return A<0&&(A+=1),A>1&&(A-=1),A*6<1?S+(v-S)*6*A:A*2<1?v:A*3<2?S+(v-S)*(4-A*6):S}function p(v,S,A){if(!A){let E=Math.round(S*255);return i(E,E,E)}let C=S<.5?S*(1+A):S+A-S*A,L=2*S-C;return i(u(0,255,Math.round(f(C,L,v+1/3)*255)),u(0,255,Math.round(f(C,L,v)*255)),u(0,255,Math.round(f(C,L,v-1/3)*255)))}function g(v,S,A){return(4278190080|Math.round(A/100*255)<<16|Math.round(S/100*255)<<8|Math.round(v/100*255))>>>0}e.normalizeRGB=g;function y(v,S,A){return p((v+240%360)/360,S/100,A/100)}e.normalizeHLS=y,e.PALETTE_VT340_COLOR=new Uint32Array([g(0,0,0),g(20,20,80),g(80,13,13),g(20,80,20),g(80,20,80),g(20,80,80),g(80,80,20),g(53,53,53),g(26,26,26),g(33,33,60),g(60,26,26),g(33,60,33),g(60,33,60),g(33,60,60),g(60,60,33),g(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([g(0,0,0),g(13,13,13),g(26,26,26),g(40,40,40),g(6,6,6),g(20,20,20),g(33,33,33),g(46,46,46),g(0,0,0),g(13,13,13),g(26,26,26),g(40,40,40),g(6,6,6),g(20,20,20),g(33,33,33),g(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let v=[i(0,0,0),i(205,0,0),i(0,205,0),i(205,205,0),i(0,0,238),i(205,0,205),i(0,250,205),i(229,229,229),i(127,127,127),i(255,0,0),i(0,255,0),i(255,255,0),i(92,92,255),i(255,0,255),i(0,255,255),i(255,255,255)],S=[0,95,135,175,215,255];for(let A=0;A<6;++A)for(let C=0;C<6;++C)for(let L=0;L<6;++L)v.push(i(S[A],S[C],S[L]));for(let A=8;A<=238;A+=10)v.push(i(A,A,A));return new Uint32Array(v)})(),e.DEFAULT_BACKGROUND=i(0,0,0,255),e.DEFAULT_FOREGROUND=i(255,255,255,255)}),G8=$0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InWasm=n;var t=r=>{if(Uint8Array.fromBase64)return Uint8Array.fromBase64(r);if(typeof Buffer<"u")return Buffer.from(r,"base64");let s=atob(r),i=new Uint8Array(s.length);for(let a=0;a<i.length;++a)i[a]=s.charCodeAt(a);return i};function n(r){if(r.d){let{t:s,s:i,d:a}=r,c,u,f=WebAssembly;return s===0?i?p=>new f.Instance(u||(u=new f.Module(c||(c=t(a)))),p):p=>u?f.instantiate(u,p):f.instantiate(c||(c=t(a)),p).then(g=>(u=g.module)&&g.instance):s===1?i?()=>u||(u=new f.Module(c||(c=t(a)))):()=>u?Promise.resolve(u):f.compile(c||(c=t(a))).then(p=>u=p):i?()=>c||(c=t(a)):()=>Promise.resolve(c||(c=t(a)))}if(typeof _wasmCtx>"u")throw new Error('must run "inwasm"');_wasmCtx.add(r)}}),W8=$0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=G8(),n=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABBQFgAAF/Ag8BA2VudgZtZW1vcnkCAAEDAwIAAAcNAgNkZWMAAANlbmQAAQqLBgKZBAEKf0GIKCgCAEGgKGohAUGEKCgCACIDQaAoaiEAQYAoKAIAQQFrQXxxIgRBoChqIQUgBEEQayADSgRAIARBkChqIQMDQCABIABBA2otAABBAnQoAoAgIABBAmotAABBAnQoAoAYIABBAWotAABBAnQoAoAQIAAtAABBAnQoAoAIcnJyIgY2AgAgAUEDaiAAQQdqLQAAQQJ0KAKAICAAQQZqLQAAQQJ0KAKAGCAAQQVqLQAAQQJ0KAKAECAAQQRqLQAAQQJ0KAKACHJyciIHNgIAIAFBBmogAEELai0AAEECdCgCgCAgAEEKai0AAEECdCgCgBggAEEJai0AAEECdCgCgBAgAEEIai0AAEECdCgCgAhycnIiCDYCACABQQlqIABBD2otAABBAnQoAoAgIABBDmotAABBAnQoAoAYIABBDWotAABBAnQoAoAQIABBDGotAABBAnQoAoAIcnJyIgk2AgAgAiAGciAHciAIciAJciECIAFBDGohASAAQRBqIgAgA0kNAAsLIAAgBUkEQANAIAEgAEEDai0AAEECdCgCgCAgAEECai0AAEECdCgCgBggAEEBai0AAEECdCgCgBAgAC0AAEECdCgCgAhycnIiAzYCACACIANyIQIgAUEDaiEBIABBBGoiACAFSQ0ACwtBfyEAIAJB////B00Ef0GEKCAENgIAQYgoIAFBoChrNgIAQQAFQX8LC+0BAQR/AkBBgCgoAgAiAUGEKCgCACIAa0EFTgRAQX8hAxAADQFBgCgoAgAhAUGEKCgCACEAC0F/IQMgASAAayIBQQJIDQAgAC0AoShBAnQoAoAQIAAtAKAoQQJ0KAKACHIhAgJ/IAFBBEYEQEEDQQQgAC0AoyhBPUYbIAAtAKIoQT1GayEBC0EBIAFBA0kNABogAC0AoihBAnQoAoAYIAJyIQJBAiABQQRHDQAaIAAtAKMoQQJ0KAKAICACciECQQMLIQEgAkH///8HSw0AQQAhA0GIKCgCACIAIAI2AKAoQYgoIAAgAWo2AgALIAML"}),r=new Uint8Array("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").map(c=>c.charCodeAt(0))),s=new Uint32Array(1024);s.fill(4278190080);for(let c=0;c<r.length;++c)s[r[c]]=c<<2;for(let c=0;c<r.length;++c)s[256+r[c]]=c>>4|(c<<4&255)<<8;for(let c=0;c<r.length;++c)s[512+r[c]]=c>>2<<8|(c<<6&255)<<16;for(let c=0;c<r.length;++c)s[768+r[c]]=c<<16;var i=new Uint8Array(0),a=class{constructor(c,u,f){if(this._inst=null,this._ended=!0,this._bytes=0,this.keepSize=c??1048576,this.maxBytes=u??4294901760,this._bytes=f??32768,this._bytes>this.maxBytes||this.maxBytes>4294901760)throw new Error("invalid byte settings")}get data8(){return this._inst?this._d.subarray(0,this._m32[1282]):i}release(){this._inst&&(this._bytes>this.keepSize?this._inst=this._m32=this._d=this._mem=null:(this._m32[1280]=0,this._m32[1281]=0,this._m32[1282]=0))}init(c,u){if(this.maxBytes=c??this.maxBytes,this._bytes=u??Math.min(this._bytes,this.maxBytes),this._bytes>this.maxBytes||this.maxBytes>4294901760)throw Error("invalid byte settings");let f=this._m32,p=this._bytes+5152;this._inst?this._mem.buffer.byteLength<p&&(this._mem.grow(Math.ceil((p-this._mem.buffer.byteLength)/65536)),f=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)):(this._mem=new WebAssembly.Memory({initial:Math.ceil(p/65536)}),this._inst=n({env:{memory:this._mem}}),f=new Uint32Array(this._mem.buffer,0),f.set(s,256),this._d=new Uint8Array(this._mem.buffer,5152)),f[1280]=0,f[1281]=0,f[1282]=0,this._m32=f,this._ended=!1}_realloc(c){let u=this._m32[1280]+c;if(this._bytes<u){if(u>this.maxBytes)return-3;let f=this._bytes;for(;(f*=2)<u;);if(f=Math.min(f,this.maxBytes),f<u)return-3;if(f+5152>this._mem.buffer.byteLength){let p=Math.ceil((f+5152-this._mem.buffer.byteLength)/65536);this._mem.grow(p),this._m32=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)}this._bytes=f}return 0}put(c){if(!this._inst||this._ended)return-2;if(this._realloc(c.length))return-3;let u=this._m32;return this._d.set(c,u[1280]),u[1280]+=c.length,u[1280]-u[1281]>=131072?this._inst.exports.dec():0}end(){return this._ended=!0,this._inst?this._inst.exports.end():-2}get loadedBytes(){return this._inst?this._m32[1280]:0}get freeBytes(){return this._inst?this.maxBytes-this._m32[1280]:0}};e.default=a}),OP=$0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=G8(),n=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABCgJgAABgA39/fwACDwEDZW52Bm1lbW9yeQIAAQMDAgABBwcBA2RlYwABCAEACu4EAgwAQQBBAEGAAvwLAAveBAEJf0EAQQBBgAL8CwAgAUEXTgRAIAAgAWpBCGshCkGACCEBIAJBAnRBgAhqIQsgAEEOaiEDQf8BIQZBACECA0AgA0EBaiEHIAMtAAAiCEE/cSEAAkACQCAIQcABcSIJRQRAIABBAnQiAC0AAyEGIAAtAAIhBCAALQABIQUgAC0AACECIAchAwwBCwJAIAhB/QFLDQAgCUHAAUcNACAFQQVsIAJBA2xqIARBB2xqIAZBC2xqQT9xQQJ0IgMgBDoAAiADIAU6AAEgAyACOgAAIANBA2ogBjoAAANAIAEgAjoAACABQQNqIAY6AAAgAUECaiAEOgAAIAFBAWogBToAACABQQRqIQEgAEUEQCAHIQMMBAsgAEEBayEAIAEgC0kNAAsgByEDDAILAn8CQAJAAkAgCEH+AWsOAgABAgsgAy0AAyEEIAMtAAIhBSADLQABIQIgA0EEagwCCyADKAIBIgJBGHYhBiACQRB2IQQgAkEIdiEFIANBBWoMAQsgCUGAAUcEQCAHIAlBwABHDQEaIAQgCEEDcWpBAmshBCACIABBBHZqQQJrIQIgBSAIQQJ2QQNxakECayEFIAcMAQsgBCAAQShrIgkgAy0AASIHQQ9xamohBCACIAdBBHYgCWpqIQIgACAFakEgayEFIANBAmoLIQMgBUEFbCACQQNsaiAEQQdsaiAGQQtsakE/cUECdCIAIAQ6AAIgACAFOgABIAAgAjoAACAAQQNqIAY6AAALIAEgBjoAAyABIAQ6AAIgASAFOgABIAEgAjoAACABQQRqIQELIAMgCkkNAAsLCw=="}),r=class{constructor(s){this.keepSize=s,this.width=0,this.height=0}decode(s){this.width=s[4]<<24|s[5]<<16|s[6]<<8|s[7],this.height=s[8]<<24|s[9]<<16|s[10]<<8|s[11];let i=this.width*this.height,a=i*4,c=s.length,u=Math.max(a,c)+(Math.min(a,c)>>1)+4096;this._inst?this._mem.buffer.byteLength<u&&(this._mem.grow(Math.ceil((u-this._mem.buffer.byteLength)/65536)),this._d=null):(this._mem=new WebAssembly.Memory({initial:Math.ceil(u/65536)}),this._inst=n({env:{memory:this._mem}})),this._d||(this._d=new Uint8Array(this._mem.buffer));let f=this._mem.buffer.byteLength-c&-256;return this._d.set(s,f),this._inst.exports.dec(f,c,i),this._d.subarray(1024,1024+a)}release(){this._inst&&this._mem.buffer.byteLength>this.keepSize&&(this._inst=this._d=this._mem=null)}};e.default=r}),QP=$0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:"AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF"}}),$P=$0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=Ky(),n=QP();function r(v){if(typeof Buffer<"u")return Buffer.from(v,"base64");let S=atob(v),A=new Uint8Array(S.length);for(let C=0;C<A.length;++C)A[C]=S.charCodeAt(C);return A}var s=r(n.LIMITS.BYTES),i,a=new Uint32Array,c=class{constructor(){this.bandHandler=v=>1,this.modeHandler=v=>1}handle_band(v){return this.bandHandler(v)}mode_parsed(v){return this.modeHandler(v)}},u={memoryLimit:2048*65536,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:n.LIMITS.PALETTE_SIZE,truncate:!0};function f(v){let S=new c,A={env:{handle_band:S.handle_band.bind(S),mode_parsed:S.mode_parsed.bind(S)}};return WebAssembly.instantiate(i||s,A).then(C=>(i=i||C.module,new p(v,C.instance||C,S)))}e.DecoderAsync=f;var p=class{constructor(v,S,A){if(this._PIXEL_OFFSET=n.LIMITS.MAX_WIDTH+4,this._canvas=a,this._bandWidths=[],this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},u,v),this._opts.paletteLimit>n.LIMITS.PALETTE_SIZE)throw new Error(`DecoderOptions.paletteLimit must not exceed ${n.LIMITS.PALETTE_SIZE}`);if(S)A.bandHandler=this._handle_band.bind(this),A.modeHandler=this._initCanvas.bind(this);else{let C=i||(i=new WebAssembly.Module(s));S=new WebAssembly.Instance(C,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=S,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),n.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),n.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(v){if(v===2){let S=this.width*this.height;if(S>this._canvas.length){if(this._opts.memoryLimit&&S*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(S)}this._maxWidth=this._width}else if(v===1)if(this._level===2){let S=Math.min(this._rasterWidth,n.LIMITS.MAX_WIDTH)*this._rasterHeight;if(S>this._canvas.length){if(this._opts.memoryLimit&&S*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(S)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536));return 0}_realloc(v,S){let A=v+S;if(A>this._canvas.length){if(this._opts.memoryLimit&&A*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");let C=new Uint32Array(Math.ceil(A/65536)*65536);C.set(this._canvas),this._canvas=C}}_handle_band(v){let S=this._PIXEL_OFFSET,A=this._lastOffset;if(this._mode===2){let C=this.height-this._currentHeight,L=0;for(;L<6&&C>0;)this._canvas.set(this._pSrc.subarray(S*L,S*L+v),A+v*L),L++,C--;this._lastOffset+=v*L,this._currentHeight+=L}else if(this._mode===1){this._realloc(A,v*6),this._maxWidth=Math.max(this._maxWidth,v),this._minWidth=Math.min(this._minWidth,v);for(let C=0;C<6;++C)this._canvas.set(this._pSrc.subarray(S*C,S*C+v),A+v*C);this._bandWidths.push(v),this._lastOffset+=v*6,this._currentHeight+=6}return 0}get width(){return this._mode!==1?this._width:Math.max(this._maxWidth,this._wasm.current_width())}get height(){return this._mode!==1?this._height:this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(v=this._opts.fillColor,S=this._opts.palette,A=this._opts.paletteLimit,C=this._opts.truncate){this._wasm.init(this._opts.sixelColor,v,A,C?1:0),S&&this._palette.set(S.subarray(0,n.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(v,S=0,A=v.length){let C=S;for(;C<A;){let L=Math.min(A-C,n.LIMITS.CHUNK_SIZE);this._chunk.set(v.subarray(C,C+=L)),this._wasm.decode(0,L)}}decodeString(v,S=0,A=v.length){let C=S;for(;C<A;){let L=Math.min(A-C,n.LIMITS.CHUNK_SIZE);for(let E=0,M=C;E<L;++E,++M)this._chunk[E]=v.charCodeAt(M);C+=L,this._wasm.decode(0,L)}}get data32(){if(this._mode===0||!this.width||!this.height)return a;let v=this._wasm.current_width();if(this._mode===2){let S=this.height-this._currentHeight;if(S>0){let A=this._PIXEL_OFFSET,C=this._lastOffset,L=0;for(;L<6&&S>0;)this._canvas.set(this._pSrc.subarray(A*L,A*L+v),C+v*L),L++,S--;S&&this._canvas.fill(this._fillColor,C+v*L)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let L=!1;if(v)if(v!==this._minWidth)L=!0;else{let E=this._PIXEL_OFFSET,M=this._lastOffset;this._realloc(M,v*6);for(let P=0;P<6;++P)this._canvas.set(this._pSrc.subarray(E*P,E*P+v),M+v*P)}if(!L)return this._canvas.subarray(0,this.width*this.height)}let S=new Uint32Array(this.width*this.height);S.fill(this._fillColor);let A=0,C=0;for(let L=0;L<this._bandWidths.length;++L){let E=this._bandWidths[L];for(let M=0;M<6;++M)S.set(this._canvas.subarray(C,C+=E),A),A+=this.width}if(v){let L=this._PIXEL_OFFSET,E=this._wasm.current_height();for(let M=0;M<E;++M)S.set(this._pSrc.subarray(L*M,L*M+v),A+this.width*M)}return S}return a}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=a,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=p;function g(v,S){let A=new p(S);return A.init(),typeof v=="string"?A.decodeString(v):A.decode(v),{width:A.width,height:A.height,data32:A.data32,data8:A.data8}}e.decode=g;async function y(v,S){let A=await f(S);return A.init(),typeof v=="string"?A.decodeString(v):A.decode(v),{width:A.width,height:A.height,data32:A.data32,data8:A.data8}}e.decodeAsync=y});function u2(e){return{dispose:e}}var V8=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},q8=class{constructor(){this._store=new V8}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};q8.None=Object.freeze({dispose(){}});var HP=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},zP=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,n)=>{if(this._disposed)return u2(()=>{});let r={fn:e,thisArgs:t};this._listeners.push(r);let s=u2(()=>{let i=this._listeners.indexOf(r);i!==-1&&this._listeners.splice(i,1)});return n&&(Array.isArray(n)?n.push(s):n.add(s)),s},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:n}=this._listeners[0];t.call(n,e);return}default:{let t=this._listeners.slice();for(let{fn:n,thisArgs:r}of t)n.call(r,e)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},UP;(e=>{function t(i,a){return i(c=>a.fire(c))}e.forward=t;function n(i,a){return(c,u,f)=>i(p=>c.call(u,a(p)),void 0,f)}e.map=n;function r(...i){return(a,c,u)=>{let f=new V8;for(let p of i)f.add(p(g=>a.call(c,g)));return u&&(Array.isArray(u)?u.push(f):u.add(f)),f}}e.any=r;function s(i,a,c){return a(c),i(u=>a(u))}e.runAndSubscribe=s})(UP||={});var jw=H0(Ky()),R0=class lu extends q8{constructor(t){super(),this._terminal=t,this._layers=new Map,this._optionsRefresh=this._register(new HP),this._oldOpen=this._terminal._core.open,this._terminal._core.open=n=>{this._oldOpen?.call(this._terminal._core,n),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange(n=>{n==="fontSize"&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))}),this._register(u2(()=>{this.removeLayerFromDom(),this.removeLayerFromDom("bottom"),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this._layers.clear(),this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0}))}get canvas(){return this._layers.get("top")?.canvas}static createCanvas(t,n,r){let s=(t??document).createElement("canvas");return s.width=n|0,s.height=r|0,s}static createImageData(t,n,r,s){if(typeof ImageData!="function"){let i=t.createImageData(n,r);return s&&i.data.set(new Uint8ClampedArray(s,0,n*r*4)),i}return s?new ImageData(new Uint8ClampedArray(s,0,n*r*4),n,r):new ImageData(n,r)}static createImageBitmap(t){return typeof createImageBitmap!="function"?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&this.cellSize.height!==-1&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._terminal.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,n,r){let s=t*(this.dimensions?.css.cell.height||0),i=this.dimensions?.css.canvas.width||0,a=(n+1-t)*(this.dimensions?.css.cell.height||0);(!r||r==="top")&&this._layers.get("top")?.clearRect(0,s,i,a),(!r||r==="bottom")&&this._layers.get("bottom")?.clearRect(0,s,i,a)}clearAll(t){if(!t||t==="top"){let n=this._layers.get("top");n?.clearRect(0,0,n.canvas.width,n.canvas.height)}if(!t||t==="bottom"){let n=this._layers.get("bottom");n?.clearRect(0,0,n.canvas.width,n.canvas.height)}}draw(t,n,r,s,i=1){let a=this._layers.get(t.layer);if(!a)return;let{width:c,height:u}=this.cellSize;if(c===-1||u===-1)return;this._rescaleImage(t,c,u);let f=t.actual,p=Math.ceil(f.width/c),g=n%p*c,y=Math.floor(n/p)*u,v=r*c,S=s*u,A=i*c+g>f.width?f.width-g:i*c,C=y+u>f.height?f.height-y:u;a.drawImage(f,Math.floor(g),Math.floor(y),Math.ceil(A),Math.ceil(C),Math.floor(v),Math.floor(S),Math.ceil(A),Math.ceil(C))}extractTile(t,n){let{width:r,height:s}=this.cellSize;if(r===-1||s===-1)return;this._rescaleImage(t,r,s);let i=t.actual,a=Math.ceil(i.width/r),c=n%a*r,u=Math.floor(n/a)*s,f=r+c>i.width?i.width-c:r,p=u+s>i.height?i.height-u:s,g=lu.createCanvas(this.document,f,p),y=g.getContext("2d");if(y)return y.drawImage(i,Math.floor(c),Math.floor(u),Math.floor(f),Math.floor(p),0,0,Math.floor(f),Math.floor(p)),g}drawPlaceholder(t,n,r=1){let s=this._layers.get("top");if(s){let{width:i,height:a}=this.cellSize;if(i===-1||a===-1||(this._placeholder?a>=this._placeholder.height&&this._createPlaceHolder(a+1):this._createPlaceHolder(Math.max(a+1,24)),!this._placeholder))return;s.drawImage(this._placeholderBitmap??this._placeholder,t*i,n*a%2?0:1,i*r,a,t*i,n*a,i*r,a)}}rescaleCanvas(){let t=this.dimensions?.css.canvas.width||0,n=this.dimensions?.css.canvas.height||0;for(let r of this._layers.values())(r.canvas.width!==t||r.canvas.height!==n)&&(r.canvas.width=t,r.canvas.height=n)}_rescaleImage(t,n,r){if(n===t.actualCellSize.width&&r===t.actualCellSize.height)return;let{width:s,height:i}=t.origCellSize;if(n===s&&r===i){t.actual=t.orig,t.actualCellSize.width=s,t.actualCellSize.height=i;return}let a=lu.createCanvas(this.document,Math.ceil(t.orig.width*n/s),Math.ceil(t.orig.height*r/i)),c=a.getContext("2d");c&&(c.drawImage(t.orig,0,0,a.width,a.height),t.actual=a,t.actualCellSize.width=n,t.actualCellSize.height=r)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{for(let n of[...this._layers.keys()])this.removeLayerFromDom(n);this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(t="top"){if(!this.document||!this._terminal._core.screenElement){console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement");return}if(this._layers.has(t))return;let n=lu.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0);n.classList.add(`xterm-image-layer-${t}`);let r=this._terminal._core.screenElement;r.style.isolation="isolate",t==="bottom"?(n.style.zIndex="-1",r.insertBefore(n,r.firstChild)):(n.style.zIndex="0",r.appendChild(n));let s=n.getContext("2d",{alpha:!0});if(!s){n.remove();return}this._layers.set(t,s),this.clearAll(t)}removeLayerFromDom(t="top"){let n=this._layers.get(t);n&&(n.canvas.remove(),this._layers.delete(t))}hasLayer(t){return this._layers.has(t)}_createPlaceHolder(t=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let n=32,r=lu.createCanvas(this.document,n,t),s=r.getContext("2d",{alpha:!1});if(!s)return;let i=lu.createImageData(s,n,t),a=new Uint32Array(i.data.buffer),c=(0,jw.toRGBA8888)(0,0,0),u=(0,jw.toRGBA8888)(255,255,255);a.fill(c);for(let g=0;g<t;++g){let y=g%2,v=g*n;for(let S=0;S<n;S+=2)a[v+S+y]=u}s.putImageData(i,0,0);let f=screen.width+n-1&-32||4096;this._placeholder=lu.createCanvas(this.document,f,t);let p=this._placeholder.getContext("2d",{alpha:!1});if(!p){this._placeholder=void 0;return}for(let g=0;g<f;g+=n)p.drawImage(r,g,0);lu.createImageBitmap(this._placeholder).then(g=>this._placeholderBitmap=g)}get document(){return this._terminal._core._coreBrowserService?.window.document}},Oc={width:7,height:14},d2=class K8{constructor(t=0,n=0,r=-1,s=-1){this.imageId=r,this.tileId=s,this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new K8(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0&&this.imageId===-1}},Fp=new d2,GP=class{constructor(e,t,n){this._terminal=e,this._renderer=t,this._opts=n,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(r){r instanceof Error&&console.error(r.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let e of this._images.values())e.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return this._pixelLimit*4/1e6}setLimit(e){if(e<.5||e>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=e/4*1e6>>>0,this._evictOldest(0)}getUsage(){return this._getStoredPixels()*4/1e6}_getStoredPixels(){let e=0;for(let t of this._images.values())t.orig&&(e+=t.orig.width*t.orig.height,t.actual&&t.actual!==t.orig&&(e+=t.actual.width*t.actual.height));return e}_delImg(e){let t=this._images.get(e);t&&(this._images.delete(e),window.ImageBitmap&&t.orig instanceof ImageBitmap&&t.orig.close(),this.onImageDeleted?.(e))}wipeAlternate(){let e=[];for(let[t,n]of this._images.entries())n.bufferType==="alternate"&&(n.marker?.dispose(),e.push(t));for(let t of e)this._delImg(t);this._needsFullClear=!0,this._fullyCleared=!1}deleteImage(e){let t=this._images.get(e);t&&(t.marker?.dispose(),this._delImg(e))}addImage(e,t){this._evictOldest(e.width*e.height);let n=this._renderer.cellSize;(n.width===-1||n.height===-1)&&(n=Oc);let r=Math.ceil(e.width/n.width),s=Math.ceil(e.height/n.height),i=++this._lastId,a=this._terminal._core.buffer,c=this._terminal.cols,u=this._terminal.rows,f=a.x,p=a.y,g=f,y=0;t.scrolling||(a.x=0,a.y=0,g=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(a.y);for(let C=0;C<s;++C){let L=a.lines.get(a.y+a.ybase);for(let E=0;E<r&&!(g+E>=c);++E)this._writeToCell(L,g+E,i,C*r+E),y++;if(t.scrolling)C<s-1&&this._terminal._core._inputHandler.lineFeed();else if(++a.y>=u)break;a.x=g}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(a.y),t.scrolling?t.cursorPos==="iip"?a.x=Math.min(g+r,c):a.x=g:(a.x=f,a.y=p);let v=[];for(let[C,L]of this._images.entries())L.tileCount<1&&(L.marker?.dispose(),v.push(C));for(let C of v)this._delImg(C);let S=this._terminal.registerMarker(0);S?.onDispose(()=>{this._images.get(i)&&this._delImg(i)}),this._terminal.buffer.active.type==="alternate"&&this._evictOnAlternate();let A={orig:e,origCellSize:n,actual:e,actualCellSize:{...n},marker:S||void 0,tileCount:y,bufferType:this._terminal.buffer.active.type,layer:t.layer,zIndex:t.zIndex};return this._images.set(i,A),this.onImageAdded?.(),i}render(e){let t=!1,n=!1;for(let f of this._images.values())if(f.layer==="bottom"?n=!0:t=!0,t&&n)break;if(t&&!this._renderer.hasLayer("top")&&(this._renderer.insertLayerToDom("top"),!this._renderer.hasLayer("top")))return;if(n&&!this._renderer.hasLayer("bottom")&&this._renderer.insertLayerToDom("bottom"),this._renderer.rescaleCanvas(),!this._images.size){this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),this._renderer.hasLayer("top")&&this._renderer.removeLayerFromDom("top"),this._renderer.hasLayer("bottom")&&this._renderer.removeLayerFromDom("bottom");return}!t&&this._renderer.hasLayer("top")&&(this._renderer.clearAll("top"),this._renderer.removeLayerFromDom("top")),!n&&this._renderer.hasLayer("bottom")&&(this._renderer.clearAll("bottom"),this._renderer.removeLayerFromDom("bottom")),this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:r,end:s}=e,i=this._terminal._core.buffer,a=this._terminal._core.cols;this._renderer.clearLines(r,s);let c=[],u=[];for(let f=r;f<=s;++f){let p=i.lines.get(f+i.ydisp);if(!p)return;for(let g=0;g<a;++g){let y;if(p.getBg(g)&268435456)y=p._extendedAttrs[g]??Fp;else{let A=p._extendedAttrs[g];if(!A||A.imageId===void 0||A.imageId===-1)continue;y=A}let v=y.imageId;if(v===void 0||v===-1)continue;let S=this._images.get(v);if(y.tileId!==-1){let A=y.tileId,C=g,L=1;for(;++g<a;){let E=p._extendedAttrs[g];if(!E||E.imageId!==v||E.tileId!==A+L)break;L++}g--,S?S.actual&&c.push({imgSpec:S,tileId:A,col:C,row:f,count:L}):this._opts.showPlaceholder&&u.push({col:C,row:f,count:L}),this._fullyCleared=!1}}}c.sort((f,p)=>f.imgSpec.zIndex-p.imgSpec.zIndex);for(let f of u)this._renderer.drawPlaceholder(f.col,f.row,f.count);for(let f of c)this._renderer.draw(f.imgSpec,f.tileId,f.col,f.row,f.count)}viewportResize(e){if(!this._images.size){this._viewportMetrics=e;return}if(this._viewportMetrics.cols>=e.cols){this._viewportMetrics=e;return}let t=this._terminal._core.buffer,n=t.lines.length,r=this._viewportMetrics.cols-1;for(let s=0;s<n;++s){let i=t.lines.get(s);if(i.getBg(r)&268435456){let a=i._extendedAttrs[r]??Fp,c=a.imageId;if(c===void 0||c===-1)continue;let u=this._images.get(c);if(!u)continue;let f=Math.ceil((u.actual?.width||0)/u.actualCellSize.width);if(a.tileId%f+1>=f)continue;let p=!1;for(let v=r+1;v>e.cols;++v)if(i._data[v*3+0]&4194303){p=!0;break}if(p)continue;let g=Math.min(e.cols,f-a.tileId%f+r),y=a.tileId;for(let v=r+1;v<g;++v)this._writeToCell(i,v,c,++y),u.tileCount++}}this._viewportMetrics=e}getImageAtBufferCell(e,t){let n=this._terminal._core.buffer.lines.get(t);if(n&&n.getBg(e)&268435456){let r=n._extendedAttrs[e]??Fp;if(r.imageId&&r.imageId!==-1){let s=this._images.get(r.imageId)?.orig;if(window.ImageBitmap&&s instanceof ImageBitmap){let i=R0.createCanvas(window.document,s.width,s.height);return i.getContext("2d")?.drawImage(s,0,0,s.width,s.height),i}return s}}}extractTileAtBufferCell(e,t){let n=this._terminal._core.buffer.lines.get(t);if(n&&n.getBg(e)&268435456){let r=n._extendedAttrs[e]??Fp;if(r.imageId&&r.imageId!==-1&&r.tileId!==-1){let s=this._images.get(r.imageId);if(s)return this._renderer.extractTile(s,r.tileId)}}}_evictOldest(e){let t=this._getStoredPixels(),n=t;for(;this._pixelLimit<n+e&&this._images.size;){let r=this._images.get(++this._lowestId);r&&r.orig&&(n-=r.orig.width*r.orig.height,r.actual&&r.orig!==r.actual&&(n-=r.actual.width*r.actual.height),r.marker?.dispose(),this._delImg(this._lowestId))}return t-n}_writeToCell(e,t,n,r){if(e._data[t*3+2]&268435456){let s=e._extendedAttrs[t];if(s){if(s.imageId!==void 0){let i=this._images.get(s.imageId);i&&i.tileCount--,s.imageId=n,s.tileId=r;return}e._extendedAttrs[t]=new d2(s.ext,s.urlId,n,r);return}}e._data[t*3+2]|=268435456,e._extendedAttrs[t]=new d2(0,0,n,r)}_evictOnAlternate(){for(let n of this._images.values())n.bufferType==="alternate"&&(n.tileCount=0);let e=this._terminal._core.buffer;for(let n=0;n<this._terminal.rows;++n){let r=e.lines.get(n);if(r){for(let s=0;s<this._terminal.cols;++s)if(r._data[s*3+2]&268435456){let i=r._extendedAttrs[s]?.imageId;if(i){let a=this._images.get(i);a&&a.tileCount++}}}}let t=[];for(let[n,r]of this._images.entries())r.bufferType==="alternate"&&!r.tileCount&&(r.marker?.dispose(),t.push(n));for(let n of t)this._delImg(n)}},WP=H0(W8()),VP=H0(OP());function sg(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}function bx(e){let t=0;for(let n=0;n<e.length;++n){if(e[n]<48||e[n]>57)throw new Error("illegal char");t=t*10+e[n]-48}return t}function Pw(e){let t=sg(e);if(!t.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return t}function qP(e){if(typeof Buffer<"u")return Buffer.from(sg(e),"base64").toString();let t=atob(sg(e)),n=new Uint8Array(t.length);for(let r=0;r<n.length;++r)n[r]=t.charCodeAt(r);return new TextDecoder().decode(n)}var Bw={inline:bx,size:bx,name:qP,width:Pw,height:Pw,preserveAspectRatio:bx},Fw=[70,105,108,101],Ow=[77,117,108,116,105,112,97,114,116,70,105,108,101],yx=[70,105,108,101,80,97,114,116],vx=[70,105,108,101,69,110,100],wx=[82,101,112,111,114,116,67,101,108,108,83,105,122,101],Sx=1024,KP=class{constructor(){this.state=0,this._buffer=new Uint32Array(Sx),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}end(){if(this.state===0){if(this._position===vx.length){for(let t=0;t<vx.length;++t)if(this._buffer[t]!==vx[t])return this._a();return this.fields.type=4,this.state=4,0}if(this._position===wx.length){for(let t=0;t<wx.length;++t)if(this._buffer[t]!==wx[t])return this._a();return this.fields.type=5,this.state=4,0}return this._a()}return this.state===4?0:this.state===3&&this.fields.type===2?this._storeValue(this._position)?(this.state=4,0):this._a():this._a()}parse(t,n,r){let s=this.state,i=this._position,a=this._buffer;if(s===1||s===4||s===0&&i>14)return-1;for(let c=n;c<r;++c){let u=t[c];switch(u){case 59:if(!this._storeValue(i))return this._a();s=2,i=0;break;case 61:if(s===0){if(a[0]===70){let f=0;for(;f<Fw.length;++f)if(a[f]!==Fw[f])return this._a();if(this.fields.type=1,i===yx.length){for(;f<yx.length;++f)if(a[f]!==yx[f])return this._a();return this.fields.type=3,this.state=4,c+1}}else if(a[0]===77){for(let f=0;f<Ow.length;++f)if(a[f]!==Ow[f])return this._a();this.fields.type=2}else return this._a();s=2,i=0}else if(s===2){if(!this._storeKey(i))return this._a();s=3,i=0}else if(s===3){if(i>=Sx)return this._a();a[i++]=u}break;case 58:return s===3&&!this._storeValue(i)?this._a():(this.state=4,c+1);default:if(i>=Sx)return this._a();a[i++]=u}}return this.state=s,this._position=i,-2}_a(){return this.fields.type=0,this.state=1,-1}_storeKey(t){let n=sg(this._buffer.subarray(0,t));return n?(this._key=n,this.fields[n]=null,!0):!1}_storeValue(t){if(this._key){try{let n=this._buffer.slice(0,t);this.fields[this._key]=Bw[this._key]?Bw[this._key](n):n}catch{return!1}return!0}return!1}},ig={mime:"unsupported",width:0,height:0};function YP(e){if(e.length<24)return ig;let t=new Uint32Array(e.buffer,e.byteOffset,6);if(t[0]===1196314761&&t[1]===169478669&&t[3]===1380206665)return{mime:"image/png",width:e[16]<<24|e[17]<<16|e[18]<<8|e[19],height:e[20]<<24|e[21]<<16|e[22]<<8|e[23]};if(e[0]===255&&e[1]===216&&e[2]===255){let[n,r]=XP(e);return{mime:"image/jpeg",width:n,height:r}}return t[0]===944130375&&(e[4]===55||e[4]===57)&&e[5]===97?{mime:"image/gif",width:e[7]<<8|e[6],height:e[9]<<8|e[8]}:t[0]===1718185841?{mime:"image/qoi",width:e[4]<<24|e[5]<<16|e[6]<<8|e[7],height:e[8]<<24|e[9]<<16|e[10]<<8|e[11]}:ig}function XP(e){let t=e.length,n=4,r=e[n]<<8|e[n+1];for(;;){if(n+=r,n>=t)return[0,0];if(e[n]!==255)return[0,0];if(e[n+1]===192||e[n+1]===194)return n+8<t?[e[n+7]<<8|e[n+8],e[n+5]<<8|e[n+6]]:[0,0];n+=2,r=e[n]<<8|e[n+1]}}var Ax={type:0,name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},ZP=class{constructor(e,t,n,r){this._opts=e,this._renderer=t,this._storage=n,this._coreTerminal=r,this._aborted=!1,this._hp=new KP,this._header=Ax,this._metrics=ig,this._isMultipart=!1,this._abortMulti=!1;let s=Math.ceil(this._opts.iipSizeLimit*4/3),i=Math.min(1048576,s);this._dec=new WP.default(4194304,s,i),this._qoiDec=new VP.default(4194304)}reset(){this._hp.reset(),this._dec.release(),this._qoiDec.release()}start(){this._aborted=!1,this._metrics=ig,this._hp.reset()}put(e,t,n){if(!this._aborted)if(this._hp.state===4)this._dec.put(e.subarray(t,n))!==0&&(this._dec.release(),this._aborted=!0);else{let r=this._hp.parse(e,t,n);if(r===-1){this._aborted=!0;return}if(r>0){if(this._hp.fields.type===1){if(this._isMultipart&&(this._isMultipart=!1,this._abortMulti=!1,this._dec.release()),this._header=Object.assign({},Ax,this._hp.fields),!this._header.inline){this._aborted=!0;return}this._dec.init()}else if(this._abortMulti){this._aborted=!0;return}this._dec.put(e.subarray(r,n))!==0&&(this._dec.release(),this._aborted=!0,this._isMultipart&&(this._abortMulti=!0))}}}end(e){if(this._aborted||this._hp.state!==4&&this._hp.end())return!0;let t=this._hp.fields.type;if(t===3)return!0;if(t===5){let a=Oc.width,c=Oc.height;this._renderer.dimensions&&(a=this._renderer.dimensions.css.canvas.width/this._coreTerminal.cols,c=this._renderer.dimensions.css.canvas.height/this._coreTerminal.rows);let u=this._coreTerminal._core._coreBrowserService?.dpr??1,f=`\x1B]1337;ReportCellSize=${c.toFixed(3)};${a.toFixed(3)};${u.toFixed(3)}\x1B\\`;return this._coreTerminal.input(f,!1),!0}if(t===2)return this._header=Object.assign({},Ax,this._hp.fields),this._isMultipart=!0,this._abortMulti=!1,this._dec.release(),this._dec.init(),!0;if(t===4&&(!this._isMultipart||(this._isMultipart=!1,this._abortMulti||this._header.type!==2)))return!0;let n=0,r=0,s;if((s=e)&&(s=!this._dec.end())&&(this._metrics=YP(this._dec.data8),(s=this._metrics.mime!=="unsupported")&&(n=this._metrics.width,r=this._metrics.height,(s=n&&r&&n*r<this._opts.pixelLimit)&&([n,r]=this._resize(n,r).map(Math.floor),s=n&&r&&n*r<this._opts.pixelLimit))),!s)return this._dec.release(),!0;let i;if(this._metrics.mime==="image/qoi"){let a=this._qoiDec.decode(this._dec.data8);if(i=new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.byteLength),this._qoiDec.width,this._qoiDec.height),this._qoiDec.release(),n===this._qoiDec.width&&r===this._qoiDec.height){this._dec.release();let c=R0.createCanvas(void 0,this._qoiDec.width,this._qoiDec.height);return c.getContext("2d")?.putImageData(i,0,0),this._storage.addImage(c),!0}}else i=new Blob([this._dec.data8],{type:this._metrics.mime});return this._dec.release(),createImageBitmap(i,{resizeWidth:n,resizeHeight:r}).then(a=>(this._storage.addImage(a),!0))}_resize(e,t){let n=this._renderer.dimensions?.css.cell.width||Oc.width,r=this._renderer.dimensions?.css.cell.height||Oc.height,s=this._renderer.dimensions?.css.canvas.width||n*this._coreTerminal.cols,i=this._renderer.dimensions?.css.canvas.height||r*this._coreTerminal.rows,a=this._dim(this._header.width,s,n),c=this._dim(this._header.height,i,r);if(!a&&!c){let u=s/e,f=(i-r)/t,p=Math.min(u,f);return p<1?[e*p,t*p]:[e,t]}return a?this._header.preserveAspectRatio||!a||!c?[a,t*a/e]:[a,c]:[e*c/t,c]}_dim(e,t,n){return e==="auto"?0:e.endsWith("%")?parseInt(e.slice(0,-1),10)*t/100:e.endsWith("px")?parseInt(e.slice(0,-2),10):parseInt(e,10)*n}},JP=H0(W8());function Qw(e){let t={},n=e.split(",");for(let r of n){let s=r.indexOf("=");if(s===-1)continue;let i=r.substring(0,s),a=r.substring(s+1);if(i==="a"){t.action=a;continue}if(i==="o"){t.compression=a;continue}if(i==="t"){t.transmission=a;continue}if(i==="d"){t.deleteSelector=a;continue}let c=parseInt(a,10);switch(i){case"f":t.format=c;break;case"i":t.id=c;break;case"I":t.imageNumber=c;break;case"s":t.width=c;break;case"v":t.height=c;break;case"x":t.x=c;break;case"y":t.y=c;break;case"w":t.sourceWidth=c;break;case"h":t.sourceHeight=c;break;case"X":t.xOffset=c;break;case"Y":t.yOffset=c;break;case"c":t.columns=c;break;case"r":t.rows=c;break;case"m":t.more=c;break;case"q":t.quiet=c;break;case"C":t.cursorMovement=c;break;case"z":t.zIndex=c;break;case"p":t.placementId=c;break}}return t}var $w=0,eB=class{constructor(e,t,n,r){this._opts=e,this._renderer=t,this._kittyStorage=n,this._coreTerminal=r,this._aborted=!1,this._decodeError=!1,this._activeDecoder=null,this._inControlData=!0,this._controlData=new Uint32Array(512),this._controlLength=0,this._encodedSizeLimit=0,this._totalEncodedSize=0,this._parsedCommand=null,this._pendingTransmissions=new Map,this._maxEncodedBytes=Math.ceil(this._opts.kittySizeLimit*4/3),this._initialEncodedBytes=Math.min(4194304,this._maxEncodedBytes)}reset(){this._cleanupAllPending(),this._activeDecoder&&(this._activeDecoder.release(),this._activeDecoder=null),this._kittyStorage.reset()}dispose(){this.reset()}_removePendingEntry(e){this._pendingTransmissions.delete(e),this._lastPendingKey===e&&(this._lastPendingKey=void 0)}_cleanupAllPending(){for(let e of this._pendingTransmissions.values())e.decoder.release();this._pendingTransmissions.clear(),this._lastPendingKey=void 0}start(){this._aborted=!1,this._decodeError=!1,this._inControlData=!0,this._controlLength=0,this._parsedCommand=null,this._encodedSizeLimit=this._maxEncodedBytes,this._totalEncodedSize=0,this._activeDecoder=null}put(e,t,n){if(!this._aborted)if(!this._inControlData)this._streamPayload(e,t,n);else{let r=n;for(let i=t;i<n;i++)if(e[i]===59){this._inControlData=!1,r=i;break}let s=r-t;if(this._controlLength+s>512){this._aborted=!0;return}if(this._controlData.set(e.subarray(t,r),this._controlLength),this._controlLength+=s,!this._inControlData){if(this._parsedCommand=Qw(this._parseControlDataString()),this._parsedCommand.id!==void 0&&this._parsedCommand.imageNumber!==void 0){this._sendResponse(this._parsedCommand.id,"EINVAL:cannot specify both i and I keys",this._parsedCommand.quiet??0),this._aborted=!0;return}if(this._parsedCommand.action==="d")return;let i=r+1;i<n&&this._streamPayload(e,i,n)}}}_streamPayload(e,t,n){if(this._aborted)return;let r=this._parsedCommand?.id??this._lastPendingKey??0,s=this._pendingTransmissions.get(r),i=s?.totalEncodedSize??0;if(this._totalEncodedSize+=n-t,i+this._totalEncodedSize>this._encodedSizeLimit){let a=this._activeDecoder??s?.decoder;a&&a.release(),this._activeDecoder=null,s&&this._removePendingEntry(r),this._aborted=!0;return}this._decodeError||(s?.decoder&&!this._activeDecoder&&(this._activeDecoder=s.decoder),this._activeDecoder||(this._activeDecoder=new JP.default(4194304,this._maxEncodedBytes,this._initialEncodedBytes),this._activeDecoder.init()),this._activeDecoder.put(e.subarray(t,n))!==$w&&(this._activeDecoder.release(),this._activeDecoder=null,this._decodeError=!0,s&&this._removePendingEntry(r)))}end(e){if(this._aborted||!e)return this._activeDecoder&&(this._activeDecoder.release(),this._activeDecoder=null),!0;if(this._inControlData)return this._handleNoPayloadCommand();let t=this._parsedCommand;if(t.action==="d")return this._handleDelete(t);let n=t.id??this._lastPendingKey??0,r=t.more===1,s=this._pendingTransmissions.get(n);if(r)return this._activeDecoder&&(s?(s.totalEncodedSize+=this._totalEncodedSize,s.decodeError=s.decodeError||this._decodeError):this._pendingTransmissions.set(n,{cmd:{...t},decoder:this._activeDecoder,totalEncodedSize:this._totalEncodedSize,decodeError:this._decodeError}),this._lastPendingKey=n,this._activeDecoder=null),!0;s&&(this._lastPendingKey=void 0);let i=this._decodeError,a=t,c=this._activeDecoder;s&&(a=s.cmd,c=s.decoder,i=i||s.decodeError,this._pendingTransmissions.delete(n));let u=new Uint8Array(0);c&&(c.end()!==$w&&(i=!0),u=c.data8),this._activeDecoder=null;let f=this._handleCommandWithBytesAndCmd(a,u,i);return c&&c.release(),f}_parseControlDataString(){let e="";for(let t=0;t<this._controlLength;t++)e+=String.fromCodePoint(this._controlData[t]);return e}_handleNoPayloadCommand(){let e=Qw(this._parseControlDataString());if(e.id!==void 0&&e.imageNumber!==void 0)return this._sendResponse(e.id,"EINVAL:cannot specify both i and I keys",e.quiet??0),!0;switch(e.action??"t"){case"d":return this._handleDelete(e);case"q":return this._sendResponse(e.id??0,"OK",e.quiet??0),!0;case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handleCommandWithBytesAndCmd(e,t,n){switch(e.action??"t"){case"t":{let r=this._handleTransmit(e,t,n);return(e.transmission??"d")==="d"&&e.id!==void 0&&(n?this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0):t.length>0&&this._sendResponse(e.id,"OK",e.quiet??0)),r}case"T":return this._handleTransmitDisplay(e,t,n);case"q":return this._handleQuery(e,t,n);case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handlePlacement(e){if(e.id===void 0)return!0;let t=e.id,n=this._kittyStorage.getImage(t);return n?this._displayImage(n,e).then(r=>(this._sendResponse(t,r?"OK":"EINVAL:image rendering failed",e.quiet??0,e.placementId),!0)):(this._sendResponse(t,"ENOENT:image not found",e.quiet??0,e.placementId),!0)}_handleTransmit(e,t,n){return(e.transmission??"d")!=="d"?(e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported transmission medium",e.quiet??0),!0):(n||t.length===0||this._kittyStorage.storeImage(e.id,{data:new Blob([t]),width:e.width??0,height:e.height??0,format:e.format??32,compression:e.compression??""}),!0)}_handleTransmitDisplay(e,t,n){if(n)return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0),!0;this._handleTransmit(e,t,n);let r=e.id??this._kittyStorage.lastImageId,s=this._kittyStorage.getImage(r);if(s){let i=this._displayImage(s,e);return e.id!==void 0?i.then(a=>(this._sendResponse(r,a?"OK":"EINVAL:image rendering failed",e.quiet??0),!0)):i.then(()=>!0)}return!0}_handleQuery(e,t,n){let r=e.id??0,s=e.quiet??0;if((e.transmission??"d")!=="d")return this._sendResponse(r,"EINVAL:unsupported transmission medium",s),!0;if(n)return this._sendResponse(r,"EINVAL:invalid base64 data",s),!0;if(t.length===0)return this._sendResponse(r,"OK",s),!0;let i=e.format??32;if(i===100)this._sendResponse(r,"OK",s);else{let a=e.width??0,c=e.height??0;if(!a||!c)return this._sendResponse(r,"EINVAL:width and height required for raw pixel data",s),!0;let u=i===32?4:3,f=a*c*u;if(t.length<f)return this._sendResponse(r,"EINVAL:insufficient pixel data",s),!0;this._sendResponse(r,"OK",s)}return!0}_handleDelete(e){switch(e.deleteSelector??"a"){case"a":case"A":this._cleanupAllPending(),this._kittyStorage.deleteAll();break;case"i":case"I":if(e.id!==void 0){let t=this._pendingTransmissions.get(e.id);t&&t.decoder.release(),this._removePendingEntry(e.id),this._kittyStorage.deleteById(e.id)}break}return!0}_sendResponse(e,t,n,r){let s=t==="OK";if(s&&n>=1||!s&&n>=2)return;let i=r?`,p=${r}`:"",a=`\x1B_Gi=${e}${i};${t}\x1B\\`;this._coreTerminal._core.coreService.triggerDataEvent(a)}_displayImage(e,t){return this._decodeAndDisplay(e,t).then(()=>!0).catch(()=>!1)}async _decodeAndDisplay(e,t){let n=await this._createBitmap(e);try{let r=Math.max(0,t.x??0),s=Math.max(0,t.y??0),i=t.sourceWidth||n.width-r,a=t.sourceHeight||n.height-s,c=Math.max(0,n.width-r),u=Math.max(0,n.height-s),f=Math.max(0,Math.min(i,c)),p=Math.max(0,Math.min(a,u));if(f===0||p===0)throw new Error("invalid source rectangle");if(r!==0||s!==0||f!==n.width||p!==n.height){let $=await createImageBitmap(n,r,s,f,p);n.close(),n=$}let g=this._renderer.dimensions?.css.cell.width||Oc.width,y=this._renderer.dimensions?.css.cell.height||Oc.height,v,S;t.columns!==void 0&&t.rows!==void 0?(v=t.columns,S=t.rows):t.columns!==void 0?(v=t.columns,S=Math.max(1,Math.ceil(n.height/n.width*(v*g)/y))):t.rows!==void 0?(S=t.rows,v=Math.max(1,Math.ceil(n.width/n.height*(S*y)/g))):(v=Math.ceil(n.width/g),S=Math.ceil(n.height/y));let A=n.width,C=n.height;if((t.columns!==void 0||t.rows!==void 0)&&(A=Math.round(v*g),C=Math.round(S*y)),A*C>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");let L=this._coreTerminal._core.buffer,E=L.x,M=L.y,P=L.ybase,F=t.zIndex!==void 0&&t.zIndex<0?"bottom":"top";if(A!==n.width||C!==n.height){let $=await createImageBitmap(n,{resizeWidth:A,resizeHeight:C});n.close(),n=$}let j=Math.min(Math.max(0,t.xOffset??0),g-1),T=Math.min(Math.max(0,t.yOffset??0),y-1);if(j!==0||T!==0){let $=t.columns!==void 0?Math.round(v*g):n.width+j,Z=t.rows!==void 0?Math.round(S*y):n.height+T,V=R0.createCanvas(window.document,$,Z),fe=V.getContext("2d");if(!fe)throw new Error("Failed to create offset canvas context");fe.drawImage(n,j,T);let X=await createImageBitmap(V);if(V.width=V.height=0,n.close(),n=X,A=n.width,C=n.height,A*C>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");t.columns===void 0&&(v=Math.ceil(n.width/g)),t.rows===void 0&&(S=Math.ceil(n.height/y))}let Q=t.zIndex??0;if(this._kittyStorage.addImage(e.id,n,!0,F,Q),n=void 0,t.cursorMovement===1){let $=L.ybase-P;L.x=E,L.y=Math.max(M-$,0)}else L.x=Math.min(E+v,this._coreTerminal.cols)}catch(r){throw n?.close(),r}}async _createBitmap(e){let t=new Uint8Array(await e.data.arrayBuffer());if(e.compression==="z"&&(t=await this._decompressZlib(t)),e.format===100){let A=new Blob([t],{type:"image/png"});if(!window.createImageBitmap){let C=URL.createObjectURL(A),L=new Image;return new Promise((E,M)=>{L.addEventListener("load",()=>{URL.revokeObjectURL(C);let P=R0.createCanvas(window.document,L.width,L.height);P.getContext("2d")?.drawImage(L,0,0),createImageBitmap(P).then(E).catch(M)}),L.addEventListener("error",()=>{URL.revokeObjectURL(C),M(new Error("Failed to load image"))}),L.src=C})}return createImageBitmap(A)}let n=e.width,r=e.height;if(!n||!r)throw new Error("Width and height required for raw pixel data");let s=e.format===32?4:3,i=n*r*s;if(t.length<i)throw new Error("Insufficient pixel data");let a=n*r;if(e.format===32)return createImageBitmap(new ImageData(new Uint8ClampedArray(t.buffer,t.byteOffset,a*4),n,r));let c=new Uint8ClampedArray(a*4),u=new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),f=new Uint32Array(c.buffer),p=a&-4,g=0,y=0;for(let A=0;A<p;A+=4){let C=u[g++],L=u[g++],E=u[g++];f[y++]=4278190080|C,f[y++]=4278190080|C>>>24|L<<8,f[y++]=4278190080|L>>>16|E<<16,f[y++]=4278190080|E>>>8}let v=p*3,S=p*4;for(let A=p;A<a;A++)c[S]=t[v],c[S+1]=t[v+1],c[S+2]=t[v+2],c[S+3]=255,v+=3,S+=4;return createImageBitmap(new ImageData(c,n,r))}async _decompressZlib(e){try{return await this._decompress(e,"deflate")}catch{return await this._decompress(e,"deflate-raw")}}async _decompress(e,t){let n=new DecompressionStream(t),r=n.writable.getWriter();r.write(e),r.close();let s=[],i=n.readable.getReader();for(;;){let{done:f,value:p}=await i.read();if(f)break;s.push(p)}let a=s.reduce((f,p)=>f+p.length,0),c=new Uint8Array(a),u=0;for(let f of s)c.set(f,u),u+=f.length;return c}get images(){return this._kittyStorage.images}get _kittyIdToStorageId(){return this._kittyStorage.kittyIdToStorageId}get pendingTransmissions(){return this._pendingTransmissions}},Y8=class f2{constructor(t){this._storage=t,this._nextImageId=1,this._images=new Map,this._kittyIdToStorageId=new Map,this._storageIdToKittyId=new Map,this._handleStorageImageDeleted=n=>{let r=this._storageIdToKittyId.get(n);r!==void 0&&(this._kittyIdToStorageId.delete(r),this._storageIdToKittyId.delete(n),this._images.delete(r))},this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"},this._previousOnImageDeleted=this._storage.onImageDeleted,this._wrappedOnImageDeleted=n=>{this._previousOnImageDeleted?.(n),this._handleStorageImageDeleted(n)},this._storage.onImageDeleted=this._wrappedOnImageDeleted}reset(){this._nextImageId=1,this._images.clear(),this._kittyIdToStorageId.clear(),this._storageIdToKittyId.clear()}dispose(){this.reset(),this._storage.onImageDeleted===this._wrappedOnImageDeleted&&(this._storage.onImageDeleted=this._previousOnImageDeleted)}storeImage(t,n){let r=t??this._nextImageId++,s=this._kittyIdToStorageId.get(r);return s!==void 0&&(this._storage.deleteImage(s),this._kittyIdToStorageId.delete(r),this._storageIdToKittyId.delete(s)),!this._images.has(r)&&this._images.size>=f2._maxStoredImages&&this._evictUndisplayedImages(),this._images.set(r,{...n,id:r}),r}addImage(t,n,r,s,i){let a=this._kittyIdToStorageId.get(t);a!==void 0&&this._storageIdToKittyId.delete(a),this._addImageOpts.scrolling=r,this._addImageOpts.layer=s,this._addImageOpts.zIndex=i;let c=this._storage.addImage(n,this._addImageOpts);this._kittyIdToStorageId.set(t,c),this._storageIdToKittyId.set(c,t)}getImage(t){return this._images.get(t)}deleteById(t){this._images.delete(t);let n=this._kittyIdToStorageId.get(t);n!==void 0&&(this._storage.deleteImage(n),this._kittyIdToStorageId.delete(t),this._storageIdToKittyId.delete(n))}deleteAll(){this._images.clear();for(let t of this._kittyIdToStorageId.values())this._storage.deleteImage(t);this._kittyIdToStorageId.clear(),this._storageIdToKittyId.clear()}get images(){return this._images}get kittyIdToStorageId(){return this._kittyIdToStorageId}get lastImageId(){return this._nextImageId-1}_evictUndisplayedImages(){for(let[t]of this._images){if(this._images.size<=f2._maxStoredImages/2)break;this._kittyIdToStorageId.has(t)||this._images.delete(t)}}};Y8._maxStoredImages=256;var tB=Y8,wh=H0(Ky()),nB=H0($P()),rB=4194304,h2=wh.PALETTE_ANSI_256;h2.set(wh.PALETTE_VT340_COLOR);var sB=class{constructor(e,t,n){this._opts=e,this._storage=t,this._coreTerminal=n,this._size=0,this._aborted=!1,(0,nB.DecoderAsync)({memoryLimit:this._opts.pixelLimit*4,palette:h2,paletteLimit:this._opts.sixelPaletteLimit}).then(r=>this._dec=r)}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,h2,this._opts.sixelPaletteLimit))}hook(e){if(this._size=0,this._aborted=!1,this._dec){let t=e.params[1]===1?0:iB(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(t,null,this._opts.sixelPaletteLimit)}}put(e,t,n){if(!(this._aborted||!this._dec)){if(this._size+=n-t,this._size>this._opts.sixelSizeLimit){console.warn("SIXEL: too much data, aborting"),this._aborted=!0,this._dec.release();return}try{this._dec.decode(e,t,n)}catch(r){console.warn(`SIXEL: error while decoding image - ${r}`),this._aborted=!0,this._dec.release()}}}unhook(e){if(this._aborted||!e||!this._dec)return!0;let t=this._dec.width,n=this._dec.height;if(!t||!n)return n&&this._storage.advanceCursor(n),!0;let r=R0.createCanvas(void 0,t,n);return r.getContext("2d")?.putImageData(new ImageData(this._dec.data8,t,n),0,0),this._dec.memoryUsage>rB&&this._dec.release(),this._storage.addImage(r),!0}};function iB(e,t){let n=0;if(!t)return n;if(e.isInverse())if(e.isFgDefault())n=Op(t.foreground.rgba);else if(e.isFgRGB()){let r=e.constructor.toColorRGB(e.getFgColor());n=(0,wh.toRGBA8888)(...r)}else n=Op(t.ansi[e.getFgColor()].rgba);else if(e.isBgDefault())n=Op(t.background.rgba);else if(e.isBgRGB()){let r=e.constructor.toColorRGB(e.getBgColor());n=(0,wh.toRGBA8888)(...r)}else n=Op(t.ansi[e.getBgColor()].rgba);return n}function Op(e){return wh.BIG_ENDIAN?e:(e&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255}var oB=class{constructor(e,t,n,r){this._storage=e,this._opts=t,this._renderer=n,this._terminal=r,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"vt340"}}addImage(e){this._addImageOpts.scrolling=this._opts.sixelScrolling,this._storage.addImage(e,this._addImageOpts)}advanceCursor(e){if(this._opts.sixelScrolling){let t=this._renderer.cellSize;(t.width===-1||t.height===-1)&&(t=Oc);let n=Math.ceil(e/t.height);for(let r=1;r<n;++r)this._terminal._core._inputHandler.lineFeed()}}},aB=class{constructor(e){this._storage=e,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"}}addImage(e){this._storage.addImage(e,this._addImageOpts)}},Hw={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:4096,sixelSizeLimit:33554432,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:33554432,kittySupport:!0,kittySizeLimit:33554432},zw=4096,lB=class{constructor(t){this._disposables=[],this._handlers=new Map,this._onImageAdded=new zP,this.onImageAdded=this._onImageAdded.event,this._opts=Object.assign({},Hw,t),this._defaultOpts=Object.assign({},Hw,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear(),this._onImageAdded.dispose()}_disposeLater(...t){for(let n of t)this._disposables.push(n)}activate(t){if(this._terminal=t,this._renderer=new R0(t),this._storage=new GP(t,this._renderer,this._opts),this._storage.onImageAdded=()=>this._onImageAdded.fire(),this._opts.enableSizeReports){let n=t.options.windowOptions??{};n.getWinSizePixels=!0,n.getCellSizePixels=!0,n.getWinSizeChars=!0,t.options.windowOptions=n}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},n=>this._decset(n)),t.parser.registerCsiHandler({prefix:"?",final:"l"},n=>this._decrst(n)),t.parser.registerCsiHandler({final:"c"},n=>this._da1(n)),t.parser.registerCsiHandler({prefix:"?",final:"S"},n=>this._xtermGraphicsAttributes(n)),t.onRender(n=>this._storage?.render(n)),t.parser.registerCsiHandler({intermediates:"!",final:"p"},()=>this.reset()),t.parser.registerEscHandler({final:"c"},()=>this.reset()),t._core._inputHandler.onRequestReset(()=>this.reset()),t.buffer.onBufferChange(()=>this._storage?.wipeAlternate()),t.onResize(n=>this._storage?.viewportResize(n))),this._opts.sixelSupport){let n=new oB(this._storage,this._opts,this._renderer,t),r=new sB(this._opts,n,t);this._handlers.set("sixel",r),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},r))}if(this._opts.iipSupport){let n=new aB(this._storage),r=new ZP(this._opts,this._renderer,n,t);this._handlers.set("iip",r),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,r))}if(this._opts.kittySupport){let n=new tB(this._storage),r=new eB(this._opts,this._renderer,n,t);this._handlers.set("kitty",r),this._disposeLater(n,r,t._core._inputHandler._parser.registerApcHandler({final:"G"},r))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,n){return this._storage?.getImageAtBufferCell(t,n)}extractTileAtBufferCell(t,n){return this._storage?.extractTileAtBufferCell(t,n)}_report(t){this._terminal?._core.input(t,!1)}_decset(t){for(let n=0;n<t.length;++n)t[n]===80&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let n=0;n<t.length;++n)t[n]===80&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return t[0]?!0:this._opts.sixelSupport?(this._report("\x1B[?62;4;9;22c"),!0):!1}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(t[0]===1)switch(t[1]){case 1:return this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let n of this._handlers.values())n.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=zw?(this._opts.sixelPaletteLimit=t[2],this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`\x1B[?${t[0]};2S`),!0;case 4:return this._report(`\x1B[?${t[0]};0;${zw}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}if(t[0]===2)switch(t[1]){case 1:let n=this._renderer?.dimensions?.css.canvas.width,r=this._renderer?.dimensions?.css.canvas.height;if(!n||!r){let i=Oc;n=(this._terminal?.cols||80)*i.width,r=(this._terminal?.rows||24)*i.height}if(n*r<this._opts.pixelLimit)this._report(`\x1B[?${t[0]};0;${n.toFixed(0)};${r.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`\x1B[?${t[0]};0;${i};${i}S`)}return!0;case 4:let s=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`\x1B[?${t[0]};0;${s};${s}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}return this._report(`\x1B[?${t[0]};1S`),!0}};const $d=new Map;function s0(e){return{name:e,get hasSubscribers(){return($d.get(e)?.size??0)>0},publish(t){const n=$d.get(e);if(n)for(const r of n)r(t,e)},subscribe(t){const n=$d.get(e)??new Set;n.add(t),$d.set(e,n)},unsubscribe(t){const n=$d.get(e);if(!n)return!1;const r=n.delete(t);return n.size===0&&$d.delete(e),r}}}function cB(e){const t={start:`${e}:start`,end:`${e}:end`,asyncStart:`${e}:asyncStart`,asyncEnd:`${e}:asyncEnd`,error:`${e}:error`},n={start:s0(t.start),end:s0(t.end),asyncStart:s0(t.asyncStart),asyncEnd:s0(t.asyncEnd),error:s0(t.error),traceSync(r,s,i,...a){n.start.publish(s);try{const c=r.apply(i,a);return n.end.publish(s),c}catch(c){throw n.error.publish(c),c}},async tracePromise(r,s,i,...a){n.asyncStart.publish(s);try{const c=await r.apply(i,a);return n.asyncEnd.publish(s),c}catch(c){throw n.error.publish(c),c}},traceCallback(r,s,i,a,...c){n.start.publish(i);try{const u=r.apply(a,c);return n.end.publish(i),u}catch(u){throw n.error.publish(u),u}}};return n}var uB=Object.create,Yy=Object.defineProperty,dB=Object.getOwnPropertyDescriptor,fB=Object.getOwnPropertyNames,hB=Object.getPrototypeOf,pB=Object.prototype.hasOwnProperty,X8=e=>{throw TypeError(e)},mB=(e,t,n)=>t in e?Yy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gB=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},xB=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fB(t))!pB.call(e,s)&&s!==n&&Yy(e,s,{get:()=>t[s],enumerable:!(r=dB(t,s))||r.enumerable});return e},bB=(e,t,n)=>(n=e!=null?uB(hB(e)):{},xB(!e||!e.__esModule?Yy(n,"default",{value:e,enumerable:!0}):n,e)),Ni=(e,t,n)=>mB(e,typeof t!="symbol"?t+"":t,n),Xy=(e,t,n)=>t.has(e)||X8("Cannot "+n),ue=(e,t,n)=>(Xy(e,t,"read from private field"),n?n.call(e):t.get(e)),Wr=(e,t,n)=>t.has(e)?X8("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qn=(e,t,n,r)=>(Xy(e,t,"write to private field"),t.set(e,n),n),en=(e,t,n)=>(Xy(e,t,"access private method"),n),Tx=(e,t,n,r)=>({set _(s){qn(e,t,s)},get _(){return ue(e,t,r)}}),yB=gB((e,t)=>{var n=(()=>{var r=Object.defineProperty,s=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c=(l,d)=>{for(var h in d)r(l,h,{get:d[h],enumerable:!0})},u=(l,d,h,m)=>{if(d&&typeof d=="object"||typeof d=="function")for(let b of i(d))!a.call(l,b)&&b!==h&&r(l,b,{get:()=>d[b],enumerable:!(m=s(d,b))||m.enumerable});return l},f=l=>u(r({},"__esModule",{value:!0}),l),p={};c(p,{BoundingBox:()=>ve,Font:()=>d5,Glyph:()=>Sr,Path:()=>ht,_parse:()=>Ne,load:()=>N_,loadSync:()=>M_,parse:()=>R_});var g=0,y=-3;function v(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function S(l,d){this.source=l,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=d,this.destLen=0,this.ltree=new v,this.dtree=new v}var A=new v,C=new v,L=new Uint8Array(30),E=new Uint16Array(30),M=new Uint8Array(30),P=new Uint16Array(30),F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),j=new v,T=new Uint8Array(320);function Q(l,d,h,m){var b,w;for(b=0;b<h;++b)l[b]=0;for(b=0;b<30-h;++b)l[b+h]=b/h|0;for(w=m,b=0;b<30;++b)d[b]=w,w+=1<<l[b]}function $(l,d){var h;for(h=0;h<7;++h)l.table[h]=0;for(l.table[7]=24,l.table[8]=152,l.table[9]=112,h=0;h<24;++h)l.trans[h]=256+h;for(h=0;h<144;++h)l.trans[24+h]=h;for(h=0;h<8;++h)l.trans[168+h]=280+h;for(h=0;h<112;++h)l.trans[176+h]=144+h;for(h=0;h<5;++h)d.table[h]=0;for(d.table[5]=32,h=0;h<32;++h)d.trans[h]=h}var Z=new Uint16Array(16);function V(l,d,h,m){var b,w;for(b=0;b<16;++b)l.table[b]=0;for(b=0;b<m;++b)l.table[d[h+b]]++;for(l.table[0]=0,w=0,b=0;b<16;++b)Z[b]=w,w+=l.table[b];for(b=0;b<m;++b)d[h+b]&&(l.trans[Z[d[h+b]]++]=b)}function fe(l){l.bitcount--||(l.tag=l.source[l.sourceIndex++],l.bitcount=7);var d=l.tag&1;return l.tag>>>=1,d}function X(l,d,h){if(!d)return h;for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var m=l.tag&65535>>>16-d;return l.tag>>>=d,l.bitcount-=d,m+h}function ge(l,d){for(;l.bitcount<24;)l.tag|=l.source[l.sourceIndex++]<<l.bitcount,l.bitcount+=8;var h=0,m=0,b=0,w=l.tag;do m=2*m+(w&1),w>>>=1,++b,h+=d.table[b],m-=d.table[b];while(m>=0);return l.tag=w,l.bitcount-=b,d.trans[h+m]}function be(l,d,h){var m,b,w,_,I,R;for(m=X(l,5,257),b=X(l,5,1),w=X(l,4,4),_=0;_<19;++_)T[_]=0;for(_=0;_<w;++_){var z=X(l,3,0);T[F[_]]=z}for(V(j,T,0,19),I=0;I<m+b;){var O=ge(l,j);switch(O){case 16:var se=T[I-1];for(R=X(l,2,3);R;--R)T[I++]=se;break;case 17:for(R=X(l,3,3);R;--R)T[I++]=0;break;case 18:for(R=X(l,7,11);R;--R)T[I++]=0;break;default:T[I++]=O;break}}V(d,T,0,m),V(h,T,m,b)}function Te(l,d,h){for(;;){var m=ge(l,d);if(m===256)return g;if(m<256)l.dest[l.destLen++]=m;else{var b,w,_,I;for(m-=257,b=X(l,L[m],E[m]),w=ge(l,h),_=l.destLen-X(l,M[w],P[w]),I=_;I<_+b;++I)l.dest[l.destLen++]=l.dest[I]}}}function ie(l){for(var d,h,m;l.bitcount>8;)l.sourceIndex--,l.bitcount-=8;if(d=l.source[l.sourceIndex+1],d=256*d+l.source[l.sourceIndex],h=l.source[l.sourceIndex+3],h=256*h+l.source[l.sourceIndex+2],d!==(~h&65535))return y;for(l.sourceIndex+=4,m=d;m;--m)l.dest[l.destLen++]=l.source[l.sourceIndex++];return l.bitcount=0,g}function U(l,d){var h=new S(l,d),m,b,w;do{switch(m=fe(h),b=X(h,2,0),b){case 0:w=ie(h);break;case 1:w=Te(h,A,C);break;case 2:be(h,h.ltree,h.dtree),w=Te(h,h.ltree,h.dtree);break;default:w=y}if(w!==g)throw new Error("Data error")}while(!m);return h.destLen<h.dest.length?typeof h.dest.slice=="function"?h.dest.slice(0,h.destLen):h.dest.subarray(0,h.destLen):h.dest}$(A,C),Q(L,E,4,3),Q(M,P,2,1),L[28]=0,E[28]=258;function G(l,d,h,m,b){return Math.pow(1-b,3)*l+3*Math.pow(1-b,2)*b*d+3*(1-b)*Math.pow(b,2)*h+Math.pow(b,3)*m}function ae(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}ae.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},ae.prototype.addPoint=function(l,d){typeof l=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=l,this.x2=l),l<this.x1&&(this.x1=l),l>this.x2&&(this.x2=l)),typeof d=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=d,this.y2=d),d<this.y1&&(this.y1=d),d>this.y2&&(this.y2=d))},ae.prototype.addX=function(l){this.addPoint(l,null)},ae.prototype.addY=function(l){this.addPoint(null,l)},ae.prototype.addBezier=function(l,d,h,m,b,w,_,I){let R=[l,d],z=[h,m],O=[b,w],se=[_,I];this.addPoint(l,d),this.addPoint(_,I);for(let ne=0;ne<=1;ne++){let _e=6*R[ne]-12*z[ne]+6*O[ne],xe=-3*R[ne]+9*z[ne]-9*O[ne]+3*se[ne],Be=3*z[ne]-3*R[ne];if(xe===0){if(_e===0)continue;let Jn=-Be/_e;0<Jn&&Jn<1&&(ne===0&&this.addX(G(R[ne],z[ne],O[ne],se[ne],Jn)),ne===1&&this.addY(G(R[ne],z[ne],O[ne],se[ne],Jn)));continue}let dt=Math.pow(_e,2)-4*Be*xe;if(dt<0)continue;let Dn=(-_e+Math.sqrt(dt))/(2*xe);0<Dn&&Dn<1&&(ne===0&&this.addX(G(R[ne],z[ne],O[ne],se[ne],Dn)),ne===1&&this.addY(G(R[ne],z[ne],O[ne],se[ne],Dn)));let An=(-_e-Math.sqrt(dt))/(2*xe);0<An&&An<1&&(ne===0&&this.addX(G(R[ne],z[ne],O[ne],se[ne],An)),ne===1&&this.addY(G(R[ne],z[ne],O[ne],se[ne],An)))}},ae.prototype.addQuad=function(l,d,h,m,b,w){let _=l+.6666666666666666*(h-l),I=d+2/3*(m-d),R=_+1/3*(b-l),z=I+1/3*(w-d);this.addBezier(l,d,_,I,R,z,b,w)};var ve=ae;function pe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var we={};function ze(l,d){let h=Math.floor(l),m=l-h;if(we[d]||(we[d]={}),we[d][m]!==void 0){let w=we[d][m];return h+w}let b=+(Math.round(m+"e+"+d)+"e-"+d);return we[d][m]=b,h+b}function Ce(l){let d=[[]],h=0,m=0;for(let b=0;b<l.length;b+=1){let w=d[d.length-1],_=l[b],I=w[0],R=w[1],z=w[w.length-1],O=l[b+1];w.push(_),_.type==="M"?(h=_.x,m=_.y):_.type==="L"&&(!O||O.type==="Z")?Math.abs(_.x-h)>1||Math.abs(_.y-m)>1||w.pop():_.type==="L"&&z&&z.x===_.x&&z.y===_.y?w.pop():_.type==="Z"&&(I&&R&&z&&I.type==="M"&&R.type==="L"&&z.type==="L"&&z.x===I.x&&z.y===I.y&&(w.shift(),w[0].type="M"),b+1<l.length&&d.push([]))}return l=[].concat.apply([],d),l}function $e(l){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},l)}function ee(l){return parseInt(l)===l&&(l={decimalPlaces:l,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},l)}pe.prototype.fromSVG=function(l,d={}){typeof SVGPathElement<"u"&&l instanceof SVGPathElement&&(l=l.getAttribute("d")),d=$e(d),this.commands=[];let h="0123456789",m="MmLlQqCcZzHhVv",b="SsTtAa",w="-+",_={},I=[""],R=!1;function z(xe){return xe.filter(Be=>Be.length).map(Be=>{let dt=parseFloat(Be);return(d.decimalPlaces||d.decimalPlaces===0)&&(dt=ze(dt,d.decimalPlaces)),dt})}function O(xe){if(!this.commands.length)return xe;let Be=this.commands[this.commands.length-1];for(let dt=0;dt<xe.length;dt++)xe[dt]+=Be[dt&1?"y":"x"];return xe}function se(){if(_.type===void 0)return;let xe=_.type.toUpperCase(),Be=xe!=="Z"&&_.type.toUpperCase()!==_.type,dt=z(I);if(I=[""],!dt.length&&xe!=="Z")return;Be&&xe!=="H"&&xe!=="V"&&(dt=O.apply(this,[dt]));let Dn=this.commands.length&&this.commands[this.commands.length-1].x||0,An=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(xe){case"M":this.moveTo(...dt);break;case"L":this.lineTo(...dt);break;case"V":for(let Jn=0;Jn<dt.length;Jn++){let Lr=0;Be&&(Lr=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(Dn,dt[Jn]+Lr)}break;case"H":for(let Jn=0;Jn<dt.length;Jn++){let Lr=0;Be&&(Lr=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(dt[Jn]+Lr,An)}break;case"C":this.bezierCurveTo(...dt);break;case"Q":this.quadraticCurveTo(...dt);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let Jn in this.commands[this.commands.length-1])this.commands[this.commands.length-1][Jn]===void 0&&(this.commands[this.commands.length-1][Jn]=0)}for(let xe=0;xe<l.length;xe++){let Be=l.charAt(xe),dt=I[I.length-1];if(h.indexOf(Be)>-1)I[I.length-1]+=Be;else if(w.indexOf(Be)>-1)if(!_.type&&!this.commands.length&&(_.type="L"),Be==="-")!_.type||dt.indexOf("-")>0?R=!0:dt.length?I.push("-"):I[I.length-1]=Be;else if(!_.type||dt.length>0)R=!0;else continue;else if(m.indexOf(Be)>-1)_.type?(se.apply(this),_={type:Be}):_.type=Be;else{if(b.indexOf(Be)>-1)throw new Error("Unsupported path command: "+Be+". Currently supported commands are "+m.split("").join(", ")+".");` ,
66
66
  \r\f\v`.indexOf(Be)>-1?I.push(""):Be==="."?!_.type||dt.indexOf(Be)>-1?R=!0:I[I.length-1]+=Be:R=!0}if(R)throw new Error("Unexpected character: "+Be+" at offset "+xe)}se.apply(this),d.optimize&&(this.commands=Ce(this.commands));let ne=d.flipY,_e=d.flipYBase;if(ne===!0&&d.flipYBase===void 0){let xe=this.getBoundingBox();_e=xe.y1+xe.y2}for(let xe in this.commands){let Be=this.commands[xe];for(let dt in Be)["x","x1","x2"].includes(dt)?this.commands[xe][dt]=d.x+Be[dt]*d.scale:["y","y1","y2"].includes(dt)&&(this.commands[xe][dt]=d.y+(ne?_e-Be[dt]:Be[dt])*d.scale)}return this},pe.fromSVG=function(l,d){return new pe().fromSVG(l,d)},pe.prototype.moveTo=function(l,d){this.commands.push({type:"M",x:l,y:d})},pe.prototype.lineTo=function(l,d){this.commands.push({type:"L",x:l,y:d})},pe.prototype.curveTo=pe.prototype.bezierCurveTo=function(l,d,h,m,b,w){this.commands.push({type:"C",x1:l,y1:d,x2:h,y2:m,x:b,y:w})},pe.prototype.quadTo=pe.prototype.quadraticCurveTo=function(l,d,h,m){this.commands.push({type:"Q",x1:l,y1:d,x:h,y:m})},pe.prototype.close=pe.prototype.closePath=function(){this.commands.push({type:"Z"})},pe.prototype.extend=function(l){if(l.commands)l=l.commands;else if(l instanceof ve){let d=l;this.moveTo(d.x1,d.y1),this.lineTo(d.x2,d.y1),this.lineTo(d.x2,d.y2),this.lineTo(d.x1,d.y2),this.close();return}Array.prototype.push.apply(this.commands,l)},pe.prototype.getBoundingBox=function(){let l=new ve,d=0,h=0,m=0,b=0;for(let w=0;w<this.commands.length;w++){let _=this.commands[w];switch(_.type){case"M":l.addPoint(_.x,_.y),d=m=_.x,h=b=_.y;break;case"L":l.addPoint(_.x,_.y),m=_.x,b=_.y;break;case"Q":l.addQuad(m,b,_.x1,_.y1,_.x,_.y),m=_.x,b=_.y;break;case"C":l.addBezier(m,b,_.x1,_.y1,_.x2,_.y2,_.x,_.y),m=_.x,b=_.y;break;case"Z":m=d,b=h;break;default:throw new Error("Unexpected path command "+_.type)}}return l.isEmpty()&&l.addPoint(0,0),l},pe.prototype.draw=function(l){let d=this._layers;if(d&&d.length){for(let m=0;m<d.length;m++)this.draw.call(d[m],l);return}let h=this._image;if(h){l.drawImage(h.image,h.x,h.y,h.width,h.height);return}l.beginPath();for(let m=0;m<this.commands.length;m+=1){let b=this.commands[m];b.type==="M"?l.moveTo(b.x,b.y):b.type==="L"?l.lineTo(b.x,b.y):b.type==="C"?l.bezierCurveTo(b.x1,b.y1,b.x2,b.y2,b.x,b.y):b.type==="Q"?l.quadraticCurveTo(b.x1,b.y1,b.x,b.y):b.type==="Z"&&this.stroke&&this.strokeWidth&&l.closePath()}this.fill&&(l.fillStyle=this.fill,l.fill()),this.stroke&&(l.strokeStyle=this.stroke,l.lineWidth=this.strokeWidth,l.stroke())},pe.prototype.toPathData=function(l){l=ee(l);function d(I){let R=ze(I,l.decimalPlaces);return Math.round(I)===R?""+R:R.toFixed(l.decimalPlaces)}function h(){let I="";for(let R=0;R<arguments.length;R+=1){let z=arguments[R];z>=0&&R>0&&(I+=" "),I+=d(z)}return I}let m=this.commands;l.optimize&&(m=JSON.parse(JSON.stringify(this.commands)),m=Ce(m));let b=l.flipY,w=l.flipYBase;if(b===!0&&w===void 0){let I=new pe;I.extend(m);let R=I.getBoundingBox();w=R.y1+R.y2}let _="";for(let I=0;I<m.length;I+=1){let R=m[I];R.type==="M"?_+="M"+h(R.x,b?w-R.y:R.y):R.type==="L"?_+="L"+h(R.x,b?w-R.y:R.y):R.type==="C"?_+="C"+h(R.x1,b?w-R.y1:R.y1,R.x2,b?w-R.y2:R.y2,R.x,b?w-R.y:R.y):R.type==="Q"?_+="Q"+h(R.x1,b?w-R.y1:R.y1,R.x,b?w-R.y:R.y):R.type==="Z"&&(_+="Z")}return _},pe.prototype.toSVG=function(l,d){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),d||(d=this.toPathData(l));let h='<path d="';return h+=d,h+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?h+=' fill="none"':h+=' fill="'+this.fill+'"'),this.stroke&&(h+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),h+="/>",h},pe.prototype.toDOMElement=function(l,d){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),d||(d=this.toPathData(l));let h=document.createElementNS("http://www.w3.org/2000/svg","path");return h.setAttribute("d",d),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?h.setAttribute("fill","none"):h.setAttribute("fill",this.fill)),this.stroke&&(h.setAttribute("stroke",this.stroke),h.setAttribute("stroke-width",this.strokeWidth)),h};var ht=pe;function mt(l){throw new Error(l)}function me(l,d){l||mt(d)}var re={fail:mt,argument:me,assert:me},Ae=32768,he=2147483648,Qe=-32768,Fe=32767+1/65536,Ke={},K={},de={};function qe(l){return function(){return l}}K.BYTE=function(l){return re.argument(l>=0&&l<=255,"Byte value should be between 0 and 255."),[l]},de.BYTE=qe(1),K.CHAR=function(l){return[l.charCodeAt(0)]},de.CHAR=qe(1),K.CHARARRAY=function(l){(l===null||typeof l>"u")&&(l="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let d=[];for(let h=0;h<l.length;h+=1)d[h]=l.charCodeAt(h);return d},de.CHARARRAY=function(l){return typeof l>"u"?0:l.length},K.USHORT=function(l){return[l>>8&255,l&255]},de.USHORT=qe(2),K.SHORT=function(l){return l>=Ae&&(l=-(2*Ae-l)),[l>>8&255,l&255]},de.SHORT=qe(2),K.UINT24=function(l){return[l>>16&255,l>>8&255,l&255]},de.UINT24=qe(3),K.ULONG=function(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]},de.ULONG=qe(4),K.LONG=function(l){return l>=he&&(l=-(2*he-l)),[l>>24&255,l>>16&255,l>>8&255,l&255]},de.LONG=qe(4),K.FLOAT=function(l){if(l>Fe||l<Qe)throw new Error(`Value ${l} is outside the range of representable values in 16.16 format`);let d=Math.round(l*65536)<<0;return K.ULONG(d)},de.FLOAT=de.ULONG,K.FIXED=K.ULONG,de.FIXED=de.ULONG,K.FWORD=K.SHORT,de.FWORD=de.SHORT,K.UFWORD=K.USHORT,de.UFWORD=de.USHORT,K.F2DOT14=function(l){return K.USHORT(l*16384)},de.F2DOT14=de.USHORT,K.LONGDATETIME=function(l){return[0,0,0,0,l>>24&255,l>>16&255,l>>8&255,l&255]},de.LONGDATETIME=qe(8),K.TAG=function(l){return re.argument(l.length===4,"Tag should be exactly 4 ASCII characters."),[l.charCodeAt(0),l.charCodeAt(1),l.charCodeAt(2),l.charCodeAt(3)]},de.TAG=qe(4),K.Card8=K.BYTE,de.Card8=de.BYTE,K.Card16=K.USHORT,de.Card16=de.USHORT,K.OffSize=K.BYTE,de.OffSize=de.BYTE,K.SID=K.USHORT,de.SID=de.USHORT,K.NUMBER=function(l){return l>=-107&&l<=107?[l+139]:l>=108&&l<=1131?(l=l-108,[(l>>8)+247,l&255]):l>=-1131&&l<=-108?(l=-l-108,[(l>>8)+251,l&255]):l>=-32768&&l<=32767?K.NUMBER16(l):K.NUMBER32(l)},de.NUMBER=function(l){return K.NUMBER(l).length},K.NUMBER16=function(l){return[28,l>>8&255,l&255]},de.NUMBER16=qe(3),K.NUMBER32=function(l){return[29,l>>24&255,l>>16&255,l>>8&255,l&255]},de.NUMBER32=qe(5),K.REAL=function(l){let d=l.toString(),h=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(d);if(h){let w=parseFloat("1e"+((h[2]?+h[2]:0)+h[1].length));d=(Math.round(l*w)/w).toString()}let m="";for(let w=0,_=d.length;w<_;w+=1){let I=d[w];I==="e"?m+=d[++w]==="-"?"c":"b":I==="."?m+="a":I==="-"?m+="e":m+=I}m+=m.length&1?"f":"ff";let b=[30];for(let w=0,_=m.length;w<_;w+=2)b.push(parseInt(m.substr(w,2),16));return b},de.REAL=function(l){return K.REAL(l).length},K.NAME=K.CHARARRAY,de.NAME=de.CHARARRAY,K.STRING=K.CHARARRAY,de.STRING=de.CHARARRAY,Ke.UTF8=function(l,d,h){let m=[],b=h;for(let w=0;w<b;w++,d+=1)m[w]=l.getUint8(d);return String.fromCharCode.apply(null,m)},Ke.UTF16=function(l,d,h){let m=[],b=h/2;for(let w=0;w<b;w++,d+=2)m[w]=l.getUint16(d);return String.fromCharCode.apply(null,m)},K.UTF16=function(l){let d=[];for(let h=0;h<l.length;h+=1){let m=l.charCodeAt(h);d[d.length]=m>>8&255,d[d.length]=m&255}return d},de.UTF16=function(l){return l.length*2};var Pe={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Ke.MACSTRING=function(l,d,h,m){let b=Pe[m];if(b===void 0)return;let w="";for(let _=0;_<h;_++){let I=l.getUint8(d+_);I<=127?w+=String.fromCharCode(I):w+=b[I&127]}return w};var We=typeof WeakMap=="function"&&new WeakMap,Oe,pt=function(l){if(!Oe){Oe={};for(let b in Pe)Oe[b]=new String(b)}let d=Oe[l];if(d===void 0)return;if(We){let b=We.get(d);if(b!==void 0)return b}let h=Pe[l];if(h===void 0)return;let m={};for(let b=0;b<h.length;b++)m[h.charCodeAt(b)]=b+128;return We&&We.set(d,m),m};K.MACSTRING=function(l,d){let h=pt(d);if(h===void 0)return;let m=[];for(let b=0;b<l.length;b++){let w=l.charCodeAt(b);if(w>=128&&(w=h[w],w===void 0))return;m[b]=w}return m},de.MACSTRING=function(l,d){let h=K.MACSTRING(l,d);return h!==void 0?h.length:0};function st(l){return l>=-128&&l<=127}function jt(l,d,h){let m=0,b=l.length;for(;d<b&&m<64&&l[d]===0;)++d,++m;return h.push(128|m-1),d}function Lt(l,d,h){let m=0,b=l.length,w=d;for(;w<b&&m<64;){let _=l[w];if(!st(_)||_===0&&w+1<b&&l[w+1]===0)break;++w,++m}h.push(m-1);for(let _=d;_<w;++_)h.push(l[_]+256&255);return w}function Nt(l,d,h){let m=0,b=l.length,w=d;for(;w<b&&m<64;){let _=l[w];if(_===0||st(_)&&w+1<b&&st(l[w+1]))break;++w,++m}h.push(64|m-1);for(let _=d;_<w;++_){let I=l[_];h.push(I+65536>>8&255,I+256&255)}return w}K.VARDELTAS=function(l){let d=0,h=[];for(;d<l.length;){let m=l[d];m===0?d=jt(l,d,h):m>=-128&&m<=127?d=Lt(l,d,h):d=Nt(l,d,h)}return h},K.INDEX=function(l){let d=1,h=[d],m=[];for(let I=0;I<l.length;I+=1){let R=K.OBJECT(l[I]);Array.prototype.push.apply(m,R),d+=R.length,h.push(d)}if(m.length===0)return[0,0];let b=[],w=1+Math.floor(Math.log(d)/Math.log(2))/8|0,_=[void 0,K.BYTE,K.USHORT,K.UINT24,K.ULONG][w];for(let I=0;I<h.length;I+=1){let R=_(h[I]);Array.prototype.push.apply(b,R)}return Array.prototype.concat(K.Card16(l.length),K.OffSize(w),b,m)},de.INDEX=function(l){return K.INDEX(l).length},K.DICT=function(l){let d=[],h=Object.keys(l),m=h.length;for(let b=0;b<m;b+=1){let w=parseInt(h[b],0),_=l[w],I=K.OPERAND(_.value,_.type),R=K.OPERATOR(w);for(let z=0;z<I.length;z++)d.push(I[z]);for(let z=0;z<R.length;z++)d.push(R[z])}return d},de.DICT=function(l){return K.DICT(l).length},K.OPERATOR=function(l){return l<1200?[l]:[12,l-1200]},K.OPERAND=function(l,d){let h=[];if(Array.isArray(d))for(let m=0;m<d.length;m+=1){re.argument(l.length===d.length,"Not enough arguments given for type"+d);let b=K.OPERAND(l[m],d[m]);for(let w=0;w<b.length;w++)h.push(b[w])}else if(d==="SID"){let m=K.NUMBER(l);for(let b=0;b<m.length;b++)h.push(m[b])}else if(d==="offset"){let m=K.NUMBER32(l);for(let b=0;b<m.length;b++)h.push(m[b])}else if(d==="number"){let m=K.NUMBER(l);for(let b=0;b<m.length;b++)h.push(m[b])}else if(d==="real"){let m=K.REAL(l);for(let b=0;b<m.length;b++)h.push(m[b])}else throw new Error("Unknown operand type "+d);return h},K.OP=K.BYTE,de.OP=de.BYTE;var Pt=typeof WeakMap=="function"&&new WeakMap;K.CHARSTRING=function(l){if(Pt){let m=Pt.get(l);if(m!==void 0)return m}let d=[],h=l.length;for(let m=0;m<h;m+=1){let b=l[m],w=K[b.type](b.value);for(let _=0;_<w.length;_++)d.push(w[_])}return Pt&&Pt.set(l,d),d},de.CHARSTRING=function(l){return K.CHARSTRING(l).length},K.OBJECT=function(l){let d=K[l.type];return re.argument(d!==void 0,"No encoding function for type "+l.type),d(l.value)},de.OBJECT=function(l){let d=de[l.type];return re.argument(d!==void 0,"No sizeOf function for type "+l.type),d(l.value)},K.TABLE=function(l){let d=[],h=(l.fields||[]).length,m=[],b=[];for(let w=0;w<h;w+=1){let _=l.fields[w],I=K[_.type];re.argument(I!==void 0,"No encoding function for field type "+_.type+" ("+_.name+")");let R=l[_.name];R===void 0&&(R=_.value);let z=I(R);if(_.type==="TABLE")R.fields!==null&&(b.push(d.length),m.push(z)),d.push(0,0);else for(let O=0;O<z.length;O++)d.push(z[O])}for(let w=0;w<m.length;w+=1){let _=b[w],I=d.length;re.argument(I<65536,"Table "+l.tableName+" too big."),d[_]=I>>8,d[_+1]=I&255;for(let R=0;R<m[w].length;R++)d.push(m[w][R])}return d},de.TABLE=function(l){let d=0,h=(l.fields||[]).length;for(let m=0;m<h;m+=1){let b=l.fields[m],w=de[b.type];re.argument(w!==void 0,"No sizeOf function for field type "+b.type+" ("+b.name+")");let _=l[b.name];_===void 0&&(_=b.value),d+=w(_),b.type==="TABLE"&&(d+=2)}return d},K.RECORD=K.TABLE,de.RECORD=de.TABLE,K.LITERAL=function(l){return l},de.LITERAL=function(l){return l.length};function vn(l,d,h){if(d&&d.length)for(let m=0;m<d.length;m+=1){let b=d[m];this[b.name]=b.value}if(this.tableName=l,this.fields=d,h){let m=Object.keys(h);for(let b=0;b<m.length;b+=1){let w=m[b],_=h[w];this[w]!==void 0&&(this[w]=_)}}}vn.prototype.encode=function(){return K.TABLE(this)},vn.prototype.sizeOf=function(){return de.TABLE(this)};function Yn(l,d,h){h===void 0&&(h=d.length);let m=new Array(d.length+1);m[0]={name:l+"Count",type:"USHORT",value:h};for(let b=0;b<d.length;b++)m[b+1]={name:l+b,type:"USHORT",value:d[b]};return m}function Se(l,d,h){let m=d.length,b=new Array(m+1);b[0]={name:l+"Count",type:"USHORT",value:m};for(let w=0;w<m;w++)b[w+1]={name:l+w,type:"TABLE",value:h(d[w],w)};return b}function lt(l,d,h){let m=d.length,b=[];b[0]={name:l+"Count",type:"USHORT",value:m};for(let w=0;w<m;w++)b=b.concat(h(d[w],w));return b}function ut(l){l.format===1?vn.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Yn("glyph",l.glyphs))):l.format===2?vn.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(lt("rangeRecord",l.ranges,function(d,h){return[{name:"startGlyphID"+h,type:"USHORT",value:d.start},{name:"endGlyphID"+h,type:"USHORT",value:d.end},{name:"startCoverageIndex"+h,type:"USHORT",value:d.index}]}))):re.assert(!1,"Coverage format must be 1 or 2.")}ut.prototype=Object.create(vn.prototype),ut.prototype.constructor=ut;function tn(l){vn.call(this,"scriptListTable",lt("scriptRecord",l,function(d,h){let m=d.script,b=m.defaultLangSys;return re.assert(!!b,"Unable to write GSUB: script "+d.tag+" has no default language system."),[{name:"scriptTag"+h,type:"TAG",value:d.tag},{name:"script"+h,type:"TABLE",value:new vn("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new vn("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:b.reqFeatureIndex}].concat(Yn("featureIndex",b.featureIndexes)))}].concat(lt("langSys",m.langSysRecords,function(w,_){let I=w.langSys;return[{name:"langSysTag"+_,type:"TAG",value:w.tag},{name:"langSys"+_,type:"TABLE",value:new vn("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:I.reqFeatureIndex}].concat(Yn("featureIndex",I.featureIndexes)))}]})))}]}))}tn.prototype=Object.create(vn.prototype),tn.prototype.constructor=tn;function ft(l){vn.call(this,"featureListTable",lt("featureRecord",l,function(d,h){let m=d.feature;return[{name:"featureTag"+h,type:"TAG",value:d.tag},{name:"feature"+h,type:"TABLE",value:new vn("featureTable",[{name:"featureParams",type:"USHORT",value:m.featureParams}].concat(Yn("lookupListIndex",m.lookupListIndexes)))}]}))}ft.prototype=Object.create(vn.prototype),ft.prototype.constructor=ft;function Wt(l,d){vn.call(this,"lookupListTable",Se("lookup",l,function(h){let m=d[h.lookupType];return re.assert(!!m,"Unable to write GSUB lookup type "+h.lookupType+" tables."),new vn("lookupTable",[{name:"lookupType",type:"USHORT",value:h.lookupType},{name:"lookupFlag",type:"USHORT",value:h.lookupFlag}].concat(Se("subtable",h.subtables,m)))}))}Wt.prototype=Object.create(vn.prototype),Wt.prototype.constructor=Wt;function it(l){l.format===1?vn.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:l.startGlyph}].concat(Yn("glyph",l.classes))):l.format===2?vn.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(lt("rangeRecord",l.ranges,function(d,h){return[{name:"startGlyphID"+h,type:"USHORT",value:d.start},{name:"endGlyphID"+h,type:"USHORT",value:d.end},{name:"class"+h,type:"USHORT",value:d.classId}]}))):re.assert(!1,"Class format must be 1 or 2.")}it.prototype=Object.create(vn.prototype),it.prototype.constructor=it;var Ve={Table:vn,Record:vn,Coverage:ut,ClassDef:it,ScriptList:tn,FeatureList:ft,LookupList:Wt,ushortList:Yn,tableList:Se,recordList:lt};function Xn(l,d){return l.getUint8(d)}function Bn(l,d){return l.getUint16(d,!1)}function Ue(l,d){return l.getInt16(d,!1)}function Nn(l,d){return(l.getUint16(d)<<8)+l.getUint8(d+2)}function Ft(l,d){return l.getUint32(d,!1)}function br(l,d){return l.getInt32(d,!1)}function Fn(l,d){let h=l.getInt16(d,!1),m=l.getUint16(d+2,!1);return h+m/65535}function Tn(l,d){let h="";for(let m=d;m<d+4;m+=1)h+=String.fromCharCode(l.getInt8(m));return h}function Qr(l,d,h){let m=0;for(let b=0;b<h;b+=1)m<<=8,m+=l.getUint8(d+b);return m}function kr(l,d,h){let m=[];for(let b=d;b<h;b+=1)m.push(l.getUint8(b));return m}function Ir(l){let d="";for(let h=0;h<l.length;h+=1)d+=String.fromCharCode(l[h]);return d}var wr={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},Le={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function te(l,d){this.data=l,this.offset=d,this.relativeOffset=0}te.prototype.parseByte=function(){let l=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,l},te.prototype.parseChar=function(){let l=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,l},te.prototype.parseCard8=te.prototype.parseByte,te.prototype.parseUShort=function(){let l=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,l},te.prototype.parseCard16=te.prototype.parseUShort,te.prototype.parseSID=te.prototype.parseUShort,te.prototype.parseOffset16=te.prototype.parseUShort,te.prototype.parseShort=function(){let l=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,l},te.prototype.parseF2Dot14=function(){let l=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,l},te.prototype.parseUInt24=function(){let l=Nn(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,l},te.prototype.parseULong=function(){let l=Ft(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,l},te.prototype.parseLong=function(){let l=br(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,l},te.prototype.parseOffset32=te.prototype.parseULong,te.prototype.parseFixed=function(){let l=Fn(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,l},te.prototype.parseString=function(l){let d=this.data,h=this.offset+this.relativeOffset,m="";this.relativeOffset+=l;for(let b=0;b<l;b++)m+=String.fromCharCode(d.getUint8(h+b));return m},te.prototype.parseTag=function(){return this.parseString(4)},te.prototype.parseLongDateTime=function(){let l=Ft(this.data,this.offset+this.relativeOffset+4);return l-=2082844800,this.relativeOffset+=8,l},te.prototype.parseVersion=function(l){let d=Bn(this.data,this.offset+this.relativeOffset),h=Bn(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,l===void 0&&(l=4096),d+h/l/10},te.prototype.skip=function(l,d){d===void 0&&(d=1),this.relativeOffset+=wr[l]*d},te.prototype.parseULongList=function(l){l===void 0&&(l=this.parseULong());let d=new Array(l),h=this.data,m=this.offset+this.relativeOffset;for(let b=0;b<l;b++)d[b]=h.getUint32(m),m+=4;return this.relativeOffset+=l*4,d},te.prototype.parseOffset16List=te.prototype.parseUShortList=function(l){l===void 0&&(l=this.parseUShort());let d=new Array(l),h=this.data,m=this.offset+this.relativeOffset;for(let b=0;b<l;b++)d[b]=h.getUint16(m),m+=2;return this.relativeOffset+=l*2,d},te.prototype.parseShortList=function(l){let d=new Array(l),h=this.data,m=this.offset+this.relativeOffset;for(let b=0;b<l;b++)d[b]=h.getInt16(m),m+=2;return this.relativeOffset+=l*2,d},te.prototype.parseByteList=function(l){let d=new Array(l),h=this.data,m=this.offset+this.relativeOffset;for(let b=0;b<l;b++)d[b]=h.getUint8(m++);return this.relativeOffset+=l,d},te.prototype.parseList=function(l,d){d||(d=l,l=this.parseUShort());let h=new Array(l);for(let m=0;m<l;m++)h[m]=d.call(this);return h},te.prototype.parseList32=function(l,d){d||(d=l,l=this.parseULong());let h=new Array(l);for(let m=0;m<l;m++)h[m]=d.call(this);return h},te.prototype.parseRecordList=function(l,d){d||(d=l,l=this.parseUShort());let h=new Array(l),m=Object.keys(d);for(let b=0;b<l;b++){let w={};for(let _=0;_<m.length;_++){let I=m[_],R=d[I];w[I]=R.call(this)}h[b]=w}return h},te.prototype.parseRecordList32=function(l,d){d||(d=l,l=this.parseULong());let h=new Array(l),m=Object.keys(d);for(let b=0;b<l;b++){let w={};for(let _=0;_<m.length;_++){let I=m[_],R=d[I];w[I]=R.call(this)}h[b]=w}return h},te.prototype.parseTupleRecords=function(l,d){let h=[];for(let m=0;m<l;m++){let b=[];for(let w=0;w<d;w++)b.push(this.parseF2Dot14());h.push(b)}return h},te.prototype.parseStruct=function(l){if(typeof l=="function")return l.call(this);{let d=Object.keys(l),h={};for(let m=0;m<d.length;m++){let b=d[m],w=l[b];h[b]=w.call(this)}return h}},te.prototype.parseValueRecord=function(l){if(l===void 0&&(l=this.parseUShort()),l===0)return;let d={};return l&1&&(d.xPlacement=this.parseShort()),l&2&&(d.yPlacement=this.parseShort()),l&4&&(d.xAdvance=this.parseShort()),l&8&&(d.yAdvance=this.parseShort()),l&16&&(d.xPlaDevice=void 0,this.parseShort()),l&32&&(d.yPlaDevice=void 0,this.parseShort()),l&64&&(d.xAdvDevice=void 0,this.parseShort()),l&128&&(d.yAdvDevice=void 0,this.parseShort()),d},te.prototype.parseValueRecordList=function(){let l=this.parseUShort(),d=this.parseUShort(),h=new Array(d);for(let m=0;m<d;m++)h[m]=this.parseValueRecord(l);return h},te.prototype.parsePointer=function(l){let d=this.parseOffset16();if(d>0)return new te(this.data,this.offset+d).parseStruct(l)},te.prototype.parsePointer32=function(l){let d=this.parseOffset32();if(d>0)return new te(this.data,this.offset+d).parseStruct(l)},te.prototype.parseListOfLists=function(l){let d=this.parseOffset16List(),h=d.length,m=this.relativeOffset,b=new Array(h);for(let w=0;w<h;w++){let _=d[w];if(_===0){b[w]=void 0;continue}if(this.relativeOffset=_,l){let I=this.parseOffset16List(),R=new Array(I.length);for(let z=0;z<I.length;z++)this.relativeOffset=_+I[z],R[z]=l.call(this);b[w]=R}else b[w]=this.parseUShortList()}return this.relativeOffset=m,b},te.prototype.parseCoverage=function(){let l=this.offset+this.relativeOffset,d=this.parseUShort(),h=this.parseUShort();if(d===1)return{format:1,glyphs:this.parseUShortList(h)};if(d===2){let m=new Array(h);for(let b=0;b<h;b++)m[b]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:m}}throw new Error("0x"+l.toString(16)+": Coverage format must be 1 or 2.")},te.prototype.parseClassDef=function(){let l=this.offset+this.relativeOffset,d=this.parseUShort();return d===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:d===2?{format:2,ranges:this.parseRecordList({start:te.uShort,end:te.uShort,classId:te.uShort})}:(console.warn(`0x${l.toString(16)}: This font file uses an invalid ClassDef format of ${d}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:d})},te.list=function(l,d){return function(){return this.parseList(l,d)}},te.list32=function(l,d){return function(){return this.parseList32(l,d)}},te.recordList=function(l,d){return function(){return this.parseRecordList(l,d)}},te.recordList32=function(l,d){return function(){return this.parseRecordList32(l,d)}},te.pointer=function(l){return function(){return this.parsePointer(l)}},te.pointer32=function(l){return function(){return this.parsePointer32(l)}},te.tag=te.prototype.parseTag,te.byte=te.prototype.parseByte,te.uShort=te.offset16=te.prototype.parseUShort,te.uShortList=te.prototype.parseUShortList,te.uInt24=te.prototype.parseUInt24,te.uLong=te.offset32=te.prototype.parseULong,te.uLongList=te.prototype.parseULongList,te.fixed=te.prototype.parseFixed,te.f2Dot14=te.prototype.parseF2Dot14,te.struct=te.prototype.parseStruct,te.coverage=te.prototype.parseCoverage,te.classDef=te.prototype.parseClassDef;var Rt={reserved:te.uShort,reqFeatureIndex:te.uShort,featureIndexes:te.uShortList};te.prototype.parseScriptList=function(){return this.parsePointer(te.recordList({tag:te.tag,script:te.pointer({defaultLangSys:te.pointer(Rt),langSysRecords:te.recordList({tag:te.tag,langSys:te.pointer(Rt)})})}))||[]},te.prototype.parseFeatureList=function(){return this.parsePointer(te.recordList({tag:te.tag,feature:te.pointer({featureParams:te.offset16,lookupListIndexes:te.uShortList})}))||[]},te.prototype.parseLookupList=function(l){return this.parsePointer(te.list(te.pointer(function(){let d=this.parseUShort();re.argument(1<=d&&d<=9,"GPOS/GSUB lookup type "+d+" unknown.");let h=this.parseUShort(),m=h&16;return{lookupType:d,lookupFlag:h,subtables:this.parseList(te.pointer(l[d])),markFilteringSet:m?this.parseUShort():void 0}})))||[]},te.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let l=this.parseUShort(),d=this.parseUShort();return re.argument(l===1&&d<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:te.offset32,featureTableSubstitutionOffset:te.offset32})})||[]},te.prototype.parseVariationStore=function(){let l=this.relativeOffset,d=this.parseUShort(),h={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=l+d+2,h},te.prototype.parseItemVariationStore=function(){let l=this.relativeOffset,d={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},h=this.parseOffset32(),m=this.parseUShort(),b=this.parseULongList(m);this.relativeOffset=l+h,d.variationRegions=this.parseVariationRegionList();for(let w=0;w<m;w++){let _=b[w];this.relativeOffset=l+_,d.itemVariationSubtables.push(this.parseItemVariationSubtable())}return d},te.prototype.parseVariationRegionList=function(){let l=this.parseUShort(),d=this.parseUShort();return this.parseRecordList(d,{regionAxes:te.recordList(l,{startCoord:te.f2Dot14,peakCoord:te.f2Dot14,endCoord:te.f2Dot14})})},te.prototype.parseItemVariationSubtable=function(){let l=this.parseUShort(),d=this.parseUShort(),h=this.parseUShortList(),m=h.length;return{regionIndexes:h,deltaSets:l&&m?this.parseDeltaSets(l,d,m):[]}},te.prototype.parseDeltaSetIndexMap=function(){let l=this.parseByte(),d=this.parseByte(),h=[],m=0;switch(l){case 0:m=this.parseUShort();break;case 1:m=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${l}`)}if(!m)return{format:l,entryFormat:d};let b=(d&Le.INNER_INDEX_BIT_COUNT_MASK)+1,w=((d&Le.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let _=0;_<m;_++){let I;if(w===1)I=this.parseByte();else if(w===2)I=this.parseUShort();else if(w===3)I=this.parseUInt24();else if(w===4)I=this.parseULong();else throw new Error(`Invalid entry size of ${w}`);let R=I>>b,z=I&(1<<b)-1;h.push({outerIndex:R,innerIndex:z})}return{format:l,entryFormat:d,map:h}},te.prototype.parseDeltaSets=function(l,d,h){let m=Array.from({length:l},()=>[]),b=d&Le.LONG_WORDS,w=d&Le.WORD_DELTA_COUNT_MASK;if(w>h)throw Error("wordCount must be less than or equal to regionIndexCount");let _=(b?this.parseLong:this.parseShort).bind(this),I=(b?this.parseShort:this.parseChar).bind(this);for(let R=0;R<l;R++)for(let z=0;z<h;z++)z<w?m[R].push(_()):m[R].push(I());return m},te.prototype.parseTupleVariationStoreList=function(l,d,h){let m=this.parseUShort(),b=this.parseUShort()&1,w=this.parseOffset32(),_=(b?this.parseULong:this.parseUShort).bind(this),I={},R=_();b||(R*=2);let z;for(let O=0;O<m;O++){z=_(),b||(z*=2);let se=z-R;I[O]=se?this.parseTupleVariationStore(w+R,l,d,h,O):void 0,R=z}return I},te.prototype.parseTupleVariationStore=function(l,d,h,m,b){let w=this.relativeOffset;this.relativeOffset=l,h==="cvar"&&(this.relativeOffset+=4);let _=this.parseUShort(),I=!!(_&Le.SHARED_POINT_NUMBERS),R=_&Le.COUNT_MASK,z=this.parseOffset16(),O=[],se=[];for(let xe=0;xe<R;xe++){let Be=this.parseTupleVariationHeader(d,h);O.push(Be)}this.relativeOffset!==l+z&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${l+z}, actually ${this.relativeOffset}`),this.relativeOffset=l+z),I&&(se=this.parsePackedPointNumbers());let ne=this.relativeOffset;for(let xe=0;xe<R;xe++){let Be=O[xe];Be.privatePoints=[],this.relativeOffset=ne,h==="cvar"&&!Be.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),Be.flags.privatePointNumbers&&(Be.privatePoints=this.parsePackedPointNumbers()),delete Be.flags;let dt=this.offset,Dn=this.relativeOffset,An=Jn=>{let Lr,ls,ms=()=>{let gs=0;if(h==="gvar"){if(gs=Be.privatePoints.length||se.length,!gs){let vi=m.get(b);vi.path,gs=vi.points.length,gs+=4}}else h==="cvar"&&(gs=m.length);this.offset=dt,this.relativeOffset=Dn,Lr=this.parsePackedDeltas(gs),h==="gvar"&&(ls=this.parsePackedDeltas(gs))};return{configurable:!0,get:function(){return Lr===void 0&&ms(),Jn==="deltasY"?ls:Lr},set:function(gs){Lr===void 0&&ms(),Jn==="deltasY"?ls=gs:Lr=gs}}};Object.defineProperty(Be,"deltas",An.call(this,"deltas")),h==="gvar"&&Object.defineProperty(Be,"deltasY",An.call(this,"deltasY")),ne+=Be.variationDataSize,delete Be.variationDataSize}this.relativeOffset=w;let _e={headers:O};return _e.sharedPoints=se,_e},te.prototype.parseTupleVariationHeader=function(l,d){let h=this.parseUShort(),m=this.parseUShort(),b=!!(m&Le.EMBEDDED_PEAK_TUPLE),w=!!(m&Le.INTERMEDIATE_REGION),_=!!(m&Le.PRIVATE_POINT_NUMBERS),I=b?void 0:m&Le.TUPLE_INDEX_MASK,R=b?this.parseTupleRecords(1,l)[0]:void 0,z=w?this.parseTupleRecords(1,l)[0]:void 0,O=w?this.parseTupleRecords(1,l)[0]:void 0,se={variationDataSize:h,peakTuple:R,intermediateStartTuple:z,intermediateEndTuple:O,flags:{embeddedPeakTuple:b,intermediateRegion:w,privatePointNumbers:_}};return d==="gvar"&&(se.sharedTupleRecordsIndex=I),se},te.prototype.parsePackedPointNumbers=function(){let l=this.parseByte(),d=[],h=l;if(l>=128){let b=this.parseByte();h=(l&Le.POINT_RUN_COUNT_MASK)<<8|b}let m=0;for(;d.length<h;){let b=this.parseByte(),w=!!(b&Le.POINTS_ARE_WORDS),_=(b&Le.POINT_RUN_COUNT_MASK)+1;for(let I=0;I<_&&d.length<h;I++){let R;w?R=this.parseUShort():R=this.parseByte(),m=m+R,d.push(m)}}return d},te.prototype.parsePackedDeltas=function(l){let d=[];for(;d.length<l;){let h=this.parseByte(),m=!!(h&Le.DELTAS_ARE_ZERO),b=!!(h&Le.DELTAS_ARE_WORDS),w=(h&Le.DELTA_RUN_COUNT_MASK)+1;for(let _=0;_<w&&d.length<l;_++)m?d.push(0):b?d.push(this.parseShort()):d.push(this.parseChar())}return d};var Ne={getByte:Xn,getCard8:Xn,getUShort:Bn,getCard16:Bn,getShort:Ue,getUInt24:Nn,getULong:Ft,getFixed:Fn,getTag:Tn,getOffset:Qr,getBytes:kr,bytesToString:Ir,Parser:te},qt=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Zt={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},Qt={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},an={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function nn(l,d,h){switch(l){case 0:if(d===65535)return"und";if(h)return h[d];break;case 1:return Zt[d];case 3:return an[d]}}var fr="utf-16",Wn={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},ar={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Xr(l,d,h){switch(l){case 0:return fr;case 1:return ar[h]||Wn[d];case 3:if(d===1||d===10)return fr;break}}var Zr={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function Re(l){return Zr[l]}function et(l,d,h){let m={},b=new Ne.Parser(l,d),w=b.parseUShort(),_=b.parseUShort(),I=b.offset+b.parseUShort();for(let R=0;R<_;R++){let z=b.parseUShort(),O=b.parseUShort(),se=b.parseUShort(),ne=b.parseUShort(),_e=qt[ne]||ne,xe=b.parseUShort(),Be=b.parseUShort(),dt=nn(z,se,h),Dn=Xr(z,O,se),An=Re(z);if(Dn!==void 0&&dt!==void 0&&An!==void 0){let Jn;if(Dn===fr?Jn=Ke.UTF16(l,I+Be,xe):Jn=Ke.MACSTRING(l,I+Be,xe,Dn),Jn){let Lr=m[An];Lr===void 0&&(Lr=m[An]={});let ls=Lr[_e];ls===void 0&&(ls=Lr[_e]={}),ls[dt]=Jn}}}return w===1&&b.parseUShort(),m}function vt(l){let d={};for(let h in l)d[l[h]]=parseInt(h);return d}function rn(l,d,h,m,b,w){return new Ve.Record("NameRecord",[{name:"platformID",type:"USHORT",value:l},{name:"encodingID",type:"USHORT",value:d},{name:"languageID",type:"USHORT",value:h},{name:"nameID",type:"USHORT",value:m},{name:"length",type:"USHORT",value:b},{name:"offset",type:"USHORT",value:w}])}function fn(l,d){let h=l.length,m=d.length-h+1;e:for(let b=0;b<m;b++)for(;b<m;b++){for(let w=0;w<h;w++)if(d[b+w]!==l[w])continue e;return b}return-1}function $t(l,d){let h=fn(l,d);if(h<0){h=d.length;let m=0,b=l.length;for(;m<b;++m)d.push(l[m])}return h}function on(l,d){let h=vt(Zr),m=vt(Zt),b=vt(an),w=[],_=[];for(let R in l){let z,O=[],se={},ne=vt(qt),_e=h[R];for(let xe in l[R]){let Be=ne[xe];if(Be===void 0&&(Be=xe),z=parseInt(Be),isNaN(z))throw new Error('Name table entry "'+xe+'" does not exist, see nameTableNames for complete list.');se[z]=l[R][xe],O.push(z)}for(let xe=0;xe<O.length;xe++){z=O[xe];let Be=se[z];for(let dt in Be){let Dn=Be[dt];if(_e===1||_e===0){let An=m[dt],Jn=Qt[An],Lr=Xr(_e,Jn,An),ls=K.MACSTRING(Dn,Lr);if(_e===0&&(An=d.indexOf(dt),An<0&&(An=d.length,d.push(dt)),Jn=4,ls=K.UTF16(Dn)),ls!==void 0){let ms=$t(ls,_);w.push(rn(_e,Jn,An,z,ls.length,ms))}}if(_e===3){let An=b[dt];if(An!==void 0){let Jn=K.UTF16(Dn),Lr=$t(Jn,_);w.push(rn(3,1,An,z,Jn.length,Lr))}}}}}w.sort(function(R,z){return R.platformID-z.platformID||R.encodingID-z.encodingID||R.languageID-z.languageID||R.nameID-z.nameID});let I=new Ve.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:w.length},{name:"stringOffset",type:"USHORT",value:6+w.length*12}]);for(let R=0;R<w.length;R++)I.fields.push({name:"record_"+R,type:"RECORD",value:w[R]});return I.fields.push({name:"strings",type:"LITERAL",value:_}),I}function hn(l,d,h=[]){if(d<256&&d in qt){if(h.length&&!h.includes(parseInt(d)))return;d=qt[d]}for(let m in l)for(let b in l[m])if(b===d||parseInt(b)===d)return l[m][b]}var Qn={parse:et,make:on,getNameByID:hn};function At(l,d,h,m){l.length=d.parseUShort(),l.language=d.parseUShort()-1;let b=d.parseByteList(l.length),w=Object.assign({},b),_=Xr(h,m,l.language),I=Pe[_];for(let R=0;R<I.length;R++)w[I.charCodeAt(R)]=b[128+R];l.glyphIndexMap=w}function zn(l,d,h){d.parseUShort(),l.length=d.parseULong(),l.language=d.parseULong();let m;l.groupCount=m=d.parseULong(),l.glyphIndexMap={};for(let b=0;b<m;b+=1){let w=d.parseULong(),_=d.parseULong(),I=d.parseULong();for(let R=w;R<=_;R+=1)l.glyphIndexMap[R]=I,h===12&&I++}}function Ge(l,d,h,m,b){l.length=d.parseUShort(),l.language=d.parseUShort();let w;l.segCount=w=d.parseUShort()>>1,d.skip("uShort",3),l.glyphIndexMap={};let _=new Ne.Parser(h,m+b+14),I=new Ne.Parser(h,m+b+16+w*2),R=new Ne.Parser(h,m+b+16+w*4),z=new Ne.Parser(h,m+b+16+w*6),O=m+b+16+w*8;for(let se=0;se<w-1;se+=1){let ne,_e=_.parseUShort(),xe=I.parseUShort(),Be=R.parseShort(),dt=z.parseUShort();for(let Dn=xe;Dn<=_e;Dn+=1)dt!==0?(O=z.offset+z.relativeOffset-2,O+=dt,O+=(Dn-xe)*2,ne=Ne.getUShort(h,O),ne!==0&&(ne=ne+Be&65535)):ne=Dn+Be&65535,l.glyphIndexMap[Dn]=ne}}function Mt(l,d){let h={};d.skip("uLong");let m=d.parseULong();for(let b=0;b<m;b+=1){let w=d.parseUInt24(),_={varSelector:w},I=d.parseOffset32(),R=d.parseOffset32(),z=d.relativeOffset;I&&(d.relativeOffset=I,_.defaultUVS=d.parseStruct({ranges:function(){return d.parseRecordList32({startUnicodeValue:d.parseUInt24,additionalCount:d.parseByte})}})),R&&(d.relativeOffset=R,_.nonDefaultUVS=d.parseStruct({uvsMappings:function(){let O={},se=d.parseRecordList32({unicodeValue:d.parseUInt24,glyphID:d.parseUShort});for(let ne=0;ne<se.length;ne+=1)O[se[ne].unicodeValue]=se[ne];return O}})),h[w]=_,d.relativeOffset=z}l.varSelectorList=h}function Ye(l,d){let h={};h.version=Ne.getUShort(l,d),re.argument(h.version===0,"cmap table version should be 0."),h.numTables=Ne.getUShort(l,d+2);let m=null,b=-1,w=-1,_=null,I=null,R=[0,1,2,3,4,6],z=[0,1,10];for(let se=h.numTables-1;se>=0;se-=1)if(_=Ne.getUShort(l,d+4+se*8),I=Ne.getUShort(l,d+4+se*8+2),_===3&&z.includes(I)||_===0&&R.includes(I)||_===1&&I===0){if(w>0)continue;if(w=Ne.getULong(l,d+4+se*8+4),m)break}else if(_===0&&I===5){if(b=Ne.getULong(l,d+4+se*8+4),m=new Ne.Parser(l,d+b),m.parseUShort()!==14)b=-1,m=null;else if(w>0)break}if(w===-1)throw new Error("No valid cmap sub-tables found.");let O=new Ne.Parser(l,d+w);if(h.format=O.parseUShort(),h.format===0)At(h,O,_,I);else if(h.format===12||h.format===13)zn(h,O,h.format);else if(h.format===4)Ge(h,O,l,d,w);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+h.format+", platformId "+_+", encodingId "+I+").");return m&&Mt(h,m),h}function ct(l,d,h){l.segments.push({end:d,start:d,delta:-(d-h),offset:0,glyphIndex:h})}function Jt(l){l.segments.push({end:65535,start:65535,delta:1,offset:0})}function Ht(l){if(l.length===0)return l;let d=[l[0]];for(let h=1;h<l.length;h++){let m=d[d.length-1],b=l[h];m.end+1===b.start&&m.delta===b.delta&&b.end!==65535?m.end=b.end:d.push(b)}return d}function xn(l){let d=!0,h;for(h=l.length-1;h>0;h-=1)if(l.get(h).unicode>65535){d=!1;break}let m=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:d?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:d?12:20}];d||m.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),m.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let b=new Ve.Table("cmap",m);for(b.segments=[],h=0;h<l.length;h+=1){let _e=l.get(h);for(let xe=0;xe<_e.unicodes.length;xe+=1)ct(b,_e.unicodes[xe],h)}b.segments.sort(function(_e,xe){return _e.start-xe.start}),b.segments=Ht(b.segments),Jt(b);let w=b.segments.length,_=0,I=[],R=[],z=[],O=[],se=[],ne=[];for(h=0;h<w;h+=1){let _e=b.segments[h];_e.end<=65535&&_e.start<=65535?(I.push({name:"end_"+h,type:"USHORT",value:_e.end}),R.push({name:"start_"+h,type:"USHORT",value:_e.start}),z.push({name:"idDelta_"+h,type:"SHORT",value:_e.delta}),O.push({name:"idRangeOffset_"+h,type:"USHORT",value:_e.offset}),_e.glyphId!==void 0&&se.push({name:"glyph_"+h,type:"USHORT",value:_e.glyphId})):_+=1,!d&&_e.glyphIndex!==void 0&&(ne.push({name:"cmap12Start_"+h,type:"ULONG",value:_e.start}),ne.push({name:"cmap12End_"+h,type:"ULONG",value:_e.end}),ne.push({name:"cmap12Glyph_"+h,type:"ULONG",value:_e.glyphIndex}))}b.segCountX2=(w-_)*2,b.searchRange=Math.pow(2,Math.floor(Math.log(w-_)/Math.log(2)))*2,b.entrySelector=Math.log(b.searchRange/2)/Math.log(2),b.rangeShift=b.segCountX2-b.searchRange;for(let _e=0;_e<I.length;_e++)b.fields.push(I[_e]);b.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let _e=0;_e<R.length;_e++)b.fields.push(R[_e]);for(let _e=0;_e<z.length;_e++)b.fields.push(z[_e]);for(let _e=0;_e<O.length;_e++)b.fields.push(O[_e]);for(let _e=0;_e<se.length;_e++)b.fields.push(se[_e]);if(b.cmap4Length=14+I.length*2+2+R.length*2+z.length*2+O.length*2+se.length*2,!d){let _e=16+ne.length*4;b.cmap12Offset=20+b.cmap4Length,b.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:_e},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:ne.length/3});for(let xe=0;xe<ne.length;xe++)b.fields.push(ne[xe])}return b}var Me={parse:Ye,make:xn},tt=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],yt=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Ot=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Zn=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],pn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],bn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Kt=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function nr(l){this.font=l}nr.prototype.charToGlyphIndex=function(l){let d=l.codePointAt(0),h=this.font.glyphs;if(h)for(let m=0;m<h.length;m+=1){let b=h.get(m);for(let w=0;w<b.unicodes.length;w+=1)if(b.unicodes[w]===d)return m}return null};function lr(l){this.cmap=l}lr.prototype.charToGlyphIndex=function(l){return this.cmap.glyphIndexMap[l.codePointAt(0)]||0};function Cn(l,d){this.encoding=l,this.charset=d}Cn.prototype.charToGlyphIndex=function(l){let d=l.codePointAt(0),h=this.encoding[d];return this.charset.indexOf(h)};function _r(l){switch(l.version){case 1:this.names=Kt.slice();break;case 2:this.names=new Array(l.numberOfGlyphs);for(let d=0;d<l.numberOfGlyphs;d++)l.glyphNameIndex[d]<Kt.length?this.names[d]=Kt[l.glyphNameIndex[d]]:this.names[d]=l.names[l.glyphNameIndex[d]-Kt.length];break;case 2.5:this.names=new Array(l.numberOfGlyphs);for(let d=0;d<l.numberOfGlyphs;d++)this.names[d]=Kt[d+l.glyphNameIndex[d]];break;case 3:this.names=[];break;default:this.names=[];break}}_r.prototype.nameToGlyphIndex=function(l){return this.names.indexOf(l)},_r.prototype.glyphIndexToName=function(l){return this.names[l]};function Jr(l){let d,h=l.tables.cmap.glyphIndexMap,m=Object.keys(h);for(let b=0;b<m.length;b+=1){let w=m[b],_=h[w];d=l.glyphs.get(_),d.addUnicode(parseInt(w))}for(let b=0;b<l.glyphs.length;b+=1)d=l.glyphs.get(b),l.cffEncoding?d.name=l.cffEncoding.charset[b]:l.glyphNames.names&&(d.name=l.glyphNames.glyphIndexToName(b))}function sr(l){l._IndexToUnicodeMap={};let d=l.tables.cmap.glyphIndexMap,h=Object.keys(d);for(let m=0;m<h.length;m+=1){let b=h[m],w=d[b];l._IndexToUnicodeMap[w]===void 0?l._IndexToUnicodeMap[w]={unicodes:[parseInt(b)]}:l._IndexToUnicodeMap[w].unicodes.push(parseInt(b))}}function pr(l,d){d.lowMemory?sr(l):Jr(l)}function Br(l,d,h,m,b){l.beginPath(),l.moveTo(d,h),l.lineTo(m,b),l.stroke()}var mr={line:Br};function vs(l,d){let h=new te(l,d),m=h.parseShort();m!==0&&console.warn("Only CPALv0 is currently fully supported.");let b=h.parseShort(),w=h.parseShort(),_=h.parseShort(),I=h.parseOffset32(),R=h.parseUShortList(w);h.relativeOffset=I;let z=h.parseULongList(_);return h.relativeOffset=I,{version:m,numPaletteEntries:b,colorRecords:z,colorRecordIndices:R}}function le({version:l=0,numPaletteEntries:d=0,colorRecords:h=[],colorRecordIndices:m=[0]}){return re.argument(l===0,"Only CPALv0 are supported."),re.argument(h.length,"No colorRecords given."),re.argument(m.length,"No colorRecordIndices given."),m.length>1&&re.argument(d,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new Ve.Table("CPAL",[{name:"version",type:"USHORT",value:l},{name:"numPaletteEntries",type:"USHORT",value:d||h.length},{name:"numPalettes",type:"USHORT",value:m.length},{name:"numColorRecords",type:"USHORT",value:h.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*m.length},...m.map((b,w)=>({name:"colorRecordIndices_"+w,type:"USHORT",value:b})),...h.map((b,w)=>({name:"colorRecords_"+w,type:"ULONG",value:b}))])}function oe(l){var d=(l&4278190080)>>24,h=(l&16711680)>>16,m=(l&65280)>>8,b=l&255;return d=d+256&255,h=h+256&255,m=m+256&255,b=(b+256&255)/255,{b:d,g:h,r:m,a:b}}function ke(l,d,h=0,m="hexa"){if(d==65535)return"currentColor";let b=l&&l.tables&&l.tables.cpal;if(!b)return"currentColor";if(h>b.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${b.colorRecordIndices.length}, index: ${d})`);if(d>b.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${b.numPaletteEntries}, index: ${d})`);let w=b.colorRecordIndices[h]+d;if(w>b.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${b.colorRecords.length}, lookupIndex: ${w})`);let _=oe(b.colorRecords[w]);return m==="bgra"?_:ln(_,m)}function Xe(l){return("0"+parseInt(l).toString(16)).slice(-2)}function Bt(l){let d=l.r/255,h=l.g/255,m=l.b/255,b=Math.max(d,h,m),w=Math.min(d,h,m),_,I,R=(b+w)/2;if(b===w)_=I=0;else{let z=b-w;switch(I=R>.5?z/(2-b-w):z/(b+w),b){case d:_=(h-m)/z+(h<m?6:0);break;case h:_=(m-d)/z+2;break;case m:_=(d-h)/z+4;break}_/=6}return{h:_*360,s:I*100,l:R*100}}function It(l){let{h:d,s:h,l:m,a:b}=l;d=d%360,h/=100,m/=100;let w=(1-Math.abs(2*m-1))*h,_=w*(1-Math.abs(d/60%2-1)),I=m-w/2,R=0,z=0,O=0;return 0<=d&&d<60?(R=w,z=_,O=0):60<=d&&d<120?(R=_,z=w,O=0):120<=d&&d<180?(R=0,z=w,O=_):180<=d&&d<240?(R=0,z=_,O=w):240<=d&&d<300?(R=_,z=0,O=w):300<=d&&d<=360&&(R=w,z=0,O=_),{r:Math.round((R+I)*255),g:Math.round((z+I)*255),b:Math.round((O+I)*255),a:b}}function yn(l){return parseInt(`0x${Xe(l.b)}${Xe(l.g)}${Xe(l.r)}${Xe(l.a*255)}`,16)}function Gt(l,d="hexa"){let h=d=="raw"||d=="cpal",m=Number.isInteger(l),b=!0;if(m&&h||l==="currentColor")return l;if(typeof l=="object"){if(d=="bgra")return l;if(h)return yn(l)}else if(!m&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(l.trim())){switch(l=l.trim().substring(1),l.length){case 3:l={r:parseInt(l[0].repeat(2),16),g:parseInt(l[1].repeat(2),16),b:parseInt(l[2].repeat(2),16),a:1};break;case 4:l={r:parseInt(l[0].repeat(2),16),g:parseInt(l[1].repeat(2),16),b:parseInt(l[2].repeat(2),16),a:parseInt(l[3].repeat(2),16)/255};break;case 6:l={r:parseInt(l[0]+l[1],16),g:parseInt(l[2]+l[3],16),b:parseInt(l[4]+l[5],16),a:1};break;case 8:l={r:parseInt(l[0]+l[1],16),g:parseInt(l[2]+l[3],16),b:parseInt(l[4]+l[5],16),a:parseInt(l[6]+l[7],16)/255};break}if(d=="bgra")return l}else if(typeof document<"u"&&/^[a-z]+$/i.test(l)){let w=document.createElement("canvas").getContext("2d");w.fillStyle=l;let _=ln(w.fillStyle,"hexa");_==="#000000ff"&&l.toLowerCase()!=="black"?b=!1:l=_}else{l=l.trim();let w=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(w.test(l)){let _=l.match(w).filter(I=>typeof I<"u");l={r:Math.round(parseFloat(_[1])/(_[2]?.39215686274509803:1)),g:Math.round(parseFloat(_[3])/(_[4]?.39215686274509803:1)),b:Math.round(parseFloat(_[5])/(_[6]?.39215686274509803:1)),a:_[7]?parseFloat(_[7])/(_[8]?100:1):1}}else{let _=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(_.test(l)){let I=l.match(_).filter(R=>typeof R<"u");l=It({h:parseFloat(I[1])*(I[2]==="turn"?360:1),s:parseFloat(I[3]),l:parseFloat(I[4]),a:I[5]?parseFloat(I[5])/(I[6]?100:1):1})}else b=!1}}if(!b)throw new Error(`Invalid color format: ${l}`);return ln(l,d)}function ln(l,d="hexa"){if(l==="currentColor")return l;if(Number.isInteger(l)){if(d=="raw"||d=="cpal")return l;l=oe(l)}else typeof l!="object"&&(l=Gt(l,"bgra"));let h=["hsl","hsla"].includes(d)?Bt(l):null;switch(d){case"rgba":return`rgba(${l.r}, ${l.g}, ${l.b}, ${parseFloat(l.a.toFixed(3))})`;case"rgb":return`rgb(${l.r}, ${l.g}, ${l.b})`;case"hex":case"hex6":case"hex-6":return`#${Xe(l.r)}${Xe(l.g)}${Xe(l.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Xe(l.r)}${Xe(l.g)}${Xe(l.b)}${Xe(l.a*255)}`;case"hsl":return`hsl(${h.h.toFixed(2)}, ${h.s.toFixed(2)}%, ${h.l.toFixed(2)}%)`;case"hsla":return`hsla(${h.h.toFixed(2)}, ${h.s.toFixed(2)}%, ${h.l.toFixed(2)}%, ${parseFloat(l.a.toFixed(3))})`;case"bgra":return l;case"raw":case"cpal":return yn(l);default:throw new Error("Unknown color format: "+d)}}var _n={parse:vs,make:le,getPaletteColor:ke,parseColor:Gt,formatColor:ln};function In(l,d){let h=d||new ht;return{configurable:!0,get:function(){return typeof h=="function"&&(h=h()),h},set:function(m){h=m}}}function Ln(l){this.bindConstructorValues(l)}Ln.prototype.bindConstructorValues=function(l){if(this.index=l.index||0,l.name===".notdef"?l.unicode=void 0:l.name===".null"&&(l.unicode=0),l.unicode===0&&l.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=l.name||null,this.unicode=l.unicode,this.unicodes=l.unicodes||(l.unicode!==void 0?[l.unicode]:[]),"xMin"in l&&(this.xMin=l.xMin),"yMin"in l&&(this.yMin=l.yMin),"xMax"in l&&(this.xMax=l.xMax),"yMax"in l&&(this.yMax=l.yMax),"advanceWidth"in l&&(this.advanceWidth=l.advanceWidth),"leftSideBearing"in l&&(this.leftSideBearing=l.leftSideBearing),"points"in l&&(this.points=l.points),Object.defineProperty(this,"path",In(this,l.path))},Ln.prototype.addUnicode=function(l){this.unicodes.length===0&&(this.unicode=l),this.unicodes.push(l)},Ln.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Ln.prototype.getPath=function(l,d,h,m,b){l=l!==void 0?l:0,d=d!==void 0?d:0,h=h!==void 0?h:72,m=Object.assign({},b&&b.defaultRenderOptions,m);let w,_,I=m.xScale,R=m.yScale,z=1/(this.path.unitsPerEm||1e3)*h,O=this;b&&b.variation&&(O=b.variation.getTransform(this,m.variation),w=O.path.commands),m.hinting&&b&&b.hinting&&(_=O.path&&b.hinting.exec(O,h,m)),_?(w=b.hinting.getCommands(_),l=Math.round(l),d=Math.round(d),I=R=1):(w=O.path.commands,I===void 0&&(I=z),R===void 0&&(R=z));let se=new ht;if(m.drawSVG){let ne=this.getSvgImage(b);if(ne){let _e=new ht;return _e._image={image:ne.image,x:l+ne.leftSideBearing*z,y:d-ne.baseline*z,width:ne.image.width*z,height:ne.image.height*z},se._layers=[_e],se}}if(m.drawLayers){let ne=this.getLayers(b);if(ne&&ne.length){se._layers=[];for(let _e=0;_e<ne.length;_e+=1){let xe=ne[_e],Be=ke(b,xe.paletteIndex,m.usePalette);Be==="currentColor"?Be=m.fill||"black":Be=ln(Be,m.colorFormat||"rgba"),m=Object.assign({},m,{fill:Be}),se._layers.push(this.getPath.call(xe.glyph,l,d,h,m,b))}return se}}se.fill=m.fill||this.path.fill,se.stroke=this.path.stroke,se.strokeWidth=this.path.strokeWidth*z;for(let ne=0;ne<w.length;ne+=1){let _e=w[ne];_e.type==="M"?se.moveTo(l+_e.x*I,d+-_e.y*R):_e.type==="L"?se.lineTo(l+_e.x*I,d+-_e.y*R):_e.type==="Q"?se.quadraticCurveTo(l+_e.x1*I,d+-_e.y1*R,l+_e.x*I,d+-_e.y*R):_e.type==="C"?se.curveTo(l+_e.x1*I,d+-_e.y1*R,l+_e.x2*I,d+-_e.y2*R,l+_e.x*I,d+-_e.y*R):_e.type==="Z"&&se.stroke&&se.strokeWidth&&se.closePath()}return se},Ln.prototype.getLayers=function(l){if(!l)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return l.layers.get(this.index)},Ln.prototype.getSvgImage=function(l){if(!l)throw new Error("The font object is required to read the svg table in order to get the image.");return l.svgImages.get(this.index)},Ln.prototype.getContours=function(l=null){if(this.points===void 0&&!l)return[];let d=[],h=[],m=l||this.points;for(let b=0;b<m.length;b+=1){let w=m[b];h.push(w),w.lastPointOfContour&&(d.push(h),h=[])}return re.argument(h.length===0,"There are still points left in the current contour."),d},Ln.prototype.getMetrics=function(){let l=this.path.commands,d=[],h=[];for(let b=0;b<l.length;b+=1){let w=l[b];w.type!=="Z"&&(d.push(w.x),h.push(w.y)),(w.type==="Q"||w.type==="C")&&(d.push(w.x1),h.push(w.y1)),w.type==="C"&&(d.push(w.x2),h.push(w.y2))}let m={xMin:Math.min.apply(null,d),yMin:Math.min.apply(null,h),xMax:Math.max.apply(null,d),yMax:Math.max.apply(null,h),leftSideBearing:this.leftSideBearing};return isFinite(m.xMin)||(m.xMin=0),isFinite(m.xMax)||(m.xMax=this.advanceWidth),isFinite(m.yMin)||(m.yMin=0),isFinite(m.yMax)||(m.yMax=0),m.rightSideBearing=this.advanceWidth-m.leftSideBearing-(m.xMax-m.xMin),m},Ln.prototype.draw=function(l,d,h,m,b,w){b=Object.assign({},w&&w.defaultRenderOptions,b),this.getPath(d,h,m,b,w).draw(l)},Ln.prototype.drawPoints=function(l,d,h,m,b,w){if(b=Object.assign({},w&&w.defaultRenderOptions,b),b.drawLayers){let se=this.getLayers(w);if(se&&se.length){for(let ne=0;ne<se.length;ne+=1)se[ne].glyph.index!==this.index&&this.drawPoints.call(se[ne].glyph,l,d,h,m);return}}function _(se,ne,_e,xe){l.beginPath();for(let Be=0;Be<se.length;Be+=1)l.moveTo(ne+se[Be].x*xe,_e+se[Be].y*xe),l.arc(ne+se[Be].x*xe,_e+se[Be].y*xe,2,0,Math.PI*2,!1);l.fill()}d=d!==void 0?d:0,h=h!==void 0?h:0,m=m!==void 0?m:24;let I=1/this.path.unitsPerEm*m,R=[],z=[],O=this.path.commands;w&&w.variation&&(O=w.variation.getTransform(this,b.variation).path.commands);for(let se=0;se<O.length;se+=1){let ne=O[se];ne.x!==void 0&&R.push({x:ne.x,y:-ne.y}),ne.x1!==void 0&&z.push({x:ne.x1,y:-ne.y1}),ne.x2!==void 0&&z.push({x:ne.x2,y:-ne.y2})}l.fillStyle="blue",_(R,d,h,I),l.fillStyle="red",_(z,d,h,I)},Ln.prototype.drawMetrics=function(l,d,h,m){let b;d=d!==void 0?d:0,h=h!==void 0?h:0,m=m!==void 0?m:24,b=1/this.path.unitsPerEm*m,l.lineWidth=1,l.strokeStyle="black",mr.line(l,d,-1e4,d,1e4),mr.line(l,-1e4,h,1e4,h);let w=this.xMin||0,_=this.yMin||0,I=this.xMax||0,R=this.yMax||0,z=this.advanceWidth||0;l.strokeStyle="blue",mr.line(l,d+w*b,-1e4,d+w*b,1e4),mr.line(l,d+I*b,-1e4,d+I*b,1e4),mr.line(l,-1e4,h+-_*b,1e4,h+-_*b),mr.line(l,-1e4,h+-R*b,1e4,h+-R*b),l.strokeStyle="green",mr.line(l,d+z*b,-1e4,d+z*b,1e4)},Ln.prototype.toPathData=function(l,d){l=Object.assign({},{variation:d&&d.defaultRenderOptions.variation},l);let h=this;d&&d.variation&&(h=d.variation.getTransform(this,l.variation));let m=h.points&&l.pointsTransform?l.pointsTransform(h.points):h.path;return l.pathTransform&&(m=l.pathTransform(m)),m.toPathData(l)},Ln.prototype.fromSVG=function(l,d={}){return this.path.fromSVG(l,d)},Ln.prototype.toSVG=function(l,d){let h=this.toPathData.apply(this,[l,d]);return this.path.toSVG(l,h)},Ln.prototype.toDOMElement=function(l,d){l=Object.assign({},{variation:d&&d.defaultRenderOptions.variation},l);let h=this.path;return d&&d.variation&&(h=d.variation.getTransform(this,l.variation).path),h.toDOMElement(l)};var Sr=Ln;function yr(l,d,h){Object.defineProperty(l,d,{get:function(){return typeof l[h]>"u"&&l.path,l[h]},set:function(m){l[h]=m},enumerable:!0,configurable:!0})}function Ar(l,d){if(this.font=l,this.glyphs={},Array.isArray(d))for(let h=0;h<d.length;h++){let m=d[h];m.path.unitsPerEm=l.unitsPerEm,this.glyphs[h]=m}this.length=d&&d.length||0}typeof Symbol<"u"&&Symbol.iterator&&(Ar.prototype[Symbol.iterator]=function(){let l=-1;return{next:(function(){l++;let d=l>=this.length-1;return{value:this.get(l),done:d}}).bind(this)}}),Ar.prototype.get=function(l){if(this.font._push&&this.glyphs[l]===void 0){this.font._push(l),typeof this.glyphs[l]=="function"&&(this.glyphs[l]=this.glyphs[l]());let d=this.glyphs[l],h=this.font._IndexToUnicodeMap[l];if(h)for(let m=0;m<h.unicodes.length;m++)d.addUnicode(h.unicodes[m]);this.font.cffEncoding?d.name=this.font.cffEncoding.charset[l]:this.font.glyphNames.names&&(d.name=this.font.glyphNames.glyphIndexToName(l)),this.glyphs[l].advanceWidth=this.font._hmtxTableData[l].advanceWidth,this.glyphs[l].leftSideBearing=this.font._hmtxTableData[l].leftSideBearing}else typeof this.glyphs[l]=="function"&&(this.glyphs[l]=this.glyphs[l]());return this.glyphs[l]},Ar.prototype.push=function(l,d){this.glyphs[l]=d,this.length++};function Rr(l,d){return new Sr({index:d,font:l})}function Mn(l,d,h,m,b,w){return function(){let _=new Sr({index:d,font:l});return _.path=function(){h(_,m,b);let I=w(l.glyphs,_);return I.unitsPerEm=l.unitsPerEm,I},yr(_,"numberOfContours","_numberOfContours"),yr(_,"xMin","_xMin"),yr(_,"xMax","_xMax"),yr(_,"yMin","_yMin"),yr(_,"yMax","_yMax"),yr(_,"points","_points"),_}}function sn(l,d,h,m,b){return function(){let w=new Sr({index:d,font:l});return w.path=function(){let _=h(l,w,m,b);return _.unitsPerEm=l.unitsPerEm,_},w}}var cn={GlyphSet:Ar,glyphLoader:Rr,ttfGlyphLoader:Mn,cffGlyphLoader:sn};function Gn(l,d){if(l===d)return!0;if(Array.isArray(l)&&Array.isArray(d)){if(l.length!==d.length)return!1;for(let h=0;h<l.length;h+=1)if(!Gn(l[h],d[h]))return!1;return!0}else return!1}var Dt=10;function mn(l){let d;return l.length<1240?d=107:l.length<33900?d=1131:d=32768,d}function $n(l,d,h,m){let b=[],w=[],_=m>1?Ne.getULong(l,d):Ne.getCard16(l,d),I=m>1?4:2,R,z;if(_!==0){let O=Ne.getByte(l,d+I);R=d+(_+1)*O+I;let se=d+I+1;for(let ne=0;ne<_+1;ne+=1)b.push(Ne.getOffset(l,se,O)),se+=O;z=R+b[_]}else z=d+I;for(let O=0;O<b.length-1;O+=1){let se=Ne.getBytes(l,R+b[O],R+b[O+1]);h&&(se=h(se,l,d,m)),w.push(se)}return{objects:w,startOffset:d,endOffset:z}}function Gs(l,d,h){let m=[],b=h>1?Ne.getULong(l,d):Ne.getCard16(l,d),w=h>1?4:2,_,I;if(b!==0){let R=Ne.getByte(l,d+w);_=d+(b+1)*R+w;let z=d+w+1;for(let O=0;O<b+1;O+=1)m.push(Ne.getOffset(l,z,R)),z+=R;I=_+m[b]}else I=d+w;return{offsets:m,startOffset:d,endOffset:I}}function Tr(l,d,h,m,b,w){let _=w>1?Ne.getULong(h,m):Ne.getCard16(h,m),I=w>1?4:2,R=0;if(_!==0){let O=Ne.getByte(h,m+I);R=m+(_+1)*O+I}let z=Ne.getBytes(h,R+d[l],R+d[l+1]);return b&&(z=b(z)),z}function Ur(l){let d="",h=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let m=l.parseByte(),b=m>>4,w=m&15;if(b===15||(d+=h[b],w===15))break;d+=h[w]}return parseFloat(d)}function _s(l,d){let h,m,b,w;if(d===28)return h=l.parseByte(),m=l.parseByte(),h<<8|m;if(d===29)return h=l.parseByte(),m=l.parseByte(),b=l.parseByte(),w=l.parseByte(),h<<24|m<<16|b<<8|w;if(d===30)return Ur(l);if(d>=32&&d<=246)return d-139;if(d>=247&&d<=250)return h=l.parseByte(),(d-247)*256+h+108;if(d>=251&&d<=254)return h=l.parseByte(),-(d-251)*256-h-108;throw new Error("Invalid b0 "+d)}function Uo(l){let d={};for(let h=0;h<l.length;h+=1){let m=l[h][0],b=l[h][1],w;if(b.length===1?w=b[0]:w=b,Object.prototype.hasOwnProperty.call(d,m)&&!isNaN(d[m]))throw new Error("Object "+d+" already has key "+m);d[m]=w}return d}function Nr(l,d,h,m){d=d!==void 0?d:0;let b=new Ne.Parser(l,d),w=[],_=[];h=h!==void 0?h:l.byteLength;let I=m<2?22:28;for(;b.relativeOffset<h;){let R=b.parseByte();if(R<I){if(R===12&&(R=1200+b.parseByte()),m>1&&R===23){to(_);continue}w.push([R,_]),_=[]}else _.push(_s(b,R,m))}return Uo(w)}function Ls(l,d){return d<=390?d=tt[d]:l?d=l[d-391]:d=void 0,d}function Ji(l,d,h){let m={},b;for(let w=0;w<d.length;w+=1){let _=d[w];if(Array.isArray(_.type)){let I=[];I.length=_.type.length;for(let R=0;R<_.type.length;R++)b=l[_.op]!==void 0?l[_.op][R]:void 0,b===void 0&&(b=_.value!==void 0&&_.value[R]!==void 0?_.value[R]:null),_.type[R]==="SID"&&(b=Ls(h,b)),I[R]=b;m[_.name]=I}else b=l[_.op],b===void 0&&(b=_.value!==void 0?_.value:null),_.type==="SID"&&(b=Ls(h,b)),m[_.name]=b}return m}function Pi(l,d){let h={};if(h.formatMajor=Ne.getCard8(l,d),h.formatMinor=Ne.getCard8(l,d+1),h.formatMajor>2)throw new Error(`Unsupported CFF table version ${h.formatMajor}.${h.formatMinor}`);return h.size=Ne.getCard8(l,d+2),h.formatMajor<2?(h.offsetSize=Ne.getCard8(l,d+3),h.startOffset=d,h.endOffset=d+4):(h.topDictLength=Ne.getCard16(l,d+3),h.endOffset=d+8),h}var Za=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],hi=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],Os=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],js=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],eo=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Qs(l,d,h,m){let b=Nr(l,d,l.byteLength,m);return Ji(b,m>1?hi:Za,h)}function Vr(l,d,h,m,b){let w=Nr(l,d,h,b);return Ji(w,b>1?js:Os,m)}function gr(l,d,h){let m=Nr(l,d,void 0,h);return Ji(m,eo)}function pi(l,d,h){let m=[];for(let b=0;b<h.length;b++){let w=new DataView(new Uint8Array(h[b]).buffer),_=gr(w,0,2),I=_.private[0],R=_.private[1];if(I!==0&&R!==0){let z=Vr(l,R+d,I,[],2);if(z.subrs){let O=R+z.subrs,se=$n(l,O+d,void 0,2);_._subrs=se.objects,_._subrsBias=mn(_._subrs)}_._privateDict=z}m.push(_)}return m}function Es(l,d,h,m,b){let w=[];for(let _=0;_<h.length;_+=1){let I=new DataView(new Uint8Array(h[_]).buffer),R=Qs(I,0,m,b);R._subrs=[],R._subrsBias=0,R._defaultWidthX=0,R._nominalWidthX=0;let z=b<2?R.private[0]:0,O=b<2?R.private[1]:0;if(z!==0&&O!==0){let se=Vr(l,O+d,z,m,b);if(R._defaultWidthX=se.defaultWidthX,R._nominalWidthX=se.nominalWidthX,se.subrs!==0){let ne=O+se.subrs,_e=$n(l,ne+d,void 0,b);R._subrs=_e.objects,R._subrsBias=mn(R._subrs)}R._privateDict=se}w.push(R)}return w}function mi(l,d,h,m,b){let w,_,I=new Ne.Parser(l,d);h-=1;let R=[".notdef"],z=I.parseCard8();if(z===0)for(let O=0;O<h;O+=1)w=I.parseSID(),b?R.push(w):R.push(Ls(m,w)||w);else if(z===1)for(;R.length<=h;){w=I.parseSID(),_=I.parseCard8();for(let O=0;O<=_;O+=1)b?R.push("cid"+("00000"+w).slice(-5)):R.push(Ls(m,w)||w),w+=1}else if(z===2)for(;R.length<=h;){w=I.parseSID(),_=I.parseCard16();for(let O=0;O<=_;O+=1)b?R.push("cid"+("00000"+w).slice(-5)):R.push(Ls(m,w)||w),w+=1}else throw new Error("Unknown charset format "+z);return R}function Cr(l,d){let h,m={},b=new Ne.Parser(l,d),w=b.parseCard8();if(w===0){let _=b.parseCard8();for(let I=0;I<_;I+=1)h=b.parseCard8(),m[h]=I}else if(w===1){let _=b.parseCard8();h=1;for(let I=0;I<_;I+=1){let R=b.parseCard8(),z=b.parseCard8();for(let O=R;O<=R+z;O+=1)m[O]=h,h+=1}}else throw new Error("Unknown encoding format "+w);return m}function to(l){let d=l.pop();for(;l.length>d;)l.pop()}function Mr(l,d){let h=l.tables.cff&&l.tables.cff.topDict&&l.tables.cff.topDict.paintType||0;return h===2&&(d.fill=null,d.stroke="black",d.strokeWidth=l.tables.cff.topDict.strokeWidth||0),h}function Ws(l,d,h,m,b){let w,_,I,R,z=new ht,O=[],se=0,ne=!1,_e=!1,xe=0,Be=0,dt,Dn,An,Jn,Lr=0,ls=[],ms,gs=0,vi=l.tables.cff2||l.tables.cff;if(An=vi.topDict._defaultWidthX,Jn=vi.topDict._nominalWidthX,b=b||l.variation&&l.variation.get(),d.getBlendPath||(d.getBlendPath=function(gn){return Ws(l,d,h,m,gn)}),l.isCIDFont||m>1){let gn=vi.topDict._fdSelect?vi.topDict._fdSelect[d.index]:0,Sn=vi.topDict._fdArray[gn];dt=Sn._subrs,Dn=Sn._subrsBias,m>1?(ls=vi.topDict._vstore.itemVariationStore,Lr=Sn._privateDict.vsindex):(An=Sn._defaultWidthX,Jn=Sn._nominalWidthX)}else dt=vi.topDict._subrs,Dn=vi.topDict._subrsBias;let Pl=Mr(l,z),Er=An;function Oa(gn,Sn){_e&&Pl!==2&&z.closePath(),z.moveTo(gn,Sn),_e=!0}function Jo(){let gn;gn=(O.length&1)!==0,gn&&!ne&&(Er=O.shift()+Jn),se+=O.length>>1,O.length=0,ne=!0}function jn(gn){let Sn,Po,eu,Lp,Nu,Bl,ea,al,Bo,Qa,ta,na,di=0;for(;di<gn.length;){let cl=gn[di];switch(di+=1,cl){case 1:Jo();break;case 3:Jo();break;case 4:O.length>1&&!ne&&(Er=O.shift()+Jn,ne=!0),Be+=O.pop(),Oa(xe,Be);break;case 5:for(;O.length>0;)xe+=O.shift(),Be+=O.shift(),z.lineTo(xe,Be);break;case 6:for(;O.length>0&&(xe+=O.shift(),z.lineTo(xe,Be),O.length!==0);)Be+=O.shift(),z.lineTo(xe,Be);break;case 7:for(;O.length>0&&(Be+=O.shift(),z.lineTo(xe,Be),O.length!==0);)xe+=O.shift(),z.lineTo(xe,Be);break;case 8:for(;O.length>0;)w=xe+O.shift(),_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),xe=I+O.shift(),Be=R+O.shift(),z.curveTo(w,_,I,R,xe,Be);break;case 10:if(Nu=O.pop()+Dn,Bl=dt[Nu],Bl){if(gs>=Dt){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}gs++,jn(Bl),gs--}break;case 11:if(m>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(cl=gn[di],di+=1,cl){case 35:w=xe+O.shift(),_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),ea=I+O.shift(),al=R+O.shift(),Bo=ea+O.shift(),Qa=al+O.shift(),ta=Bo+O.shift(),na=Qa+O.shift(),xe=ta+O.shift(),Be=na+O.shift(),O.shift(),z.curveTo(w,_,I,R,ea,al),z.curveTo(Bo,Qa,ta,na,xe,Be);break;case 34:w=xe+O.shift(),_=Be,I=w+O.shift(),R=_+O.shift(),ea=I+O.shift(),al=R,Bo=ea+O.shift(),Qa=R,ta=Bo+O.shift(),na=Be,xe=ta+O.shift(),z.curveTo(w,_,I,R,ea,al),z.curveTo(Bo,Qa,ta,na,xe,Be);break;case 36:w=xe+O.shift(),_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),ea=I+O.shift(),al=R,Bo=ea+O.shift(),Qa=R,ta=Bo+O.shift(),na=Qa+O.shift(),xe=ta+O.shift(),z.curveTo(w,_,I,R,ea,al),z.curveTo(Bo,Qa,ta,na,xe,Be);break;case 37:w=xe+O.shift(),_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),ea=I+O.shift(),al=R+O.shift(),Bo=ea+O.shift(),Qa=al+O.shift(),ta=Bo+O.shift(),na=Qa+O.shift(),Math.abs(ta-xe)>Math.abs(na-Be)?xe=ta+O.shift():Be=na+O.shift(),z.curveTo(w,_,I,R,ea,al),z.curveTo(Bo,Qa,ta,na,xe,Be);break;default:console.log("Glyph "+d.index+": unknown operator 1200"+cl),O.length=0}break;case 14:if(m>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(O.length>=4){let Mu=pn[O.pop()],Fd=pn[O.pop()],Ep=O.pop(),Ip=O.pop();if(Mu&&Fd){d.isComposite=!0,d.components=[];let p5=l.cffEncoding.charset.indexOf(Mu),m5=l.cffEncoding.charset.indexOf(Fd);d.components.push({glyphIndex:m5,dx:0,dy:0}),d.components.push({glyphIndex:p5,dx:Ip,dy:Ep}),z.extend(l.glyphs.get(m5).path);let D_=l.glyphs.get(p5),W1=JSON.parse(JSON.stringify(D_.path.commands));for(let V1=0;V1<W1.length;V1+=1){let rc=W1[V1];rc.type!=="Z"&&(rc.x+=Ip,rc.y+=Ep),(rc.type==="Q"||rc.type==="C")&&(rc.x1+=Ip,rc.y1+=Ep),rc.type==="C"&&(rc.x2+=Ip,rc.y2+=Ep)}z.extend(W1)}}else O.length>0&&!ne&&(Er=O.shift()+Jn,ne=!0);_e&&Pl!==2&&(z.closePath(),_e=!1);break;case 15:if(m<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}Lr=O.pop();break;case 16:if(m<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}ms||(ms=l.variation&&b&&l.variation.process.getBlendVector(ls,Lr,b));var ys=O.pop(),ba=ms?ms.length:ls.itemVariationSubtables[Lr].regionIndexes.length,ll=ys*ba,Fl=O.length-ll,_c=Fl-ys;if(ms)for(let Mu=0;Mu<ys;Mu++){var h5=O[_c+Mu];for(let Fd=0;Fd<ba;Fd++)h5+=ms[Fd]*O[Fl++];O[_c+Mu]=h5}for(;ll--;)O.pop();break;case 18:Jo();break;case 19:case 20:Jo(),di+=se+7>>3;break;case 21:O.length>2&&!ne&&(Er=O.shift()+Jn,ne=!0),Be+=O.pop(),xe+=O.pop(),Oa(xe,Be);break;case 22:O.length>1&&!ne&&(Er=O.shift()+Jn,ne=!0),xe+=O.pop(),Oa(xe,Be);break;case 23:Jo();break;case 24:for(;O.length>2;)w=xe+O.shift(),_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),xe=I+O.shift(),Be=R+O.shift(),z.curveTo(w,_,I,R,xe,Be);xe+=O.shift(),Be+=O.shift(),z.lineTo(xe,Be);break;case 25:for(;O.length>6;)xe+=O.shift(),Be+=O.shift(),z.lineTo(xe,Be);w=xe+O.shift(),_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),xe=I+O.shift(),Be=R+O.shift(),z.curveTo(w,_,I,R,xe,Be);break;case 26:for(O.length&1&&(xe+=O.shift());O.length>0;)w=xe,_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),xe=I,Be=R+O.shift(),z.curveTo(w,_,I,R,xe,Be);break;case 27:for(O.length&1&&(Be+=O.shift());O.length>0;)w=xe+O.shift(),_=Be,I=w+O.shift(),R=_+O.shift(),xe=I+O.shift(),Be=R,z.curveTo(w,_,I,R,xe,Be);break;case 28:Sn=gn[di],Po=gn[di+1],O.push((Sn<<24|Po<<16)>>16),di+=2;break;case 29:if(Nu=O.pop()+l.gsubrsBias,Bl=l.gsubrs[Nu],Bl){if(gs>=Dt){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}gs++,jn(Bl),gs--}break;case 30:for(;O.length>0&&(w=xe,_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),xe=I+O.shift(),Be=R+(O.length===1?O.shift():0),z.curveTo(w,_,I,R,xe,Be),O.length!==0);)w=xe+O.shift(),_=Be,I=w+O.shift(),R=_+O.shift(),Be=R+O.shift(),xe=I+(O.length===1?O.shift():0),z.curveTo(w,_,I,R,xe,Be);break;case 31:for(;O.length>0&&(w=xe+O.shift(),_=Be,I=w+O.shift(),R=_+O.shift(),Be=R+O.shift(),xe=I+(O.length===1?O.shift():0),z.curveTo(w,_,I,R,xe,Be),O.length!==0);)w=xe,_=Be+O.shift(),I=w+O.shift(),R=_+O.shift(),xe=I+O.shift(),Be=R+(O.length===1?O.shift():0),z.curveTo(w,_,I,R,xe,Be);break;default:cl<32?console.log("Glyph "+d.index+": unknown operator "+cl):cl<247?O.push(cl-139):cl<251?(Sn=gn[di],di+=1,O.push((cl-247)*256+Sn+108)):cl<255?(Sn=gn[di],di+=1,O.push(-(cl-251)*256-Sn-108)):(Sn=gn[di],Po=gn[di+1],eu=gn[di+2],Lp=gn[di+3],di+=4,O.push((Sn<<24|Po<<16|eu<<8|Lp)/65536))}}}return jn(h),l.variation&&b&&(z.commands=z.commands.map(gn=>{let Sn=Object.keys(gn);for(let Po=0;Po<Sn.length;Po++){let eu=Sn[Po];eu!=="type"&&(gn[eu]=Math.round(gn[eu]))}return gn})),ne&&(d.advanceWidth=Er),z}function Gr(l,d,h,m,b){let w=[],_,I=new Ne.Parser(l,d),R=I.parseCard8();if(R===0)for(let z=0;z<h;z++){if(_=I.parseCard8(),_>=m)throw new Error("CFF table CID Font FDSelect has bad FD index value "+_+" (FD count "+m+")");w.push(_)}else if(R===3||b>1&&R===4){let z=R===4?I.parseULong():I.parseCard16(),O=R===4?I.parseULong():I.parseCard16();if(O!==0)throw new Error(`CFF Table CID Font FDSelect format ${R} range has bad initial GID ${O}`);let se;for(let ne=0;ne<z;ne++){if(_=R===4?I.parseUShort():I.parseCard8(),se=R===4?I.parseULong():I.parseCard16(),_>=m)throw new Error("CFF table CID Font FDSelect has bad FD index value "+_+" (FD count "+m+")");if(se>h)throw new Error(`CFF Table CID Font FDSelect format ${b} range has bad GID ${se}`);for(;O<se;O++)w.push(_);O=se}if(se!==h)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+se)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+R);return w}function no(l,d,h,m){let b,w=Pi(l,d);w.formatMajor===2?b=h.tables.cff2={}:b=h.tables.cff={};let _=w.formatMajor>1?null:$n(l,w.endOffset,Ne.bytesToString),I=w.formatMajor>1?null:$n(l,_.endOffset),R=w.formatMajor>1?null:$n(l,I.endOffset,Ne.bytesToString),z=$n(l,w.formatMajor>1?d+w.size+w.topDictLength:R.endOffset,void 0,w.formatMajor);h.gsubrs=z.objects,h.gsubrsBias=mn(h.gsubrs);let O;if(w.formatMajor>1){let ne=d+w.size,_e=Ne.getBytes(l,ne,ne+w.topDictLength);O=Es(l,0,[_e],void 0,w.formatMajor)[0]}else{let ne=Es(l,d,I.objects,R.objects,w.formatMajor);if(ne.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+ne.length);O=ne[0]}if(b.topDict=O,O._privateDict&&(h.defaultWidthX=O._privateDict.defaultWidthX,h.nominalWidthX=O._privateDict.nominalWidthX),w.formatMajor<2&&O.ros[0]!==void 0&&O.ros[1]!==void 0&&(h.isCIDFont=!0),w.formatMajor>1){let ne=O.fdArray,_e=O.fdSelect;if(!ne)throw new Error("This is a CFF2 font, but FDArray information is missing");let xe=$n(l,d+ne,null,w.formatMajor),Be=pi(l,d,xe.objects);O._fdArray=Be,_e&&(O._fdSelect=Gr(l,d+_e,h.numGlyphs,Be.length,w.formatMajor))}else if(h.isCIDFont){let ne=O.fdArray,_e=O.fdSelect;if(ne===0||_e===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");ne+=d;let xe=$n(l,ne),Be=Es(l,d,xe.objects,R.objects,w.formatMajor);O._fdArray=Be,_e+=d,O._fdSelect=Gr(l,_e,h.numGlyphs,Be.length,w.formatMajor)}if(w.formatMajor<2){let ne=d+O.private[1],_e=Vr(l,ne,O.private[0],R.objects,w.formatMajor);if(h.defaultWidthX=_e.defaultWidthX,h.nominalWidthX=_e.nominalWidthX,_e.subrs!==0){let xe=ne+_e.subrs,Be=$n(l,xe);h.subrs=Be.objects,h.subrsBias=mn(h.subrs)}else h.subrs=[],h.subrsBias=0}let se;if(m.lowMemory?(se=Gs(l,d+O.charStrings,w.formatMajor),h.nGlyphs=se.offsets.length-(w.formatMajor>1?1:0)):(se=$n(l,d+O.charStrings,null,w.formatMajor),h.nGlyphs=se.objects.length),w.formatMajor>1&&h.tables.maxp&&h.nGlyphs!==h.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${h.nGlyphs}) must correspond to the glyph count in the maxp table (${h.tables.maxp.numGlyphs})`),w.formatMajor<2){let ne=[],_e=[];O.charset===0?ne=yt:O.charset===1?ne=Ot:O.charset===2?ne=Zn:ne=mi(l,d+O.charset,h.nGlyphs,R.objects,h.isCIDFont),O.encoding===0?_e=pn:O.encoding===1?_e=bn:_e=Cr(l,d+O.encoding),h.cffEncoding=new Cn(_e,ne),h.encoding=h.encoding||h.cffEncoding}if(h.glyphs=new cn.GlyphSet(h),m.lowMemory)h._push=function(ne){let _e=Tr(ne,se.offsets,l,d+O.charStrings,void 0,w.formatMajor);h.glyphs.push(ne,cn.cffGlyphLoader(h,ne,Ws,_e,w.formatMajor))};else for(let ne=0;ne<h.nGlyphs;ne+=1){let _e=se.objects[ne];h.glyphs.push(ne,cn.cffGlyphLoader(h,ne,Ws,_e,w.formatMajor))}if(O.vstore){let ne=new Ne.Parser(l,d+O.vstore);O._vstore=ne.parseVariationStore()}}function ro(l,d){let h,m=tt.indexOf(l);return m>=0&&(h=m),m=d.indexOf(l),m>=0?h=m+tt.length:(h=tt.length+d.length,d.push(l)),h}function Is(){return new Ve.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function $s(l){let d=new Ve.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);d.names=[];for(let h=0;h<l.length;h+=1)d.names.push({name:"name_"+h,type:"NAME",value:l[h]});return d}function ka(l,d,h){let m={};for(let b=0;b<l.length;b+=1){let w=l[b],_=d[w.name];_!==void 0&&!Gn(_,w.value)&&(w.type==="SID"&&(_=ro(_,h)),m[w.op]={name:w.name,type:w.type,value:_})}return m}function _a(l,d,h){let m=new Ve.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return m.dict=ka(h>1?hi:Za,l,d),m}function La(l){let d=new Ve.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return d.topDicts=[{name:"topDict_0",type:"TABLE",value:l}],d}function Cl(l){let d=new Ve.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);d.strings=[];for(let h=0;h<l.length;h+=1)d.strings.push({name:"string_"+h,type:"STRING",value:l[h]});return d}function ds(){return new Ve.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Vs(l,d){let h=new Ve.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let m=0;m<l.length;m+=1){let b=l[m],w=ro(b,d);h.fields.push({name:"glyph_"+m,type:"SID",value:w})}return h}function Bi(l,d){let h=[],m=l.path;d<2&&h.push({name:"width",type:"NUMBER",value:l.advanceWidth});let b=0,w=0;for(let _=0;_<m.commands.length;_+=1){let I,R,z=m.commands[_];if(z.type==="Q"){let O=.3333333333333333,se=2/3;z={type:"C",x:z.x,y:z.y,x1:Math.round(O*b+se*z.x1),y1:Math.round(O*w+se*z.y1),x2:Math.round(O*z.x+se*z.x1),y2:Math.round(O*z.y+se*z.y1)}}if(z.type==="M")I=Math.round(z.x-b),R=Math.round(z.y-w),h.push({name:"dx",type:"NUMBER",value:I}),h.push({name:"dy",type:"NUMBER",value:R}),h.push({name:"rmoveto",type:"OP",value:21}),b=Math.round(z.x),w=Math.round(z.y);else if(z.type==="L")I=Math.round(z.x-b),R=Math.round(z.y-w),h.push({name:"dx",type:"NUMBER",value:I}),h.push({name:"dy",type:"NUMBER",value:R}),h.push({name:"rlineto",type:"OP",value:5}),b=Math.round(z.x),w=Math.round(z.y);else if(z.type==="C"){let O=Math.round(z.x1-b),se=Math.round(z.y1-w),ne=Math.round(z.x2-z.x1),_e=Math.round(z.y2-z.y1);I=Math.round(z.x-z.x2),R=Math.round(z.y-z.y2),h.push({name:"dx1",type:"NUMBER",value:O}),h.push({name:"dy1",type:"NUMBER",value:se}),h.push({name:"dx2",type:"NUMBER",value:ne}),h.push({name:"dy2",type:"NUMBER",value:_e}),h.push({name:"dx",type:"NUMBER",value:I}),h.push({name:"dy",type:"NUMBER",value:R}),h.push({name:"rrcurveto",type:"OP",value:8}),b=Math.round(z.x),w=Math.round(z.y)}}return d<2&&h.push({name:"endchar",type:"OP",value:14}),h}function ko(l,d){let h=new Ve.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let m=0;m<l.length;m+=1){let b=l.get(m),w=Bi(b,d);h.charStrings.push({name:b.name,type:"CHARSTRING",value:w})}return h}function so(l,d,h){let m=new Ve.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return m.dict=ka(h>1?js:Os,l,d),m}function Ea(l,d){let h=new Ve.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),m=1/d.unitsPerEm,b={version:d.version,fullName:d.fullName,familyName:d.familyName,weight:d.weightName,fontBBox:d.fontBBox||[0,0,0,0],fontMatrix:[m,0,0,m,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},w=d&&d.topDict||{};w.paintType&&(b.paintType=w.paintType,b.strokeWidth=w.strokeWidth||0);let _={},I=[],R;for(let ne=1;ne<l.length;ne+=1)R=l.get(ne),I.push(R.name);let z=[];h.header=Is(),h.nameIndex=$s([d.postScriptName]);let O=_a(b,z);h.topDictIndex=La(O),h.globalSubrIndex=ds(),h.charsets=Vs(I,z),h.charStringsIndex=ko(l,1),h.privateDict=so(_,z),h.stringIndex=Cl(z);let se=h.header.sizeOf()+h.nameIndex.sizeOf()+h.topDictIndex.sizeOf()+h.stringIndex.sizeOf()+h.globalSubrIndex.sizeOf();return b.charset=se,b.encoding=0,b.charStrings=b.charset+h.charsets.sizeOf(),b.private[1]=b.charStrings+h.charStringsIndex.sizeOf(),O=_a(b,z),h.topDictIndex=La(O),h}var io={parse:no,make:Ea};function _o(l,d){let h={},m=new Ne.Parser(l,d);return h.version=m.parseVersion(),h.fontRevision=Math.round(m.parseFixed()*1e3)/1e3,h.checkSumAdjustment=m.parseULong(),h.magicNumber=m.parseULong(),re.argument(h.magicNumber===1594834165,"Font header has wrong magic number."),h.flags=m.parseUShort(),h.unitsPerEm=m.parseUShort(),h.created=m.parseLongDateTime(),h.modified=m.parseLongDateTime(),h.xMin=m.parseShort(),h.yMin=m.parseShort(),h.xMax=m.parseShort(),h.yMax=m.parseShort(),h.macStyle=m.parseUShort(),h.lowestRecPPEM=m.parseUShort(),h.fontDirectionHint=m.parseShort(),h.indexToLocFormat=m.parseShort(),h.glyphDataFormat=m.parseShort(),h}function qs(l){let d=Math.round(new Date().getTime()/1e3)+2082844800,h=d,m=l.macStyle||0;return l.createdTimestamp&&(h=l.createdTimestamp+2082844800),new Ve.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:h},{name:"modified",type:"LONGDATETIME",value:d},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:m},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],l)}var Hs={parse:_o,make:qs};function ni(l,d){let h={},m=new Ne.Parser(l,d);return h.version=m.parseVersion(),h.ascender=m.parseShort(),h.descender=m.parseShort(),h.lineGap=m.parseShort(),h.advanceWidthMax=m.parseUShort(),h.minLeftSideBearing=m.parseShort(),h.minRightSideBearing=m.parseShort(),h.xMaxExtent=m.parseShort(),h.caretSlopeRise=m.parseShort(),h.caretSlopeRun=m.parseShort(),h.caretOffset=m.parseShort(),m.relativeOffset+=8,h.metricDataFormat=m.parseShort(),h.numberOfHMetrics=m.parseUShort(),h}function Lo(l){return new Ve.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],l)}var De={parse:ni,make:Lo};function gt(l,d,h,m,b){let w,_,I=new Ne.Parser(l,d);for(let R=0;R<m;R+=1){R<h&&(w=I.parseUShort(),_=I.parseShort());let z=b.get(R);z.advanceWidth=w,z.leftSideBearing=_}}function Tt(l,d,h,m,b){l._hmtxTableData={};let w,_,I=new Ne.Parser(d,h);for(let R=0;R<b;R+=1)R<m&&(w=I.parseUShort(),_=I.parseShort()),l._hmtxTableData[R]={advanceWidth:w,leftSideBearing:_}}function Ze(l,d,h,m,b,w,_){_.lowMemory?Tt(l,d,h,m,b):gt(d,h,m,b,w)}function wt(l){let d=new Ve.Table("hmtx",[]);for(let h=0;h<l.length;h+=1){let m=l.get(h),b=m.advanceWidth||0,w=m.leftSideBearing||0;d.fields.push({name:"advanceWidth_"+h,type:"USHORT",value:b}),d.fields.push({name:"leftSideBearing_"+h,type:"SHORT",value:w})}return d}var kn={parse:Ze,make:wt};function ir(l){let d=new Ve.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:l.length}]),h="",m=12+l.length*4;for(let b=0;b<l.length;++b){let w=h.indexOf(l[b]);w<0&&(w=h.length,h+=l[b]),d.fields.push({name:"offset "+b,type:"USHORT",value:m+w}),d.fields.push({name:"length "+b,type:"USHORT",value:l[b].length})}return d.fields.push({name:"stringPool",type:"CHARARRAY",value:h}),d}function Fr(l,d){let h=new Ne.Parser(l,d),m=h.parseULong();re.argument(m===1,"Unsupported ltag table version."),h.skip("uLong",1);let b=h.parseULong(),w=[];for(let _=0;_<b;_++){let I="",R=d+h.parseUShort(),z=h.parseUShort();for(let O=R;O<R+z;++O)I+=String.fromCharCode(l.getInt8(O));w.push(I)}return w}var ps={make:ir,parse:Fr};function cr(l,d){let h={},m=new Ne.Parser(l,d);return h.version=m.parseVersion(),h.numGlyphs=m.parseUShort(),h.version===1&&(h.maxPoints=m.parseUShort(),h.maxContours=m.parseUShort(),h.maxCompositePoints=m.parseUShort(),h.maxCompositeContours=m.parseUShort(),h.maxZones=m.parseUShort(),h.maxTwilightPoints=m.parseUShort(),h.maxStorage=m.parseUShort(),h.maxFunctionDefs=m.parseUShort(),h.maxInstructionDefs=m.parseUShort(),h.maxStackElements=m.parseUShort(),h.maxSizeOfInstructions=m.parseUShort(),h.maxComponentElements=m.parseUShort(),h.maxComponentDepth=m.parseUShort()),h}function rs(l){return new Ve.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:l}])}var _t={parse:cr,make:rs},xs=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function Go(l){for(let d=0;d<xs.length;d+=1){let h=xs[d];if(l>=h.begin&&l<h.end)return d}return-1}function Ia(l,d){let h={},m=new Ne.Parser(l,d);h.version=m.parseUShort(),h.xAvgCharWidth=m.parseShort(),h.usWeightClass=m.parseUShort(),h.usWidthClass=m.parseUShort(),h.fsType=m.parseUShort(),h.ySubscriptXSize=m.parseShort(),h.ySubscriptYSize=m.parseShort(),h.ySubscriptXOffset=m.parseShort(),h.ySubscriptYOffset=m.parseShort(),h.ySuperscriptXSize=m.parseShort(),h.ySuperscriptYSize=m.parseShort(),h.ySuperscriptXOffset=m.parseShort(),h.ySuperscriptYOffset=m.parseShort(),h.yStrikeoutSize=m.parseShort(),h.yStrikeoutPosition=m.parseShort(),h.sFamilyClass=m.parseShort(),h.panose=[];for(let b=0;b<10;b++)h.panose[b]=m.parseByte();return h.ulUnicodeRange1=m.parseULong(),h.ulUnicodeRange2=m.parseULong(),h.ulUnicodeRange3=m.parseULong(),h.ulUnicodeRange4=m.parseULong(),h.achVendID=String.fromCharCode(m.parseByte(),m.parseByte(),m.parseByte(),m.parseByte()),h.fsSelection=m.parseUShort(),h.usFirstCharIndex=m.parseUShort(),h.usLastCharIndex=m.parseUShort(),h.sTypoAscender=m.parseShort(),h.sTypoDescender=m.parseShort(),h.sTypoLineGap=m.parseShort(),h.usWinAscent=m.parseUShort(),h.usWinDescent=m.parseUShort(),h.version>=1&&(h.ulCodePageRange1=m.parseULong(),h.ulCodePageRange2=m.parseULong()),h.version>=2&&(h.sxHeight=m.parseShort(),h.sCapHeight=m.parseShort(),h.usDefaultChar=m.parseUShort(),h.usBreakChar=m.parseUShort(),h.usMaxContent=m.parseUShort()),h}function ws(l){return new Ve.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],l)}var oo={parse:Ia,make:ws,unicodeRanges:xs,getUnicodeRange:Go};function Ie(l,d){let h={},m=new Ne.Parser(l,d);switch(h.version=m.parseVersion(),h.italicAngle=m.parseFixed(),h.underlinePosition=m.parseShort(),h.underlineThickness=m.parseShort(),h.isFixedPitch=m.parseULong(),h.minMemType42=m.parseULong(),h.maxMemType42=m.parseULong(),h.minMemType1=m.parseULong(),h.maxMemType1=m.parseULong(),h.version){case 1:h.names=Kt.slice();break;case 2:h.numberOfGlyphs=m.parseUShort(),h.glyphNameIndex=new Array(h.numberOfGlyphs);for(let b=0;b<h.numberOfGlyphs;b++)h.glyphNameIndex[b]=m.parseUShort();h.names=[];for(let b=0;b<h.numberOfGlyphs;b++)if(h.glyphNameIndex[b]>=Kt.length){let w=m.parseChar();h.names.push(m.parseString(w))}break;case 2.5:h.numberOfGlyphs=m.parseUShort(),h.offset=new Array(h.numberOfGlyphs);for(let b=0;b<h.numberOfGlyphs;b++)h.offset[b]=m.parseChar();break}return h}function Wo(l){let{italicAngle:d=Math.round((l.italicAngle||0)*65536),underlinePosition:h=0,underlineThickness:m=0,isFixedPitch:b=0,minMemType42:w=0,maxMemType42:_=0,minMemType1:I=0,maxMemType1:R=0}=l.tables.post||{};return new Ve.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:d},{name:"underlinePosition",type:"FWORD",value:h},{name:"underlineThickness",type:"FWORD",value:m},{name:"isFixedPitch",type:"ULONG",value:b},{name:"minMemType42",type:"ULONG",value:w},{name:"maxMemType42",type:"ULONG",value:_},{name:"minMemType1",type:"ULONG",value:I},{name:"maxMemType1",type:"ULONG",value:R}])}var kl={parse:Ie,make:Wo},Ks=new Array(9);Ks[1]=function(){let l=this.offset+this.relativeOffset,d=this.parseUShort();if(d===1)return{substFormat:1,coverage:this.parsePointer(te.coverage),deltaGlyphId:this.parseShort()};if(d===2)return{substFormat:2,coverage:this.parsePointer(te.coverage),substitute:this.parseOffset16List()};re.assert(!1,"0x"+l.toString(16)+": lookup type 1 format must be 1 or 2.")},Ks[2]=function(){let l=this.parseUShort();return re.argument(l===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:l,coverage:this.parsePointer(te.coverage),sequences:this.parseListOfLists()}},Ks[3]=function(){let l=this.parseUShort();return re.argument(l===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:l,coverage:this.parsePointer(te.coverage),alternateSets:this.parseListOfLists()}},Ks[4]=function(){let l=this.parseUShort();return re.argument(l===1,"GSUB ligature table identifier-format must be 1"),{substFormat:l,coverage:this.parsePointer(te.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Ci={sequenceIndex:te.uShort,lookupListIndex:te.uShort};Ks[5]=function(){let l=this.offset+this.relativeOffset,d=this.parseUShort();if(d===1)return{substFormat:d,coverage:this.parsePointer(te.coverage),ruleSets:this.parseListOfLists(function(){let h=this.parseUShort(),m=this.parseUShort();return{input:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(m,Ci)}})};if(d===2)return{substFormat:d,coverage:this.parsePointer(te.coverage),classDef:this.parsePointer(te.classDef),classSets:this.parseListOfLists(function(){let h=this.parseUShort(),m=this.parseUShort();return{classes:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(m,Ci)}})};if(d===3){let h=this.parseUShort(),m=this.parseUShort();return{substFormat:d,coverages:this.parseList(h,te.pointer(te.coverage)),lookupRecords:this.parseRecordList(m,Ci)}}re.assert(!1,"0x"+l.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Ks[6]=function(){let l=this.offset+this.relativeOffset,d=this.parseUShort();if(d===1)return{substFormat:1,coverage:this.parsePointer(te.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ci)}})};if(d===2)return{substFormat:2,coverage:this.parsePointer(te.coverage),backtrackClassDef:this.parsePointer(te.classDef),inputClassDef:this.parsePointer(te.classDef),lookaheadClassDef:this.parsePointer(te.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ci)}})};if(d===3)return{substFormat:3,backtrackCoverage:this.parseList(te.pointer(te.coverage)),inputCoverage:this.parseList(te.pointer(te.coverage)),lookaheadCoverage:this.parseList(te.pointer(te.coverage)),lookupRecords:this.parseRecordList(Ci)};re.assert(!1,"0x"+l.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Ks[7]=function(){let l=this.parseUShort();re.argument(l===1,"GSUB Extension Substitution subtable identifier-format must be 1");let d=this.parseUShort(),h=new te(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:d,extension:Ks[d].call(h)}},Ks[8]=function(){let l=this.parseUShort();return re.argument(l===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:l,coverage:this.parsePointer(te.coverage),backtrackCoverage:this.parseList(te.pointer(te.coverage)),lookaheadCoverage:this.parseList(te.pointer(te.coverage)),substitutes:this.parseUShortList()}};function zs(l,d){d=d||0;let h=new te(l,d),m=h.parseVersion(1);return re.argument(m===1||m===1.1,"Unsupported GSUB table version."),m===1?{version:m,scripts:h.parseScriptList(),features:h.parseFeatureList(),lookups:h.parseLookupList(Ks)}:{version:m,scripts:h.parseScriptList(),features:h.parseFeatureList(),lookups:h.parseLookupList(Ks),variations:h.parseFeatureVariationsList()}}var Yr=new Array(9);Yr[1]=function(l){if(l.substFormat===1)return new Ve.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)},{name:"deltaGlyphID",type:"SHORT",value:l.deltaGlyphId}]);if(l.substFormat===2)return new Ve.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)}].concat(Ve.ushortList("substitute",l.substitute)));re.fail("Lookup type 1 substFormat must be 1 or 2.")},Yr[2]=function(l){return re.assert(l.substFormat===1,"Lookup type 2 substFormat must be 1."),new Ve.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)}].concat(Ve.tableList("seqSet",l.sequences,function(d){return new Ve.Table("sequenceSetTable",Ve.ushortList("sequence",d))})))},Yr[3]=function(l){return re.assert(l.substFormat===1,"Lookup type 3 substFormat must be 1."),new Ve.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)}].concat(Ve.tableList("altSet",l.alternateSets,function(d){return new Ve.Table("alternateSetTable",Ve.ushortList("alternate",d))})))},Yr[4]=function(l){return re.assert(l.substFormat===1,"Lookup type 4 substFormat must be 1."),new Ve.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)}].concat(Ve.tableList("ligSet",l.ligatureSets,function(d){return new Ve.Table("ligatureSetTable",Ve.tableList("ligature",d,function(h){return new Ve.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:h.ligGlyph}].concat(Ve.ushortList("component",h.components,h.components.length+1)))}))})))},Yr[5]=function(l){if(l.substFormat===1)return new Ve.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:l.substFormat},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)}].concat(Ve.tableList("sequenceRuleSet",l.ruleSets,function(d){return d?new Ve.Table("sequenceRuleSetTable",Ve.tableList("sequenceRule",d,function(h){let m=Ve.ushortList("seqLookup",[],h.lookupRecords.length).concat(Ve.ushortList("inputSequence",h.input,h.input.length+1));[m[0],m[1]]=[m[1],m[0]];for(let b=0;b<h.lookupRecords.length;b++){let w=h.lookupRecords[b];m=m.concat({name:"sequenceIndex"+b,type:"USHORT",value:w.sequenceIndex}).concat({name:"lookupListIndex"+b,type:"USHORT",value:w.lookupListIndex})}return new Ve.Table("sequenceRuleTable",m)})):new Ve.Table("NULL",null)})));if(l.substFormat===2)return new Ve.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:l.substFormat},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)},{name:"classDef",type:"TABLE",value:new Ve.ClassDef(l.classDef)}].concat(Ve.tableList("classSeqRuleSet",l.classSets,function(d){return d?new Ve.Table("classSeqRuleSetTable",Ve.tableList("classSeqRule",d,function(h){let m=Ve.ushortList("classes",h.classes,h.classes.length+1).concat(Ve.ushortList("seqLookupCount",[],h.lookupRecords.length));for(let b=0;b<h.lookupRecords.length;b++){let w=h.lookupRecords[b];m=m.concat({name:"sequenceIndex"+b,type:"USHORT",value:w.sequenceIndex}).concat({name:"lookupListIndex"+b,type:"USHORT",value:w.lookupListIndex})}return new Ve.Table("classSeqRuleTable",m)})):new Ve.Table("NULL",null)})));if(l.substFormat===3){let d=[{name:"substFormat",type:"USHORT",value:l.substFormat}];d.push({name:"inputGlyphCount",type:"USHORT",value:l.coverages.length}),d.push({name:"substitutionCount",type:"USHORT",value:l.lookupRecords.length});for(let h=0;h<l.coverages.length;h++){let m=l.coverages[h];d.push({name:"inputCoverage"+h,type:"TABLE",value:new Ve.Coverage(m)})}for(let h=0;h<l.lookupRecords.length;h++){let m=l.lookupRecords[h];d=d.concat({name:"sequenceIndex"+h,type:"USHORT",value:m.sequenceIndex}).concat({name:"lookupListIndex"+h,type:"USHORT",value:m.lookupListIndex})}return new Ve.Table("contextualSubstitutionTable",d)}re.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},Yr[6]=function(l){if(l.substFormat===1)return new Ve.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:l.substFormat},{name:"coverage",type:"TABLE",value:new Ve.Coverage(l.coverage)}].concat(Ve.tableList("chainRuleSet",l.chainRuleSets,function(d){return new Ve.Table("chainRuleSetTable",Ve.tableList("chainRule",d,function(h){let m=Ve.ushortList("backtrackGlyph",h.backtrack,h.backtrack.length).concat(Ve.ushortList("inputGlyph",h.input,h.input.length+1)).concat(Ve.ushortList("lookaheadGlyph",h.lookahead,h.lookahead.length)).concat(Ve.ushortList("substitution",[],h.lookupRecords.length));for(let b=0;b<h.lookupRecords.length;b++){let w=h.lookupRecords[b];m=m.concat({name:"sequenceIndex"+b,type:"USHORT",value:w.sequenceIndex}).concat({name:"lookupListIndex"+b,type:"USHORT",value:w.lookupListIndex})}return new Ve.Table("chainRuleTable",m)}))})));if(l.substFormat===2)re.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(l.substFormat===3){let d=[{name:"substFormat",type:"USHORT",value:l.substFormat}];d.push({name:"backtrackGlyphCount",type:"USHORT",value:l.backtrackCoverage.length});for(let h=0;h<l.backtrackCoverage.length;h++){let m=l.backtrackCoverage[h];d.push({name:"backtrackCoverage"+h,type:"TABLE",value:new Ve.Coverage(m)})}d.push({name:"inputGlyphCount",type:"USHORT",value:l.inputCoverage.length});for(let h=0;h<l.inputCoverage.length;h++){let m=l.inputCoverage[h];d.push({name:"inputCoverage"+h,type:"TABLE",value:new Ve.Coverage(m)})}d.push({name:"lookaheadGlyphCount",type:"USHORT",value:l.lookaheadCoverage.length});for(let h=0;h<l.lookaheadCoverage.length;h++){let m=l.lookaheadCoverage[h];d.push({name:"lookaheadCoverage"+h,type:"TABLE",value:new Ve.Coverage(m)})}d.push({name:"substitutionCount",type:"USHORT",value:l.lookupRecords.length});for(let h=0;h<l.lookupRecords.length;h++){let m=l.lookupRecords[h];d=d.concat({name:"sequenceIndex"+h,type:"USHORT",value:m.sequenceIndex}).concat({name:"lookupListIndex"+h,type:"USHORT",value:m.lookupListIndex})}return new Ve.Table("chainContextTable",d)}re.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Eo(l){return new Ve.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Ve.ScriptList(l.scripts)},{name:"features",type:"TABLE",value:new Ve.FeatureList(l.features)},{name:"lookups",type:"TABLE",value:new Ve.LookupList(l.lookups,Yr)}])}var ri={parse:zs,make:Eo};function es(l,d){let h=new Ne.Parser(l,d),m=h.parseULong();re.argument(m===1,"Unsupported META table version."),h.parseULong(),h.parseULong();let b=h.parseULong(),w={};for(let _=0;_<b;_++){let I=h.parseTag(),R=h.parseULong(),z=h.parseULong();if(I==="appl"||I==="bild")continue;let O=Ke.UTF8(l,d+R,z);w[I]=O}return w}function ss(l){let d=Object.keys(l).length,h="",m=16+d*12,b=new Ve.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:m},{name:"numTags",type:"ULONG",value:d}]);for(let w in l){let _=h.length;h+=l[w],b.fields.push({name:"tag "+w,type:"TAG",value:w}),b.fields.push({name:"offset "+w,type:"ULONG",value:m+_}),b.fields.push({name:"length "+w,type:"ULONG",value:l[w].length})}return b.fields.push({name:"stringPool",type:"CHARARRAY",value:h}),b}var B={parse:es,make:ss};function Y(l,d){let h=new te(l,d),m=h.parseUShort();m!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");let b=h.parseUShort(),w=h.parseOffset32(),_=h.parseOffset32(),I=h.parseUShort();h.relativeOffset=w;let R=h.parseRecordList(b,{glyphID:te.uShort,firstLayerIndex:te.uShort,numLayers:te.uShort});h.relativeOffset=_;let z=h.parseRecordList(I,{glyphID:te.uShort,paletteIndex:te.uShort});return{version:m,baseGlyphRecords:R,layerRecords:z}}function q({version:l=0,baseGlyphRecords:d=[],layerRecords:h=[]}){re.argument(l===0,"Only COLRv0 supported.");let m=14,b=m+d.length*6;return new Ve.Table("COLR",[{name:"version",type:"USHORT",value:l},{name:"numBaseGlyphRecords",type:"USHORT",value:d.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:m},{name:"layerRecordsOffset",type:"ULONG",value:b},{name:"numLayerRecords",type:"USHORT",value:h.length},...d.map((w,_)=>[{name:"glyphID_"+_,type:"USHORT",value:w.glyphID},{name:"firstLayerIndex_"+_,type:"USHORT",value:w.firstLayerIndex},{name:"numLayers_"+_,type:"USHORT",value:w.numLayers}]).flat(),...h.map((w,_)=>[{name:"LayerGlyphID_"+_,type:"USHORT",value:w.glyphID},{name:"paletteIndex_"+_,type:"USHORT",value:w.paletteIndex}]).flat()])}var ce={parse:Y,make:q};function ot(l,d){return[{name:"tag_"+l,type:"TAG",value:d.tag},{name:"minValue_"+l,type:"FIXED",value:d.minValue<<16},{name:"defaultValue_"+l,type:"FIXED",value:d.defaultValue<<16},{name:"maxValue_"+l,type:"FIXED",value:d.maxValue<<16},{name:"flags_"+l,type:"USHORT",value:0},{name:"nameID_"+l,type:"USHORT",value:d.axisNameID}]}function nt(l,d,h){let m={},b=new Ne.Parser(l,d);m.tag=b.parseTag(),m.minValue=b.parseFixed(),m.defaultValue=b.parseFixed(),m.maxValue=b.parseFixed(),b.skip("uShort",1);let w=b.parseUShort();return m.axisNameID=w,m.name=hn(h,w),m}function xt(l,d,h,m={}){let b=[{name:"nameID_"+l,type:"USHORT",value:d.subfamilyNameID},{name:"flags_"+l,type:"USHORT",value:0}];for(let w=0;w<h.length;++w){let _=h[w].tag;b.push({name:"axis_"+l+" "+_,type:"FIXED",value:d.coordinates[_]<<16})}return m&&m.postScriptNameID&&b.push({name:"postScriptNameID_",type:"USHORT",value:d.postScriptNameID!==void 0?d.postScriptNameID:65535}),b}function zt(l,d,h,m,b){let w={},_=new Ne.Parser(l,d),I=_.parseUShort();w.subfamilyNameID=I,w.name=hn(m,I,[2,17]),_.skip("uShort",1),w.coordinates={};for(let z=0;z<h.length;++z)w.coordinates[h[z].tag]=_.parseFixed();if(_.relativeOffset===b)return w.postScriptNameID=void 0,w.postScriptName=void 0,w;let R=_.parseUShort();return w.postScriptNameID=R==65535?void 0:R,w.postScriptName=w.postScriptNameID!==void 0?hn(m,R,[6]):"",w}function St(l,d){let h=new Ve.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:l.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:l.instances.length},{name:"instanceSize",type:"USHORT",value:4+l.axes.length*4}]);h.offsetToData=h.sizeOf();for(let b=0;b<l.axes.length;b++)h.fields=h.fields.concat(ot(b,l.axes[b],d));let m={};for(let b=0;b<l.instances.length;b++)if(l.instances[b].postScriptNameID!==void 0){h.instanceSize+=2,m.postScriptNameID=!0;break}for(let b=0;b<l.instances.length;b++)h.fields=h.fields.concat(xt(b,l.instances[b],l.axes,m));return h}function Yt(l,d,h){let m=new Ne.Parser(l,d),b=m.parseULong();re.argument(b===65536,"Unsupported fvar table version.");let w=m.parseOffset16();m.skip("uShort",1);let _=m.parseUShort(),I=m.parseUShort(),R=m.parseUShort(),z=m.parseUShort(),O=[];for(let _e=0;_e<_;_e++)O.push(nt(l,d+w+_e*I,h));let se=[],ne=d+w+_*I;for(let _e=0;_e<R;_e++)se.push(zt(l,ne+_e*z,O,h,z));return{axes:O,instances:se}}var xr={make:St,parse:Yt},jr={tag:te.tag,nameID:te.uShort,ordering:te.uShort},is=new Array(5);is[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},is[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},is[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},is[4]=function(){let l=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(l,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function fs(){let l=this.parseUShort(),d=is[l],h={format:l};return d===void 0?(console.warn(`Unknown axis value table format ${l}`),h):Object.assign(h,this.parseStruct(d.bind(this)))}function si(l,d,h){d||(d=0);let m=new Ne.Parser(l,d),b=m.parseUShort(),w=m.parseUShort();b!==1&&console.warn(`Unsupported STAT table version ${b}.${w}`);let _=[b,w],I=m.parseUShort(),R=m.parseUShort(),z=m.parseOffset32(),O=m.parseUShort(),se=m.parseOffset32(),ne=b>1||w>0?m.parseUShort():void 0;h!==void 0&&re.argument(R>=h.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),O>0&&re.argument(R>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let _e=[];for(let dt=0;dt<R;dt++)m.offset=d+z,m.relativeOffset=dt*I,_e.push(m.parseStruct(jr));m.offset=d,m.relativeOffset=se;let xe=m.parseUShortList(O),Be=[];for(let dt=0;dt<O;dt++)m.offset=d+se,m.relativeOffset=xe[dt],Be.push(fs.apply(m));return{version:_,axes:_e,values:Be,elidedFallbackNameID:ne}}var En=new Array(5);En[1]=function(l,d){return[{name:`format${l}`,type:"USHORT",value:1},{name:`axisIndex${l}`,type:"USHORT",value:d.axisIndex},{name:`flags${l}`,type:"USHORT",value:d.flags},{name:`valueNameID${l}`,type:"USHORT",value:d.valueNameID},{name:`value${l}`,type:"FLOAT",value:d.value}]},En[2]=function(l,d){return[{name:`format${l}`,type:"USHORT",value:2},{name:`axisIndex${l}`,type:"USHORT",value:d.axisIndex},{name:`flags${l}`,type:"USHORT",value:d.flags},{name:`valueNameID${l}`,type:"USHORT",value:d.valueNameID},{name:`nominalValue${l}`,type:"FLOAT",value:d.nominalValue},{name:`rangeMinValue${l}`,type:"FLOAT",value:d.rangeMinValue},{name:`rangeMaxValue${l}`,type:"FLOAT",value:d.rangeMaxValue}]},En[3]=function(l,d){return[{name:`format${l}`,type:"USHORT",value:3},{name:`axisIndex${l}`,type:"USHORT",value:d.axisIndex},{name:`flags${l}`,type:"USHORT",value:d.flags},{name:`valueNameID${l}`,type:"USHORT",value:d.valueNameID},{name:`value${l}`,type:"FLOAT",value:d.value},{name:`linkedValue${l}`,type:"FLOAT",value:d.linkedValue}]},En[4]=function(l,d){let h=[{name:`format${l}`,type:"USHORT",value:4},{name:`axisCount${l}`,type:"USHORT",value:d.axisValues.length},{name:`flags${l}`,type:"USHORT",value:d.flags},{name:`valueNameID${l}`,type:"USHORT",value:d.valueNameID}];for(let m=0;m<d.axisValues.length;m++)h=h.concat([{name:`format${l}axisIndex${m}`,type:"USHORT",value:d.axisValues[m].axisIndex},{name:`format${l}value${m}`,type:"FLOAT",value:d.axisValues[m].value}]);return h};function Vn(l,d){return new Ve.Record("axisRecord_"+l,[{name:"axisTag_"+l,type:"TAG",value:d.tag},{name:"axisNameID_"+l,type:"USHORT",value:d.nameID},{name:"axisOrdering_"+l,type:"USHORT",value:d.ordering}])}function ki(l,d){let h=d.format,m=En[h];re.argument(m!==void 0,`Unknown axis value table format ${h}`);let b=m(l,d);return new Ve.Table("axisValueTable_"+l,b)}function un(l){let d=new Ve.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:l.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:l.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:l.elidedFallbackNameID}]);d.designAxesOffset=d.offsetToAxisValueOffsets=d.sizeOf();for(let w=0;w<l.axes.length;w++){let _=Vn(w,l.axes[w]);d.offsetToAxisValueOffsets+=_.sizeOf(),d.fields=d.fields.concat(_.fields)}let h=[],m=[],b=l.values.length*2;for(let w=0;w<l.values.length;w++){let _=ki(w,l.values[w]);h.push({name:"offset_"+w,type:"USHORT",value:b}),b+=_.sizeOf(),m=m.concat(_.fields)}return d.fields=d.fields.concat(h),d.fields=d.fields.concat(m),d}var _l={make:un,parse:si};function Dr(l,d){return new Ve.Record("axisValueMap_"+l,[{name:"fromCoordinate_"+l,type:"F2DOT14",value:d.fromCoordinate},{name:"toCoordinate_"+l,type:"F2DOT14",value:d.toCoordinate}])}function Ll(l,d){let h=new Ve.Record("segmentMap_"+l,[{name:"positionMapCount_"+l,type:"USHORT",value:d.axisValueMaps.length}]),m=[];for(let b=0;b<d.axisValueMaps.length;b++){let w=Dr(`${l}_${b}`,d.axisValueMaps[b]);m=m.concat(w.fields)}return h.fields=h.fields.concat(m),h}function Rs(l,d){re.argument(l.axisSegmentMaps.length===d.axes.length,"avar axis count must correspond to fvar axis count");let h=new Ve.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:l.axisSegmentMaps.length}]);for(let m=0;m<l.axisSegmentMaps.length;m++){let b=Ll(m,l.axisSegmentMaps[m]);h.fields=h.fields.concat(b.fields)}return h}function ii(l,d,h){d||(d=0);let m=new te(l,d),b=m.parseUShort(),w=m.parseUShort();b!==1&&console.warn(`Unsupported avar table version ${b}.${w}`),m.skip("uShort",1);let _=m.parseUShort();re.argument(_===h.axes.length,"avar axis count must correspond to fvar axis count");let I=[];for(let R=0;R<_;R++){let z=[],O=m.parseUShort();for(let se=0;se<O;se++){let ne=m.parseF2Dot14(),_e=m.parseF2Dot14();z.push({fromCoordinate:ne,toCoordinate:_e})}I.push({axisValueMaps:z})}return{version:[b,w],axisSegmentMaps:I}}var Io={make:Rs,parse:ii};function gi(l,d,h,m){let b=new Ne.Parser(l,d),w=b.parseTupleVariationStore(b.relativeOffset,h.axes.length,"cvar",m),_=b.parseUShort(),I=b.parseUShort();return _!==1&&console.warn(`Unsupported cvar table version ${_}.${I}`),{version:[_,I],...w}}function Ja(){console.warn("Writing of cvar tables is not yet supported.")}var fa={make:Ja,parse:gi};function el(l,d,h,m){let b=new Ne.Parser(l,d),w=b.parseUShort(),_=b.parseUShort();w!==1&&console.warn(`Unsupported gvar table version ${w}.${_}`);let I=b.parseUShort();I!==h.axes.length&&console.warn(`axisCount ${I} in gvar table does not match the number of axes ${h.axes.length} in the fvar table!`);let R=b.parseUShort(),z=b.parsePointer32(function(){return this.parseTupleRecords(R,I)}),O=b.parseTupleVariationStoreList(I,"gvar",m);return{version:[w,_],sharedTuples:z,glyphVariations:O}}function Wc(){console.warn("Writing of gvar tables is not yet supported.")}var Ro={make:Wc,parse:el};function Ra(l,d){let h={},m=new Ne.Parser(l,d);h.version=m.parseUShort(),re.argument(h.version<=1,"Unsupported gasp table version."),h.numRanges=m.parseUShort(),h.gaspRanges=[];for(let b=0;b<h.numRanges;b++)h.gaspRanges[b]={rangeMaxPPEM:m.parseUShort(),rangeGaspBehavior:m.parseUShort()};return h}function Fi(l){let d=new Ve.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:l.numRanges}]);for(let h in l.gaspRanges)d.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:l.gaspRanges[h].rangeMaxPPEM}),d.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:l.gaspRanges[h].rangeGaspBehavior});return d}var Wl={parse:Ra,make:Fi};function No(l,d){let h=new Map,m=l.buffer,b=new te(l,d);if(b.parseUShort()!==0)return h;b.relativeOffset=b.parseOffset32();let w=l.byteOffset+d+b.relativeOffset,_=b.parseUShort(),I=new Map;for(let R=0;R<_;R++){let z=b.parseUShort(),O=b.parseUShort(),se=w+b.parseOffset32(),ne=b.parseULong(),_e=I.get(se);_e===void 0&&(_e=new Uint8Array(m,se,ne),I.set(se,_e));for(let xe=z;xe<=O;xe++)h.set(xe,_e)}return h}function ha(l){let d=Array.from(l.keys()).sort(),h=[],m=[],b=new Map,w=0,_={endGlyphID:null};for(let ne=0,_e=d.length;ne<_e;ne++){let xe=d[ne],Be=l.get(xe),dt=b.get(Be);dt===void 0&&(dt=w,m.push(Be),b.set(Be,dt),w+=Be.byteLength),xe-1===_.endGlyphID&&dt===_.svgDocOffset?_.endGlyphID=xe:(_={startGlyphID:xe,endGlyphID:xe,svgDocOffset:dt,svgDocLength:Be.byteLength},h.push(_))}let I=h.length,R=m.length,z=2+I*12,O=new Array(4+I*4+R),se=0;O[se++]={name:"version",type:"USHORT",value:0},O[se++]={name:"svgDocumentListOffset",type:"ULONG",value:10},O[se++]={name:"reserved",type:"ULONG",value:0},O[se++]={name:"numEntries",type:"USHORT",value:I};for(let ne=0;ne<I;ne++){let _e="documentRecord_"+ne,{startGlyphID:xe,endGlyphID:Be,svgDocOffset:dt,svgDocLength:Dn}=h[ne];O[se++]={name:_e+"_startGlyphID",type:"USHORT",value:xe},O[se++]={name:_e+"_endGlyphID",type:"USHORT",value:Be},O[se++]={name:_e+"_svgDocOffset",type:"ULONG",value:z+dt},O[se++]={name:_e+"_svgDocLength",type:"ULONG",value:Dn}}for(let ne=0;ne<R;ne++)O[se++]={name:"svgDoc_"+ne,type:"LITERAL",value:m[ne]};return new Ve.Table("SVG ",O)}var Na={make:ha,parse:No};function El(l){return Math.log(l)/Math.log(2)|0}function xi(l){for(;l.length%4!==0;)l.push(0);let d=0;for(let h=0;h<l.length;h+=4)d+=(l[h]<<24)+(l[h+1]<<16)+(l[h+2]<<8)+l[h+3];return d%=Math.pow(2,32),d}function oi(l,d,h,m){return new Ve.Record("Table Record",[{name:"tag",type:"TAG",value:l!==void 0?l:""},{name:"checkSum",type:"ULONG",value:d!==void 0?d:0},{name:"offset",type:"ULONG",value:h!==void 0?h:0},{name:"length",type:"ULONG",value:m!==void 0?m:0}])}function Ma(l){let d=new Ve.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);d.tables=l,d.numTables=l.length;let h=Math.pow(2,El(d.numTables));d.searchRange=16*h,d.entrySelector=El(h),d.rangeShift=d.numTables*16-d.searchRange;let m=[],b=[],w=d.sizeOf()+oi().sizeOf()*d.numTables;for(;w%4!==0;)w+=1,b.push({name:"padding",type:"BYTE",value:0});for(let _=0;_<l.length;_+=1){let I=l[_];re.argument(I.tableName.length===4,"Table name"+I.tableName+" is invalid.");let R=I.sizeOf(),z=oi(I.tableName,xi(I.encode()),w,R);for(m.push({name:z.tag+" Table Record",type:"RECORD",value:z}),b.push({name:I.tableName+" table",type:"RECORD",value:I}),w+=R,re.argument(!isNaN(w),"Something went wrong calculating the offset.");w%4!==0;)w+=1,b.push({name:"padding",type:"BYTE",value:0})}return m.sort(function(_,I){return _.value.tag>I.value.tag?1:-1}),d.fields=d.fields.concat(m),d.fields=d.fields.concat(b),d}function Vc(l,d,h){for(let m=0;m<d.length;m+=1){let b=l.charToGlyphIndex(d[m]);if(b>0)return l.glyphs.get(b).getMetrics()}return h}function ao(l){let d=0;for(let h=0;h<l.length;h+=1)d+=l[h];return d/l.length}function Ac(l){let d=[],h=[],m=[],b=[],w=[],_=[],I=[],R,z=0,O=0,se=0,ne=0,_e=0;for(let ys=0;ys<l.glyphs.length;ys+=1){let ba=l.glyphs.get(ys),ll=ba.unicode|0;if(isNaN(ba.advanceWidth))throw new Error("Glyph "+ba.name+" ("+ys+"): advanceWidth is not a number.");(R>ll||R===void 0)&&ll>0&&(R=ll),z<ll&&(z=ll);let Fl=oo.getUnicodeRange(ll);if(Fl<32)O|=1<<Fl;else if(Fl<64)se|=1<<Fl-32;else if(Fl<96)ne|=1<<Fl-64;else if(Fl<123)_e|=1<<Fl-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(ba.name===".notdef")continue;let _c=ba.getMetrics();d.push(_c.xMin),h.push(_c.yMin),m.push(_c.xMax),b.push(_c.yMax),_.push(_c.leftSideBearing),I.push(_c.rightSideBearing),w.push(ba.advanceWidth)}let xe={xMin:Math.min.apply(null,d),yMin:Math.min.apply(null,h),xMax:Math.max.apply(null,m),yMax:Math.max.apply(null,b),advanceWidthMax:Math.max.apply(null,w),advanceWidthAvg:ao(w),minLeftSideBearing:Math.min.apply(null,_),maxLeftSideBearing:Math.max.apply(null,_),minRightSideBearing:Math.min.apply(null,I)};xe.ascender=l.ascender,xe.descender=l.descender;let Be=0;l.weightClass>=600&&(Be|=l.macStyleValues.BOLD),l.italicAngle<0&&(Be|=l.macStyleValues.ITALIC);let dt=Hs.make({flags:3,unitsPerEm:l.unitsPerEm,xMin:xe.xMin,yMin:xe.yMin,xMax:xe.xMax,yMax:xe.yMax,lowestRecPPEM:3,macStyle:Be,createdTimestamp:l.createdTimestamp}),Dn=De.make({ascender:xe.ascender,descender:xe.descender,advanceWidthMax:xe.advanceWidthMax,minLeftSideBearing:xe.minLeftSideBearing,minRightSideBearing:xe.minRightSideBearing,xMaxExtent:xe.maxLeftSideBearing+(xe.xMax-xe.xMin),numberOfHMetrics:l.glyphs.length}),An=_t.make(l.glyphs.length),Jn=oo.make(Object.assign({xAvgCharWidth:Math.round(xe.advanceWidthAvg),usFirstCharIndex:R,usLastCharIndex:z,ulUnicodeRange1:O,ulUnicodeRange2:se,ulUnicodeRange3:ne,ulUnicodeRange4:_e,sTypoAscender:xe.ascender,sTypoDescender:xe.descender,sTypoLineGap:0,usWinAscent:xe.yMax,usWinDescent:Math.abs(xe.yMin),ulCodePageRange1:1,sxHeight:Vc(l,"xyvw",{yMax:Math.round(xe.ascender/2)}).yMax,sCapHeight:Vc(l,"HIKLEFJMNTZBDPRAGOQSUVWXY",xe).yMax,usDefaultChar:l.hasChar(" ")?32:0,usBreakChar:l.hasChar(" ")?32:0},l.tables.os2)),Lr=kn.make(l.glyphs),ls=Me.make(l.glyphs),ms=l.getEnglishName("fontFamily"),gs=l.getEnglishName("fontSubfamily"),vi=ms+" "+gs,Pl=l.getEnglishName("postScriptName");Pl||(Pl=ms.replace(/\s/g,"")+"-"+gs);let Er={};for(let ys in l.names)Er[ys]=l.names[ys];Er.unicode=Er.unicode||{},Er.macintosh=Er.macintosh||{},Er.windows=Er.windows||{};let Oa=l.names.unicode||{},Jo=l.names.macintosh||{},jn=l.names.windows||{};for(let ys in Er){if(Er[ys]=Er[ys]||{},!Er[ys].uniqueID){let ba=l.getEnglishName("manufacturer")||"";Er[ys].uniqueID={en:`${ba}: ${vi}`}}Er[ys].postScriptName||(Er[ys].postScriptName={en:Pl})}Er.unicode.preferredFamily||(Er.unicode.preferredFamily=Oa.fontFamily||Jo.fontFamily||jn.fontFamily),Er.macintosh.preferredFamily||(Er.macintosh.preferredFamily=Jo.fontFamily||Oa.fontFamily||jn.fontFamily),Er.windows.preferredFamily||(Er.windows.preferredFamily=jn.fontFamily||Oa.fontFamily||Jo.fontFamily),Er.unicode.preferredSubfamily||(Er.unicode.preferredSubfamily=Oa.fontSubfamily||Jo.fontSubfamily||jn.fontSubfamily),Er.macintosh.preferredSubfamily||(Er.macintosh.preferredSubfamily=Jo.fontSubfamily||Oa.fontSubfamily||jn.fontSubfamily),Er.windows.preferredSubfamily||(Er.windows.preferredSubfamily=jn.fontSubfamily||Oa.fontSubfamily||Jo.fontSubfamily);let gn=[],Sn=Qn.make(Er,gn),Po=gn.length>0?ps.make(gn):void 0,eu=kl.make(l),Lp=io.make(l.glyphs,{version:l.getEnglishName("version"),fullName:vi,familyName:ms,weightName:gs,postScriptName:Pl,unitsPerEm:l.unitsPerEm,fontBBox:[0,xe.yMin,xe.ascender,xe.advanceWidthMax],topDict:l.tables.cff&&l.tables.cff.topDict||{}}),Nu=l.metas&&Object.keys(l.metas).length>0?B.make(l.metas):void 0,Bl=[dt,Dn,An,Jn,Sn,ls,eu,Lp,Lr];Po&&Bl.push(Po);let ea={gsub:ri,cpal:_n,colr:ce,stat:_l,avar:Io,cvar:fa,fvar:xr,gvar:Ro,gasp:Wl,svg:Na},al={avar:[l.tables.fvar],fvar:[l.names]};for(let ys in ea){let ba=l.tables[ys];if(ba){let ll=ea[ys].make.call(l,ba,...al[ys]||[]);ll&&Bl.push(ll)}}Nu&&Bl.push(Nu);let Bo=Ma(Bl),Qa=Bo.encode(),ta=xi(Qa),na=Bo.fields,di=!1;for(let ys=0;ys<na.length;ys+=1)if(na[ys].name==="head table"){na[ys].value.checkSumAdjustment=2981146554-ta,di=!0;break}if(!di)throw new Error("Could not find head table with checkSum to adjust.");return Bo}var Tc={make:Ma,fontToTable:Ac,computeCheckSum:xi};function Vl(l,d){let h=0,m=l.length-1;for(;h<=m;){let b=h+m>>>1,w=l[b].tag;if(w===d)return b;w<d?h=b+1:m=b-1}return-h-1}function ai(l,d){let h=0,m=l.length-1;for(;h<=m;){let b=h+m>>>1,w=l[b];if(w===d)return b;w<d?h=b+1:m=b-1}return-h-1}function lo(l,d){let h,m=0,b=l.length-1;for(;m<=b;){let w=m+b>>>1;h=l[w];let _=h.start;if(_===d)return h;_<d?m=w+1:b=w-1}if(m>0)return h=l[m-1],d>h.end?0:h}function Da(l,d){this.font=l,this.tableName=d}Da.prototype={searchTag:Vl,binSearch:ai,getTable:function(l){let d=this.font.tables[this.tableName];return!d&&l&&(d=this.font.tables[this.tableName]=this.createDefaultTable()),d},getScriptNames:function(){let l=this.getTable();return l?l.scripts.map(function(d){return d.tag}):[]},getDefaultScriptName:function(){let l=this.getTable();if(!l)return;let d=!1;for(let h=0;h<l.scripts.length;h++){let m=l.scripts[h].tag;if(m==="DFLT")return m;m==="latn"&&(d=!0)}if(d)return"latn"},getScriptTable:function(l,d){let h=this.getTable(d);if(h){l=l||"DFLT";let m=h.scripts,b=Vl(h.scripts,l);if(b>=0)return m[b].script;if(d){let w={tag:l,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return m.splice(-1-b,0,w),w.script}}},getLangSysTable:function(l,d,h){let m=this.getScriptTable(l,h);if(m){if(!d||d==="dflt"||d==="DFLT")return m.defaultLangSys;let b=Vl(m.langSysRecords,d);if(b>=0)return m.langSysRecords[b].langSys;if(h){let w={tag:d,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return m.langSysRecords.splice(-1-b,0,w),w.langSys}}},getFeatureTable:function(l,d,h,m){let b=this.getLangSysTable(l,d,m);if(b){let w,_=b.featureIndexes,I=this.font.tables[this.tableName].features;for(let R=0;R<_.length;R++)if(w=I[_[R]],w.tag===h)return w.feature;if(m){let R=I.length;return re.assert(R===0||h>=I[R-1].tag,"Features must be added in alphabetical order."),w={tag:h,feature:{params:0,lookupListIndexes:[]}},I.push(w),_.push(R),w.feature}}},getLookupTables:function(l,d,h,m,b){let w=this.getFeatureTable(l,d,h,b),_=[];if(w){let I,R=w.lookupListIndexes,z=this.font.tables[this.tableName].lookups;for(let O=0;O<R.length;O++)I=z[R[O]],I.lookupType===m&&_.push(I);if(_.length===0&&b){I={lookupType:m,lookupFlag:0,subtables:[],markFilteringSet:void 0};let O=z.length;return z.push(I),R.push(O),[I]}}return _},getGlyphClass:function(l,d){switch(l.format){case 1:return l.startGlyph<=d&&d<l.startGlyph+l.classes.length?l.classes[d-l.startGlyph]:0;case 2:{let h=lo(l.ranges,d);return h?h.classId:0}}},getCoverageIndex:function(l,d){switch(l.format){case 1:{let h=ai(l.glyphs,d);return h>=0?h:-1}case 2:{let h=lo(l.ranges,d);return h?h.index+d-h.start:-1}}},expandCoverage:function(l){if(l.format===1)return l.glyphs;{let d=[],h=l.ranges;for(let m=0;m<h.length;m++){let b=h[m],w=b.start,_=b.end;for(let I=w;I<=_;I++)d.push(I)}return d}}};var or=Da;function ql(l){or.call(this,l,"gpos")}ql.prototype=or.prototype,ql.prototype.init=function(){let l=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(l)},ql.prototype.getKerningValue=function(l,d,h){for(let m=0;m<l.length;m++){let b=l[m].subtables;for(let w=0;w<b.length;w++){let _=b[w],I=this.getCoverageIndex(_.coverage,d);if(!(I<0))switch(_.posFormat){case 1:{let R=_.pairSets[I];for(let z=0;z<R.length;z++){let O=R[z];if(O.secondGlyph===h)return O.value1&&O.value1.xAdvance||0}break}case 2:{let R=this.getGlyphClass(_.classDef1,d),z=this.getGlyphClass(_.classDef2,h),O=_.classRecords[R][z];return O.value1&&O.value1.xAdvance||0}}}}return 0},ql.prototype.getKerningTables=function(l,d){if(this.font.tables.gpos)return this.getLookupTables(l,d,"kern",2)};var Vo=ql;function pa(l,d){let h=l.length;if(h!==d.length)return!1;for(let m=0;m<h;m++)if(l[m]!==d[m])return!1;return!0}function co(l,d,h){let m=0,b=l.length-1,w=null;for(;m<=b;){let _=Math.floor((m+b)/2),I=l[_],R=I[d];if(R<h)m=_+1;else if(R>h)b=_-1;else{w=I;break}}return w}function q0(l,d,h){let m=0,b=l.length-1;for(;m<=b;){let w=Math.floor((m+b)/2),_=l[w];if(_[d]<h)m=w+1;else if(_[d]>h)b=w-1;else return w}return-1}function uo(l,d,h){let m=0,b=l.length,w=(_,I)=>_[d]-I[d];for(;m<b;){let _=m+b>>>1;w(l[_],h)<0?m=_+1:b=_}return l.splice(m,0,h),m}function Kl(l){return l[0]===31&&l[1]===139&&l[2]===8}function ja(l){let d=new DataView(l.buffer,l.byteOffset,l.byteLength),h=10,m=l.byteLength-8,b=d.getInt8(3);if(b&4&&(h+=2+d.getUint16(h,!0)),b&8)for(;h<m&&l[h++]!==0;);if(b&16)for(;h<m&&l[h++]!==0;);if(b&2&&(h+=2),h>=m)throw new Error("Can't find compressed blocks");let w=d.getUint32(d.byteLength-4,!0);return U(l.subarray(h,m),new Uint8Array(w))}function tl(l){return{x:l.x,y:l.y,onCurve:l.onCurve,lastPointOfContour:l.lastPointOfContour}}function Yl(l){return{glyphIndex:l.glyphIndex,xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:l.dx,dy:l.dy}}function bi(l){or.call(this,l,"gsub")}function qo(l,d,h){let m=l.subtables;for(let b=0;b<m.length;b++){let w=m[b];if(w.substFormat===d)return w}if(h)return m.push(h),h}bi.prototype=or.prototype,bi.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},bi.prototype.getSingle=function(l,d,h){let m=[],b=this.getLookupTables(d,h,l,1);for(let w=0;w<b.length;w++){let _=b[w].subtables;for(let I=0;I<_.length;I++){let R=_[I],z=this.expandCoverage(R.coverage),O;if(R.substFormat===1){let se=R.deltaGlyphId;for(O=0;O<z.length;O++){let ne=z[O];m.push({sub:ne,by:ne+se})}}else{let se=R.substitute;for(O=0;O<z.length;O++)m.push({sub:z[O],by:se[O]})}}}return m},bi.prototype.getMultiple=function(l,d,h){let m=[],b=this.getLookupTables(d,h,l,2);for(let w=0;w<b.length;w++){let _=b[w].subtables;for(let I=0;I<_.length;I++){let R=_[I],z=this.expandCoverage(R.coverage),O;for(O=0;O<z.length;O++){let se=z[O],ne=R.sequences[O];m.push({sub:se,by:ne})}}}return m},bi.prototype.getAlternates=function(l,d,h){let m=[],b=this.getLookupTables(d,h,l,3);for(let w=0;w<b.length;w++){let _=b[w].subtables;for(let I=0;I<_.length;I++){let R=_[I],z=this.expandCoverage(R.coverage),O=R.alternateSets;for(let se=0;se<z.length;se++)m.push({sub:z[se],by:O[se]})}}return m},bi.prototype.getLigatures=function(l,d,h){let m=[],b=this.getLookupTables(d,h,l,4);for(let w=0;w<b.length;w++){let _=b[w].subtables;for(let I=0;I<_.length;I++){let R=_[I],z=this.expandCoverage(R.coverage),O=R.ligatureSets;for(let se=0;se<z.length;se++){let ne=z[se],_e=O[se];for(let xe=0;xe<_e.length;xe++){let Be=_e[xe];m.push({sub:[ne].concat(Be.components),by:Be.ligGlyph})}}}}return m},bi.prototype.addSingle=function(l,d,h,m){let b=this.getLookupTables(h,m,l,1,!0)[0],w=qo(b,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});re.assert(w.coverage.format===1,"Single: unable to modify coverage table format "+w.coverage.format);let _=d.sub,I=this.binSearch(w.coverage.glyphs,_);I<0&&(I=-1-I,w.coverage.glyphs.splice(I,0,_),w.substitute.splice(I,0,0)),w.substitute[I]=d.by},bi.prototype.addMultiple=function(l,d,h,m){re.assert(d.by instanceof Array&&d.by.length>1,'Multiple: "by" must be an array of two or more ids');let b=this.getLookupTables(h,m,l,2,!0)[0],w=qo(b,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});re.assert(w.coverage.format===1,"Multiple: unable to modify coverage table format "+w.coverage.format);let _=d.sub,I=this.binSearch(w.coverage.glyphs,_);I<0&&(I=-1-I,w.coverage.glyphs.splice(I,0,_),w.sequences.splice(I,0,0)),w.sequences[I]=d.by},bi.prototype.addAlternate=function(l,d,h,m){let b=this.getLookupTables(h,m,l,3,!0)[0],w=qo(b,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});re.assert(w.coverage.format===1,"Alternate: unable to modify coverage table format "+w.coverage.format);let _=d.sub,I=this.binSearch(w.coverage.glyphs,_);I<0&&(I=-1-I,w.coverage.glyphs.splice(I,0,_),w.alternateSets.splice(I,0,0)),w.alternateSets[I]=d.by},bi.prototype.addLigature=function(l,d,h,m){let b=this.getLookupTables(h,m,l,4,!0)[0],w=b.subtables[0];w||(w={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},b.subtables[0]=w),re.assert(w.coverage.format===1,"Ligature: unable to modify coverage table format "+w.coverage.format);let _=d.sub[0],I=d.sub.slice(1),R={ligGlyph:d.by,components:I},z=this.binSearch(w.coverage.glyphs,_);if(z>=0){let O=w.ligatureSets[z];for(let se=0;se<O.length;se++)if(pa(O[se].components,I))return;O.push(R)}else z=-1-z,w.coverage.glyphs.splice(z,0,_),w.ligatureSets.splice(z,0,[R])},bi.prototype.getFeature=function(l,d,h){if(/ss\d\d/.test(l))return this.getSingle(l,d,h);switch(l){case"aalt":case"salt":return this.getSingle(l,d,h).concat(this.getAlternates(l,d,h));case"dlig":case"liga":case"rlig":return this.getLigatures(l,d,h);case"ccmp":return this.getMultiple(l,d,h).concat(this.getLigatures(l,d,h));case"stch":return this.getMultiple(l,d,h)}},bi.prototype.add=function(l,d,h,m){if(/ss\d\d/.test(l))return this.addSingle(l,d,h,m);switch(l){case"aalt":case"salt":return typeof d.by=="number"?this.addSingle(l,d,h,m):this.addAlternate(l,d,h,m);case"dlig":case"liga":case"rlig":return this.addLigature(l,d,h,m);case"ccmp":return d.by instanceof Array?this.addMultiple(l,d,h,m):this.addLigature(l,d,h,m)}};var Xl=bi,gd=class{constructor(l){this.defaultValue=255,this.font=l}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(l){let d=[],h=this.cpal();if(!h)return d;for(let m=0;m<h.colorRecordIndices.length;m++){let b=h.colorRecordIndices[m],w=[];for(let _=b;_<b+h.numPaletteEntries;_++)w.push(ln(h.colorRecords[_],l||"hexa"));d.push(w)}return d}toCPALcolor(l){return Array.isArray(l)?l.map(d=>Gt(d,"raw")):Gt(l,"raw")}fillPalette(l,d=[],h=this.cpal().numPaletteEntries){return l=Number.isInteger(l)?this.get(l,"raw"):l,Object.assign(Array(h).fill(this.defaultValue),this.toCPALcolor(l).concat(this.toCPALcolor(d)))}extend(l){if(this.ensureCPAL(Array(l).fill(this.defaultValue)))return;let d=this.cpal(),h=d.numPaletteEntries+l,m=this.getAll().map(b=>this.fillPalette(b,[],h));d.numPaletteEntries=h,d.colorRecords=this.toCPALcolor(m.flat()),this.updateIndices()}get(l,d="hexa"){return this.getAll(d)[l]||null}getColor(l,d=0,h="hexa"){return ke(this.font,l,d,h)}setColor(l,d,h=0){l=parseInt(l),h=parseInt(h);let m=this.getAll("raw"),b=m[h];if(!b)throw Error(`paletteIndex ${h} out of range`);let w=this.cpal(),_=w.numPaletteEntries;Array.isArray(d)||(d=[d]),d.length+l>_&&(this.extend(d.length+l-_),m=this.getAll("raw"),b=m[h]);for(let I=0;I<d.length;I++)b[I+l]=this.toCPALcolor(d[I]);w.colorRecords=m.flat(),this.updateIndices()}add(l){if(this.ensureCPAL(l))return;let d=this.cpal(),h=d.numPaletteEntries;l&&l.length?(l=this.toCPALcolor(l),l.length>h?this.extend(l.length-h):l.length<h&&(l=this.fillPalette(l)),d.colorRecordIndices.push(d.colorRecords.length),d.colorRecords.push(...l)):(d.colorRecordIndices.push(d.colorRecords.length),d.colorRecords.push(...Array(h).fill(this.defaultValue)))}delete(l){let d=this.getAll("raw");delete d[l];let h=this.cpal();h.colorRecordIndices.pop(),h.colorRecords=d.flat()}deleteColor(l,d){if(l===d)throw Error("replacementIndex cannot be the same as colorIndex");let h=this.cpal(),m=this.getAll("raw"),b=[];if(d>h.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${h.numPaletteEntries-1}, replacementIndex: ${d})`);for(let I=0;I<m.length;I++){let R=m[I].filter((z,O)=>O!==l);b.push(R)}let w=this.font.tables.colr;if(w){let I=w.layerRecords;for(let R=0;R<I.length;R++){let z=I[R].paletteIndex;if(z>l)I[R].paletteIndex-=1;else if(z===l){let O=0;for(let se=0;se<m.length;se++)if(d>l&&d<=l+m[se].length){O++;break}I[R].paletteIndex=d-O}}this.font.tables.colr={...w,layerRecords:I}}let _=b.flat();for(let I=0;I<m.length;I++)h.colorRecordIndices[I]-=I;h.numPaletteEntries=Math.max(0,h.numPaletteEntries-1),h.colorRecords=this.toCPALcolor(_)}ensureCPAL(l){return this.cpal()?!1:(!l||!l.length?l=[this.defaultValue]:l=this.toCPALcolor(l),this.font.tables.cpal={version:0,numPaletteEntries:l.length,colorRecords:l,colorRecordIndices:[0]},!0)}updateIndices(){let l=this.cpal(),d=Math.ceil(l.colorRecords.length/l.numPaletteEntries);l.colorRecordIndices=[];for(let h=0;h<d;h++)l.colorRecordIndices.push(h*l.numPaletteEntries)}},Tu=class{constructor(l){this.font=l}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(l){let d=this.font,h=[],m=d.tables.colr,b=d.tables.cpal;if(!m||!b)return h;let w=co(m.baseGlyphRecords,"glyphID",l);if(!w)return h;let _=w.firstLayerIndex,I=w.numLayers;for(let R=0;R<I;R++){let z=m.layerRecords[_+R];h.push({glyph:d.glyphs.get(z.glyphID),paletteIndex:z.paletteIndex})}return h}add(l,d,h){let m=this.get(l);d=Array.isArray(d)?d:[d],h===void 0||h===1/0||h>m.length?h=m.length:h<0&&(h=m.length+1+h%(m.length+1),h>=m.length+1&&(h-=m.length+1));let b=[];for(let w=0;w<h;w++){let _=Number.isInteger(m[w].glyph)?m[w].glyph:m[w].glyph.index;b.push({glyphID:_,paletteIndex:m[w].paletteIndex})}for(let w of d){let _=Number.isInteger(w.glyph)?w.glyph:w.glyph.index;b.push({glyphID:_,paletteIndex:w.paletteIndex})}for(let w=h;w<m.length;w++){let _=Number.isInteger(m[w].glyph)?m[w].glyph:m[w].glyph.index;b.push({glyphID:_,paletteIndex:m[w].paletteIndex})}this.updateColrTable(l,b)}setPaletteIndex(l,d,h){let m=this.get(l);m[d]?(m=m.map((b,w)=>({glyphID:b.glyph.index,paletteIndex:w===d?h:b.paletteIndex})),this.updateColrTable(l,m)):console.error("Invalid layer index")}remove(l,d,h=d){let m=this.get(l);m=m.map(b=>({glyphID:b.glyph.index,paletteIndex:b.paletteIndex})),m.splice(d,h-d+1),this.updateColrTable(l,m)}updateColrTable(l,d){this.ensureCOLR();let h=this.font.tables.colr,m=q0(h.baseGlyphRecords,"glyphID",l);if(m===-1){let R={glyphID:l,firstLayerIndex:h.layerRecords.length,numLayers:0};m=uo(h.baseGlyphRecords,"glyphID",R)}let b=h.baseGlyphRecords[m],w=b.numLayers,_=d.length,I=_-w;if(I>0){let R=d.slice(w).map(z=>({glyphID:z.glyphID,paletteIndex:z.paletteIndex}));h.layerRecords.splice(b.firstLayerIndex+w,0,...R)}else I<0&&h.layerRecords.splice(b.firstLayerIndex+_,-I);for(let R=0;R<Math.min(w,_);R++)h.layerRecords[b.firstLayerIndex+R]={glyphID:d[R].glyphID,paletteIndex:d[R].paletteIndex};if(b.numLayers=_,I!==0)for(let R=0;R<h.baseGlyphRecords.length;R++){let z=h.baseGlyphRecords[R];R===m||z.firstLayerIndex<b.firstLayerIndex||(h.baseGlyphRecords[R].firstLayerIndex+=I)}}},Zl=class{constructor(l){this.font=l,this.cache=new WeakMap}get(l){let d=this.getOrCreateSvgImageCacheEntry(l);return d&&d.image}getAsync(l){let d=this.getOrCreateSvgImageCacheEntry(l);return d&&d.promise}getOrCreateSvgImageCacheEntry(l){let d=this.font.tables.svg;if(d===void 0)return;let h=d.get(l);if(h===void 0)return;let m=this.cache.get(h);m===void 0&&(m=Ko(h),this.cache.set(h,m));let b=m.images.get(l);return b===void 0&&(b=Ss(this.font,m.template,l),b.promise.then(w=>{if(b.image=w,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(l)}catch(_){console.error("font.onGlyphUpdated",l,_)}}),m.images.set(l,b)),b}};function Ko(l){return{template:Il(l).then(yi),images:new Map}}function Ss(l,d,h){return{promise:d.then(m=>{let b;typeof m=="string"?b=m:(m[4]=h,b=m.join(""));let w=Rl(b,l.unitsPerEm);return w.image.decode().then(()=>w)}),image:void 0}}var Il=typeof DecompressionStream=="function"?Cu:Ys;function Ys(l){try{return Promise.resolve(new TextDecoder().decode(Kl(l)?ja(l):l))}catch(d){return Promise.reject(d)}}function Cu(l){if(Kl(l))return new Response(new Response(l).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(l))}catch(d){return Promise.reject(d)}}function yi(l){let d=l.indexOf("<svg"),h=l.indexOf(">",d+4)+1;if(/ id=['"]glyph\d+['"]/.test(l.substring(d,h)))return l;let m=l.lastIndexOf("</svg>");return[l.substring(0,h),"<defs>",l.substring(h,m),'</defs><use href="#glyph',"",'"/>',l.substring(m)]}function Rl(l,d){let h=new DOMParser().parseFromString(l,"image/svg+xml").documentElement,m=h.viewBox.baseVal,b=h.width.baseVal,w=h.height.baseVal,_=1,I=1;m.width>0&&m.height>0&&(b.unitType===1?(_=b.valueInSpecifiedUnits/m.width,I=w.unitType===1?w.valueInSpecifiedUnits/m.height:_):w.unitType===1?(I=w.valueInSpecifiedUnits/m.height,_=I):d&&(_=d/m.width,I=d/m.height));let R=document.createElement("div");R.style.position="fixed",R.style.visibility="hidden",R.appendChild(h),document.body.appendChild(R);let z=h.getBBox();document.body.removeChild(R);let O=(z.x-m.x)*_,se=(m.y-z.y)*I,ne=z.width*_,_e=z.height*I;h.setAttribute("viewBox",[z.x,z.y,z.width,z.height].join(" ")),_!==1&&h.setAttribute("width",ne),I!==1&&h.setAttribute("height",_e);let xe=new Image(ne,_e);return xe.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(h.outerHTML),{leftSideBearing:O,baseline:se,image:xe}}var ma=new WeakMap;function Jl(l,d,h,m,b){let w;return(d&m)>0?(w=l.parseByte(),(d&b)===0&&(w=-w),w=h+w):(d&b)>0?w=h:w=h+l.parseShort(),w}function ga(l,d,h){let m=new Ne.Parser(d,h);l._numberOfContours=m.parseShort(),l._xMin=m.parseShort(),l._yMin=m.parseShort(),l._xMax=m.parseShort(),l._yMax=m.parseShort();let b,w;if(l._numberOfContours>0){let _=l.endPointIndices=[];for(let R=0;R<l._numberOfContours;R+=1)_.push(m.parseUShort());l.instructionLength=m.parseUShort(),l.instructions=[];for(let R=0;R<l.instructionLength;R+=1)l.instructions.push(m.parseByte());let I=_[_.length-1]+1;b=[];for(let R=0;R<I;R+=1)if(w=m.parseByte(),b.push(w),(w&8)>0){let z=m.parseByte();for(let O=0;O<z;O+=1)b.push(w),R+=1}if(re.argument(b.length===I,"Bad flags."),_.length>0){let R=[],z;if(I>0){for(let ne=0;ne<I;ne+=1)w=b[ne],z={},z.onCurve=!!(w&1),z.lastPointOfContour=_.indexOf(ne)>=0,R.push(z);let O=0;for(let ne=0;ne<I;ne+=1)w=b[ne],z=R[ne],z.x=Jl(m,w,O,2,16),O=z.x;let se=0;for(let ne=0;ne<I;ne+=1)w=b[ne],z=R[ne],z.y=Jl(m,w,se,4,32),se=z.y}l.points=R}else l.points=[]}else if(l._numberOfContours===0)l.points=[];else{l.isComposite=!0,l.points=[],l.components=[];let _=!0;for(;_;){b=m.parseUShort();let I={glyphIndex:m.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(b&1)>0?(b&2)>0?(I.dx=m.parseShort(),I.dy=m.parseShort()):I.matchedPoints=[m.parseUShort(),m.parseUShort()]:(b&2)>0?(I.dx=m.parseChar(),I.dy=m.parseChar()):I.matchedPoints=[m.parseByte(),m.parseByte()],(b&8)>0?I.xScale=I.yScale=m.parseF2Dot14():(b&64)>0?(I.xScale=m.parseF2Dot14(),I.yScale=m.parseF2Dot14()):(b&128)>0&&(I.xScale=m.parseF2Dot14(),I.scale01=m.parseF2Dot14(),I.scale10=m.parseF2Dot14(),I.yScale=m.parseF2Dot14()),l.components.push(I),_=!!(b&32)}if(b&256){l.instructionLength=m.parseUShort(),l.instructions=[];for(let I=0;I<l.instructionLength;I+=1)l.instructions.push(m.parseByte())}}}function As(l,d){let h=[];for(let m=0;m<l.length;m+=1){let b=l[m],w={x:d.xScale*b.x+d.scale10*b.y+d.dx,y:d.scale01*b.x+d.yScale*b.y+d.dy,onCurve:b.onCurve,lastPointOfContour:b.lastPointOfContour};h.push(w)}return h}function xd(l){let d=[],h=[];for(let m=0;m<l.length;m+=1){let b=l[m];h.push(b),b.lastPointOfContour&&(d.push(h),h=[])}return re.argument(h.length===0,"There are still points left in the current contour."),d}function qc(l){let d=new ht;if(!l)return d;let h=xd(l);for(let m=0;m<h.length;++m){let b=h[m],w=b[b.length-1],_=b[0];if(w.onCurve)d.moveTo(w.x,w.y);else if(_.onCurve)d.moveTo(_.x,_.y);else{let I={x:(w.x+_.x)*.5,y:(w.y+_.y)*.5};d.moveTo(I.x,I.y)}for(let I=0;I<b.length;++I)if(w=_,_=b[(I+1)%b.length],w.onCurve)d.lineTo(w.x,w.y);else{let R=_;_.onCurve||(R={x:(w.x+_.x)*.5,y:(w.y+_.y)*.5}),d.quadraticCurveTo(w.x,w.y,R.x,R.y)}d.closePath()}return d}function Yo(l,d){if(d.isComposite){ma.has(l)||ma.set(l,new Set);let h=ma.get(l);h.add(d.index);try{for(let m=0;m<d.components.length;m+=1){let b=d.components[m];if(h.has(b.glyphIndex))continue;let w=l.get(b.glyphIndex);if(w.getPath(),w.points){let _;if(b.matchedPoints===void 0)_=As(w.points,b);else{if(b.matchedPoints[0]>d.points.length-1||b.matchedPoints[1]>w.points.length-1)throw Error("Matched points out of range in "+d.name);let I=d.points[b.matchedPoints[0]],R=w.points[b.matchedPoints[1]],z={xScale:b.xScale,scale01:b.scale01,scale10:b.scale10,yScale:b.yScale,dx:0,dy:0};R=As([R],z)[0],z.dx=I.x-R.x,z.dy=I.y-R.y,_=As(w.points,z)}d.points=d.points.concat(_)}}}finally{h.delete(d.index)}}return qc(d.points)}function N(l,d,h,m){let b=new cn.GlyphSet(m);for(let w=0;w<h.length-1;w+=1){let _=h[w],I=h[w+1];_!==I?b.push(w,cn.ttfGlyphLoader(m,w,ga,l,d+_,Yo)):b.push(w,cn.glyphLoader(m,w))}return b}function W(l,d,h,m){let b=new cn.GlyphSet(m);return m._push=function(w){let _=h[w],I=h[w+1];_!==I?b.push(w,cn.ttfGlyphLoader(m,w,ga,l,d+_,Yo)):b.push(w,cn.glyphLoader(m,w))},b}function ye(l,d,h,m,b){return b.lowMemory?W(l,d,h,m):N(l,d,h,m)}var rt={getPath:qc,parse:ye},Et=class{constructor(l){this.font=l}normalizeCoordTags(l){for(let d in l)if(d.length<4){let h=d.padEnd(4," ");l[h]===void 0&&(l[h]=l[d]),delete l[d]}}getNormalizedCoords(l){l||(l=this.font.variation.get());let d=[];this.normalizeCoordTags(l);for(let h=0;h<this.fvar().axes.length;h++){let m=this.fvar().axes[h],b=l[m.tag];b===void 0&&(b=m.defaultValue),b<m.defaultValue?d.push((b-m.defaultValue+Number.EPSILON)/(m.defaultValue-m.minValue+Number.EPSILON)):d.push((b-m.defaultValue+Number.EPSILON)/(m.maxValue-m.defaultValue+Number.EPSILON))}if(this.avar())for(let h=0;h<this.avar().axisSegmentMaps.length;h++){let m=this.avar().axisSegmentMaps[h];for(let b=0;b<m.axisValueMaps.length;b++){let w=m.axisValueMaps[b];if(b>=1&&d[h]<w.fromCoordinate){let _=m.axisValueMaps[b-1];d[h]=((d[h]-_.fromCoordinate)*(w.toCoordinate-_.toCoordinate)+Number.EPSILON)/(w.fromCoordinate-_.fromCoordinate+Number.EPSILON)+_.toCoordinate;break}}}return d}interpolatePoints(l,d,h){if(l.length===0)return;let m=0;for(;m<l.length;){let b=m,w=m,_=l[w];for(;!_.lastPointOfContour;)_=l[++w];for(;m<=w&&!h[m];)m++;if(m>w)continue;let I=m,R=m;for(m++;m<=w;)h[m]&&(this.deltaInterpolate(R+1,m-1,R,m,d,l),R=m),m++;R===I?this.deltaShift(b,w,R,d,l):(this.deltaInterpolate(R+1,w,R,I,d,l),I>0&&this.deltaInterpolate(b,I-1,R,I,d,l)),m=w+1}}deltaInterpolate(l,d,h,m,b,w){if(l>d)return;let _=["x","y"];for(let R=0;R<_.length;R++){let z=_[R];if(b[h][z]>b[m][z]){var I=h;h=m,m=I}let O=b[h][z],se=b[m][z],ne=w[h][z],_e=w[m][z];if(O!==se||ne===_e){let xe=O===se?0:(_e-ne)/(se-O);for(let Be=l;Be<=d;Be++){let dt=b[Be][z];dt<=O?dt+=ne-O:dt>=se?dt+=_e-se:dt=ne+(dt-O)*xe,w[Be][z]=dt}}}}deltaShift(l,d,h,m,b){let w=b[h].x-m[h].x,_=b[h].y-m[h].y;if(!(w===0&&_===0))for(let I=l;I<=d;I++)I!==h&&(b[I].x+=w,b[I].y+=_)}transformComponents(l,d,h,m,b,w){let _=0;for(let I=0;I<l.components.length;I++){let R=l.components[I],z=this.font.glyphs.get(R.glyphIndex),O=Yl(R),se=m.indexOf(I);se>-1&&(O.dx+=Math.round(b.deltas[se]*w),O.dy+=Math.round(b.deltasY[se]*w));let ne=As(this.getTransform(z,h).points,O);d.splice(_,ne.length,...ne),_+=z.points.length}}applyTupleVariationStore(l,d,h,m="gvar",b={}){h||(h=this.font.variation.get());let w=this.getNormalizedCoords(h),{headers:_,sharedPoints:I}=l,R=this.fvar().axes.length,z;m==="gvar"?z=d.map(tl):m==="cvar"&&(z=[...d]);for(let O=0;O<_.length;O++){let se=_[O],ne=1;for(let xe=0;xe<R;xe++){let Be=[0];switch(m){case"gvar":Be=se.peakTuple?se.peakTuple:this.gvar().sharedTuples[se.sharedTupleRecordsIndex];break;case"cvar":Be=se.peakTuple;break}if(Be[xe]!==0){if(w[xe]===0){ne=0;break}if(se.intermediateStartTuple)if(w[xe]<se.intermediateStartTuple[xe]||w[xe]>se.intermediateEndTuple[xe]){ne=0;break}else w[xe]<Be[xe]?ne=ne*(w[xe]-se.intermediateStartTuple[xe]+Number.EPSILON)/(Be[xe]-se.intermediateStartTuple[xe]+Number.EPSILON):ne=ne*(se.intermediateEndTuple[xe]-w[xe]+Number.EPSILON)/(se.intermediateEndTuple[xe]-Be[xe]+Number.EPSILON);else{if(w[xe]<Math.min(0,Be[xe])||w[xe]>Math.max(0,Be[xe])){ne=0;break}ne=(ne*w[xe]+Number.EPSILON)/(Be[xe]+Number.EPSILON)}}}if(ne===0)continue;let _e=se.privatePoints.length?se.privatePoints:I;if(m==="gvar"&&b.glyph&&b.glyph.isComposite)this.transformComponents(b.glyph,z,h,_e,se,ne);else if(_e.length===0)for(let xe=0;xe<z.length;xe++){let Be=z[xe];m==="gvar"?z[xe]={x:Math.round(Be.x+se.deltas[xe]*ne),y:Math.round(Be.y+se.deltasY[xe]*ne),onCurve:Be.onCurve,lastPointOfContour:Be.lastPointOfContour}:m==="cvar"&&(z[xe]=Math.round(Be+se.deltas[xe]*ne))}else{let xe;m==="gvar"?xe=z.map(tl):m==="cvar"&&(xe=z);let Be=Array(d.length).fill(!1);for(let dt=0;dt<_e.length;dt++){let Dn=_e[dt];if(Dn<d.length){let An=xe[Dn];m==="gvar"?(Be[Dn]=!0,An.x+=se.deltas[dt]*ne,An.y+=se.deltasY[dt]*ne):m==="cvar"&&(z[Dn]=Math.round(An+se.deltas[dt]*ne))}}if(m==="gvar"){this.interpolatePoints(xe,z,Be);for(let dt=0;dt<d.length;dt++){let Dn=xe[dt].x-z[dt].x,An=xe[dt].y-z[dt].y;z[dt].x=Math.round(z[dt].x+Dn),z[dt].y=Math.round(z[dt].y+An)}}}}return z}getTransform(l,d){Number.isInteger(l)&&(l=this.font.glyphs.get(l));let h=l.getBlendPath,m=!!(l.points&&l.points.length),b=l;if(h||m){if(d||(d=this.font.variation.get()),m){let w=this.gvar()&&this.gvar().glyphVariations[l.index];if(w){let _=l.points,I=this.applyTupleVariationStore(w,_,d,"gvar",{glyph:l});b=new Sr(Object.assign({},l,{points:I,path:qc(I)}))}}else if(h){let w=l.getBlendPath(d);b=new Sr(Object.assign({},l,{path:w}))}}return this.font.tables.hvar&&(l._advanceWidth=typeof l._advanceWidth<"u"?l._advanceWidth:l.advanceWidth,l.advanceWidth=b.advanceWidth=Math.round(l._advanceWidth+this.getVariableAdjustment(b.index,"hvar","advanceWidth",d)),l._leftSideBearing=typeof l._leftSideBearing<"u"?l._leftSideBearing:l.leftSideBearing,l.leftSideBearing=b.leftSideBearing=Math.round(l._leftSideBearing+this.getVariableAdjustment(b.index,"hvar","lsb",d))),b}getCvarTransform(l){let d=this.font.tables.cvt,h=this.cvar();return!d||!d.length||!h||!h.headers.length?d:this.applyTupleVariationStore(h,d,l,"cvar")}getVariableAdjustment(l,d,h,m){m=m||this.font.variation.get();let b,w,_=this.font.tables[d];if(!_)throw Error(`trying to get variation adjustment from non-existent table "${_}"`);if(!_.itemVariationStore)throw Error(`trying to get variation adjustment from table "${_}" which does not have an itemVariationStore`);let I=_[h]&&_[h].map.length;if(I){let R=l;R>=I&&(R=I-1),{outerIndex:b,innerIndex:w}=_[h].map[R]}else b=0,w=l;return this.getDelta(_.itemVariationStore,b,w,m)}getDelta(l,d,h,m){if(d>=l.itemVariationSubtables.length)return 0;let b=l.itemVariationSubtables[d];if(h>=b.deltaSets.length)return 0;let w=b.deltaSets[h],_=this.getBlendVector(l,d,m),I=0;for(let R=0;R<b.regionIndexes.length;R++)I+=w[R]*_[R];return I}getBlendVector(l,d,h){h||(h=this.font.variation.get());let m=l.itemVariationSubtables[d],b=this.getNormalizedCoords(h),w=[];for(let _=0;_<m.regionIndexes.length;_++){let I=1,R=m.regionIndexes[_],z=l.variationRegions[R].regionAxes;for(let O=0;O<z.length;O++){let se=z[O],ne;se.startCoord>se.peakCoord||se.peakCoord>se.endCoord||se.startCoord<0&&se.endCoord>0&&se.peakCoord!==0||se.peakCoord===0?ne=1:b[O]<se.startCoord||b[O]>se.endCoord?ne=0:b[O]===se.peakCoord?ne=1:b[O]<se.peakCoord?ne=(b[O]-se.startCoord+Number.EPSILON)/(se.peakCoord-se.startCoord+Number.EPSILON):ne=(se.endCoord-b[O]+Number.EPSILON)/(se.endCoord-se.peakCoord+Number.EPSILON),I*=ne}w[_]=I}return w}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},dn=class{constructor(l){this.font=l,this.process=new Et(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let l=this.getDefaultInstanceIndex();l>-1?this.set(l):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((l,d)=>(l[d.tag]=d.defaultValue,l),{})}getDefaultInstanceIndex(){let l=this.getDefaultCoordinates(),d=this.getInstanceIndex(l);return d<0&&(d=this.fvar().instances.findIndex(h=>h.name&&h.name.en==="Regular")),d}getInstanceIndex(l){return this.fvar().instances.findIndex(d=>Object.keys(l).every(h=>d.coordinates[h]===l[h]))}getInstance(l){return this.fvar().instances&&this.fvar().instances[l]}set(l){let d;if(Number.isInteger(l)){let h=this.getInstance(l);if(!h)throw Error(`Invalid instance index ${l}`);d={...h.coordinates}}else d=l,this.process.normalizeCoordTags(d);d=Object.assign({},this.font.defaultRenderOptions.variation,d),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:d})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Rn=1e6,$r=64,Hr=1e4,Or,li,rr,_i;function fo(l){this.font=l,this.getCommands=function(d){return rt.getPath(d).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Mo(l){return l}function Xs(l){return Math.sign(l)*Math.round(Math.abs(l))}function Zs(l){return Math.sign(l)*Math.round(Math.abs(l*2))/2}function Do(l){return Math.sign(l)*(Math.round(Math.abs(l)+.5)-.5)}function K0(l){return Math.sign(l)*Math.ceil(Math.abs(l))}function Li(l){return Math.sign(l)*Math.floor(Math.abs(l))}var Y0=function(l){let d=this.srPeriod,h=this.srPhase,m=this.srThreshold,b=1;return l<0&&(l=-l,b=-1),l+=m-h,l=Math.trunc(l/d)*d,l+=h,l<0?h*b:l*b},nl={x:1,y:0,axis:"x",distance:function(l,d,h,m){return(h?l.xo:l.x)-(m?d.xo:d.x)},interpolate:function(l,d,h,m){let b,w,_,I,R,z,O;if(!m||m===this){if(b=l.xo-d.xo,w=l.xo-h.xo,R=d.x-d.xo,z=h.x-h.xo,_=Math.abs(b),I=Math.abs(w),O=_+I,O===0){l.x=l.xo+(R+z)/2;return}l.x=l.xo+(R*I+z*_)/O;return}if(b=m.distance(l,d,!0,!0),w=m.distance(l,h,!0,!0),R=m.distance(d,d,!1,!0),z=m.distance(h,h,!1,!0),_=Math.abs(b),I=Math.abs(w),O=_+I,O===0){nl.setRelative(l,l,(R+z)/2,m,!0);return}nl.setRelative(l,l,(R*I+z*_)/O,m,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(l,d,h,m,b){if(!m||m===this){l.x=(b?d.xo:d.x)+h;return}let w=b?d.xo:d.x,_=b?d.yo:d.y,I=w+h*m.x,R=_+h*m.y;l.x=I+(l.y-R)/m.normalSlope},slope:0,touch:function(l){l.xTouched=!0},touched:function(l){return l.xTouched},untouch:function(l){l.xTouched=!1}},rl={x:0,y:1,axis:"y",distance:function(l,d,h,m){return(h?l.yo:l.y)-(m?d.yo:d.y)},interpolate:function(l,d,h,m){let b,w,_,I,R,z,O;if(!m||m===this){if(b=l.yo-d.yo,w=l.yo-h.yo,R=d.y-d.yo,z=h.y-h.yo,_=Math.abs(b),I=Math.abs(w),O=_+I,O===0){l.y=l.yo+(R+z)/2;return}l.y=l.yo+(R*I+z*_)/O;return}if(b=m.distance(l,d,!0,!0),w=m.distance(l,h,!0,!0),R=m.distance(d,d,!1,!0),z=m.distance(h,h,!1,!0),_=Math.abs(b),I=Math.abs(w),O=_+I,O===0){rl.setRelative(l,l,(R+z)/2,m,!0);return}rl.setRelative(l,l,(R*I+z*_)/O,m,!0)},normalSlope:0,setRelative:function(l,d,h,m,b){if(!m||m===this){l.y=(b?d.yo:d.y)+h;return}let w=b?d.xo:d.x,_=b?d.yo:d.y,I=w+h*m.x,R=_+h*m.y;l.y=R+m.normalSlope*(l.x-I)},slope:Number.POSITIVE_INFINITY,touch:function(l){l.yTouched=!0},touched:function(l){return l.yTouched},untouch:function(l){l.yTouched=!1}};Object.freeze(nl),Object.freeze(rl);function ku(l,d){this.x=l,this.y=d,this.axis=void 0,this.slope=d/l,this.normalSlope=-l/d,Object.freeze(this)}ku.prototype.distance=function(l,d,h,m){return this.x*nl.distance(l,d,h,m)+this.y*rl.distance(l,d,h,m)},ku.prototype.interpolate=function(l,d,h,m){let b,w,_,I,R,z,O;if(_=m.distance(l,d,!0,!0),I=m.distance(l,h,!0,!0),b=m.distance(d,d,!1,!0),w=m.distance(h,h,!1,!0),R=Math.abs(_),z=Math.abs(I),O=R+z,O===0){this.setRelative(l,l,(b+w)/2,m,!0);return}this.setRelative(l,l,(b*z+w*R)/O,m,!0)},ku.prototype.setRelative=function(l,d,h,m,b){m=m||this;let w=b?d.xo:d.x,_=b?d.yo:d.y,I=w+h*m.x,R=_+h*m.y,z=m.normalSlope,O=this.slope,se=l.x,ne=l.y;l.x=(O*se-z*I+R-ne)/(O-z),l.y=O*(l.x-se)+ne},ku.prototype.touch=function(l){l.xTouched=!0,l.yTouched=!0};function _u(l,d){let h=Math.sqrt(l*l+d*d);return l/=h,d/=h,l===1&&d===0?nl:l===0&&d===1?rl:new ku(l,d)}function sl(l,d,h,m){this.x=this.xo=Math.round(l*64)/64,this.y=this.yo=Math.round(d*64)/64,this.lastPointOfContour=h,this.onCurve=m,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}sl.prototype.nextTouched=function(l){let d=this.nextPointOnContour;for(;!l.touched(d)&&d!==this;)d=d.nextPointOnContour;return d},sl.prototype.prevTouched=function(l){let d=this.prevPointOnContour;for(;!l.touched(d)&&d!==this;)d=d.prevPointOnContour;return d};var Kc=Object.freeze(new sl(0,0)),Kh={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Nl(l,d){switch(this.env=l,this.stack=[],this.prog=d,l){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=nl,this.round=Xs}}fo.prototype.exec=function(l,d){if(typeof d!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let h=this.font,m=this._prepState;if(!m||m.ppem!==d){let b=this._fpgmState;if(!b){Nl.prototype=Kh,b=this._fpgmState=new Nl("fpgm",h.tables.fpgm),b.funcs=[],b.font=h,b.instructionCount=0,b.callDepth=0;try{li(b)}catch(_){console.log("Hinting error in FPGM:"+_),this._errorState=3;return}}Nl.prototype=b,m=this._prepState=new Nl("prep",h.tables.prep),m.ppem=d,m.instructionCount=0,m.callDepth=0;let w=h.variation&&h.variation.process.getCvarTransform()||h.tables.cvt;if(w){let _=m.cvt=new Array(w.length),I=d/h.unitsPerEm;for(let R=0;R<w.length;R++)_[R]=w[R]*I}else m.cvt=[];try{li(m)}catch(_){this._errorState<2&&console.log("Hinting error in PREP:"+_),this._errorState=2}}if(!(this._errorState>1))try{return rr(l,m)}catch(b){this._errorState<1&&(console.log("Hinting error:"+b),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},rr=function(l,d){let h=d.ppem/d.font.unitsPerEm,m=h,b=l.components,w,_,I;if(Nl.prototype=d,!b)I=new Nl("glyf",l.instructions),I.instructionCount=0,I.callDepth=0,_i(l,I,h,m),_=I.gZone;else{let R=d.font;_=[],w=[];for(let z=0;z<b.length;z++){let O=b[z],se=R.glyphs.get(O.glyphIndex);I=new Nl("glyf",se.instructions),I.instructionCount=0,I.callDepth=0,_i(se,I,h,m);let ne=Math.round(O.dx*h),_e=Math.round(O.dy*m),xe=I.gZone,Be=I.contours;for(let Dn=0;Dn<xe.length;Dn++){let An=xe[Dn];An.xTouched=An.yTouched=!1,An.xo=An.x=An.x+ne,An.yo=An.y=An.y+_e}let dt=_.length;_.push.apply(_,xe);for(let Dn=0;Dn<Be.length;Dn++)w.push(Be[Dn]+dt)}l.instructions&&!I.inhibitGridFit&&(I=new Nl("glyf",l.instructions),I.gZone=I.z0=I.z1=I.z2=_,I.contours=w,_.push(new sl(0,0),new sl(Math.round(l.advanceWidth*h),0)),li(I),_.length-=2)}return _},_i=function(l,d,h,m){let b=l.points||[],w=b.length,_=d.gZone=d.z0=d.z1=d.z2=[],I=d.contours=[],R;for(let se=0;se<w;se++)R=b[se],_[se]=new sl(R.x*h,R.y*m,R.lastPointOfContour,R.onCurve);let z,O;for(let se=0;se<w;se++)R=_[se],z||(z=R,I.push(se)),R.lastPointOfContour?(R.nextPointOnContour=z,z.prevPointOnContour=R,z=void 0):(O=_[se+1],R.nextPointOnContour=O,O.prevPointOnContour=R);d.inhibitGridFit||(_.push(new sl(0,0),new sl(Math.round(l.advanceWidth*h),0)),li(d),_.length-=2)},li=function(l){let d=l.prog;if(!d)return;let h=d.length,m;for(l.ip=0;l.ip<h;l.ip++){if(++l.instructionCount>Rn)throw new Error("Hinting instructions exceeded maximum of "+Rn);if(m=Or[d[l.ip]],!m)throw new Error("unknown instruction: 0x"+Number(d[l.ip]).toString(16));m(l)}};function Lu(l){let d=l.tZone=new Array(l.gZone.length);for(let h=0;h<d.length;h++)d[h]=new sl(0,0)}function bd(l,d){let h=l.prog,m=l.ip,b=1,w;do if(w=h[++m],w===88)b++;else if(w===89)b--;else if(w===64)m+=h[m+1]+1;else if(w===65)m+=2*h[m+1]+1;else if(w>=176&&w<=183)m+=w-176+1;else if(w>=184&&w<=191)m+=(w-184+1)*2;else if(d&&b===1&&w===27)break;while(b>0);l.ip=m}function ci(l,d){d.fv=d.pv=d.dpv=l}function Oi(l,d){d.pv=d.dpv=l}function ho(l,d){d.fv=l}function Pa(l,d){let h=d.stack,m=h.pop(),b=h.pop(),w=d.z2[m],_=d.z1[b],I,R;l?(I=w.y-_.y,R=_.x-w.x):(I=_.x-w.x,R=_.y-w.y),d.pv=d.dpv=_u(I,R)}function Qi(l,d){let h=d.stack,m=h.pop(),b=h.pop(),w=d.z2[m],_=d.z1[b],I,R;l?(I=w.y-_.y,R=_.x-w.x):(I=_.x-w.x,R=_.y-w.y),d.fv=_u(I,R)}function ur(l){let d=l.stack,h=d.pop(),m=d.pop();l.pv=l.dpv=_u(m,h)}function Yh(l){let d=l.stack,h=d.pop(),m=d.pop();l.fv=_u(m,h)}function On(l){let d=l.stack,h=l.pv;d.push(h.x*16384),d.push(h.y*16384)}function Ts(l){let d=l.stack,h=l.fv;d.push(h.x*16384),d.push(h.y*16384)}function Xh(l){l.fv=l.pv}function Cc(l){let d=l.stack,h=d.pop(),m=d.pop(),b=d.pop(),w=d.pop(),_=d.pop(),I=l.z0,R=l.z1,z=I[h],O=I[m],se=R[b],ne=R[w],_e=l.z2[_],xe=z.x,Be=z.y,dt=O.x,Dn=O.y,An=se.x,Jn=se.y,Lr=ne.x,ls=ne.y,ms=(xe-dt)*(Jn-ls)-(Be-Dn)*(An-Lr),gs=xe*Dn-Be*dt,vi=An*ls-Jn*Lr;_e.x=(gs*(An-Lr)-vi*(xe-dt))/ms,_e.y=(gs*(Jn-ls)-vi*(Be-Dn))/ms}function X0(l){l.rp0=l.stack.pop()}function w1(l){l.rp1=l.stack.pop()}function S1(l){l.rp2=l.stack.pop()}function Yc(l){let d=l.stack.pop();switch(l.zp0=d,d){case 0:l.tZone||Lu(l),l.z0=l.tZone;break;case 1:l.z0=l.gZone;break;default:throw new Error("Invalid zone pointer")}}function Eu(l){let d=l.stack.pop();switch(l.zp1=d,d){case 0:l.tZone||Lu(l),l.z1=l.tZone;break;case 1:l.z1=l.gZone;break;default:throw new Error("Invalid zone pointer")}}function A1(l){let d=l.stack.pop();switch(l.zp2=d,d){case 0:l.tZone||Lu(l),l.z2=l.tZone;break;case 1:l.z2=l.gZone;break;default:throw new Error("Invalid zone pointer")}}function T1(l){let d=l.stack.pop();switch(l.zp0=l.zp1=l.zp2=d,d){case 0:l.tZone||Lu(l),l.z0=l.z1=l.z2=l.tZone;break;case 1:l.z0=l.z1=l.z2=l.gZone;break;default:throw new Error("Invalid zone pointer")}}function Zh(l){l.loop=l.stack.pop(),l.loop>Hr&&(l.loop=Hr)}function kc(l){l.round=Xs}function yd(l){l.round=Do}function Jh(l){let d=l.stack.pop();l.minDis=d/64}function vd(l){bd(l,!1)}function C1(l){let d=l.stack.pop();l.ip+=d-1}function ep(l){let d=l.stack.pop();l.cvCutIn=d/64}function tp(l){let d=l.stack;d.push(d[d.length-1])}function Z0(l){l.stack.pop()}function xa(l){l.stack.length=0}function wd(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(h),d.push(m)}function Sd(l){let d=l.stack;d.push(d.length)}function il(l){let d=l.stack,h=d.pop(),m=d.pop();if(m>Hr&&(m=Hr),++l.callDepth>$r)throw new Error("Hinting call depth exceeded maximum of "+$r);let b=l.ip,w=l.prog;l.prog=l.funcs[h];for(let _=0;_<m;_++)li(l);l.ip=b,l.prog=w,l.callDepth--}function Ba(l){let d=l.stack.pop();if(++l.callDepth>$r)throw new Error("Hinting call depth exceeded maximum of "+$r);let h=l.ip,m=l.prog;l.prog=l.funcs[d],li(l),l.ip=h,l.prog=m,l.callDepth--}function np(l){let d=l.stack,h=d.pop();d.push(d[d.length-h])}function rp(l){let d=l.stack,h=d.pop();d.push(d.splice(d.length-h,1)[0])}function sp(l){if(l.env!=="fpgm")throw new Error("FDEF not allowed here");let d=l.stack,h=l.prog,m=l.ip,b=d.pop(),w=m;for(;h[++m]!==45;);l.ip=m,l.funcs[b]=h.slice(w+1,m)}function ip(l,d){let h=d.stack.pop(),m=d.z0[h],b=d.fv,w=d.pv,_=w.distance(m,Kc);l&&(_=d.round(_)),b.setRelative(m,Kc,_,w),b.touch(m),d.rp0=d.rp1=h}function Ad(l,d){let h=d.z2,m=h.length-2,b,w,_;for(let I=0;I<m;I++)b=h[I],!l.touched(b)&&(w=b.prevTouched(l),w!==b&&(_=b.nextTouched(l),w===_&&l.setRelative(b,b,l.distance(w,w,!1,!0),l,!0),l.interpolate(b,w,_,l)))}function J0(l,d){let h=d.stack,m=l?d.rp1:d.rp2,b=(l?d.z0:d.z1)[m],w=d.fv,_=d.pv,I=d.loop,R=d.z2;for(;I--;){let z=h.pop(),O=R[z],se=_.distance(b,b,!1,!0);w.setRelative(O,O,se,_),w.touch(O)}d.loop=1}function op(l,d){let h=d.stack,m=l?d.rp1:d.rp2,b=(l?d.z0:d.z1)[m],w=d.fv,_=d.pv,I=h.pop(),R=d.z2[d.contours[I]],z=R,O=_.distance(b,b,!1,!0);do z!==b&&w.setRelative(z,z,O,_),z=z.nextPointOnContour;while(z!==R)}function ap(l,d){let h=d.stack,m=l?d.rp1:d.rp2,b=(l?d.z0:d.z1)[m],w=d.fv,_=d.pv,I=h.pop(),R;switch(I){case 0:R=d.tZone;break;case 1:R=d.gZone;break;default:throw new Error("Invalid zone")}let z,O=_.distance(b,b,!1,!0),se=R.length-2;for(let ne=0;ne<se;ne++)z=R[ne],w.setRelative(z,z,O,_)}function lp(l){let d=l.stack,h=l.loop,m=l.fv,b=d.pop()/64,w=l.z2;for(;h--;){let _=d.pop(),I=w[_];m.setRelative(I,I,b),m.touch(I)}l.loop=1}function cp(l){let d=l.stack,h=l.rp1,m=l.rp2,b=l.loop,w=l.z0[h],_=l.z1[m],I=l.fv,R=l.dpv,z=l.z2;for(;b--;){let O=d.pop(),se=z[O];I.interpolate(se,w,_,R),I.touch(se)}l.loop=1}function ef(l,d){let h=d.stack,m=h.pop()/64,b=h.pop(),w=d.z1[b],_=d.z0[d.rp0],I=d.fv,R=d.pv;I.setRelative(w,_,m,R),I.touch(w),d.rp1=d.rp0,d.rp2=b,l&&(d.rp0=b)}function up(l){let d=l.stack,h=l.rp0,m=l.z0[h],b=l.loop,w=l.fv,_=l.pv,I=l.z1;for(;b--;){let R=d.pop(),z=I[R];w.setRelative(z,m,0,_),w.touch(z)}l.loop=1}function dp(l){l.round=Zs}function Td(l,d){let h=d.stack,m=h.pop(),b=h.pop(),w=d.z0[b],_=d.fv,I=d.pv,R=d.cvt[m],z=I.distance(w,Kc);l&&(Math.abs(z-R)<d.cvCutIn&&(z=R),z=d.round(z)),_.setRelative(w,Kc,z,I),d.zp0===0&&(w.xo=w.x,w.yo=w.y),_.touch(w),d.rp0=d.rp1=b}function fp(l){let d=l.prog,h=l.ip,m=l.stack,b=d[++h];for(let w=0;w<b;w++)m.push(d[++h]);l.ip=h}function hp(l){let d=l.ip,h=l.prog,m=l.stack,b=h[++d];for(let w=0;w<b;w++){let _=h[++d]<<8|h[++d];_&32768&&(_=-((_^65535)+1)),m.push(_)}l.ip=d}function pp(l){let d=l.stack,h=l.store;h||(h=l.store=[]);let m=d.pop(),b=d.pop();h[b]=m}function Cd(l){let d=l.stack,h=l.store,m=d.pop(),b=h&&h[m]||0;d.push(b)}function k1(l){let d=l.stack,h=d.pop(),m=d.pop();l.cvt[m]=h/64}function _1(l){let d=l.stack,h=d.pop();d.push(l.cvt[h]*64)}function mp(l,d){let h=d.stack,m=h.pop(),b=d.z2[m];h.push(d.dpv.distance(b,Kc,l,!1)*64)}function Xo(l,d){let h=d.stack,m=h.pop(),b=h.pop(),w=d.z1[m],_=d.z0[b],I=d.dpv.distance(_,w,l,l);d.stack.push(Math.round(I*64))}function kd(l){l.stack.push(l.ppem)}function _d(l){l.autoFlip=!0}function tf(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m<h?1:0)}function L1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m<=h?1:0)}function Ld(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m>h?1:0)}function E1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m>=h?1:0)}function I1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(h===m?1:0)}function R1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(h!==m?1:0)}function N1(l){let d=l.stack,h=d.pop();d.push(Math.trunc(h)&1?1:0)}function nf(l){let d=l.stack,h=d.pop();d.push(Math.trunc(h)&1?0:1)}function rf(l){let d=l.stack.pop(),h;d||bd(l,!0)}function Xc(l){}function sf(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(h&&m?1:0)}function Ed(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(h||m?1:0)}function M1(l){let d=l.stack,h=d.pop();d.push(h?0:1)}function of(l,d){let h=d.stack,m=h.pop(),b=d.fv,w=d.pv,_=d.ppem,I=d.deltaBase+(l-1)*16,R=d.deltaShift,z=d.z0;for(let O=0;O<m;O++){let se=h.pop(),ne=h.pop();if(I+((ne&240)>>4)!==_)continue;let _e=(ne&15)-8;_e>=0&&_e++;let xe=z[se];b.setRelative(xe,xe,_e*R,w)}}function D1(l){let d=l.stack.pop();l.deltaBase=d}function af(l){let d=l.stack.pop();l.deltaShift=Math.pow(.5,d)}function j1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m+h)}function P1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m-h)}function B1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m*64/h)}function F1(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(m*h/64)}function O1(l){let d=l.stack,h=d.pop();d.push(Math.abs(h))}function Q1(l){let d=l.stack,h=d.pop();d.push(-h)}function $1(l){let d=l.stack,h=d.pop();d.push(Math.floor(h/64)*64)}function gp(l){let d=l.stack,h=d.pop();d.push(Math.ceil(h/64)*64)}function Iu(l,d){let h=d.stack,m=h.pop();h.push(d.round(m/64)*64)}function Id(l){let d=l.stack,h=d.pop(),m=d.pop();l.cvt[m]=h*l.ppem/l.font.unitsPerEm}function Rd(l,d){let h=d.stack,m=h.pop(),b=d.ppem,w=d.deltaBase+(l-1)*16,_=d.deltaShift;for(let I=0;I<m;I++){let R=h.pop(),z=h.pop();if(w+((z&240)>>4)!==b)continue;let O=(z&15)-8;O>=0&&O++;let se=O*_;d.cvt[R]+=se}}function xp(l){let d=l.stack.pop();l.round=Y0;let h;switch(d&192){case 0:h=.5;break;case 64:h=1;break;case 128:h=2;break;default:throw new Error("invalid SROUND value")}switch(l.srPeriod=h,d&48){case 0:l.srPhase=0;break;case 16:l.srPhase=.25*h;break;case 32:l.srPhase=.5*h;break;case 48:l.srPhase=.75*h;break;default:throw new Error("invalid SROUND value")}d&=15,d===0?l.srThreshold=0:l.srThreshold=(d/8-.5)*h}function H1(l){let d=l.stack.pop();l.round=Y0;let h;switch(d&192){case 0:h=Math.sqrt(2)/2;break;case 64:h=Math.sqrt(2);break;case 128:h=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(l.srPeriod=h,d&48){case 0:l.srPhase=0;break;case 16:l.srPhase=.25*h;break;case 32:l.srPhase=.5*h;break;case 48:l.srPhase=.75*h;break;default:throw new Error("invalid S45ROUND value")}d&=15,d===0?l.srThreshold=0:l.srThreshold=(d/8-.5)*h}function bp(l){l.round=Mo}function Nd(l){l.round=K0}function lf(l){l.round=Li}function yp(l){let d=l.stack.pop()}function cf(l,d){let h=d.stack,m=h.pop(),b=h.pop(),w=d.z2[m],_=d.z1[b],I,R;l?(I=w.y-_.y,R=_.x-w.x):(I=_.x-w.x,R=_.y-w.y),d.dpv=_u(I,R)}function vp(l){let d=l.stack,h=d.pop(),m=0;h&1&&(m=35),h&32&&(m|=4096),d.push(m)}function wp(l){let d=l.stack,h=d.pop(),m=d.pop(),b=d.pop();d.push(m),d.push(h),d.push(b)}function Sp(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(Math.max(m,h))}function Md(l){let d=l.stack,h=d.pop(),m=d.pop();d.push(Math.min(m,h))}function Ei(l){let d=l.stack.pop()}function Ap(l){let d=l.stack.pop(),h=l.stack.pop();switch(d){case 1:l.inhibitGridFit=!!h;return;case 2:l.ignoreCvt=!!h;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Fa(l,d){let h=d.stack,m=d.prog,b=d.ip;for(let w=0;w<l;w++)h.push(m[++b]);d.ip=b}function Ml(l,d){let h=d.ip,m=d.prog,b=d.stack;for(let w=0;w<l;w++){let _=m[++h]<<8|m[++h];_&32768&&(_=-((_^65535)+1)),b.push(_)}d.ip=h}function wn(l,d,h,m,b,w){let _=w.stack,I=l&&_.pop(),R=_.pop(),z=w.rp0,O=w.z0[z],se=w.z1[R],ne=w.minDis,_e=w.fv,xe=w.dpv,Be,dt,Dn,An;dt=Be=xe.distance(se,O,!0,!0),Dn=dt>=0?1:-1,dt=Math.abs(dt),l&&(An=w.cvt[I],m&&Math.abs(dt-An)<w.cvCutIn&&(dt=An)),h&&dt<ne&&(dt=ne),m&&(dt=w.round(dt)),_e.setRelative(se,O,Dn*dt,xe),_e.touch(se),w.rp1=w.rp0,w.rp2=R,d&&(w.rp0=R)}Or=[ci.bind(void 0,rl),ci.bind(void 0,nl),Oi.bind(void 0,rl),Oi.bind(void 0,nl),ho.bind(void 0,rl),ho.bind(void 0,nl),Pa.bind(void 0,0),Pa.bind(void 0,1),Qi.bind(void 0,0),Qi.bind(void 0,1),ur,Yh,On,Ts,Xh,Cc,X0,w1,S1,Yc,Eu,A1,T1,Zh,kc,yd,Jh,vd,C1,ep,void 0,void 0,tp,Z0,xa,wd,Sd,np,rp,void 0,void 0,void 0,il,Ba,sp,void 0,ip.bind(void 0,0),ip.bind(void 0,1),Ad.bind(void 0,rl),Ad.bind(void 0,nl),J0.bind(void 0,0),J0.bind(void 0,1),op.bind(void 0,0),op.bind(void 0,1),ap.bind(void 0,0),ap.bind(void 0,1),lp,cp,ef.bind(void 0,0),ef.bind(void 0,1),up,dp,Td.bind(void 0,0),Td.bind(void 0,1),fp,hp,pp,Cd,k1,_1,mp.bind(void 0,0),mp.bind(void 0,1),void 0,Xo.bind(void 0,0),Xo.bind(void 0,1),kd,void 0,_d,void 0,void 0,tf,L1,Ld,E1,I1,R1,N1,nf,rf,Xc,sf,Ed,M1,of.bind(void 0,1),D1,af,j1,P1,B1,F1,O1,Q1,$1,gp,Iu.bind(void 0,0),Iu.bind(void 0,1),Iu.bind(void 0,2),Iu.bind(void 0,3),void 0,void 0,void 0,void 0,Id,of.bind(void 0,2),of.bind(void 0,3),Rd.bind(void 0,1),Rd.bind(void 0,2),Rd.bind(void 0,3),xp,H1,void 0,void 0,bp,void 0,Nd,lf,Z0,Z0,void 0,void 0,void 0,void 0,void 0,yp,cf.bind(void 0,0),cf.bind(void 0,1),vp,void 0,wp,Sp,Md,Ei,Ap,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,Fa.bind(void 0,1),Fa.bind(void 0,2),Fa.bind(void 0,3),Fa.bind(void 0,4),Fa.bind(void 0,5),Fa.bind(void 0,6),Fa.bind(void 0,7),Fa.bind(void 0,8),Ml.bind(void 0,1),Ml.bind(void 0,2),Ml.bind(void 0,3),Ml.bind(void 0,4),Ml.bind(void 0,5),Ml.bind(void 0,6),Ml.bind(void 0,7),Ml.bind(void 0,8),wn.bind(void 0,0,0,0,0,0),wn.bind(void 0,0,0,0,0,1),wn.bind(void 0,0,0,0,0,2),wn.bind(void 0,0,0,0,0,3),wn.bind(void 0,0,0,0,1,0),wn.bind(void 0,0,0,0,1,1),wn.bind(void 0,0,0,0,1,2),wn.bind(void 0,0,0,0,1,3),wn.bind(void 0,0,0,1,0,0),wn.bind(void 0,0,0,1,0,1),wn.bind(void 0,0,0,1,0,2),wn.bind(void 0,0,0,1,0,3),wn.bind(void 0,0,0,1,1,0),wn.bind(void 0,0,0,1,1,1),wn.bind(void 0,0,0,1,1,2),wn.bind(void 0,0,0,1,1,3),wn.bind(void 0,0,1,0,0,0),wn.bind(void 0,0,1,0,0,1),wn.bind(void 0,0,1,0,0,2),wn.bind(void 0,0,1,0,0,3),wn.bind(void 0,0,1,0,1,0),wn.bind(void 0,0,1,0,1,1),wn.bind(void 0,0,1,0,1,2),wn.bind(void 0,0,1,0,1,3),wn.bind(void 0,0,1,1,0,0),wn.bind(void 0,0,1,1,0,1),wn.bind(void 0,0,1,1,0,2),wn.bind(void 0,0,1,1,0,3),wn.bind(void 0,0,1,1,1,0),wn.bind(void 0,0,1,1,1,1),wn.bind(void 0,0,1,1,1,2),wn.bind(void 0,0,1,1,1,3),wn.bind(void 0,1,0,0,0,0),wn.bind(void 0,1,0,0,0,1),wn.bind(void 0,1,0,0,0,2),wn.bind(void 0,1,0,0,0,3),wn.bind(void 0,1,0,0,1,0),wn.bind(void 0,1,0,0,1,1),wn.bind(void 0,1,0,0,1,2),wn.bind(void 0,1,0,0,1,3),wn.bind(void 0,1,0,1,0,0),wn.bind(void 0,1,0,1,0,1),wn.bind(void 0,1,0,1,0,2),wn.bind(void 0,1,0,1,0,3),wn.bind(void 0,1,0,1,1,0),wn.bind(void 0,1,0,1,1,1),wn.bind(void 0,1,0,1,1,2),wn.bind(void 0,1,0,1,1,3),wn.bind(void 0,1,1,0,0,0),wn.bind(void 0,1,1,0,0,1),wn.bind(void 0,1,1,0,0,2),wn.bind(void 0,1,1,0,0,3),wn.bind(void 0,1,1,0,1,0),wn.bind(void 0,1,1,0,1,1),wn.bind(void 0,1,1,0,1,2),wn.bind(void 0,1,1,0,1,3),wn.bind(void 0,1,1,1,0,0),wn.bind(void 0,1,1,1,0,1),wn.bind(void 0,1,1,1,0,2),wn.bind(void 0,1,1,1,0,3),wn.bind(void 0,1,1,1,1,0),wn.bind(void 0,1,1,1,1,1),wn.bind(void 0,1,1,1,1,2),wn.bind(void 0,1,1,1,1,3)];var Tp=fo;function Zc(l){this.char=l,this.state={},this.activeState=null}function uf(l,d,h){this.contextName=h,this.startIndex=l,this.endOffset=d}function df(l,d,h){this.contextName=l,this.openRange=null,this.ranges=[],this.checkStart=d,this.checkEnd=h}function Ii(l,d){this.context=l,this.index=d,this.length=l.length,this.current=l[d],this.backtrack=l.slice(0,d),this.lookahead=l.slice(d+1)}function Jc(l){this.eventId=l,this.subscribers=[]}function ff(l){let d=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let m=0;m<d.length;m++){let b=d[m];Object.defineProperty(this.events,b,{value:new Jc(b)})}if(l)for(let m=0;m<d.length;m++){let b=d[m],w=l[b];typeof w=="function"&&this.events[b].subscribe(w)}let h=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let m=0;m<h.length;m++){let b=h[m];this.events[b].subscribe(this.updateContextsRanges)}}function bs(l){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],ff.call(this,l)}Zc.prototype.setState=function(l,d){return this.state[l]=d,this.activeState={key:l,value:this.state[l]},this.activeState},Zc.prototype.getState=function(l){return this.state[l]||null},bs.prototype.inboundIndex=function(l){return l>=0&&l<this.tokens.length},bs.prototype.composeRUD=function(l){let d=l.map(m=>this[m[0]].apply(this,m.slice(1).concat(!0))),h=m=>typeof m=="object"&&Object.prototype.hasOwnProperty.call(m,"FAIL");if(d.every(h))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:d.filter(h)};this.dispatch("composeRUD",[d.filter(m=>!h(m))])},bs.prototype.replaceRange=function(l,d,h,m){d=d!==null?d:this.tokens.length;let b=h.every(w=>w instanceof Zc);if(!isNaN(l)&&this.inboundIndex(l)&&b){let w=this.tokens.splice.apply(this.tokens,[l,d].concat(h));return m||this.dispatch("replaceToken",[l,d,h]),[w,h]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},bs.prototype.replaceToken=function(l,d,h){if(!isNaN(l)&&this.inboundIndex(l)&&d instanceof Zc){let m=this.tokens.splice(l,1,d);return h||this.dispatch("replaceToken",[l,d]),[m[0],d]}else return{FAIL:"replaceToken: invalid token or index."}},bs.prototype.removeRange=function(l,d,h){d=isNaN(d)?this.tokens.length:d;let m=this.tokens.splice(l,d);return h||this.dispatch("removeRange",[m,l,d]),m},bs.prototype.removeToken=function(l,d){if(!isNaN(l)&&this.inboundIndex(l)){let h=this.tokens.splice(l,1);return d||this.dispatch("removeToken",[h,l]),h}else return{FAIL:"removeToken: invalid token index."}},bs.prototype.insertToken=function(l,d,h){return l.every(m=>m instanceof Zc)?(this.tokens.splice.apply(this.tokens,[d,0].concat(l)),h||this.dispatch("insertToken",[l,d]),l):{FAIL:"insertToken: invalid token(s)."}},bs.prototype.registerModifier=function(l,d,h){this.events.newToken.subscribe(function(m,b){let w=[m,b],_=d===null||d.apply(this,w)===!0,I=[m,b];if(_){let R=h.apply(this,I);m.setState(l,R)}}),this.registeredModifiers.push(l)},Jc.prototype.subscribe=function(l){return typeof l=="function"?this.subscribers.push(l)-1:{FAIL:`invalid '${this.eventId}' event handler`}},Jc.prototype.unsubscribe=function(l){this.subscribers.splice(l,1)},Ii.prototype.setCurrentIndex=function(l){this.index=l,this.current=this.context[l],this.backtrack=this.context.slice(0,l),this.lookahead=this.context.slice(l+1)},Ii.prototype.get=function(l){switch(!0){case l===0:return this.current;case(l<0&&Math.abs(l)<=this.backtrack.length):return this.backtrack.slice(l)[0];case(l>0&&l<=this.lookahead.length):return this.lookahead[l-1];default:return null}},bs.prototype.rangeToText=function(l){if(l instanceof uf)return this.getRangeTokens(l).map(d=>d.char).join("")},bs.prototype.getText=function(){return this.tokens.map(l=>l.char).join("")},bs.prototype.getContext=function(l){return this.registeredContexts[l]||null},bs.prototype.on=function(l,d){let h=this.events[l];return h?h.subscribe(d):null},bs.prototype.dispatch=function(l,d){let h=this.events[l];if(h instanceof Jc)for(let m=0;m<h.subscribers.length;m++)h.subscribers[m].apply(this,d||[])},bs.prototype.registerContextChecker=function(l,d,h){if(this.getContext(l))return{FAIL:`context name '${l}' is already registered.`};if(typeof d!="function")return{FAIL:"missing context start check."};if(typeof h!="function")return{FAIL:"missing context end check."};let m=new df(l,d,h);return this.registeredContexts[l]=m,this.contextCheckers.push(m),m},bs.prototype.getRangeTokens=function(l){let d=l.startIndex+l.endOffset;return[].concat(this.tokens.slice(l.startIndex,d))},bs.prototype.getContextRanges=function(l){let d=this.getContext(l);return d?d.ranges:{FAIL:`context checker '${l}' is not registered.`}},bs.prototype.resetContextsRanges=function(){let l=this.registeredContexts;for(let d in l)if(Object.prototype.hasOwnProperty.call(l,d)){let h=l[d];h.ranges=[]}},bs.prototype.updateContextsRanges=function(){this.resetContextsRanges();let l=this.tokens.map(d=>d.char);for(let d=0;d<l.length;d++){let h=new Ii(l,d);this.runContextCheck(h)}this.dispatch("updateContextsRanges",[this.registeredContexts])},bs.prototype.setEndOffset=function(l,d){let h=this.getContext(d).openRange.startIndex,m=new uf(h,l,d),b=this.getContext(d).ranges;return m.rangeId=`${d}.${b.length}`,b.push(m),this.getContext(d).openRange=null,m},bs.prototype.runContextCheck=function(l){let d=l.index;for(let h=0;h<this.contextCheckers.length;h++){let m=this.contextCheckers[h],b=m.contextName,w=this.getContext(b).openRange;if(!w&&m.checkStart(l)&&(w=new uf(d,null,b),this.getContext(b).openRange=w,this.dispatch("contextStart",[b,d])),w&&m.checkEnd(l)){let _=d-w.startIndex+1,I=this.setEndOffset(_,b);this.dispatch("contextEnd",[b,I])}}},bs.prototype.tokenize=function(l){this.tokens=[],this.resetContextsRanges();let d=Array.from(l);this.dispatch("start");for(let h=0;h<d.length;h++){let m=d[h],b=new Ii(d,h);this.dispatch("next",[b]),this.runContextCheck(b);let w=new Zc(m);this.tokens.push(w),this.dispatch("newToken",[w,b])}return this.dispatch("end",[this.tokens]),this.tokens};var hf=bs;function ec(l){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(l)}function pf(l){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(l)}function tc(l){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(l)}function Ru(l){return/[\u0E00-\u0E7F]/.test(l)}function Dd(l){return/[A-z]/.test(l)}function Cp(l){return/\s/.test(l)}function Zo(l){this.font=l,this.features={}}function nc(l){this.id=l.id,this.tag=l.tag,this.substitution=l.substitution}function Dl(l,d){if(!l)return-1;switch(d.format){case 1:return d.glyphs.indexOf(l);case 2:{let h=d.ranges;for(let m=0;m<h.length;m++){let b=h[m];if(l>=b.start&&l<=b.end){let w=l-b.start;return b.index+w}}break}default:return-1}return-1}function kp(l,d){return Dl(l,d.coverage)===-1?null:l+d.deltaGlyphId}function mf(l,d){let h=Dl(l,d.coverage);return h===-1?null:d.substitute[h]}function jd(l,d){let h=[];for(let m=0;m<l.length;m++){let b=l[m],w=d.current;w=Array.isArray(w)?w[0]:w;let _=Dl(w,b);_!==-1&&h.push(_)}return h.length!==l.length?-1:h}function z1(l,d){let h=d.inputCoverage.length+d.lookaheadCoverage.length+d.backtrackCoverage.length;if(l.context.length<h)return[];let m=jd(d.inputCoverage,l);if(m===-1)return[];let b=d.inputCoverage.length-1;if(l.lookahead.length<d.lookaheadCoverage.length)return[];let w=l.lookahead.slice(b);for(;w.length&&tc(w[0].char);)w.shift();let _=new Ii(w,0),I=jd(d.lookaheadCoverage,_),R=[].concat(l.backtrack);for(R.reverse();R.length&&tc(R[0].char);)R.shift();if(R.length<d.backtrackCoverage.length)return[];let z=new Ii(R,0),O=jd(d.backtrackCoverage,z),se=m.length===d.inputCoverage.length&&I.length===d.lookaheadCoverage.length&&O.length===d.backtrackCoverage.length,ne=[];if(se)for(let _e=0;_e<d.lookupRecords.length;_e++){let xe=d.lookupRecords[_e],Be=xe.lookupListIndex,dt=this.getLookupByIndex(Be);for(let Dn=0;Dn<dt.subtables.length;Dn++){let An=dt.subtables[Dn],Jn,Lr=this.getSubstitutionType(dt,An);if(Lr==="71"?(Lr=this.getSubstitutionType(An,An.extension),Jn=this.getLookupMethod(An,An.extension),An=An.extension):Jn=this.getLookupMethod(dt,An),Lr==="12"){let ls=l.get(xe.sequenceIndex),ms=Jn(ls);ms&&ne.push(ms)}else if(Lr==="21"){let ls=l.get(xe.sequenceIndex),ms=Jn(ls);ms&&ne.push(ms)}else throw new Error(`Substitution type ${Lr} is not supported in chaining substitution`)}}return ne}function _p(l,d){let h=l.current,m=Dl(h,d.coverage);if(m===-1)return null;let b,w=d.ligatureSets[m];for(let _=0;_<w.length;_++){b=w[_];for(let I=0;I<b.components.length;I++){let R=l.lookahead[I],z=b.components[I];if(R!==z)break;if(I===b.components.length-1)return b}}return null}function Pd(l,d){let h=l.current;if(Dl(h,d.coverage)===-1)return null;for(let m of d.ruleSets)for(let b of m){let w=!0;for(let _=0;_<b.input.length;_++)if(l.lookahead[_]!==b.input[_]){w=!1;break}if(w){let _=[];_.push(h);for(let R=0;R<b.input.length;R++)_.push(b.input[R]);let I=(R,z)=>{let{lookupListIndex:O,sequenceIndex:se}=z,{subtables:ne}=this.getLookupByIndex(O);for(let _e of ne)Dl(R[se],_e.coverage)!==-1&&(R[se]=_e.deltaGlyphId)};for(let R=0;R<b.lookupRecords.length;R++){let z=b.lookupRecords[R];I(_,z)}return _}}return null}function k(l,d){if(l.context.length<d.coverages.length)return[];for(let m=0;m<d.coverages.length;m++){let b=l.get(m);if(b=Array.isArray(b)?b[0]:b,Dl(b,d.coverages[m])===-1)return[]}let h=[];for(let m=0;m<d.lookupRecords.length;m++){let b=d.lookupRecords[m],w=b.lookupListIndex,_=this.getLookupByIndex(w);for(let I=0;I<_.subtables.length;I++){let R=_.subtables[I],z,O=this.getSubstitutionType(_,R);if(O==="71"?(O=this.getSubstitutionType(R,R.extension),z=this.getLookupMethod(R,R.extension),R=R.extension):z=this.getLookupMethod(_,R),O==="12"){let se=l.get(b.sequenceIndex),ne=z(se);ne&&h.push(ne)}else if(O==="21"){let se=l.get(b.sequenceIndex),ne=z(se);ne&&h.push(ne)}}}return h}function H(l,d){let h=Dl(l,d.coverage);return h===-1?null:d.sequences[h]}Zo.prototype.getDefaultScriptFeaturesIndexes=function(){let l=this.font.tables.gsub.scripts;for(let d=0;d<l.length;d++){let h=l[d];if(h.tag==="DFLT")return h.script.defaultLangSys.featureIndexes}return[]},Zo.prototype.getScriptFeaturesIndexes=function(l){if(!this.font.tables.gsub)return[];if(!l)return this.getDefaultScriptFeaturesIndexes();let d=this.font.tables.gsub.scripts;for(let h=0;h<d.length;h++){let m=d[h];if(m.tag===l&&m.script.defaultLangSys)return m.script.defaultLangSys.featureIndexes;{let b=m.langSysRecords;if(b)for(let w=0;w<b.length;w++){let _=b[w];if(_.tag===l)return _.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Zo.prototype.mapTagsToFeatures=function(l,d){let h={};for(let m=0;m<l.length;m++){let b=l[m].tag,w=l[m].feature;h[b]=w}this.features[d].tags=h},Zo.prototype.getScriptFeatures=function(l){let d=this.features[l];if(Object.prototype.hasOwnProperty.call(this.features,l))return d;let h=this.getScriptFeaturesIndexes(l);if(!h)return null;let m=this.font.tables.gsub;return d=h.map(b=>m.features[b]),this.features[l]=d,this.mapTagsToFeatures(d,l),d},Zo.prototype.getSubstitutionType=function(l,d){let h=l.lookupType.toString(),m=d.substFormat.toString();return h+m},Zo.prototype.getLookupMethod=function(l,d){let h=this.getSubstitutionType(l,d);switch(h){case"11":return m=>kp.apply(this,[m,d]);case"12":return m=>mf.apply(this,[m,d]);case"63":return m=>z1.apply(this,[m,d]);case"41":return m=>_p.apply(this,[m,d]);case"21":return m=>H.apply(this,[m,d]);case"51":return m=>Pd.apply(this,[m,d]);case"53":return m=>k.apply(this,[m,d]);default:throw new Error(`substitutionType : ${h} lookupType: ${l.lookupType} - substFormat: ${d.substFormat} is not yet supported`)}},Zo.prototype.lookupFeature=function(l){let d=l.contextParams,h=d.index,m=this.getFeature({tag:l.tag,script:l.script});if(!m)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${l.tag}' for script '${l.script}'.`);let b=this.getFeatureLookups(m),w=[].concat(d.context);for(let _=0;_<b.length;_++){let I=b[_],R=this.getLookupSubtables(I);for(let z=0;z<R.length;z++){let O=R[z],se=this.getSubstitutionType(I,O),ne;se==="71"?(se=this.getSubstitutionType(O,O.extension),ne=this.getLookupMethod(O,O.extension),O=O.extension):ne=this.getLookupMethod(I,O);let _e;switch(se){case"11":_e=ne(d.current),_e&&w.splice(h,1,new nc({id:11,tag:l.tag,substitution:_e}));break;case"12":_e=ne(d.current),_e&&w.splice(h,1,new nc({id:12,tag:l.tag,substitution:_e}));break;case"63":_e=ne(d),Array.isArray(_e)&&_e.length&&w.splice(h,1,new nc({id:63,tag:l.tag,substitution:_e}));break;case"41":_e=ne(d),_e&&w.splice(h,1,new nc({id:41,tag:l.tag,substitution:_e}));break;case"21":_e=ne(d.current),_e&&w.splice(h,1,new nc({id:21,tag:l.tag,substitution:_e}));break;case"51":case"53":_e=ne(d),Array.isArray(_e)&&_e.length&&w.splice(h,1,new nc({id:parseInt(se),tag:l.tag,substitution:_e}));break}d=new Ii(w,h),!(Array.isArray(_e)&&!_e.length)&&(_e=null)}}return w.length?w:null},Zo.prototype.supports=function(l){if(!l.script)return!1;this.getScriptFeatures(l.script);let d=Object.prototype.hasOwnProperty.call(this.features,l.script);if(!l.tag)return d;let h=this.features[l.script].some(m=>m.tag===l.tag);return d&&h},Zo.prototype.getLookupSubtables=function(l){return l.subtables||null},Zo.prototype.getLookupByIndex=function(l){return this.font.tables.gsub.lookups[l]||null},Zo.prototype.getFeatureLookups=function(l){return l.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Zo.prototype.getFeature=function(l){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,l.script)||this.getScriptFeatures(l.script);let d=this.features[l.script];return d?d.tags[l.tag]?this.features[l.script].tags[l.tag]:null:{FAIL:`No feature for script ${l.script}`}};var J=Zo;function Ee(l){let d=l.current,h=l.get(-1);return h===null&&ec(d)||!ec(h)&&ec(d)}function je(l){let d=l.get(1);return d===null||!ec(d)}var Je={startCheck:Ee,endCheck:je};function bt(l){let d=l.current,h=l.get(-1);return(ec(d)||tc(d))&&!ec(h)}function Ct(l){let d=l.get(1);switch(!0){case d===null:return!0;case(!ec(d)&&!tc(d)):{let h=Cp(d);if(!h)return!0;if(h){let m=!1;if(m=l.lookahead.some(b=>ec(b)||tc(b)),!m)return!0}break}default:return!1}}var Ut={startCheck:bt,endCheck:Ct};function Pr(l,d,h){d[h].setState(l.tag,l.substitution)}function ui(l,d,h){d[h].setState(l.tag,l.substitution)}function as(l,d,h){for(let m=0;m<l.substitution.length;m++){let b=l.substitution[m],w=d[h+m];if(Array.isArray(b)){b.length?w.setState(l.tag,b[0]):w.setState("deleted",!0);continue}w.setState(l.tag,b)}}function tr(l,d,h){let m=d[h];m.setState(l.tag,l.substitution.ligGlyph);let b=l.substitution.components.length;for(let w=0;w<b;w++)m=d[h+w+1],m.setState("deleted",!0)}var Ps={11:Pr,12:ui,63:as,41:tr,51:as,53:as};function dr(l,d,h){l instanceof nc&&Ps[l.id]&&Ps[l.id](l,d,h)}var jo=dr;function Ck(l){let d=[].concat(l.backtrack);for(let h=d.length-1;h>=0;h--){let m=d[h],b=pf(m),w=tc(m);if(!b&&!w)return!0;if(b)return!1}return!1}function kk(l){if(pf(l.current))return!1;for(let d=0;d<l.lookahead.length;d++){let h=l.lookahead[d];if(!tc(h))return!0}return!1}function _k(l){let d="arab",h=this.featuresTags[d],m=this.tokenizer.getRangeTokens(l);if(m.length===1)return;let b=new Ii(m.map(_=>_.getState("glyphIndex")),0),w=new Ii(m.map(_=>_.char),0);for(let _=0;_<m.length;_++){let I=m[_];if(tc(I.char))continue;b.setCurrentIndex(_),w.setCurrentIndex(_);let R=0;Ck(w)&&(R|=1),kk(w)&&(R|=2);let z;switch(R){case 1:z="fina";break;case 2:z="init";break;case 3:z="medi";break}if(h.indexOf(z)===-1)continue;let O=this.query.lookupFeature({tag:z,script:d,contextParams:b});if(O instanceof Error){console.info(O.message);continue}for(let se=0;se<O.length;se++){let ne=O[se];ne instanceof nc&&(jo(ne,m,se),b.context[se]=ne.substitution)}}}var Lk=_k;function i5(l,d){let h=l.map(m=>m.activeState.value);return new Ii(h,d||0)}function Ek(l){let d="arab",h=this.tokenizer.getRangeTokens(l),m=i5(h);for(let b=0;b<m.context.length;b++){m.setCurrentIndex(b);let w=this.query.lookupFeature({tag:"rlig",script:d,contextParams:m});if(w.length){for(let _=0;_<w.length;_++){let I=w[_];jo(I,h,b)}m=i5(h)}}}var Ik=Ek;function Rk(l){return l.index===0&&l.context.length>1}function Nk(l){return l.index===l.context.length-1}var Mk={startCheck:Rk,endCheck:Nk};function o5(l,d){let h=l.map(m=>m.activeState.value);return new Ii(h,d||0)}function Dk(l){let d="delf",h="ccmp",m=this.tokenizer.getRangeTokens(l),b=o5(m);for(let w=0;w<b.context.length;w++){if(!this.query.getFeature({tag:h,script:d,contextParams:b}))continue;b.setCurrentIndex(w);let _=this.query.lookupFeature({tag:h,script:d,contextParams:b});if(_.length){for(let I=0;I<_.length;I++){let R=_[I];jo(R,m,w)}b=o5(m)}}}var jk=Dk;function Pk(l){let d=l.current,h=l.get(-1);return h===null&&Dd(d)||!Dd(h)&&Dd(d)}function Bk(l){let d=l.get(1);return d===null||!Dd(d)}var Fk={startCheck:Pk,endCheck:Bk};function a5(l,d){let h=l.map(m=>m.activeState.value);return new Ii(h,d||0)}function Ok(l){let d="latn",h=this.tokenizer.getRangeTokens(l),m=a5(h);for(let b=0;b<m.context.length;b++){m.setCurrentIndex(b);let w=this.query.lookupFeature({tag:"liga",script:d,contextParams:m});if(w.length){for(let _=0;_<w.length;_++){let I=w[_];jo(I,h,b)}m=a5(h)}}}var Qk=Ok;function $k(l){let d=l.current,h=l.get(-1);return h===null&&Ru(d)||!Ru(h)&&Ru(d)}function Hk(l){let d=l.get(1);return d===null||!Ru(d)}var zk={startCheck:$k,endCheck:Hk};function l5(l,d){let h=l.map(m=>m.activeState.value);return new Ii(h,d||0)}function Uk(l){let d="thai",h=this.tokenizer.getRangeTokens(l),m=l5(h,0);for(let b=0;b<m.context.length;b++){m.setCurrentIndex(b);let w=this.query.lookupFeature({tag:"ccmp",script:d,contextParams:m});if(w.length){for(let _=0;_<w.length;_++){let I=w[_];jo(I,h,b)}m=l5(h,b)}}}var Gk=Uk;function c5(l,d){let h=l.map(m=>m.activeState.value);return new Ii(h,d||0)}function Wk(l){let d="thai",h=this.tokenizer.getRangeTokens(l),m=c5(h,0);for(let b=0;b<m.context.length;b++){m.setCurrentIndex(b);let w=this.query.lookupFeature({tag:"liga",script:d,contextParams:m});if(w.length){for(let _=0;_<w.length;_++){let I=w[_];jo(I,h,b)}m=c5(h,b)}}}var Vk=Wk;function u5(l,d){let h=l.map(m=>m.activeState.value);return new Ii(h,d||0)}function qk(l){let d="thai",h=this.tokenizer.getRangeTokens(l),m=u5(h,0);for(let b=0;b<m.context.length;b++){m.setCurrentIndex(b);let w=this.query.lookupFeature({tag:"rlig",script:d,contextParams:m});if(w.length){for(let _=0;_<w.length;_++){let I=w[_];jo(I,h,b)}m=u5(h,b)}}}var Kk=qk;function U1(l){if(l===null)return!1;let d=l.codePointAt(0);return d>=6155&&d<=6157||d>=65024&&d<=65039||d>=917760&&d<=917999}function Yk(l){let d=l.current,h=l.get(1);return h===null&&U1(d)||U1(h)}function Xk(l){let d=l.get(1);return d===null||!U1(d)}var Zk={startCheck:Yk,endCheck:Xk};function Jk(l){let d=this.query.font,h=this.tokenizer.getRangeTokens(l);if(h[1].setState("deleted",!0),d.tables.cmap&&d.tables.cmap.varSelectorList){let m=h[0].char.codePointAt(0),b=h[1].char.codePointAt(0),w=d.tables.cmap.varSelectorList[b];if(w!==void 0&&w.nonDefaultUVS){let _=w.nonDefaultUVS.uvsMappings;if(_[m]){let I=_[m].glyphID;d.glyphs.glyphs[I]!==void 0&&h[0].setState("glyphIndex",I)}}}}var e_=Jk;function ol(l){this.baseDir=l||"ltr",this.tokenizer=new hf,this.featuresTags={}}ol.prototype.setText=function(l){this.text=l},ol.prototype.contextChecks={ccmpReplacementCheck:Mk,latinWordCheck:Fk,arabicWordCheck:Je,arabicSentenceCheck:Ut,thaiWordCheck:zk,unicodeVariationSequenceCheck:Zk};function Bd(l){let d=this.contextChecks[`${l}Check`];return this.tokenizer.registerContextChecker(l,d.startCheck,d.endCheck)}function t_(){return Bd.call(this,"ccmpReplacement"),Bd.call(this,"latinWord"),Bd.call(this,"arabicWord"),Bd.call(this,"arabicSentence"),Bd.call(this,"thaiWord"),Bd.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function n_(){let l=this.tokenizer.getContextRanges("arabicSentence");for(let d=0;d<l.length;d++){let h=l[d],m=this.tokenizer.getRangeTokens(h);this.tokenizer.replaceRange(h.startIndex,h.endOffset,m.reverse())}}ol.prototype.registerFeatures=function(l,d){let h=d.filter(m=>this.query.supports({script:l,tag:m}));Object.prototype.hasOwnProperty.call(this.featuresTags,l)?this.featuresTags[l]=this.featuresTags[l].concat(h):this.featuresTags[l]=h},ol.prototype.applyFeatures=function(l,d){if(!l)throw new Error("No valid font was provided to apply features");this.query||(this.query=new J(l));for(let h=0;h<d.length;h++){let m=d[h];this.query.supports({script:m.script})&&this.registerFeatures(m.script,m.tags)}},ol.prototype.registerModifier=function(l,d,h){this.tokenizer.registerModifier(l,d,h)};function gf(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function r_(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;gf.call(this);let l=this.tokenizer.getContextRanges("arabicWord");for(let d=0;d<l.length;d++){let h=l[d];Lk.call(this,h)}}function s_(){gf.call(this);let l=this.tokenizer.getContextRanges("ccmpReplacement");for(let d=0;d<l.length;d++){let h=l[d];jk.call(this,h)}}function i_(){if(!this.hasFeatureEnabled("arab","rlig"))return;gf.call(this);let l=this.tokenizer.getContextRanges("arabicWord");for(let d=0;d<l.length;d++){let h=l[d];Ik.call(this,h)}}function o_(){if(!this.hasFeatureEnabled("latn","liga"))return;gf.call(this);let l=this.tokenizer.getContextRanges("latinWord");for(let d=0;d<l.length;d++){let h=l[d];Qk.call(this,h)}}function a_(){let l=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let d=0;d<l.length;d++){let h=l[d];e_.call(this,h)}}function l_(){gf.call(this);let l=this.tokenizer.getContextRanges("thaiWord");for(let d=0;d<l.length;d++){let h=l[d];this.hasFeatureEnabled("thai","liga")&&Vk.call(this,h),this.hasFeatureEnabled("thai","rlig")&&Kk.call(this,h),this.hasFeatureEnabled("thai","ccmp")&&Gk.call(this,h)}}ol.prototype.checkContextReady=function(l){return!!this.tokenizer.getContext(l)},ol.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&s_.call(this),this.checkContextReady("arabicWord")&&(r_.call(this),i_.call(this)),this.checkContextReady("latinWord")&&o_.call(this),this.checkContextReady("arabicSentence")&&n_.call(this),this.checkContextReady("thaiWord")&&l_.call(this),this.checkContextReady("unicodeVariationSequence")&&a_.call(this)},ol.prototype.hasFeatureEnabled=function(l,d){return(this.featuresTags[l]||[]).indexOf(d)!==-1},ol.prototype.processText=function(l){(!this.text||this.text!==l)&&(this.setText(l),t_.call(this),this.applyFeaturesToContexts())},ol.prototype.getBidiText=function(l){return this.processText(l),this.tokenizer.getText()},ol.prototype.getTextGlyphs=function(l){this.processText(l);let d=[];for(let h=0;h<this.tokenizer.tokens.length;h++){let m=this.tokenizer.tokens[h];if(m.state.deleted)continue;let b=m.activeState.value;d.push(Array.isArray(b)?b[0]:b)}return d};var c_=ol;function G1(l){return{fontFamily:{en:l.familyName||" "},fontSubfamily:{en:l.styleName||" "},fullName:{en:l.fullName||l.familyName+" "+l.styleName},postScriptName:{en:l.postScriptName||(l.familyName+l.styleName).replace(/\s/g,"")},designer:{en:l.designer||" "},designerURL:{en:l.designerURL||" "},manufacturer:{en:l.manufacturer||" "},manufacturerURL:{en:l.manufacturerURL||" "},license:{en:l.license||" "},licenseURL:{en:l.licenseURL||" "},version:{en:l.version||"Version 0.1"},description:{en:l.description||" "},copyright:{en:l.copyright||" "},trademark:{en:l.trademark||" "}}}function hs(l){if(l=l||{},l.tables=l.tables||{},!l.empty){if(!l.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!l.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!l.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!l.ascender)throw new Error("When creating a new Font object, ascender is required.");if(l.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=G1(l),this.names.macintosh=G1(l),this.names.windows=G1(l),this.unitsPerEm=l.unitsPerEm||1e3,this.ascender=l.ascender,this.descender=l.descender,this.createdTimestamp=l.createdTimestamp,this.italicAngle=l.italicAngle||0,this.weightClass=l.weightClass||0;let d=0;l.fsSelection?d=l.fsSelection:(this.italicAngle<0?d|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(d|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(d|=this.fsSelectionValues.BOLD),d===0&&(d=this.fsSelectionValues.REGULAR)),(!l.panose||!Array.isArray(l.panose))&&(l.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(l.tables,{os2:Object.assign({usWeightClass:l.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:l.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:l.panose[0]||0,bSerifStyle:l.panose[1]||0,bWeight:l.panose[2]||0,bProportion:l.panose[3]||0,bContrast:l.panose[4]||0,bStrokeVariation:l.panose[5]||0,bArmStyle:l.panose[6]||0,bLetterform:l.panose[7]||0,bMidline:l.panose[8]||0,bXHeight:l.panose[9]||0,fsSelection:d},l.tables.os2)})}this.supported=!0,this.glyphs=new cn.GlyphSet(this,l.glyphs||[]),this.encoding=new nr(this),this.position=new Vo(this),this.substitution=new Xl(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(d,h,m)=>(d[h]=m,d.fvar&&(d.gvar||d.cff2)&&!this.variation&&(this.variation=new dn(this)),!0)}),this.palettes=new gd(this),this.layers=new Tu(this),this.svgImages=new Zl(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new Tp(this):null}})}hs.prototype.hasChar=function(l){return this.encoding.charToGlyphIndex(l)>0},hs.prototype.charToGlyphIndex=function(l){return this.encoding.charToGlyphIndex(l)},hs.prototype.charToGlyph=function(l){let d=this.charToGlyphIndex(l),h=this.glyphs.get(d);return h||(h=this.glyphs.get(0)),h},hs.prototype.updateFeatures=function(l){return this.defaultRenderOptions.features.map(d=>d.script==="latn"?{script:"latn",tags:d.tags.filter(h=>l[h])}:d)},hs.prototype.stringToGlyphIndexes=function(l,d){let h=new c_,m=w=>this.charToGlyphIndex(w.char);h.registerModifier("glyphIndex",null,m);let b=d?this.updateFeatures(d.features):this.defaultRenderOptions.features;return h.applyFeatures(this,b),h.getTextGlyphs(l)},hs.prototype.stringToGlyphs=function(l,d){let h=this.stringToGlyphIndexes(l,d),m=h.length,b=new Array(m),w=this.glyphs.get(0);for(let _=0;_<m;_+=1)b[_]=this.glyphs.get(h[_])||w;return b},hs.prototype.nameToGlyphIndex=function(l){return this.glyphNames.nameToGlyphIndex(l)},hs.prototype.nameToGlyph=function(l){let d=this.nameToGlyphIndex(l),h=this.glyphs.get(d);return h||(h=this.glyphs.get(0)),h},hs.prototype.glyphIndexToName=function(l){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(l):""},hs.prototype.getKerningValue=function(l,d){l=l.index||l,d=d.index||d;let h=this.position.defaultKerningTables;return h?this.position.getKerningValue(h,l,d):this.kerningPairs[l+","+d]||0},hs.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},hs.prototype.forEachGlyph=function(l,d,h,m,b,w){d=d!==void 0?d:0,h=h!==void 0?h:0,m=m!==void 0?m:72,b=Object.assign({},this.defaultRenderOptions,b);let _=1/this.unitsPerEm*m,I=this.stringToGlyphs(l,b),R;if(b.kerning){let z=b.script||this.position.getDefaultScriptName();R=this.position.getKerningTables(z,b.language)}for(let z=0;z<I.length;z+=1){let O=I[z];if(w.call(this,O,d,h,m,b),O.advanceWidth&&(d+=O.advanceWidth*_),b.kerning&&z<I.length-1){let se=R?this.position.getKerningValue(R,O.index,I[z+1].index):this.getKerningValue(O,I[z+1]);d+=se*_}b.letterSpacing?d+=b.letterSpacing*m:b.tracking&&(d+=b.tracking/1e3*m)}return d},hs.prototype.getPath=function(l,d,h,m,b){b=Object.assign({},this.defaultRenderOptions,b);let w=new ht;if(w._layers=[],Mr(this,w,m),w.stroke){let _=1/(w.unitsPerEm||1e3)*m;w.strokeWidth*=_}return this.forEachGlyph(l,d,h,m,b,(_,I,R,z)=>{let O=_.getPath(I,R,z,b,this);if(b.drawSVG||b.drawLayers){let se=O._layers;if(se&&se.length){for(let ne=0;ne<se.length;ne++){let _e=se[ne];w._layers.push(_e)}return}}w.extend(O)}),w},hs.prototype.getPaths=function(l,d,h,m,b){b=Object.assign({},this.defaultRenderOptions,b);let w=[];return this.forEachGlyph(l,d,h,m,b,function(_,I,R,z){let O=_.getPath(I,R,z,b,this);w.push(O)}),w},hs.prototype.getAdvanceWidth=function(l,d,h){return h=Object.assign({},this.defaultRenderOptions,h),this.forEachGlyph(l,0,0,d,h,function(){})},hs.prototype.draw=function(l,d,h,m,b,w){this.getPath(d,h,m,b,w).draw(l)},hs.prototype.drawPoints=function(l,d,h,m,b,w){w=Object.assign({},this.defaultRenderOptions,w),this.forEachGlyph(d,h,m,b,w,function(_,I,R,z){_.drawPoints(l,I,R,z,w,this)})},hs.prototype.drawMetrics=function(l,d,h,m,b,w){w=Object.assign({},this.defaultRenderOptions,w),this.forEachGlyph(d,h,m,b,w,function(_,I,R,z){_.drawMetrics(l,I,R,z)})},hs.prototype.getEnglishName=function(l){let d=(this.names.unicode||this.names.macintosh||this.names.windows)[l];if(d)return d.en},hs.prototype.validate=function(){let l=[],d=this;function h(b,w){b||(console.warn(`[opentype.js] ${w}`),l.push(w))}function m(b){let w=d.getEnglishName(b);h(w&&w.trim().length>0,"No English "+b+" specified.")}if(m("fontFamily"),m("weightName"),m("manufacturer"),m("copyright"),m("version"),h(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let b=this.tables.colr.baseGlyphRecords,w=-1;for(let _=0;_<b.length;_++){let I=b[_].glyphID;if(h(w<b[_].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${I} comes after ${w}`),w>b[_].glyphID)break;w=I}}return l},hs.prototype.toTables=function(){return Tc.fontToTable(this)},hs.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},hs.prototype.toArrayBuffer=function(){let l=this.toTables().encode(),d=new ArrayBuffer(l.length),h=new Uint8Array(d);for(let m=0;m<l.length;m++)h[m]=l[m];return d},hs.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},hs.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},hs.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},hs.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},hs.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var d5=hs;function u_(l,d){let h=new Ne.Parser(l,d),m=h.parseUShort(),b=h.parseUShort();m!==1&&console.warn(`Unsupported hvar table version ${m}.${b}`);let w=[m,b],_=h.parsePointer32(function(){return this.parseItemVariationStore()}),I=h.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),R=h.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),z=h.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:w,itemVariationStore:_,advanceWidth:I,lsb:R,rsb:z}}function d_(){console.warn("Writing of hvar tables is not yet supported.")}var f_={make:d_,parse:u_},h_=function(){return{coverage:this.parsePointer(te.coverage),attachPoints:this.parseList(te.pointer(te.uShortList))}},p_=function(){var l=this.parseUShort();if(re.argument(l===1||l===2||l===3,"Unsupported CaretValue table version."),l===1)return{coordinate:this.parseShort()};if(l===2)return{pointindex:this.parseShort()};if(l===3)return{coordinate:this.parseShort()}},m_=function(){return this.parseList(te.pointer(p_))},g_=function(){return{coverage:this.parsePointer(te.coverage),ligGlyphs:this.parseList(te.pointer(m_))}},x_=function(){return this.parseUShort(),this.parseList(te.pointer(te.coverage))};function b_(l,d){d=d||0;let h=new te(l,d),m=h.parseVersion(1);re.argument(m===1||m===1.2||m===1.3,"Unsupported GDEF table version.");var b={version:m,classDef:h.parsePointer(te.classDef),attachList:h.parsePointer(h_),ligCaretList:h.parsePointer(g_),markAttachClassDef:h.parsePointer(te.classDef)};return m>=1.2&&(b.markGlyphSets=h.parsePointer(x_)),b}var y_={parse:b_},jl=new Array(10);jl[1]=function(){let l=this.offset+this.relativeOffset,d=this.parseUShort();if(d===1)return{posFormat:1,coverage:this.parsePointer(te.coverage),value:this.parseValueRecord()};if(d===2)return{posFormat:2,coverage:this.parsePointer(te.coverage),values:this.parseValueRecordList()};re.assert(!1,"0x"+l.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},jl[2]=function(){let l=this.offset+this.relativeOffset,d=this.parseUShort();re.assert(d===1||d===2,"0x"+l.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let h=this.parsePointer(te.coverage),m=this.parseUShort(),b=this.parseUShort();if(d===1)return{posFormat:d,coverage:h,valueFormat1:m,valueFormat2:b,pairSets:this.parseList(te.pointer(te.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(m),value2:this.parseValueRecord(b)}})))};if(d===2){let w=this.parsePointer(te.classDef),_=this.parsePointer(te.classDef),I=this.parseUShort(),R=this.parseUShort();return{posFormat:d,coverage:h,valueFormat1:m,valueFormat2:b,classDef1:w,classDef2:_,class1Count:I,class2Count:R,classRecords:this.parseList(I,te.list(R,function(){return{value1:this.parseValueRecord(m),value2:this.parseValueRecord(b)}}))}}},jl[3]=function(){return{error:"GPOS Lookup 3 not supported"}},jl[4]=function(){return{error:"GPOS Lookup 4 not supported"}},jl[5]=function(){return{error:"GPOS Lookup 5 not supported"}},jl[6]=function(){return{error:"GPOS Lookup 6 not supported"}},jl[7]=function(){return{error:"GPOS Lookup 7 not supported"}},jl[8]=function(){return{error:"GPOS Lookup 8 not supported"}},jl[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function v_(l,d){d=d||0;let h=new te(l,d),m=h.parseVersion(1);return re.argument(m===1||m===1.1,"Unsupported GPOS table version "+m),m===1?{version:m,scripts:h.parseScriptList(),features:h.parseFeatureList(),lookups:h.parseLookupList(jl)}:{version:m,scripts:h.parseScriptList(),features:h.parseFeatureList(),lookups:h.parseLookupList(jl),variations:h.parseFeatureVariationsList()}}var w_=new Array(10);function S_(l){return new Ve.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new Ve.ScriptList(l.scripts)},{name:"features",type:"TABLE",value:new Ve.FeatureList(l.features)},{name:"lookups",type:"TABLE",value:new Ve.LookupList(l.lookups,w_)}])}var A_={parse:v_,make:S_};function T_(l){let d={};l.skip("uShort");let h=l.parseUShort();re.argument(h===0,"Unsupported kern sub-table version."),l.skip("uShort",2);let m=l.parseUShort();l.skip("uShort",3);for(let b=0;b<m;b+=1){let w=l.parseUShort(),_=l.parseUShort(),I=l.parseShort();d[w+","+_]=I}return d}function C_(l){let d={};l.skip("uShort"),l.parseULong()>1&&console.warn("Only the first kern subtable is supported."),l.skip("uLong");let h=l.parseUShort()&255;if(l.skip("uShort"),h===0){let m=l.parseUShort();l.skip("uShort",3);for(let b=0;b<m;b+=1){let w=l.parseUShort(),_=l.parseUShort(),I=l.parseShort();d[w+","+_]=I}}return d}function k_(l,d){let h=new Ne.Parser(l,d),m=h.parseUShort();if(m===0)return T_(h);if(m===1)return C_(h);throw new Error("Unsupported kern table version ("+m+").")}var __={parse:k_};function L_(l,d,h,m){let b=new Ne.Parser(l,d),w=m?b.parseUShort:b.parseULong,_=[];for(let I=0;I<h+1;I+=1){let R=w.call(b);m&&(R*=2),_.push(R)}return _}var E_={parse:L_};function f5(l,d){let h=[],m=12;for(let b=0;b<d;b+=1){let w=Ne.getTag(l,m),_=Ne.getULong(l,m+4),I=Ne.getULong(l,m+8),R=Ne.getULong(l,m+12);h.push({tag:w,checksum:_,offset:I,length:R,compression:!1}),m+=16}return h}function I_(l,d){let h=[],m=44;for(let b=0;b<d;b+=1){let w=Ne.getTag(l,m),_=Ne.getULong(l,m+4),I=Ne.getULong(l,m+8),R=Ne.getULong(l,m+12),z;I<R?z="WOFF":z=!1,h.push({tag:w,offset:_,compression:z,compressedLength:I,length:R}),m+=20}return h}function os(l,d){if(d.compression==="WOFF"){let h=new Uint8Array(l.buffer,d.offset+2,d.compressedLength-2),m=new Uint8Array(d.length);if(U(h,m),m.byteLength!==d.length)throw new Error("Decompression error: "+d.tag+" decompressed length doesn't match recorded length");return{data:new DataView(m.buffer,0),offset:0}}else return{data:l,offset:d.offset}}function R_(l,d={}){let h,m,b=new d5({empty:!0});l.constructor!==ArrayBuffer&&(l=new Uint8Array(l).buffer);let w=new DataView(l,0),_,I=[],R=Ne.getTag(w,0);if(R==="\0\0\0"||R==="true"||R==="typ1")b.outlinesFormat="truetype",_=Ne.getUShort(w,4),I=f5(w,_);else if(R==="OTTO")b.outlinesFormat="cff",_=Ne.getUShort(w,4),I=f5(w,_);else if(R==="wOFF"){let jn=Ne.getTag(w,4);if(jn==="\0\0\0")b.outlinesFormat="truetype";else if(jn==="OTTO")b.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+R);_=Ne.getUShort(w,12),I=I_(w,_)}else if(R==="wOF2"){let jn="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+jn)}else throw new Error("Unsupported OpenType signature "+R);let z,O,se,ne,_e,xe,Be,dt,Dn,An,Jn,Lr,ls,ms,gs,vi,Pl,Er;for(let jn=0;jn<_;jn+=1){let gn=I[jn],Sn;switch(gn.tag){case"avar":Be=gn;break;case"cmap":Sn=os(w,gn),b.tables.cmap=Me.parse(Sn.data,Sn.offset),b.encoding=new lr(b.tables.cmap);break;case"cvt ":Sn=os(w,gn),Er=new Ne.Parser(Sn.data,Sn.offset),b.tables.cvt=Er.parseShortList(gn.length/2);break;case"fvar":se=gn;break;case"STAT":ne=gn;break;case"gvar":_e=gn;break;case"cvar":xe=gn;break;case"fpgm":Sn=os(w,gn),Er=new Ne.Parser(Sn.data,Sn.offset),b.tables.fpgm=Er.parseByteList(gn.length);break;case"head":Sn=os(w,gn),b.tables.head=Hs.parse(Sn.data,Sn.offset),b.unitsPerEm=b.tables.head.unitsPerEm,h=b.tables.head.indexToLocFormat;break;case"hhea":Sn=os(w,gn),b.tables.hhea=De.parse(Sn.data,Sn.offset),b.ascender=b.tables.hhea.ascender,b.descender=b.tables.hhea.descender,b.numberOfHMetrics=b.tables.hhea.numberOfHMetrics;break;case"HVAR":ls=gn;break;case"hmtx":Lr=gn;break;case"ltag":Sn=os(w,gn),m=ps.parse(Sn.data,Sn.offset);break;case"COLR":Sn=os(w,gn),b.tables.colr=ce.parse(Sn.data,Sn.offset);break;case"CPAL":Sn=os(w,gn),b.tables.cpal=_n.parse(Sn.data,Sn.offset);break;case"maxp":Sn=os(w,gn),b.tables.maxp=_t.parse(Sn.data,Sn.offset),b.numGlyphs=b.tables.maxp.numGlyphs;break;case"name":vi=gn;break;case"OS/2":Sn=os(w,gn),b.tables.os2=oo.parse(Sn.data,Sn.offset);break;case"post":Sn=os(w,gn),b.tables.post=kl.parse(Sn.data,Sn.offset),b.glyphNames=new _r(b.tables.post);break;case"prep":Sn=os(w,gn),Er=new Ne.Parser(Sn.data,Sn.offset),b.tables.prep=Er.parseByteList(gn.length);break;case"glyf":dt=gn;break;case"loca":gs=gn;break;case"CFF ":z=gn;break;case"CFF2":O=gn;break;case"kern":ms=gn;break;case"GDEF":Dn=gn;break;case"GPOS":An=gn;break;case"GSUB":Jn=gn;break;case"meta":Pl=gn;break;case"gasp":try{Sn=os(w,gn),b.tables.gasp=Wl.parse(Sn.data,Sn.offset)}catch(Po){console.warn("Failed to parse gasp table, skipping."),console.warn(Po)}break;case"SVG ":Sn=os(w,gn),b.tables.svg=Na.parse(Sn.data,Sn.offset);break;default:break}}let Oa=os(w,vi);if(b.tables.name=Qn.parse(Oa.data,Oa.offset,m),b.names=b.tables.name,dt&&gs){let jn=h===0,gn=os(w,gs),Sn=E_.parse(gn.data,gn.offset,b.numGlyphs,jn),Po=os(w,dt);b.glyphs=rt.parse(Po.data,Po.offset,Sn,b,d)}else if(z){let jn=os(w,z);io.parse(jn.data,jn.offset,b,d)}else if(O){let jn=os(w,O);io.parse(jn.data,jn.offset,b,d)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let Jo=os(w,Lr);if(kn.parse(b,Jo.data,Jo.offset,b.numberOfHMetrics,b.numGlyphs,b.glyphs,d),pr(b,d),ms){let jn=os(w,ms);b.kerningPairs=__.parse(jn.data,jn.offset)}else b.kerningPairs={};if(Dn){let jn=os(w,Dn);b.tables.gdef=y_.parse(jn.data,jn.offset)}if(An){let jn=os(w,An);b.tables.gpos=A_.parse(jn.data,jn.offset),b.position.init()}if(Jn){let jn=os(w,Jn);b.tables.gsub=ri.parse(jn.data,jn.offset)}if(se){let jn=os(w,se);b.tables.fvar=xr.parse(jn.data,jn.offset,b.names)}if(ne){let jn=os(w,ne);b.tables.stat=_l.parse(jn.data,jn.offset,b.tables.fvar)}if(_e){se||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),dt||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let jn=os(w,_e);b.tables.gvar=Ro.parse(jn.data,jn.offset,b.tables.fvar,b.glyphs)}if(xe){se||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),b.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),dt||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let jn=os(w,xe);b.tables.cvar=fa.parse(jn.data,jn.offset,b.tables.fvar,b.tables.cvt||[])}if(Be){se||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let jn=os(w,Be);b.tables.avar=Io.parse(jn.data,jn.offset,b.tables.fvar)}if(ls){se||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),Lr||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let jn=os(w,ls);b.tables.hvar=f_.parse(jn.data,jn.offset,b.tables.fvar)}if(Pl){let jn=os(w,Pl);b.tables.meta=B.parse(jn.data,jn.offset),b.metas=b.tables.meta}return b.palettes=new gd(b),b}function N_(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function M_(){console.error('DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)')}return f(p)})();(function(r,s){typeof define=="function"&&define.amd?define(s):typeof t=="object"&&t.exports?t.exports=s():r.opentype=s()})(typeof self<"u"?self:e,()=>({...n,default:n}))}),vB=bB(yB()),yo=s0("lru-cache:metrics"),Zf=cB("lru-cache"),wB=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Cx=()=>yo.hasSubscribers||Zf.hasSubscribers,Z8=new Set,Uw=typeof process=="object"&&process?process:{},SB=(e,t,n,r)=>{typeof Uw.emitWarning=="function"?Uw.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)},AB=e=>!Z8.has(e),cu=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),J8=e=>cu(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?jm:null:null,jm=class extends Array{constructor(e){super(e),this.fill(0)}},Bu,Cf,TB=(Bu=class{constructor(e,t){if(Ni(this,"heap"),Ni(this,"length"),!ue(Bu,Cf))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){let t=J8(e);if(!t)return[];qn(Bu,Cf,!0);let n=new Bu(e,t);return qn(Bu,Cf,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Cf=new WeakMap,Wr(Bu,Cf,!1),Bu),Gw,Ww,Ol,ul,oc,Hd,ac,kf,_f,lc,Hi,dl,Ri,Bs,vr,va,fl,ra,mo,cc,go,uc,dc,hl,pl,fc,Lf,wa,zd,Xt,kx,Ud,ru,Qp,ml,Vw,Gd,Ef,$p,su,iu,_x,Wd,Hp,qw,Kw,zp,Cs,Lx,Yw,Xw,If,Ex,Rf,ou,Ix,Rx,CB=(Rx=class{constructor(e){Wr(this,Xt),Wr(this,Ol),Wr(this,ul),Wr(this,oc),Wr(this,Hd),Wr(this,ac),Wr(this,kf),Wr(this,_f),Wr(this,lc),Ni(this,"ttl"),Ni(this,"ttlResolution"),Ni(this,"ttlAutopurge"),Ni(this,"updateAgeOnGet"),Ni(this,"updateAgeOnHas"),Ni(this,"allowStale"),Ni(this,"noDisposeOnSet"),Ni(this,"noUpdateTTL"),Ni(this,"maxEntrySize"),Ni(this,"sizeCalculation"),Ni(this,"noDeleteOnFetchRejection"),Ni(this,"noDeleteOnStaleGet"),Ni(this,"allowStaleOnFetchAbort"),Ni(this,"allowStaleOnFetchRejection"),Ni(this,"ignoreFetchAbort"),Ni(this,"backgroundFetchSize"),Wr(this,Hi),Wr(this,dl),Wr(this,Ri),Wr(this,Bs),Wr(this,vr),Wr(this,va),Wr(this,fl),Wr(this,ra),Wr(this,mo),Wr(this,cc),Wr(this,go),Wr(this,uc),Wr(this,dc),Wr(this,hl),Wr(this,pl),Wr(this,fc),Wr(this,Lf),Wr(this,wa),Wr(this,zd),Wr(this,Ud,()=>{}),Wr(this,ru,()=>{}),Wr(this,Qp,()=>{}),Wr(this,ml,()=>!1),Wr(this,Gd,Z=>{}),Wr(this,Ef,(Z,V,fe)=>{}),Wr(this,$p,(Z,V,fe,X)=>{if(fe||X)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0}),Ni(this,Gw,"LRUCache");let{max:t=0,ttl:n,ttlResolution:r=1,ttlAutopurge:s,updateAgeOnGet:i,updateAgeOnHas:a,allowStale:c,dispose:u,onInsert:f,disposeAfter:p,noDisposeOnSet:g,noUpdateTTL:y,maxSize:v=0,maxEntrySize:S=0,sizeCalculation:A,fetchMethod:C,memoMethod:L,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:M,allowStaleOnFetchRejection:P,allowStaleOnFetchAbort:F,ignoreFetchAbort:j,backgroundFetchSize:T=1,perf:Q}=e;if(this.backgroundFetchSize=T,Q!==void 0&&typeof Q?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(qn(this,lc,Q??wB),t!==0&&!cu(t))throw new TypeError("max option must be a nonnegative integer");let $=t?J8(t):Array;if(!$)throw new Error("invalid max value: "+t);if(qn(this,Ol,t),qn(this,ul,v),this.maxEntrySize=S||ue(this,ul),this.sizeCalculation=A,this.sizeCalculation){if(!ue(this,ul)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(L!==void 0&&typeof L!="function")throw new TypeError("memoMethod must be a function if defined");if(qn(this,_f,L),C!==void 0&&typeof C!="function")throw new TypeError("fetchMethod must be a function if specified");if(qn(this,kf,C),qn(this,Lf,!!C),qn(this,Ri,new Map),qn(this,Bs,Array.from({length:t}).fill(void 0)),qn(this,vr,Array.from({length:t}).fill(void 0)),qn(this,va,new $(t)),qn(this,fl,new $(t)),qn(this,ra,0),qn(this,mo,0),qn(this,cc,TB.create(t)),qn(this,Hi,0),qn(this,dl,0),typeof u=="function"&&qn(this,oc,u),typeof f=="function"&&qn(this,Hd,f),typeof p=="function"?(qn(this,ac,p),qn(this,go,[])):(qn(this,ac,void 0),qn(this,go,void 0)),qn(this,fc,!!ue(this,oc)),qn(this,zd,!!ue(this,Hd)),qn(this,wa,!!ue(this,ac)),this.noDisposeOnSet=!!g,this.noUpdateTTL=!!y,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!P,this.allowStaleOnFetchAbort=!!F,this.ignoreFetchAbort=!!j,this.maxEntrySize!==0){if(ue(this,ul)!==0&&!cu(ue(this,ul)))throw new TypeError("maxSize must be a positive integer if specified");if(!cu(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");en(this,Xt,Vw).call(this)}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!M,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!a,this.ttlResolution=cu(r)||r===0?r:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!cu(this.ttl))throw new TypeError("ttl must be a positive integer if specified");en(this,Xt,kx).call(this)}if(ue(this,Ol)===0&&this.ttl===0&&ue(this,ul)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!ue(this,Ol)&&!ue(this,ul)){let Z="LRU_CACHE_UNBOUNDED";AB(Z)&&(Z8.add(Z),SB("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Z,Rx))}}get perf(){return ue(this,lc)}static unsafeExposeInternals(e){return{starts:ue(e,dc),ttls:ue(e,hl),autopurgeTimers:ue(e,pl),sizes:ue(e,uc),keyMap:ue(e,Ri),keyList:ue(e,Bs),valList:ue(e,vr),next:ue(e,va),prev:ue(e,fl),get head(){return ue(e,ra)},get tail(){return ue(e,mo)},free:ue(e,cc),isBackgroundFetch:t=>{var n;return en(n=e,Xt,Cs).call(n,t)},backgroundFetch:(t,n,r,s)=>{var i;return en(i=e,Xt,zp).call(i,t,n,r,s)},moveToTail:t=>{var n;return en(n=e,Xt,Rf).call(n,t)},indexes:t=>{var n;return en(n=e,Xt,su).call(n,t)},rindexes:t=>{var n;return en(n=e,Xt,iu).call(n,t)},isStale:t=>{var n;return ue(n=e,ml).call(n,t)}}}get max(){return ue(this,Ol)}get maxSize(){return ue(this,ul)}get calculatedSize(){return ue(this,dl)}get size(){return ue(this,Hi)}get fetchMethod(){return ue(this,kf)}get memoMethod(){return ue(this,_f)}get dispose(){return ue(this,oc)}get onInsert(){return ue(this,Hd)}get disposeAfter(){return ue(this,ac)}getRemainingTTL(e){return ue(this,Ri).has(e)?1/0:0}*entries(){for(let e of en(this,Xt,su).call(this))ue(this,vr)[e]!==void 0&&ue(this,Bs)[e]!==void 0&&!en(this,Xt,Cs).call(this,ue(this,vr)[e])&&(yield[ue(this,Bs)[e],ue(this,vr)[e]])}*rentries(){for(let e of en(this,Xt,iu).call(this))ue(this,vr)[e]!==void 0&&ue(this,Bs)[e]!==void 0&&!en(this,Xt,Cs).call(this,ue(this,vr)[e])&&(yield[ue(this,Bs)[e],ue(this,vr)[e]])}*keys(){for(let e of en(this,Xt,su).call(this)){let t=ue(this,Bs)[e];t!==void 0&&!en(this,Xt,Cs).call(this,ue(this,vr)[e])&&(yield t)}}*rkeys(){for(let e of en(this,Xt,iu).call(this)){let t=ue(this,Bs)[e];t!==void 0&&!en(this,Xt,Cs).call(this,ue(this,vr)[e])&&(yield t)}}*values(){for(let e of en(this,Xt,su).call(this))ue(this,vr)[e]!==void 0&&!en(this,Xt,Cs).call(this,ue(this,vr)[e])&&(yield ue(this,vr)[e])}*rvalues(){for(let e of en(this,Xt,iu).call(this))ue(this,vr)[e]!==void 0&&!en(this,Xt,Cs).call(this,ue(this,vr)[e])&&(yield ue(this,vr)[e])}[(Ww=Symbol.iterator,Gw=Symbol.toStringTag,Ww)](){return this.entries()}find(e,t={}){for(let n of en(this,Xt,su).call(this)){let r=ue(this,vr)[n],s=en(this,Xt,Cs).call(this,r)?r.__staleWhileFetching:r;if(s!==void 0&&e(s,ue(this,Bs)[n],this))return en(this,Xt,If).call(this,ue(this,Bs)[n],t)}}forEach(e,t=this){for(let n of en(this,Xt,su).call(this)){let r=ue(this,vr)[n],s=en(this,Xt,Cs).call(this,r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,ue(this,Bs)[n],this)}}rforEach(e,t=this){for(let n of en(this,Xt,iu).call(this)){let r=ue(this,vr)[n],s=en(this,Xt,Cs).call(this,r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,ue(this,Bs)[n],this)}}purgeStale(){let e=!1;for(let t of en(this,Xt,iu).call(this,{allowStale:!0}))ue(this,ml).call(this,t)&&(en(this,Xt,ou).call(this,ue(this,Bs)[t],"expire"),e=!0);return e}info(e){let t=ue(this,Ri).get(e);if(t===void 0)return;let n=ue(this,vr)[t],r=en(this,Xt,Cs).call(this,n)?n.__staleWhileFetching:n;if(r===void 0)return;let s={value:r};if(ue(this,hl)&&ue(this,dc)){let i=ue(this,hl)[t],a=ue(this,dc)[t];if(i&&a){let c=i-(ue(this,lc).now()-a);s.ttl=c,s.start=Date.now()}}return ue(this,uc)&&(s.size=ue(this,uc)[t]),s}dump(){let e=[];for(let t of en(this,Xt,su).call(this,{allowStale:!0})){let n=ue(this,Bs)[t],r=ue(this,vr)[t],s=en(this,Xt,Cs).call(this,r)?r.__staleWhileFetching:r;if(s===void 0||n===void 0)continue;let i={value:s};if(ue(this,hl)&&ue(this,dc)){i.ttl=ue(this,hl)[t];let a=ue(this,lc).now()-ue(this,dc)[t];i.start=Math.floor(Date.now()-a)}ue(this,uc)&&(i.size=ue(this,uc)[t]),e.unshift([n,i])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let r=Date.now()-n.start;n.start=ue(this,lc).now()-r}en(this,Xt,Wd).call(this,t,n.value,n)}}set(e,t,n={}){let{status:r=yo.hasSubscribers?{}:void 0}=n;n.status=r,r&&(r.op="set",r.key=e,t!==void 0&&(r.value=t),r.cache=this);let s=en(this,Xt,Wd).call(this,e,t,n);return r&&yo.hasSubscribers&&yo.publish(r),s}pop(){var e;try{for(;ue(this,Hi);){let t=ue(this,vr)[ue(this,ra)];if(en(this,Xt,Hp).call(this,!0),en(this,Xt,Cs).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(ue(this,wa)&&ue(this,go)){let t=ue(this,go),n;for(;n=t?.shift();)(e=ue(this,ac))==null||e.call(this,...n)}}}has(e,t={}){let{status:n=yo.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="has",n.key=e,n.cache=this);let r=en(this,Xt,qw).call(this,e,t);return yo.hasSubscribers&&yo.publish(n),r}peek(e,t={}){let{status:n=Cx()?{}:void 0}=t;n&&(n.op="peek",n.key=e,n.cache=this),t.status=n;let r=en(this,Xt,Kw).call(this,e,t);return yo.hasSubscribers&&yo.publish(n),r}fetch(e,t={}){let n=Zf.hasSubscribers,{status:r=Cx()?{}:void 0}=t;t.status=r,r&&t.context&&(r.context=t.context);let s=en(this,Xt,Lx).call(this,e,t);return r&&n&&(r.trace=!0,Zf.tracePromise(()=>s,r).catch(()=>{})),s}forceFetch(e,t={}){let n=Zf.hasSubscribers,{status:r=Cx()?{}:void 0}=t;t.status=r,r&&t.context&&(r.context=t.context);let s=en(this,Xt,Yw).call(this,e,t);return r&&n&&(r.trace=!0,Zf.tracePromise(()=>s,r).catch(()=>{})),s}memo(e,t={}){let{status:n=yo.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="memo",n.key=e,t.context&&(n.context=t.context),n.cache=this);let r=en(this,Xt,Xw).call(this,e,t);return n&&(n.value=r),yo.hasSubscribers&&yo.publish(n),r}get(e,t={}){let{status:n=yo.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="get",n.key=e,n.cache=this);let r=en(this,Xt,If).call(this,e,t);return n&&(r!==void 0&&(n.value=r),yo.hasSubscribers&&yo.publish(n)),r}delete(e){return en(this,Xt,ou).call(this,e,"delete")}clear(){return en(this,Xt,Ix).call(this,"delete")}},Ol=new WeakMap,ul=new WeakMap,oc=new WeakMap,Hd=new WeakMap,ac=new WeakMap,kf=new WeakMap,_f=new WeakMap,lc=new WeakMap,Hi=new WeakMap,dl=new WeakMap,Ri=new WeakMap,Bs=new WeakMap,vr=new WeakMap,va=new WeakMap,fl=new WeakMap,ra=new WeakMap,mo=new WeakMap,cc=new WeakMap,go=new WeakMap,uc=new WeakMap,dc=new WeakMap,hl=new WeakMap,pl=new WeakMap,fc=new WeakMap,Lf=new WeakMap,wa=new WeakMap,zd=new WeakMap,Xt=new WeakSet,kx=function(){let e=new jm(ue(this,Ol)),t=new jm(ue(this,Ol));qn(this,hl,e),qn(this,dc,t);let n=this.ttlAutopurge?Array.from({length:ue(this,Ol)}):void 0;qn(this,pl,n),qn(this,Qp,(a,c,u=ue(this,lc).now())=>{t[a]=c!==0?u:0,e[a]=c,r(a,c)}),qn(this,Ud,a=>{t[a]=e[a]!==0?ue(this,lc).now():0,r(a,e[a])});let r=this.ttlAutopurge?(a,c)=>{if(n?.[a]&&(clearTimeout(n[a]),n[a]=void 0),c&&c!==0&&n){let u=setTimeout(()=>{ue(this,ml).call(this,a)&&en(this,Xt,ou).call(this,ue(this,Bs)[a],"expire")},c+1);u.unref&&u.unref(),n[a]=u}}:()=>{};qn(this,ru,(a,c)=>{if(e[c]){let u=e[c],f=t[c];if(!u||!f)return;a.ttl=u,a.start=f,a.now=s||i();let p=a.now-f;a.remainingTTL=u-p}});let s=0,i=()=>{let a=ue(this,lc).now();if(this.ttlResolution>0){s=a;let c=setTimeout(()=>s=0,this.ttlResolution);c.unref&&c.unref()}return a};this.getRemainingTTL=a=>{let c=ue(this,Ri).get(a);if(c===void 0)return 0;let u=e[c],f=t[c];if(!u||!f)return 1/0;let p=(s||i())-f;return u-p},qn(this,ml,a=>{let c=t[a],u=e[a];return!!u&&!!c&&(s||i())-c>u})},Ud=new WeakMap,ru=new WeakMap,Qp=new WeakMap,ml=new WeakMap,Vw=function(){let e=new jm(ue(this,Ol));qn(this,dl,0),qn(this,uc,e),qn(this,Gd,t=>{qn(this,dl,ue(this,dl)-e[t]),e[t]=0}),qn(this,$p,(t,n,r,s)=>{if(!cu(r)){if(en(this,Xt,Cs).call(this,n))return this.backgroundFetchSize;if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(r=s(n,t),!cu(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return r}),qn(this,Ef,(t,n,r)=>{if(e[t]=n,ue(this,ul)){let s=ue(this,ul)-e[t];for(;ue(this,dl)>s;)en(this,Xt,Hp).call(this,!0)}qn(this,dl,ue(this,dl)+e[t]),r&&(r.entrySize=n,r.totalCalculatedSize=ue(this,dl))})},Gd=new WeakMap,Ef=new WeakMap,$p=new WeakMap,su=function*({allowStale:e=this.allowStale}={}){if(ue(this,Hi))for(let t=ue(this,mo);en(this,Xt,_x).call(this,t)&&((e||!ue(this,ml).call(this,t))&&(yield t),t!==ue(this,ra));)t=ue(this,fl)[t]},iu=function*({allowStale:e=this.allowStale}={}){if(ue(this,Hi))for(let t=ue(this,ra);en(this,Xt,_x).call(this,t)&&((e||!ue(this,ml).call(this,t))&&(yield t),t!==ue(this,mo));)t=ue(this,va)[t]},_x=function(e){return e!==void 0&&ue(this,Ri).get(ue(this,Bs)[e])===e},Wd=function(e,t,n,r){var s,i,a,c;let{ttl:u=this.ttl,start:f,noDisposeOnSet:p=this.noDisposeOnSet,sizeCalculation:g=this.sizeCalculation,status:y}=n,v=en(this,Xt,Cs).call(this,t);if(t===void 0)return y&&(y.set="deleted"),this.delete(e),this;let{noUpdateTTL:S=this.noUpdateTTL}=n;y&&!v&&(y.value=t);let A=ue(this,$p).call(this,e,t,n.size||0,g,y);if(this.maxEntrySize&&A>this.maxEntrySize)return en(this,Xt,ou).call(this,e,"set"),y&&(y.set="miss",y.maxEntrySizeExceeded=!0),this;let C=ue(this,Hi)===0?void 0:ue(this,Ri).get(e);if(C===void 0)C=ue(this,Hi)===0?ue(this,mo):ue(this,cc).length!==0?ue(this,cc).pop():ue(this,Hi)===ue(this,Ol)?en(this,Xt,Hp).call(this,!1):ue(this,Hi),ue(this,Bs)[C]=e,ue(this,vr)[C]=t,ue(this,Ri).set(e,C),ue(this,va)[ue(this,mo)]=C,ue(this,fl)[C]=ue(this,mo),qn(this,mo,C),Tx(this,Hi)._++,ue(this,Ef).call(this,C,A,y),y&&(y.set="add"),S=!1,ue(this,zd)&&!v&&((s=ue(this,Hd))==null||s.call(this,t,e,"add"));else{en(this,Xt,Rf).call(this,C);let L=ue(this,vr)[C];if(t!==L){if(!p)if(en(this,Xt,Cs).call(this,L)){L!==r&&L.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:E}=L;E!==void 0&&E!==t&&(ue(this,fc)&&((i=ue(this,oc))==null||i.call(this,E,e,"set")),ue(this,wa)&&ue(this,go)?.push([E,e,"set"]))}else ue(this,fc)&&((a=ue(this,oc))==null||a.call(this,L,e,"set")),ue(this,wa)&&ue(this,go)?.push([L,e,"set"]);if(ue(this,Gd).call(this,C),ue(this,Ef).call(this,C,A,y),ue(this,vr)[C]=t,!v){let E=L&&en(this,Xt,Cs).call(this,L)?L.__staleWhileFetching:L,M=E===void 0?"add":t!==E?"replace":"update";y&&(y.set=M,E!==void 0&&(y.oldValue=E)),ue(this,zd)&&this.onInsert?.(t,e,M)}}else v||(y&&(y.set="update"),ue(this,zd)&&this.onInsert?.(t,e,"update"))}if(u!==0&&!ue(this,hl)&&en(this,Xt,kx).call(this),ue(this,hl)&&(S||ue(this,Qp).call(this,C,u,f),y&&ue(this,ru).call(this,y,C)),!p&&ue(this,wa)&&ue(this,go)){let L=ue(this,go),E;for(;E=L?.shift();)(c=ue(this,ac))==null||c.call(this,...E)}return this},Hp=function(e){var t;let n=ue(this,ra),r=ue(this,Bs)[n],s=ue(this,vr)[n],i=en(this,Xt,Cs).call(this,s);i&&s.__abortController.abort(new Error("evicted"));let a=i?s.__staleWhileFetching:s;return(ue(this,fc)||ue(this,wa))&&a!==void 0&&(ue(this,fc)&&((t=ue(this,oc))==null||t.call(this,a,r,"evict")),ue(this,wa)&&ue(this,go)?.push([a,r,"evict"])),ue(this,Gd).call(this,n),ue(this,pl)?.[n]&&(clearTimeout(ue(this,pl)[n]),ue(this,pl)[n]=void 0),e&&(ue(this,Bs)[n]=void 0,ue(this,vr)[n]=void 0,ue(this,cc).push(n)),ue(this,Hi)===1?(qn(this,ra,qn(this,mo,0)),ue(this,cc).length=0):qn(this,ra,ue(this,va)[n]),ue(this,Ri).delete(r),Tx(this,Hi)._--,n},qw=function(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,s=ue(this,Ri).get(e);if(s!==void 0){let i=ue(this,vr)[s];if(en(this,Xt,Cs).call(this,i)&&i.__staleWhileFetching===void 0)return!1;if(ue(this,ml).call(this,s))r&&(r.has="stale",ue(this,ru).call(this,r,s));else return n&&ue(this,Ud).call(this,s),r&&(r.has="hit",ue(this,ru).call(this,r,s)),!0}else r&&(r.has="miss");return!1},Kw=function(e,t){let{status:n,allowStale:r=this.allowStale}=t,s=ue(this,Ri).get(e);if(s===void 0||!r&&ue(this,ml).call(this,s)){n&&(n.peek=s===void 0?"miss":"stale");return}let i=ue(this,vr)[s],a=en(this,Xt,Cs).call(this,i)?i.__staleWhileFetching:i;return n&&(a!==void 0?(n.peek="hit",n.value=a):n.peek="miss"),a},zp=function(e,t,n,r){let s=t===void 0?void 0:ue(this,vr)[t];if(en(this,Xt,Cs).call(this,s))return s;let i=new AbortController,{signal:a}=n;a?.addEventListener("abort",()=>i.abort(a.reason),{signal:i.signal});let c={signal:i.signal,options:n,context:r},u=(S,A=!1)=>{let{aborted:C}=i.signal,L=n.ignoreFetchAbort&&S!==void 0,E=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&S!==void 0);if(n.status&&(C&&!A?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,L&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),C&&!L&&!A)return p(i.signal.reason,E);let M=y,P=ue(this,vr)[t];return(P===y||P===void 0&&L&&A)&&(S===void 0?M.__staleWhileFetching!==void 0?ue(this,vr)[t]=M.__staleWhileFetching:en(this,Xt,ou).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),en(this,Xt,Wd).call(this,e,S,c.options,M))),S},f=S=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=S),p(S,!1)),p=(S,A)=>{let{aborted:C}=i.signal,L=C&&n.allowStaleOnFetchAbort,E=L||n.allowStaleOnFetchRejection,M=E||n.noDeleteOnFetchRejection,P=y;if(ue(this,vr)[t]===y&&(!M||!A&&P.__staleWhileFetching===void 0?en(this,Xt,ou).call(this,e,"fetch"):L||(ue(this,vr)[t]=P.__staleWhileFetching)),E)return n.status&&P.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),P.__staleWhileFetching;if(P.__returned===P)throw S},g=(S,A)=>{var C;let L=(C=ue(this,kf))==null?void 0:C.call(this,e,s,c);i.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(S(void 0),n.allowStaleOnFetchAbort&&(S=E=>u(E,!0)))}),L&&L instanceof Promise?L.then(E=>S(E===void 0?void 0:E),A):L!==void 0&&S(L)};n.status&&(n.status.fetchDispatched=!0);let y=new Promise(g).then(u,f),v=Object.assign(y,{__abortController:i,__staleWhileFetching:s,__returned:void 0});return t===void 0?(en(this,Xt,Wd).call(this,e,v,{...c.options,status:void 0}),t=ue(this,Ri).get(e)):ue(this,vr)[t]=v,v},Cs=function(e){if(!ue(this,Lf))return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},Lx=async function(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:g=this.allowStaleOnFetchRejection,ignoreFetchAbort:y=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:S,forceRefresh:A=!1,status:C,signal:L}=t;if(C&&(C.op="fetch",C.key=e,A&&(C.forceRefresh=!0),C.cache=this),!ue(this,Lf))return C&&(C.fetch="get"),en(this,Xt,If).call(this,e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:s,status:C});let E={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:s,ttl:i,noDisposeOnSet:a,size:c,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:g,allowStaleOnFetchAbort:v,ignoreFetchAbort:y,status:C,signal:L},M=ue(this,Ri).get(e);if(M===void 0){C&&(C.fetch="miss");let P=en(this,Xt,zp).call(this,e,M,E,S);return P.__returned=P}else{let P=ue(this,vr)[M];if(en(this,Xt,Cs).call(this,P)){let Q=n&&P.__staleWhileFetching!==void 0;return C&&(C.fetch="inflight",Q&&(C.returnedStale=!0)),Q?P.__staleWhileFetching:P.__returned=P}let F=ue(this,ml).call(this,M);if(!A&&!F)return C&&(C.fetch="hit"),en(this,Xt,Rf).call(this,M),r&&ue(this,Ud).call(this,M),C&&ue(this,ru).call(this,C,M),P;let j=en(this,Xt,zp).call(this,e,M,E,S),T=j.__staleWhileFetching!==void 0&&n;return C&&(C.fetch=F?"stale":"refresh",T&&F&&(C.returnedStale=!0)),T?j.__staleWhileFetching:j.__returned=j}},Yw=async function(e,t={}){let n=await en(this,Xt,Lx).call(this,e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n},Xw=function(e,t={}){let n=ue(this,_f);if(!n)throw new Error("no memoMethod provided to constructor");let{context:r,status:s,forceRefresh:i,...a}=t;s&&i&&(s.forceRefresh=!0);let c=en(this,Xt,If).call(this,e,a),u=i||c===void 0;if(s&&(s.memo=u?"miss":"hit",u||(s.value=c)),!u)return c;let f=n(e,c,{options:a,context:r});return s&&(s.value=f),en(this,Xt,Wd).call(this,e,f,a),f},If=function(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:i}=t,a=ue(this,Ri).get(e);if(a===void 0){i&&(i.get="miss");return}let c=ue(this,vr)[a],u=en(this,Xt,Cs).call(this,c);return i&&ue(this,ru).call(this,i,a),ue(this,ml).call(this,a)?u?(i&&(i.get="stale-fetching"),n&&c.__staleWhileFetching!==void 0?(i&&(i.returnedStale=!0),c.__staleWhileFetching):void 0):(s||en(this,Xt,ou).call(this,e,"expire"),i&&(i.get="stale"),n?(i&&(i.returnedStale=!0),c):void 0):(i&&(i.get=u?"fetching":"hit"),en(this,Xt,Rf).call(this,a),r&&ue(this,Ud).call(this,a),u?c.__staleWhileFetching:c)},Ex=function(e,t){ue(this,fl)[t]=e,ue(this,va)[e]=t},Rf=function(e){e!==ue(this,mo)&&(e===ue(this,ra)?qn(this,ra,ue(this,va)[e]):en(this,Xt,Ex).call(this,ue(this,fl)[e],ue(this,va)[e]),en(this,Xt,Ex).call(this,ue(this,mo),e),qn(this,mo,e))},ou=function(e,t){var n,r;yo.hasSubscribers&&yo.publish({op:"delete",delete:t,key:e,cache:this});let s=!1;if(ue(this,Hi)!==0){let i=ue(this,Ri).get(e);if(i!==void 0)if(ue(this,pl)?.[i]&&(clearTimeout(ue(this,pl)?.[i]),ue(this,pl)[i]=void 0),s=!0,ue(this,Hi)===1)en(this,Xt,Ix).call(this,t);else{ue(this,Gd).call(this,i);let a=ue(this,vr)[i];if(en(this,Xt,Cs).call(this,a)?a.__abortController.abort(new Error("deleted")):(ue(this,fc)||ue(this,wa))&&(ue(this,fc)&&((n=ue(this,oc))==null||n.call(this,a,e,t)),ue(this,wa)&&ue(this,go)?.push([a,e,t])),ue(this,Ri).delete(e),ue(this,Bs)[i]=void 0,ue(this,vr)[i]=void 0,i===ue(this,mo))qn(this,mo,ue(this,fl)[i]);else if(i===ue(this,ra))qn(this,ra,ue(this,va)[i]);else{let c=ue(this,fl)[i];ue(this,va)[c]=ue(this,va)[i];let u=ue(this,va)[i];ue(this,fl)[u]=ue(this,fl)[i]}Tx(this,Hi)._--,ue(this,cc).push(i)}}if(ue(this,wa)&&ue(this,go)?.length){let i=ue(this,go),a;for(;a=i?.shift();)(r=ue(this,ac))==null||r.call(this,...a)}return s},Ix=function(e){var t,n;for(let r of en(this,Xt,iu).call(this,{allowStale:!0})){let s=ue(this,vr)[r];if(en(this,Xt,Cs).call(this,s))s.__abortController.abort(new Error("deleted"));else{let i=ue(this,Bs)[r];ue(this,fc)&&((t=ue(this,oc))==null||t.call(this,s,i,e)),ue(this,wa)&&ue(this,go)?.push([s,i,e])}}if(ue(this,Ri).clear(),ue(this,vr).fill(void 0),ue(this,Bs).fill(void 0),ue(this,hl)&&ue(this,dc)){ue(this,hl).fill(0),ue(this,dc).fill(0);for(let r of ue(this,pl)??[])r!==void 0&&clearTimeout(r);ue(this,pl)?.fill(void 0)}if(ue(this,uc)&&ue(this,uc).fill(0),qn(this,ra,0),qn(this,mo,0),ue(this,cc).length=0,qn(this,dl,0),qn(this,Hi,0),ue(this,wa)&&ue(this,go)){let r=ue(this,go),s;for(;s=r?.shift();)(n=ue(this,ac))==null||n.call(this,...s)}},Rx);function eA(e){let t={individual:{},range:[]},n=new WeakMap;for(let r of e)p2(t,r,n);return t}function p2(e,t,n){for(let[r,s]of Object.entries(t.individual))if(e.individual[r])Vd(e.individual[r],s,n);else{let i=!1;for(let[a,{range:c,entry:u}]of e.range.entries()){let f=Nx(Number(r),c);if(f.both!==null){i=!0,e.individual[r]=s,Vd(e.individual[r],vo(u),n),e.range.splice(a,1);for(let p of f.second)Array.isArray(p)?e.range.push({range:p,entry:vo(u)}):e.individual[p]=vo(u)}}i||(e.individual[r]=s)}for(let{range:r,entry:s}of t.range){let i=[r];for(let a=0;a<e.range.length;a++){let{range:c,entry:u}=e.range[a];for(let[f,p]of i.entries())if(Array.isArray(p)){let g=kB(p,c);if(g.both===null)continue;e.range.splice(a,1),a--;let y=vo(u);Array.isArray(g.both)?e.range.push({range:g.both,entry:y}):e.individual[g.both]=y,Vd(y,vo(s),n);for(let v of g.second)Array.isArray(v)?e.range.push({range:v,entry:vo(u)}):e.individual[v]=vo(u);i=g.first}else{let g=Nx(p,c);if(g.both===null)continue;e.individual[p]=vo(s),Vd(e.individual[p],vo(u),n),e.range.splice(a,1),a--;for(let y of g.second)Array.isArray(y)?e.range.push({range:y,entry:vo(u)}):e.individual[y]=vo(u);i.splice(f,1,...g.first);break}}for(let a of Object.keys(e.individual))for(let[c,u]of i.entries())if(Array.isArray(u)){let f=Nx(Number(a),u);if(f.both===null)continue;Vd(e.individual[a],vo(s),n),i.splice(c,1,...f.second);break}else if(Number(a)===u){Vd(e.individual[a],vo(s),n);break}for(let a of i)Array.isArray(a)?e.range.push({range:a,entry:vo(s)}):e.individual[a]=vo(s)}}function Vd(e,t,n){let r=n.get(e);r?.has(t)||(r||(r=new Set,n.set(e,r)),r.add(t),t.lookup&&(!e.lookup||e.lookup.index>t.lookup.index||e.lookup.index===t.lookup.index&&e.lookup.subIndex>t.lookup.subIndex)&&(e.lookup=t.lookup),t.forward&&(e.forward?p2(e.forward,t.forward,n):e.forward=t.forward),t.reverse&&(e.reverse?p2(e.reverse,t.reverse,n):e.reverse=t.reverse))}function kB(e,t){let n={first:[],second:[],both:null};if(e[0]<t[1]&&t[0]<e[1]){let r=Math.max(e[0],t[0]),s=Math.min(e[1],t[1]);n.both=Vu(r,s)}if(e[0]<t[0]){let r=e[0],s=Math.min(t[0],e[1]);n.first.push(Vu(r,s))}else if(t[0]<e[0]){let r=t[0],s=Math.min(t[1],e[0]);n.second.push(Vu(r,s))}if(e[1]>t[1]){let r=Math.max(e[0],t[1]),s=e[1];n.first.push(Vu(r,s))}else if(t[1]>e[1]){let r=Math.max(e[1],t[0]),s=t[1];n.second.push(Vu(r,s))}return n}function Nx(e,t){if(e<t[0]||e>t[1])return{first:[e],second:[t],both:null};let n={first:[],second:[],both:e};return t[0]<e&&n.second.push(Vu(t[0],e)),t[1]>e&&n.second.push(Vu(e+1,t[1])),n}function Vu(e,t){return t-e===1?e:[e,t]}function vo(e,t=new Map){if(t.has(e))return t.get(e);let n={};return t.set(e,n),e.forward&&(n.forward=Zw(e.forward,t)),e.reverse&&(n.reverse=Zw(e.reverse,t)),e.lookup&&(n.lookup={contextRange:e.lookup.contextRange.slice(),index:e.lookup.index,length:e.lookup.length,subIndex:e.lookup.subIndex,substitutions:e.lookup.substitutions.slice()}),n}function Zw(e,t=new Map){let n={};for(let[r,s]of Object.entries(e.individual))n[r]=vo(s,t);return{individual:n,range:e.range.map(({range:r,entry:s})=>({range:r.slice(),entry:vo(s,t)}))}}function m2(e,t,n,r){let s=t[r],i=e[s];if(!i)return;let a=i.lookup;if(i.reverse){let u=_B(i.reverse,t,n);(!a&&u||u&&a&&(a.index>u.index||a.index===u.index&&a.subIndex>u.subIndex))&&(a=u)}if(++r>=t.length||!i.forward)return a;let c=m2(i.forward,t,n,r);return(!a&&c||c&&a&&(a.index>c.index||a.index===c.index&&a.subIndex>c.subIndex))&&(a=c),a}function _B(e,t,n){let r=e[t[--n]],s=r&&r.lookup;for(;r&&((!s&&r.lookup||r.lookup&&s&&s.index>r.lookup.index)&&(s=r.lookup),!(--n<0||!r.reverse));)r=r.reverse[t[n]];return s}function Jw(e,t,n){let r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(r){if(n<=i[0])return e[s-1][1]=n,e;if(n<=i[1])return e[s-1][1]=Math.max(n,i[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(n<=i[0])return e.splice(s,0,[t,n]),e;if(n<=i[1])return i[0]=Math.min(t,i[0]),e;if(t<i[1])i[0]=Math.min(t,i[0]),r=!0;else continue}}return r?e[e.length-1][1]=n:e.push([t,n]),e}function LB(e,t){switch(e.format){case 1:let n=e.glyphs.indexOf(t);return n!==-1?n:null;case 2:let r=e.ranges.find(s=>s.start<=t&&s.end>=t);return r?r.index:null}}function Qc(e){switch(e.format){case 1:return e.glyphs.map((n,r)=>({glyphId:n,index:r}));case 2:let t=[];for(let[n,r]of e.ranges.entries())r.end===r.start?t.push({glyphId:r.start,index:n}):t.push({glyphId:[r.start,r.end+1],index:n});return t}}function EB(e,t){let n=t[0],r=g2(e,n),s=t[0]+1,i=new Map;for(;s<t[1];)g2(e,s)!==r&&(s-n<=1?i.set(n,r):i.set([n,s],r)),s++;return s-n<=1?i.set(n,r):i.set([n,s],r),i}function g2(e,t){let n=LB(e.coverage,t);if(n===null)return null;switch(e.substFormat){case 1:return(t+e.deltaGlyphId)%2**16;case 2:return e.substitute[n]??null}}function Zy(e,t,n,r,s){let i=[];for(let a of n){a.entry.forward={individual:{},range:[]};for(let c of e)i.push(...e1(a.entry.forward,r,s,t,c).map(({entry:u,substitution:f})=>({entry:u,substitutions:[...a.substitutions,f]})))}return i}function Zg(e,t){let n=[],r=new Set;for(let s of t){if(r.has(s.entry))continue;r.add(s.entry),s.entry.forward??={individual:{},range:[]};let i={};for(let a of e)Array.isArray(a)?s.entry.forward.range.push({entry:i,range:a}):s.entry.forward.individual[a]=i;n.push({entry:i,substitutions:s.substitutions})}return n}function Jg(e,t){let n=[],r=new Set;for(let s of t){if(r.has(s.entry))continue;r.add(s.entry),s.entry.reverse??={individual:{},range:[]};let i={};for(let a of e)Array.isArray(a)?s.entry.reverse.range.push({entry:i,range:a}):s.entry.reverse.individual[a]=i;n.push({entry:i,substitutions:s.substitutions})}return n}function e1(e,t,n,r,s){let i=[];if(!Array.isArray(s))e.individual[s]={},i.push({entry:e.individual[s],substitution:RB(t,n,r,s)});else{let a=IB(t,n,r,s);for(let[c,u]of a){let f={};Array.isArray(c)?e.range.push({range:c,entry:f}):e.individual[c]={},i.push({entry:f,substitution:u})}}return i}function IB(e,t,n,r){for(let s of e.filter(i=>i.sequenceIndex===n))for(let i of t[s.lookupListIndex].subtables){let a=EB(i,r);if(!Array.from(a.values()).every(c=>c!==null))return a}return new Map([[r,null]])}function RB(e,t,n,r){for(let s of e.filter(i=>i.sequenceIndex===n))for(let i of t[s.lookupListIndex].subtables){let a=g2(i,r);if(a!==null)return a}return null}function NB(e,t,n){let r={individual:{},range:[]},s=Qc(e.coverage);for(let{glyphId:i,index:a}of s){let c=e.chainRuleSets[a];if(c)for(let[u,f]of c.entries()){let p=e1(r,f.lookupRecords,t,0,i).map(({entry:g,substitution:y})=>({entry:g,substitutions:[y]}));for(let[g,y]of f.input.entries())p=Zy([y],g+1,p,f.lookupRecords,t);for(let g of f.lookahead)p=Zg([g],p);for(let g of f.backtrack)p=Jg([g],p);for(let{entry:g,substitutions:y}of p)g.lookup={substitutions:y,length:f.input.length+1,index:n,subIndex:u,contextRange:[-1*f.backtrack.length,1+f.input.length+f.lookahead.length]}}}return r}function MB(e,t){return e.format===2?Array.isArray(t)?DB(e,t):new Map([[t,x2(e,t)]]):new Map([[t,null]])}function DB(e,t){let n=t[0],r=x2(e,n),s=t[0]+1,i=new Map;for(;s<t[1];)x2(e,s)!==r&&(s-n<=1?i.set(n,r):i.set([n,s],r)),s++;return s-n<=1?i.set(n,r):i.set([n,s],r),i}function x2(e,t){for(let n of e.ranges)if(n.start<=t&&n.end>=t)return n.classId;return null}function Mx(e,t){switch(e.format){case 2:let n=[];for(let r of e.ranges)r.classId===t&&(r.end===r.start?n.push(r.start):n.push([r.start,r.end+1]));return n;default:return[]}}function jB(e,t,n){let r=[],s=Qc(e.coverage);for(let{glyphId:i}of s){let a=MB(e.inputClassDef,i);for(let[c,u]of a.entries()){if(u===null)continue;let f=e.chainClassSet[u];if(f)for(let[p,g]of f.entries()){let y={individual:{},range:[]},v=e1(y,g.lookupRecords,t,0,c).map(({entry:S,substitution:A})=>({entry:S,substitutions:[A]}));for(let[S,A]of g.input.entries())v=Zy(Mx(e.inputClassDef,A),S+1,v,g.lookupRecords,t);for(let S of g.lookahead)v=Zg(Mx(e.lookaheadClassDef,S),v);for(let S of g.backtrack)v=Jg(Mx(e.backtrackClassDef,S),v);for(let{entry:S,substitutions:A}of v)S.lookup={substitutions:A,index:n,subIndex:p,length:g.input.length+1,contextRange:[-1*g.backtrack.length,1+g.input.length+g.lookahead.length]};r.push(y)}}}return eA(r)}function PB(e,t,n){let r={individual:{},range:[]},s=Qc(e.inputCoverage[0]);for(let{glyphId:i}of s){let a=e1(r,e.lookupRecords,t,0,i).map(({entry:c,substitution:u})=>({entry:c,substitutions:[u]}));for(let[c,u]of e.inputCoverage.slice(1).entries())a=Zy(Qc(u).map(f=>f.glyphId),c+1,a,e.lookupRecords,t);for(let c of e.lookaheadCoverage)a=Zg(Qc(c).map(u=>u.glyphId),a);for(let c of e.backtrackCoverage)a=Jg(Qc(c).map(u=>u.glyphId),a);for(let{entry:c,substitutions:u}of a)c.lookup={substitutions:u,index:n,subIndex:0,length:e.inputCoverage.length,contextRange:[-1*e.backtrackCoverage.length,e.inputCoverage.length+e.lookaheadCoverage.length]}}return r}function BB(e,t){let n={individual:{},range:[]},r=Qc(e.coverage);for(let{glyphId:s,index:i}of r){let a={};Array.isArray(s)?n.range.push({entry:a,range:s}):n.individual[s]=a;let c=[{entry:a,substitutions:[e.substitutes[i]]}];for(let u of e.lookaheadCoverage)c=Zg(Qc(u).map(f=>f.glyphId),c);for(let u of e.backtrackCoverage)c=Jg(Qc(u).map(f=>f.glyphId),c);for(let{entry:u,substitutions:f}of c)u.lookup={substitutions:f,index:t,subIndex:0,length:1,contextRange:[-1*e.backtrackCoverage.length,1+e.lookaheadCoverage.length]}}return n}function b2(e,t=new Map){let n={};for(let[r,s]of Object.entries(e.individual))n[r]=e3(s,t);for(let{range:r,entry:s}of e.range){let i=e3(s,t);for(let a=r[0];a<r[1];a++)n[a]=i}return n}function e3(e,t){if(t.has(e))return t.get(e);let n={};return t.set(e,n),e.forward&&(n.forward=b2(e.forward,t)),e.reverse&&(n.reverse=b2(e.reverse,t)),e.lookup&&(n.lookup=e.lookup),n}var FB=class{constructor(e,t){this._lookupTrees=[],this._glyphLookups={},this._font=e,t.cacheSize>0&&(this._cache=new CB({maxSize:t.cacheSize,sizeCalculation:((i,a)=>a.length)}));let n=(this._font.tables.gsub&&this._font.tables.gsub.features.filter(i=>i.tag==="calt")||[]).reduce((i,a)=>[...i,...a.feature.lookupListIndexes],[]),r=this._font.tables.gsub&&this._font.tables.gsub.lookups||[],s=r.filter((i,a)=>n.some(c=>c===a));for(let[i,a]of s.entries()){let c=[];switch(a.lookupType){case 6:for(let[f,p]of a.subtables.entries())switch(p.substFormat){case 1:c.push(NB(p,r,f));break;case 2:c.push(jB(p,r,f));break;case 3:c.push(PB(p,r,f));break}break;case 8:for(let[f,p]of a.subtables.entries())c.push(BB(p,f));break}let u=b2(eA(c));this._lookupTrees.push({tree:u,processForward:a.lookupType!==8});for(let f of Object.keys(u))this._glyphLookups[f]||(this._glyphLookups[f]=[]),this._glyphLookups[f].push(i)}}findLigatures(e){let t=this._cache&&this._cache.get(e);if(t&&!Array.isArray(t))return t;let n=[];for(let i of e)n.push(this._font.charToGlyphIndex(i));if(this._lookupTrees.length===0)return{inputGlyphs:n,outputGlyphs:n,contextRanges:[]};let r=this._findInternal(n.slice()),s={inputGlyphs:n,outputGlyphs:r.sequence,contextRanges:r.ranges};return this._cache&&this._cache.set(e,s),s}findLigatureRanges(e){if(this._lookupTrees.length===0)return[];let t=this._cache&&this._cache.get(e);if(t)return Array.isArray(t)?t:t.contextRanges;let n=[];for(let s of e)n.push(this._font.charToGlyphIndex(s));let r=this._findInternal(n);return this._cache&&this._cache.set(e,r.ranges),r.ranges}_findInternal(e){let t=[],n=this._getNextLookup(e,0);for(;n.index!==null;){let r=this._lookupTrees[n.index];if(r.processForward){let s=n.last;for(let i=n.first;i<s;i++){let a=m2(r.tree,e,i,i);if(a){for(let c=0;c<a.substitutions.length;c++){let u=a.substitutions[c];u!==null&&(e[i+c]=u)}Jw(t,a.contextRange[0]+i,a.contextRange[1]+i),i+a.length>=s&&(s=i+a.length+1),i+=a.length-1}}}else for(let s=n.last-1;s>=n.first;s--){let i=m2(r.tree,e,s,s);if(i){for(let a=0;a<i.substitutions.length;a++){let c=i.substitutions[a];c!==null&&(e[s+a]=c)}Jw(t,i.contextRange[0]+s,i.contextRange[1]+s),s-=i.length-1}}n=this._getNextLookup(e,n.index+1)}return{sequence:e,ranges:t}}_getNextLookup(e,t){let n={index:null,first:1/0,last:-1};for(let r=0;r<e.length;r++){let s=this._glyphLookups[e[r]];if(s)for(let i=0;i<s.length;i++){let a=s[i];if(a>=t){(n.index===null||a<=n.index)&&(n.index=a,n.first>r&&(n.first=r),n.last=r+1);break}}}return n}};function OB(e,t){let n=vB.parse(e);return new FB(n,{cacheSize:0,...t})}function QB(e){if(typeof e!="string")throw new Error("Font family must be a string");let t={input:e,offset:0},n=[],r="";for(;t.offset<t.input.length;){let s=t.input[t.offset++];switch(s){case"'":case'"':r+=$B(t,s);break;case",":n.push(r),r="";break;default:/\s/.test(s)||(t.offset--,r+=HB(t),n.push(r),r="")}}return n}function $B(e,t){let n="",r=!1;for(;e.offset<e.input.length;){let s=e.input[e.offset++];if(r)/[\dA-Fa-f]/.test(s)?(e.offset--,n+=tA(e)):s!==`
67
- `&&(n+=s),r=!1;else switch(s){case t:return n;case"\\":r=!0;break;default:n+=s}}throw new Error("Unterminated string")}function HB(e){let t="",n=!1;for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(n)/[\dA-Fa-f]/.test(r)?(e.offset--,t+=tA(e)):t+=r,n=!1;else switch(r){case"\\":n=!0;break;case",":return t;default:/\s/.test(r)?t.endsWith(" ")||(t+=" "):t+=r}}return t}function tA(e){let t="";for(;e.offset<e.input.length;){let n=e.input[e.offset++];if(/\s/.test(n))return Dx(t);if(t.length>=6||!/[\dA-Fa-f]/.test(n))return e.offset--,Dx(t);t+=n}return Dx(t)}function Dx(e){return String.fromCodePoint(parseInt(e,16))}var Nf;async function zB(e,t){if(!Nf){if(typeof navigator<"u"&&"fonts"in navigator){try{let s=await navigator.permissions.request?.({name:"local-fonts"});if(s&&s.state!=="granted")throw new Error("Permission to access local fonts not granted.")}catch(s){if(s instanceof Error&&s.name!=="TypeError")throw s}let r={};try{let s=await navigator.fonts.query();for(let i of s)r.hasOwnProperty(i.family)||(r[i.family]=[]),r[i.family].push(i);Nf=Promise.resolve(r)}catch(s){s instanceof Error&&console.error(s.name,s.message)}}else if(typeof window<"u"&&"queryLocalFonts"in window){let r={};try{let s=await window.queryLocalFonts();for(let i of s)r.hasOwnProperty(i.family)||(r[i.family]=[]),r[i.family].push(i);Nf=Promise.resolve(r)}catch(s){s instanceof Error&&console.error(s.name,s.message)}}Nf??=Promise.resolve({})}let n=await Nf;for(let r of QB(e)){if(UB.includes(r))return;if(n.hasOwnProperty(r)&&n[r].length>0){let s=n[r][0];if("blob"in s){let i=await(await s.blob()).arrayBuffer();return OB(i,{cacheSize:t})}return}}}var UB=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],GB=1e5;function WB(e,t=[]){let n,r,s=0,i;return e.registerCharacterJoiner(a=>{let c=e.options.fontFamily;if(c&&(s===0||n!==c)){r=void 0,s=1,n=c;let u=n;zB(u,GB).then(f=>{u===e.options.fontFamily&&(s=2,r=f,f&&e.refresh(0,e.rows-1))}).catch(f=>{u===e.options.fontFamily&&(s=3,e.options.logLevel==="debug"&&console.debug(i,new Error("Failure while loading font")),r=void 0,i=f)})}return r&&s===2?r.findLigatureRanges(a).map(u=>[u[0],u[1]]):VB(a,t)})}function VB(e,t){let n=[];for(let r=0;r<e.length;r++)for(let s=0;s<t.length;s++)if(e.startsWith(t[s],r)){n.push([r,r+t[s].length]),r+=t[s].length-1;break}return n}var qB=class{constructor(e){this._fallbackLigatures=(e?.fallbackLigatures??["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!===","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"]).sort((t,n)=>n.length-t.length),this._fontFeatureSettings=e?.fontFeatureSettings}activate(e){if(!e.element)throw new Error("Cannot activate LigaturesAddon before open is called");this._terminal=e,this._characterJoinerId=WB(e,this._fallbackLigatures),e.element.style.fontFeatureSettings=this._fontFeatureSettings??'"calt" on'}dispose(){this._characterJoinerId!==void 0&&(this._terminal?.deregisterCharacterJoiner(this._characterJoinerId),this._characterJoinerId=void 0),this._terminal?.element&&(this._terminal.element.style.fontFeatureSettings="")}};function t3(e){let t=0;for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);if(r<48||57<r)return-1;t=t*10+r-48}return t}var KB=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,t=>{if(!t.startsWith("4;"))return!1;let n=t.split(";");if(n.length>3)return!0;n.length===2&&n.push("");let r=t3(n[1]),s=t3(n[2]);switch(r){case 0:this.progress={state:r,value:0};break;case 1:if(s<0)return!0;this.progress={state:r,value:s};break;case 2:case 4:if(s<0)return!0;this.progress={state:r,value:s||this._pr};break;case 3:this.progress={state:r,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn("progress state out of bounds, not applied");return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function nA(e,t){const n=Math.max(e.left,t.left),r=Math.max(e.top,t.top),s=Math.min(e.right,t.right),i=Math.min(e.bottom,t.bottom);return s>n&&i>r?{left:n,top:r,right:s,bottom:i}:null}function n3(e,t){const n=nA(e,t);return n?(n.right-n.left)*(n.bottom-n.top):0}function Ju(e){const t=e.element;if(!t||!e.cols||!e.rows)return null;const r=(t.querySelector?.(".xterm-screen")??null??t).getBoundingClientRect();if(!r.width||!r.height)return null;const s=e.dimensions?.css?.cell?.height,i=r.width/e.cols,a=s&&s>0?s:r.height/e.rows;return{originLeft:r.left,originTop:r.top,cellW:i,cellH:a}}function Pm(e,t){const n=Ju(e);if(!n)return null;const r=t.row-e.buffer.active.viewportY;if(r<0||r>=e.rows)return null;const s=Math.max(0,Math.min(e.cols-1,t.col));return{x:n.originLeft+(s+.5)*n.cellW,y:n.originTop+r*n.cellH}}function YB(e,t){const n=Math.max(0,e.buffer.active.baseY+e.rows-1);return{col:Math.max(0,Math.min(e.cols-1,t.col)),row:Math.max(0,Math.min(n,t.row))}}function og(e,t,n){const r=e.row*n+e.col,s=t.row*n+t.col;return r<=s?{start:e,end:t}:{start:t,end:e}}function XB(e,t,n){const r=Ju(e);if(!r)return null;const{start:s,end:i}=og(t,n,e.cols),a=e.buffer.active.viewportY,c=a+e.rows-1;if(i.row<a||s.row>c)return null;const u=Math.max(s.row,a),f=Math.min(i.row,c),p=r.originTop+(u-a)*r.cellH,g=r.originTop+(f-a+1)*r.cellH;return s.row===i.row?{left:r.originLeft+s.col*r.cellW,top:p,right:r.originLeft+(i.col+1)*r.cellW,bottom:g}:{left:r.originLeft,top:p,right:r.originLeft+e.cols*r.cellW,bottom:g}}function ZB(e){const t=Math.max(e.viewport.left,e.terminal.left),n=Math.max(e.viewport.top,e.terminal.top),r=Math.min(e.viewport.right,e.terminal.right),s=Math.min(e.viewport.bottom,e.terminal.bottom),i=t+e.margin,a=n+e.margin,c=Math.max(i,r-e.width-e.margin),u=Math.max(a,s-e.height-e.margin),f=Q=>Math.max(i,Math.min(Q,c)),p=Q=>Math.max(a,Math.min(Q,u)),g=e.selection?nA(e.selection,{left:t,top:n,right:r,bottom:s}):null;if(!g){const Q=f(e.clientX-e.width/2),$=e.clientY-e.height-e.fingerGap,Z=e.clientY+e.fingerGap,V=p($>=a?$:Z);return{left:Math.round(Q),top:Math.round(V)}}const y=(g.left+g.right)/2,v=(g.top+g.bottom)/2,S=e.preference?.alignX??y,A=e.selectionGap??e.fingerGap,C=g.top-e.height-A,L=g.bottom+A,E=e.preference?.vertical==="below"?L:C,M=e.preference?.vertical==="below"?C:L,P=[{left:i,top:a},{left:c,top:a},{left:i,top:u},{left:c,top:u}];e.preference&&P.sort((Q,$)=>{const Z=V=>{const fe=V.left+e.width/2,X=V.top+e.height/2;return Math.hypot(fe-e.preference.focusX,X-e.preference.focusY)};return Z($)-Z(Q)});const F=[{left:S-e.width/2,top:E},{left:y-e.width/2,top:E},{left:S-e.width/2,top:M},{left:y-e.width/2,top:M},{left:g.left-e.width-e.fingerGap,top:v-e.height/2},{left:g.right+e.fingerGap,top:v-e.height/2},...P].map(Q=>({left:f(Q.left),top:p(Q.top)}));let j=F[0],T=Number.POSITIVE_INFINITY;return F.forEach((Q,$)=>{const Z={left:Q.left,top:Q.top,right:Q.left+e.width,bottom:Q.top+e.height},V=(e.avoid??[]).reduce((X,ge)=>X+n3(Z,ge),0),fe=(V>0?1e6:0)+V*100+n3(Z,g)*10+$*.01;fe<T&&(j=Q,T=fe)}),{left:Math.round(j.left),top:Math.round(j.top)}}function JB(e){const t=e.willChange.split(",").map(r=>r.trim()),n=(r,s)=>!!(r&&r!==s);return n(e.transform,"none")||n(e.perspective,"none")||n(e.filter,"none")||n(e.backdropFilter,"none")||n(e.containerType,"normal")||e.contain.includes("layout")||e.contain.includes("paint")||e.contain.includes("strict")||e.contain.includes("content")||t.includes("transform")||t.includes("perspective")||t.includes("filter")}function eF(e){let t=e.parentElement;for(;t;){if(JB(window.getComputedStyle(t)))return t;t=t.parentElement}return null}function tF(e,t,n,r){const s=e.getBoundingClientRect();let i=0,a=0;if(t){const c=t.getBoundingClientRect();i=c.left+t.clientLeft,a=c.top+t.clientTop}return{x:s.left-i+n,y:s.top-a+r}}function nF(e,t){const n=e.replace(/\r?\n/g,"\r");return`\x1B[200~${(t&&n.endsWith("\r")?n.slice(0,-1):n).replace(/\x1b/g,"␛")}\x1B[201~${t?"\r":""}`}const r3=2,rF=new Set(["mount","init-fit","resize","dpr-change","session-key-change","session-reset","tmux-layout"]);function sF(e){const t=e.reason.replace(/^refresh:/,""),n=rF.has(t),r=Math.abs(e.proposedCols-e.currentCols),s=Math.abs(e.proposedRows-e.currentRows);return{accept:n?r>0||s>0:r>=r3||s>=r3,isRealResize:n,colsDelta:r,rowsDelta:s}}function iF(e){return e.before.cols!==e.after.cols||e.before.rows!==e.after.rows||e.lastServerSize===null||e.reconcileServerSize===!0&&(e.lastServerSize.cols!==e.after.cols||e.lastServerSize.rows!==e.after.rows)}function oF(e,t){return e?"none":t?"single":"settled"}function rA(e,t){return!e||!t?!0:e.cols===t.cols&&e.rows===t.rows}function aF(e,t){return e==="webgl"&&t}function jx(){return{confirmed:null,pending:null,nextSeq:1}}function s3(e,t){return e?.cols===t.cols&&e.rows===t.rows}function sA(e,t,n){const r={...t,seq:e.nextSeq,attempt:n};return{state:{...e,pending:r,nextSeq:e.nextSeq+1},request:r}}function lF(e,t){return s3(e.pending,t)||!e.pending&&s3(e.confirmed,t)?{state:e,request:null}:sA(e,t,0)}function cF(e,t){const n=e.pending;if(!n||t.seq!==n.seq)return{state:e,accepted:!1};const r=t.ok&&Number.isFinite(t.cols)&&Number.isFinite(t.rows)&&(t.cols??0)>0&&(t.rows??0)>0?{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}:null;return{state:{...e,confirmed:r,pending:null},accepted:!0}}function i3(e,t,n=1){const r=e.pending;return!r||r.seq!==t?{state:e,request:null,exhausted:!1}:r.attempt>=n?{state:{...e,confirmed:null,pending:null},request:null,exhausted:!0}:{...sA(e,r,r.attempt+1),exhausted:!1}}function uF(e,t){return!Number.isFinite(t.cols)||!Number.isFinite(t.rows)||t.cols<=0||t.rows<=0?e:{...e,confirmed:{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}}}function dF(e){return{...e,pending:null}}const y2="termdock-settings",fF=6,hF=100,pF='"calt" on',mF=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function gF(){if(typeof window>"u")return 13;const e=window.matchMedia("(max-width: 767px)").matches,t=window.matchMedia("(pointer: coarse)").matches;return e||t?10:13}function Jy(){return{fontFamily:"var(--font-mono)",fontSize:gF(),rendererMode:"auto",fontWeight:"normal",fontWeightBold:"bold",letterSpacing:1,lineHeight:1.05,minimumContrastRatio:4.5,drawBoldTextInBrightColors:!0,unicodeVersion:"11",customGlyphs:!0,rescaleOverlappingGlyphs:!1,fontLigatures:!0,enableImages:!0,smoothScrolling:!0}}function Up(e,t,n,r){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(n,e)):r}function o3(e,t){return e==="normal"||e==="bold"?e:typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(1e3,Math.round(e))):t}function y0(e){const t=Jy(),n=e&&typeof e=="object"?e:{},r=n.rendererMode??n.renderer;return{fontFamily:typeof n.fontFamily=="string"&&n.fontFamily.trim()?n.fontFamily.trim():t.fontFamily,fontSize:Up(n.fontSize,fF,hF,t.fontSize),rendererMode:r==="auto"||r==="webgl"||r==="canvas"?r:t.rendererMode,fontWeight:o3(n.fontWeight,t.fontWeight),fontWeightBold:o3(n.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(Up(n.letterSpacing,-5,10,t.letterSpacing)),lineHeight:Up(n.lineHeight,1,2,t.lineHeight),minimumContrastRatio:Up(n.minimumContrastRatio,1,21,t.minimumContrastRatio),drawBoldTextInBrightColors:t.drawBoldTextInBrightColors,unicodeVersion:t.unicodeVersion,customGlyphs:t.customGlyphs,rescaleOverlappingGlyphs:t.rescaleOverlappingGlyphs,fontLigatures:t.fontLigatures,enableImages:t.enableImages,smoothScrolling:t.smoothScrolling}}function Gp(e){return e.pointerType==="touch"||e.pointerType==="pen"}class xF{handlers=new Map;active=new Map;pointerStates=new Map;sorted=[];sortedDirty=!1;listenersRegistered=!1;changeListeners=new Set;constructor(){this.ensureListeners()}register(t){return this.handlers.has(t.name)&&this.log("replace",t.name),this.handlers.set(t.name,t),this.sortedDirty=!0,this.log("register",t.name,`prio=${t.priority}`),()=>{this.unregister(t.name)}}unregister(t){this.handlers.delete(t),this.sortedDirty=!0;for(const[n,r]of this.active)r===t&&(this.active.delete(n),this.pointerStates.delete(n));this.log("unregister",t)}getHandlers(){return this.sortedHandlers().map(t=>({name:t.name,priority:t.priority,hasContainer:t.container!=null}))}getClaimedHandler(t){return this.active.get(t)??null}isClaimedBy(t,n){return this.active.get(t)===n}isAnyPointerClaimed(){return this.active.size>0}onChange(t){return this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}}emitChange(t,n,r){this.changeListeners.size!==0&&this.changeListeners.forEach(s=>{try{s({type:t,pointerId:n,handler:r})}catch{}})}log(t,n,r=""){if(typeof window<"u"&&window.__TERMDOCK_GESTURE_DEBUG__){const s=performance.now().toFixed(0);console.debug(`[GestureManager ${s}] ${t} ${n} ${r}`)}}sortedHandlers(){return this.sortedDirty&&(this.sorted=[...this.handlers.values()].sort((t,n)=>n.priority-t.priority),this.sortedDirty=!1),this.sorted}ensureListeners(){this.listenersRegistered||(this.listenersRegistered=!0,document.addEventListener("pointerdown",this.handlePointerDown,{capture:!0,passive:!1}),document.addEventListener("pointermove",this.handlePointerMove,{capture:!0,passive:!1}),document.addEventListener("pointerup",this.handlePointerUp,{capture:!0,passive:!1}),document.addEventListener("pointercancel",this.handlePointerCancel,{capture:!0,passive:!1}))}handlePointerDown=t=>{if(!Gp(t))return;const n={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now()};this.pointerStates.set(t.pointerId,n);let r=!1;for(const s of this.sortedHandlers()){if(!this.handlerMatchesContainer(s,t)){this.log("skip-container",s.name);continue}s.onPointerDown(t,n)&&!r&&(this.active.set(t.pointerId,s.name),r=!0,this.log("claim",s.name,`pid=${t.pointerId} onPointerDown`),this.emitChange("claim",t.pointerId,s.name))}r&&t.preventDefault()};handlePointerMove=t=>{if(!Gp(t)||!this.pointerStates.has(t.pointerId))return;let n=!1;for(const r of this.sortedHandlers()){if(!this.handlerMatchesContainer(r,t))continue;const s=this.active.get(t.pointerId)===r.name,i=r.onPointerMove(t,s);if(i==="claim"&&!n){const a=this.active.get(t.pointerId)??null;this.active.set(t.pointerId,r.name),n=!0,t.preventDefault(),a&&a!==r.name&&this.log("handoff",`${a}->${r.name}`,`pid=${t.pointerId}`),this.log("claim",r.name,`pid=${t.pointerId} onPointerMove`),this.emitChange("claim",t.pointerId,r.name)}if(i==="release"&&s&&!n){const a=this.active.get(t.pointerId);this.active.delete(t.pointerId),this.log("release",r.name,`pid=${t.pointerId}`),this.emitChange("release",t.pointerId,a??null)}}};handlePointerUp=t=>{if(!Gp(t))return;for(const r of this.sortedHandlers())this.handlerMatchesContainer(r,t)&&r.onPointerUp(t);const n=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,n)};handlePointerCancel=t=>{if(!Gp(t))return;for(const r of this.sortedHandlers())this.handlerMatchesContainer(r,t)&&r.onPointerCancel(t);const n=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,n)};handlerMatchesContainer(t,n){return t.container?t.container.contains(n.target):!0}}const iA=new xF,bF=90,yF=80,vF=70,wF=(e,t)=>{const{scrollMultiplier:n=1.2,maxScrollBoost:r=.8,boostDenominator:s=50,velocityAlpha:i=.15,maxVelocity:a=15,minVelocity:c=.3,decelerationRate:u=.998,enableKinetic:f=!0,shouldCaptureTouch:p,canStartScrollGesture:g,onScroll:y,onScrollWithCoords:v,onTap:S,onClickWithCoords:A,onClaimChange:C,tapThreshold:L=10,gestureName:E="normal-scroll"}=t,M=1.06,P=D.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),F=D.useRef(0),j=D.useRef(0),T=D.useRef(0),Q=D.useRef(null),$=D.useRef(0),Z=D.useRef(!1),V=D.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),fe=D.useCallback(()=>{Q.current=null,F.current!==0&&(v&&j.current>0&&T.current>0?v(F.current,j.current,T.current):y&&y(F.current),F.current=0,j.current=0,T.current=0)},[y,v]),X=D.useCallback(()=>{Q.current===null&&typeof window<"u"&&(Q.current=window.requestAnimationFrame(fe))},[fe]),ge=D.useCallback(($e,ee,ht)=>{F.current+=$e,ee!==void 0&&ht!==void 0&&(j.current=ee,T.current=ht),X()},[X]),be=D.useCallback($e=>{if(!$e||!y)return!1;const ee=y($e);return ee?$.current=0:$.current++,ee},[y]),Te=D.useCallback($e=>{Z.current!==$e&&(Z.current=$e,C?.($e))},[C]),ie=D.useCallback(()=>{const $e=P.current;$e.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame($e.rafId),$e.rafId=null,Q.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(Q.current),Q.current=null,F.current=0},[]),U=D.useRef(S);U.current=S;const G=D.useRef(A);G.current=A;const ae=D.useRef(p);ae.current=p;const ve=D.useCallback(()=>{const $e=e.current;if(!$e||!("PointerEvent"in window))return()=>{};const ee=P.current,ht={name:E,priority:vF,get container(){return e.current??void 0},onPointerDown:(re,Ae)=>(re.pointerType!=="touch"||(ee.pointerId=re.pointerId,ee.startX=Ae.startX,ee.startY=Ae.startY,ee.didMove=!1,ee.gestureAxis=null,ee.lastY=re.clientY,ee.lastTime=V(),ee.velocity=0,ie()),!1),onPointerMove:(re,Ae)=>{if(re.pointerType!=="touch"||ee.pointerId!==re.pointerId||!ee.lastY||!ee.lastTime)return"neutral";const he=re.clientX,Qe=re.clientY,Fe=V(),Ke=Fe-ee.lastTime,K=Qe-ee.lastY;if(ee.startX!==null&&ee.startY!==null){const qe=he-ee.startX,Pe=Qe-ee.startY;if(!ee.didMove&&Math.hypot(qe,Pe)>=L&&(ee.didMove=!0),ee.gestureAxis===null&&ee.didMove){const We=Math.abs(qe),Oe=Math.abs(Pe);We>Oe*M?ee.gestureAxis="x":Oe>We*M&&(ee.gestureAxis="y")}if(ee.gestureAxis==="x")return ee.isCurrentlyScrolling=!1,Te(!1),ee.lastY=Qe,ee.lastTime=Fe,Ae?"release":"neutral";if(ee.gestureAxis===null)return ee.lastY=Qe,ee.lastTime=Fe,"neutral"}if(ee.gestureAxis==="y"&&!Ae&&!(g?.()??!0))return ee.lastY=Qe,ee.lastTime=Fe,Te(!1),"neutral";const de=K/Math.max(Ke,1);if(ee.velocity=ee.velocity*(1-i)+de*i,ee.velocity=Math.max(-a,Math.min(a,ee.velocity)),Math.abs(K)>1){if(!Ae)return Te(!0),ee.lastY=Qe,ee.lastTime=Fe,"claim";ee.isCurrentlyScrolling=!0;const qe=n+Math.min(r,Math.abs(K)/s),Pe=-K*qe;ge(Pe,he,Qe),Te(!0)}return ee.lastY=Qe,ee.lastTime=Fe,Ae?"claim":"neutral"},onPointerUp:re=>{if(re.pointerType!=="touch"||ee.pointerId!==re.pointerId)return;const Ae=ee.isCurrentlyScrolling;ee.isCurrentlyScrolling=!1,Te(!1);const he=ee.rafId!==null||Q.current!==null;!ee.didMove&&!he&&ee.startX!==null&&ee.startY!==null&&U.current?.(ee.startX,ee.startY),!ee.didMove&&!he&&ee.startX!==null&&ee.startY!==null&&G.current?.(ee.startX,ee.startY),ee.pointerId=null,ee.startX=null,ee.startY=null;const Qe=ee.gestureAxis==="x";if(ee.gestureAxis=null,f&&Ae&&!Qe&&Math.abs(ee.velocity)>c&&ee.didMove){const Fe=()=>{const Ke=V(),K=Ke-(ee.lastTime||Ke);if(ee.lastTime=Ke,ee.velocity*=Math.pow(u,K),Math.abs(ee.velocity)<c){ee.velocity=0,ie();return}if(!be(-ee.velocity*K)&&$.current>2){ee.velocity=0,ie();return}ee.rafId=requestAnimationFrame(Fe)};ee.rafId=requestAnimationFrame(Fe)}},onPointerCancel:re=>{re.pointerType!=="touch"||ee.pointerId!==re.pointerId||(ee.isCurrentlyScrolling=!1,Te(!1),ee.pointerId=null,ee.startX=null,ee.startY=null,ee.gestureAxis=null,ie())}},mt=iA.register(ht),me=$e.style.touchAction;return $e.style.touchAction="none",()=>{Te(!1),mt(),$e.style.touchAction=me,ie()}},[e,E,n,r,s,i,a,c,u,V,ie,be,ge,L,f,Te,g]),pe=D.useCallback(()=>{const $e=e.current;if(!$e)return()=>{};const ee=P.current,ht=Ae=>{Ae.touches.length===1&&((p?.()??!0)&&Ae.cancelable&&Ae.preventDefault(),ee.isCurrentlyScrolling=!1,ee.gestureAxis=null,ee.lastY=Ae.touches[0].clientY,ee.startX=Ae.touches[0].clientX,ee.startY=Ae.touches[0].clientY,ee.didMove=!1,ee.velocity=0,ie())},mt=Ae=>{if(Ae.touches.length!==1)return;const he=Ae.touches[0].clientX,Qe=Ae.touches[0].clientY;if(ee.startX!==null&&ee.startY!==null){const Ke=he-ee.startX,K=Qe-ee.startY;if(!ee.didMove&&Math.hypot(Ke,K)>=L&&(ee.didMove=!0),ee.gestureAxis===null&&ee.didMove){const de=Math.abs(Ke),qe=Math.abs(K);de>qe*M?ee.gestureAxis="x":qe>de*M&&(ee.gestureAxis="y")}if(ee.gestureAxis==="x"){ee.isCurrentlyScrolling=!1,ee.lastY=Qe;return}if(ee.gestureAxis===null){(p?.()??!1)&&Ae.cancelable&&Ae.preventDefault(),ee.lastY=Qe;return}}if(Ae.preventDefault(),!ee.lastY){ee.lastY=Qe;return}const Fe=Qe-ee.lastY;if(Math.abs(Fe)>1){ee.isCurrentlyScrolling=!0;const Ke=n+Math.min(r,Math.abs(Fe)/s),K=-Fe*Ke;ge(K,he,Qe)}ee.lastY=Qe},me=Ae=>{if(!Ae.changedTouches?.[0])return;const Qe=ee.isCurrentlyScrolling;ee.isCurrentlyScrolling=!1;const Fe=ee.rafId!==null||Q.current!==null;!ee.didMove&&!Fe&&S&&ee.startX!==null&&ee.startY!==null&&S(ee.startX,ee.startY),!ee.didMove&&!Fe&&A&&ee.startX!==null&&ee.startY!==null&&A(ee.startX,ee.startY),ee.startX=null,ee.startY=null;const Ke=ee.gestureAxis==="x";if(ee.gestureAxis=null,f&&Qe&&!Ke&&ee.didMove&&Math.abs(ee.velocity)>c){const K=()=>{if(ee.velocity*=Math.pow(u,16),Math.abs(ee.velocity)<c){ee.velocity=0,ie();return}if(!be(-ee.velocity*16)&&$.current>2){ee.velocity=0,ie();return}ee.rafId=requestAnimationFrame(K)};ee.rafId=requestAnimationFrame(K)}};$e.addEventListener("touchstart",ht,{passive:!1}),$e.addEventListener("touchmove",mt,{passive:!1}),$e.addEventListener("touchend",me,{passive:!1}),$e.addEventListener("touchcancel",me,{passive:!1});const re=$e.style.touchAction;return $e.style.touchAction="none",()=>{$e.removeEventListener("touchstart",ht),$e.removeEventListener("touchmove",mt),$e.removeEventListener("touchend",me),$e.removeEventListener("touchcancel",me),$e.style.touchAction=re,ie()}},[e,n,r,s,c,u,ie,be,ge,S,A,L,p,f]),we=D.useCallback(()=>{ie();const $e=typeof window<"u"&&"PointerEvent"in window,ee=$e?ve():()=>{},ht=$e?()=>{}:pe();return()=>{ee(),ht(),ie()}},[ve,pe,ie]),ze=D.useCallback(()=>P.current.isCurrentlyScrolling||P.current.rafId!==null||Q.current!==null,[]),Ce=D.useCallback(()=>{ie();const $e=P.current;$e.isCurrentlyScrolling=!1,$e.velocity=0,$e.lastY=null,$e.lastTime=null,$e.startX=null,$e.startY=null,$e.pointerId=null,$e.didMove=!1,$e.gestureAxis=null},[ie]);return{setupTouchScroll:we,isScrolling:ze,stopAllScroll:Ce}};function a3(e){const{name:t,priority:n}=e,r=x.useRef(e.onPointerDown),s=x.useRef(e.onPointerMove),i=x.useRef(e.onPointerUp),a=x.useRef(e.onPointerCancel),c=x.useRef(e.container);r.current=e.onPointerDown,s.current=e.onPointerMove,i.current=e.onPointerUp,a.current=e.onPointerCancel,c.current=e.container,x.useEffect(()=>{const u={name:t,priority:n,get container(){const p=c.current;return typeof p=="function"?p():p},onPointerDown(p,g){return r.current?.(p,g)??!1},onPointerMove(p,g){return s.current?.(p,g)??"neutral"},onPointerUp(p){i.current?.(p)},onPointerCancel(p){a.current?.(p)}};return iA.register(u)},[t,n])}var Ti;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})(Ti||(Ti={}));Ti.Light,Ti.Medium,Ti.Heavy,Ti.Success,Ti.Warning,Ti.Error;Ti.Light,Ti.Medium,Ti.Heavy,Ti.Success,Ti.Warning,Ti.Error;Ti.Light,Ti.Medium,Ti.Heavy,Ti.Success,Ti.Warning,Ti.Error;const SF=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",AF=()=>typeof document<"u"&&!!document.body,TF=()=>{if(AF())try{const e=document.createElement("label");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;";const t=document.createElement("input");t.type="checkbox",t.setAttribute("switch",""),e.appendChild(t),document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch{}},l3=e=>Array.isArray(e)?[...e]:[e],CF=e=>{if(SF()){try{const s=l3(e),i=s.length===1?s[0]:s;navigator.vibrate(i)}catch{}return}const t=l3(e),n=Array.from({length:Math.ceil(t.length/2)},(s,i)=>[t[i*2]??0,t[i*2+1]??0]);let r=0;for(const[s,i]of n)s>0&&setTimeout(TF,r),r+=s+i},$l=e=>CF(e),kF=({message:e})=>{const{t}=er();return o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsxs("div",{className:"rounded-full bg-surface-2 px-4 py-2 flex items-center gap-3 shadow-sm",children:[o.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:e??t("terminal.loading")})]})})},_F=()=>{const{t:e}=er();return o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsxs("div",{className:"rounded-full bg-surface-2 px-4 py-2 flex items-center gap-3 shadow-sm",children:[o.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:e("terminal.initializing")})]})})},LF=({message:e,onRetry:t})=>{const{t:n}=er();return o.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:o.jsxs("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,role:"img","aria-label":n("terminal.error"),children:[o.jsx("title",{children:n("terminal.error")}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})]})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"font-medium text-foreground",children:n("terminal.failedToLoad")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e||n("terminal.unknownError")})]}),t&&o.jsx("button",{type:"button",onClick:t,className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:n("common.retry")})]})})},EF="debug",IF="termdock:debug";function c3(e){return e?new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean)):new Set}function RF(){if(typeof window>"u")return new Set;const e=c3(new URLSearchParams(window.location.search).get(EF));let t=new Set;try{t=c3(window.localStorage.getItem(IF))}catch{t=new Set}const n=new Set([...e,...t]);return n.has("1")||n.has("true")||n.has("*")||n.has("all")?new Set(["*"]):n}function NF(e){const t=RF();return t.has("*")||t.has(e)}function ld(e){const t=NF(e);return(...n)=>{t&&console.log(`[debug:${e}]`,...n)}}function Bm(e){return Array.from(e)}function u3(e,t,n){return Math.max(t,Math.min(n,e))}function MF(e,t,n,r){const s=Bm(e),i=Bm(t);let a=u3(n,0,s.length);const c=u3(r,0,i.length);let u=0;for(;u<s.length&&u<i.length&&s[u]===i[u];)u++;let f=0;for(;f<s.length-u&&f<i.length-u&&s[s.length-1-f]===i[i.length-1-f];)f++;const p=s.length-u-f,g=i.slice(u,i.length-f).join(""),y=[];if(p>0||g){const v=u+p;a>v?y.push({left:a-v}):a<v&&y.push({right:v-a}),a=v,p>0&&(y.push({backspace:p}),a=u),g&&(y.push({insert:g}),a+=Bm(g).length)}return a>c?y.push({left:a-c}):a<c&&y.push({right:c-a}),a=c,{ops:y,cursor:a}}function d3(e){const t=e.value,n=e.selectionStart??t.length;return Bm(t.slice(0,n)).length}const ag=16,DF=10,f3=1.5,jF=1.8,h3=240,PF=125,BF=92;function FF(e,t,n){const r=Math.hypot(e,t),s=Math.abs(e),i=Math.abs(t),a=()=>s>=i*f3?e>0?"right":"left":i>=s*f3?t>0?"down":"up":"";if(n==="")return r>ag?a():"";if(r<DF)return"";if(r<=ag)return n;const c=a();if(c===""||c===n)return n;if(n==="left"&&c==="right"||n==="right"&&c==="left"||n==="up"&&c==="down"||n==="down"&&c==="up")return c;const f=n==="left"||n==="right";return(f?i:s)>=(f?s:i)*jF?c:n}function OF(e){const t=BF-ag,n=Math.min(Math.max((e-ag)/t,0),1);return h3-n*(h3-PF)}const v2="termdock-open-terminal-directory",p3=/(?:\\[ \t]|[^\s`"'<>|()[\]{}=,:;!?])+/gu,QF=/[,;:!?]+$/u,$F=/^[a-z][a-z\d+.-]*:\/\//iu;function HF(e){return!e||e==="/"||$F.test(e)||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.endsWith("/")||/^[^/:]+\/[^/:]+\/(?:[^/:]+\/?)+$/u.test(e)}function zF(e){const t=[];p3.lastIndex=0;let n;for(;(n=p3.exec(e))!==null;){const s=n[0].replace(QF,"");HF(s)&&t.push({text:s,startIndex:n.index,endIndex:n.index+s.length})}return t}function Px(e){const t=[];for(const n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return`/${t.join("/")}`}function UF(e){return e.match(/^\/(?:home|Users)\/[^/]+/u)?.[0]??null}function GF(e,t){const n=e.replace(/\\([ \t])/gu,"$1").replace(/\/+$/u,"")||"/";if(n.startsWith("/"))return Px(n);if(n==="~"||n.startsWith("~/")){const r=t?UF(t):null;return r?Px(`${r}/${n.slice(2)}`):null}return t?.startsWith("/")?Px(`${t}/${n}`):null}function WF(e,t){const n=e.buffer.active;let r=t-1;if(!n.getLine(r))return null;for(;r>0&&n.getLine(r)?.isWrapped;)r-=1;let s=t-1;for(;s+1<n.length&&n.getLine(s+1)?.isWrapped;)s+=1;let i="";const a=[],c=[];for(let f=r;f<=s&&i.length<=2048;f+=1){const p=n.getLine(f);if(!p)break;for(let g=0;g<p.length;g+=1){const y=p.getCell(g);if(!y||y.getWidth()===0)continue;const v=y.getChars()||" ";i+=v;for(let S=0;S<v.length;S+=1)a.push({x:g+1,y:f+1}),c.push({x:g+Math.max(1,y.getWidth()),y:f+1})}}const u=i.trimEnd().length;return{text:i.slice(0,u),startPositions:a.slice(0,u),endPositions:c.slice(0,u)}}function VF(e,t){return{provideLinks(n,r){const s=WF(e,n);if(!s){r(void 0);return}const i=zF(s.text).map(a=>({text:a.text,range:{start:s.startPositions[a.startIndex]??{x:a.startIndex+1,y:n},end:s.endPositions[a.endIndex-1]??{x:a.endIndex,y:n}},activate:()=>t(a.text)}));r(i.length>0?i:void 0)}}}function m3(e,t){if(!e||e.lines.length===0||!Number.isFinite(t)||t<=0)return 0;const n=Math.max(0,Math.floor(e.ybase)+Math.floor(t));let r=0;for(;e.lines.length<n;)e.lines.push(e.getBlankLine(void 0)),r++;return r}function g3(e,t=e.rows){const r=e._core?._bufferService?.buffers;return r?m3(r.normal,t)+m3(r.alt,t):0}const Fu=8,Wp=36,x3=10,qF=1.08,KF=1.16,Vp=6,YF=.94,XF=.08,ZF=.12,JF=88,eO=36,tO=10,nO=14,rO=52;function qp(e){return e?e.replace(/\r\n|\r|\n/g,"\r").replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," ").replace(/[\u200B-\u200D\uFEFF]/g,""):""}const sO=80,iO=8,b3={F1:"\x1BOP",F2:"\x1BOQ",F3:"\x1BOR",F4:"\x1BOS",F5:"\x1B[15~",F6:"\x1B[17~",F7:"\x1B[18~",F8:"\x1B[19~",F9:"\x1B[20~",F10:"\x1B[21~",F11:"\x1B[23~",F12:"\x1B[24~"};function du(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function oO(e,t){switch(e.key){case"ArrowUp":return du(t,"A");case"ArrowDown":return du(t,"B");case"ArrowRight":return du(t,"C");case"ArrowLeft":return du(t,"D");case"Home":return"\x1B[H";case"End":return"\x1B[F";case"PageUp":return"\x1B[5~";case"PageDown":return"\x1B[6~";case"Insert":return"\x1B[2~";case"Delete":return"\x1B[3~";case"Tab":return" ";case"Escape":return"\x1B";default:return b3[e.key]?b3[e.key]:null}}function aO(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function lO(e){try{const t=atob(e),n=Uint8Array.from(t,r=>r.charCodeAt(0));return new TextDecoder("utf-8").decode(n)}catch{return null}}function cO(e){const t="\x1B]52;";let n=0,r="";for(;n<e.length;){const s=e.indexOf(t,n);if(s===-1)return r+=e.slice(n),{cleaned:r,remainder:""};r+=e.slice(n,s);let i=-1,a=1;for(let f=s+t.length;f<e.length;f+=1){const p=e.charCodeAt(f);if(p===7){i=f,a=1;break}if(p===27&&f+1<e.length&&e[f+1]==="\\"){i=f,a=2;break}}if(i===-1)return{cleaned:r,remainder:e.slice(s)};const c=e.slice(s+t.length,i),u=c.indexOf(";");if(u>=0){const f=c.slice(u+1);if(f&&f!=="?"){const p=lO(f);p!==null&&navigator.clipboard?.writeText(p).catch(()=>{})}}n=i+a}return{cleaned:r,remainder:""}}function uO(e){if(typeof window>"u")return null;const t=[e,...Array.from(e.querySelectorAll("*"))];let n=null;for(const r of t){const i=window.getComputedStyle(r).overflowY;if(!(i!=="auto"&&i!=="scroll")){if(r.scrollHeight-r.clientHeight>2)return r;n||(n=r)}}return n}const dO=new Set(["visibility","bfcache","online"]),fO=5e5,hO=1e5,Mf=260,Df=140,y3=80;function pO(e){return!e}let qd=null;const mO=[{font:'400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'italic 400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 italic 13px "Termdock Mono"',text:"Termdock 0123456789 ❖ "},{font:'400 13px "Noto Sans Symbols 2"',text:"⏺⏸⏹✓✗"},{font:'400 13px "Termdock Star Symbol"',text:"✦✧"},{font:'400 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"},{font:'700 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"}],gO=()=>{if(qd)return qd;if(typeof document>"u"||!("fonts"in document))return qd=Promise.resolve(),qd;const e=document.fonts;return qd=Promise.allSettled(mO.map(({font:n,text:r})=>e.load(n,r))).then(()=>e.ready).then(()=>{}).catch(()=>{}),qd},v3=e=>{if((!e||e.includes("var("))&&typeof window<"u"){const t=getComputedStyle(document.documentElement).getPropertyValue("--font-mono").trim();if(t)return t}return e};function w3(e){return e==="normal"||e==="bold"?e:Math.max(1,Math.min(1e3,Math.round(e)))}function Ou(e,t,n){const r=e?.dimensions?.css.cell.height;return Math.max(8,Math.round(r||t*n))}function xO(e){return{background:e.background,foreground:e.foreground,cursor:e.cursor||e.foreground,cursorAccent:e.cursorAccent||e.background,selectionBackground:e.selectionBackground||"rgba(0, 0, 0, 0.3)",selectionForeground:e.selectionForeground||e.foreground,black:e.black||"#6F6E69",red:e.red||"#AF3029",green:e.green||"#66800B",yellow:e.yellow||"#AD8301",blue:e.blue||"#205EA6",magenta:e.magenta||"#A02F6F",cyan:e.cyan||"#24837B",white:e.white||"#CECDC3",brightBlack:e.brightBlack||"#6F6E69",brightRed:e.brightRed||"#D14D41",brightGreen:e.brightGreen||"#879A39",brightYellow:e.brightYellow||"#D0A215",brightBlue:e.brightBlue||"#4385BE",brightMagenta:e.brightMagenta||"#CE5D97",brightCyan:e.brightCyan||"#3AA99F",brightWhite:e.brightWhite||"#FFFCF0"}}const S3=new Map;function bO(e,t,n,r,s){if(typeof window>"u"||typeof document>"u")return null;const i=e.getBoundingClientRect();if(i.width<24||i.height<24)return null;const a=window.devicePixelRatio||1,c=`${n}::${r}::${s}::${a}::${t}`;let u=S3.get(c);if(!u)try{const y=document.createElement("canvas").getContext("2d");if(!y)return null;y.font=`${n}px ${t}`;const v=y.measureText("M"),A=(Math.floor(v.width*a)+Math.round(r))/a,C=v.actualBoundingBoxAscent??n*.8,L=v.actualBoundingBoxDescent??n*.2,E=Math.floor(Math.ceil(C+L)*s);A>=1&&E>=1&&(u={cellWidth:A,cellHeight:E},S3.set(c,u))}catch{return null}if(!u)return null;const f=Math.max(2,Math.floor(i.width/u.cellWidth)),p=Math.max(2,Math.floor(i.height/u.cellHeight));return!Number.isFinite(f)||!Number.isFinite(p)?null:{cols:f,rows:p}}async function A3(e){if(!e)return!1;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}function yO(e){const t=e.buffer.active,n=t.viewportY,r=Math.min(t.length,n+e.rows),s=[];for(let i=n;i<r;i+=1){const a=t.getLine(i);a&&s.push(a.translateToString(!0))}return s.join(`
67
+ `&&(n+=s),r=!1;else switch(s){case t:return n;case"\\":r=!0;break;default:n+=s}}throw new Error("Unterminated string")}function HB(e){let t="",n=!1;for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(n)/[\dA-Fa-f]/.test(r)?(e.offset--,t+=tA(e)):t+=r,n=!1;else switch(r){case"\\":n=!0;break;case",":return t;default:/\s/.test(r)?t.endsWith(" ")||(t+=" "):t+=r}}return t}function tA(e){let t="";for(;e.offset<e.input.length;){let n=e.input[e.offset++];if(/\s/.test(n))return Dx(t);if(t.length>=6||!/[\dA-Fa-f]/.test(n))return e.offset--,Dx(t);t+=n}return Dx(t)}function Dx(e){return String.fromCodePoint(parseInt(e,16))}var Nf;async function zB(e,t){if(!Nf){if(typeof navigator<"u"&&"fonts"in navigator){try{let s=await navigator.permissions.request?.({name:"local-fonts"});if(s&&s.state!=="granted")throw new Error("Permission to access local fonts not granted.")}catch(s){if(s instanceof Error&&s.name!=="TypeError")throw s}let r={};try{let s=await navigator.fonts.query();for(let i of s)r.hasOwnProperty(i.family)||(r[i.family]=[]),r[i.family].push(i);Nf=Promise.resolve(r)}catch(s){s instanceof Error&&console.error(s.name,s.message)}}else if(typeof window<"u"&&"queryLocalFonts"in window){let r={};try{let s=await window.queryLocalFonts();for(let i of s)r.hasOwnProperty(i.family)||(r[i.family]=[]),r[i.family].push(i);Nf=Promise.resolve(r)}catch(s){s instanceof Error&&console.error(s.name,s.message)}}Nf??=Promise.resolve({})}let n=await Nf;for(let r of QB(e)){if(UB.includes(r))return;if(n.hasOwnProperty(r)&&n[r].length>0){let s=n[r][0];if("blob"in s){let i=await(await s.blob()).arrayBuffer();return OB(i,{cacheSize:t})}return}}}var UB=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],GB=1e5;function WB(e,t=[]){let n,r,s=0,i;return e.registerCharacterJoiner(a=>{let c=e.options.fontFamily;if(c&&(s===0||n!==c)){r=void 0,s=1,n=c;let u=n;zB(u,GB).then(f=>{u===e.options.fontFamily&&(s=2,r=f,f&&e.refresh(0,e.rows-1))}).catch(f=>{u===e.options.fontFamily&&(s=3,e.options.logLevel==="debug"&&console.debug(i,new Error("Failure while loading font")),r=void 0,i=f)})}return r&&s===2?r.findLigatureRanges(a).map(u=>[u[0],u[1]]):VB(a,t)})}function VB(e,t){let n=[];for(let r=0;r<e.length;r++)for(let s=0;s<t.length;s++)if(e.startsWith(t[s],r)){n.push([r,r+t[s].length]),r+=t[s].length-1;break}return n}var qB=class{constructor(e){this._fallbackLigatures=(e?.fallbackLigatures??["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!===","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"]).sort((t,n)=>n.length-t.length),this._fontFeatureSettings=e?.fontFeatureSettings}activate(e){if(!e.element)throw new Error("Cannot activate LigaturesAddon before open is called");this._terminal=e,this._characterJoinerId=WB(e,this._fallbackLigatures),e.element.style.fontFeatureSettings=this._fontFeatureSettings??'"calt" on'}dispose(){this._characterJoinerId!==void 0&&(this._terminal?.deregisterCharacterJoiner(this._characterJoinerId),this._characterJoinerId=void 0),this._terminal?.element&&(this._terminal.element.style.fontFeatureSettings="")}};function t3(e){let t=0;for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);if(r<48||57<r)return-1;t=t*10+r-48}return t}var KB=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,t=>{if(!t.startsWith("4;"))return!1;let n=t.split(";");if(n.length>3)return!0;n.length===2&&n.push("");let r=t3(n[1]),s=t3(n[2]);switch(r){case 0:this.progress={state:r,value:0};break;case 1:if(s<0)return!0;this.progress={state:r,value:s};break;case 2:case 4:if(s<0)return!0;this.progress={state:r,value:s||this._pr};break;case 3:this.progress={state:r,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn("progress state out of bounds, not applied");return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function nA(e,t){const n=Math.max(e.left,t.left),r=Math.max(e.top,t.top),s=Math.min(e.right,t.right),i=Math.min(e.bottom,t.bottom);return s>n&&i>r?{left:n,top:r,right:s,bottom:i}:null}function n3(e,t){const n=nA(e,t);return n?(n.right-n.left)*(n.bottom-n.top):0}function Ju(e){const t=e.element;if(!t||!e.cols||!e.rows)return null;const r=(t.querySelector?.(".xterm-screen")??null??t).getBoundingClientRect();if(!r.width||!r.height)return null;const s=e.dimensions?.css?.cell?.height,i=r.width/e.cols,a=s&&s>0?s:r.height/e.rows;return{originLeft:r.left,originTop:r.top,cellW:i,cellH:a}}function Pm(e,t){const n=Ju(e);if(!n)return null;const r=t.row-e.buffer.active.viewportY;if(r<0||r>=e.rows)return null;const s=Math.max(0,Math.min(e.cols-1,t.col));return{x:n.originLeft+(s+.5)*n.cellW,y:n.originTop+r*n.cellH}}function YB(e,t){const n=Math.max(0,e.buffer.active.baseY+e.rows-1);return{col:Math.max(0,Math.min(e.cols-1,t.col)),row:Math.max(0,Math.min(n,t.row))}}function og(e,t,n){const r=e.row*n+e.col,s=t.row*n+t.col;return r<=s?{start:e,end:t}:{start:t,end:e}}function XB(e,t,n){const r=Ju(e);if(!r)return null;const{start:s,end:i}=og(t,n,e.cols),a=e.buffer.active.viewportY,c=a+e.rows-1;if(i.row<a||s.row>c)return null;const u=Math.max(s.row,a),f=Math.min(i.row,c),p=r.originTop+(u-a)*r.cellH,g=r.originTop+(f-a+1)*r.cellH;return s.row===i.row?{left:r.originLeft+s.col*r.cellW,top:p,right:r.originLeft+(i.col+1)*r.cellW,bottom:g}:{left:r.originLeft,top:p,right:r.originLeft+e.cols*r.cellW,bottom:g}}function ZB(e){const t=Math.max(e.viewport.left,e.terminal.left),n=Math.max(e.viewport.top,e.terminal.top),r=Math.min(e.viewport.right,e.terminal.right),s=Math.min(e.viewport.bottom,e.terminal.bottom),i=t+e.margin,a=n+e.margin,c=Math.max(i,r-e.width-e.margin),u=Math.max(a,s-e.height-e.margin),f=Q=>Math.max(i,Math.min(Q,c)),p=Q=>Math.max(a,Math.min(Q,u)),g=e.selection?nA(e.selection,{left:t,top:n,right:r,bottom:s}):null;if(!g){const Q=f(e.clientX-e.width/2),$=e.clientY-e.height-e.fingerGap,Z=e.clientY+e.fingerGap,V=p($>=a?$:Z);return{left:Math.round(Q),top:Math.round(V)}}const y=(g.left+g.right)/2,v=(g.top+g.bottom)/2,S=e.preference?.alignX??y,A=e.selectionGap??e.fingerGap,C=g.top-e.height-A,L=g.bottom+A,E=e.preference?.vertical==="below"?L:C,M=e.preference?.vertical==="below"?C:L,P=[{left:i,top:a},{left:c,top:a},{left:i,top:u},{left:c,top:u}];e.preference&&P.sort((Q,$)=>{const Z=V=>{const fe=V.left+e.width/2,X=V.top+e.height/2;return Math.hypot(fe-e.preference.focusX,X-e.preference.focusY)};return Z($)-Z(Q)});const F=[{left:S-e.width/2,top:E},{left:y-e.width/2,top:E},{left:S-e.width/2,top:M},{left:y-e.width/2,top:M},{left:g.left-e.width-e.fingerGap,top:v-e.height/2},{left:g.right+e.fingerGap,top:v-e.height/2},...P].map(Q=>({left:f(Q.left),top:p(Q.top)}));let j=F[0],T=Number.POSITIVE_INFINITY;return F.forEach((Q,$)=>{const Z={left:Q.left,top:Q.top,right:Q.left+e.width,bottom:Q.top+e.height},V=(e.avoid??[]).reduce((X,ge)=>X+n3(Z,ge),0),fe=(V>0?1e6:0)+V*100+n3(Z,g)*10+$*.01;fe<T&&(j=Q,T=fe)}),{left:Math.round(j.left),top:Math.round(j.top)}}function JB(e){const t=e.willChange.split(",").map(r=>r.trim()),n=(r,s)=>!!(r&&r!==s);return n(e.transform,"none")||n(e.perspective,"none")||n(e.filter,"none")||n(e.backdropFilter,"none")||n(e.containerType,"normal")||e.contain.includes("layout")||e.contain.includes("paint")||e.contain.includes("strict")||e.contain.includes("content")||t.includes("transform")||t.includes("perspective")||t.includes("filter")}function eF(e){let t=e.parentElement;for(;t;){if(JB(window.getComputedStyle(t)))return t;t=t.parentElement}return null}function tF(e,t,n,r){const s=e.getBoundingClientRect();let i=0,a=0;if(t){const c=t.getBoundingClientRect();i=c.left+t.clientLeft,a=c.top+t.clientTop}return{x:s.left-i+n,y:s.top-a+r}}function nF(e,t){const n=e.replace(/\r?\n/g,"\r");return`\x1B[200~${(t&&n.endsWith("\r")?n.slice(0,-1):n).replace(/\x1b/g,"␛")}\x1B[201~${t?"\r":""}`}const r3=2,rF=new Set(["mount","init-fit","resize","dpr-change","session-key-change","session-reset","tmux-layout"]);function sF(e){const t=e.reason.replace(/^refresh:/,""),n=rF.has(t),r=Math.abs(e.proposedCols-e.currentCols),s=Math.abs(e.proposedRows-e.currentRows);return{accept:n?r>0||s>0:r>=r3||s>=r3,isRealResize:n,colsDelta:r,rowsDelta:s}}function iF(e){return e.before.cols!==e.after.cols||e.before.rows!==e.after.rows||e.lastServerSize===null||e.reconcileServerSize===!0&&(e.lastServerSize.cols!==e.after.cols||e.lastServerSize.rows!==e.after.rows)}function oF(e,t){return e?"none":t?"single":"settled"}function rA(e,t){return!e||!t?!0:e.cols===t.cols&&e.rows===t.rows}function aF(e,t){return e==="webgl"&&t}function jx(){return{confirmed:null,pending:null,nextSeq:1}}function s3(e,t){return e?.cols===t.cols&&e.rows===t.rows}function sA(e,t,n){const r={...t,seq:e.nextSeq,attempt:n};return{state:{...e,pending:r,nextSeq:e.nextSeq+1},request:r}}function lF(e,t){return s3(e.pending,t)||!e.pending&&s3(e.confirmed,t)?{state:e,request:null}:sA(e,t,0)}function cF(e,t){const n=e.pending;if(!n||t.seq!==n.seq)return{state:e,accepted:!1};const r=t.ok&&Number.isFinite(t.cols)&&Number.isFinite(t.rows)&&(t.cols??0)>0&&(t.rows??0)>0?{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}:null;return{state:{...e,confirmed:r,pending:null},accepted:!0}}function i3(e,t,n=1){const r=e.pending;return!r||r.seq!==t?{state:e,request:null,exhausted:!1}:r.attempt>=n?{state:{...e,confirmed:null,pending:null},request:null,exhausted:!0}:{...sA(e,r,r.attempt+1),exhausted:!1}}function uF(e,t){return!Number.isFinite(t.cols)||!Number.isFinite(t.rows)||t.cols<=0||t.rows<=0?e:{...e,confirmed:{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}}}function dF(e){return{...e,pending:null}}const y2="termdock-settings",fF=6,hF=100,pF='"calt" on',mF=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function gF(){if(typeof window>"u")return 13;const e=window.matchMedia("(max-width: 767px)").matches,t=window.matchMedia("(pointer: coarse)").matches;return e||t?10:13}function Jy(){return{fontFamily:"var(--font-mono)",fontSize:gF(),rendererMode:"auto",fontWeight:"normal",fontWeightBold:"bold",letterSpacing:1,lineHeight:1.05,minimumContrastRatio:4.5,drawBoldTextInBrightColors:!0,unicodeVersion:"11",customGlyphs:!0,rescaleOverlappingGlyphs:!1,fontLigatures:!0,enableImages:!0,smoothScrolling:!0}}function Up(e,t,n,r){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(n,e)):r}function o3(e,t){return e==="normal"||e==="bold"?e:typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(1e3,Math.round(e))):t}function y0(e){const t=Jy(),n=e&&typeof e=="object"?e:{},r=n.rendererMode??n.renderer;return{fontFamily:typeof n.fontFamily=="string"&&n.fontFamily.trim()?n.fontFamily.trim():t.fontFamily,fontSize:Up(n.fontSize,fF,hF,t.fontSize),rendererMode:r==="auto"||r==="webgl"||r==="canvas"?r:t.rendererMode,fontWeight:o3(n.fontWeight,t.fontWeight),fontWeightBold:o3(n.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(Up(n.letterSpacing,-5,10,t.letterSpacing)),lineHeight:Up(n.lineHeight,1,2,t.lineHeight),minimumContrastRatio:Up(n.minimumContrastRatio,1,21,t.minimumContrastRatio),drawBoldTextInBrightColors:t.drawBoldTextInBrightColors,unicodeVersion:t.unicodeVersion,customGlyphs:t.customGlyphs,rescaleOverlappingGlyphs:t.rescaleOverlappingGlyphs,fontLigatures:t.fontLigatures,enableImages:t.enableImages,smoothScrolling:t.smoothScrolling}}function Gp(e){return e.pointerType==="touch"||e.pointerType==="pen"}class xF{handlers=new Map;active=new Map;pointerStates=new Map;sorted=[];sortedDirty=!1;listenersRegistered=!1;changeListeners=new Set;constructor(){this.ensureListeners()}register(t){return this.handlers.has(t.name)&&this.log("replace",t.name),this.handlers.set(t.name,t),this.sortedDirty=!0,this.log("register",t.name,`prio=${t.priority}`),()=>{this.unregister(t.name)}}unregister(t){this.handlers.delete(t),this.sortedDirty=!0;for(const[n,r]of this.active)r===t&&(this.active.delete(n),this.pointerStates.delete(n));this.log("unregister",t)}getHandlers(){return this.sortedHandlers().map(t=>({name:t.name,priority:t.priority,hasContainer:t.container!=null}))}getClaimedHandler(t){return this.active.get(t)??null}isClaimedBy(t,n){return this.active.get(t)===n}isAnyPointerClaimed(){return this.active.size>0}onChange(t){return this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}}emitChange(t,n,r){this.changeListeners.size!==0&&this.changeListeners.forEach(s=>{try{s({type:t,pointerId:n,handler:r})}catch{}})}log(t,n,r=""){if(typeof window<"u"&&window.__TERMDOCK_GESTURE_DEBUG__){const s=performance.now().toFixed(0);console.debug(`[GestureManager ${s}] ${t} ${n} ${r}`)}}sortedHandlers(){return this.sortedDirty&&(this.sorted=[...this.handlers.values()].sort((t,n)=>n.priority-t.priority),this.sortedDirty=!1),this.sorted}ensureListeners(){this.listenersRegistered||(this.listenersRegistered=!0,document.addEventListener("pointerdown",this.handlePointerDown,{capture:!0,passive:!1}),document.addEventListener("pointermove",this.handlePointerMove,{capture:!0,passive:!1}),document.addEventListener("pointerup",this.handlePointerUp,{capture:!0,passive:!1}),document.addEventListener("pointercancel",this.handlePointerCancel,{capture:!0,passive:!1}))}handlePointerDown=t=>{if(!Gp(t))return;const n={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now()};this.pointerStates.set(t.pointerId,n);let r=!1;for(const s of this.sortedHandlers()){if(!this.handlerMatchesContainer(s,t)){this.log("skip-container",s.name);continue}s.onPointerDown(t,n)&&!r&&(this.active.set(t.pointerId,s.name),r=!0,this.log("claim",s.name,`pid=${t.pointerId} onPointerDown`),this.emitChange("claim",t.pointerId,s.name))}r&&t.preventDefault()};handlePointerMove=t=>{if(!Gp(t)||!this.pointerStates.has(t.pointerId))return;let n=!1;for(const r of this.sortedHandlers()){if(!this.handlerMatchesContainer(r,t))continue;const s=this.active.get(t.pointerId)===r.name,i=r.onPointerMove(t,s);if(i==="claim"&&!n){const a=this.active.get(t.pointerId)??null;this.active.set(t.pointerId,r.name),n=!0,t.preventDefault(),a&&a!==r.name&&this.log("handoff",`${a}->${r.name}`,`pid=${t.pointerId}`),this.log("claim",r.name,`pid=${t.pointerId} onPointerMove`),this.emitChange("claim",t.pointerId,r.name)}if(i==="release"&&s&&!n){const a=this.active.get(t.pointerId);this.active.delete(t.pointerId),this.log("release",r.name,`pid=${t.pointerId}`),this.emitChange("release",t.pointerId,a??null)}}};handlePointerUp=t=>{if(!Gp(t))return;for(const r of this.sortedHandlers())this.handlerMatchesContainer(r,t)&&r.onPointerUp(t);const n=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,n)};handlePointerCancel=t=>{if(!Gp(t))return;for(const r of this.sortedHandlers())this.handlerMatchesContainer(r,t)&&r.onPointerCancel(t);const n=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,n)};handlerMatchesContainer(t,n){return t.container?t.container.contains(n.target):!0}}const iA=new xF,bF=90,yF=80,vF=70,wF=(e,t)=>{const{scrollMultiplier:n=1.2,maxScrollBoost:r=.8,boostDenominator:s=50,velocityAlpha:i=.15,maxVelocity:a=15,minVelocity:c=.3,decelerationRate:u=.998,enableKinetic:f=!0,shouldCaptureTouch:p,canStartScrollGesture:g,onScroll:y,onScrollWithCoords:v,onTap:S,onClickWithCoords:A,onClaimChange:C,tapThreshold:L=10,gestureName:E="normal-scroll"}=t,M=1.06,P=D.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),F=D.useRef(0),j=D.useRef(0),T=D.useRef(0),Q=D.useRef(null),$=D.useRef(0),Z=D.useRef(!1),V=D.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),fe=D.useCallback(()=>{Q.current=null,F.current!==0&&(v&&j.current>0&&T.current>0?v(F.current,j.current,T.current):y&&y(F.current),F.current=0,j.current=0,T.current=0)},[y,v]),X=D.useCallback(()=>{Q.current===null&&typeof window<"u"&&(Q.current=window.requestAnimationFrame(fe))},[fe]),ge=D.useCallback(($e,ee,ht)=>{F.current+=$e,ee!==void 0&&ht!==void 0&&(j.current=ee,T.current=ht),X()},[X]),be=D.useCallback($e=>{if(!$e||!y)return!1;const ee=y($e);return ee?$.current=0:$.current++,ee},[y]),Te=D.useCallback($e=>{Z.current!==$e&&(Z.current=$e,C?.($e))},[C]),ie=D.useCallback(()=>{const $e=P.current;$e.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame($e.rafId),$e.rafId=null,Q.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(Q.current),Q.current=null,F.current=0},[]),U=D.useRef(S);U.current=S;const G=D.useRef(A);G.current=A;const ae=D.useRef(p);ae.current=p;const ve=D.useCallback(()=>{const $e=e.current;if(!$e||!("PointerEvent"in window))return()=>{};const ee=P.current,ht={name:E,priority:vF,get container(){return e.current??void 0},onPointerDown:(re,Ae)=>(re.pointerType!=="touch"||(ee.pointerId=re.pointerId,ee.startX=Ae.startX,ee.startY=Ae.startY,ee.didMove=!1,ee.gestureAxis=null,ee.lastY=re.clientY,ee.lastTime=V(),ee.velocity=0,ie()),!1),onPointerMove:(re,Ae)=>{if(re.pointerType!=="touch"||ee.pointerId!==re.pointerId||!ee.lastY||!ee.lastTime)return"neutral";const he=re.clientX,Qe=re.clientY,Fe=V(),Ke=Fe-ee.lastTime,K=Qe-ee.lastY;if(ee.startX!==null&&ee.startY!==null){const qe=he-ee.startX,Pe=Qe-ee.startY;if(!ee.didMove&&Math.hypot(qe,Pe)>=L&&(ee.didMove=!0),ee.gestureAxis===null&&ee.didMove){const We=Math.abs(qe),Oe=Math.abs(Pe);We>Oe*M?ee.gestureAxis="x":Oe>We*M&&(ee.gestureAxis="y")}if(ee.gestureAxis==="x")return ee.isCurrentlyScrolling=!1,Te(!1),ee.lastY=Qe,ee.lastTime=Fe,Ae?"release":"neutral";if(ee.gestureAxis===null)return ee.lastY=Qe,ee.lastTime=Fe,"neutral"}if(ee.gestureAxis==="y"&&!Ae&&!(g?.()??!0))return ee.lastY=Qe,ee.lastTime=Fe,Te(!1),"neutral";const de=K/Math.max(Ke,1);if(ee.velocity=ee.velocity*(1-i)+de*i,ee.velocity=Math.max(-a,Math.min(a,ee.velocity)),Math.abs(K)>1){if(!Ae)return Te(!0),ee.lastY=Qe,ee.lastTime=Fe,"claim";ee.isCurrentlyScrolling=!0;const qe=n+Math.min(r,Math.abs(K)/s),Pe=-K*qe;ge(Pe,he,Qe),Te(!0)}return ee.lastY=Qe,ee.lastTime=Fe,Ae?"claim":"neutral"},onPointerUp:re=>{if(re.pointerType!=="touch"||ee.pointerId!==re.pointerId)return;const Ae=ee.isCurrentlyScrolling;ee.isCurrentlyScrolling=!1,Te(!1);const he=ee.rafId!==null||Q.current!==null;!ee.didMove&&!he&&ee.startX!==null&&ee.startY!==null&&U.current?.(ee.startX,ee.startY),!ee.didMove&&!he&&ee.startX!==null&&ee.startY!==null&&G.current?.(ee.startX,ee.startY),ee.pointerId=null,ee.startX=null,ee.startY=null;const Qe=ee.gestureAxis==="x";if(ee.gestureAxis=null,f&&Ae&&!Qe&&Math.abs(ee.velocity)>c&&ee.didMove){const Fe=()=>{const Ke=V(),K=Ke-(ee.lastTime||Ke);if(ee.lastTime=Ke,ee.velocity*=Math.pow(u,K),Math.abs(ee.velocity)<c){ee.velocity=0,ie();return}if(!be(-ee.velocity*K)&&$.current>2){ee.velocity=0,ie();return}ee.rafId=requestAnimationFrame(Fe)};ee.rafId=requestAnimationFrame(Fe)}},onPointerCancel:re=>{re.pointerType!=="touch"||ee.pointerId!==re.pointerId||(ee.isCurrentlyScrolling=!1,Te(!1),ee.pointerId=null,ee.startX=null,ee.startY=null,ee.gestureAxis=null,ie())}},mt=iA.register(ht),me=$e.style.touchAction;return $e.style.touchAction="none",()=>{Te(!1),mt(),$e.style.touchAction=me,ie()}},[e,E,n,r,s,i,a,c,u,V,ie,be,ge,L,f,Te,g]),pe=D.useCallback(()=>{const $e=e.current;if(!$e)return()=>{};const ee=P.current,ht=Ae=>{Ae.touches.length===1&&((p?.()??!0)&&Ae.cancelable&&Ae.preventDefault(),ee.isCurrentlyScrolling=!1,ee.gestureAxis=null,ee.lastY=Ae.touches[0].clientY,ee.startX=Ae.touches[0].clientX,ee.startY=Ae.touches[0].clientY,ee.didMove=!1,ee.velocity=0,ie())},mt=Ae=>{if(Ae.touches.length!==1)return;const he=Ae.touches[0].clientX,Qe=Ae.touches[0].clientY;if(ee.startX!==null&&ee.startY!==null){const Ke=he-ee.startX,K=Qe-ee.startY;if(!ee.didMove&&Math.hypot(Ke,K)>=L&&(ee.didMove=!0),ee.gestureAxis===null&&ee.didMove){const de=Math.abs(Ke),qe=Math.abs(K);de>qe*M?ee.gestureAxis="x":qe>de*M&&(ee.gestureAxis="y")}if(ee.gestureAxis==="x"){ee.isCurrentlyScrolling=!1,ee.lastY=Qe;return}if(ee.gestureAxis===null){(p?.()??!1)&&Ae.cancelable&&Ae.preventDefault(),ee.lastY=Qe;return}}if(Ae.preventDefault(),!ee.lastY){ee.lastY=Qe;return}const Fe=Qe-ee.lastY;if(Math.abs(Fe)>1){ee.isCurrentlyScrolling=!0;const Ke=n+Math.min(r,Math.abs(Fe)/s),K=-Fe*Ke;ge(K,he,Qe)}ee.lastY=Qe},me=Ae=>{if(!Ae.changedTouches?.[0])return;const Qe=ee.isCurrentlyScrolling;ee.isCurrentlyScrolling=!1;const Fe=ee.rafId!==null||Q.current!==null;!ee.didMove&&!Fe&&S&&ee.startX!==null&&ee.startY!==null&&S(ee.startX,ee.startY),!ee.didMove&&!Fe&&A&&ee.startX!==null&&ee.startY!==null&&A(ee.startX,ee.startY),ee.startX=null,ee.startY=null;const Ke=ee.gestureAxis==="x";if(ee.gestureAxis=null,f&&Qe&&!Ke&&ee.didMove&&Math.abs(ee.velocity)>c){const K=()=>{if(ee.velocity*=Math.pow(u,16),Math.abs(ee.velocity)<c){ee.velocity=0,ie();return}if(!be(-ee.velocity*16)&&$.current>2){ee.velocity=0,ie();return}ee.rafId=requestAnimationFrame(K)};ee.rafId=requestAnimationFrame(K)}};$e.addEventListener("touchstart",ht,{passive:!1}),$e.addEventListener("touchmove",mt,{passive:!1}),$e.addEventListener("touchend",me,{passive:!1}),$e.addEventListener("touchcancel",me,{passive:!1});const re=$e.style.touchAction;return $e.style.touchAction="none",()=>{$e.removeEventListener("touchstart",ht),$e.removeEventListener("touchmove",mt),$e.removeEventListener("touchend",me),$e.removeEventListener("touchcancel",me),$e.style.touchAction=re,ie()}},[e,n,r,s,c,u,ie,be,ge,S,A,L,p,f]),we=D.useCallback(()=>{ie();const $e=typeof window<"u"&&"PointerEvent"in window,ee=$e?ve():()=>{},ht=$e?()=>{}:pe();return()=>{ee(),ht(),ie()}},[ve,pe,ie]),ze=D.useCallback(()=>P.current.isCurrentlyScrolling||P.current.rafId!==null||Q.current!==null,[]),Ce=D.useCallback(()=>{ie();const $e=P.current;$e.isCurrentlyScrolling=!1,$e.velocity=0,$e.lastY=null,$e.lastTime=null,$e.startX=null,$e.startY=null,$e.pointerId=null,$e.didMove=!1,$e.gestureAxis=null},[ie]);return{setupTouchScroll:we,isScrolling:ze,stopAllScroll:Ce}};function a3(e){const{name:t,priority:n}=e,r=x.useRef(e.onPointerDown),s=x.useRef(e.onPointerMove),i=x.useRef(e.onPointerUp),a=x.useRef(e.onPointerCancel),c=x.useRef(e.container);r.current=e.onPointerDown,s.current=e.onPointerMove,i.current=e.onPointerUp,a.current=e.onPointerCancel,c.current=e.container,x.useEffect(()=>{const u={name:t,priority:n,get container(){const p=c.current;return typeof p=="function"?p():p},onPointerDown(p,g){return r.current?.(p,g)??!1},onPointerMove(p,g){return s.current?.(p,g)??"neutral"},onPointerUp(p){i.current?.(p)},onPointerCancel(p){a.current?.(p)}};return iA.register(u)},[t,n])}var Ti;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})(Ti||(Ti={}));Ti.Light,Ti.Medium,Ti.Heavy,Ti.Success,Ti.Warning,Ti.Error;Ti.Light,Ti.Medium,Ti.Heavy,Ti.Success,Ti.Warning,Ti.Error;Ti.Light,Ti.Medium,Ti.Heavy,Ti.Success,Ti.Warning,Ti.Error;const SF=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",AF=()=>typeof document<"u"&&!!document.body,TF=()=>{if(AF())try{const e=document.createElement("label");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;";const t=document.createElement("input");t.type="checkbox",t.setAttribute("switch",""),e.appendChild(t),document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch{}},l3=e=>Array.isArray(e)?[...e]:[e],CF=e=>{if(SF()){try{const s=l3(e),i=s.length===1?s[0]:s;navigator.vibrate(i)}catch{}return}const t=l3(e),n=Array.from({length:Math.ceil(t.length/2)},(s,i)=>[t[i*2]??0,t[i*2+1]??0]);let r=0;for(const[s,i]of n)s>0&&setTimeout(TF,r),r+=s+i},$l=e=>CF(e),kF=({message:e})=>{const{t}=er();return o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsxs("div",{className:"rounded-full bg-surface-2 px-4 py-2 flex items-center gap-3 shadow-sm",children:[o.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:e??t("terminal.loading")})]})})},_F=()=>{const{t:e}=er();return o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsxs("div",{className:"rounded-full bg-surface-2 px-4 py-2 flex items-center gap-3 shadow-sm",children:[o.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:e("terminal.initializing")})]})})},LF=({message:e,onRetry:t})=>{const{t:n}=er();return o.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:o.jsxs("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,role:"img","aria-label":n("terminal.error"),children:[o.jsx("title",{children:n("terminal.error")}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})]})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"font-medium text-foreground",children:n("terminal.failedToLoad")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e||n("terminal.unknownError")})]}),t&&o.jsx("button",{type:"button",onClick:t,className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:n("common.retry")})]})})},EF="debug",IF="termdock:debug";function c3(e){return e?new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean)):new Set}function RF(){if(typeof window>"u")return new Set;const e=c3(new URLSearchParams(window.location.search).get(EF));let t=new Set;try{t=c3(window.localStorage.getItem(IF))}catch{t=new Set}const n=new Set([...e,...t]);return n.has("1")||n.has("true")||n.has("*")||n.has("all")?new Set(["*"]):n}function NF(e){const t=RF();return t.has("*")||t.has(e)}function ld(e){const t=NF(e);return(...n)=>{t&&console.log(`[debug:${e}]`,...n)}}function Bm(e){return Array.from(e)}function u3(e,t,n){return Math.max(t,Math.min(n,e))}function MF(e,t,n,r){const s=Bm(e),i=Bm(t);let a=u3(n,0,s.length);const c=u3(r,0,i.length);let u=0;for(;u<s.length&&u<i.length&&s[u]===i[u];)u++;let f=0;for(;f<s.length-u&&f<i.length-u&&s[s.length-1-f]===i[i.length-1-f];)f++;const p=s.length-u-f,g=i.slice(u,i.length-f).join(""),y=[];if(p>0||g){const v=u+p;a>v?y.push({left:a-v}):a<v&&y.push({right:v-a}),a=v,p>0&&(y.push({backspace:p}),a=u),g&&(y.push({insert:g}),a+=Bm(g).length)}return a>c?y.push({left:a-c}):a<c&&y.push({right:c-a}),a=c,{ops:y,cursor:a}}function d3(e){const t=e.value,n=e.selectionStart??t.length;return Bm(t.slice(0,n)).length}const ag=16,DF=10,f3=1.5,jF=1.8,h3=240,PF=125,BF=92;function FF(e,t,n){const r=Math.hypot(e,t),s=Math.abs(e),i=Math.abs(t),a=()=>s>=i*f3?e>0?"right":"left":i>=s*f3?t>0?"down":"up":"";if(n==="")return r>ag?a():"";if(r<DF)return"";if(r<=ag)return n;const c=a();if(c===""||c===n)return n;if(n==="left"&&c==="right"||n==="right"&&c==="left"||n==="up"&&c==="down"||n==="down"&&c==="up")return c;const f=n==="left"||n==="right";return(f?i:s)>=(f?s:i)*jF?c:n}function OF(e){const t=BF-ag,n=Math.min(Math.max((e-ag)/t,0),1);return h3-n*(h3-PF)}const v2="termdock-open-terminal-directory",p3=/(?:\\[ \t]|[^\s`"'<>|()[\]{}=,:;!?])+/gu,QF=/[,;:!?]+$/u,$F=/^[a-z][a-z\d+.-]*:\/\//iu;function HF(e){return!e||e==="/"||$F.test(e)||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.endsWith("/")||/^[^/:]+\/[^/:]+\/(?:[^/:]+\/?)+$/u.test(e)}function zF(e){const t=[];p3.lastIndex=0;let n;for(;(n=p3.exec(e))!==null;){const s=n[0].replace(QF,"");HF(s)&&t.push({text:s,startIndex:n.index,endIndex:n.index+s.length})}return t}function Px(e){const t=[];for(const n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return`/${t.join("/")}`}function UF(e){return e.match(/^\/(?:home|Users)\/[^/]+/u)?.[0]??null}function GF(e,t){const n=e.replace(/\\([ \t])/gu,"$1").replace(/\/+$/u,"")||"/";if(n.startsWith("/"))return Px(n);if(n==="~"||n.startsWith("~/")){const r=t?UF(t):null;return r?Px(`${r}/${n.slice(2)}`):null}return t?.startsWith("/")?Px(`${t}/${n}`):null}function WF(e,t){const n=e.buffer.active;let r=t-1;if(!n.getLine(r))return null;for(;r>0&&n.getLine(r)?.isWrapped;)r-=1;let s=t-1;for(;s+1<n.length&&n.getLine(s+1)?.isWrapped;)s+=1;let i="";const a=[],c=[];for(let f=r;f<=s&&i.length<=2048;f+=1){const p=n.getLine(f);if(!p)break;for(let g=0;g<p.length;g+=1){const y=p.getCell(g);if(!y||y.getWidth()===0)continue;const v=y.getChars()||" ";i+=v;for(let S=0;S<v.length;S+=1)a.push({x:g+1,y:f+1}),c.push({x:g+Math.max(1,y.getWidth()),y:f+1})}}const u=i.trimEnd().length;return{text:i.slice(0,u),startPositions:a.slice(0,u),endPositions:c.slice(0,u)}}function VF(e,t){return{provideLinks(n,r){const s=WF(e,n);if(!s){r(void 0);return}const i=zF(s.text).map(a=>({text:a.text,range:{start:s.startPositions[a.startIndex]??{x:a.startIndex+1,y:n},end:s.endPositions[a.endIndex-1]??{x:a.endIndex,y:n}},activate:()=>t(a.text)}));r(i.length>0?i:void 0)}}}function m3(e,t){if(!e||e.lines.length===0||!Number.isFinite(t)||t<=0)return 0;const n=Math.floor(t),r=Number.isFinite(e.lines.maxLength)&&e.lines.maxLength>0?Math.floor(e.lines.maxLength):null;let s=0;if(r!==null){const u=Math.max(0,r-n);e.ybase>u&&(e.ybase=u,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,u)),s++)}const i=Math.max(0,Math.floor(e.ybase)+n),a=r===null?i:Math.min(i,r),c=Math.max(0,a-e.lines.length);for(let u=0;u<c;u++){const f=e.lines.length;if(e.lines.push(e.getBlankLine(void 0)),e.lines.length<=f)break;s++}return s}function g3(e,t=e.rows){const r=e._core?._bufferService?.buffers;return r?m3(r.normal,t)+m3(r.alt,t):0}const Fu=8,Wp=36,x3=10,qF=1.08,KF=1.16,Vp=6,YF=.94,XF=.08,ZF=.12,JF=88,eO=36,tO=10,nO=14,rO=52;function qp(e){return e?e.replace(/\r\n|\r|\n/g,"\r").replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," ").replace(/[\u200B-\u200D\uFEFF]/g,""):""}const sO=80,iO=8,b3={F1:"\x1BOP",F2:"\x1BOQ",F3:"\x1BOR",F4:"\x1BOS",F5:"\x1B[15~",F6:"\x1B[17~",F7:"\x1B[18~",F8:"\x1B[19~",F9:"\x1B[20~",F10:"\x1B[21~",F11:"\x1B[23~",F12:"\x1B[24~"};function du(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function oO(e,t){switch(e.key){case"ArrowUp":return du(t,"A");case"ArrowDown":return du(t,"B");case"ArrowRight":return du(t,"C");case"ArrowLeft":return du(t,"D");case"Home":return"\x1B[H";case"End":return"\x1B[F";case"PageUp":return"\x1B[5~";case"PageDown":return"\x1B[6~";case"Insert":return"\x1B[2~";case"Delete":return"\x1B[3~";case"Tab":return" ";case"Escape":return"\x1B";default:return b3[e.key]?b3[e.key]:null}}function aO(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function lO(e){try{const t=atob(e),n=Uint8Array.from(t,r=>r.charCodeAt(0));return new TextDecoder("utf-8").decode(n)}catch{return null}}function cO(e){const t="\x1B]52;";let n=0,r="";for(;n<e.length;){const s=e.indexOf(t,n);if(s===-1)return r+=e.slice(n),{cleaned:r,remainder:""};r+=e.slice(n,s);let i=-1,a=1;for(let f=s+t.length;f<e.length;f+=1){const p=e.charCodeAt(f);if(p===7){i=f,a=1;break}if(p===27&&f+1<e.length&&e[f+1]==="\\"){i=f,a=2;break}}if(i===-1)return{cleaned:r,remainder:e.slice(s)};const c=e.slice(s+t.length,i),u=c.indexOf(";");if(u>=0){const f=c.slice(u+1);if(f&&f!=="?"){const p=lO(f);p!==null&&navigator.clipboard?.writeText(p).catch(()=>{})}}n=i+a}return{cleaned:r,remainder:""}}function uO(e){if(typeof window>"u")return null;const t=[e,...Array.from(e.querySelectorAll("*"))];let n=null;for(const r of t){const i=window.getComputedStyle(r).overflowY;if(!(i!=="auto"&&i!=="scroll")){if(r.scrollHeight-r.clientHeight>2)return r;n||(n=r)}}return n}const dO=new Set(["visibility","bfcache","online"]),fO=5e5,hO=1e5,Mf=260,Df=140,y3=80;function pO(e){return!e}let qd=null;const mO=[{font:'400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'italic 400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 italic 13px "Termdock Mono"',text:"Termdock 0123456789 ❖ "},{font:'400 13px "Noto Sans Symbols 2"',text:"⏺⏸⏹✓✗"},{font:'400 13px "Termdock Star Symbol"',text:"✦✧"},{font:'400 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"},{font:'700 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"}],gO=()=>{if(qd)return qd;if(typeof document>"u"||!("fonts"in document))return qd=Promise.resolve(),qd;const e=document.fonts;return qd=Promise.allSettled(mO.map(({font:n,text:r})=>e.load(n,r))).then(()=>e.ready).then(()=>{}).catch(()=>{}),qd},v3=e=>{if((!e||e.includes("var("))&&typeof window<"u"){const t=getComputedStyle(document.documentElement).getPropertyValue("--font-mono").trim();if(t)return t}return e};function w3(e){return e==="normal"||e==="bold"?e:Math.max(1,Math.min(1e3,Math.round(e)))}function Ou(e,t,n){const r=e?.dimensions?.css.cell.height;return Math.max(8,Math.round(r||t*n))}function xO(e){return{background:e.background,foreground:e.foreground,cursor:e.cursor||e.foreground,cursorAccent:e.cursorAccent||e.background,selectionBackground:e.selectionBackground||"rgba(0, 0, 0, 0.3)",selectionForeground:e.selectionForeground||e.foreground,black:e.black||"#6F6E69",red:e.red||"#AF3029",green:e.green||"#66800B",yellow:e.yellow||"#AD8301",blue:e.blue||"#205EA6",magenta:e.magenta||"#A02F6F",cyan:e.cyan||"#24837B",white:e.white||"#CECDC3",brightBlack:e.brightBlack||"#6F6E69",brightRed:e.brightRed||"#D14D41",brightGreen:e.brightGreen||"#879A39",brightYellow:e.brightYellow||"#D0A215",brightBlue:e.brightBlue||"#4385BE",brightMagenta:e.brightMagenta||"#CE5D97",brightCyan:e.brightCyan||"#3AA99F",brightWhite:e.brightWhite||"#FFFCF0"}}const S3=new Map;function bO(e,t,n,r,s){if(typeof window>"u"||typeof document>"u")return null;const i=e.getBoundingClientRect();if(i.width<24||i.height<24)return null;const a=window.devicePixelRatio||1,c=`${n}::${r}::${s}::${a}::${t}`;let u=S3.get(c);if(!u)try{const y=document.createElement("canvas").getContext("2d");if(!y)return null;y.font=`${n}px ${t}`;const v=y.measureText("M"),A=(Math.floor(v.width*a)+Math.round(r))/a,C=v.actualBoundingBoxAscent??n*.8,L=v.actualBoundingBoxDescent??n*.2,E=Math.floor(Math.ceil(C+L)*s);A>=1&&E>=1&&(u={cellWidth:A,cellHeight:E},S3.set(c,u))}catch{return null}if(!u)return null;const f=Math.max(2,Math.floor(i.width/u.cellWidth)),p=Math.max(2,Math.floor(i.height/u.cellHeight));return!Number.isFinite(f)||!Number.isFinite(p)?null:{cols:f,rows:p}}async function A3(e){if(!e)return!1;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}function yO(e){const t=e.buffer.active,n=t.viewportY,r=Math.min(t.length,n+e.rows),s=[];for(let i=n;i<r;i+=1){const a=t.getLine(i);a&&s.push(a.translateToString(!0))}return s.join(`
68
68
  `).replace(/\s+$/g,"")}function jf(e,t,n){const r=Ju(e);if(!r)return null;const s=Math.max(0,Math.min(e.cols-1,Math.floor((t-r.originLeft)/r.cellW))),i=Math.max(0,Math.min(e.rows-1,Math.floor((n-r.originTop)/r.cellH)));return{col:s,row:e.buffer.active.viewportY+i}}function Bx(e,t,n){const r=t.row*e.cols+t.col,s=n.row*e.cols+n.col;if(r===s)return e.clearSelection(),!1;const i=Math.min(r,s),a=Math.max(r,s)+1,c=i%e.cols,u=Math.floor(i/e.cols);return e.select(c,u,a-i),!0}function T3(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function vO(e,t,n,r,s=!0){if(typeof window>"u")return{left:0,top:0};const i=window.visualViewport,a=i?.offsetLeft??0,c=i?.offsetTop??0,u=i?.width??window.innerWidth,f=i?.height??window.innerHeight,p=T3("--safe-top-inset"),g=T3("--safe-bottom-inset"),y=r?XB(r.terminal,r.anchor,r.focus):null,v=[];let S;if(s&&v.push({left:e-32,top:t-32,right:e+32,bottom:t+32}),r){const C=Ju(r.terminal),{start:L,end:E}=og(r.anchor,r.focus,r.terminal.cols),M=Pm(r.terminal,L),P=Pm(r.terminal,E);if(M&&v.push({left:M.x-24,top:M.y-48,right:M.x+24,bottom:M.y+4}),P&&C){const F=P.y+C.cellH;v.push({left:P.x-24,top:F-4,right:P.x+24,bottom:F+48})}if(y){const F=r.anchor.row*r.terminal.cols+r.anchor.col,j=r.focus.row*r.terminal.cols+r.focus.col,T=F<=j,Q=y.right-y.left,Z=r.anchor.row===r.focus.row?T?y.left+Q*.25:y.right-Q*.25:(y.left+y.right)/2,V=Pm(r.terminal,r.focus),fe=V&&C?V.y+C.cellH/2:t;S={vertical:r.focus.row<r.anchor.row?"below":"above",alignX:Z,focusX:V?.x??e,focusY:fe}}}const A=ZB({clientX:e,clientY:t,viewport:{left:a,top:c+p,right:a+u,bottom:c+f-g},terminal:n,width:JF,height:eO,margin:tO,fingerGap:nO,selection:y,avoid:v,preference:S,selectionGap:rO});return{left:A.left-n.left,top:A.top-n.top}}const oA=D.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,onFlowControl:s,onTmuxScroll:i,tmuxScrollSensitivity:a=.55,onDoubleTap:c,onInputFocusChange:u,onMobileLongPressCopyResult:f,onMobilePasteResult:p,onReadyChange:g,onDirectoryLinkActivate:y,terminalSettings:v,theme:S,className:A,enableTouchScroll:C,mobileLongPressMode:L="arrows",autoFocus:E=!0},M)=>{const{t:P}=er(),F=D.useRef(null),j=D.useRef(null),T=D.useRef(null),Q=D.useRef(null),$=D.useRef(n),Z=D.useRef(r),V=D.useRef(u),fe=D.useRef(s),X=D.useRef(g);X.current=g;const ge=D.useRef(y);ge.current=y;const be=D.useRef(v.rendererMode),Te=D.useRef(""),ie=D.useRef(0),U=D.useRef(!1),G=D.useRef(null),ae=D.useRef(!1),ve=D.useRef(null),pe=D.useRef(null),we=D.useRef(null),ze=D.useRef(void 0),Ce=D.useRef(null),$e=D.useRef(!1),ee=D.useRef(0),ht=D.useRef(""),mt=D.useRef(null),me=D.useRef(null),re=D.useRef(!1),Ae=D.useRef(typeof window<"u"?window.devicePixelRatio:1),he=D.useRef(null),Qe=D.useRef(!1),Fe=D.useRef(!1),Ke=D.useRef(null),K=D.useRef(""),de=D.useRef(0),qe=D.useRef(null),Pe=D.useRef(null),We=D.useRef(null),Oe=D.useRef(0),pt=D.useRef(0),st=D.useRef(0),jt=D.useRef(null),Lt=D.useRef(0),Nt=D.useRef(0),Pt=D.useRef(!1),vn=D.useRef(0),[,Yn]=D.useReducer(B=>B+1,0),[Se,lt]=D.useReducer(B=>B+1,0),[ut,tn]=D.useState("loading"),[ft,Wt]=D.useState(null),it=D.useMemo(()=>ld("terminal"),[]),[Ve,Xn]=D.useState(!0),[Bn,Ue]=D.useState(!1);D.useEffect(()=>{if(!Ve&&ut!=="loading"){Ue(!1);return}const B=window.setTimeout(()=>Ue(!0),160);return()=>window.clearTimeout(B)},[Ve,ut]);const[Nn,Ft]=D.useState(!1),[br,Fn]=D.useState({visible:!1,activeDir:""}),[Tn,Qr]=D.useState(null),kr=D.useRef(null),Ir=D.useRef(!1),wr=D.useRef({active:!1,anchor:null,focus:null,dragging:null}),[Le,te]=D.useState(null),[Rt,Ne]=D.useState({x:0,y:0,cellW:8,cellH:17,cursorX:0}),qt=D.useRef(Rt);qt.current=Rt;const Zt=D.useRef(null),[Qt,an]=D.useState({active:!1,text:""}),nn=D.useRef(null),fr=D.useRef(null);$.current=n,Z.current=r,V.current=u,fe.current=s,be.current=v.rendererMode;const Wn=D.useRef(E);Wn.current=E;const ar=D.useRef(C);ar.current=C;const Zr=pO(!!i),{rendererMode:Re,fontFamily:et,fontSize:vt,fontWeight:rn,fontWeightBold:fn,letterSpacing:$t,lineHeight:on,minimumContrastRatio:hn,drawBoldTextInBrightColors:Qn,unicodeVersion:At,customGlyphs:zn,rescaleOverlappingGlyphs:Ge,fontLigatures:Mt,enableImages:Ye,smoothScrolling:ct}=v,Jt=Re==="webgl",Ht=D.useCallback(()=>{kr.current!==null&&(clearTimeout(kr.current),kr.current=null),Qr(null)},[]),xn=D.useCallback((B,Y)=>{kr.current!==null&&(clearTimeout(kr.current),kr.current=null),Ir.current=!1,Qr(B),!Y?.persistent&&(kr.current=setTimeout(()=>{kr.current=null,Qr(null)},3e3))},[]);D.useEffect(()=>{if(!Tn)return;const B=()=>{wr.current.active||Ht()},Y=()=>Ht();return window.addEventListener("scroll",B,!0),window.addEventListener("resize",Y),document.addEventListener("visibilitychange",Y),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",Y),document.removeEventListener("visibilitychange",Y)}},[Ht,Tn]),D.useEffect(()=>()=>{kr.current!==null&&(clearTimeout(kr.current),kr.current=null)},[]);const Me=D.useCallback(()=>{const B=T.current,Y=F.current,q=wr.current;if(!B||!Y||!q.active||!q.anchor||!q.focus){te(null);return}const ce=Y.getBoundingClientRect(),ot=Ju(B)?.cellH??16,{start:nt,end:xt}=og(q.anchor,q.focus,B.cols),zt=q.dragging==="start"?q.focus:q.dragging==="end"?q.anchor:nt,St=q.dragging==="end"?q.focus:q.dragging==="start"?q.anchor:xt,Yt=(xr,jr)=>{const is=Pm(B,xr);return is?{left:is.x-ce.left,top:jr?is.y-ce.top:is.y+ot-ce.top}:null};te({start:Yt(zt,!0),end:Yt(St,!1)})},[]),tt=D.useCallback(B=>{const Y=T.current,q=F.current,ce=wr.current;if(!Y||!q||!ce.active||!ce.anchor||!ce.focus)return;if(ce.dragging){Ht();return}const ot=q.getBoundingClientRect(),nt={x:(ot.left+ot.right)/2,y:(ot.top+ot.bottom)/2};xn(vO(B?.x??nt.x,B?.y??nt.y,ot,{terminal:Y,anchor:ce.anchor,focus:ce.focus},B!==void 0),{persistent:!0})},[Ht,xn]),yt=D.useCallback(()=>{const B=wr.current;B.active=!1,B.anchor=null,B.focus=null,B.dragging=null,te(null),Ht()},[Ht]);D.useEffect(()=>{if(!Le)return;const B=T.current;if(!B)return;const Y=B.onScroll(()=>{Me(),tt()}),q=B.onResize(()=>yt());return()=>{Y.dispose(),q.dispose()}},[Le,Me,tt,yt]),D.useEffect(()=>{C||V.current?.(!1)},[C]);const Ot=D.useCallback((B,Y,q)=>{const ce=(q.element?.offsetWidth||0)/q.cols||8,ot=(q.element?.offsetHeight||0)/q.rows||16,nt=Math.max(1,Math.min(q.cols,Math.floor(B/ce)+1)),xt=Math.max(1,Math.min(q.rows,Math.floor(Y/ot)+1));return{x:nt,y:xt}},[]),Zn=D.useCallback((B,Y,q)=>{const ce=T.current;if(!ce)return!1;const ot=B>0?-1:1;if(ce.modes?.mouseTrackingMode!=="none"){let nt,xt;if(Y!==void 0&&q!==void 0){const Yt=Ot(Y,q,ce);nt=Yt.x,xt=Yt.y}else nt=ce.buffer.active.cursorX+1,xt=ce.buffer.active.cursorY+1;const St=`\x1B[<${ot>0?64:65};${nt};${xt}M`;return $.current(St),!0}if(ce.buffer.active.type==="alternate"){const nt=ot>0?"\x1B[A":"\x1B[B";return $.current(nt),!0}return null},[Ot]),pn=D.useCallback(B=>{const Y=T.current;if(!Y)return!1;const q=Ou(T.current,vt,on),ce=ee.current+B,ot=Math.trunc(ce/q);return ee.current=ce-ot*q,ot!==0?(Y.scrollLines(ot),!0):!1},[vt,on]),bn=D.useCallback(B=>{if(!T.current)return!1;const ce=Ou(T.current,vt,on)/Math.max(.1,a),ot=ee.current+B;let nt=Math.trunc(ot/ce);if(ee.current=ot-nt*ce,nt===0&&Math.abs(ot)>=ce/3&&(nt=ot>0?1:-1,ee.current=0),nt===0)return!1;const xt=nt>0?"down":"up",zt=Math.max(1,Math.min(Math.abs(nt),10));return i(xt,zt),!0},[vt,on,i,a]),Kt=D.useRef(Zn);Kt.current=Zn;const nr=D.useRef(pn);nr.current=pn;const lr=D.useRef(bn);lr.current=bn;const Cn=D.useRef(i);Cn.current=i;const _r=D.useRef({pointerId:null,tmuxActiveAtDown:!1});D.useEffect(()=>{if(!C)return;const B=F.current;if(!B)return;const Y=ce=>{ce.pointerType==="touch"&&(_r.current.pointerId=ce.pointerId,_r.current.tmuxActiveAtDown=!!Cn.current)},q=ce=>{ce.pointerType==="touch"&&_r.current.pointerId===ce.pointerId&&(_r.current.pointerId=null,_r.current.tmuxActiveAtDown=!1)};return B.addEventListener("pointerdown",Y,{capture:!0,passive:!0}),B.addEventListener("pointerup",q,{capture:!0,passive:!0}),B.addEventListener("pointercancel",q,{capture:!0,passive:!0}),()=>{B.removeEventListener("pointerdown",Y,!0),B.removeEventListener("pointerup",q,!0),B.removeEventListener("pointercancel",q,!0)}},[C]);const Jr=D.useCallback(()=>{if(Pt.current)return!1;const B=_r.current;return B.pointerId!==null?!B.tmuxActiveAtDown:!Cn.current},[]),sr=D.useCallback((B,Y,q)=>{const ce=Kt.current(B,Y,q);return ce!==null?ce:Cn.current?lr.current(B):nr.current(B)},[]),pr=D.useCallback((B,Y)=>{if(performance.now()<=Nt.current){Nt.current=0;return}const q=T.current;if(q&&q.modes?.mouseTrackingMode!=="none"){const ce=Ot(B,Y,q),ot=ce.x,nt=ce.y,xt=`\x1B[<0;${ot};${nt}M`,zt=`\x1B[<0;${ot};${nt}m`;$.current(xt),$.current(zt)}},[Ot]),Br=D.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),mr=D.useCallback((B=700)=>{jt.current=null,Lt.current=Br()+B},[Br]),vs=D.useCallback(()=>ar.current&&Br()<=Lt.current,[Br]),le=D.useCallback(()=>{const B=we.current;return!B||typeof document>"u"?!1:document.activeElement===B},[]),oe=D.useCallback(()=>{if(typeof window>"u")return!1;const B=zt=>{if(typeof document>"u")return 0;const St=Number.parseFloat(document.documentElement.style.getPropertyValue(zt)||"0");return Number.isFinite(St)?St:0},Y=B("--kb-height");if(Y>0)return Y>=y3;const q=window.visualViewport;if(!q)return!1;const ce=B("--app-base-vh")||window.innerHeight,ot=B("--safe-bottom-inset"),nt=q.height+q.offsetTop;return Math.max(0,Math.round(ce-nt-ot))>=y3},[]),ke=D.useCallback(()=>{qe.current!==null&&(clearTimeout(qe.current),qe.current=null),Pe.current=null},[]),Xe=D.useCallback(B=>{const Y=T.current;let q="";for(const ce of B)ce.left&&(q+=(Y?du(Y,"D"):"\x1B[D").repeat(ce.left)),ce.right&&(q+=(Y?du(Y,"C"):"\x1B[C").repeat(ce.right)),ce.backspace&&(q+="".repeat(ce.backspace)),ce.insert&&(q+=ce.insert);return q},[]),Bt=D.useCallback(B=>{const Y=B.value,q=qp(Y),ce=K.current;if(!(ar.current&&!q.includes("\r")&&!ce.includes("\r"))){if(q===ce)return;let Yt=0;for(;Yt<ce.length&&Yt<q.length&&ce[Yt]===q[Yt];)Yt++;const xr=ce.length-Yt;xr>0&&$.current("".repeat(xr));const jr=q.slice(Yt);if(jr){try{T.current?.clearSelection()}catch{}$.current(jr)}K.current=q,de.current=Array.from(q).length;return}const nt=d3(B),{ops:xt,cursor:zt}=MF(ce,q,de.current,nt),St=Xe(xt);if(St){if(xt.some(Yt=>Yt.insert))try{T.current?.clearSelection()}catch{}$.current(St)}K.current=q,de.current=zt},[Xe]),It=D.useCallback((B,Y)=>{const q=B.value,ce=qp(q),ot=K.current;if(ce===ot){ke();return}let nt=0;for(;nt<ot.length&&nt<ce.length&&ot[nt]===ce[nt];)nt++;const xt=ot.length-nt;if(C&&!Y?.immediate&&xt>=iO){Pe.current=B,qe.current!==null&&clearTimeout(qe.current),qe.current=setTimeout(()=>{qe.current=null;const St=Pe.current;Pe.current=null,St&&Bt(St)},sO);return}ke(),Bt(B)},[ke,C,Bt]),yn=D.useCallback(B=>{It(B,{immediate:!0}),$.current("\r"),B.value="",K.current="",de.current=0},[It]),Gt=D.useCallback((B,Y,q)=>{if(!B)return;ke();const ce=Y??we.current;ce&&(ce.value=""),K.current="",de.current=0;try{T.current?.clearSelection()}catch{}if(yt(),q?.paste&&/[\r\n]/.test(B)){const ot=q.submitAfterPaste??B.endsWith("\r"),nt=nF(B,ot);$.current(nt,{skipModifierTransform:!0,consumeModifier:q?.consumeModifier});return}$.current(B,{skipModifierTransform:!0,consumeModifier:q?.consumeModifier})},[ke]),ln=D.useCallback((B,Y)=>{const q=qp(B);return q?(Gt(q,Y,{paste:!0,submitAfterPaste:!1}),Ht(),!0):!1},[Ht,Gt]);D.useEffect(()=>IR(B=>{if(B.sessionKey!==e||B.paths.length===0)return;const Y=B.paths.map(ow).join(" ");Gt(Y);try{we.current?.focus({preventScroll:!0})}catch{}}),[Gt,e]);const _n=D.useCallback(async B=>{try{const Y=Di();if(Y?.pasteClipboardImage){const ce=await Y.pasteClipboardImage();if(ce)return Gt(ow(ce),B),Ht(),!0}if(!navigator.clipboard?.readText)return!1;const q=await navigator.clipboard.readText();return ln(q,B)}catch{return!1}},[Ht,ln,Gt]),In=D.useCallback(()=>{if(C||Zt.current)return null;const B=T.current;if(!B||!B.element)return null;const Y=Ju(B),ce=B.element.querySelector(".xterm-screen")??B.element,ot=ce.getBoundingClientRect(),nt=Y?.cellW??(ot.width>0&&B.cols>0?ot.width/B.cols:8),xt=Y?.cellH??(ot.height>0&&B.rows>0?ot.height/B.rows:17),zt=we.current;let St=ze.current;zt&&(St===void 0||St!==null&&(!St.isConnected||!St.contains(zt)))&&(St=eF(zt),ze.current=St);const Yt=B.buffer.active,xr=Yt.cursorX*nt,jr=Yt.cursorY*xt,is=tF(ce,St??null,xr,jr),fs=Math.round(is.x),si=Math.round(is.y),En={x:fs,y:si,cellW:nt,cellH:xt,cursorX:Yt.cursorX};return qt.current=En,Ne(Vn=>Math.abs(Vn.x-fs)<.5&&Math.abs(Vn.y-si)<.5&&Math.abs(Vn.cellW-nt)<.5&&Math.abs(Vn.cellH-xt)<.5&&Vn.cursorX===Yt.cursorX?Vn:En),En},[C]),Ln=D.useRef(In);Ln.current=In;const Sr=D.useCallback(B=>{let Y=0;for(const q of B){const ce=q.codePointAt(0)??0,ot=ce>=4352&&ce<=4447||ce>=11904&&ce<=12350||ce>=12353&&ce<=13311||ce>=13312&&ce<=19903||ce>=19968&&ce<=40959||ce>=40960&&ce<=42191||ce>=44032&&ce<=55203||ce>=63744&&ce<=64255||ce>=65072&&ce<=65103||ce>=65280&&ce<=65376||ce>=65504&&ce<=65510||ce>=127744&&ce<=129791;Y+=ot?2:1}return Y},[]),yr=D.useCallback(B=>{const Y=T.current,{cellW:q,cellH:ce}=Rt;if(!Y||!B)return{width:Math.max(1,Math.round(q)),height:Math.max(1,Math.round(ce)),whiteSpace:"pre"};const nt=Zt.current?.cursorX??Y.buffer.active.cursorX,xt=Math.max(1,Y.cols),zt=Math.max(1,Sr(B)),St=Math.max(1,xt-nt);if(zt<=St)return{width:Math.max(1,Math.round(zt*q)),height:Math.max(1,Math.round(ce)),whiteSpace:"pre"};const Yt=zt-St,jr=1+Math.ceil(Yt/xt);return{width:Math.max(1,Math.round(St*q)),height:Math.max(1,Math.round(jr*ce)),whiteSpace:"pre-wrap"}},[Rt,Sr]),Ar=D.useCallback(()=>{ze.current=void 0;const B=Ln.current();Zt.current={...B??qt.current}},[]),Rr=D.useCallback(()=>{Zt.current=null},[]),Mn=D.useCallback(B=>{if(!Qe.current&&Zt.current===null)return!1;if(Qe.current=!1,Zt.current=null,ke(),Ke.current!==null&&(clearTimeout(Ke.current),Ke.current=null),Fe.current=!1,B){B.value=K.current;try{B.setSelectionRange(B.value.length,B.value.length)}catch{}}return an(Y=>Y.active||Y.text?{active:!1,text:""}:Y),!0},[ke]),sn=D.useCallback((B,Y)=>{const q=we.current;if(q)try{q.removeAttribute("readonly");const ot=typeof document<"u"&&document.activeElement===q&&!oe(),nt=Br(),xt=nt-vn.current;vn.current=nt,ot&&xt>600?(q.blur(),q.removeAttribute("readonly"),q.focus(),vn.current=Br()):q.focus()}catch{}},[oe,Br]),cn=D.useCallback(B=>{pt.current=Br()+B},[Br]),Gn=D.useCallback(()=>C?Br()<=pt.current:!1,[C,Br]),Dt=D.useCallback(B=>{cn(B),st.current=Br()},[cn,Br]),mn=D.useCallback(()=>{C&&we.current?.removeAttribute("readonly")},[C]),$n=D.useCallback(B=>B instanceof HTMLElement&&(B.closest('[data-terminal-copy-popover="true"]')!==null||B.closest('[data-mobile-copy-button="true"]')!==null||B.closest("[data-selection-handle]")!==null),[]),Gs=D.useCallback(B=>{if(mn(),Dt(Mf),!C||B.pointerType!=="touch"){jt.current=null;return}const Y=B.target;if($n(Y)){mr();return}Tn&&!(Y instanceof HTMLElement&&Y.closest('[data-terminal-copy-popover="true"]'))&&Ht(),jt.current={pointerId:B.pointerId,startX:B.clientX,startY:B.clientY,moved:!1}},[Ht,C,Dt,$n,Tn,mn,mr]),Tr=D.useCallback(B=>{Dt(Mf);const Y=jt.current;!Y||Y.pointerId!==B.pointerId||Math.hypot(B.clientX-Y.startX,B.clientY-Y.startY)>12&&(Y.moved=!0)},[Dt]),Ur=D.useCallback(B=>{Dt(Df);const Y=jt.current;jt.current=null,!(!C||B.pointerType!=="touch")&&(!Y||Y.pointerId!==B.pointerId||Y.moved||vs()||sn(B.clientX,B.clientY))},[C,Dt,sn,vs]),_s=D.useCallback(()=>{jt.current=null,Dt(Df)},[Dt]),Uo=D.useMemo(()=>({enableKinetic:!0}),[]),Nr=D.useRef(()=>!1),Ls=D.useRef(sn);Ls.current=sn;const Ji=D.useCallback((B,Y)=>{vs()||Ls.current(B,Y)},[vs]),Pi=D.useRef(c);Pi.current=c;const Za=D.useRef(f);Za.current=f;const hi=D.useRef(p);hi.current=p;const Os=D.useCallback(()=>{if(Ir.current)return;Ir.current=!0,mr();const B=T.current,Y=B?.hasSelection()?B.getSelection():"";try{B?.clearSelection()}catch{}fi.flushSync(()=>{yt()}),(async()=>{const q=await A3(Y);Za.current?.(q)})()},[yt,mr]),js=D.useCallback(B=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:B}}))},[]),{setupTouchScroll:eo,stopAllScroll:Qs}=wF(F,{...Uo,shouldCaptureTouch:Nr.current,canStartScrollGesture:Jr,onScroll:sr,onScrollWithCoords:sr,onClickWithCoords:pr,onTap:Ji,onClaimChange:js,tapThreshold:12,gestureName:`normal-scroll:${e}`});D.useEffect(()=>{if(!C)return;we.current?.setAttribute("readonly","");const B=eo();return()=>{B()}},[C,eo]),D.useEffect(()=>{if(!C)return;let B=oe();const Y=()=>{const q=oe();if(B&&!q){const ce=we.current;ce&&typeof document<"u"&&document.activeElement===ce&&(ce.setAttribute("readonly",""),ce.blur())}B=q};return window.visualViewport?.addEventListener("resize",Y),window.visualViewport?.addEventListener("scroll",Y),document.addEventListener("termdock:viewport-keyboard-change",Y),()=>{window.visualViewport?.removeEventListener("resize",Y),window.visualViewport?.removeEventListener("scroll",Y),document.removeEventListener("termdock:viewport-keyboard-change",Y)}},[C,oe]),D.useEffect(()=>{if(!C)return;const B=F.current;if(!B)return;const Y=ce=>{const nt=ce.sourceCapabilities?.firesTouchEvents===!0,xt=Br()-st.current<=1200;return!nt&&!xt?!1:B.contains(ce.target)},q=ce=>{Y(ce)&&(ce.cancelable&&ce.preventDefault(),ce.stopImmediatePropagation(),ce.stopPropagation())};return B.addEventListener("mousedown",q,{capture:!0,passive:!1}),B.addEventListener("mouseup",q,{capture:!0,passive:!1}),B.addEventListener("click",q,{capture:!0,passive:!1}),document.addEventListener("mouseup",q,{capture:!0,passive:!1}),()=>{B.removeEventListener("mousedown",q,!0),B.removeEventListener("mouseup",q,!0),B.removeEventListener("click",q,!0),document.removeEventListener("mouseup",q,!0)}},[C,Br]);const Vr=D.useRef({pointerId:null,lastX:null,lastY:null,startX:null,startY:null,gestureAxis:null,remainder:0,didScroll:!1,rafId:null,velocity:0,instantSpeed:0}),gr=D.useCallback(()=>{const B=Vr.current;B.rafId!==null&&(cancelAnimationFrame(B.rafId),B.rafId=null)},[]),pi=D.useCallback((B,Y,q)=>{const ce=T.current;if(!ce||!ce.element||!ce.cols||!ce.rows)return null;const ot=Vr.current,nt=ce.element.getBoundingClientRect(),xt=Y??ot.lastX??nt.left+nt.width/2,zt=q??ot.lastY??nt.top+nt.height/2,St=xt-nt.left,Yt=zt-nt.top,xr=ce.element.offsetWidth/ce.cols||8,jr=ce.element.offsetHeight/ce.rows||16,is=Math.max(1,Math.min(ce.cols,Math.floor(St/xr)+1)),fs=Math.max(1,Math.min(ce.rows,Math.floor(Yt/jr)+1));return`\x1B[<${B==="up"?64:65};${is};${fs}M`},[]),Es=D.useCallback((B,Y,q,ce)=>{if(Y<=0)return;const ot=pi(B,q,ce);ot&&$.current(Y===1?ot:ot.repeat(Y))},[pi]),mi=D.useRef(Es);mi.current=Es;const Cr=D.useRef(()=>{}),to=D.useCallback(()=>{const Y=Ou(T.current,vt,on)/Math.max(.1,a),q=1+Vr.current.instantSpeed*.1;return Y/Math.min(6,q)},[vt,on,a]),Mr=D.useCallback(()=>{const B=Vr.current;B.rafId=null;const Y=to();let q=0,ce=0;for(;q+ce<Vp&&B.remainder>=Y;)B.remainder-=Y,ce++;for(;q+ce<Vp&&B.remainder<=-Y;)B.remainder+=Y,q++;if(ce>0&&Es("down",ce),q>0&&Es("up",q),q+ce>0)B.rafId=requestAnimationFrame(Mr);else if(B.pointerId!==null&&Math.abs(B.remainder)>=Y/3){const nt=B.remainder>0?"down":"up";B.remainder=0,Es(nt,1),B.rafId=requestAnimationFrame(Mr)}},[to,Es]),Ws=D.useCallback(()=>{const B=Vr.current;B.rafId===null&&typeof requestAnimationFrame<"u"&&(B.rafId=requestAnimationFrame(Mr))},[Mr]),Gr=D.useCallback(B=>{if(B.pointerType!=="touch")return!1;gr();const Y=Vr.current;return Y.pointerId=B.pointerId,Y.lastX=B.clientX,Y.lastY=B.clientY,Y.startX=B.clientX,Y.startY=B.clientY,Y.gestureAxis=null,Y.remainder=0,Y.velocity=0,Y.instantSpeed=0,Y.didScroll=!1,!1},[gr]),no=D.useCallback((B,Y)=>{if(Pt.current)return Y?"release":"neutral";if(performance.now()<=Nt.current)return"neutral";const q=Vr.current;if(B.pointerType!=="touch"||B.pointerId!==q.pointerId||q.lastY==null)return"neutral";if(q.gestureAxis===null&&q.startX!==null&&q.startY!==null){const nt=Math.abs(B.clientX-q.startX),xt=Math.abs(B.clientY-q.startY);if(nt>x3||xt>x3){if(nt>xt*qF)return q.gestureAxis="x","release";xt>nt*KF&&(q.gestureAxis="y")}}if(q.gestureAxis==="x")return q.lastX=B.clientX,q.lastY=B.clientY,"release";if(q.gestureAxis===null)return q.lastX=B.clientX,q.lastY=B.clientY,"neutral";const ce=B.clientY-q.lastY;q.lastX=B.clientX,q.lastY=B.clientY;const ot=-ce;if(q.remainder+=ot,q.instantSpeed=Math.abs(ot),q.velocity=q.velocity*.45+ot*.55,Y){const xt=Ou(T.current,vt,on)/Math.max(.1,a);Math.abs(q.remainder)>=xt/3&&(q.didScroll=!0,Ws())}return"claim"},[vt,on,a,Ws]),ro=D.useCallback(B=>{const Y=Vr.current;if(B.pointerType!=="touch"||B.pointerId!==Y.pointerId)return;if(gr(),Y.pointerId=null,Y.lastX=null,Y.lastY=null,Y.startX=null,Y.startY=null,Y.instantSpeed=0,Y.gestureAxis==="x"){Y.gestureAxis=null;return}Y.gestureAxis=null;const ce=Ou(T.current,vt,on)/Math.max(.1,a);if(Y.didScroll&&Math.abs(Y.velocity)>ce*XF){const ot=()=>{Y.velocity*=YF,Y.remainder+=Y.velocity;const nt=1+Math.abs(Y.velocity)*.1,xt=ce/Math.min(6,nt);if(Math.abs(Y.velocity)<ce*ZF){if(Math.abs(Y.remainder)>=xt/3){const Yt=Y.remainder>0?"down":"up";Es(Yt,1),Y.remainder=0}Y.velocity=0,Y.rafId=null;return}let zt=0,St=0;for(;zt+St<Vp&&Y.remainder>=xt;)Y.remainder-=xt,St++;for(;zt+St<Vp&&Y.remainder<=-xt;)Y.remainder+=xt,zt++;St>0&&Es("down",St),zt>0&&Es("up",zt),Y.rafId=requestAnimationFrame(ot)};Y.rafId=requestAnimationFrame(ot)}else Math.abs(Y.remainder)>=ce/3&&Ws();Y.didScroll&&B.stopImmediatePropagation()},[gr,Es,Ws,a,vt,on]),Is=D.useCallback(B=>{const Y=Vr.current;B.pointerType!=="touch"||B.pointerId!==Y.pointerId||(gr(),Y.pointerId=null,Y.lastX=null,Y.lastY=null,Y.startX=null,Y.startY=null,Y.gestureAxis=null,Y.remainder=0,Y.velocity=0,Y.didScroll=!1)},[gr]);a3({name:`tmux-scroll:${e}`,priority:yF,container:()=>F.current,onPointerDown:C&&i?Gr:void 0,onPointerMove:C&&i?no:void 0,onPointerUp:C&&i?ro:void 0,onPointerCancel:C&&i?Is:void 0});const $s=D.useRef({pointerId:null,originX:0,originY:0,holdTimer:null,mode:"idle",longPressMode:"arrows",copyStart:null,copyDidSelect:!1,edgeScrollTimer:null,edgeScrollDir:0,edgeScrollLines:0,edgeClientX:0,edgeClientY:0,gestureLocked:!1,joystickDir:"",joystickRepeatTimer:null,repeatIntervalMs:260,lastHapticTime:0,lastTapTime:0,lastTapX:0,lastTapY:0,tapStartX:0,tapStartY:0,tapDidMove:!1}),ka=D.useRef(null);ka.current=F.current;const _a=ka,La=$,Cl=D.useRef(L);Cl.current=L;const ds=D.useCallback(B=>{const Y=$s.current;Y.gestureLocked!==B&&(Y.gestureLocked=B,js(B))},[js]),Vs=D.useCallback(()=>{const B=$s.current;B.edgeScrollTimer!==null&&(clearInterval(B.edgeScrollTimer),B.edgeScrollTimer=null),B.edgeScrollDir=0},[]),Bi=D.useCallback(B=>{const Y=T.current,q=$s.current;if(Y){if(q.mode==="copy"&&q.copyStart){q.copyDidSelect=Bx(Y,q.copyStart,B)||q.copyDidSelect;return}if(q.mode==="adjust"){const ce=wr.current;if(!ce.active||!ce.anchor)return;ce.focus=YB(Y,B),Bx(Y,ce.anchor,ce.focus),Me()}}},[Me]),ko=D.useCallback((B,Y)=>{const q=T.current,ce=$s.current;if(!q)return;const ot=Ju(q);if(!ot)return;const nt=ot.originTop,xt=ot.originTop+q.rows*ot.cellH,zt=Math.max(28,ot.cellH*1.5),St=Y-nt,Yt=xt-Y;let xr=0,jr=0;if(St<zt?(xr=-1,jr=Math.min(1,(zt-St)/zt)):Yt<zt&&(xr=1,jr=Math.min(1,(zt-Yt)/zt)),ce.edgeClientX=B,ce.edgeClientY=Y,xr===0){Vs();return}ce.edgeScrollDir=xr,ce.edgeScrollLines=1+Math.round(jr*5),ce.edgeScrollTimer===null&&(ce.edgeScrollTimer=setInterval(()=>{const is=T.current,fs=$s.current;if(!is||fs.edgeScrollDir===0)return;if(fs.mode!=="copy"&&fs.mode!=="adjust"){Vs();return}is.scrollLines(fs.edgeScrollDir*fs.edgeScrollLines);const si=jf(is,fs.edgeClientX,fs.edgeClientY-Wp);si&&Bi(si)},60))},[Bi,Vs]),so=D.useCallback(B=>{if(B.pointerType!=="touch")return!1;const Y=_a.current;if(!Y)return!1;const q=B.target;if(!(q instanceof HTMLElement)||!Y.contains(q)||q.closest('[data-mobile-keyboard="true"]'))return!1;const ce=$s.current;ce.longPressMode=Cl.current;const ot=wr.current;if(ot.active&&ce.pointerId===null){const nt=q.closest("[data-selection-handle]");if(nt instanceof HTMLElement){const xt=T.current,zt=nt.dataset.selectionHandle==="start"?"start":"end";if(xt&&ot.anchor&&ot.focus){const St=og(ot.anchor,ot.focus,xt.cols);return ot.anchor=zt==="start"?St.end:St.start,ot.focus=zt==="start"?St.start:St.end,ot.dragging=zt,Ht(),ce.pointerId=B.pointerId,ce.tapStartX=B.clientX,ce.tapStartY=B.clientY,ce.tapDidMove=!1,ce.mode="adjust",Pt.current=!0,mr(1800),we.current?.setAttribute("readonly",""),Qs(),gr(),$l(Fu),ds(!0),!0}}if(!q.closest("[data-terminal-copy-popover]")){yt();try{T.current?.clearSelection()}catch{}}}if(ce.pointerId!==null)return!0;if(Pt.current=!1,Pi.current){const nt=performance.now(),xt=B.clientX,zt=B.clientY;if(ce.lastTapTime!==0&&nt-ce.lastTapTime<=300&&Math.hypot(xt-ce.lastTapX,zt-ce.lastTapY)<=25)return $l(Fu),Nt.current=performance.now()+500,Pi.current?.(),Ft(!0),fr.current&&clearTimeout(fr.current),fr.current=setTimeout(()=>Ft(!1),400),ce.lastTapTime=0,!0}return ce.holdTimer!==null&&(clearTimeout(ce.holdTimer),ce.holdTimer=null),ce.joystickRepeatTimer!==null&&(clearTimeout(ce.joystickRepeatTimer),ce.joystickRepeatTimer=null),ce.joystickDir="",ce.copyStart=null,ce.copyDidSelect=!1,ce.pointerId=B.pointerId,ce.originX=B.clientX,ce.originY=B.clientY,ce.tapStartX=B.clientX,ce.tapStartY=B.clientY,ce.tapDidMove=!1,ce.mode="holding",ce.longPressMode==="copy"&&ds(!0),ce.holdTimer=setTimeout(()=>{if(ce.holdTimer=null,ce.mode==="holding"){if(ce.longPressMode==="copy"){const nt=T.current,xt=nt?jf(nt,ce.tapStartX,ce.tapStartY):null;if(!nt||!xt){ce.mode="idle";return}ce.mode="copy",Pt.current=!0,mr(1800),we.current?.setAttribute("readonly",""),ce.copyStart=xt,ce.copyDidSelect=!1,Qs(),gr(),nt.clearSelection(),$l(Fu),ds(!0);return}ce.mode="arrow",Pt.current=!0,mr(1e3),Qs(),gr(),$l(Fu),ds(!0),requestAnimationFrame(()=>{Fn({visible:!0,activeDir:""})})}},350),!0},[ds,Ht,yt]),Ea=D.useCallback((B,Y)=>{if(B.pointerType!=="touch")return"neutral";const q=$s.current;if(q.mode==="arrow"&&B.pointerId!==q.pointerId||q.mode==="copy"&&B.pointerId!==q.pointerId||q.mode!=="arrow"&&q.mode!=="copy"&&B.pointerId!==q.pointerId)return"neutral";const ce=B.clientX-q.tapStartX,ot=B.clientY-q.tapStartY;if(Math.hypot(ce,ot)>10&&(q.tapDidMove=!0),q.mode==="holding"){if(!Y)return q.holdTimer!==null&&(clearTimeout(q.holdTimer),q.holdTimer=null),ds(!1),Pt.current=!1,q.mode="idle","neutral";const nt=B.clientX-q.originX,xt=B.clientY-q.originY;return q.longPressMode==="copy"&&Math.hypot(nt,xt)>20?(q.holdTimer!==null&&(clearTimeout(q.holdTimer),q.holdTimer=null),ds(!1),Pt.current=!1,q.mode="idle","release"):Math.hypot(nt,xt)>20?(q.holdTimer!==null&&(clearTimeout(q.holdTimer),q.holdTimer=null),ds(!1),q.mode="idle","release"):"claim"}if(q.mode==="adjust"){if(!Y)return"claim";Qs();const nt=T.current,xt=wr.current;if(!nt||!xt.active||!xt.anchor||!xt.focus)return"claim";const zt=jf(nt,B.clientX,B.clientY-Wp);return zt&&(Bi(zt),ko(B.clientX,B.clientY)),"claim"}if(q.mode==="copy"){if(!Y)return"claim";Qs();const nt=T.current;if(!nt||!q.copyStart)return"claim";const xt=jf(nt,B.clientX,B.clientY-Wp);return xt&&(Bi(xt),ko(B.clientX,B.clientY)),"claim"}if(q.mode==="arrow"){if(!Y)return"claim";const nt={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},xt=B.clientX-q.tapStartX,zt=B.clientY-q.tapStartY,St=FF(xt,zt,q.joystickDir);if(St&&St!==q.joystickDir&&(q.originX=B.clientX,q.originY=B.clientY),St){const Yt=B.clientX-q.originX,xr=B.clientY-q.originY,jr=Math.hypot(Yt,xr);if(q.repeatIntervalMs=OF(jr),St!==q.joystickDir){q.joystickRepeatTimer!==null&&clearTimeout(q.joystickRepeatTimer);const is=q.joystickDir==="";q.joystickDir=St,La.current(nt[St]);const fs=performance.now();fs-q.lastHapticTime>120&&($l(Fu),q.lastHapticTime=fs);const si=is?400:300;q.joystickRepeatTimer=setTimeout(function En(){if(q.joystickDir!==St)return;La.current(nt[St]);const Vn=performance.now();Vn-q.lastHapticTime>120&&($l(Fu),q.lastHapticTime=Vn),q.joystickRepeatTimer=setTimeout(En,q.repeatIntervalMs)},si)}Fn({visible:!0,activeDir:St})}else q.joystickRepeatTimer!==null&&(clearTimeout(q.joystickRepeatTimer),q.joystickRepeatTimer=null),q.joystickDir="",Fn({visible:!0,activeDir:""});return"claim"}return"neutral"},[ds,Bi,ko]),io=D.useCallback(B=>{if(B.pointerType!=="touch"||B.pointerId!==$s.current.pointerId)return;const Y=$s.current;if(Y.mode==="copy"){Qs(),gr(),Vs(),ds(!1);const ce=T.current;let ot=null;if(ce&&Y.copyStart&&(ot=jf(ce,B.clientX,B.clientY-Wp),ot&&(Y.copyDidSelect=Bx(ce,Y.copyStart,ot)||Y.copyDidSelect)),ce&&Y.copyDidSelect&&ce.hasSelection()&&Y.copyStart){const nt=wr.current;nt.active=!0,nt.anchor=Y.copyStart,nt.focus=ot??Y.copyStart,nt.dragging=null,Me(),tt({x:B.clientX,y:B.clientY}),mr(1800),$l(Fu)}else Za.current?.(!1);Y.holdTimer!==null&&(clearTimeout(Y.holdTimer),Y.holdTimer=null),Y.copyStart=null,Y.copyDidSelect=!1,Y.pointerId=null,Y.mode="idle",Pt.current=!1;return}if(Y.mode==="adjust"){Qs(),gr(),Vs(),ds(!1),wr.current.dragging=null,Me(),tt({x:B.clientX,y:B.clientY}),mr(1800),Y.pointerId=null,Y.mode="idle",Pt.current=!1;return}if(Y.mode==="arrow"){Qs(),gr(),ds(!1),Fn({visible:!1,activeDir:""}),Y.holdTimer!==null&&(clearTimeout(Y.holdTimer),Y.holdTimer=null),Y.joystickRepeatTimer!==null&&(clearTimeout(Y.joystickRepeatTimer),Y.joystickRepeatTimer=null),Y.joystickDir="",Y.pointerId=null,Y.mode="idle",Pt.current=!1;return}const q=_a.current;if(q&&!Y.tapDidMove){const ce=B.target;ce instanceof HTMLElement&&q.contains(ce)&&!ce.closest('[data-mobile-keyboard="true"]')&&(Y.lastTapTime=performance.now(),Y.lastTapX=B.clientX,Y.lastTapY=B.clientY)}else Y.tapDidMove&&(Y.lastTapTime=0);Y.holdTimer!==null&&(clearTimeout(Y.holdTimer),Y.holdTimer=null),Y.joystickRepeatTimer!==null&&(clearTimeout(Y.joystickRepeatTimer),Y.joystickRepeatTimer=null),Y.joystickDir="",ds(!1),Pt.current=!1,Y.copyStart=null,Y.copyDidSelect=!1,Y.pointerId=null,Y.mode="idle"},[ds,Qs,mr,Vs,Me,tt]),_o=D.useCallback(()=>{const B=$s.current;ds(!1),Vs(),B.mode==="arrow"&&Fn({visible:!1,activeDir:""}),B.mode==="adjust"&&(wr.current.dragging=null,Me(),tt()),B.holdTimer!==null&&(clearTimeout(B.holdTimer),B.holdTimer=null),B.joystickRepeatTimer!==null&&(clearTimeout(B.joystickRepeatTimer),B.joystickRepeatTimer=null),B.joystickDir="",Pt.current=!1,B.copyStart=null,B.copyDidSelect=!1,B.pointerId=null,B.tapDidMove=!1,B.mode="idle"},[ds,Vs,Me,tt]);a3({name:`long-press:${e}`,priority:bF,container:()=>F.current,onPointerDown:C?so:void 0,onPointerMove:C?Ea:void 0,onPointerUp:C?io:void 0,onPointerCancel:C?_o:void 0});const qs=D.useCallback((B={})=>{Te.current="",ie.current=0,U.current&&(U.current=!1,B.notifyFlowResume===!0&&fe.current?.(!1)),G.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(G.current),G.current=null,ae.current=!1,ve.current=null,ht.current=""},[]),Hs=D.useCallback((B="unknown")=>{const Y=Q.current,q=T.current,ce=F.current;if(!Y||!q||!ce||!q.element||!q.cols||!q.rows)return;const ot=ce.getBoundingClientRect();if(ot.width<24||ot.height<24){it("skip fit: container too small",{reason:B,width:Math.round(ot.width),height:Math.round(ot.height)});return}try{const nt={cols:q.cols,rows:q.rows},xt=Y.proposeDimensions();if(!xt||xt.cols<=0||xt.rows<=0)return;const zt=g3(q,nt.rows),St=sF({reason:B,currentCols:nt.cols,currentRows:nt.rows,proposedCols:xt.cols,proposedRows:xt.rows});let Yt=0;St.accept&&(q.resize(xt.cols,xt.rows),Yt=g3(q,xt.rows),ee.current=0),(zt>0||Yt>0)&&(q.refresh(0,Math.max(0,q.rows-1)),it("xterm buffer invariant repaired",{reason:B,before:zt,after:Yt,cols:q.cols,rows:q.rows}));const xr={cols:q.cols,rows:q.rows};it("fit",{reason:B,backend:"xterm",width:Math.round(ot.width),height:Math.round(ot.height),before:nt,proposed:xt,next:xr,hysteresis:St,changed:nt.cols!==xr.cols||nt.rows!==xr.rows})}catch{}},[it]),ni=D.useCallback(B=>{const Y=T.current;if(Y)try{Y.refresh(0,Math.max(0,Y.rows-1)),it("terminal refreshed (sync)",{reason:B,cols:Y.cols,rows:Y.rows,hasWebgl:!!mt.current})}catch(q){it("terminal refresh (sync) failed",{reason:B,error:q})}},[it]),Lo=D.useCallback(B=>{const Y=me.current;if(Y){try{Y.dispose()}catch{}me.current=null}const q=mt.current;if(!q)return!1;try{q.dispose()}catch{}return mt.current=null,it("renderer disposed",{type:"webgl",reason:B}),!0},[it]),De=D.useCallback((B,Y)=>{if(mt.current)return!0;try{const q=new rP({customGlyphs:zn});return me.current=q.onContextLoss(()=>{it("webgl context loss",{reason:"onContextLoss"}),re.current=!0,typeof window<"u"&&window.setTimeout(()=>{Yr("webgl-context-loss",{forceRendererRecreate:!0})},0)}),B.loadAddon(q),mt.current=q,re.current=!1,it("renderer",{type:"webgl",reason:Y,mobile:C,mode:be.current}),ni(`webgl-enabled:${Y}`),Hs(`webgl-enabled:${Y}`),ps.current=!0,!0}catch(q){return it("webgl load failed, fallback to dom renderer",{reason:Y,error:q,mobile:C,mode:be.current}),!1}},[it,zn,C,Hs,ni]),gt=200,Tt=D.useRef(0),Ze=D.useRef(new Map),wt=D.useRef(new Map),kn=D.useRef(jx()),ir=D.useRef(null),Fr=D.useRef(new Map),ps=D.useRef(!1),cr=D.useRef(!1),rs=D.useCallback(B=>{const Y=Ze.current,q=Y.get(B);q!==void 0&&(cancelAnimationFrame(q),Y.delete(B)),wt.current.delete(B)},[]),_t=D.useCallback(()=>{const B=Ze.current;B.forEach(Y=>cancelAnimationFrame(Y)),B.clear(),wt.current.clear()},[]),xs=D.useCallback(()=>{ir.current!==null&&(window.clearTimeout(ir.current),ir.current=null)},[]),Go=D.useRef(()=>{}),Ia=D.useCallback(B=>{xs(),Z.current(B.cols,B.rows,B.seq),ir.current=window.setTimeout(()=>{ir.current=null;const Y=i3(kn.current,B.seq);kn.current=Y.state,Y.request&&cr.current?(it("resize ack timeout; retrying",{seq:B.seq,retrySeq:Y.request.seq,cols:Y.request.cols,rows:Y.request.rows}),Go.current(Y.request)):Y.exhausted&&it("resize ack timeout; leaving size unconfirmed",{seq:B.seq,cols:B.cols,rows:B.rows})},1200)},[xs,it]);Go.current=Ia;const ws=D.useCallback((B,Y)=>{if(!cr.current)return;const q=lF(kn.current,{cols:B,rows:Y});kn.current=q.state,q.request&&Ia(q.request)},[Ia]),oo=1500,Ie=400,Wo=D.useRef(0),kl=D.useRef(0),Ks=D.useCallback((B,Y,q)=>{if(!Number.isFinite(B)||!Number.isFinite(Y)||B<=0||Y<=0)return;const ce=Math.floor(B),ot=Math.floor(Y);kn.current=uF(kn.current,{cols:ce,rows:ot}),Wo.current=Date.now(),it("pty-size broadcast received",{cols:ce,rows:ot,source:q??"unknown"})},[it]),Ci=D.useCallback(B=>{const Y=T.current;if(!Y||!Y.cols||!Y.rows||!cr.current||typeof document<"u"&&document.visibilityState!=="visible")return;const q=Date.now();if(q-Wo.current<oo||q-kl.current<Ie)return;const ce=Y.cols,ot=Y.rows,nt=kn.current.confirmed;nt&&nt.cols===ce&&nt.rows===ot||(kl.current=q,it("ensureSizeMatches push",{reason:B,cols:ce,rows:ot,lastServerSize:nt}),ws(ce,ot))},[it,ws]),zs=D.useCallback((B,Y)=>{const q=T.current,ce=Q.current;if(!q||!ce)return;if(!ps.current){it("refresh skipped: renderer not ready",{reason:B});return}if(Y.dedupeKey!==void 0){if(Fr.current.get(B)===Y.dedupeKey){it("refresh deduped",{reason:B,dedupeKey:Y.dedupeKey});return}Fr.current.set(B,Y.dedupeKey)}it("refresh",{reason:B,options:Y}),Y.forceRendererRecreate===!0||re.current||Jt&&!!mt.current&&dO.has(B)?(re.current=!1,Jt?(Lo(`refresh:${B}`),De(q,`refresh:${B}`)||ni(`refresh:${B}:webgl-fallback`)):ni(`refresh:${B}`)):mt.current&&Jt&&!Y.forceRedraw?it("webgl refresh skipped: renderer alive",{reason:B}):ni(`refresh:${B}`);const nt={cols:q.cols,rows:q.rows};Hs(`refresh:${B}`);const xt={cols:q.cols,rows:q.rows};if(!Y.skipResizePush)if(Y.candidateSize){const St=Y.candidateSize;St.cols<xt.cols||St.rows<xt.rows||ws(St.cols,St.rows)}else iF({before:nt,after:xt,lastServerSize:kn.current.confirmed,reconcileServerSize:Y.reconcileServerSize})&&ws(xt.cols,xt.rows);if(!Y.skipScrollToBottom&&B!=="resize"&&B!=="dpr-change"){const St=requestAnimationFrame(()=>{const jr=T.current;if(jr&&jr.buffer.active.type!=="alternate")try{jr.scrollToBottom()}catch{}}),Yt=Ze.current,xr=Yt.get(B);xr!==void 0&&cancelAnimationFrame(xr),Yt.set(B,St)}},[it,Jt,Lo,De,ni,Hs,ws]),Yr=D.useCallback((B,Y={})=>{if(T.current,B==="session-key-change"&&(kn.current=jx(),xs(),Fr.current.clear(),_t()),!Y.force&&(B==="visibility"||B==="bfcache"||B==="online")){const ce=Date.now();if(ce-Tt.current<gt){it("refresh throttled",{reason:B});return}Tt.current=ce}rs(B);const q=requestAnimationFrame(()=>{Ze.current.delete(B),wt.current.delete(B),zs(B,Y)});Ze.current.set(B,q),wt.current.set(B,Y)},[it,rs,_t,xs,zs]),Eo=D.useCallback(B=>{const Y=Ze.current.get(B);if(Y===void 0)return;const q=wt.current.get(B)??{};cancelAnimationFrame(Y),Ze.current.delete(B),wt.current.delete(B),zs(B,q)},[zs]);Cr.current=()=>Eo("resize"),D.useEffect(()=>()=>{_t(),Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null)},[e,_t]),D.useEffect(()=>{kn.current=jx(),xs(),Fr.current.clear()},[e,xs]);const ri=D.useCallback(()=>{if(ae.current)return;const B=T.current;if(!B){qs();return}if(!Te.current)return;const Y=Te.current,q=Y.length;Te.current="",ae.current=!0,B.write(Y,()=>{ae.current=!1,ie.current-=q,ie.current<0&&(ie.current=0),U.current&&ie.current<hO&&(U.current=!1,fe.current?.(!1)),Te.current&&(typeof window<"u"?G.current=window.requestAnimationFrame(()=>{G.current=null,ri()}):ri())})},[qs]),es=D.useCallback(()=>{G.current===null&&(typeof window<"u"?G.current=window.requestAnimationFrame(()=>{G.current=null,ri()}):ri())},[ri]),ss=D.useCallback(B=>{B&&(Te.current+=B,ie.current+=B.length,!U.current&&ie.current>=fO&&(U.current=!0,fe.current?.(!0)),es())},[es]);return D.useEffect(()=>{let B=!1,Y=null,q=null,ce=null,ot=null,nt=[];const xt=F.current;return xt?(xt.tabIndex=C?-1:0,(async()=>{if(X.current?.(!1),tn("loading"),Wt(null),Xn(!0),await gO(),!B)try{const St=bO(xt,v3(et),vt,$t,on),Yt=new B_({...St?{cols:St.cols,rows:St.rows}:{},allowProposedApi:!0,fontFamily:v3(et),fontSize:vt,fontWeight:w3(rn),fontWeightBold:w3(fn),theme:xO(S),logLevel:"off",cursorBlink:!Jt,cursorStyle:"block",cursorInactiveStyle:"bar",scrollback:i?2e3:5e3,allowTransparency:aF(Re,Ye),convertEol:Zr,drawBoldTextInBrightColors:Qn,rescaleOverlappingGlyphs:Ge,minimumContrastRatio:hn,letterSpacing:$t,lineHeight:on,smoothScrollDuration:ct?125:0,scrollOnEraseInDisplay:!0,tabStopWidth:8,vtExtensions:{kittyKeyboard:!0},windowOptions:{getWinSizePixels:!0,getCellSizePixels:!0,getWinSizeChars:!0}}),xr=new F_,jr=xr.proposeDimensions.bind(xr);xr.proposeDimensions=()=>{const En=Yt.options.scrollback;Yt.options.scrollback=0;const Vn=jr();return Yt.options.scrollback=En,Vn},Yt.loadAddon(xr),Yt.loadAddon(new cP),Yt.registerLinkProvider(VF(Yt,En=>{ge.current?.(En)}));const is=new gP;Yt.loadAddon(is),Yt.unicode.activeVersion=At,Yt.loadAddon(new TP({highlightLimit:1e3})),Yt.loadAddon(new EP),Yt.loadAddon(new KB);try{Yt.loadAddon(new RP(void 0,new z8))}catch(En){it("clipboard addon skipped",{error:En})}Y=Yt,T.current=Yt,Q.current=xr,Ae.current=typeof window<"u"?window.devicePixelRatio:1,he.current=Yt.buffer.active.type,Yt.open(xt),Mt&&Yt.loadAddon(new qB({fontFeatureSettings:pF,fallbackLigatures:mF}));try{const En=Yt._core;En?.coreService&&(En.coreService.isCursorInitialized=!0),Yt.refresh(0,Yt.rows-1)}catch{}if(Jt?(De(Yt,"init"),ps.current=!0):(it("renderer",{type:"dom",reason:"renderer-mode-dom-fallback",mobile:C,mode:Re}),ps.current=!0),Xn(!1),lt(),C){const En=Vn=>{if(Vn.ctrlKey||Vn.metaKey){Vn.preventDefault();const ki=Vn.deltaY>0?-1:1,un=Math.max(8,Math.min(32,vt+ki));un!==vt&&xt.dispatchEvent(new CustomEvent("termfontchange",{detail:un}))}};We.current=En,xt.addEventListener("wheel",En,{passive:!1})}if(!C){let En=0,Vn=null,ki=null,un=null;const _l=()=>{un=null,Cr.current();const Dr=Ou(T.current,vt,on),Ll=Oe.current+En;En=0;const Rs=Math.trunc(Ll/Dr);if(Oe.current=Ll-Rs*Dr,Rs!==0){const ii=Rs>0?"down":"up",Io=T.current,gi=Math.max(3,Math.floor((Io?.rows??24)/2)),Ja=Math.abs(Rs);Ja>gi&&(Oe.current=0),mi.current(ii,Math.min(Ja,gi),Vn??void 0,ki??void 0)}};Yt.attachCustomWheelEventHandler(Dr=>{if(Dr.ctrlKey||Dr.metaKey||Dr.shiftKey)return!0;if(Dr.deltaY===0)return!1;if(!T.current||!Cn.current)return!0;const Rs=Ou(T.current,vt,on);let ii=Dr.deltaY;return Dr.deltaMode===1?ii=Dr.deltaY*Rs:Dr.deltaMode===2&&(ii=Dr.deltaY*(xt.clientHeight||Rs*20)),En+=ii,Vn=Dr.clientX,ki=Dr.clientY,un===null&&(un=requestAnimationFrame(_l)),Dr.preventDefault(),!1})}const fs=uO(xt);if(fs?(fs.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),j.current=fs,Yn()):j.current=null,Yr("mount",{skipResizePush:!0,skipScrollToBottom:!0}),Wn.current&&(C?Yt.focus():we.current?.focus({preventScroll:!0})),C||Ln.current(),nt.push(Yt.onRender(()=>{const En=Yt.buffer.active.type;he.current!==En&&(he.current=En,ni(`buffer-type-change:${En}`)),C||Ln.current()})),!C){try{const En=Yt.textarea;if(En){En.tabIndex=-1,En.setAttribute("aria-hidden","true"),En.setAttribute("readonly",""),En.value="";const Vn=()=>{we.current?.focus({preventScroll:!0})};En.addEventListener("focus",Vn),nt.push({dispose:()=>En.removeEventListener("focus",Vn)})}}catch{}try{nt.push(Yt.onCursorMove(()=>Ln.current())),nt.push(Yt.onResize(()=>Ln.current()))}catch{}}nt.push(Yt.onData(En=>{$.current(En)}));const si=En=>{const Vn=typeof window<"u"?window.devicePixelRatio:1,ki=Math.abs(Vn-Ae.current)>.001;return ki&&(Ae.current=Vn,it("device pixel ratio changed",{value:Vn,source:En})),ki};if(q=new ResizeObserver(En=>{if(ze.current=void 0,ce===null){const un=T.current;ot=un?{cols:un.cols,rows:un.rows}:null}const Vn=En[0];Vn&&it("resize observer",{width:Math.round(Vn.contentRect.width),height:Math.round(Vn.contentRect.height)});const ki=si("resize-observer");Yr(ki?"dpr-change":"resize"),ce!==null&&window.clearTimeout(ce),ce=window.setTimeout(()=>{ce=null;const un=xt.getBoundingClientRect(),_l=window.visualViewport?.width??window.innerWidth,Dr=window.visualViewport?.height??window.innerHeight;if(!(un.width>0&&un.height>0&&un.right>0&&un.bottom>0&&un.left<_l&&un.top<Dr)||document.visibilityState!=="visible"){ot=null;return}const Rs=T.current,ii=Rs?{cols:Rs.cols,rows:Rs.rows}:null;Yr("resize",{force:!0,forceRedraw:rA(ot,ii),reconcileServerSize:!0,skipScrollToBottom:!0}),ot=null},180)}),q.observe(xt),typeof window<"u"){const En=()=>{si("window-resize")&&Yr("dpr-change")};window.addEventListener("resize",En),nt.push({dispose:()=>window.removeEventListener("resize",En)});const Vn=window.visualViewport;if(Vn){const ki=()=>{si("visual-viewport-resize")&&Yr("dpr-change")};Vn.addEventListener("resize",ki),nt.push({dispose:()=>Vn.removeEventListener("resize",ki)})}}typeof window<"u"&&window.setTimeout(()=>{Yr("init-fit",{skipScrollToBottom:!0})},0),tn("ready"),X.current?.(!0)}catch(St){console.error("Failed to initialize terminal:",St),Xn(!1),tn("error"),Wt(St instanceof Error?St.message:"Failed to load terminal")}})(),()=>{X.current?.(!1),B=!0,V.current?.(!1),pe.current?.(),pe.current=null,Qe.current=!1,Ke.current!==null&&(clearTimeout(Ke.current),Ke.current=null),Fe.current=!1,Zt.current=null,ke(),an({active:!1,text:""});for(const St of nt)St.dispose();q?.disconnect(),ce!==null&&(window.clearTimeout(ce),ce=null),We.current&&(xt.removeEventListener("wheel",We.current),We.current=null),Lo("component-unmount"),Y?.dispose(),T.current=null,Q.current=null,j.current=null,he.current=null,qs({notifyFlowResume:!0}),xs()}):void 0},[Hs,et,vt,rn,fn,$t,on,hn,Qn,At,zn,Ge,Mt,Ye,ct,S,qs,ke,C,De,Lo,it,xs]),D.useEffect(()=>{const B=T.current;if(B){if(Jt){if(B.options.cursorBlink=!1,De(B,"renderer-mode-change")&&Ye&&!$e.current)try{B.loadAddon(new lB({storageLimit:64,pixelLimit:1<<24,sixelSupport:!0,iipSupport:!0,kittySupport:!0})),$e.current=!0}catch(q){it("image addon skipped",{error:q})}return}B.options.cursorBlink=!0,Lo("renderer-mode-change")&&(ni("renderer-mode-change:webgl-disabled"),Hs("renderer-mode-change:webgl-disabled"))}},[Jt,Ye,De,Lo,ni,Hs,it]),D.useEffect(()=>{const B=T.current;B&&(B.reset(),qs(),K.current="",de.current=0,we.current&&(we.current.value=""),Yr("session-reset",{skipScrollToBottom:!0}),Wn.current&&(ar.current?B.focus():we.current?.focus({preventScroll:!0})))},[e,Se,Yr,qs]),D.useEffect(()=>{if(!C||typeof document>"u")return;let B=null;const Y=()=>{B=null;const ce=we.current;if(!ce||document.activeElement!==ce||Qe.current)return;const ot=K.current,nt=qp(ce.value);if(nt!==ot||nt.includes("\r")||!oe())return;const xt=Math.min(d3(ce),Array.from(nt).length),zt=xt-de.current;if(zt===0)return;const St=T.current,Yt=zt<0?(St?du(St,"D"):"\x1B[D").repeat(-zt):(St?du(St,"C"):"\x1B[C").repeat(zt);$.current(Yt),de.current=xt},q=()=>{B===null&&(B=requestAnimationFrame(Y))};return document.addEventListener("selectionchange",q),()=>{document.removeEventListener("selectionchange",q),B!==null&&cancelAnimationFrame(B)}},[C,oe]),D.useEffect(()=>{if(!C)return;const B=eo();return pe.current=B,()=>{B(),pe.current=null}},[C,eo]),D.useEffect(()=>{const B=T.current;if(B)try{B.options.scrollback=i?0:1e3}catch{}},[i,Se]),D.useEffect(()=>{const B=T.current;if(!B)return;if(t.length===0){ve.current!==null&&(B.reset(),qs(),Yr("buffer-reset",{skipResizePush:!0,skipScrollToBottom:!0}));return}const Y=ve.current;let q;if(Y===null)q=t;else{const ce=t.findIndex(ot=>ot.id===Y);q=ce>=0?t.slice(ce+1):t}if(q.length>0){const ce=q.map(zt=>zt.data).join(""),ot=ht.current+ce,{cleaned:nt,remainder:xt}=cO(ot);ht.current=xt,nt&&ss(nt)}ve.current=t[t.length-1].id},[t,Se,ss,Yr,qs]),D.useImperativeHandle(M,()=>({focus:()=>{if(ar.current){sn();return}we.current?.focus({preventScroll:!0})},blur:()=>{const B=we.current;Mn(B),B&&typeof document<"u"&&document.activeElement===B&&B.blur(),ar.current&&B?.setAttribute("readonly",""),V.current?.(!1)},clear:()=>{const B=T.current;B&&(B.reset(),qs(),Yr("clear",{skipResizePush:!0,skipScrollToBottom:!0}))},copySelectionOrViewport:async()=>{const B=T.current;if(!B)return!1;const Y=B.hasSelection()?B.getSelection():yO(B),q=await A3(Y);return q&&B.hasSelection()&&Ht(),q},pasteClipboardText:async()=>{mr();const B=await _n(we.current);return hi.current?.(B),B},sendSequence:(B,Y)=>{Gt(B,null,Y)},getDimensions:()=>{const B=T.current;return!B||!B.cols||!B.rows?null:{cols:B.cols,rows:B.rows}},requestRefresh:Yr,setSessionReady:B=>{cr.current=B,B||(xs(),kn.current=dF(kn.current))},acknowledgeResize:B=>{if(!B.ok&&typeof B.seq=="number"){const q=i3(kn.current,B.seq);if(!q.request&&!q.exhausted)return;xs(),kn.current=q.state,q.request&&cr.current&&Go.current(q.request);return}const Y=cF(kn.current,B);Y.accepted&&(xs(),kn.current=Y.state,it("resize acknowledged",{seq:B.seq,ok:B.ok,cols:B.cols,rows:B.rows}))},notifyServerSize:Ks,ensureSizeMatches:Ci}),[C,Mn,sn,qs,_n,Gt,Yr,xs,it,ws,Ks,Ci]),o.jsxs("div",{ref:F,"data-termdock-terminal-dropzone":e,className:`relative h-full w-full terminal-viewport-container ${A||""}`,style:{backgroundColor:S.background,touchAction:br.visible?"none":void 0},role:"button",tabIndex:-1,onPointerDownCapture:Gs,onPointerMoveCapture:Tr,onPointerUpCapture:Ur,onPointerCancelCapture:_s,onTouchStartCapture:B=>{if($n(B.target)){mr(),Dt(Mf);return}mn(),Dt(Mf)},onTouchMoveCapture:()=>Dt(Mf),onTouchEndCapture:()=>Dt(Df),onTouchCancelCapture:()=>Dt(Df),onMouseDown:B=>{C||B.button===0&&(Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null),requestAnimationFrame(()=>{try{we.current?.focus({preventScroll:!0})}catch{}}))},onMouseUp:B=>{C||B.button===0&&(Ce.current!==null&&window.clearTimeout(Ce.current),Ce.current=window.setTimeout(()=>{Ce.current=null;try{we.current?.focus({preventScroll:!0})}catch{}},0))},children:[Tn&&o.jsxs("button",{type:"button","data-terminal-copy-popover":"true",className:"absolute z-30 inline-flex h-9 w-[88px] select-none items-center justify-center gap-1.5 rounded-full border border-white/15 bg-[rgb(28_28_30_/_0.92)] px-3 text-[13px] font-semibold text-white shadow-[0_10px_28px_rgb(0_0_0_/_0.32),0_2px_8px_rgb(0_0_0_/_0.18)] backdrop-blur-xl transition-transform duration-100 ease-out active:scale-[0.96]",style:{left:Tn.left,top:Tn.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:B=>{mr(),B.stopPropagation()},onPointerUp:B=>{B.preventDefault(),B.stopPropagation(),Os()},onTouchStart:B=>{mr(),B.stopPropagation()},onTouchEnd:B=>{B.preventDefault(),B.stopPropagation(),Os()},onClick:B=>{B.preventDefault(),B.stopPropagation(),Os()},children:[o.jsx(Hy,{size:14,strokeWidth:2.4}),o.jsx("span",{children:P("common.copy")})]}),Le?.start&&o.jsx("div",{"data-selection-handle":"start",className:"absolute z-30 h-11 w-11 select-none",style:{left:Le.start.left,top:Le.start.top,transform:"translate(-50%, -100%)",touchAction:"none"},onPointerDown:B=>B.stopPropagation(),children:o.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-1/2 flex -translate-x-1/2 flex-col items-center",children:[o.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-[var(--accent)] shadow-[0_1px_4px_rgb(0_0_0_/_0.4)]"}),o.jsx("div",{className:"h-3 w-0.5 bg-[var(--accent)]"})]})}),Le?.end&&o.jsx("div",{"data-selection-handle":"end",className:"absolute z-30 h-11 w-11 select-none",style:{left:Le.end.left,top:Le.end.top,transform:"translate(-50%, 0)",touchAction:"none"},onPointerDown:B=>B.stopPropagation(),children:o.jsxs("div",{className:"pointer-events-none absolute left-1/2 top-0 flex -translate-x-1/2 flex-col items-center",children:[o.jsx("div",{className:"h-3 w-0.5 bg-[var(--accent)]"}),o.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-[var(--accent)] shadow-[0_1px_4px_rgb(0_0_0_/_0.4)]"})]})}),Bn&&Ve&&o.jsx(_F,{}),Bn&&ut==="loading"&&!Ve&&o.jsx(kF,{}),ut==="error"&&o.jsx(LF,{message:ft||void 0,onRetry:()=>{window.location.reload()}}),ut==="ready"&&o.jsxs(o.Fragment,{children:[o.jsx("textarea",{ref:we,"aria-label":P("terminal.input"),"data-terminal-input-anchor":"true",inputMode:"text",enterKeyHint:"enter",autoCapitalize:"off",autoComplete:"nope",autoCorrect:"off",spellCheck:!1,tabIndex:-1,style:{position:"absolute",opacity:0,zIndex:20,background:"transparent",color:"transparent",caretColor:"transparent",resize:"none",overflow:"hidden",border:"none",padding:0,margin:0,outline:"none",...C?{inset:0,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",pointerEvents:"auto",fontSize:"16px"}:(()=>{const B=Rt.x,Y=Rt.y,q={position:"fixed",left:B,top:Y,pointerEvents:"none",touchAction:"auto",fontSize:`${vt}px`,fontFamily:et,lineHeight:"1",whiteSpace:"pre",boxSizing:"content-box",width:Math.max(1,Math.round(Rt.cellW)),height:Math.max(1,Math.round(Rt.cellH))};if(!Qt.active)return q;const ce=yr(Qt.text);return{...q,opacity:1,color:"transparent",WebkitTextFillColor:"transparent",background:"transparent",transition:"none",caretColor:"transparent",textDecorationColor:"transparent",wordBreak:"break-all",zIndex:20,width:ce.width,height:ce.height,whiteSpace:ce.whiteSpace}})()},onContextMenu:B=>{B.preventDefault()},onFocus:()=>{it("input anchor focus"),ze.current=void 0,Ln.current(),Yr("focus",{skipResizePush:!0,skipScrollToBottom:!0}),V.current?.(!0)},onBlur:B=>{C||Mn(B.currentTarget);const Y=Gn(),q=typeof document<"u"?document.activeElement:null;if(it("input anchor blur",{guarded:Y,activeTag:q?.tagName??null,activeClass:q?.className??null}),!Y){C&&we.current?.setAttribute("readonly",""),V.current?.(!1);return}if(typeof window>"u"){V.current?.(!1);return}window.setTimeout(()=>{le()||oe()||(C&&we.current?.setAttribute("readonly",""),V.current?.(!1))},Df)},onBeforeInput:B=>{if(Qe.current)return;const Y=B.nativeEvent;if(Y instanceof InputEvent){if(Y.inputType==="insertLineBreak"){if(Fe.current){Fe.current=!1,Ke.current!==null&&(clearTimeout(Ke.current),Ke.current=null),B.preventDefault();return}B.preventDefault(),yn(B.currentTarget);return}if(Y.inputType==="deleteContentBackward"||Y.inputType==="deleteContentForward"||Y.inputType==="deleteByCut"){if(!B.currentTarget.value){B.preventDefault(),$.current("");return}if(Y.inputType==="deleteContentBackward"&&B.currentTarget.selectionStart===0&&B.currentTarget.selectionEnd===0){B.preventDefault(),$.current("");return}return}}},onInput:B=>{Qe.current||It(B.currentTarget)},onPaste:B=>{const Y=B.clipboardData.getData("text/plain");if(!Y){Di()?.pasteClipboardImage&&(B.preventDefault(),_n(B.currentTarget));return}B.preventDefault();const q=ln(Y,B.currentTarget);C&&hi.current?.(q)},onKeyDown:B=>{const Y=aO(B);if(!C){const q=T.current,ce=B.metaKey,ot=B.ctrlKey,nt=B.altKey,xt=B.shiftKey,zt=B.key;if(ce&&!ot&&!nt&&!xt&&zt==="Enter"){B.preventDefault(),yn(B.currentTarget);return}if((ce||ot)&&!nt&&!xt&&(zt==="v"||zt==="V")){B.preventDefault(),_n(B.currentTarget);return}if(ce&&!ot&&!nt&&!xt&&(zt==="c"||zt==="C")){B.preventDefault();const St=q?.hasSelection()?q.getSelection():"";St&&navigator.clipboard?.writeText(St).catch(()=>{});return}if((ce||ot)&&!nt&&!xt&&(zt==="k"||zt==="K")){B.preventDefault(),q&&(q.reset(),qs(),Yr("clear",{skipResizePush:!0,skipScrollToBottom:!0})),B.currentTarget.value="",K.current="",de.current=0;return}if(ce&&!ot&&!nt&&!xt&&zt==="Backspace"){B.preventDefault(),Gt("",B.currentTarget);return}if(ce&&!ot&&!nt&&!xt&&zt==="Delete"){B.preventDefault(),Gt("\v",B.currentTarget);return}if(ce&&!ot&&!nt&&!xt&&zt==="ArrowLeft"){B.preventDefault(),Gt("",B.currentTarget);return}if(ce&&!ot&&!nt&&!xt&&zt==="ArrowRight"){B.preventDefault(),Gt("",B.currentTarget);return}if(ce)return;if(ot&&!nt&&!xt&&zt===" "){B.preventDefault(),Gt("\0",B.currentTarget);return}if(ot&&!nt&&!ce&&zt.length===1){const St=zt.toLowerCase().charCodeAt(0);if(St>=64&&St<=127){B.preventDefault(),Gt(String.fromCharCode(St&31),B.currentTarget);return}}if(nt&&!ot&&!ce&&!xt&&zt==="Backspace"){B.preventDefault(),Gt("\x1B",B.currentTarget);return}if(nt&&!ot&&!ce&&!xt&&zt==="Delete"){B.preventDefault(),Gt("\x1Bd",B.currentTarget);return}if(nt&&!ot&&!ce&&!xt&&zt==="ArrowLeft"){B.preventDefault(),Gt("\x1Bb",B.currentTarget);return}if(nt&&!ot&&!ce&&!xt&&zt==="ArrowRight"){B.preventDefault(),Gt("\x1Bf",B.currentTarget);return}if(nt&&!ot&&!ce&&zt.length===1){B.preventDefault(),Gt(`\x1B${zt}`,B.currentTarget);return}if(Y||Qe.current)return;if(q){const St=oO(B,q);if(St!==null){B.preventDefault(),Gt(St,B.currentTarget);return}}}if(B.key==="Enter"||B.key==="Go"||B.key==="done"||B.key==="send"){if(Y||Qe.current){B.preventDefault();return}if(Fe.current){Fe.current=!1,Ke.current!==null&&(clearTimeout(Ke.current),Ke.current=null),B.preventDefault();return}B.preventDefault(),yn(B.currentTarget);return}if(B.key==="Backspace"){if(Qe.current)return;if(!B.currentTarget.value){B.preventDefault(),$.current("");return}if(B.currentTarget.selectionStart===0&&B.currentTarget.selectionEnd===0){B.preventDefault(),$.current("");return}}},onCompositionStart:()=>{Qe.current=!0,Ar(),an({active:!0,text:""})},onCompositionUpdate:B=>{Qe.current=!0;const Y=B.data??B.currentTarget.value;an(q=>q.active&&q.text===Y?q:{active:!0,text:Y})},onCompositionEnd:B=>{Qe.current=!1,Fe.current=!0,Ke.current!==null&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{Fe.current=!1,Ke.current=null},50),an({active:!1,text:""}),It(B.currentTarget),Rr()}}),Qt.active&&(()=>{const B=yr(Qt.text);return o.jsx("div",{"aria-hidden":"true","data-terminal-ime-composition":"true",style:{position:"fixed",left:Rt.x,top:Rt.y,zIndex:21,pointerEvents:"none",overflow:"hidden",boxSizing:"content-box",width:B.width,height:B.height,margin:0,padding:0,color:S.foreground,background:S.background,boxShadow:`-1px 0 0 1px ${S.background}`,fontSize:`${vt}px`,fontFamily:et,lineHeight:"1",textDecorationLine:"underline",textDecorationStyle:"solid",textDecorationColor:S.foreground,wordBreak:"break-all",whiteSpace:B.whiteSpace,transition:"none"},children:Qt.text})})(),o.jsx("div",{"aria-hidden":!0,className:`absolute left-1/2 -translate-x-1/2 top-6 z-30 pointer-events-none
69
69
  rounded-full bg-[var(--surface-elevated)] px-4 py-1.5 text-sm font-semibold text-foreground
70
70
  shadow-lg transition-all duration-150 ease-out`,style:{opacity:Nn?1:0,transform:Nn?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),o.jsx("div",{ref:nn,"aria-hidden":!0,className:"absolute left-1/2 top-6 z-30 pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:br.visible?1:0,transform:br.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:br.visible&&(()=>{const{activeDir:B}=br,Y=q=>B===q;return o.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-xl bg-[var(--overlay-background)] backdrop-blur-sm shadow-lg px-1.5 py-1.5",children:[o.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${Y("up")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M12 19V5M7 11l5-5 5 5"})})}),o.jsxs("div",{className:"flex items-center gap-0.5",children:[o.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${Y("left")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),o.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg text-[rgb(var(--overlay-foreground-rgb)_/_0.18)]",children:o.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("circle",{cx:"12",cy:"12",r:"4"})})}),o.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${Y("right")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})})]}),o.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${Y("down")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})})]})})()})]})]})});oA.displayName="TerminalViewport";const wO=oA,SO={background:"#1C1B1A",foreground:"#CECDC3",cursor:"#CECDC3",cursorAccent:"#1C1B1A",selectionBackground:"#403E3C",selectionForeground:"#CECDC3",selectionInactiveBackground:"#403E3C50",black:"#6F6E69",red:"#AF3029",green:"#66800B",yellow:"#AD8301",blue:"#205EA6",magenta:"#A02F6F",cyan:"#24837B",white:"#CECDC3",brightBlack:"#6F6E69",brightRed:"#D14D41",brightGreen:"#879A39",brightYellow:"#D0A215",brightBlue:"#4385BE",brightMagenta:"#CE5D97",brightCyan:"#3AA99F",brightWhite:"#FFFCF0"},AO={background:"#FFFCF0",foreground:"#100F0F",cursor:"#100F0F",cursorAccent:"#FFFCF0",selectionBackground:"#CECDC3",selectionForeground:"#100F0F",selectionInactiveBackground:"#CECDC350",black:"#100F0F",red:"#AF3029",green:"#66800B",yellow:"#AD8301",blue:"#205EA6",magenta:"#A02F6F",cyan:"#24837B",white:"#575653",brightBlack:"#6F6E69",brightRed:"#D14D41",brightGreen:"#879A39",brightYellow:"#D0A215",brightBlue:"#4385BE",brightMagenta:"#CE5D97",brightCyan:"#3AA99F",brightWhite:"#100F0F"};function TO(e){return e==="light"?AO:SO}const ev=new Set(["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"]);function bc(e){if(!e)return null;if(e==="/")return"/";const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function jc(e,t,n,r=ev,s=null,i=null){if(e.customName)return{primary:e.name,secondary:bc(n)};if(s){const c=bc(n),u=s===n||s===c;if(i!=="idle"&&!r.has(s)&&!u)return{primary:s,secondary:c}}if(t&&!r.has(t))return{primary:t,secondary:bc(n)};const a=bc(n);return a?{primary:a,secondary:null}:{primary:e.name,secondary:null}}function CO(e,t,n,r=ev,s=null,i=null){return jc(e,t,n,r,s,i).primary}function tv(e,t,n){const r=[],s=new Map;for(const i of e){const a=t(i),c=a&&a.trim().length>0?a:"";let u=s.get(c);u||(u={key:c,label:c?bc(c)??c:n,sessions:[]},s.set(c,u),r.push(u)),u.sessions.push(i)}return r.sort((i,a)=>(i.key===""?1:0)-(a.key===""?1:0))}function C3(e){return e&&e.trim().length>0?e:""}function aA(e,t,n){const r=[...e],[s]=r.splice(t,1);return s?(r.splice(n,0,s),r.flatMap(i=>i.sessions.map(a=>a.id))):e.flatMap(i=>i.sessions.map(a=>a.id))}function kO(e,t,n,r){return e.flatMap(s=>{if(s.key!==t)return s.sessions.map(c=>c.id);const i=s.sessions.map(c=>c.id),[a]=i.splice(n,1);return a===void 0?s.sessions.map(c=>c.id):(i.splice(r,0,a),i)})}function lA(e,t,n,r){if(!n)return{arranged:e,groups:[]};const s=tv(e,t,r);return{arranged:s.flatMap(a=>a.sessions),groups:s}}function _O(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function LO(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function EO(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function IO(e,t){return!e&&t}const RO=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},NO=()=>({async createSession(e){return sI(e)},connect(e,t,n){const r=iI(e,t.onEvent,t.onError,RO(n));return{close:()=>r()}},async sendInput(e,t){await HS(e,t)},async resize(e){await lI(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await zS(e)},async restartSession(e,t){return uI(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await fI(e)},async tmuxAction(e,t){return cI(e,t)},async listTmuxSessions(){return Yb()},async getTmuxStatus(){return Xb()},async checkHealth(e){return dI(e)}}),MO="\x1B",DO=/\x1b\[[IO]/g,jO=/\x1b\[<[0-9]+;[0-9]+;[0-9]+[mM]/y,PO=/\x1b\[[0-9]+;[0-9]+;[0-9]+M/y;function k3(e,t,n){return e.lastIndex=n,e.exec(t)?e.lastIndex:-1}function BO(e){const t=e.replace(DO,"");if(t.length===0)return e.length>0;let n=0;for(;n<t.length;){let r=k3(jO,t,n);if(r<0&&(r=k3(PO,t,n)),r<0&&t.startsWith("\x1B[M",n)&&t.length>=n+6&&(r=n+6),r<0)return!1;n=r}return!0}function FO(e){return e===MO}function OO(e,t,n){const r=e?.name||"Error",s=e?.message||"Unexpected error";return["Termdock error report",`Time: ${n.capturedAt}`,`URL: ${n.url}`,`User agent: ${n.userAgent}`,"",`${r}: ${s}`,e?.stack?`
@@ -179,12 +179,12 @@ ${G.desc}`:""}`,"aria-pressed":C===G.key,onPointerEnter:()=>A(G.key),onPointerLe
179
179
 
180
180
  `;return`${e}${r}${n}`}function Eee(e,t){const n=e.trim();return n?t?`${n}\r`:/\s$/.test(e)?e:`${n} `:""}const gy="termdock:right-sidebar:html-view-mode-by-file:v1";function Iee(e){return e==="preview"||e==="source"}function TC(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(Iee)}function CC(e,t){if(!t)return null;const n=e&&!t.startsWith("/")?`${e}/${t}`:t;return e?`${e}::${n}`:n}function A7(e,t){const n=CC(e,t);return n?zr(gy,TC)?.[n]??"source":"source"}function Ree(e,t,n){const r=CC(e,t);if(!r)return;const s=zr(gy,TC)??{};Un(gy,{...s,[r]:n})}function kb(e){const t=Number.isFinite(e)&&e>0?Math.floor(e):0,n=Math.floor(t/3600),r=Math.floor(t%3600/60),s=t%60,i=String(r).padStart(2,"0"),a=String(s).padStart(2,"0");return n>0?`${n}:${i}:${a}`:`${i}:${a}`}function Nee(e,t,n){return!Number.isFinite(n)||n<=0||!t.width?0:Math.min(1,Math.max(0,(e-t.left)/t.width))*n}const Mee=350,Dee=12,jee=90;function Pee({url:e,onLoadError:t}){const{t:n}=er(),r=x.useRef(null),s=x.useRef(null),i=x.useRef(null),a=x.useRef(null),c=x.useRef(!1),u=x.useRef(null),f=x.useRef(null),p=x.useRef(0),g=x.useRef(!1),y=x.useRef(!1),v=x.useRef(!1),S=x.useRef(null),A=x.useRef(null),C=x.useRef(!1),L=x.useRef(1),E=x.useRef(!1),[M,P]=x.useState(0),[F,j]=x.useState(0),[T,Q]=x.useState(!1),[$,Z]=x.useState(!1),[V,fe]=x.useState(null),[X,ge]=x.useState(!1),[be,Te]=x.useState(0),[ie,U]=x.useState(!1),[G,ae]=x.useState({width:0,height:0}),ve=x.useCallback(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null)},[]),pe=x.useCallback(()=>{if(ve(),A.current=null,!C.current)return!1;const Pe=i.current;return Pe&&(Pe.playbackRate=L.current),C.current=!1,ge(!1),!0},[ve]);x.useEffect(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),f.current!==null&&clearTimeout(f.current),ve();const Pe=i.current;Pe&&C.current&&(Pe.playbackRate=L.current)},[ve]),x.useEffect(()=>{const Pe=s.current;if(!Pe||typeof ResizeObserver>"u")return;const We=new ResizeObserver(([Oe])=>{Oe&&ae({width:Oe.contentRect.width,height:Oe.contentRect.height})});return We.observe(Pe),()=>We.disconnect()},[]),x.useEffect(()=>{const Pe=()=>U(document.fullscreenElement===r.current);return document.addEventListener("fullscreenchange",Pe),()=>document.removeEventListener("fullscreenchange",Pe)},[]);const we=x.useCallback((Pe,We=!1)=>{const Oe=i.current;if(!Oe)return!1;const pt=Number.isFinite(Oe.duration)?Oe.duration:Pe,st=Math.min(Math.max(Pe,0),pt);if(j(st),Math.abs(Oe.currentTime-st)<1/120)return!1;const jt=Oe.fastSeek;return We&&typeof jt=="function"?jt.call(Oe,st):Oe.currentTime=st,!0},[]),ze=x.useCallback(()=>{u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null;const Pe=i.current;if(!Pe||!g.current||y.current||Pe.seeking)return;const We=v.current;v.current=!1,y.current=we(p.current,!We)}))},[we]),Ce=x.useCallback(Pe=>{const We=a.current,Oe=i.current;if(!We||!Oe)return;const pt=We.getBoundingClientRect(),st=Nee(Pe,pt,Oe.duration);p.current=st,fe(st),v.current=!1,ze(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,v.current=!0,ze()},jee)},[ze]),$e=x.useCallback(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),v.current=!1,y.current=!1,we(p.current)},[we]),ee=x.useCallback(Pe=>{const We=i.current;if(!(!We||!Number.isFinite(We.duration)||We.duration<=0)){c.current=!We.paused,We.pause(),g.current=!0,Z(!0);try{Pe.currentTarget.setPointerCapture(Pe.pointerId)}catch{}Ce(Pe.clientX)}},[Ce]),ht=x.useCallback(()=>{g.current=!1,$e(),Z(!1),fe(null);const Pe=i.current;Pe&&c.current&&!Pe.ended&&Pe.play().catch(()=>{}),c.current=!1},[$e]),mt=x.useCallback(()=>{const Pe=i.current;if(Pe){if(E.current){E.current=!1;return}Pe.paused?Pe.play().catch(()=>{}):Pe.pause()}},[]),me=x.useCallback(Pe=>{const We=i.current;!We||We.paused||Pe.button!==0||(ve(),A.current={id:Pe.pointerId,x:Pe.clientX,y:Pe.clientY},S.current=setTimeout(()=>{S.current=null,L.current=We.playbackRate,We.playbackRate=2,C.current=!0,ge(!0)},Mee))},[ve]),re=x.useCallback(Pe=>{const We=A.current;!We||We.id!==Pe.pointerId||C.current||Math.hypot(Pe.clientX-We.x,Pe.clientY-We.y)>Dee&&(ve(),A.current=null)},[ve]),Ae=x.useCallback(()=>{pe()&&(E.current=!0)},[pe]);x.useEffect(()=>(window.addEventListener("pointerup",Ae),window.addEventListener("pointercancel",Ae),window.addEventListener("blur",Ae),()=>{window.removeEventListener("pointerup",Ae),window.removeEventListener("pointercancel",Ae),window.removeEventListener("blur",Ae)}),[Ae]);const he=x.useCallback(async()=>{const Pe=r.current,We=i.current;if(!(!Pe||!We))try{document.fullscreenElement===Pe?await document.exitFullscreen():Pe.requestFullscreen?await Pe.requestFullscreen():We.webkitEnterFullscreen?.()}catch{We.webkitEnterFullscreen?.()}},[]),Qe=x.useCallback(()=>Te(Pe=>(Pe+90)%360),[]),Fe=x.useCallback(Pe=>{const We=i.current;if(!We||!Number.isFinite(We.duration))return;const Oe=Pe.shiftKey?10:5;let pt=null;Pe.key==="ArrowLeft"?pt=We.currentTime-Oe:Pe.key==="ArrowRight"?pt=We.currentTime+Oe:Pe.key==="Home"?pt=0:Pe.key==="End"&&(pt=We.duration),pt!==null&&(Pe.preventDefault(),we(pt))},[we]),Ke=$&&V!==null?V:F,K=M>0?Math.min(1,Math.max(0,Ke/M)):0,qe=(be===90||be===270)&&G.width>0&&G.height>0?{width:`${G.height}px`,height:`${G.width}px`}:{width:"100%",height:"100%"};return o.jsxs("div",{ref:r,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":be,children:[o.jsxs("div",{ref:s,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[o.jsx("video",{ref:i,"data-testid":"file-preview-video",className:"absolute left-1/2 top-1/2 max-w-none object-contain transition-transform duration-200",style:{...qe,transform:`translate(-50%, -50%) rotate(${be}deg)`},src:e,preload:"auto",playsInline:!0,onClick:mt,onPointerDown:me,onPointerMove:re,onPointerUp:Ae,onPointerCancel:Ae,onContextMenu:Pe=>{C.current&&Pe.preventDefault()},onPlay:()=>Q(!0),onPause:()=>Q(!1),onTimeUpdate:Pe=>j(Pe.currentTarget.currentTime),onSeeked:Pe=>{const We=Pe.currentTarget;if(j(We.currentTime),y.current=!1,!g.current)return;const Oe=We.requestVideoFrameCallback;typeof Oe=="function"?Oe.call(We,()=>{g.current&&ze()}):requestAnimationFrame(()=>{g.current&&ze()})},onLoadedMetadata:Pe=>P(Number.isFinite(Pe.currentTarget.duration)?Pe.currentTarget.duration:0),onDurationChange:Pe=>P(Number.isFinite(Pe.currentTarget.duration)?Pe.currentTarget.duration:0),onError:t,children:n("rightSidebar.videoUnsupported")}),X&&o.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:n("rightSidebar.videoLongPressSpeed")}),$&&V!==null&&o.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${K*100}%`},"data-testid":"file-preview-video-scrub-time",children:kb(V)})]}),o.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${xT}`,[bT]:"",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:mt,"aria-label":n(T?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:n(T?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:T?o.jsx(g8,{size:14}):o.jsx(a2,{size:14})}),o.jsxs("div",{ref:a,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(M),"aria-valuenow":Math.floor(Ke),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:ee,onPointerMove:Pe=>{$&&Ce(Pe.clientX)},onPointerUp:ht,onPointerCancel:ht,onKeyDown:Fe,children:[o.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),o.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${K*100}%`}}),o.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${K*100}%`}})]}),o.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[kb(Ke)," / ",kb(M)]}),o.jsx("button",{type:"button",onClick:Qe,"aria-label":n("rightSidebar.videoRotate"),title:n("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:o.jsx(yD,{size:14})}),o.jsx("button",{type:"button",onClick:()=>{he()},"aria-label":n(ie?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:n(ie?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:ie?o.jsx(qM,{size:14}):o.jsx(zM,{size:14})})]})})]})}function Bee(e){const t=Math.max(0,Math.min(100,e.xPercent)),n=Math.max(0,Math.min(100,e.yPercent));return{...t<=50?{left:`calc(${t}% + 8px)`}:{right:`calc(${100-t}% + 8px)`},...n<=50?{top:`calc(${n}% + 8px)`}:{bottom:`calc(${100-n}% + 8px)`}}}function x1({anchor:e,children:t,disabled:n=!1,onClick:r,title:s}){return o.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:n,onClick:i=>{i.stopPropagation(),r()},title:s,style:Bee(e),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[o.jsx(Gl,{size:11}),t]})}function Fee(e,t,n,r){if(n.width<=0||n.height<=0||r.width<=0||r.height<=0)return null;const s=Math.min(n.width/r.width,n.height/r.height);if(!Number.isFinite(s)||s<=0)return null;const i=r.width*s,a=r.height*s,c=n.left+(n.width-i)/2,u=n.top+(n.height-a)/2,f=e-c,p=t-u;if(f<0||p<0||f>i||p>a)return null;const g=f/i*100,y=p/a*100;return{x:r.x+r.width*g/100,y:r.y+r.height*y/100,xPercent:g,yPercent:y}}function Oee(e,t,n){const r=[`SVG标注: ${e}`,`视图: ${t}`,`SVG坐标: (${n.x.toFixed(2)},${n.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${n.xPercent.toFixed(1)}%,${n.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return n.nearestText&&r.push(`最近文字: ${n.nearestText}`),`"${r.join(" / ")}"`}function Qee(e){const t=new DOMParser().parseFromString(e,"image/svg+xml"),n=t.documentElement;if(n.nodeName.toLowerCase()!=="svg"||t.querySelector("parsererror"))throw new Error("Invalid SVG document");return t.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(r=>r.remove()),t.querySelectorAll("*").forEach(r=>{for(const s of Array.from(r.attributes)){const i=s.name.toLowerCase(),a=s.value.trim();(i.startsWith("on")||(i==="href"||i.endsWith(":href"))&&a&&!a.startsWith("#"))&&r.removeAttribute(s.name)}}),n.removeAttribute("width"),n.removeAttribute("height"),n.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(n)}function $ee(e,t,n){let r=null;for(const s of Array.from(e.querySelectorAll("text"))){const i=(s.textContent??"").replace(/\s+/g," ").trim();if(!i)continue;const a=Number(s.getAttribute("x")),c=Number(s.getAttribute("y"));if(!Number.isFinite(a)||!Number.isFinite(c))continue;const u=Math.hypot(a-t,c-n);(!r||u<r.distance)&&(r={text:i,distance:u})}return r?.text.slice(0,120)}function kC({blobUrl:e,filePath:t,viewLabel:n,onInsertAnnotation:r}){const s=x.useRef(null),i=x.useRef(null),[a,c]=x.useState(null),[u,f]=x.useState(null),[p,g]=x.useState(1),[y,v]=x.useState(!1),[S,A]=x.useState(null),C=x.useRef(new Map),L=x.useRef(null),E=x.useRef(!1),M=x.useRef(null),P=x.useRef(p);P.current=p,x.useEffect(()=>{const ie=new AbortController;return c(null),f(null),A(null),g(1),fetch(e,{signal:ie.signal}).then(U=>U.text()).then(U=>c(Qee(U))).catch(U=>{ie.signal.aborted||f(U instanceof Error?U.message:"SVG preview failed")}),()=>ie.abort()},[e]),x.useEffect(()=>{if(!y)return;const ie=U=>{U.key==="Escape"&&v(!1)};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[y]),x.useLayoutEffect(()=>{const ie=i.current,U=ie?.querySelector("[data-svg-document] > svg");if(!ie||!U)return;let G;try{G=U.getBBox()}catch{return}if(!G.width||!G.height)return;const ae=Math.max(2,Math.min(G.width,G.height)*.025);U.setAttribute("viewBox",`${G.x-ae} ${G.y-ae} ${G.width+2*ae} ${G.height+2*ae}`),U.style.width=`${p*100}%`,U.style.height=`${p*100}%`,U.style.minWidth=`${p*100}%`,U.style.minHeight=`${p*100}%`,U.style.display="block"},[a,p]);const F=x.useMemo(()=>S?Oee(t,n,S):null,[t,S,n]),j=ie=>{if(E.current){E.current=!1;return}const U=i.current,G=U?.querySelector("[data-svg-document] > svg"),ae=s.current;if(!U||!G||!ae)return;const ve=G.viewBox.baseVal,pe=Fee(ie.clientX,ie.clientY,G.getBoundingClientRect(),ve);if(!pe)return;const we=ae.getBoundingClientRect();A({...pe,nearestText:$ee(G,pe.x,pe.y),stageX:ie.clientX-we.left,stageY:ie.clientY-we.top,stageXPercent:(ie.clientX-we.left)/we.width*100,stageYPercent:(ie.clientY-we.top)/we.height*100})},T=ie=>Math.max(1,Math.min(12,ie)),Q=(ie,U)=>{const G=T(U),ae=ie.querySelector("[data-svg-document] > svg");if(!ae)return G;const ve=`${G*100}%`;return ae.style.width=ve,ae.style.height=ve,ae.style.minWidth=ve,ae.style.minHeight=ve,P.current=G,G},$=(ie,U,G,ae)=>{const ve=P.current,pe=ie.getBoundingClientRect(),we=G-pe.left,ze=ae-pe.top,Ce=(ie.scrollLeft+we)/ve,$e=(ie.scrollTop+ze)/ve,ee=Q(ie,U);return ie.scrollLeft=Ce*ee-we,ie.scrollTop=$e*ee-ze,ee},Z=()=>{const ie=Array.from(C.current.values());return ie.length>=2?Math.hypot(ie[0].x-ie[1].x,ie[0].y-ie[1].y):0},V=ie=>{if(ie.pointerType==="mouse"&&ie.button!==0)return;const U=i.current;U&&(C.current.set(ie.pointerId,{x:ie.clientX,y:ie.clientY}),U.setPointerCapture?.(ie.pointerId),C.current.size>=2?(L.current={kind:"pinch",startX:ie.clientX,startY:ie.clientY,startScrollLeft:U.scrollLeft,startScrollTop:U.scrollTop,startDistance:Z(),startZoom:P.current,moved:!1},E.current=!0):P.current>1&&(L.current={kind:"pan",startX:ie.clientX,startY:ie.clientY,startScrollLeft:U.scrollLeft,startScrollTop:U.scrollTop,startZoom:P.current,moved:!1}))},fe=ie=>{if(!C.current.has(ie.pointerId))return;C.current.set(ie.pointerId,{x:ie.clientX,y:ie.clientY});const U=i.current,G=L.current;if(!(!U||!G)){if(C.current.size>=2&&G.kind==="pinch"){const ae=Z();if(!G.startDistance||!ae)return;const ve=T(G.startZoom*ae/G.startDistance);if(Math.abs(ve-P.current)<.01)return;const pe=Array.from(C.current.values()),we=(pe[0].x+pe[1].x)/2,ze=(pe[0].y+pe[1].y)/2;G.moved=!0,E.current=!0,$(U,ve,we,ze),ie.preventDefault();return}if(G.kind==="pan"&&C.current.size===1){const ae=ie.clientX-G.startX,ve=ie.clientY-G.startY;if(!G.moved&&Math.hypot(ae,ve)<6)return;G.moved=!0,E.current=!0,U.scrollLeft=G.startScrollLeft-ae,U.scrollTop=G.startScrollTop-ve,ie.preventDefault()}}},X=ie=>{const U=i.current,G=L.current,ae=C.current.size===1&&!G?.moved;C.current.delete(ie.pointerId);try{U?.releasePointerCapture?.(ie.pointerId)}catch{}if(C.current.size===1&&G?.kind==="pinch"){const we=Array.from(C.current.values())[0];L.current=U?{kind:"pan",startX:we.x,startY:we.y,startScrollLeft:U.scrollLeft,startScrollTop:U.scrollTop,startZoom:P.current,moved:!1}:null;return}if(C.current.size>0||(L.current=null,G?.kind==="pinch"&&g(P.current),!ae||E.current))return;const ve=Date.now(),pe=M.current;pe&&ve-pe.time<350&&Math.hypot(ie.clientX-pe.x,ie.clientY-pe.y)<24?(M.current=null,E.current=!0,g(we=>we>1?1:2.5)):M.current={time:ve,x:ie.clientX,y:ie.clientY}},ge=ie=>{if(!ie.ctrlKey&&!ie.metaKey)return;const U=i.current;if(!U)return;ie.preventDefault();const G=$(U,P.current*Math.exp(-ie.deltaY*.01),ie.clientX,ie.clientY);g(G)},be=()=>{g(1),P.current=1,i.current&&(i.current.scrollLeft=0,i.current.scrollTop=0)},Te=o.jsxs("div",{className:y?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[o.jsxs("div",{ref:s,className:"relative min-h-0 flex-1",children:[o.jsx("div",{ref:i,role:"button",tabIndex:0,onClick:j,onDoubleClick:ie=>{ie.preventDefault(),g(U=>U>1?1:2.5)},onPointerDown:V,onPointerMove:fe,onPointerUp:X,onPointerCancel:X,onWheel:ge,onScroll:()=>A(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:u?o.jsx("div",{className:"p-4 text-sm text-destructive",children:u}):a?o.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:a}}):o.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),S&&o.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:S.stageX,top:S.stageY}}),S&&F&&o.jsx(x1,{anchor:{xPercent:S.stageXPercent,yPercent:S.stageYPercent},title:"引用 SVG 标注",onClick:()=>{r?.(F,`svg:${S.x.toFixed(2)}:${S.y.toFixed(2)}`),A(null)},children:"引用 SVG 标注"}),o.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[p>1.001&&o.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:ie=>{ie.stopPropagation(),be()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:o.jsx(SD,{size:14})}),o.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:ie=>{ie.stopPropagation(),v(U=>!U)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:y?o.jsx(Gy,{size:14}):o.jsx(Uy,{size:14})})]})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:S?`SVG (${S.x.toFixed(2)}, ${S.y.toFixed(2)}) · ${S.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return y?fi.createPortal(Te,document.body):Te}function Ym(e){switch(e){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function Hee(e,t,n,r){const s=[`电子标注: ${e}`,`视图: ${Ym(t)}`,`图片位置: (${n.xPercent.toFixed(1)}%,${n.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(r?.available&&r.xMm!==void 0&&r.yMm!==void 0&&(s.push(`PCB坐标: (${r.xMm.toFixed(2)},${r.yMm.toFixed(2)})mm [KiCad板坐标]`),r.layer&&s.push(`显示层: ${r.layer}`),r.nearest)){const i=[r.nearest.net?`网络 ${r.nearest.net}`:null,`对象层 ${r.nearest.layer}`,`距离 ${r.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");s.push(`最近对象: ${r.nearest.label}${i?`(${i})`:""}`)}return`"${s.join(" / ")}"`}function zee({blobUrl:e,filePath:t,view:n,board:r,onViewChange:s,onInsertAnnotation:i,onRefresh:a,interactive3d:c}){const{t:u}=er(),f=x.useRef(null),p=x.useRef(null),g=x.useRef(null),[y,v]=x.useState(null),[S,A]=x.useState(!1);x.useEffect(()=>(g.current?.abort(),v(null),A(!1),()=>g.current?.abort()),[e,n]);const C=x.useMemo(()=>y?Hee(t,n,y,y.inspection):null,[t,y,n]),L=M=>{const P=f.current,F=p.current;if(!P||!F||!F.naturalWidth||!F.naturalHeight)return;const j=P.getBoundingClientRect(),T=Math.min(j.width/F.naturalWidth,j.height/F.naturalHeight),Q=F.naturalWidth*T,$=F.naturalHeight*T,Z=j.left+(j.width-Q)/2,V=j.top+(j.height-$)/2,fe=M.clientX-Z,X=M.clientY-V;if(fe<0||X<0||fe>Q||X>$)return;const ge={xPercent:Math.max(0,Math.min(100,fe/Q*100)),yPercent:Math.max(0,Math.min(100,X/$*100)),stageXPercent:(M.clientX-j.left)/j.width*100,stageYPercent:(M.clientY-j.top)/j.height*100,inspecting:r&&n!=="pcb-3d"};if(v(ge),g.current?.abort(),!ge.inspecting)return;const be=new AbortController;g.current=be,eR(t,n,ge.xPercent,ge.yPercent,be.signal).then(Te=>v(ie=>ie===ge?{...ie,inspection:Te,inspecting:!1}:ie)).catch(()=>{be.signal.aborted||v(Te=>Te===ge?{...Te,inspection:{available:!1},inspecting:!1}:Te)})},E=r?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return o.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[o.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:E.map(M=>o.jsx("button",{type:"button",onClick:()=>s(M),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${M===n?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:Ym(M)},M))}),o.jsx("button",{type:"button",onClick:a,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:u("rightSidebar.edaRefresh"),"aria-label":u("rightSidebar.edaRefresh"),children:o.jsx(Fs,{size:13})})]}),r&&c?o.jsx("div",{className:n==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:c}):null,r?n==="pcb-3d"?c?null:o.jsx("div",{className:"min-h-0 flex-1"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:f,role:"button",tabIndex:0,onClick:L,onKeyDown:M=>{M.key!=="Enter"&&M.key!==" "||(M.preventDefault(),v({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:u("rightSidebar.edaPickHint"),children:[o.jsx("img",{ref:p,src:e,alt:`${t} ${Ym(n)}`,onLoad:()=>A(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${S?"opacity-100":"opacity-0"}`}),y&&o.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${y.stageXPercent}%`,top:`${y.stageYPercent}%`}}),y&&C&&o.jsx(x1,{anchor:{xPercent:y.stageXPercent,yPercent:y.stageYPercent},disabled:y.inspecting,title:u("rightSidebar.edaInsertAnnotation"),onClick:()=>{i?.(C,`eda:${n}:${y.xPercent.toFixed(1)}:${y.yPercent.toFixed(1)}`),v(null)},children:u("rightSidebar.edaInsertAnnotation")})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:y?y.inspecting?u("rightSidebar.edaInspecting"):y.inspection?.available?u("rightSidebar.edaPickedBoardPosition",{x:y.inspection.xMm?.toFixed(2)??"—",y:y.inspection.yMm?.toFixed(2)??"—",object:y.inspection.nearest?.label??u("rightSidebar.edaNoNearbyObject")}):u("rightSidebar.edaPickedPosition",{x:y.xPercent.toFixed(1),y:y.yPercent.toFixed(1)}):u("rightSidebar.edaPickHint")})})]}):o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:o.jsx(kC,{blobUrl:e,filePath:t,viewLabel:Ym(n),onInsertAnnotation:i})})]})}function Uee(e){const t=[];let n=[],r="",s=!1;for(let i=0;i<e.length;i+=1){const a=e[i];s?a==='"'&&e[i+1]==='"'?(r+='"',i+=1):a==='"'?s=!1:r+=a:a==='"'?s=!0:a===","?(n.push(r),r=""):a===`
181
181
  `?(n.push(r.replace(/\r$/,"")),t.push(n),n=[],r=""):r+=a}return(r||n.length>0)&&(n.push(r.replace(/\r$/,"")),t.push(n)),t}function Gee(e,t,n,r,s){const i=t[s]||`第${s+1}列`,a=n[s]??"",c=t.map((u,f)=>`${u||`第${f+1}列`}=${n[f]??""}`).join(";");return`"表格标注: ${e} / 数据行: ${r+1} / 列: ${i} / 值: ${a} / 记录: ${c}"`}function Wee({content:e,filePath:t,onInsertAnnotation:n}){const{t:r}=er(),s=x.useMemo(()=>Uee(e),[e]),i=s[0]??[],a=s.slice(1),c=x.useRef(null),[u,f]=x.useState(null),p=u?a[u.row]:null,g=u&&p?Gee(t,i,p,u.row+1,u.column):null;return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[o.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[o.jsx("div",{className:"h-full overflow-auto",children:o.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),i.map((y,v)=>o.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:y||r("rightSidebar.csvUnnamedColumn",{index:v+1})},`${y}:${v}`))]})}),o.jsx("tbody",{children:a.map((y,v)=>o.jsxs("tr",{className:"hover:bg-surface-2",children:[o.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:v+1}),i.map((S,A)=>{const C=u?.row===v&&u.column===A;return o.jsx("td",{className:`border-b border-r border-border/15 p-0 ${C?"bg-primary/15":""}`,children:o.jsx("button",{type:"button",onClick:L=>{const E=c.current?.getBoundingClientRect(),M=L.currentTarget.getBoundingClientRect();if(!E?.width||!E.height)return;const P=L.clientX||M.left+M.width/2,F=L.clientY||M.top+M.height/2;f({row:v,column:A,xPercent:(P-E.left)/E.width*100,yPercent:(F-E.top)/E.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:y[A]||" "})},`cell:${v}:${A}`)})]},`row:${v}`))})]})}),u&&g&&o.jsx(x1,{anchor:{xPercent:u.xPercent,yPercent:u.yPercent},title:r("rightSidebar.csvInsertAnnotation"),onClick:()=>{n?.(g,`csv:${t}:${u.row+1}:${u.column+1}`),f(null)},children:r("rightSidebar.csvInsertAnnotation")})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:u&&p?r("rightSidebar.csvSelectedCell",{row:u.row+1,column:i[u.column]||u.column+1}):r("rightSidebar.csvPickHint",{rows:a.length,columns:i.length})})})]})}function Zd(e,t){let n=e;for(const r of t){if(!n||typeof n!="object")return;n=n[r]}return n}function Vee(e,t){const n=JSON.parse(e),r=Zd(n,["meta","version"]);if(t)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(r??"未知")},{label:"活动层编号",value:String(Zd(n,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Zd(n,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Zd(n,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const s=Zd(n,["net_settings","classes"]),i=Array.isArray(s)?s.find(c=>c&&typeof c=="object"&&c.name==="Default"):void 0,a=Zd(n,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(r??"未知")},{label:"网络类数量",value:String(Array.isArray(s)?s.length:0)},{label:"默认间距",value:i?.clearance!==void 0?`${i.clearance} mm`:"未设置"},{label:"默认线宽",value:i?.track_width!==void 0?`${i.track_width} mm`:"未设置"},{label:"默认过孔",value:i?.via_diameter!==void 0?`${i.via_diameter} / ${i.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(a)?a.length:0)}]}function qee(e,t){return`"KiCad项目标注: ${e} / 项: ${t.label} / 值: ${t.value}"`}function Kee({content:e,filePath:t,localState:n,onInsertAnnotation:r}){const{t:s}=er(),i=x.useRef(null),[a,c]=x.useState(null),u=x.useMemo(()=>{try{return{items:Vee(e,n),error:null}}catch(p){return{items:[],error:p instanceof Error?p.message:String(p)}}},[e,n]),f=a===null?null:u.items[a.index];return u.error?o.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:e}):o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[n&&o.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:s("rightSidebar.kicadLocalStateNotice")}),o.jsxs("div",{ref:i,className:"relative min-h-0 flex-1",children:[o.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[o.jsx("div",{className:"divide-y divide-border/15",children:u.items.map((p,g)=>o.jsxs("button",{type:"button",onClick:y=>{const v=i.current?.getBoundingClientRect(),S=y.currentTarget.getBoundingClientRect();if(!v?.width||!v.height)return;const A=y.clientX||S.left+S.width/2,C=y.clientY||S.top+S.height/2;c({index:g,xPercent:(A-v.left)/v.width*100,yPercent:(C-v.top)/v.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${a?.index===g?"bg-primary/10":""}`,children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:p.label}),o.jsx("span",{className:"break-words text-xs text-foreground",children:p.value})]},p.label))}),o.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[o.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:s("rightSidebar.kicadShowRawJson")}),o.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:e})]})]}),f&&a&&o.jsx(x1,{anchor:{xPercent:a.xPercent,yPercent:a.yPercent},title:s("rightSidebar.kicadInsertSetting"),onClick:()=>{r?.(qee(t,f),`kicad-project:${t}:${f.label}`),c(null)},children:s("rightSidebar.kicadInsertSetting")})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:f?`${f.label}: ${f.value}`:s("rightSidebar.kicadProjectPickHint")})})]})}const Yee=x.forwardRef(function({src:t,title:n,exitFullscreenLabel:r,onFullscreenChange:s},i){const a=x.useRef(null),[c,u]=x.useState(!1),[f,p]=x.useState(!1),g=c||f;x.useEffect(()=>{s?.(g)},[g,s]),x.useEffect(()=>{const S=()=>{u(document.fullscreenElement===a.current)};return document.addEventListener("fullscreenchange",S),()=>document.removeEventListener("fullscreenchange",S)},[]),x.useEffect(()=>{if(!f)return;const S=A=>{A.key==="Escape"&&p(!1)};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[f]);const y=x.useCallback(async()=>{const S=a.current;if(S){if(f){p(!1);return}if(document.fullscreenElement===S){await document.exitFullscreen();return}if(S.requestFullscreen&&document.fullscreenEnabled!==!1)try{await S.requestFullscreen();return}catch{}p(!0)}},[f]);x.useImperativeHandle(i,()=>({toggleFullscreen:y}),[y]);const v=o.jsxs("div",{ref:a,"data-html-preview-frame":!0,className:g?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[g&&o.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[o.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:n}),o.jsx("button",{type:"button",onClick:()=>{y()},"aria-label":r,title:`${r} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:o.jsx(Gy,{size:15})})]}),o.jsx("iframe",{src:t,title:n,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return f?fi.createPortal(v,document.body):v}),_C="termdock-file-search-match",xy="termdock-file-search-current";function Xee(e){const t=e.metaKey||e.ctrlKey,n=e.key.toLocaleLowerCase();return t&&n==="f"?"open":t&&n==="g"||e.key==="F3"?e.shiftKey?"previous":"next":e.key==="Escape"?"close":null}function Zee(e){return e.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function Jee(e,t){const n=t.trim().toLocaleLowerCase();if(!n)return[];const r=[];let s="",i=null;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let p=a.nextNode();p;p=a.nextNode()){if(!(p instanceof Text)||!p.data)continue;const g=Zee(p);if(!g)continue;i&&i!==g&&(s+=`
182
- `);const y=s.length;s+=p.data,r.push({node:p,start:y,end:s.length,group:g}),i=g}const c=s.toLocaleLowerCase(),u=[];let f=0;for(;f<=c.length-n.length;){const p=c.indexOf(n,f);if(p<0)break;const g=p+n.length,y=r.find(S=>S.start<=p&&S.end>p),v=r.find(S=>S.start<g&&S.end>=g);if(y&&v&&y.group===v.group){const S=document.createRange();S.setStart(y.node,p-y.start),S.setEnd(v.node,g-v.start),u.push(S)}f=p+Math.max(n.length,1)}return u}function LC(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function xm(){const e=LC();e?.delete(_C),e?.delete(xy)}function T7(e,t){const n=LC();if(!n||typeof Highlight>"u")return;n.set(_C,new Highlight(...e));const r=e[t];r?n.set(xy,new Highlight(r)):n.delete(xy)}function C7(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function ete(e){return Array.from(new Set(e.split(/[\n,]/).map(t=>t.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function tte(e,t){const n=t.trim();return!n||n==="."?e:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(n)?n.replace(/[\\/]+$/,""):`${e.replace(/[\\/]+$/,"")}/${n.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function nte(e,t){if(t===e)return".";const n=`${e.replace(/[\\/]+$/,"")}/`;return t.startsWith(n)?t.slice(n.length):t}function rte(e,t,n){return t?e:fi.createPortal(e,n)}const qv="termdock:right-sidebar:file-tree-scroll:v1",Kv="termdock:right-sidebar:file-preview-reading-state:v1",sh="termdock:right-sidebar:file-tree-width:v1",EC="termdock:right-sidebar:markdown-view-mode:v1",IC="termdock:right-sidebar:diff-change-list-mode:v1",RC="termdock:right-sidebar:diff-wrap:v1",NC="termdock:diff-viewer:view-type:v1",MC="termdock:right-sidebar:file-search-mode:v1",_b="termdock:right-sidebar:collapsed-git-repo-groups:v1",k7="termdock:right-sidebar:collapsed-diff-directories:v1",Lb="termdock:right-sidebar:branch-audit-module-open:v1",DC="termdock:right-sidebar:branch-audit-module:v1",ste=150,jC="termdock:right-sidebar:active-git-repo:v1",_7="termdock:right-sidebar:context-draft-enabled:v1",L7="termdock:right-sidebar:context-draft-collapsed:v1",E7="termdock:right-sidebar:context-draft-auto-collapse:v1",Eb="termdock:right-sidebar:context-draft-text:v1",ite=300,ote=20,ate=120,lte=250,cte=250,ute=120,dte=700,Ib=600,I7=[2e3,5e3,15e3,3e4],fte=320,hte=500,pte=20,mte=12e3,by=300,R7=240,gte=560,PC="border-r px-2 py-1.5 sm:px-3 sm:py-2",Dg="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",BC=`${PC} border-b border-border/15 font-semibold last:border-r-0`,FC=`${PC} border-border/10 align-top text-muted-foreground last:border-r-0`,Yv="termdock-file-preview-horizontal-scroll",N7=x.lazy(()=>B0(()=>import("./ModelPreview-CxvutFIK.js"),__vite__mapDeps([2,3,1,4]))),OC=`${Yv} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function xte(e,t,n){return e&&!t?"unified":n}const bte=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function yte(e){return e==="preview"||e==="source"}function vte(e){return e==="list"||e==="tree"||e==="ai"}function M7(){return zr(EC,yte)??"preview"}function wte(){return zr(IC,vte)??"tree"}function ih(e){return typeof e=="boolean"}function Ste(e){return typeof e=="string"}function Ate(){return zr(RC,ih)??!0}function Tte(e){return e==="unified"||e==="split"}function Cte(){return zr(NC,Tte)??"unified"}function kte(e){return e==="name"||e==="content"||e==="regex"}function _te(){return zr(MC,kte)??"name"}function QC(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:Oo(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function Lte(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>t===null||typeof t=="string")}function $C(){return zr(jC,Lte)??{}}function D7(e){if(!e)return;const t=$C();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Rb(e,t){e&&Un(jC,{...$C(),[e]:t})}function Ete(e,t){if(!t)return null;const n=new Set((e.repoFilters??[]).map(r=>r.root));return n.has(t)?t:n.size>0?null:(e.repositories??[]).some(r=>r.root===t)?t:null}function yy(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function j7(e){const t=zr(e,yy);return t?new Set(t):new Set}function Nb(e,t){Un(e,[...t])}function Ite(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.filePath=="string"&&typeof t.hunkHeader=="string"&&typeof t.hunkIndex=="number"&&typeof t.fingerprint=="string"&&typeof t.additions=="number"&&typeof t.deletions=="number"&&typeof t.diff=="string"&&(t.oldPath===void 0||t.oldPath===null||typeof t.oldPath=="string")&&(t.newPath===void 0||t.newPath===null||typeof t.newPath=="string")&&(t.source===void 0||t.source==="committed"||t.source==="uncommitted"||t.source==="unknown")&&(t.commit===void 0||t.commit===null||typeof t.commit=="string")}function Rte(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.available=="boolean"&&(t.repoRoot===void 0||typeof t.repoRoot=="string")&&(t.workspaceRoot===void 0||typeof t.workspaceRoot=="string")&&(t.baseRef===void 0||typeof t.baseRef=="string")&&(t.baseBranch===void 0||typeof t.baseBranch=="string")&&(t.currentBranch===void 0||t.currentBranch===null||typeof t.currentBranch=="string")&&(t.headRef===void 0||t.headRef===null||typeof t.headRef=="string")&&(t.diffFingerprint===void 0||typeof t.diffFingerprint=="string")&&(t.stat===void 0||typeof t.stat=="string")&&(t.files===void 0||yy(t.files))&&(t.hunks===void 0||Array.isArray(t.hunks)&&t.hunks.every(Ite))&&(t.commits===void 0||yy(t.commits))&&(t.commitCount===void 0||typeof t.commitCount=="number")&&(t.diff===void 0||typeof t.diff=="string")&&(t.truncated===void 0||typeof t.truncated=="boolean")&&(t.error===void 0||typeof t.error=="string")}function Nte(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.key=="string"&&Rte(t.diff)&&typeof t.repoLabel=="string"&&typeof t.createdAt=="number"}function Mte(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return Array.isArray(n.selectedRepoRoots)&&n.selectedRepoRoots.every(r=>typeof r=="string")&&!!n.repoTargetBranches&&typeof n.repoTargetBranches=="object"&&!Array.isArray(n.repoTargetBranches)&&Object.values(n.repoTargetBranches).every(r=>typeof r=="string")&&(n.repoBaseBranches===void 0||!!n.repoBaseBranches&&typeof n.repoBaseBranches=="object"&&!Array.isArray(n.repoBaseBranches)&&Object.values(n.repoBaseBranches).every(r=>typeof r=="string"))&&(n.previewEntries===void 0||Array.isArray(n.previewEntries)&&n.previewEntries.every(Nte))&&(n.selectedPreviewKey===void 0||n.selectedPreviewKey===null||typeof n.selectedPreviewKey=="string")&&(n.selectedPreviewFileKey===void 0||n.selectedPreviewFileKey===null||typeof n.selectedPreviewFileKey=="string")&&(n.previewDetailOpen===void 0||typeof n.previewDetailOpen=="boolean")&&(n.previewScrollTops===void 0||!!n.previewScrollTops&&typeof n.previewScrollTops=="object"&&!Array.isArray(n.previewScrollTops)&&Object.values(n.previewScrollTops).every(r=>typeof r=="number"))&&(n.previewMobileSlideIndex===void 0||typeof n.previewMobileSlideIndex=="number")&&(n.includeUncommitted===void 0||typeof n.includeUncommitted=="boolean")&&typeof n.updatedAt=="number"})}function P7(){return zr(DC,Mte)??{}}function B7(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function F7(e){const t=e?.trim()??"",n=t.indexOf("/");return n>=0?t.slice(n+1):t}function HC(e,t){const n=e?.trim(),r=t?.trim();return!n||!r?!1:n===r||F7(n)===F7(r)}function O7(e){const t=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(r=>r&&!HC(r,t))??""}function vy(e,t){const n=Math.max(R7,t-320),r=Math.min(gte,n);return Math.min(r,Math.max(R7,e))}function Dte(e){return typeof e=="number"&&Number.isFinite(e)}function jte(e){return vy(zr(sh,Dte)??by,e)}function zC(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n).toLowerCase():""}function Gf(e){return bte.has(zC(e))}function UC(e){const t=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(t)||/^\*{3,}$/.test(t)||/^_{3,}$/.test(t)}function wy(e){const t=e.trim();return/^#{1,6}\s+/.test(t)||UC(e)||/^>\s?/.test(t)||/^(```|~~~)/.test(t)||/^(?:[-+*]|\d+[.)])\s+/.test(t)}function Pte(e){const t=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(t)||!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/[<>]/.test(t)?t:null}const GC=x.createContext(null);function Xm(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function WC(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function VC(e){return e.replace(/\s+#+\s*$/,"").trim()}function Sy(e,t){const r=WC(e).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",s=t.headingSlugCounts.get(r)??0;return t.headingSlugCounts.set(r,s+1),s===0?r:`${r}-${s}`}function Q7(e){return WC(e)||e.trim()}function jg(e){const t=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!t)return null;const n=Ty(t[2]);return n?{id:Xm(t[1]),definition:{href:n.href,title:n.title}}:null}function Bte(e){const t=new Map;for(const n of e){const r=jg(n);r&&t.set(r.id,r.definition)}return t}function qC(e){return e.trim().toLowerCase()}function KC(e){const t=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return t?{id:qC(t[1]),text:t[2]}:null}function Fte(e){const t=new Map;let n=null;for(const r of e){const s=KC(r);if(s){n=s.id,t.set(s.id,{id:s.id,text:s.text,index:t.size+1});continue}if(n&&/^\s{4,}\S/.test(r)){const i=t.get(n);i&&(i.text=`${i.text} ${r.trim()}`);continue}r.trim()&&(n=null)}return t}function Ote(e){const t=new Set;let n=!1;return e.forEach((r,s)=>{if(KC(r)){t.add(s),n=!0;return}if(n&&/^\s{4,}\S/.test(r)){t.add(s);return}r.trim()&&(n=!1)}),t}function Qte(e){const t=[...e];let n=0;const r=e[0]?.trim();if(r==="---"||r==="+++"){for(t[0]="",n=1;n<e.length&&e[n].trim()!==r;)t[n]="",n+=1;n<e.length&&(t[n]="",n+=1)}for(;n<e.length;){const s=e[n].trim();if(s.startsWith("<!--")){if(t[n]="",!s.includes("-->")){for(n+=1;n<e.length&&!e[n].includes("-->");)t[n]="",n+=1;n<e.length&&(t[n]="")}n+=1;continue}n+=1}return t}function YC(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n<=0?n===0?"/":"":t.slice(0,n)}function bh(e){const t=e.split(/[?#]/,1)[0],n=t.startsWith("/"),r=[];for(const i of t.split("/"))if(!(!i||i===".")){if(i===".."){r.length>0&&r.pop();continue}r.push(i)}return`${n?"/":""}${r.join("/")}`||(n?"/":".")}function $te(e,t,n){const r=e.trim();if(!r||/^(?:https?:|mailto:|javascript:|data:|#)/i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))return null;const s=r.indexOf("#"),i=s>=0?r.slice(0,s):r,a=s>=0?r.slice(s+1):"",c=i.split("?",1)[0];if(!c)return null;let u,f=null;try{u=decodeURIComponent(c),f=a?decodeURIComponent(a):null}catch{return null}const p=n?bh(n):null;let g;if(u.startsWith("/")){const y=p&&(u===p||u.startsWith(`${p}/`));g=bh(p&&!y?`${p}/${u.slice(1)}`:u)}else{if(!t)return null;g=bh(`${YC(t)}/${u}`)}return p&&g!==p&&!g.startsWith(`${p}/`)?null:{path:g,fragment:f,directory:/\/$/.test(c)}}function Hte(e,t,n){const r=e.trim();if(!r||/^(?:javascript|data):/i.test(r))return null;if(/^https?:\/\//i.test(r))return r;if(!Py(r.split(/[?#]/,1)[0]))return null;let s;if(r.startsWith("/")){const i=n&&(r===n||r.startsWith(`${n}/`));s=bh(n&&!i?`${n}/${r.slice(1)}`:r)}else{if(!t)return null;s=bh(`${YC(t)}/${r}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(s)}`}const Ay=128,zte=360,Mb=480;function Xv(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function Ute(e,t,n,r){if(!t||!n)return null;let s,i;return Xv(e)?(i=Math.min(Math.max(n,Ay),zte),s=t*i/n):(s=t,i=n),r>0&&s>r&&(i=i*r/s,s=r),i>Mb&&(s=s*Mb/i,i=Mb),{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(i))}}function Gte(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function XC(e){const t=Gte(e),n=at(r=>t?(r.fileChangeVersions.get(t)??0)+r.fileWatchEpoch:0);return t&&n>0?`${e}&v=${n}`:e}function Wte({src:e,alt:t,title:n}){const r=Xv(e),s=XC(e),i=x.useRef(null),[a,c]=x.useState(!1),[u,f]=x.useState(0),[p,g]=x.useState({status:"loading"}),[y,v]=x.useState(null);x.useLayoutEffect(()=>{const C=i.current,L=C?.parentElement?.parentElement??C?.parentElement;if(!L)return;const E=()=>f(L.clientWidth);if(E(),typeof ResizeObserver>"u")return;const M=new ResizeObserver(E);return M.observe(L),()=>M.disconnect()},[]),x.useEffect(()=>{if(a)return;const C=i.current;if(!C||typeof IntersectionObserver>"u"){c(!0);return}const L=new IntersectionObserver(E=>{E.some(M=>M.isIntersecting)&&(c(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(C),()=>L.disconnect()},[a]),x.useEffect(()=>{if(!a)return;const C=new AbortController;let L=null;g({status:"loading"});const E=window.setTimeout(()=>{C.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return fetch(s,{signal:C.signal}).then(async M=>{if(!M.ok)throw new Error(`HTTP ${M.status}`);const P=Number(M.headers.get("X-Image-Width"))||0,F=Number(M.headers.get("X-Image-Height"))||0;return{blob:await M.blob(),width:P,height:F}}).then(({blob:M,width:P,height:F})=>{C.signal.aborted||(L=URL.createObjectURL(M),P>0&&F>0&&v({width:P,height:F}),g({status:"ready",objectUrl:L}))}).catch(()=>{const M=C.signal.reason;C.signal.aborted&&!(M instanceof DOMException&&M.name==="TimeoutError")||g({status:"fallback"})}).finally(()=>{window.clearTimeout(E)}),()=>{window.clearTimeout(E),C.abort(),L&&URL.revokeObjectURL(L)}},[a,s]);const S=Ute(e,y?.width??0,y?.height??0,u),A=S??{width:Ay*2,height:Ay};return o.jsx("div",{ref:i,className:"block max-w-full",style:S?{width:S.width,height:S.height}:void 0,children:p.status==="ready"?o.jsx("img",{src:p.objectUrl,alt:t,title:n,decoding:"async",className:`${r?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:S?{width:S.width,height:S.height}:void 0,onLoad:C=>{if(y)return;const L=C.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):p.status==="fallback"?o.jsx("img",{src:s,alt:t,title:n,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:S?{width:S.width,height:S.height}:void 0,onLoad:C=>{if(y)return;const L=C.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):o.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:A.width,height:A.height},children:o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:t||"…"})})})}function Db(e,t,n,r,s){const i=Hte(n,s.markdownFilePath,s.rootPath);if(!i)return`![${t}](${n})`;const a=s.images.length;s.images.push({kind:"image",src:i,alt:t,title:r});const c=o.jsx(Wte,{src:i,alt:t,title:r});return s.onImageOpen?o.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:r||t||"Open image",onClick:u=>{u.stopPropagation(),s.onImageOpen?.(a)},children:c},e):o.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c},e)}function jb(e){let t=e,n="";for(;/[.,;:!?)]$/.test(t);)n=`${t.slice(-1)}${n}`,t=t.slice(0,-1);return{linkText:t,suffix:n}}function $7(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function Ty(e){const t=e.trim(),n=t.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(n)return{href:n[1],title:n[2]??n[3]??n[4]};const r=t.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return r?{href:r[1],title:r[2]??r[3]??r[4]}:null}const ZC="",Vte=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function qte(e){return e.replace(Vte,(t,n)=>`${ZC}${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function H7(e){return e.replace(new RegExp(`${ZC}([0-9a-f]{4})`,"g"),(t,n)=>String.fromCharCode(Number.parseInt(n,16))).replace(/\\([()])/g,"$1")}function Kte(e){const t=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(t)&&/[^ ]/.test(t.slice(1,-1))?t.slice(1,-1):t}const JC={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let bm=null;function ek(){return bm||(bm=B0(()=>import("./purify.es-CC4Brkr_.js"),[]).then(e=>e.default??e).catch(e=>{throw bm=null,e})),bm}function tk({html:e}){const{t}=er(),[n,r]=x.useState(null);return x.useEffect(()=>{let s=!1;return r(null),ek().then(i=>{s||r(i.sanitize(e,JC))}).catch(()=>{s||r("")}),()=>{s=!0}},[e]),n===null?o.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:t("rightSidebar.renderingHtml")}):n?o.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:n}}):null}function Yte({html:e}){const[t,n]=x.useState(null);return x.useEffect(()=>{let r=!1;return n(null),ek().then(s=>{r||n(s.sanitize(e,JC))}).catch(()=>{r||n("")}),()=>{r=!0}},[e]),t===null?null:t?o.jsx("span",{dangerouslySetInnerHTML:{__html:t}}):e}function nk(e){const t=e.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!t)return null;const n=t[1].toLowerCase();return{tag:n,selfContained:new RegExp(`</${n}>`,"i").test(e)}}let ym=null;function Xte(){return ym||(ym=Promise.all([B0(()=>import("./katex-DnlPpQZa.js"),[]),B0(()=>Promise.resolve({}),__vite__mapDeps([5]))]).then(([e])=>e.default??e).catch(e=>{throw ym=null,e})),ym}function Oh({tex:e,display:t=!1}){const[n,r]=x.useState(null),[s,i]=x.useState(!1);if(x.useEffect(()=>{let c=!1;return r(null),i(!1),Xte().then(u=>{c||r(u.renderToString(e,{displayMode:t,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{c||i(!0)}),()=>{c=!0}},[t,e]),s)return o.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:t?`$$${e}$$`:`$${e}$`});if(!n)return o.jsx("span",{className:"text-muted-foreground/70",children:t?"Rendering formula...":e});const a=t?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return o.jsx("span",{className:a,dangerouslySetInnerHTML:{__html:n}})}function Zte(e,t,n){if(/^<br\s*\/?>$/i.test(e))return o.jsx("br",{},t);const r=e.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!r)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(e)?o.jsx(Yte,{html:e},t):null;const s=r[1].toLowerCase(),i=ji(r[2],`${t}-${s}`,!0,n);return s==="kbd"?o.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:i},t):s==="mark"?o.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:i},t):s==="sub"?o.jsx("sub",{children:i},t):o.jsx("sup",{children:i},t)}function ji(e,t,n=!0,r){const s=qte(e),i=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,a=[];let c=0,u;for(;(u=i.exec(s))!==null;){u.index>c&&a.push(H7(s.slice(c,u.index)));const f=u[0],p=`${t}-${u.index}`,g=f.startsWith("<")?Zte(f,p,r):null;if(g)a.push(g);else if(f.startsWith("\\(")&&f.endsWith("\\)"))a.push(o.jsx(Oh,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))a.push(o.jsx(Oh,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const y=f.match(/^`+/)?.[0].length??1;a.push(o.jsx("code",{className:`${n?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:Kte(f.slice(y,-y))},p))}else if(f.startsWith("~~"))a.push(o.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ji(f.slice(2,-2),`${p}-del`,n,r)},p));else if(f.startsWith("**")||f.startsWith("__"))a.push(o.jsx("strong",{className:"font-semibold text-foreground",children:ji(f.slice(2,-2),`${p}-strong`,n,r)},p));else if(f.startsWith("*")||f.startsWith("_"))a.push(o.jsx("em",{className:"italic",children:ji(f.slice(1,-1),`${p}-em`,n,r)},p));else if(f.startsWith("![")){const y=f.match(/^!\[([^\]]*)\]\((.*)\)$/),v=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^!\[([^\]]+)\]$/);if(y){const A=Ty(y[2]);a.push(A?Db(p,y[1],A.href,A.title,r):f)}else if(v){const A=v[2]||v[1],C=r.referenceDefinitions.get(Xm(A));a.push(C?Db(p,v[1],C.href,C.title,r):f)}else if(S){const A=r.referenceDefinitions.get(Xm(S[1]));a.push(A?Db(p,S[1],A.href,A.title,r):f)}else a.push(f)}else if(f.startsWith("[^")){const y=qC(f.slice(2,-1)),v=r.footnoteDefinitions.get(y);a.push(v?o.jsx("sup",{id:`fnref-${v.id}`,title:v.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:o.jsx("a",{href:`#fn-${v.id}`,className:"text-primary no-underline",children:v.index})},p):f)}else if(f.startsWith("<http")){const y=f.slice(1,-1);a.push(o.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if(f.startsWith("<")&&f.endsWith(">")&&$7(f.slice(1,-1))){const y=f.slice(1,-1);a.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if($7(jb(f).linkText)){const{linkText:y,suffix:v}=jb(f);a.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&a.push(v)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:y,suffix:v}=jb(f),S=y.startsWith("www.")?`https://${y}`:y;a.push(o.jsx("a",{href:S,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&a.push(v)}else{const y=f.match(/^\[([^\]]+)\]\((.*)\)$/),v=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^\[([^\]]+)\]$/),A=v?v[2]||v[1]:S?.[1]??null,C=A?r.referenceDefinitions.get(Xm(A)):null,L=y?Ty(y[2]):null,E=L?.href??C?.href??null,M=E?Pte(E):null,P=y?.[1]??v?.[1]??S?.[1]??"";a.push(M?o.jsx("a",{href:M,title:L?.title??C?.title,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ji(P,`${p}-link`,n,r)},p):f)}c=i.lastIndex}return c<s.length&&a.push(H7(s.slice(c))),a.length>0?a:[e]}function rk(e){return/(?: {2,}|\\)$/.test(e)}function sk(e){return e.replace(/(?: {2,}|\\)$/,"")}function Pg(e){return/^(?: {4}|\t)/.test(e)}function ik(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function ok(e,t,n){const r=[];return e.forEach((s,i)=>{const a=rk(s);r.push(...ji(sk(s),`${t}-${i}`,!0,n)),i<e.length-1&&r.push(a?o.jsx("br",{},`${t}-${i}-br`):" ")}),r}function Cy(e,t,n){const r=[],s=[];return e.forEach((i,a)=>{s.push(rk(i)),r.push(ji(sk(i),`${t}-${a}`,!0,n))}),{perLine:r,hardBreaks:s}}function ky(e,t,n,r,s){const i=[];return e.forEach((a,c)=>{const u=n[c]??0,f=!!(s&&u>=s.start&&u<=s.end);i.push(o.jsx("span",{"data-md-ref-start":u,"data-md-ref-end":u,"data-selected":f?"true":void 0,children:a},`${r}-ref-${c}`)),c<e.length-1&&i.push(t[c]?o.jsx("br",{},`${r}-${c}-br`):" ")}),i}function Qh(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="",s=!1,i=0,a=0;for(let c=0;c<t.length;c+=1){const u=t[c];if(s){r+=u,s=!1;continue}if(u==="\\"){s=!0;continue}if(u==="`"){const f=c;for(;c+1<t.length&&t[c+1]==="`";)c+=1;const p=c-f+1;r+="`".repeat(p),i===0?i=p:i===p&&(i=0);continue}if(i===0&&u==="["?a+=1:i===0&&u==="]"&&a>0&&(a-=1),u==="|"&&i===0&&a===0){n.push(r.trim()),r="";continue}r+=u}return s&&(r+="\\"),n.push(r.trim()),n}function ak(e){return Qh(e).map(t=>/^:-+:$/.test(t)?"center":/^-+:$/.test(t)?"right":/^:-+$/.test(t)?"left":null)}function Bg(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Fg(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function Jte(e,t){return e>96||e>44&&t>.35}function Zv(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Jv(e){const t=e.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!t)return null;const n=/^\d+[.)]$/.test(t[1]);return{ordered:n,start:n?Number.parseInt(t[1],10):void 0,content:t[2]}}function lk(e,t,n,r,s,i=new Set){const a=[],c=[];let u=t;for(;u<e.length;){const f=e[u];if(s&&(jg(f)||i.has(u))){u+=1;continue}const p=Jv(f),g=Zv(f);if(!p){if(g>n&&c.length>0){([...c].reverse().find(A=>A.indent<g)?.item??c[c.length-1].item).paragraphs.push(f.trim());for(const A of c)A.item.lineEnd=u+1;u+=1;continue}break}if(g<n||g===n&&p.ordered!==r)break;const y={content:p.content,ordered:p.ordered,start:p.start,children:[],paragraphs:[],lineStart:u+1,lineEnd:u+1};for(;c.length>0&&c[c.length-1].indent>=g;)c.pop();const v=c[c.length-1]?.item??null;v?v.children.push(y):a.push(y),c.push({indent:g,item:y});for(const S of c)S.item.lineEnd=u+1;u+=1}return{items:a,nextIndex:u}}function e5(e,t,n,r=0){return e.map((s,i)=>{const a=s.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${i}`,taskItem:!!a,refStart:s.lineStart+r,refEnd:s.lineEnd+r,content:o.jsxs(o.Fragment,{children:[a?o.jsx("input",{type:"checkbox",checked:a[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ji(a?.[2]??s.content,`li-${t}-${i}`,!0,n),s.paragraphs.length>0&&o.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:s.paragraphs.map((c,u)=>o.jsx("p",{children:ji(c,`li-${t}-${i}-p-${u}`,!0,n)},`paragraph-${u}`))})]}),groups:ene(s.children,`${t}-${i}`,n,r)}})}function ene(e,t,n,r=0){const s=[];for(const i of e){const a=s[s.length-1];a&&a.ordered===i.ordered?a.items.push(i):s.push({ordered:i.ordered,items:[i]})}return s.map((i,a)=>({ordered:i.ordered,start:i.ordered?i.items[0]?.start:void 0,items:e5(i.items,`${t}-g${a}`,n,r)}))}function t5(e,t){return e.map(n=>{const r=!!(t&&n.refStart<=t.end&&n.refEnd>=t.start);return o.jsxs("li",{className:n.taskItem?"list-none":void 0,"data-md-ref-start":n.refStart,"data-md-ref-end":n.refEnd,"data-selected":r?"true":void 0,children:[n.content,n.groups.length>0&&tne(n.groups,t)]},n.key)})}function tne(e,t){return e.map((n,r)=>{const s=n.ordered?"ol":"ul";return o.jsx(s,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:t5(n.items,t)},`nested-${r}`)})}function nne(e){const t=Array.from(e.footnoteDefinitions.values()).sort((n,r)=>n.index-r.index);return t.length===0?null:o.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[o.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.footnotesLabel}),o.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:t.map(n=>o.jsxs("li",{id:`fn-${n.id}`,children:[ji(n.text,`footnote-${n.id}`,!0,e)," ",o.jsx("a",{href:`#fnref-${n.id}`,className:"text-primary no-underline","aria-label":e.backToFootnoteLabel(n.index),children:"↩"})]},n.id))})]})}function rne(e,t,n,r){const s=[];let i=0;const a=c=>r?.[c]??c+1;for(;i<e.length;){const c=e[i],u=c.trim();if(!u){i+=1;continue}if(/^<details>\s*$/i.test(u)){const L=i;let E="Details";const M=[];for(i+=1;i<e.length&&!/^<\/details>\s*$/i.test(e[i].trim());){const P=e[i].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?E=P[1].trim()||E:M.push(e[i].trimStart()),i+=1}i<e.length&&(i+=1),s.push({kind:"static",node:o.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[o.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ji(E,`${t}-details-${L}-summary`,!0,n)}),M.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:ok(M,`${t}-details-${L}`,n)})]},`${t}-details-${L}`)});continue}const f=nk(c);if(f){const L=[c],E=i;for(i+=1;i<e.length&&!f.selfContained&&!new RegExp(`</${f.tag}>`,"i").test(e[i]);)L.push(e[i]),i+=1;i<e.length&&!f.selfContained&&(L.push(e[i]),i+=1),s.push({kind:"static",node:o.jsx(tk,{html:L.join(`
182
+ `);const y=s.length;s+=p.data,r.push({node:p,start:y,end:s.length,group:g}),i=g}const c=s.toLocaleLowerCase(),u=[];let f=0;for(;f<=c.length-n.length;){const p=c.indexOf(n,f);if(p<0)break;const g=p+n.length,y=r.find(S=>S.start<=p&&S.end>p),v=r.find(S=>S.start<g&&S.end>=g);if(y&&v&&y.group===v.group){const S=document.createRange();S.setStart(y.node,p-y.start),S.setEnd(v.node,g-v.start),u.push(S)}f=p+Math.max(n.length,1)}return u}function LC(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function xm(){const e=LC();e?.delete(_C),e?.delete(xy)}function T7(e,t){const n=LC();if(!n||typeof Highlight>"u")return;n.set(_C,new Highlight(...e));const r=e[t];r?n.set(xy,new Highlight(r)):n.delete(xy)}function C7(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function ete(e){return Array.from(new Set(e.split(/[\n,]/).map(t=>t.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function tte(e,t){const n=t.trim();return!n||n==="."?e:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(n)?n.replace(/[\\/]+$/,""):`${e.replace(/[\\/]+$/,"")}/${n.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function nte(e,t){if(t===e)return".";const n=`${e.replace(/[\\/]+$/,"")}/`;return t.startsWith(n)?t.slice(n.length):t}function rte(e,t,n){return t?e:fi.createPortal(e,n)}const qv="termdock:right-sidebar:file-tree-scroll:v1",Kv="termdock:right-sidebar:file-preview-reading-state:v1",sh="termdock:right-sidebar:file-tree-width:v1",EC="termdock:right-sidebar:markdown-view-mode:v1",IC="termdock:right-sidebar:diff-change-list-mode:v1",RC="termdock:right-sidebar:diff-wrap:v1",NC="termdock:diff-viewer:view-type:v1",MC="termdock:right-sidebar:file-search-mode:v1",_b="termdock:right-sidebar:collapsed-git-repo-groups:v1",k7="termdock:right-sidebar:collapsed-diff-directories:v1",Lb="termdock:right-sidebar:branch-audit-module-open:v1",DC="termdock:right-sidebar:branch-audit-module:v1",ste=150,jC="termdock:right-sidebar:active-git-repo:v1",_7="termdock:right-sidebar:context-draft-enabled:v1",L7="termdock:right-sidebar:context-draft-collapsed:v1",E7="termdock:right-sidebar:context-draft-auto-collapse:v1",Eb="termdock:right-sidebar:context-draft-text:v1",ite=300,ote=20,ate=120,lte=250,cte=250,ute=120,dte=700,Ib=600,I7=[2e3,5e3,15e3,3e4],fte=320,hte=500,pte=20,mte=12e3,by=300,R7=240,gte=560,PC="border-r px-2 py-1.5 sm:px-3 sm:py-2",Dg="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",BC=`${PC} border-b border-border/15 font-semibold last:border-r-0`,FC=`${PC} border-border/10 align-top text-muted-foreground last:border-r-0`,Yv="termdock-file-preview-horizontal-scroll",N7=x.lazy(()=>B0(()=>import("./ModelPreview-WiyzRLKE.js"),__vite__mapDeps([2,3,1,4]))),OC=`${Yv} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function xte(e,t,n){return e&&!t?"unified":n}const bte=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function yte(e){return e==="preview"||e==="source"}function vte(e){return e==="list"||e==="tree"||e==="ai"}function M7(){return zr(EC,yte)??"preview"}function wte(){return zr(IC,vte)??"tree"}function ih(e){return typeof e=="boolean"}function Ste(e){return typeof e=="string"}function Ate(){return zr(RC,ih)??!0}function Tte(e){return e==="unified"||e==="split"}function Cte(){return zr(NC,Tte)??"unified"}function kte(e){return e==="name"||e==="content"||e==="regex"}function _te(){return zr(MC,kte)??"name"}function QC(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:Oo(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function Lte(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>t===null||typeof t=="string")}function $C(){return zr(jC,Lte)??{}}function D7(e){if(!e)return;const t=$C();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Rb(e,t){e&&Un(jC,{...$C(),[e]:t})}function Ete(e,t){if(!t)return null;const n=new Set((e.repoFilters??[]).map(r=>r.root));return n.has(t)?t:n.size>0?null:(e.repositories??[]).some(r=>r.root===t)?t:null}function yy(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function j7(e){const t=zr(e,yy);return t?new Set(t):new Set}function Nb(e,t){Un(e,[...t])}function Ite(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.filePath=="string"&&typeof t.hunkHeader=="string"&&typeof t.hunkIndex=="number"&&typeof t.fingerprint=="string"&&typeof t.additions=="number"&&typeof t.deletions=="number"&&typeof t.diff=="string"&&(t.oldPath===void 0||t.oldPath===null||typeof t.oldPath=="string")&&(t.newPath===void 0||t.newPath===null||typeof t.newPath=="string")&&(t.source===void 0||t.source==="committed"||t.source==="uncommitted"||t.source==="unknown")&&(t.commit===void 0||t.commit===null||typeof t.commit=="string")}function Rte(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.available=="boolean"&&(t.repoRoot===void 0||typeof t.repoRoot=="string")&&(t.workspaceRoot===void 0||typeof t.workspaceRoot=="string")&&(t.baseRef===void 0||typeof t.baseRef=="string")&&(t.baseBranch===void 0||typeof t.baseBranch=="string")&&(t.currentBranch===void 0||t.currentBranch===null||typeof t.currentBranch=="string")&&(t.headRef===void 0||t.headRef===null||typeof t.headRef=="string")&&(t.diffFingerprint===void 0||typeof t.diffFingerprint=="string")&&(t.stat===void 0||typeof t.stat=="string")&&(t.files===void 0||yy(t.files))&&(t.hunks===void 0||Array.isArray(t.hunks)&&t.hunks.every(Ite))&&(t.commits===void 0||yy(t.commits))&&(t.commitCount===void 0||typeof t.commitCount=="number")&&(t.diff===void 0||typeof t.diff=="string")&&(t.truncated===void 0||typeof t.truncated=="boolean")&&(t.error===void 0||typeof t.error=="string")}function Nte(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.key=="string"&&Rte(t.diff)&&typeof t.repoLabel=="string"&&typeof t.createdAt=="number"}function Mte(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return Array.isArray(n.selectedRepoRoots)&&n.selectedRepoRoots.every(r=>typeof r=="string")&&!!n.repoTargetBranches&&typeof n.repoTargetBranches=="object"&&!Array.isArray(n.repoTargetBranches)&&Object.values(n.repoTargetBranches).every(r=>typeof r=="string")&&(n.repoBaseBranches===void 0||!!n.repoBaseBranches&&typeof n.repoBaseBranches=="object"&&!Array.isArray(n.repoBaseBranches)&&Object.values(n.repoBaseBranches).every(r=>typeof r=="string"))&&(n.previewEntries===void 0||Array.isArray(n.previewEntries)&&n.previewEntries.every(Nte))&&(n.selectedPreviewKey===void 0||n.selectedPreviewKey===null||typeof n.selectedPreviewKey=="string")&&(n.selectedPreviewFileKey===void 0||n.selectedPreviewFileKey===null||typeof n.selectedPreviewFileKey=="string")&&(n.previewDetailOpen===void 0||typeof n.previewDetailOpen=="boolean")&&(n.previewScrollTops===void 0||!!n.previewScrollTops&&typeof n.previewScrollTops=="object"&&!Array.isArray(n.previewScrollTops)&&Object.values(n.previewScrollTops).every(r=>typeof r=="number"))&&(n.previewMobileSlideIndex===void 0||typeof n.previewMobileSlideIndex=="number")&&(n.includeUncommitted===void 0||typeof n.includeUncommitted=="boolean")&&typeof n.updatedAt=="number"})}function P7(){return zr(DC,Mte)??{}}function B7(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function F7(e){const t=e?.trim()??"",n=t.indexOf("/");return n>=0?t.slice(n+1):t}function HC(e,t){const n=e?.trim(),r=t?.trim();return!n||!r?!1:n===r||F7(n)===F7(r)}function O7(e){const t=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(r=>r&&!HC(r,t))??""}function vy(e,t){const n=Math.max(R7,t-320),r=Math.min(gte,n);return Math.min(r,Math.max(R7,e))}function Dte(e){return typeof e=="number"&&Number.isFinite(e)}function jte(e){return vy(zr(sh,Dte)??by,e)}function zC(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n).toLowerCase():""}function Gf(e){return bte.has(zC(e))}function UC(e){const t=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(t)||/^\*{3,}$/.test(t)||/^_{3,}$/.test(t)}function wy(e){const t=e.trim();return/^#{1,6}\s+/.test(t)||UC(e)||/^>\s?/.test(t)||/^(```|~~~)/.test(t)||/^(?:[-+*]|\d+[.)])\s+/.test(t)}function Pte(e){const t=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(t)||!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/[<>]/.test(t)?t:null}const GC=x.createContext(null);function Xm(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function WC(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function VC(e){return e.replace(/\s+#+\s*$/,"").trim()}function Sy(e,t){const r=WC(e).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",s=t.headingSlugCounts.get(r)??0;return t.headingSlugCounts.set(r,s+1),s===0?r:`${r}-${s}`}function Q7(e){return WC(e)||e.trim()}function jg(e){const t=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!t)return null;const n=Ty(t[2]);return n?{id:Xm(t[1]),definition:{href:n.href,title:n.title}}:null}function Bte(e){const t=new Map;for(const n of e){const r=jg(n);r&&t.set(r.id,r.definition)}return t}function qC(e){return e.trim().toLowerCase()}function KC(e){const t=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return t?{id:qC(t[1]),text:t[2]}:null}function Fte(e){const t=new Map;let n=null;for(const r of e){const s=KC(r);if(s){n=s.id,t.set(s.id,{id:s.id,text:s.text,index:t.size+1});continue}if(n&&/^\s{4,}\S/.test(r)){const i=t.get(n);i&&(i.text=`${i.text} ${r.trim()}`);continue}r.trim()&&(n=null)}return t}function Ote(e){const t=new Set;let n=!1;return e.forEach((r,s)=>{if(KC(r)){t.add(s),n=!0;return}if(n&&/^\s{4,}\S/.test(r)){t.add(s);return}r.trim()&&(n=!1)}),t}function Qte(e){const t=[...e];let n=0;const r=e[0]?.trim();if(r==="---"||r==="+++"){for(t[0]="",n=1;n<e.length&&e[n].trim()!==r;)t[n]="",n+=1;n<e.length&&(t[n]="",n+=1)}for(;n<e.length;){const s=e[n].trim();if(s.startsWith("<!--")){if(t[n]="",!s.includes("-->")){for(n+=1;n<e.length&&!e[n].includes("-->");)t[n]="",n+=1;n<e.length&&(t[n]="")}n+=1;continue}n+=1}return t}function YC(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n<=0?n===0?"/":"":t.slice(0,n)}function bh(e){const t=e.split(/[?#]/,1)[0],n=t.startsWith("/"),r=[];for(const i of t.split("/"))if(!(!i||i===".")){if(i===".."){r.length>0&&r.pop();continue}r.push(i)}return`${n?"/":""}${r.join("/")}`||(n?"/":".")}function $te(e,t,n){const r=e.trim();if(!r||/^(?:https?:|mailto:|javascript:|data:|#)/i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))return null;const s=r.indexOf("#"),i=s>=0?r.slice(0,s):r,a=s>=0?r.slice(s+1):"",c=i.split("?",1)[0];if(!c)return null;let u,f=null;try{u=decodeURIComponent(c),f=a?decodeURIComponent(a):null}catch{return null}const p=n?bh(n):null;let g;if(u.startsWith("/")){const y=p&&(u===p||u.startsWith(`${p}/`));g=bh(p&&!y?`${p}/${u.slice(1)}`:u)}else{if(!t)return null;g=bh(`${YC(t)}/${u}`)}return p&&g!==p&&!g.startsWith(`${p}/`)?null:{path:g,fragment:f,directory:/\/$/.test(c)}}function Hte(e,t,n){const r=e.trim();if(!r||/^(?:javascript|data):/i.test(r))return null;if(/^https?:\/\//i.test(r))return r;if(!Py(r.split(/[?#]/,1)[0]))return null;let s;if(r.startsWith("/")){const i=n&&(r===n||r.startsWith(`${n}/`));s=bh(n&&!i?`${n}/${r.slice(1)}`:r)}else{if(!t)return null;s=bh(`${YC(t)}/${r}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(s)}`}const Ay=128,zte=360,Mb=480;function Xv(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function Ute(e,t,n,r){if(!t||!n)return null;let s,i;return Xv(e)?(i=Math.min(Math.max(n,Ay),zte),s=t*i/n):(s=t,i=n),r>0&&s>r&&(i=i*r/s,s=r),i>Mb&&(s=s*Mb/i,i=Mb),{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(i))}}function Gte(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function XC(e){const t=Gte(e),n=at(r=>t?(r.fileChangeVersions.get(t)??0)+r.fileWatchEpoch:0);return t&&n>0?`${e}&v=${n}`:e}function Wte({src:e,alt:t,title:n}){const r=Xv(e),s=XC(e),i=x.useRef(null),[a,c]=x.useState(!1),[u,f]=x.useState(0),[p,g]=x.useState({status:"loading"}),[y,v]=x.useState(null);x.useLayoutEffect(()=>{const C=i.current,L=C?.parentElement?.parentElement??C?.parentElement;if(!L)return;const E=()=>f(L.clientWidth);if(E(),typeof ResizeObserver>"u")return;const M=new ResizeObserver(E);return M.observe(L),()=>M.disconnect()},[]),x.useEffect(()=>{if(a)return;const C=i.current;if(!C||typeof IntersectionObserver>"u"){c(!0);return}const L=new IntersectionObserver(E=>{E.some(M=>M.isIntersecting)&&(c(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(C),()=>L.disconnect()},[a]),x.useEffect(()=>{if(!a)return;const C=new AbortController;let L=null;g({status:"loading"});const E=window.setTimeout(()=>{C.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return fetch(s,{signal:C.signal}).then(async M=>{if(!M.ok)throw new Error(`HTTP ${M.status}`);const P=Number(M.headers.get("X-Image-Width"))||0,F=Number(M.headers.get("X-Image-Height"))||0;return{blob:await M.blob(),width:P,height:F}}).then(({blob:M,width:P,height:F})=>{C.signal.aborted||(L=URL.createObjectURL(M),P>0&&F>0&&v({width:P,height:F}),g({status:"ready",objectUrl:L}))}).catch(()=>{const M=C.signal.reason;C.signal.aborted&&!(M instanceof DOMException&&M.name==="TimeoutError")||g({status:"fallback"})}).finally(()=>{window.clearTimeout(E)}),()=>{window.clearTimeout(E),C.abort(),L&&URL.revokeObjectURL(L)}},[a,s]);const S=Ute(e,y?.width??0,y?.height??0,u),A=S??{width:Ay*2,height:Ay};return o.jsx("div",{ref:i,className:"block max-w-full",style:S?{width:S.width,height:S.height}:void 0,children:p.status==="ready"?o.jsx("img",{src:p.objectUrl,alt:t,title:n,decoding:"async",className:`${r?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:S?{width:S.width,height:S.height}:void 0,onLoad:C=>{if(y)return;const L=C.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):p.status==="fallback"?o.jsx("img",{src:s,alt:t,title:n,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:S?{width:S.width,height:S.height}:void 0,onLoad:C=>{if(y)return;const L=C.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):o.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:A.width,height:A.height},children:o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:t||"…"})})})}function Db(e,t,n,r,s){const i=Hte(n,s.markdownFilePath,s.rootPath);if(!i)return`![${t}](${n})`;const a=s.images.length;s.images.push({kind:"image",src:i,alt:t,title:r});const c=o.jsx(Wte,{src:i,alt:t,title:r});return s.onImageOpen?o.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:r||t||"Open image",onClick:u=>{u.stopPropagation(),s.onImageOpen?.(a)},children:c},e):o.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c},e)}function jb(e){let t=e,n="";for(;/[.,;:!?)]$/.test(t);)n=`${t.slice(-1)}${n}`,t=t.slice(0,-1);return{linkText:t,suffix:n}}function $7(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function Ty(e){const t=e.trim(),n=t.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(n)return{href:n[1],title:n[2]??n[3]??n[4]};const r=t.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return r?{href:r[1],title:r[2]??r[3]??r[4]}:null}const ZC="",Vte=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function qte(e){return e.replace(Vte,(t,n)=>`${ZC}${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function H7(e){return e.replace(new RegExp(`${ZC}([0-9a-f]{4})`,"g"),(t,n)=>String.fromCharCode(Number.parseInt(n,16))).replace(/\\([()])/g,"$1")}function Kte(e){const t=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(t)&&/[^ ]/.test(t.slice(1,-1))?t.slice(1,-1):t}const JC={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let bm=null;function ek(){return bm||(bm=B0(()=>import("./purify.es-CC4Brkr_.js"),[]).then(e=>e.default??e).catch(e=>{throw bm=null,e})),bm}function tk({html:e}){const{t}=er(),[n,r]=x.useState(null);return x.useEffect(()=>{let s=!1;return r(null),ek().then(i=>{s||r(i.sanitize(e,JC))}).catch(()=>{s||r("")}),()=>{s=!0}},[e]),n===null?o.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:t("rightSidebar.renderingHtml")}):n?o.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:n}}):null}function Yte({html:e}){const[t,n]=x.useState(null);return x.useEffect(()=>{let r=!1;return n(null),ek().then(s=>{r||n(s.sanitize(e,JC))}).catch(()=>{r||n("")}),()=>{r=!0}},[e]),t===null?null:t?o.jsx("span",{dangerouslySetInnerHTML:{__html:t}}):e}function nk(e){const t=e.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!t)return null;const n=t[1].toLowerCase();return{tag:n,selfContained:new RegExp(`</${n}>`,"i").test(e)}}let ym=null;function Xte(){return ym||(ym=Promise.all([B0(()=>import("./katex-DnlPpQZa.js"),[]),B0(()=>Promise.resolve({}),__vite__mapDeps([5]))]).then(([e])=>e.default??e).catch(e=>{throw ym=null,e})),ym}function Oh({tex:e,display:t=!1}){const[n,r]=x.useState(null),[s,i]=x.useState(!1);if(x.useEffect(()=>{let c=!1;return r(null),i(!1),Xte().then(u=>{c||r(u.renderToString(e,{displayMode:t,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{c||i(!0)}),()=>{c=!0}},[t,e]),s)return o.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:t?`$$${e}$$`:`$${e}$`});if(!n)return o.jsx("span",{className:"text-muted-foreground/70",children:t?"Rendering formula...":e});const a=t?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return o.jsx("span",{className:a,dangerouslySetInnerHTML:{__html:n}})}function Zte(e,t,n){if(/^<br\s*\/?>$/i.test(e))return o.jsx("br",{},t);const r=e.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!r)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(e)?o.jsx(Yte,{html:e},t):null;const s=r[1].toLowerCase(),i=ji(r[2],`${t}-${s}`,!0,n);return s==="kbd"?o.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:i},t):s==="mark"?o.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:i},t):s==="sub"?o.jsx("sub",{children:i},t):o.jsx("sup",{children:i},t)}function ji(e,t,n=!0,r){const s=qte(e),i=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,a=[];let c=0,u;for(;(u=i.exec(s))!==null;){u.index>c&&a.push(H7(s.slice(c,u.index)));const f=u[0],p=`${t}-${u.index}`,g=f.startsWith("<")?Zte(f,p,r):null;if(g)a.push(g);else if(f.startsWith("\\(")&&f.endsWith("\\)"))a.push(o.jsx(Oh,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))a.push(o.jsx(Oh,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const y=f.match(/^`+/)?.[0].length??1;a.push(o.jsx("code",{className:`${n?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:Kte(f.slice(y,-y))},p))}else if(f.startsWith("~~"))a.push(o.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:ji(f.slice(2,-2),`${p}-del`,n,r)},p));else if(f.startsWith("**")||f.startsWith("__"))a.push(o.jsx("strong",{className:"font-semibold text-foreground",children:ji(f.slice(2,-2),`${p}-strong`,n,r)},p));else if(f.startsWith("*")||f.startsWith("_"))a.push(o.jsx("em",{className:"italic",children:ji(f.slice(1,-1),`${p}-em`,n,r)},p));else if(f.startsWith("![")){const y=f.match(/^!\[([^\]]*)\]\((.*)\)$/),v=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^!\[([^\]]+)\]$/);if(y){const A=Ty(y[2]);a.push(A?Db(p,y[1],A.href,A.title,r):f)}else if(v){const A=v[2]||v[1],C=r.referenceDefinitions.get(Xm(A));a.push(C?Db(p,v[1],C.href,C.title,r):f)}else if(S){const A=r.referenceDefinitions.get(Xm(S[1]));a.push(A?Db(p,S[1],A.href,A.title,r):f)}else a.push(f)}else if(f.startsWith("[^")){const y=qC(f.slice(2,-1)),v=r.footnoteDefinitions.get(y);a.push(v?o.jsx("sup",{id:`fnref-${v.id}`,title:v.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:o.jsx("a",{href:`#fn-${v.id}`,className:"text-primary no-underline",children:v.index})},p):f)}else if(f.startsWith("<http")){const y=f.slice(1,-1);a.push(o.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if(f.startsWith("<")&&f.endsWith(">")&&$7(f.slice(1,-1))){const y=f.slice(1,-1);a.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if($7(jb(f).linkText)){const{linkText:y,suffix:v}=jb(f);a.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&a.push(v)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:y,suffix:v}=jb(f),S=y.startsWith("www.")?`https://${y}`:y;a.push(o.jsx("a",{href:S,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&a.push(v)}else{const y=f.match(/^\[([^\]]+)\]\((.*)\)$/),v=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^\[([^\]]+)\]$/),A=v?v[2]||v[1]:S?.[1]??null,C=A?r.referenceDefinitions.get(Xm(A)):null,L=y?Ty(y[2]):null,E=L?.href??C?.href??null,M=E?Pte(E):null,P=y?.[1]??v?.[1]??S?.[1]??"";a.push(M?o.jsx("a",{href:M,title:L?.title??C?.title,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:ji(P,`${p}-link`,n,r)},p):f)}c=i.lastIndex}return c<s.length&&a.push(H7(s.slice(c))),a.length>0?a:[e]}function rk(e){return/(?: {2,}|\\)$/.test(e)}function sk(e){return e.replace(/(?: {2,}|\\)$/,"")}function Pg(e){return/^(?: {4}|\t)/.test(e)}function ik(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function ok(e,t,n){const r=[];return e.forEach((s,i)=>{const a=rk(s);r.push(...ji(sk(s),`${t}-${i}`,!0,n)),i<e.length-1&&r.push(a?o.jsx("br",{},`${t}-${i}-br`):" ")}),r}function Cy(e,t,n){const r=[],s=[];return e.forEach((i,a)=>{s.push(rk(i)),r.push(ji(sk(i),`${t}-${a}`,!0,n))}),{perLine:r,hardBreaks:s}}function ky(e,t,n,r,s){const i=[];return e.forEach((a,c)=>{const u=n[c]??0,f=!!(s&&u>=s.start&&u<=s.end);i.push(o.jsx("span",{"data-md-ref-start":u,"data-md-ref-end":u,"data-selected":f?"true":void 0,children:a},`${r}-ref-${c}`)),c<e.length-1&&i.push(t[c]?o.jsx("br",{},`${r}-${c}-br`):" ")}),i}function Qh(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="",s=!1,i=0,a=0;for(let c=0;c<t.length;c+=1){const u=t[c];if(s){r+=u,s=!1;continue}if(u==="\\"){s=!0;continue}if(u==="`"){const f=c;for(;c+1<t.length&&t[c+1]==="`";)c+=1;const p=c-f+1;r+="`".repeat(p),i===0?i=p:i===p&&(i=0);continue}if(i===0&&u==="["?a+=1:i===0&&u==="]"&&a>0&&(a-=1),u==="|"&&i===0&&a===0){n.push(r.trim()),r="";continue}r+=u}return s&&(r+="\\"),n.push(r.trim()),n}function ak(e){return Qh(e).map(t=>/^:-+:$/.test(t)?"center":/^-+:$/.test(t)?"right":/^:-+$/.test(t)?"left":null)}function Bg(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Fg(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function Jte(e,t){return e>96||e>44&&t>.35}function Zv(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Jv(e){const t=e.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!t)return null;const n=/^\d+[.)]$/.test(t[1]);return{ordered:n,start:n?Number.parseInt(t[1],10):void 0,content:t[2]}}function lk(e,t,n,r,s,i=new Set){const a=[],c=[];let u=t;for(;u<e.length;){const f=e[u];if(s&&(jg(f)||i.has(u))){u+=1;continue}const p=Jv(f),g=Zv(f);if(!p){if(g>n&&c.length>0){([...c].reverse().find(A=>A.indent<g)?.item??c[c.length-1].item).paragraphs.push(f.trim());for(const A of c)A.item.lineEnd=u+1;u+=1;continue}break}if(g<n||g===n&&p.ordered!==r)break;const y={content:p.content,ordered:p.ordered,start:p.start,children:[],paragraphs:[],lineStart:u+1,lineEnd:u+1};for(;c.length>0&&c[c.length-1].indent>=g;)c.pop();const v=c[c.length-1]?.item??null;v?v.children.push(y):a.push(y),c.push({indent:g,item:y});for(const S of c)S.item.lineEnd=u+1;u+=1}return{items:a,nextIndex:u}}function e5(e,t,n,r=0){return e.map((s,i)=>{const a=s.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${i}`,taskItem:!!a,refStart:s.lineStart+r,refEnd:s.lineEnd+r,content:o.jsxs(o.Fragment,{children:[a?o.jsx("input",{type:"checkbox",checked:a[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,ji(a?.[2]??s.content,`li-${t}-${i}`,!0,n),s.paragraphs.length>0&&o.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:s.paragraphs.map((c,u)=>o.jsx("p",{children:ji(c,`li-${t}-${i}-p-${u}`,!0,n)},`paragraph-${u}`))})]}),groups:ene(s.children,`${t}-${i}`,n,r)}})}function ene(e,t,n,r=0){const s=[];for(const i of e){const a=s[s.length-1];a&&a.ordered===i.ordered?a.items.push(i):s.push({ordered:i.ordered,items:[i]})}return s.map((i,a)=>({ordered:i.ordered,start:i.ordered?i.items[0]?.start:void 0,items:e5(i.items,`${t}-g${a}`,n,r)}))}function t5(e,t){return e.map(n=>{const r=!!(t&&n.refStart<=t.end&&n.refEnd>=t.start);return o.jsxs("li",{className:n.taskItem?"list-none":void 0,"data-md-ref-start":n.refStart,"data-md-ref-end":n.refEnd,"data-selected":r?"true":void 0,children:[n.content,n.groups.length>0&&tne(n.groups,t)]},n.key)})}function tne(e,t){return e.map((n,r)=>{const s=n.ordered?"ol":"ul";return o.jsx(s,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:t5(n.items,t)},`nested-${r}`)})}function nne(e){const t=Array.from(e.footnoteDefinitions.values()).sort((n,r)=>n.index-r.index);return t.length===0?null:o.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[o.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.footnotesLabel}),o.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:t.map(n=>o.jsxs("li",{id:`fn-${n.id}`,children:[ji(n.text,`footnote-${n.id}`,!0,e)," ",o.jsx("a",{href:`#fnref-${n.id}`,className:"text-primary no-underline","aria-label":e.backToFootnoteLabel(n.index),children:"↩"})]},n.id))})]})}function rne(e,t,n,r){const s=[];let i=0;const a=c=>r?.[c]??c+1;for(;i<e.length;){const c=e[i],u=c.trim();if(!u){i+=1;continue}if(/^<details>\s*$/i.test(u)){const L=i;let E="Details";const M=[];for(i+=1;i<e.length&&!/^<\/details>\s*$/i.test(e[i].trim());){const P=e[i].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?E=P[1].trim()||E:M.push(e[i].trimStart()),i+=1}i<e.length&&(i+=1),s.push({kind:"static",node:o.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[o.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ji(E,`${t}-details-${L}-summary`,!0,n)}),M.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:ok(M,`${t}-details-${L}`,n)})]},`${t}-details-${L}`)});continue}const f=nk(c);if(f){const L=[c],E=i;for(i+=1;i<e.length&&!f.selfContained&&!new RegExp(`</${f.tag}>`,"i").test(e[i]);)L.push(e[i]),i+=1;i<e.length&&!f.selfContained&&(L.push(e[i]),i+=1),s.push({kind:"static",node:o.jsx(tk,{html:L.join(`
183
183
  `)},`${t}-html-${E}`)});continue}const p=u.match(/^(```|~~~)\s*(.*)$/);if(p){const L=[],E=p[1],M=p[2]?.trim(),P=i;for(i+=1;i<e.length&&!e[i].trim().startsWith(E);)L.push(e[i]),i+=1;i<e.length&&(i+=1),M.toLowerCase()==="mermaid"?s.push({kind:"static",node:o.jsx(uk,{code:L.join(`
184
184
  `),blockKey:`${t}-code-${P}`},`${t}-code-${P}`)}):["math","latex","tex"].includes(M.toLowerCase())?s.push({kind:"static",node:o.jsx(Oh,{tex:L.join(`
185
185
  `),display:!0},`${t}-code-${P}`)}):s.push({kind:"code",key:`${t}-code-${P}`,code:L.join(`
186
186
  `),lang:M,blockKey:`${t}-code-${P}`,codeStartLine:a(P)+1});continue}if(Pg(c)){const L=[],E=i;for(;i<e.length&&(Pg(e[i])||!e[i].trim());)L.push(e[i].trim()?ik(e[i]):""),i+=1;s.push({kind:"code",key:`${t}-indented-code-${E}`,code:L.join(`
187
- `).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${E}`,codeStartLine:a(E)});continue}const g=u.match(/^(#{1,6})\s+(.+)$/);if(g){const E=`h${Math.min(6,g[1].length+1)}`,M=VC(g[2]),P=Sy(M,n);s.push({kind:"static",node:o.jsx(E,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:ji(M,`${t}-heading-${i}`,!0,n)},`${t}-heading-${i}`)}),i+=1;continue}if(i+1<e.length&&c.includes("|")&&Fg(e[i+1])){const L=Qh(c),E=ak(e[i+1]),M=[],P=i;for(i+=2;i<e.length&&e[i].includes("|")&&e[i].trim();)M.push(Qh(e[i])),i+=1;s.push({kind:"static",node:o.jsx("div",{className:OC,"data-markdown-table-scroll":!0,children:o.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[o.jsx("thead",{className:"bg-surface-2 text-foreground",children:o.jsx("tr",{children:L.map((F,j)=>o.jsx("th",{className:`${BC} ${Bg(E[j]??null)}`,children:o.jsx("div",{className:Dg,children:ji(F,`${t}-th-${P}-${j}`,!0,n)})},`h-${j}`))})}),o.jsx("tbody",{children:M.map((F,j)=>o.jsx("tr",{className:"border-t border-border/10",children:L.map((T,Q)=>o.jsx("td",{className:`${FC} ${Bg(E[Q]??null)}`,children:o.jsx("div",{className:Dg,children:ji(F[Q]??"",`${t}-td-${P}-${j}-${Q}`,!0,n)})},`c-${Q}`))},`r-${j}`))})]})},`${t}-table-${P}`)});continue}const y=Jv(c);if(y){const L=y.ordered,E=Zv(c),M=y.start,P=i,F=lk(e,i,E,L,!1);i=F.nextIndex,s.push({kind:"list",keyPrefix:`${t}-list-${P}`,ordered:L,start:L?M:void 0,renders:e5(F.items,`${t}-list-${P}`,n,a(0)-1)});continue}const v=[c.trimStart()],S=[a(i)],A=i;for(i+=1;i<e.length&&e[i].trim()&&!wy(e[i])&&!(i+1<e.length&&e[i].includes("|")&&Fg(e[i+1]));)v.push(e[i].trimStart()),S.push(a(i)),i+=1;const C=Cy(v,`${t}-p-${A}`,n);s.push({kind:"paragraph",keyPrefix:`${t}-p-${A}`,perLine:C.perLine,hardBreaks:C.hardBreaks,lineNums:S})}return s}function sne(e,t){return e.map(n=>{switch(n.kind){case"static":return n.node;case"paragraph":return o.jsx("p",{children:ky(n.perLine,n.hardBreaks,n.lineNums,n.keyPrefix,t)},n.keyPrefix);case"list":{const r=n.ordered?"ol":"ul";return o.jsx(r,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:t5(n.renders,t)},n.keyPrefix)}case"code":return o.jsx(Og,{code:n.code,lang:n.lang,blockKey:n.blockKey,codeStartLine:n.codeStartLine,lineRange:t},n.key)}})}let vm=null,z7=!1;const wm=16,ck=192;function ine(){return vm||(vm=B0(()=>import("./mermaid.core-HyKj4scx.js").then(e=>e.aJ),__vite__mapDeps([6,1,7])).then(e=>e.default??e).catch(e=>{throw vm=null,e})),vm}function one(e){z7||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),z7=!0)}function ane(e){const t=e.match(/\sviewBox=(["'])([^"']+)\1/i);if(!t)return e;const[,,n]=t,r=n.trim().split(/[\s,]+/).map(Number),[,,s,i]=r;if(!Number.isFinite(s)||!Number.isFinite(i)||s<=0||i<=0)return e;const a=Math.max(ck,Math.ceil(s)),c=Math.ceil(a/s*i);return e.replace(/<svg\b([^>]*)>/i,(u,f)=>`<svg${f.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${a}" height="${c}">`)}function lne(e){const t=e?.querySelector("svg");if(!t)return;let n;try{n=t.getBBox()}catch{return}if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return;const r=n.x-wm,s=n.y-wm,i=n.width+wm*2,a=n.height+wm*2,c=Math.max(ck,Math.ceil(i)),u=Math.ceil(c/i*a);t.setAttribute("viewBox",`${r} ${s} ${i} ${a}`),t.setAttribute("width",String(c)),t.setAttribute("height",String(u)),t.removeAttribute("style")}function cne(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t)return null;const n=t.replace(/^language-/,"");return S0(`code.${n}`)??n}function uk({code:e,blockKey:t}){const{t:n}=er(),[r,s]=x.useState(null),[i,a]=x.useState(!1),c=x.useRef(null),u=x.useContext(GC);x.useEffect(()=>{let p=!1;return s(null),a(!1),ine().then(async g=>{one(g);const y=`termdock-md-mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:v}=await g.render(y,e);p||s(ane(v))}).catch(()=>{p||a(!0)}),()=>{p=!0}},[t,e]),x.useLayoutEffect(()=>{r&&lne(c.current)},[r]);const f=x.useCallback(()=>{const p=c.current?.querySelector("svg")?.outerHTML??r;p&&u?.(p)},[u,r]);return i?o.jsx(Og,{code:e,lang:"mermaid",blockKey:`${t}-fallback`}):o.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[o.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),o.jsx("div",{className:"bg-surface p-3",children:r?o.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:n("rightSidebar.openMermaidDiagram"),onClick:p=>{p.stopPropagation(),f()},children:o.jsx("span",{ref:c,role:"img","aria-label":n("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:r}})}):o.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:n("rightSidebar.renderingDiagram")})})]})}function Og({code:e,lang:t,blockKey:n,codeStartLine:r,lineRange:s}){const i=cne(t),[a,c]=x.useState(null);x.useEffect(()=>{if(!i||!iC(e)){c(null);return}let f=!1;return oC().then(p=>{if(f||!p.registered(i)){f||c(null);return}try{c(aC(p,e,i))}catch{f||c(null)}}).catch(()=>{f||c(null)}),()=>{f=!0}},[n,e,i]);const u=a??(e||" ").split(`
187
+ `).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${E}`,codeStartLine:a(E)});continue}const g=u.match(/^(#{1,6})\s+(.+)$/);if(g){const E=`h${Math.min(6,g[1].length+1)}`,M=VC(g[2]),P=Sy(M,n);s.push({kind:"static",node:o.jsx(E,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:ji(M,`${t}-heading-${i}`,!0,n)},`${t}-heading-${i}`)}),i+=1;continue}if(i+1<e.length&&c.includes("|")&&Fg(e[i+1])){const L=Qh(c),E=ak(e[i+1]),M=[],P=i;for(i+=2;i<e.length&&e[i].includes("|")&&e[i].trim();)M.push(Qh(e[i])),i+=1;s.push({kind:"static",node:o.jsx("div",{className:OC,"data-markdown-table-scroll":!0,children:o.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[o.jsx("thead",{className:"bg-surface-2 text-foreground",children:o.jsx("tr",{children:L.map((F,j)=>o.jsx("th",{className:`${BC} ${Bg(E[j]??null)}`,children:o.jsx("div",{className:Dg,children:ji(F,`${t}-th-${P}-${j}`,!0,n)})},`h-${j}`))})}),o.jsx("tbody",{children:M.map((F,j)=>o.jsx("tr",{className:"border-t border-border/10",children:L.map((T,Q)=>o.jsx("td",{className:`${FC} ${Bg(E[Q]??null)}`,children:o.jsx("div",{className:Dg,children:ji(F[Q]??"",`${t}-td-${P}-${j}-${Q}`,!0,n)})},`c-${Q}`))},`r-${j}`))})]})},`${t}-table-${P}`)});continue}const y=Jv(c);if(y){const L=y.ordered,E=Zv(c),M=y.start,P=i,F=lk(e,i,E,L,!1);i=F.nextIndex,s.push({kind:"list",keyPrefix:`${t}-list-${P}`,ordered:L,start:L?M:void 0,renders:e5(F.items,`${t}-list-${P}`,n,a(0)-1)});continue}const v=[c.trimStart()],S=[a(i)],A=i;for(i+=1;i<e.length&&e[i].trim()&&!wy(e[i])&&!(i+1<e.length&&e[i].includes("|")&&Fg(e[i+1]));)v.push(e[i].trimStart()),S.push(a(i)),i+=1;const C=Cy(v,`${t}-p-${A}`,n);s.push({kind:"paragraph",keyPrefix:`${t}-p-${A}`,perLine:C.perLine,hardBreaks:C.hardBreaks,lineNums:S})}return s}function sne(e,t){return e.map(n=>{switch(n.kind){case"static":return n.node;case"paragraph":return o.jsx("p",{children:ky(n.perLine,n.hardBreaks,n.lineNums,n.keyPrefix,t)},n.keyPrefix);case"list":{const r=n.ordered?"ol":"ul";return o.jsx(r,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:t5(n.renders,t)},n.keyPrefix)}case"code":return o.jsx(Og,{code:n.code,lang:n.lang,blockKey:n.blockKey,codeStartLine:n.codeStartLine,lineRange:t},n.key)}})}let vm=null,z7=!1;const wm=16,ck=192;function ine(){return vm||(vm=B0(()=>import("./mermaid.core-mk9uZjla.js").then(e=>e.aJ),__vite__mapDeps([6,1,7])).then(e=>e.default??e).catch(e=>{throw vm=null,e})),vm}function one(e){z7||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),z7=!0)}function ane(e){const t=e.match(/\sviewBox=(["'])([^"']+)\1/i);if(!t)return e;const[,,n]=t,r=n.trim().split(/[\s,]+/).map(Number),[,,s,i]=r;if(!Number.isFinite(s)||!Number.isFinite(i)||s<=0||i<=0)return e;const a=Math.max(ck,Math.ceil(s)),c=Math.ceil(a/s*i);return e.replace(/<svg\b([^>]*)>/i,(u,f)=>`<svg${f.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${a}" height="${c}">`)}function lne(e){const t=e?.querySelector("svg");if(!t)return;let n;try{n=t.getBBox()}catch{return}if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return;const r=n.x-wm,s=n.y-wm,i=n.width+wm*2,a=n.height+wm*2,c=Math.max(ck,Math.ceil(i)),u=Math.ceil(c/i*a);t.setAttribute("viewBox",`${r} ${s} ${i} ${a}`),t.setAttribute("width",String(c)),t.setAttribute("height",String(u)),t.removeAttribute("style")}function cne(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t)return null;const n=t.replace(/^language-/,"");return S0(`code.${n}`)??n}function uk({code:e,blockKey:t}){const{t:n}=er(),[r,s]=x.useState(null),[i,a]=x.useState(!1),c=x.useRef(null),u=x.useContext(GC);x.useEffect(()=>{let p=!1;return s(null),a(!1),ine().then(async g=>{one(g);const y=`termdock-md-mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:v}=await g.render(y,e);p||s(ane(v))}).catch(()=>{p||a(!0)}),()=>{p=!0}},[t,e]),x.useLayoutEffect(()=>{r&&lne(c.current)},[r]);const f=x.useCallback(()=>{const p=c.current?.querySelector("svg")?.outerHTML??r;p&&u?.(p)},[u,r]);return i?o.jsx(Og,{code:e,lang:"mermaid",blockKey:`${t}-fallback`}):o.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[o.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),o.jsx("div",{className:"bg-surface p-3",children:r?o.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:n("rightSidebar.openMermaidDiagram"),onClick:p=>{p.stopPropagation(),f()},children:o.jsx("span",{ref:c,role:"img","aria-label":n("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:r}})}):o.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:n("rightSidebar.renderingDiagram")})})]})}function Og({code:e,lang:t,blockKey:n,codeStartLine:r,lineRange:s}){const i=cne(t),[a,c]=x.useState(null);x.useEffect(()=>{if(!i||!iC(e)){c(null);return}let f=!1;return oC().then(p=>{if(f||!p.registered(i)){f||c(null);return}try{c(aC(p,e,i))}catch{f||c(null)}}).catch(()=>{f||c(null)}),()=>{f=!0}},[n,e,i]);const u=a??(e||" ").split(`
188
188
  `).map(f=>[f||" "]);return o.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[t&&o.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:t}),o.jsx("pre",{className:`${Yv} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:o.jsx("code",{children:u.map((f,p)=>{const g=r!=null?r+p:null,y=!!(s&&g!=null&&g>=s.start&&g<=s.end);return o.jsxs("span",{"data-md-ref-start":g??void 0,"data-md-ref-end":g??void 0,"data-selected":y?"true":void 0,children:[f,p<u.length-1?`
189
189
  `:null]},`${n}-line-${p}`)})})})]})}function une(e,t,n,r,s){e=Qte(e);const i=Bte(e),a=Ote(e),c=[],u={markdownFilePath:t,rootPath:n,referenceDefinitions:i,footnoteDefinitions:Fte(e),headingSlugCounts:new Map,images:c,onImageOpen:r,footnotesLabel:s?.footnotes??"Footnotes",backToFootnoteLabel:s?.backToFootnote??(y=>`Back to footnote ${y}`)},f=[];let p=0;for(;p<e.length;){const y=e[p],v=y.trim();if(jg(y)||a.has(p)){p+=1;continue}if(!v){p+=1;continue}if(/^<details>\s*$/i.test(v)){const j=p;let T="Details";const Q=[];for(p+=1;p<e.length&&!/^<\/details>\s*$/i.test(e[p].trim());){const $=e[p].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);$?T=$[1].trim()||T:Q.push(e[p].trimStart()),p+=1}p<e.length&&(p+=1),f.push({key:`details-${j}`,startLine:j+1,endLine:p,content:o.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[o.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:ji(T,`details-${j}-summary`,!0,u)}),Q.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:ok(Q,`details-${j}`,u)})]})});continue}const S=nk(y);if(S){const j=[y],T=p;for(p+=1;p<e.length&&!S.selfContained&&!new RegExp(`</${S.tag}>`,"i").test(e[p]);)j.push(e[p]),p+=1;p<e.length&&!S.selfContained&&(j.push(e[p]),p+=1),f.push({key:`html-${T}`,startLine:T+1,endLine:p,content:o.jsx(tk,{html:j.join(`
190
190
  `)})});continue}const A=v.match(/^(```|~~~)\s*(.*)$/);if(A){const j=[],T=A[1],Q=A[2]?.trim(),$=p;for(p+=1;p<e.length&&!e[p].trim().startsWith(T);)j.push(e[p]),p+=1;p<e.length&&(p+=1),f.push({key:`code-${$}`,startLine:$+1,endLine:p,fineGrained:Q.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(Q.toLowerCase()),content:Q.toLowerCase()==="mermaid"?o.jsx(uk,{code:j.join(`
@@ -628,4 +628,4 @@ new file mode 100644
628
628
  @@ -0,0 +1,2 @@
629
629
  +export const second = true;
630
630
  +announce(second);`}};function pS(){if(typeof window>"u")return"kotlin";const t=new URLSearchParams(window.location.search).get("fixture");return t&&t in Ey?t:"kotlin"}function mS(){return typeof window>"u"?"unified":new URLSearchParams(window.location.search).get("view")==="split"?"split":"unified"}function gS(){if(typeof window>"u")return"words";const e=new URLSearchParams(window.location.search).get("inline");return e==="none"||e==="chars"||e==="words"?e:"words"}function xS(){return typeof window>"u"?!0:new URLSearchParams(window.location.search).get("wrap")!=="off"}function Are(){const[e,t]=x.useState(()=>pS()),[n,r]=x.useState(()=>mS()),[s,i]=x.useState(()=>yC()),[a,c]=x.useState(()=>gS()),[u,f]=x.useState(()=>xS()),p=Ey[e],g=x.useMemo(()=>Object.entries(Ey),[]),y=n==="split"&&!s?"unified":n;return x.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const v=window.matchMedia(Vv),S=()=>i(v.matches);return S(),v.addEventListener?.("change",S),()=>v.removeEventListener?.("change",S)},[]),x.useEffect(()=>{if(typeof window>"u")return;let v=window.location.search;const S=()=>{window.location.search!==v&&(v=window.location.search,t(pS()),r(mS()),c(gS()),f(xS()))};window.addEventListener("popstate",S),window.addEventListener("pageshow",S),window.addEventListener("focus",S);const A=window.setInterval(S,250);return()=>{window.removeEventListener("popstate",S),window.removeEventListener("pageshow",S),window.removeEventListener("focus",S),window.clearInterval(A)}},[]),o.jsx("div",{className:"min-h-screen bg-background-subtle text-foreground","data-diff-lab":!0,"data-diff-lab-fixture":e,"data-diff-lab-view":y,"data-diff-lab-requested-view":n,"data-diff-lab-inline":a,"data-diff-lab-wrap":u?"on":"off",children:o.jsxs("div",{className:"mx-auto flex min-h-screen max-w-[1180px] flex-col px-4 py-4",children:[o.jsxs("header",{className:"mb-3 flex flex-wrap items-center justify-between gap-3 border-b border-border/20 pb-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-semibold",children:"Diff Lab"}),o.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Fixed fixtures for iterating diff rendering without app auth, PWA state, or live Git data."})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("select",{value:e,onChange:v=>t(v.target.value),"aria-label":"Fixture",className:"h-8 rounded-md border border-border/30 bg-surface px-2 text-xs text-foreground outline-none",children:g.map(([v,S])=>o.jsx("option",{value:v,children:S.label},v))}),o.jsxs("div",{className:"inline-flex h-8 overflow-hidden rounded-full bg-surface-2 p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":y==="unified",className:`rounded-full px-3 text-xs font-semibold ${y==="unified"?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:"Unified"}),o.jsx("button",{type:"button",onClick:()=>r("split"),disabled:!s,"aria-pressed":y==="split",className:`rounded-full px-3 text-xs font-semibold ${y==="split"?"bg-surface-elevated text-foreground":"text-muted-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:"Split"})]}),o.jsx("div",{className:"inline-flex h-8 overflow-hidden rounded-full bg-surface-2 p-0.5",children:["none","words","chars"].map(v=>o.jsx("button",{type:"button",onClick:()=>c(v),className:`rounded-full px-3 text-xs font-semibold ${a===v?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:v},v))}),o.jsxs("button",{type:"button",onClick:()=>f(v=>!v),className:`h-8 rounded-full px-3 text-xs font-semibold ${u?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground"}`,children:["Wrap ",u?"on":"off"]})]})]}),o.jsx("main",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border/20 bg-surface",children:o.jsx(vC,{filePath:p.path,repoRoot:"/tmp/termdock-diff-lab",changedFile:{path:p.path,absolutePath:`/tmp/termdock-diff-lab/${p.path}`,repoRoot:"/tmp/termdock-diff-lab",status:"modified",staged:!1,unstaged:!0,untracked:!1,tracked:!0,canStage:!1,canUnstage:!1,canStash:!1,canRestoreWorktree:!1},diffOverride:p.diff,oldSourceOverride:p.oldSource,active:!0,wrap:u,showScrollHint:!u,viewType:y,inlineMode:a})})]})})}const Tk=40,Iy="/tmp/termdock-diff-review-lab";function bS(e,t){const n=[`diff --git a/${e} b/${e}`,`--- a/${e}`,`+++ b/${e}`,`@@ -1,${t} +1,${t} @@`];for(let r=0;r<t;r+=1)r%5===0&&n.push(`-const removed_${r} = ${r};`),r%3===0&&n.push(`+const added_${r} = ${r} * 2;`),n.push(` context line ${r} in ${e}`);return n.join(`
631
- `)}function Tre(e,t){return Array.from({length:Tk},(n,r)=>{const s=6+r*7%60,i=`src/module${String(r).padStart(2,"0")}/File${r}.ts`,a=`${Iy}/${i}`,c=bS(i,s),u=bS(i,1);return{key:a,path:i,absolutePath:a,status:"modified",repoRoot:Iy,displayName:`File${r}.ts`,displayDir:`src/module${String(r).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(r)?c:u,auditRecords:[]}})}function Cre(){const e=x.useMemo(()=>{if(typeof window>"u")return 0;const L=new URLSearchParams(window.location.search).get("delay"),E=L===null?0:Number.parseInt(L,10);return Number.isInteger(E)&&E>0?E:0},[]),t=e>0,[n,r]=x.useState(()=>new Set);x.useEffect(()=>{if(!t)return;const L=Array.from({length:Tk},(E,M)=>window.setTimeout(()=>{r(P=>{const F=new Set(P);return F.add(M),F})},e+M*20));return()=>L.forEach(E=>window.clearTimeout(E))},[t,e]);const s=x.useMemo(()=>Tre(n,t),[n,t]),i=x.useMemo(()=>[{key:"mock-repo",root:Iy,label:"diff-review-lab",files:s.map(L=>({key:L.key,path:L.path,absolutePath:L.absolutePath,displayName:L.displayName,displayDir:L.displayDir,status:L.status}))}],[s]),a=x.useMemo(()=>{if(typeof window>"u")return null;const L=new URLSearchParams(window.location.search).get("select");if(L===null)return null;const E=Number.parseInt(L,10);return Number.isInteger(E)&&E>=0&&E<s.length?E:null},[s.length]),[c,u]=x.useState(()=>a!==null?s[a].key:null),[f,p]=x.useState(()=>({key:a!==null?s[a].key:null,nonce:a!==null?1:0})),[g,y]=x.useState("list"),[v,S]=x.useState(new Set),[A,C]=x.useState(a!==null?1:0);return o.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground","data-diff-review-lab":!0,children:[o.jsxs("div",{className:"shrink-0 border-b border-border/20 px-3 py-2 text-xs text-muted-foreground",children:["DiffReview Lab · ",s.length," mock files · selected: ",o.jsx("span",{"data-lab-selected":!0,children:c??"none"})," · slide ",A]}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(Rg,{mobile:!0,backLabel:"Back",files:s,groups:i,selectedKey:c,scrollToKey:f.key,scrollToKeyNonce:f.nonce,mode:g,onModeChange:L=>{L!=="ai"&&y(L)},collapsedDirectoryKeys:v,onToggleDirectory:L=>S(E=>{const M=new Set(E);return M.has(L)?M.delete(L):M.add(L),M}),onSelectFile:L=>{u(L.key),p(E=>({key:L.key,nonce:E.nonce+1}))},onMobileSlideChange:C,renderLeading:()=>null,renderStreamBadge:L=>o.jsx("span",{className:"text-[10px] text-muted-foreground",children:L}),wrap:!0,showScrollHint:!1,activePane:!0})})]})}const kre=6e4,Wb="termdock:build-id:v1";let yS=!1;function vS(){yS||(yS=!0,window.setTimeout(()=>{window.location.reload()},80))}function Ry(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function _re(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function Lre(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&Ry(e)})})}function Ere(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="1788441613757",t=window.localStorage.getItem(Wb);if(t&&t!==e){_re().finally(()=>{window.localStorage.setItem(Wb,e),vS()});return}t!==e&&window.localStorage.setItem(Wb,e);let n=null;navigator.serviceWorker.addEventListener("controllerchange",vS),window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(r=>{Lre(r),Ry(r);const s=()=>{document.visibilityState==="visible"&&r.update().then(()=>Ry(r)).catch(()=>{})};s(),n=window.setInterval(s,kre),document.addEventListener("visibilitychange",s)}).catch(()=>{})}),window.addEventListener("beforeunload",()=>{n!==null&&window.clearInterval(n)})}cQ();Ere();try{const e=JSON.parse(window.localStorage.getItem("termdock-color-theme")||"null");(e==="dark"||e==="light")&&(document.documentElement.dataset.theme=e,rT(e))}catch{}function Ire(){const{t:e}=er(),[t,n]=x.useState(null),[r,s]=x.useState(null),i=x.useCallback(async()=>{try{const a=await AI();n(a),s(null)}catch(a){s(a instanceof Error?a.message:"Failed to query auth status")}},[]);return x.useEffect(()=>{i()},[i]),x.useEffect(()=>{const a=()=>{n(c=>c&&{...c,authenticated:!1})};return window.addEventListener(yh,a),()=>window.removeEventListener(yh,a)},[]),t===null?o.jsx("div",{className:"flex w-screen items-center justify-center bg-background text-muted-foreground",style:{height:"var(--app-vh, 100vh)"},children:r?`${e("common.error")}: ${r}`:e("common.loading")}):t.enabled&&!t.authenticated?o.jsx(wre,{onLoginSuccess:i}):o.jsx(yre,{})}z_.createRoot(document.getElementById("root")).render(o.jsx(D.StrictMode,{children:o.jsx(cN,{children:o.jsx(cA,{children:(()=>{const e=new URLSearchParams(window.location.search);return e.get("dag-playground")==="1"?o.jsx(Sre,{}):e.get("diff-review-lab")==="1"?o.jsx(Cre,{}):e.get("diff-lab")==="1"?o.jsx(Are,{}):o.jsx(Ire,{})})()})})}));export{zM as M,Fs as R,jD as S,B0 as _,qM as a,YM as b,kt as c,o as j,er as u,TE as v};
631
+ `)}function Tre(e,t){return Array.from({length:Tk},(n,r)=>{const s=6+r*7%60,i=`src/module${String(r).padStart(2,"0")}/File${r}.ts`,a=`${Iy}/${i}`,c=bS(i,s),u=bS(i,1);return{key:a,path:i,absolutePath:a,status:"modified",repoRoot:Iy,displayName:`File${r}.ts`,displayDir:`src/module${String(r).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(r)?c:u,auditRecords:[]}})}function Cre(){const e=x.useMemo(()=>{if(typeof window>"u")return 0;const L=new URLSearchParams(window.location.search).get("delay"),E=L===null?0:Number.parseInt(L,10);return Number.isInteger(E)&&E>0?E:0},[]),t=e>0,[n,r]=x.useState(()=>new Set);x.useEffect(()=>{if(!t)return;const L=Array.from({length:Tk},(E,M)=>window.setTimeout(()=>{r(P=>{const F=new Set(P);return F.add(M),F})},e+M*20));return()=>L.forEach(E=>window.clearTimeout(E))},[t,e]);const s=x.useMemo(()=>Tre(n,t),[n,t]),i=x.useMemo(()=>[{key:"mock-repo",root:Iy,label:"diff-review-lab",files:s.map(L=>({key:L.key,path:L.path,absolutePath:L.absolutePath,displayName:L.displayName,displayDir:L.displayDir,status:L.status}))}],[s]),a=x.useMemo(()=>{if(typeof window>"u")return null;const L=new URLSearchParams(window.location.search).get("select");if(L===null)return null;const E=Number.parseInt(L,10);return Number.isInteger(E)&&E>=0&&E<s.length?E:null},[s.length]),[c,u]=x.useState(()=>a!==null?s[a].key:null),[f,p]=x.useState(()=>({key:a!==null?s[a].key:null,nonce:a!==null?1:0})),[g,y]=x.useState("list"),[v,S]=x.useState(new Set),[A,C]=x.useState(a!==null?1:0);return o.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground","data-diff-review-lab":!0,children:[o.jsxs("div",{className:"shrink-0 border-b border-border/20 px-3 py-2 text-xs text-muted-foreground",children:["DiffReview Lab · ",s.length," mock files · selected: ",o.jsx("span",{"data-lab-selected":!0,children:c??"none"})," · slide ",A]}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(Rg,{mobile:!0,backLabel:"Back",files:s,groups:i,selectedKey:c,scrollToKey:f.key,scrollToKeyNonce:f.nonce,mode:g,onModeChange:L=>{L!=="ai"&&y(L)},collapsedDirectoryKeys:v,onToggleDirectory:L=>S(E=>{const M=new Set(E);return M.has(L)?M.delete(L):M.add(L),M}),onSelectFile:L=>{u(L.key),p(E=>({key:L.key,nonce:E.nonce+1}))},onMobileSlideChange:C,renderLeading:()=>null,renderStreamBadge:L=>o.jsx("span",{className:"text-[10px] text-muted-foreground",children:L}),wrap:!0,showScrollHint:!1,activePane:!0})})]})}const kre=6e4,Wb="termdock:build-id:v1";let yS=!1;function vS(){yS||(yS=!0,window.setTimeout(()=>{window.location.reload()},80))}function Ry(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function _re(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function Lre(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&Ry(e)})})}function Ere(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="1788442634596",t=window.localStorage.getItem(Wb);if(t&&t!==e){_re().finally(()=>{window.localStorage.setItem(Wb,e),vS()});return}t!==e&&window.localStorage.setItem(Wb,e);let n=null;navigator.serviceWorker.addEventListener("controllerchange",vS),window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(r=>{Lre(r),Ry(r);const s=()=>{document.visibilityState==="visible"&&r.update().then(()=>Ry(r)).catch(()=>{})};s(),n=window.setInterval(s,kre),document.addEventListener("visibilitychange",s)}).catch(()=>{})}),window.addEventListener("beforeunload",()=>{n!==null&&window.clearInterval(n)})}cQ();Ere();try{const e=JSON.parse(window.localStorage.getItem("termdock-color-theme")||"null");(e==="dark"||e==="light")&&(document.documentElement.dataset.theme=e,rT(e))}catch{}function Ire(){const{t:e}=er(),[t,n]=x.useState(null),[r,s]=x.useState(null),i=x.useCallback(async()=>{try{const a=await AI();n(a),s(null)}catch(a){s(a instanceof Error?a.message:"Failed to query auth status")}},[]);return x.useEffect(()=>{i()},[i]),x.useEffect(()=>{const a=()=>{n(c=>c&&{...c,authenticated:!1})};return window.addEventListener(yh,a),()=>window.removeEventListener(yh,a)},[]),t===null?o.jsx("div",{className:"flex w-screen items-center justify-center bg-background text-muted-foreground",style:{height:"var(--app-vh, 100vh)"},children:r?`${e("common.error")}: ${r}`:e("common.loading")}):t.enabled&&!t.authenticated?o.jsx(wre,{onLoginSuccess:i}):o.jsx(yre,{})}z_.createRoot(document.getElementById("root")).render(o.jsx(D.StrictMode,{children:o.jsx(cN,{children:o.jsx(cA,{children:(()=>{const e=new URLSearchParams(window.location.search);return e.get("dag-playground")==="1"?o.jsx(Sre,{}):e.get("diff-review-lab")==="1"?o.jsx(Cre,{}):e.get("diff-lab")==="1"?o.jsx(Are,{}):o.jsx(Ire,{})})()})})}));export{zM as M,Fs as R,jD as S,B0 as _,qM as a,YM as b,kt as c,o as j,er as u,TE as v};