@gramlot/gramlot 0.3.31 → 0.3.33

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 (65) hide show
  1. package/dist/components/charts/__init__.py +1 -1
  2. package/dist/components/charts/assets/collection.js +36 -21
  3. package/dist/components/charts/assets/index.js +1 -1
  4. package/dist/components/charts/grammar.json +15482 -232
  5. package/dist/components/grid/__init__.py +1 -1
  6. package/dist/components/grid/assets/collection.js +5 -5
  7. package/dist/components/grid/assets/index.js +1 -1
  8. package/dist/gramlot.js +22 -10
  9. package/dist/gramlot.min.js +2 -2
  10. package/dist/standard-collections.js +1 -1
  11. package/package.json +1 -1
  12. package/src/components/chart-boxplot-options.js +22 -0
  13. package/src/components/chart-candlestick-options.js +27 -0
  14. package/src/components/chart-controls.js +28 -6
  15. package/src/components/chart-domains.js +1 -1
  16. package/src/components/chart-engines/echarts.js +18 -0
  17. package/src/components/chart-fields.js +11 -1
  18. package/src/components/chart-funnel-options.js +19 -0
  19. package/src/components/chart-gauge-options.js +98 -0
  20. package/src/components/chart-gauge.js +105 -0
  21. package/src/components/chart-heatmap-options.js +29 -0
  22. package/src/components/chart-notice.js +126 -0
  23. package/src/components/chart-pane.js +7 -1
  24. package/src/components/chart-parallel-options.js +24 -0
  25. package/src/components/chart-radar-options.js +29 -0
  26. package/src/components/chart-renderer.js +2 -8
  27. package/src/components/chart-sankey-options.js +43 -0
  28. package/src/components/chart-sunburst-options.js +12 -0
  29. package/src/components/chart-syntax.js +82 -0
  30. package/src/components/chart-time.js +2 -1
  31. package/src/components/chart-treemap-options.js +16 -0
  32. package/src/components/chart-type-data.js +62 -0
  33. package/src/components/chart-types/area.js +6 -1
  34. package/src/components/chart-types/bar.js +6 -1
  35. package/src/components/chart-types/bar3D.js +7 -1
  36. package/src/components/chart-types/boxplot.js +11 -0
  37. package/src/components/chart-types/candlestick.js +10 -0
  38. package/src/components/chart-types/donut.js +6 -1
  39. package/src/components/chart-types/funnel.js +7 -0
  40. package/src/components/chart-types/heatmap.js +8 -0
  41. package/src/components/chart-types/horizontalBar.js +6 -1
  42. package/src/components/chart-types/index.js +21 -1
  43. package/src/components/chart-types/line.js +6 -1
  44. package/src/components/chart-types/line3D.js +7 -1
  45. package/src/components/chart-types/lines3D.js +7 -1
  46. package/src/components/chart-types/map.js +7 -1
  47. package/src/components/chart-types/map3D.js +6 -1
  48. package/src/components/chart-types/mapBar3D.js +6 -1
  49. package/src/components/chart-types/parallel.js +7 -0
  50. package/src/components/chart-types/pie.js +6 -1
  51. package/src/components/chart-types/polygons3D.js +7 -1
  52. package/src/components/chart-types/radar.js +7 -0
  53. package/src/components/chart-types/sankey.js +8 -0
  54. package/src/components/chart-types/scatter.js +6 -1
  55. package/src/components/chart-types/scatter3D.js +7 -1
  56. package/src/components/chart-types/stackedArea.js +6 -1
  57. package/src/components/chart-types/stackedBar.js +6 -1
  58. package/src/components/chart-types/sunburst.js +7 -0
  59. package/src/components/chart-types/surface.js +7 -1
  60. package/src/components/chart-types/treemap.js +7 -0
  61. package/src/components/charts.js +60 -13
  62. package/src/components/grid-selection.js +10 -3
  63. package/src/components/registry.js +9 -5
  64. package/src/page-store-connection.js +15 -5
  65. package/themes/gramlot-base/theme.css +2 -0
@@ -1,20 +1,20 @@
1
- import{a as Cu}from"./modules/chunk-2CCTLZE7.js";import{a as Ge,b as Es,c as Kt,d as ni}from"./modules/chunk-RMRBEYTI.js";var ht=Ge(ae=>{"use strict";function Wl(t,e,r){if(r===void 0&&(r=Array.prototype),t&&typeof r.find=="function")return r.find.call(t,e);for(var n=0;n<t.length;n++)if(ft(t,n)){var i=t[n];if(e.call(void 0,i,n,t))return i}}function Ct(t,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(t=e.create(null,e.getOwnPropertyDescriptors(t))),e&&typeof e.freeze=="function"?e.freeze(t):t}function ft(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Jl(t,e){if(t===null||typeof t!="object")throw new TypeError("target is not an object");for(var r in e)ft(e,r)&&(t[r]=e[r]);return t}var Qs=Ct({allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,default:!0,defer:!0,disabled:!0,formnovalidate:!0,hidden:!0,ismap:!0,itemscope:!0,loop:!0,multiple:!0,muted:!0,nomodule:!0,novalidate:!0,open:!0,playsinline:!0,readonly:!0,required:!0,reversed:!0,selected:!0});function Zl(t){return ft(Qs,t.toLowerCase())}var Ks=Ct({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ql(t){return ft(Ks,t.toLowerCase())}var ar=Ct({script:!1,style:!1,textarea:!0,title:!0});function Kl(t){var e=t.toLowerCase();return ft(ar,e)&&!ar[e]}function ec(t){var e=t.toLowerCase();return ft(ar,e)&&ar[e]}function eo(t){return t===ur.HTML}function tc(t){return eo(t)||t===ur.XML_XHTML_APPLICATION}var ur=Ct({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),rc=Object.keys(ur).map(function(t){return ur[t]});function nc(t){return rc.indexOf(t)>-1}var ic=Ct({HTML:"http://www.w3.org/1999/xhtml",SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});ae.assign=Jl;ae.find=Wl;ae.freeze=Ct;ae.HTML_BOOLEAN_ATTRIBUTES=Qs;ae.HTML_RAW_TEXT_ELEMENTS=ar;ae.HTML_VOID_ELEMENTS=Ks;ae.hasDefaultHTMLNamespace=tc;ae.hasOwn=ft;ae.isHTMLBooleanAttribute=Zl;ae.isHTMLRawTextElement=Kl;ae.isHTMLEscapableRawTextElement=ec;ae.isHTMLMimeType=eo;ae.isHTMLVoidElement=Ql;ae.isValidMimeType=nc;ae.MIME_TYPE=ur;ae.NAMESPACE=ic});var dr=Ge(hr=>{"use strict";var sc=ht();function ro(t,e){t.prototype=Object.create(Error.prototype,{constructor:{value:t},name:{value:t.name,enumerable:!0,writable:e}})}var cr=sc.freeze({Error:"Error",IndexSizeError:"IndexSizeError",DomstringSizeError:"DomstringSizeError",HierarchyRequestError:"HierarchyRequestError",WrongDocumentError:"WrongDocumentError",InvalidCharacterError:"InvalidCharacterError",NoDataAllowedError:"NoDataAllowedError",NoModificationAllowedError:"NoModificationAllowedError",NotFoundError:"NotFoundError",NotSupportedError:"NotSupportedError",InUseAttributeError:"InUseAttributeError",InvalidStateError:"InvalidStateError",SyntaxError:"SyntaxError",InvalidModificationError:"InvalidModificationError",NamespaceError:"NamespaceError",InvalidAccessError:"InvalidAccessError",ValidationError:"ValidationError",TypeMismatchError:"TypeMismatchError",SecurityError:"SecurityError",NetworkError:"NetworkError",AbortError:"AbortError",URLMismatchError:"URLMismatchError",QuotaExceededError:"QuotaExceededError",TimeoutError:"TimeoutError",InvalidNodeTypeError:"InvalidNodeTypeError",DataCloneError:"DataCloneError",EncodingError:"EncodingError",NotReadableError:"NotReadableError",UnknownError:"UnknownError",ConstraintError:"ConstraintError",DataError:"DataError",TransactionInactiveError:"TransactionInactiveError",ReadOnlyError:"ReadOnlyError",VersionError:"VersionError",OperationError:"OperationError",NotAllowedError:"NotAllowedError",OptOutError:"OptOutError"}),no=Object.keys(cr);function io(t){return typeof t=="number"&&t>=1&&t<=25}function oc(t){return typeof t=="string"&&t.substring(t.length-cr.Error.length)===cr.Error}function fr(t,e){io(t)?(this.name=no[t],this.message=e||""):(this.message=t,this.name=oc(e)?e:cr.Error),Error.captureStackTrace&&Error.captureStackTrace(this,fr)}ro(fr,!0);Object.defineProperties(fr.prototype,{code:{enumerable:!0,get:function(){var t=no.indexOf(this.name);return io(t)?t:0}}});var so={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},bi=Object.entries(so);for(lr=0;lr<bi.length;lr++)to=bi[lr][0],fr[to]=bi[lr][1];var to,lr;function Di(t,e,r){this.message=t,this.locator=e,this.cause=r,Error.captureStackTrace&&Error.captureStackTrace(this,Di)}ro(Di);hr.DOMException=fr;hr.DOMExceptionName=cr;hr.ExceptionCode=so;hr.ParseError=Di});var Si=Ge(M=>{"use strict";function fo(t){try{typeof t!="function"&&(t=RegExp);var e=new t("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var Nt=fo();function Qe(t){if(t.source[0]!=="[")throw new Error(t+" can not be used with chars");return t.source.slice(1,t.source.lastIndexOf("]"))}function _t(t,e){if(t.source[0]!=="[")throw new Error("/"+t.source+"/ can not be used with chars_without");if(!e||typeof e!="string")throw new Error(JSON.stringify(e)+" is not a valid search");if(t.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+t.source+"/");if(e==="-"&&t.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+t.source+"/");return new RegExp(t.source.replace(e,""),Nt?"u":"")}function R(t){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(r){var n=typeof r=="string";if(n&&e===void 0&&r==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return n?r:r.source}).join(""),Nt?"u":"")}function N(t){if(arguments.length===0)throw new Error("no parameters provided");return R.apply(N,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var ac="\uFFFD",Ke=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;Nt&&(Ke=R("[",Qe(Ke),"\\u{10000}-\\u{10FFFF}","]"));var uc=new RegExp("[^"+Qe(Ke)+"]",Nt?"u":""),nn=/[\x20\x09\x0D\x0A]/,lc=Qe(nn),j=R(nn,"+"),G=R(nn,"*"),pr=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;Nt&&(pr=R("[",Qe(pr),"\\u{10000}-\\u{10FFFF}","]"));var cc=Qe(pr),xi=R("[",cc,Qe(/[-.0-9\xB7]/),Qe(/[\u0300-\u036F\u203F-\u2040]/),"]"),we=R(pr,xi,"*"),fc=R("^",we,"$"),oo=R(xi,"+"),hc=R("&",we,";"),dc=N(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),mr=N(hc,"|",dc),gr=R("%",we,";"),Ai=N(R('"',N(/[^%&"]/,"|",gr,"|",mr),"*",'"'),"|",R("'",N(/[^%&']/,"|",gr,"|",mr),"*","'")),pc=N('"',N(/[^<&"]/,"|",mr),"*",'"',"|","'",N(/[^<&']/,"|",mr),"*","'"),mc=_t(pr,":"),gc=_t(xi,":"),vi=R(mc,gc,"*"),yc=R("^",vi,"$"),yr=R(vi,N(":",vi),"?"),wc=R("^",yr,"$"),Ec=R("(",yr,")"),St=N(/"[^"]*"|'[^']*'/),bc=R(/^<\?/,"(",we,")",N(j,"(?!",nn,")(",Ke,"*?)"),"?",/\?>/),ao=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,wr=N('"',ao,'*"',"|","'",_t(ao,"'"),"*'"),ho="<!--",po="-->",Dc=R(ho,N(_t(Ke,"-"),"|",R("-",_t(Ke,"-"))),"*",po),uo="#PCDATA",vc=N(R(/\(/,G,uo,N(G,/\|/,G,yr),"*",G,/\)\*/),"|",R(/\(/,G,uo,G,/\)/)),Tc=/[?*+]?/,xc=R(/\([^>]+\)/,Tc),Ac=N("EMPTY","|","ANY","|",vc,"|",xc),Cc="<!ELEMENT",_c=R(Cc,j,N(yr,"|",gr),j,N(Ac,"|",gr),G,">"),Sc=R("NOTATION",j,/\(/,G,we,N(G,/\|/,G,we),"*",G,/\)/),Nc=R(/\(/,G,oo,N(G,/\|/,G,oo),"*",G,/\)/),Ic=N(Sc,"|",Nc),Oc=N(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Ic),Bc=N(/#REQUIRED|#IMPLIED/,"|",N(N("#FIXED",j),"?",pc)),Mc=N(j,we,j,Oc,j,Bc),kc="<!ATTLIST",Fc=R(kc,j,we,Mc,"*",G,">"),Ti="about:legacy-compat",Rc=N('"'+Ti+'"',"|","'"+Ti+"'"),Ci="SYSTEM",sn="PUBLIC",on=N(N(Ci,j,St),"|",N(sn,j,wr,j,St)),Lc=R("^",N(N(Ci,j,"(?<SystemLiteralOnly>",St,")"),"|",N(sn,j,"(?<PubidLiteral>",wr,")",j,"(?<SystemLiteral>",St,")"))),Pc=R("^",wr,"$"),Uc=R("^",St,"$"),$c=N(j,"NDATA",j,we),qc=N(Ai,"|",N(on,$c,"?")),mo="<!ENTITY",Vc=R(mo,j,we,j,qc,G,">"),zc=N(Ai,"|",on),jc=R(mo,j,"%",j,we,j,zc,G,">"),Hc=N(Vc,"|",jc),Gc=R(sn,j,wr),Xc=R("<!NOTATION",j,we,j,N(on,"|",Gc),G,">"),_i=R(G,"=",G),lo=/1[.]\d+/,Yc=R(j,"version",_i,N("'",lo,"'","|",'"',lo,'"')),co=/[A-Za-z][-A-Za-z0-9._]*/,Wc=N(j,"encoding",_i,N('"',co,'"',"|","'",co,"'")),Jc=N(j,"standalone",_i,N("'",N("yes","|","no"),"'","|",'"',N("yes","|","no"),'"')),Zc=R(/^<\?xml/,Yc,Wc,"?",Jc,"?",G,/\?>/),Qc="<!DOCTYPE",Kc="<![CDATA[",ef="]]>",tf=/<!\[CDATA\[/,rf=/\]\]>/,nf=R(Ke,"*?",rf),sf=R(tf,nf);M.chars=Qe;M.chars_without=_t;M.detectUnicodeSupport=fo;M.reg=R;M.regg=N;M.ABOUT_LEGACY_COMPAT=Ti;M.ABOUT_LEGACY_COMPAT_SystemLiteral=Rc;M.AttlistDecl=Fc;M.CDATA_START=Kc;M.CDATA_END=ef;M.CDSect=sf;M.Char=Ke;M.Comment=Dc;M.COMMENT_START=ho;M.COMMENT_END=po;M.DOCTYPE_DECL_START=Qc;M.elementdecl=_c;M.EntityDecl=Hc;M.EntityValue=Ai;M.ExternalID=on;M.ExternalID_match=Lc;M.Name=we;M.Name_exact=fc;M.NCName_exact=yc;M.NotationDecl=Xc;M.Reference=mr;M.PEReference=gr;M.PI=bc;M.PUBLIC=sn;M.PubidLiteral=wr;M.PubidLiteral_match=Pc;M.QName=yr;M.QName_exact=wc;M.QName_group=Ec;M.S=j;M.SChar_s=lc;M.S_OPT=G;M.SYSTEM=Ci;M.SystemLiteral=St;M.SystemLiteral_match=Uc;M.InvalidChar=uc;M.UNICODE_REPLACEMENT_CHARACTER=ac;M.UNICODE_SUPPORT=Nt;M.XMLDecl=Zc});var Pi=Ge(W=>{"use strict";var Te=ht(),ke=Te.find,of=Te.hasDefaultHTMLNamespace,Ot=Te.hasOwn,af=Te.isHTMLMimeType,uf=Te.isHTMLRawTextElement,lf=Te.isHTMLVoidElement,Er=Te.MIME_TYPE,Fe=Te.NAMESPACE,de=Symbol(),vo=dr(),A=vo.DOMException,he=vo.DOMExceptionName,Y=Si();function me(t){if(t!==de)throw new TypeError("Illegal constructor")}function cf(t){return t!==""}function ff(t){return t?t.split(/[\t\n\f\r ]+/).filter(cf):[]}function hf(t,e){return Ot(t,e)||(t[e]=!0),t}function go(t){if(!t)return[];var e=ff(t);return Object.keys(e.reduce(hf,{}))}function df(t){return function(e){return t&&t.indexOf(e)!==-1}}function To(t){if(!Y.QName_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+t+'"')}function Ii(t,e){To(e),t=t||null;var r=null,n=e;if(e.indexOf(":")>=0){var i=e.split(":");r=i[0],n=i[1]}if(r!==null&&t===null)throw new A(A.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(r==="xml"&&t!==Te.NAMESPACE.XML)throw new A(A.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((r==="xmlns"||e==="xmlns")&&t!==Te.NAMESPACE.XMLNS)throw new A(A.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(t===Te.NAMESPACE.XMLNS&&r!=="xmlns"&&e!=="xmlns")throw new A(A.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[t,r,n]}function kt(t,e){for(var r in t)Ot(t,r)&&(e[r]=t[r])}function ge(t,e){var r=t.prototype;if(!(r instanceof e)){let n=function(){};n.prototype=e.prototype,n=new n,kt(r,n),t.prototype=r=n}r.constructor!=t&&(typeof t!="function"&&console.error("unknown Class:"+t),r.constructor=t)}var ye={},ve=ye.ELEMENT_NODE=1,Bt=ye.ATTRIBUTE_NODE=2,br=ye.TEXT_NODE=3,xo=ye.CDATA_SECTION_NODE=4,Ao=ye.ENTITY_REFERENCE_NODE=5,pf=ye.ENTITY_NODE=6,Oi=ye.PROCESSING_INSTRUCTION_NODE=7,Bi=ye.COMMENT_NODE=8,It=ye.DOCUMENT_NODE=9,Co=ye.DOCUMENT_TYPE_NODE=10,et=ye.DOCUMENT_FRAGMENT_NODE=11,mf=ye.NOTATION_NODE=12,X=Te.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function _o(t,e){if(e.length<t.length)return _o(e,t);var r=null;for(var n in t){if(t[n]!==e[n])return r;r=t[n]}return r}function yo(t){return t.guid||(t.guid=Math.random()),t.guid}function te(){}te.prototype={length:0,item:function(t){return t>=0&&t<this.length?this[t]:null},toString:function(t){var e;typeof t=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:t}:t?e={requireWellFormed:!!t.requireWellFormed,splitCDATASections:t.splitCDATASections!==!1,nodeFilter:t.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var r=[],n=0;n<this.length;n++)Li(this[n],r,null,e);return r.join("")},filter:function(t){return Array.prototype.filter.call(this,t)},indexOf:function(t){return Array.prototype.indexOf.call(this,t)}};te.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Me(t,e){this._node=t,this._refresh=e,cn(this)}function cn(t){var e=t._node._inc||t._node.ownerDocument._inc;if(t._inc!==e){var r=t._refresh(t._node);if(Po(t,"length",r.length),!t.$$length||r.length<t.$$length)for(var n=r.length;n in t;n++)Ot(t,n)&&delete t[n];kt(r,t),t._inc=e}}Me.prototype.item=function(t){return cn(this),this[t]||null};ge(Me,te);function Mt(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function So(t,e){for(var r=0;r<t.length;){if(t[r]===e)return r;r++}}function Mi(t,e,r){if(!e)return t._noNsIndex;var n=t._nsIndex[e];return!n&&r&&(n=t._nsIndex[e]=Object.create(null)),n}function gf(t,e,r){var n=Mi(t,e,!1),i=n&&n[r];return i||null}function yf(t,e){Mi(t,e.namespaceURI,!0)[e.localName]=e}function wf(t,e){var r=Mi(t,e.namespaceURI,!1);r&&delete r[e.localName]}function Ef(t,e,r,n){if(n?e[So(e,n)]=r:(e[e.length]=r,e.length++),yf(e,r),t){r.ownerElement=t;var i=t.ownerDocument;i&&(n&&Oo(i,t,n),bf(i,t,r))}}function wo(t,e,r){var n=So(e,r);if(n>=0){for(var i=e.length-1;n<=i;)e[n]=e[++n];if(e.length=i,wf(e,r),t){var s=t.ownerDocument;s&&Oo(s,t,r),r.ownerElement=null}}}Mt.prototype={length:0,item:te.prototype.item,getNamedItem:function(t){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());for(var e=0;e<this.length;){var r=this[e];if(r.nodeName===t)return r;e++}return null},setNamedItem:function(t){var e=t.ownerElement;if(e&&e!==this._ownerElement)throw new A(A.INUSE_ATTRIBUTE_ERR);var r=gf(this,t.namespaceURI,t.localName);return r===t?t:(Ef(this._ownerElement,this,t,r),r)},setNamedItemNS:function(t){return this.setNamedItem(t)},removeNamedItem:function(t){var e=this.getNamedItem(t);if(!e)throw new A(A.NOT_FOUND_ERR,t);return wo(this._ownerElement,this,e),e},removeNamedItemNS:function(t,e){var r=this.getNamedItemNS(t,e);if(!r)throw new A(A.NOT_FOUND_ERR,t?t+" : "+e:e);return wo(this._ownerElement,this,r),r},getNamedItemNS:function(t,e){t||(t=null);for(var r=0;r<this.length;){var n=this[r];if(n.localName===e&&n.namespaceURI===t)return n;r++}return null}};Mt.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function No(){}No.prototype={hasFeature:function(t,e){return!0},createDocument:function(t,e,r){var n=Er.XML_APPLICATION;t===Fe.HTML?n=Er.XML_XHTML_APPLICATION:t===Fe.SVG&&(n=Er.XML_SVG_IMAGE);var i=new qe(de,{contentType:n});if(i.implementation=this,i.childNodes=new te,i.doctype=r||null,r&&i.appendChild(r),e){var s=i.createElementNS(t,e);i.appendChild(s)}return i},createDocumentType:function(t,e,r,n){To(t);var i=new dn(de);return i.name=t,i.nodeName=t,i.publicId=e||"",i.systemId=r||"",i.internalSubset=n||"",i.childNodes=new te,i},createHTMLDocument:function(t){var e=new qe(de,{contentType:Er.HTML});if(e.implementation=this,e.childNodes=new te,t!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var r=e.createElement("html");e.appendChild(r);var n=e.createElement("head");if(r.appendChild(n),typeof t=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(t)),n.appendChild(i)}r.appendChild(e.createElement("body"))}return e}};function P(t){me(t)}P.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,parentNode:null,get parentElement(){return this.parentNode&&this.parentNode.nodeType===this.ELEMENT_NODE?this.parentNode:null},childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,baseURI:"about:blank",get isConnected(){var t=this.getRootNode();return t&&t.nodeType===t.DOCUMENT_NODE},contains:function(t){if(!t)return!1;var e=t;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(t){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(t){if(!t)return!1;for(var e=[{node:this,other:t}];e.length>0;){var r=e.pop(),n=r.node,i=r.other;if(n.nodeType!==i.nodeType)return!1;switch(n.nodeType){case n.DOCUMENT_TYPE_NODE:if(n.name!==i.name||n.publicId!==i.publicId||n.systemId!==i.systemId)return!1;break;case n.ELEMENT_NODE:if(n.namespaceURI!==i.namespaceURI||n.prefix!==i.prefix||n.localName!==i.localName||n.attributes.length!==i.attributes.length)return!1;for(var s=0;s<n.attributes.length;s++){var o=n.attributes.item(s),a=i.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case n.ATTRIBUTE_NODE:if(n.namespaceURI!==i.namespaceURI||n.localName!==i.localName||n.value!==i.value)return!1;break;case n.PROCESSING_INSTRUCTION_NODE:if(n.target!==i.target||n.data!==i.data)return!1;break;case n.TEXT_NODE:case n.CDATA_SECTION_NODE:case n.COMMENT_NODE:if(n.data!==i.data)return!1;break}if(n.childNodes.length!==i.childNodes.length)return!1;for(var s=n.childNodes.length-1;s>=0;s--)e.push({node:n.childNodes[s],other:i.childNodes[s]})}return!0},isSameNode:function(t){return this===t},insertBefore:function(t,e){return ln(this,t,e)},replaceChild:function(t,e){ln(this,t,e,ko),e&&this.removeChild(e)},removeChild:function(t){return Bo(this,t)},appendChild:function(t){return this.insertBefore(t,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(t){return Lo(this.ownerDocument||this,this,t)},normalize:function(){ue(this,null,{enter:function(t){for(var e=t.firstChild;e;){var r=e.nextSibling;if(r!==null&&r.nodeType===br&&e.nodeType===br){for(var n=[],i=r;i!==null&&i.nodeType===br;)n.push(i.data),i=i.nextSibling;for(var s=e.nextSibling;s!==i;){var o=s.nextSibling;s.parentNode=null,s.previousSibling=null,s.nextSibling=null,s=o}e.nextSibling=i,i!==null?i.previousSibling=e:t.lastChild=e,e.appendData(n.join("")),ki(t.ownerDocument,t),e=i}else e=r}return!0}})},isSupported:function(t,e){return this.ownerDocument.implementation.hasFeature(t,e)},lookupPrefix:function(t){for(var e=this;e;){var r=e._nsMap;if(r){for(var n in r)if(Ot(r,n)&&r[n]===t)return n}e=e.nodeType==Bt?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(t){for(var e=this;e;){var r=e._nsMap;if(r&&Ot(r,t))return r[t];e=e.nodeType==Bt?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(t){var e=this.lookupPrefix(t);return e==null},compareDocumentPosition:function(t){if(this===t)return 0;var e=t,r=this,n=null,i=null;if(e instanceof dt&&(n=e,e=n.ownerElement),r instanceof dt&&(i=r,r=i.ownerElement,n&&e&&r===e))for(var s=0,o;o=r.attributes[s];s++){if(o===n)return X.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+X.DOCUMENT_POSITION_PRECEDING;if(o===i)return X.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+X.DOCUMENT_POSITION_FOLLOWING}if(!e||!r||r.ownerDocument!==e.ownerDocument)return X.DOCUMENT_POSITION_DISCONNECTED+X.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(yo(r.ownerDocument)>yo(e.ownerDocument)?X.DOCUMENT_POSITION_FOLLOWING:X.DOCUMENT_POSITION_PRECEDING);if(i&&e===r)return X.DOCUMENT_POSITION_CONTAINS+X.DOCUMENT_POSITION_PRECEDING;if(n&&e===r)return X.DOCUMENT_POSITION_CONTAINED_BY+X.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===r)return X.DOCUMENT_POSITION_CONTAINED_BY+X.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=r.parentNode;c;){if(!n&&c===e)return X.DOCUMENT_POSITION_CONTAINS+X.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var f=_o(a,u);for(var h in f.childNodes){var d=f.childNodes[h];if(d===r)return X.DOCUMENT_POSITION_FOLLOWING;if(d===e)return X.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(d)>=0)return X.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(d)>=0)return X.DOCUMENT_POSITION_PRECEDING}return 0}};function Io(t){return t=="<"&&"&lt;"||t==">"&&"&gt;"||t=="&"&&"&amp;"||t=='"'&&"&quot;"||"&#"+t.charCodeAt()+";"}kt(ye,P);kt(ye,P.prototype);kt(X,P);kt(X,P.prototype);function un(t,e){ue(t,null,{enter:function(r){return e(r)?ue.STOP:!0}})}function ue(t,e,r){for(var n=[{node:t,context:e,phase:ue.ENTER}];n.length>0;){var i=n.pop();if(i.phase===ue.ENTER){var s=r.enter(i.node,i.context);if(s===ue.STOP)return ue.STOP;if(n.push({node:i.node,context:s,phase:ue.EXIT}),s==null)continue;for(var o=i.node.lastChild;o;)n.push({node:o,context:s,phase:ue.ENTER}),o=o.previousSibling}else r.exit&&r.exit(i.node,i.context)}}ue.STOP=Symbol("walkDOM.STOP");ue.ENTER=0;ue.EXIT=1;function qe(t,e){me(t);var r=e||{};this.ownerDocument=this,this.contentType=r.contentType||Er.XML_APPLICATION,this.type=af(this.contentType)?"html":"xml"}function bf(t,e,r){t&&t._inc++;var n=r.namespaceURI;n===Fe.XMLNS&&(e._nsMap[r.prefix?r.localName:""]=r.value)}function Oo(t,e,r,n){t&&t._inc++;var i=r.namespaceURI;i===Fe.XMLNS&&delete e._nsMap[r.prefix?r.localName:""]}function ki(t,e,r){if(t&&t._inc){t._inc++;var n=e.childNodes;if(r&&!r.nextSibling)n[n.length++]=r;else{for(var i=e.firstChild,s=0;i;)n[s++]=i,i=i.nextSibling;n.length=s,delete n[n.length]}}}function Bo(t,e){if(t!==e.parentNode)throw new A(A.NOT_FOUND_ERR,"child's parent is not parent");var r=e.previousSibling,n=e.nextSibling;return r?r.nextSibling=n:t.firstChild=n,n?n.previousSibling=r:t.lastChild=r,ki(t.ownerDocument,t),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function Df(t){return t&&(t.nodeType===P.DOCUMENT_NODE||t.nodeType===P.DOCUMENT_FRAGMENT_NODE||t.nodeType===P.ELEMENT_NODE)}function vf(t){return t&&(t.nodeType===P.CDATA_SECTION_NODE||t.nodeType===P.COMMENT_NODE||t.nodeType===P.DOCUMENT_FRAGMENT_NODE||t.nodeType===P.DOCUMENT_TYPE_NODE||t.nodeType===P.ELEMENT_NODE||t.nodeType===P.PROCESSING_INSTRUCTION_NODE||t.nodeType===P.TEXT_NODE)}function tt(t){return t&&t.nodeType===P.DOCUMENT_TYPE_NODE}function $e(t){return t&&t.nodeType===P.ELEMENT_NODE}function Mo(t){return t&&t.nodeType===P.TEXT_NODE}function Eo(t,e){var r=t.childNodes||[];if(ke(r,$e)||tt(e))return!1;var n=ke(r,tt);return!(e&&n&&r.indexOf(n)>r.indexOf(e))}function bo(t,e){var r=t.childNodes||[];function n(s){return $e(s)&&s!==e}if(ke(r,n))return!1;var i=ke(r,tt);return!(e&&i&&r.indexOf(i)>r.indexOf(e))}function Tf(t,e,r){if(!Df(t))throw new A(A.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+t.nodeType);if(r&&r.parentNode!==t)throw new A(A.NOT_FOUND_ERR,"child not in parent");if(!vf(e)||tt(e)&&t.nodeType!==P.DOCUMENT_NODE)throw new A(A.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+t.nodeType)}function xf(t,e,r){var n=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===P.DOCUMENT_FRAGMENT_NODE){var s=i.filter($e);if(s.length>1||ke(i,Mo))throw new A(A.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Eo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if($e(e)&&!Eo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(tt(e)){if(ke(n,tt))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=ke(n,$e);if(r&&n.indexOf(o)<n.indexOf(r))throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!r&&o)throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function ko(t,e,r){var n=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===P.DOCUMENT_FRAGMENT_NODE){var s=i.filter($e);if(s.length>1||ke(i,Mo))throw new A(A.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!bo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if($e(e)&&!bo(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(tt(e)){if(ke(n,function(l){return tt(l)&&l!==r}))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=ke(n,$e);if(r&&n.indexOf(o)<n.indexOf(r))throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function ln(t,e,r,n){Tf(t,e,r),t.nodeType===P.DOCUMENT_NODE&&(n||xf)(t,e,r);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===et){var s=e.firstChild;if(s==null)return e;var o=e.lastChild}else s=o=e;var a=r?r.previousSibling:t.lastChild;s.previousSibling=a,o.nextSibling=r,a?a.nextSibling=s:t.firstChild=s,r==null?t.lastChild=o:r.previousSibling=o;do s.parentNode=t;while(s!==o&&(s=s.nextSibling));return ki(t.ownerDocument||t,t,e),e.nodeType==et&&(e.firstChild=e.lastChild=null),e}qe.prototype={implementation:null,nodeName:"#document",nodeType:It,doctype:null,documentElement:null,_inc:1,insertBefore:function(t,e){if(t.nodeType===et){for(var r=t.firstChild;r;){var n=r.nextSibling;this.insertBefore(r,e),r=n}return t}return ln(this,t,e),t.ownerDocument=this,this.documentElement===null&&t.nodeType===ve&&(this.documentElement=t),t},removeChild:function(t){var e=Bo(this,t);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(t,e){ln(this,t,e,ko),t.ownerDocument=this,e&&this.removeChild(e),$e(t)&&(this.documentElement=t)},importNode:function(t,e){return Af(this,t,e)},getElementById:function(t){var e=null;return un(this.documentElement,function(r){if(r.nodeType==ve&&r.getAttribute("id")==t)return e=r,!0}),e},createElement:function(t){var e=new Ve(de);e.ownerDocument=this,this.type==="html"&&(t=t.toLowerCase()),of(this.contentType)&&(e.namespaceURI=Fe.HTML),e.nodeName=t,e.tagName=t,e.localName=t,e.childNodes=new te;var r=e.attributes=new Mt;return r._ownerElement=e,e},createDocumentFragment:function(){var t=new Ft(de);return t.ownerDocument=this,t.childNodes=new te,t},createTextNode:function(t){var e=new Dr(de);return e.ownerDocument=this,e.childNodes=new te,e.appendData(t),e},createComment:function(t){var e=new fn(de);return e.ownerDocument=this,e.childNodes=new te,e.appendData(t),e},createCDATASection:function(t){if(t.indexOf("]]>")!==-1)throw new A(A.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new hn(de);return e.ownerDocument=this,e.childNodes=new te,e.appendData(t),e},createProcessingInstruction:function(t,e){var r=new mn(de);return r.ownerDocument=this,r.childNodes=new te,r.nodeName=r.target=t,r.nodeValue=r.data=e,r},createAttribute:function(t){if(!Y.QName_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'invalid character in name "'+t+'"');return this.type==="html"&&(t=t.toLowerCase()),this._createAttribute(t)},_createAttribute:function(t){var e=new dt(de);return e.ownerDocument=this,e.childNodes=new te,e.name=t,e.nodeName=t,e.localName=t,e.specified=!0,e},createEntityReference:function(t){if(!Y.Name_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'not a valid xml name "'+t+'"');if(this.type==="html")throw new A("document is an html document",he.NotSupportedError);var e=new pn(de);return e.ownerDocument=this,e.childNodes=new te,e.nodeName=t,e},createElementNS:function(t,e){var r=Ii(t,e),n=new Ve(de),i=n.attributes=new Mt;return n.childNodes=new te,n.ownerDocument=this,n.nodeName=e,n.tagName=e,n.namespaceURI=r[0],n.prefix=r[1],n.localName=r[2],i._ownerElement=n,n},createAttributeNS:function(t,e){var r=Ii(t,e),n=new dt(de);return n.ownerDocument=this,n.childNodes=new te,n.nodeName=e,n.name=e,n.specified=!0,n.namespaceURI=r[0],n.prefix=r[1],n.localName=r[2],n}};ge(qe,P);function Ve(t){me(t),this._nsMap=Object.create(null)}Ve.prototype={nodeType:ve,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Fe.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(t){return!!this.getAttributeNode(t)},getAttribute:function(t){var e=this.getAttributeNode(t);return e?e.value:null},getAttributeNode:function(t){return this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase()),this.attributes.getNamedItem(t)},setAttribute:function(t,e){this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());var r=this.getAttributeNode(t);r?r.value=r.nodeValue=""+e:(r=this.ownerDocument._createAttribute(t),r.value=r.nodeValue=""+e,this.setAttributeNode(r))},removeAttribute:function(t){var e=this.getAttributeNode(t);e&&this.removeAttributeNode(e)},setAttributeNode:function(t){return this.attributes.setNamedItem(t)},setAttributeNodeNS:function(t){return this.attributes.setNamedItemNS(t)},removeAttributeNode:function(t){return this.attributes.removeNamedItem(t.nodeName)},removeAttributeNS:function(t,e){var r=this.getAttributeNodeNS(t,e);r&&this.removeAttributeNode(r)},hasAttributeNS:function(t,e){return this.getAttributeNodeNS(t,e)!=null},getAttributeNS:function(t,e){var r=this.getAttributeNodeNS(t,e);return r?r.value:null},setAttributeNS:function(t,e,r){var n=Ii(t,e),i=n[2],s=this.getAttributeNodeNS(t,i);s?s.value=s.nodeValue=""+r:(s=this.ownerDocument.createAttributeNS(t,e),s.value=s.nodeValue=""+r,this.setAttributeNode(s))},getAttributeNodeNS:function(t,e){return this.attributes.getNamedItemNS(t,e)},getElementsByClassName:function(t){var e=go(t);return new Me(this,function(r){var n=[];return e.length>0&&un(r,function(i){if(i!==r&&i.nodeType===ve){var s=i.getAttribute("class");if(s){var o=t===s;if(!o){var a=go(s);o=e.every(df(a))}o&&n.push(i)}}}),n})},getElementsByTagName:function(t){var e=(this.nodeType===It?this:this.ownerDocument).type==="html",r=t.toLowerCase();return new Me(this,function(n){var i=[];return un(n,function(s){if(!(s===n||s.nodeType!==ve))if(t==="*")i.push(s);else{var o=s.getQualifiedName(),a=e&&s.namespaceURI===Fe.HTML?r:t;o===a&&i.push(s)}}),i})},getElementsByTagNameNS:function(t,e){return new Me(this,function(r){var n=[];return un(r,function(i){i!==r&&i.nodeType===ve&&(t==="*"||i.namespaceURI===t)&&(e==="*"||i.localName==e)&&n.push(i)}),n})}};qe.prototype.getElementsByClassName=Ve.prototype.getElementsByClassName;qe.prototype.getElementsByTagName=Ve.prototype.getElementsByTagName;qe.prototype.getElementsByTagNameNS=Ve.prototype.getElementsByTagNameNS;ge(Ve,P);function dt(t){me(t),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}dt.prototype.nodeType=Bt;ge(dt,P);function rt(t){me(t)}rt.prototype={data:"",substringData:function(t,e){return this.data.substring(t,t+e)},appendData:function(t){t=this.data+t,this.nodeValue=this.data=t,this.length=t.length},insertData:function(t,e){this.replaceData(t,0,e)},deleteData:function(t,e){this.replaceData(t,e,"")},replaceData:function(t,e,r){var n=this.data.substring(0,t),i=this.data.substring(t+e);r=n+r+i,this.nodeValue=this.data=r,this.length=r.length}};ge(rt,P);function Dr(t){me(t)}Dr.prototype={nodeName:"#text",nodeType:br,splitText:function(t){var e=this.data,r=e.substring(t);e=e.substring(0,t),this.data=this.nodeValue=e,this.length=e.length;var n=this.ownerDocument.createTextNode(r);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}};ge(Dr,rt);function fn(t){me(t)}fn.prototype={nodeName:"#comment",nodeType:Bi};ge(fn,rt);function hn(t){me(t)}hn.prototype={nodeName:"#cdata-section",nodeType:xo};ge(hn,Dr);function dn(t){me(t)}dn.prototype.nodeType=Co;ge(dn,P);function Fi(t){me(t)}Fi.prototype.nodeType=mf;ge(Fi,P);function Ri(t){me(t)}Ri.prototype.nodeType=pf;ge(Ri,P);function pn(t){me(t)}pn.prototype.nodeType=Ao;ge(pn,P);function Ft(t){me(t)}Ft.prototype.nodeName="#document-fragment";Ft.prototype.nodeType=et;ge(Ft,P);function mn(t){me(t)}mn.prototype.nodeType=Oi;ge(mn,rt);function Fo(){}Fo.prototype.serializeToString=function(t,e){return Ro.call(t,e)};P.prototype.toString=Ro;function Ro(t){var e;typeof t=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:t}:t!=null?e={requireWellFormed:!!t.requireWellFormed,splitCDATASections:t.splitCDATASections!==!1,nodeFilter:t.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var r=[],n=this.nodeType===It&&this.documentElement||this,i=n.prefix,s=n.namespaceURI;if(s&&i==null){var i=n.lookupPrefix(s);if(i==null)var o=[{namespace:s,prefix:null}]}return Li(this,r,o,e),r.join("")}function Do(t,e,r){var n=t.prefix||"",i=t.namespaceURI;if(!i||n==="xml"&&i===Fe.XML||i===Fe.XMLNS)return!1;for(var s=r.length;s--;){var o=r[s];if(o.prefix===n)return o.namespace!==i}return!0}function an(t,e,r,n){if(n&&!Y.QName_exact.test(e))throw new A('The attribute name "'+e+'" is not a valid XML QName',he.InvalidStateError);t.push(" ",e,'="',r.replace(/[<>&"\t\n\r]/g,Io),'"')}function Li(t,e,r,n){r||(r=[]);var i=n.nodeFilter,s=n.requireWellFormed,o=n.splitCDATASections,a=t.nodeType===It?t:t.ownerDocument,l=a.type==="html";ue(t,{ns:r},{enter:function(u,c){var f=c.ns;if(i)if(u=i(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case ve:var h=u.attributes,d=h.length,p=u.tagName,m=p;if(!l&&!u.prefix&&u.namespaceURI){for(var g,y=0;y<h.length;y++)if(h.item(y).name==="xmlns"){g=h.item(y).value;break}if(!g)for(var E=f.length-1;E>=0;E--){var w=f[E];if(w.prefix===""&&w.namespace===u.namespaceURI){g=w.namespace;break}}if(g!==u.namespaceURI)for(var E=f.length-1;E>=0;E--){var w=f[E];if(w.namespace===u.namespaceURI){w.prefix&&(m=w.prefix+":"+p);break}}}if(s&&!Y.QName_exact.test(m))throw new A('The element name "'+m+'" is not a valid XML QName',he.InvalidStateError);e.push("<",m);for(var v=f.slice(),x=0;x<d;x++){var T=h.item(x);T.prefix=="xmlns"?v.push({prefix:T.localName,namespace:T.value}):T.nodeName=="xmlns"&&v.push({prefix:"",namespace:T.value})}for(var x=0;x<d;x++){var T=h.item(x);if(Do(T,l,v)){var b=T.prefix||"",C=T.namespaceURI;an(e,b?"xmlns:"+b:"xmlns",C,s),v.push({prefix:b,namespace:C})}var I=i?i(T):T;I&&(typeof I=="string"?e.push(I):an(e,I.name,I.value,s))}if(p===m&&Do(u,l,v)){var O=u.prefix||"",C=u.namespaceURI;an(e,O?"xmlns:"+O:"xmlns",C,s),v.push({prefix:O,namespace:C})}var L=!u.firstChild;if(L&&(l||u.namespaceURI===Fe.HTML)&&(L=lf(p)),L)return e.push("/>"),null;if(e.push(">"),l&&uf(p)){for(var $=u.firstChild;$;)$.data?e.push($.data):Li($,e,v.slice(),n),$=$.nextSibling;return e.push("</",m,">"),null}return{ns:v,tag:m};case It:case et:if(s&&u.nodeType===It&&u.documentElement==null)throw new A("The Document has no documentElement",he.InvalidStateError);return{ns:f};case Bt:return an(e,u.name,u.value,s),null;case br:if(s&&Y.InvalidChar.test(u.data))throw new A("The Text node data contains characters outside the XML Char production",he.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Io)),null;case xo:if(s&&u.data.indexOf("]]>")!==-1)throw new A('The CDATASection data contains "]]>"',he.InvalidStateError);return o?e.push(Y.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),Y.CDATA_END):e.push(Y.CDATA_START,u.data,Y.CDATA_END),null;case Bi:if(s){if(Y.InvalidChar.test(u.data))throw new A("The comment node data contains characters outside the XML Char production",he.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new A('The comment node data contains "--" or ends with "-"',he.InvalidStateError)}return e.push(Y.COMMENT_START,u.data,Y.COMMENT_END),null;case Co:var se=u.publicId,V=u.systemId;if(s){if(!Y.Name_exact.test(u.name))throw new A('The doctype name "'+u.name+'" is not a valid XML Name',he.InvalidStateError);if(se&&!Y.PubidLiteral_match.test(se))throw new A("DocumentType publicId is not a valid PubidLiteral",he.InvalidStateError);if(V&&V!=="."&&!Y.SystemLiteral_match.test(V))throw new A("DocumentType systemId is not a valid SystemLiteral",he.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new A('DocumentType internalSubset contains "]>"',he.InvalidStateError)}return e.push(Y.DOCTYPE_DECL_START," ",u.name),se?(e.push(" ",Y.PUBLIC," ",se),V&&V!=="."&&e.push(" ",V)):V&&V!=="."&&e.push(" ",Y.SYSTEM," ",V),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case Oi:if(s){if(!Y.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new A('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',he.InvalidStateError);if(Y.InvalidChar.test(u.data))throw new A("The ProcessingInstruction data contains characters outside the XML Char production",he.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new A('The ProcessingInstruction data contains "?>"',he.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Ao:if(s&&!Y.Name_exact.test(u.nodeName))throw new A('The entity reference name "'+u.nodeName+'" is not a valid XML Name',he.InvalidStateError);return e.push("&",u.nodeName,";"),null;default:return e.push("??",u.nodeName),null}},exit:function(u,c){c&&c.tag&&e.push("</",c.tag,">")}})}function Af(t,e,r){var n;return ue(e,null,{enter:function(i,s){var o=i.cloneNode(!1);o.ownerDocument=t,o.parentNode=null,s===null?n=o:s.appendChild(o);var a=i.nodeType===Bt||r;return a?o:null}}),n}function Lo(t,e,r){var n;return ue(e,null,{enter:function(i,s){var o=new i.constructor(de);for(var a in i)if(Ot(i,a)){var l=i[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}i.childNodes&&(o.childNodes=new te),o.ownerDocument=t;var u=r;switch(o.nodeType){case ve:var c=i.attributes,f=o.attributes=new Mt,h=c.length;f._ownerElement=o;for(var d=0;d<h;d++)o.setAttributeNode(Lo(t,c.item(d),!0));break;case Bt:u=!0}return s!==null?s.appendChild(o):n=o,u?o:null}}),n}function Po(t,e,r){t[e]=r}function Ni(t){for(var e=[],r=t.firstChild;r;)r.nodeType===ve&&e.push(r),r=r.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Me.prototype,"length",{get:function(){return cn(this),this.$$length}}),Object.defineProperty(P.prototype,"textContent",{get:function(){if(this.nodeType===ve||this.nodeType===et){var t=[];return ue(this,null,{enter:function(e){if(e.nodeType===ve||e.nodeType===et)return!0;if(e.nodeType===Oi||e.nodeType===Bi)return null;t.push(e.nodeValue)}}),t.join("")}return this.nodeValue},set:function(t){switch(this.nodeType){case ve:case et:for(;this.firstChild;)this.removeChild(this.firstChild);(t||String(t))&&this.appendChild(this.ownerDocument.createTextNode(t));break;default:this.data=t,this.value=t,this.nodeValue=t}}}),Object.defineProperty(rt.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(t){this._data=t,this.length=typeof t=="string"?t.length:0}}),Object.defineProperty(rt.prototype,"nodeValue",{get:function(){return this.data},set:function(t){this.data=t},enumerable:!0,configurable:!0}),Object.defineProperty(Ve.prototype,"children",{get:function(){return new Me(this,Ni)}}),Object.defineProperty(qe.prototype,"children",{get:function(){return new Me(this,Ni)}}),Object.defineProperty(Ft.prototype,"children",{get:function(){return new Me(this,Ni)}}),Po=function(t,e,r){t["$$"+e]=r})}catch{}W._updateLiveList=cn;W.Attr=dt;W.CDATASection=hn;W.CharacterData=rt;W.Comment=fn;W.Document=qe;W.DocumentFragment=Ft;W.DocumentType=dn;W.DOMImplementation=No;W.Element=Ve;W.Entity=Ri;W.EntityReference=pn;W.LiveNodeList=Me;W.NamedNodeMap=Mt;W.Node=P;W.NodeList=te;W.Notation=Fi;W.Text=Dr;W.ProcessingInstruction=mn;W.walkDOM=ue;W.XMLSerializer=Fo});var $o=Ge(vr=>{"use strict";var Uo=ht().freeze;vr.XML_ENTITIES=Uo({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});vr.HTML_ENTITIES=Uo({Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",AMP:"&",amp:"&",And:"\u2A53",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",ap:"\u2248",apacir:"\u2A6F",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",Barwed:"\u2306",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",Because:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxDL:"\u2557",boxDl:"\u2556",boxdL:"\u2555",boxdl:"\u2510",boxDR:"\u2554",boxDr:"\u2553",boxdR:"\u2552",boxdr:"\u250C",boxH:"\u2550",boxh:"\u2500",boxHD:"\u2566",boxHd:"\u2564",boxhD:"\u2565",boxhd:"\u252C",boxHU:"\u2569",boxHu:"\u2567",boxhU:"\u2568",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxUL:"\u255D",boxUl:"\u255C",boxuL:"\u255B",boxul:"\u2518",boxUR:"\u255A",boxUr:"\u2559",boxuR:"\u2558",boxur:"\u2514",boxV:"\u2551",boxv:"\u2502",boxVH:"\u256C",boxVh:"\u256B",boxvH:"\u256A",boxvh:"\u253C",boxVL:"\u2563",boxVl:"\u2562",boxvL:"\u2561",boxvl:"\u2524",boxVR:"\u2560",boxVr:"\u255F",boxvR:"\u255E",boxvr:"\u251C",bprime:"\u2035",Breve:"\u02D8",breve:"\u02D8",brvbar:"\xA6",Bscr:"\u212C",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",Bumpeq:"\u224E",bumpeq:"\u224F",Cacute:"\u0106",cacute:"\u0107",Cap:"\u22D2",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",Ccaron:"\u010C",ccaron:"\u010D",Ccedil:"\xC7",ccedil:"\xE7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",Cdot:"\u010A",cdot:"\u010B",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",CenterDot:"\xB7",centerdot:"\xB7",Cfr:"\u212D",cfr:"\u{1D520}",CHcy:"\u0427",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",Chi:"\u03A7",chi:"\u03C7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cirE:"\u29C3",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",Colon:"\u2237",colon:":",Colone:"\u2A74",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",Conint:"\u222F",conint:"\u222E",ContourIntegral:"\u222E",Copf:"\u2102",copf:"\u{1D554}",coprod:"\u2210",Coproduct:"\u2210",COPY:"\xA9",copy:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",Cross:"\u2A2F",cross:"\u2717",Cscr:"\u{1D49E}",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",Cup:"\u22D3",cup:"\u222A",cupbrcap:"\u2A48",CupCap:"\u224D",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",Dagger:"\u2021",dagger:"\u2020",daleth:"\u2138",Darr:"\u21A1",dArr:"\u21D3",darr:"\u2193",dash:"\u2010",Dashv:"\u2AE4",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",Dcaron:"\u010E",dcaron:"\u010F",Dcy:"\u0414",dcy:"\u0434",DD:"\u2145",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",Delta:"\u0394",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",Dfr:"\u{1D507}",dfr:"\u{1D521}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",Diamond:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",DJcy:"\u0402",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",Dopf:"\u{1D53B}",dopf:"\u{1D555}",Dot:"\xA8",dot:"\u02D9",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",Downarrow:"\u21D3",downarrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",Dscr:"\u{1D49F}",dscr:"\u{1D4B9}",DScy:"\u0405",dscy:"\u0455",dsol:"\u29F6",Dstrok:"\u0110",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",DZcy:"\u040F",dzcy:"\u045F",dzigrarr:"\u27FF",Eacute:"\xC9",eacute:"\xE9",easter:"\u2A6E",Ecaron:"\u011A",ecaron:"\u011B",ecir:"\u2256",Ecirc:"\xCA",ecirc:"\xEA",ecolon:"\u2255",Ecy:"\u042D",ecy:"\u044D",eDDot:"\u2A77",Edot:"\u0116",eDot:"\u2251",edot:"\u0117",ee:"\u2147",efDot:"\u2252",Efr:"\u{1D508}",efr:"\u{1D522}",eg:"\u2A9A",Egrave:"\xC8",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",Emacr:"\u0112",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",ENG:"\u014A",eng:"\u014B",ensp:"\u2002",Eogon:"\u0118",eogon:"\u0119",Eopf:"\u{1D53C}",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",Escr:"\u2130",escr:"\u212F",esdot:"\u2250",Esim:"\u2A73",esim:"\u2242",Eta:"\u0397",eta:"\u03B7",ETH:"\xD0",eth:"\xF0",Euml:"\xCB",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",ExponentialE:"\u2147",exponentiale:"\u2147",fallingdotseq:"\u2252",Fcy:"\u0424",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",Ffr:"\u{1D509}",ffr:"\u{1D523}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",Fopf:"\u{1D53D}",fopf:"\u{1D557}",ForAll:"\u2200",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",Fscr:"\u2131",fscr:"\u{1D4BB}",gacute:"\u01F5",Gamma:"\u0393",gamma:"\u03B3",Gammad:"\u03DC",gammad:"\u03DD",gap:"\u2A86",Gbreve:"\u011E",gbreve:"\u011F",Gcedil:"\u0122",Gcirc:"\u011C",gcirc:"\u011D",Gcy:"\u0413",gcy:"\u0433",Gdot:"\u0120",gdot:"\u0121",gE:"\u2267",ge:"\u2265",gEl:"\u2A8C",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",Gfr:"\u{1D50A}",gfr:"\u{1D524}",Gg:"\u22D9",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",GJcy:"\u0403",gjcy:"\u0453",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gnE:"\u2269",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",Gopf:"\u{1D53E}",gopf:"\u{1D558}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",Gt:"\u226B",GT:">",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",HARDcy:"\u042A",hardcy:"\u044A",hArr:"\u21D4",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",Hcirc:"\u0124",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",Hfr:"\u210C",hfr:"\u{1D525}",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",Hopf:"\u210D",hopf:"\u{1D559}",horbar:"\u2015",HorizontalLine:"\u2500",Hscr:"\u210B",hscr:"\u{1D4BD}",hslash:"\u210F",Hstrok:"\u0126",hstrok:"\u0127",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",Iacute:"\xCD",iacute:"\xED",ic:"\u2063",Icirc:"\xCE",icirc:"\xEE",Icy:"\u0418",icy:"\u0438",Idot:"\u0130",IEcy:"\u0415",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",Ifr:"\u2111",ifr:"\u{1D526}",Igrave:"\xCC",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",IJlig:"\u0132",ijlig:"\u0133",Im:"\u2111",Imacr:"\u012A",imacr:"\u012B",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",Int:"\u222C",int:"\u222B",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",IOcy:"\u0401",iocy:"\u0451",Iogon:"\u012E",iogon:"\u012F",Iopf:"\u{1D540}",iopf:"\u{1D55A}",Iota:"\u0399",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",Iscr:"\u2110",iscr:"\u{1D4BE}",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",Itilde:"\u0128",itilde:"\u0129",Iukcy:"\u0406",iukcy:"\u0456",Iuml:"\xCF",iuml:"\xEF",Jcirc:"\u0134",jcirc:"\u0135",Jcy:"\u0419",jcy:"\u0439",Jfr:"\u{1D50D}",jfr:"\u{1D527}",jmath:"\u0237",Jopf:"\u{1D541}",jopf:"\u{1D55B}",Jscr:"\u{1D4A5}",jscr:"\u{1D4BF}",Jsercy:"\u0408",jsercy:"\u0458",Jukcy:"\u0404",jukcy:"\u0454",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",Kcedil:"\u0136",kcedil:"\u0137",Kcy:"\u041A",kcy:"\u043A",Kfr:"\u{1D50E}",kfr:"\u{1D528}",kgreen:"\u0138",KHcy:"\u0425",khcy:"\u0445",KJcy:"\u040C",kjcy:"\u045C",Kopf:"\u{1D542}",kopf:"\u{1D55C}",Kscr:"\u{1D4A6}",kscr:"\u{1D4C0}",lAarr:"\u21DA",Lacute:"\u0139",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",Lambda:"\u039B",lambda:"\u03BB",Lang:"\u27EA",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",Larr:"\u219E",lArr:"\u21D0",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",lAtail:"\u291B",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lBarr:"\u290E",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",Lcaron:"\u013D",lcaron:"\u013E",Lcedil:"\u013B",lcedil:"\u013C",lceil:"\u2308",lcub:"{",Lcy:"\u041B",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",lE:"\u2266",le:"\u2264",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",Leftarrow:"\u21D0",leftarrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",LeftRightArrow:"\u2194",Leftrightarrow:"\u21D4",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",lEg:"\u2A8B",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",Lfr:"\u{1D50F}",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",LJcy:"\u0409",ljcy:"\u0459",Ll:"\u22D8",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",Lmidot:"\u013F",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lnE:"\u2268",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",LongLeftArrow:"\u27F5",Longleftarrow:"\u27F8",longleftarrow:"\u27F5",LongLeftRightArrow:"\u27F7",Longleftrightarrow:"\u27FA",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",LongRightArrow:"\u27F6",Longrightarrow:"\u27F9",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",Lopf:"\u{1D543}",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",Lscr:"\u2112",lscr:"\u{1D4C1}",Lsh:"\u21B0",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",Lstrok:"\u0141",lstrok:"\u0142",Lt:"\u226A",LT:"<",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",Map:"\u2905",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",Mcy:"\u041C",mcy:"\u043C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",Mopf:"\u{1D544}",mopf:"\u{1D55E}",mp:"\u2213",Mscr:"\u2133",mscr:"\u{1D4C2}",mstpos:"\u223E",Mu:"\u039C",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",Nacute:"\u0143",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",Ncy:"\u041D",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",neArr:"\u21D7",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
2
- `,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"});vr.entityMap=vr.HTML_ENTITIES});var Wo=Ge(yn=>{"use strict";var $t=ht(),k=Si(),jo=dr(),Cf=$t.isHTMLEscapableRawTextElement,_f=$t.isHTMLMimeType,Sf=$t.isHTMLRawTextElement,Ar=$t.hasOwn,qo=$t.NAMESPACE,Nf=jo.ParseError,If=jo.DOMException,Rt=0,nt=1,Lt=2,Tr=3,Pt=4,Ut=5,xr=6,gn=7;function Ho(){}Ho.prototype={parse:function(t,e,r){var n=this.domBuilder;n.startDocument(),kf(e,e=Object.create(null)),Of(t,e,r,n,this.errorHandler),n.endDocument()}};var Ui=/&#?\w+;?/g;function Of(t,e,r,n,i){var s=_f(n.mimeType);t.indexOf(k.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function o(q){if(q>65535){q-=65536;var be=55296+(q>>10),$r=56320+(q&1023);return String.fromCharCode(be,$r)}else return String.fromCharCode(q)}function a(q){var be=q[q.length-1]===";"?q:q+";";if(!s&&be!==q)return i.error("EntityRef: expecting ;"),q;var $r=k.Reference.exec(be);if(!$r||$r[0].length!==be.length)return i.error("entity not matching Reference production: "+q),q;var qr=be.slice(1,-1);return Ar(r,qr)?r[qr]:qr.charAt(0)==="#"?o(parseInt(qr.substring(1).replace("x","0x"))):(i.error("entity not found:"+q),q)}function l(q){if(q>g){var be=t.substring(g,q).replace(Ui,a);h&&d(g),n.characters(be,0,q-g),g=q}}var u=0,c=0,f=/\r\n?|\n|$/g,h=n.locator;function d(q,be){for(;q>=c&&(be=f.exec(t));)u=c,c=be.index+be[0].length,h.lineNumber++;h.columnNumber=q-u+1}for(var p=[{currentNSMap:e}],m=[],g=0;;){try{var y=t.indexOf("<",g);if(y<0){if(!s&&m.length>0)return i.fatalError("unclosed xml tag(s): "+m.join(", "));if(!t.substring(g).match(/^\s*$/)){var E=n.doc,w=E.createTextNode(t.substring(g));if(E.documentElement)return i.error("Extra content at the end of the document");E.appendChild(w),n.currentElement=w}return}if(y>g){var v=t.substring(g,y);!s&&m.length===0&&(v=v.replace(new RegExp(k.S_OPT.source,"g"),""),v&&i.error("Unexpected content outside root element: '"+v+"'")),l(y)}switch(t.charAt(y+1)){case"/":var F=t.indexOf(">",y+2),x=t.substring(y+2,F>0?F:void 0);if(!x)return i.fatalError("end tag name missing");var T=k.reg("^",k.QName_group,k.S_OPT,"$"),b=F>0&&T.exec(x);if(!b){var C=F>0&&k.reg("^",k.QName_group).exec(x);if(s&&C)i.warning('end tag name contains invalid trailing characters: "'+x+'"'),b=C;else if(C&&new RegExp(T.source,T.flags+"m").test(x))i.error('end tag name is followed by a line break and trailing content: "'+x+'"'),b=C;else return i.fatalError('end tag name contains invalid characters: "'+x+'"')}if(!n.currentElement&&!n.doc.documentElement)return;var I=m[m.length-1]||n.currentElement.tagName||n.doc.documentElement.tagName||"";if(I!==b[1]){var O=b[1].toLowerCase();if(!s||I.toLowerCase()!==O)return i.fatalError('Opening and ending tag mismatch: "'+I+'" != "'+x+'"')}var L=p.pop();m.pop();var $=L.localNSMap;if(n.endElement(L.uri,L.localName,I),$)for(var se in $)Ar($,se)&&n.endPrefixMapping(se);F++;break;case"?":h&&d(y),F=Rf(t,y,n,i);break;case"!":h&&d(y),F=Xo(t,y,n,i,s);break;default:h&&d(y);var V=new Yo,Q=p[p.length-1].currentNSMap,F=Bf(t,y,V,Q,a,i,s),ys=V.length;if(V.closed||(s&&$t.isHTMLVoidElement(V.tagName)?V.closed=!0:m.push(V.tagName)),h&&ys){for(var Au=Vo(h,{}),ri=0;ri<ys;ri++){var ws=V[ri];d(ws.offset),ws.locator=Vo(h,{})}n.locator=Au,zo(V,n,Q)&&p.push(V),n.locator=h}else zo(V,n,Q)&&p.push(V);s&&!V.closed?F=Mf(t,F,V.tagName,a,n):F++}}catch(q){if(q instanceof Nf)throw q;if(q instanceof If)return i.fatalError("Error constructing the DOM: "+q.name+": "+q.message,q);i.error("element parse error: "+q),F=-1}F>g?g=F:l(Math.max(y,g)+1)}}function Vo(t,e){return e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber,e}function Bf(t,e,r,n,i,s,o){function a(d,p,m){if(Ar(r.attributeNames,d))return s.fatalError("Attribute "+d+" redefined");if(!o&&p.indexOf("<")>=0)return s.fatalError("Unescaped '<' not allowed in attributes values");r.addValue(d,p.replace(/[\t\n\r]/g," ").replace(Ui,i),m)}for(var l,u,c=++e,f=Rt;;){var h=t.charAt(c);if(f===Rt&&h==="<")throw new Error("unexpected < in tag name: "+t.slice(e,c));switch(h){case"=":if(f===nt)l=t.slice(e,c),f=Tr;else if(f===Lt)f=Tr;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(f===Tr||f===nt)if(f===nt&&(s.warning('attribute value must after "="'),l=t.slice(e,c)),e=c+1,c=t.indexOf(h,e),c>0)u=t.slice(e,c),a(l,u,e-1),f=Ut;else throw new Error("attribute value no end '"+h+"' match");else if(f==Pt)u=t.slice(e,c),a(l,u,e),s.warning('attribute "'+l+'" missed start quot('+h+")!!"),e=c+1,f=Ut;else throw new Error('attribute value must after "="');break;case"/":switch(f){case Rt:r.setTagName(t.slice(e,c));case Ut:case xr:case gn:f=gn,r.closed=!0;case Pt:case nt:break;case Lt:r.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),f==Rt&&r.setTagName(t.slice(e,c)),c;case">":switch(f){case Rt:r.setTagName(t.slice(e,c));case Ut:case xr:case gn:break;case Pt:case nt:u=t.slice(e,c),u.slice(-1)==="/"&&(r.closed=!0,u=u.slice(0,-1));case Lt:f===Lt&&(u=l),f==Pt?(s.warning('attribute "'+u+'" missed quot(")!'),a(l,u,e)):(o||s.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case Tr:if(!o)return s.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":h=" ";default:if(h<=" ")switch(f){case Rt:r.setTagName(t.slice(e,c)),f=xr;break;case nt:l=t.slice(e,c),f=Lt;break;case Pt:var u=t.slice(e,c);s.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Ut:f=xr;break}else switch(f){case Lt:o||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,f=nt;break;case Ut:s.warning('attribute space is required"'+l+'"!!');case xr:f=nt,e=c;break;case Tr:f=Pt,e=c;break;case gn:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function zo(t,e,r){for(var n=t.tagName,i=null,f=t.length;f--;){var s=t[f],o=s.qName,a=s.value,h=o.indexOf(":");if(h>0)var l=s.prefix=o.slice(0,h),u=o.slice(h+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";s.localName=u,c!==!1&&(i==null&&(i=Object.create(null),r=Object.create(r)),r[c]=i[c]=a,s.uri=qo.XMLNS,e.startPrefixMapping(c,a))}for(var f=t.length;f--;)s=t[f],s.prefix&&(s.prefix==="xml"&&(s.uri=qo.XML),s.prefix!=="xmlns"&&(s.uri=r[s.prefix]));var h=n.indexOf(":");h>0?(l=t.prefix=n.slice(0,h),u=t.localName=n.slice(h+1)):(l=null,u=t.localName=n);var d=t.uri=r[l||""];if(e.startElement(d,u,n,t),t.closed){if(e.endElement(d,u,n),i)for(l in i)Ar(i,l)&&e.endPrefixMapping(l)}else return t.currentNSMap=r,t.localNSMap=i,!0}function Mf(t,e,r,n,i){var s=Cf(r);if(s||Sf(r)){var o=new RegExp("</"+r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(t),l=a?a.index:-1;if(l<0)return e+1;var u=t.substring(e+1,l);return s&&(u=u.replace(Ui,n)),i.characters(u,0,u.length),l}return e+1}function kf(t,e){for(var r in t)Ar(t,r)&&(e[r]=t[r])}function Go(t,e){var r=e;function n(c){return c=c||0,t.charAt(r+c)}function i(c){c=c||1,r+=c}function s(){for(var c=0;r<t.length;){var f=n();if(f!==" "&&f!==`
3
- `&&f!==" "&&f!=="\r")return c;c++,i()}return-1}function o(){return t.substring(r)}function a(c){return t.substring(r,r+c.length)===c}function l(c){return t.substring(r,r+c.length).toUpperCase()===c.toUpperCase()}function u(c){var f=k.reg("^",c),h=f.exec(o());return h?(i(h[0].length),h[0]):null}return{char:n,getIndex:function(){return r},getMatch:u,getSource:function(){return t},skip:i,skipBlanks:s,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function Ff(t,e){function r(a,l){var u=k.PI.exec(a.substringFromIndex());return u?u[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+a.getIndex()):(a.skip(u[0].length),u[0]):l.fatalError("processing instruction is not well-formed at position "+a.getIndex())}var n=t.getSource();if(t.char()==="["){t.skip(1);for(var i=t.getIndex();t.getIndex()<n.length;){if(t.skipBlanks(),t.char()==="]"){var s=n.substring(i,t.getIndex());return t.skip(1),s}var o=null;if(t.char()==="<"&&t.char(1)==="!")switch(t.char(2)){case"E":t.char(3)==="L"?o=t.getMatch(k.elementdecl):t.char(3)==="N"&&(o=t.getMatch(k.EntityDecl));break;case"A":o=t.getMatch(k.AttlistDecl);break;case"N":o=t.getMatch(k.NotationDecl);break;case"-":o=t.getMatch(k.Comment);break}else if(t.char()==="<"&&t.char(1)==="?")o=r(t,e);else if(t.char()==="%")o=t.getMatch(k.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!o)return e.fatalError("Error in internal subset at position "+t.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function Xo(t,e,r,n,i){var s=Go(t,e);switch(i?s.char(2).toUpperCase():s.char(2)){case"-":var o=s.getMatch(k.Comment);return o?(r.comment(o,k.COMMENT_START.length,o.length-k.COMMENT_START.length-k.COMMENT_END.length),s.getIndex()):n.fatalError("comment is not well-formed at position "+s.getIndex());case"[":var a=s.getMatch(k.CDSect);return a?!i&&!r.currentElement?n.fatalError("CDATA outside of element"):(r.startCDATA(),r.characters(a,k.CDATA_START.length,a.length-k.CDATA_START.length-k.CDATA_END.length),r.endCDATA(),s.getIndex()):n.fatalError("Invalid CDATA starting at position "+e);case"D":{if(r.doc&&r.doc.documentElement)return n.fatalError("Doctype not allowed inside or after documentElement at position "+s.getIndex());if(i?!s.substringStartsWithCaseInsensitive(k.DOCTYPE_DECL_START):!s.substringStartsWith(k.DOCTYPE_DECL_START))return n.fatalError("Expected "+k.DOCTYPE_DECL_START+" at position "+s.getIndex());if(s.skip(k.DOCTYPE_DECL_START.length),s.skipBlanks()<1)return n.fatalError("Expected whitespace after "+k.DOCTYPE_DECL_START+" at position "+s.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=s.getMatch(k.Name),!l.name)return n.fatalError("doctype name missing or contains unexpected characters at position "+s.getIndex());if(i&&l.name.toLowerCase()!=="html"&&n.warning("Unexpected DOCTYPE in HTML document at position "+s.getIndex()),s.skipBlanks(),s.substringStartsWith(k.PUBLIC)||s.substringStartsWith(k.SYSTEM)){var u=k.ExternalID_match.exec(s.substringFromIndex());if(!u)return n.fatalError("doctype external id is not well-formed at position "+s.getIndex());u.groups.SystemLiteralOnly!==void 0?l.systemId=u.groups.SystemLiteralOnly:(l.systemId=u.groups.SystemLiteral,l.publicId=u.groups.PubidLiteral),s.skip(u[0].length)}else if(i&&s.substringStartsWithCaseInsensitive(k.SYSTEM)){if(s.skip(k.SYSTEM.length),s.skipBlanks()<1)return n.fatalError("Expected whitespace after "+k.SYSTEM+" at position "+s.getIndex());if(l.systemId=s.getMatch(k.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return n.fatalError("Expected "+k.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+k.SYSTEM+" at position "+s.getIndex())}return i&&l.systemId&&!k.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&n.warning("Unexpected doctype.systemId in HTML document at position "+s.getIndex()),i||(s.skipBlanks(),l.internalSubset=Ff(s,n)),s.skipBlanks(),s.char()!==">"?n.fatalError("doctype not terminated with > at position "+s.getIndex()):(s.skip(1),r.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),r.endDTD(),s.getIndex())}default:return n.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function Rf(t,e,r,n){var i=t.substring(e).match(k.PI);if(!i)return n.fatalError("Invalid processing instruction starting at position "+e);if(i[1].toLowerCase()==="xml"){if(e>0)return n.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!k.XMLDecl.test(t.substring(e)))return n.fatalError("xml declaration is not well-formed")}return r.processingInstruction(i[1],i[2]),e+i[0].length}function Yo(){this.attributeNames=Object.create(null)}Yo.prototype={setTagName:function(t){if(!k.QName_exact.test(t))throw new Error("invalid tagName:"+t);this.tagName=t},addValue:function(t,e,r){if(!k.QName_exact.test(t))throw new Error("invalid attribute:"+t);this.attributeNames[t]=this.length,this[this.length++]={qName:t,value:e,offset:r}},length:0,getLocalName:function(t){return this[t].localName},getLocator:function(t){return this[t].locator},getQName:function(t){return this[t].qName},getURI:function(t){return this[t].uri},getValue:function(t){return this[t].value}};yn.XMLReader=Ho;yn.parseUtils=Go;yn.parseDoctypeCommentOrCData=Xo});var ra=Ge(Vt=>{"use strict";var pt=ht(),Lf=Pi(),Pf=dr(),Jo=$o(),Uf=Wo(),$f=Lf.DOMImplementation,qf=pt.hasDefaultHTMLNamespace,Vf=pt.isHTMLMimeType,zf=pt.isValidMimeType,Ko=pt.MIME_TYPE,$i=pt.NAMESPACE,Zo=Pf.ParseError,jf=Uf.XMLReader;function ea(t){return t.replace(/\r[\n\u0085]/g,`
1
+ import{a as Lo}from"./modules/chunk-2CCTLZE7.js";import{a as Ze,b as Ro,c as fr,d as Qr}from"./modules/chunk-RMRBEYTI.js";var yt=Ze(le=>{"use strict";function Lc(t,e,r){if(r===void 0&&(r=Array.prototype),t&&typeof r.find=="function")return r.find.call(t,e);for(var n=0;n<t.length;n++)if(gt(t,n)){var i=t[n];if(e.call(void 0,i,n,t))return i}}function Bt(t,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(t=e.create(null,e.getOwnPropertyDescriptors(t))),e&&typeof e.freeze=="function"?e.freeze(t):t}function gt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Pc(t,e){if(t===null||typeof t!="object")throw new TypeError("target is not an object");for(var r in e)gt(e,r)&&(t[r]=e[r]);return t}var gs=Bt({allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,default:!0,defer:!0,disabled:!0,formnovalidate:!0,hidden:!0,ismap:!0,itemscope:!0,loop:!0,multiple:!0,muted:!0,nomodule:!0,novalidate:!0,open:!0,playsinline:!0,readonly:!0,required:!0,reversed:!0,selected:!0});function Uc(t){return gt(gs,t.toLowerCase())}var ys=Bt({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $c(t){return gt(ys,t.toLowerCase())}var br=Bt({script:!1,style:!1,textarea:!0,title:!0});function qc(t){var e=t.toLowerCase();return gt(br,e)&&!br[e]}function zc(t){var e=t.toLowerCase();return gt(br,e)&&br[e]}function ws(t){return t===Er.HTML}function Vc(t){return ws(t)||t===Er.XML_XHTML_APPLICATION}var Er=Bt({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),jc=Object.keys(Er).map(function(t){return Er[t]});function Hc(t){return jc.indexOf(t)>-1}var Gc=Bt({HTML:"http://www.w3.org/1999/xhtml",SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});le.assign=Pc;le.find=Lc;le.freeze=Bt;le.HTML_BOOLEAN_ATTRIBUTES=gs;le.HTML_RAW_TEXT_ELEMENTS=br;le.HTML_VOID_ELEMENTS=ys;le.hasDefaultHTMLNamespace=Vc;le.hasOwn=gt;le.isHTMLBooleanAttribute=Uc;le.isHTMLRawTextElement=qc;le.isHTMLEscapableRawTextElement=zc;le.isHTMLMimeType=ws;le.isHTMLVoidElement=$c;le.isValidMimeType=Hc;le.MIME_TYPE=Er;le.NAMESPACE=Gc});var Ar=Ze(Tr=>{"use strict";var Wc=yt();function Es(t,e){t.prototype=Object.create(Error.prototype,{constructor:{value:t},name:{value:t.name,enumerable:!0,writable:e}})}var vr=Wc.freeze({Error:"Error",IndexSizeError:"IndexSizeError",DomstringSizeError:"DomstringSizeError",HierarchyRequestError:"HierarchyRequestError",WrongDocumentError:"WrongDocumentError",InvalidCharacterError:"InvalidCharacterError",NoDataAllowedError:"NoDataAllowedError",NoModificationAllowedError:"NoModificationAllowedError",NotFoundError:"NotFoundError",NotSupportedError:"NotSupportedError",InUseAttributeError:"InUseAttributeError",InvalidStateError:"InvalidStateError",SyntaxError:"SyntaxError",InvalidModificationError:"InvalidModificationError",NamespaceError:"NamespaceError",InvalidAccessError:"InvalidAccessError",ValidationError:"ValidationError",TypeMismatchError:"TypeMismatchError",SecurityError:"SecurityError",NetworkError:"NetworkError",AbortError:"AbortError",URLMismatchError:"URLMismatchError",QuotaExceededError:"QuotaExceededError",TimeoutError:"TimeoutError",InvalidNodeTypeError:"InvalidNodeTypeError",DataCloneError:"DataCloneError",EncodingError:"EncodingError",NotReadableError:"NotReadableError",UnknownError:"UnknownError",ConstraintError:"ConstraintError",DataError:"DataError",TransactionInactiveError:"TransactionInactiveError",ReadOnlyError:"ReadOnlyError",VersionError:"VersionError",OperationError:"OperationError",NotAllowedError:"NotAllowedError",OptOutError:"OptOutError"}),Ds=Object.keys(vr);function vs(t){return typeof t=="number"&&t>=1&&t<=25}function Xc(t){return typeof t=="string"&&t.substring(t.length-vr.Error.length)===vr.Error}function xr(t,e){vs(t)?(this.name=Ds[t],this.message=e||""):(this.message=t,this.name=Xc(e)?e:vr.Error),Error.captureStackTrace&&Error.captureStackTrace(this,xr)}Es(xr,!0);Object.defineProperties(xr.prototype,{code:{enumerable:!0,get:function(){var t=Ds.indexOf(this.name);return vs(t)?t:0}}});var xs={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},ki=Object.entries(xs);for(Dr=0;Dr<ki.length;Dr++)bs=ki[Dr][0],xr[bs]=ki[Dr][1];var bs,Dr;function Ri(t,e,r){this.message=t,this.locator=e,this.cause=r,Error.captureStackTrace&&Error.captureStackTrace(this,Ri)}Es(Ri);Tr.DOMException=xr;Tr.DOMExceptionName=vr;Tr.ExceptionCode=xs;Tr.ParseError=Ri});var Vi=Ze(F=>{"use strict";function _s(t){try{typeof t!="function"&&(t=RegExp);var e=new t("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var Rt=_s();function nt(t){if(t.source[0]!=="[")throw new Error(t+" can not be used with chars");return t.source.slice(1,t.source.lastIndexOf("]"))}function Ft(t,e){if(t.source[0]!=="[")throw new Error("/"+t.source+"/ can not be used with chars_without");if(!e||typeof e!="string")throw new Error(JSON.stringify(e)+" is not a valid search");if(t.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+t.source+"/");if(e==="-"&&t.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+t.source+"/");return new RegExp(t.source.replace(e,""),Rt?"u":"")}function L(t){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(r){var n=typeof r=="string";if(n&&e===void 0&&r==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return n?r:r.source}).join(""),Rt?"u":"")}function O(t){if(arguments.length===0)throw new Error("no parameters provided");return L.apply(O,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var Yc="\uFFFD",it=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;Rt&&(it=L("[",nt(it),"\\u{10000}-\\u{10FFFF}","]"));var Jc=new RegExp("[^"+nt(it)+"]",Rt?"u":""),gn=/[\x20\x09\x0D\x0A]/,Zc=nt(gn),j=L(gn,"+"),W=L(gn,"*"),Cr=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;Rt&&(Cr=L("[",nt(Cr),"\\u{10000}-\\u{10FFFF}","]"));var Kc=nt(Cr),Ui=L("[",Kc,nt(/[-.0-9\xB7]/),nt(/[\u0300-\u036F\u203F-\u2040]/),"]"),xe=L(Cr,Ui,"*"),Qc=L("^",xe,"$"),Ts=L(Ui,"+"),ef=L("&",xe,";"),tf=O(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),Sr=O(ef,"|",tf),Nr=L("%",xe,";"),$i=O(L('"',O(/[^%&"]/,"|",Nr,"|",Sr),"*",'"'),"|",L("'",O(/[^%&']/,"|",Nr,"|",Sr),"*","'")),rf=O('"',O(/[^<&"]/,"|",Sr),"*",'"',"|","'",O(/[^<&']/,"|",Sr),"*","'"),nf=Ft(Cr,":"),of=Ft(Ui,":"),Li=L(nf,of,"*"),sf=L("^",Li,"$"),_r=L(Li,O(":",Li),"?"),af=L("^",_r,"$"),uf=L("(",_r,")"),kt=O(/"[^"]*"|'[^']*'/),lf=L(/^<\?/,"(",xe,")",O(j,"(?!",gn,")(",it,"*?)"),"?",/\?>/),As=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,Ir=O('"',As,'*"',"|","'",Ft(As,"'"),"*'"),Is="<!--",Os="-->",cf=L(Is,O(Ft(it,"-"),"|",L("-",Ft(it,"-"))),"*",Os),Cs="#PCDATA",ff=O(L(/\(/,W,Cs,O(W,/\|/,W,_r),"*",W,/\)\*/),"|",L(/\(/,W,Cs,W,/\)/)),hf=/[?*+]?/,df=L(/\([^>]+\)/,hf),pf=O("EMPTY","|","ANY","|",ff,"|",df),mf="<!ELEMENT",gf=L(mf,j,O(_r,"|",Nr),j,O(pf,"|",Nr),W,">"),yf=L("NOTATION",j,/\(/,W,xe,O(W,/\|/,W,xe),"*",W,/\)/),wf=L(/\(/,W,Ts,O(W,/\|/,W,Ts),"*",W,/\)/),bf=O(yf,"|",wf),Ef=O(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",bf),Df=O(/#REQUIRED|#IMPLIED/,"|",O(O("#FIXED",j),"?",rf)),vf=O(j,xe,j,Ef,j,Df),xf="<!ATTLIST",Tf=L(xf,j,xe,vf,"*",W,">"),Pi="about:legacy-compat",Af=O('"'+Pi+'"',"|","'"+Pi+"'"),qi="SYSTEM",yn="PUBLIC",wn=O(O(qi,j,kt),"|",O(yn,j,Ir,j,kt)),Cf=L("^",O(O(qi,j,"(?<SystemLiteralOnly>",kt,")"),"|",O(yn,j,"(?<PubidLiteral>",Ir,")",j,"(?<SystemLiteral>",kt,")"))),Sf=L("^",Ir,"$"),Nf=L("^",kt,"$"),_f=O(j,"NDATA",j,xe),If=O($i,"|",O(wn,_f,"?")),Ms="<!ENTITY",Of=L(Ms,j,xe,j,If,W,">"),Mf=O($i,"|",wn),Bf=L(Ms,j,"%",j,xe,j,Mf,W,">"),Ff=O(Of,"|",Bf),kf=L(yn,j,Ir),Rf=L("<!NOTATION",j,xe,j,O(wn,"|",kf),W,">"),zi=L(W,"=",W),Ss=/1[.]\d+/,Lf=L(j,"version",zi,O("'",Ss,"'","|",'"',Ss,'"')),Ns=/[A-Za-z][-A-Za-z0-9._]*/,Pf=O(j,"encoding",zi,O('"',Ns,'"',"|","'",Ns,"'")),Uf=O(j,"standalone",zi,O("'",O("yes","|","no"),"'","|",'"',O("yes","|","no"),'"')),$f=L(/^<\?xml/,Lf,Pf,"?",Uf,"?",W,/\?>/),qf="<!DOCTYPE",zf="<![CDATA[",Vf="]]>",jf=/<!\[CDATA\[/,Hf=/\]\]>/,Gf=L(it,"*?",Hf),Wf=L(jf,Gf);F.chars=nt;F.chars_without=Ft;F.detectUnicodeSupport=_s;F.reg=L;F.regg=O;F.ABOUT_LEGACY_COMPAT=Pi;F.ABOUT_LEGACY_COMPAT_SystemLiteral=Af;F.AttlistDecl=Tf;F.CDATA_START=zf;F.CDATA_END=Vf;F.CDSect=Wf;F.Char=it;F.Comment=cf;F.COMMENT_START=Is;F.COMMENT_END=Os;F.DOCTYPE_DECL_START=qf;F.elementdecl=gf;F.EntityDecl=Ff;F.EntityValue=$i;F.ExternalID=wn;F.ExternalID_match=Cf;F.Name=xe;F.Name_exact=Qc;F.NCName_exact=sf;F.NotationDecl=Rf;F.Reference=Sr;F.PEReference=Nr;F.PI=lf;F.PUBLIC=yn;F.PubidLiteral=Ir;F.PubidLiteral_match=Sf;F.QName=_r;F.QName_exact=af;F.QName_group=uf;F.S=j;F.SChar_s=Zc;F.S_OPT=W;F.SYSTEM=qi;F.SystemLiteral=kt;F.SystemLiteral_match=Nf;F.InvalidChar=Jc;F.UNICODE_REPLACEMENT_CHARACTER=Yc;F.UNICODE_SUPPORT=Rt;F.XMLDecl=$f});var Qi=Ze(Z=>{"use strict";var Ne=yt(),$e=Ne.find,Xf=Ne.hasDefaultHTMLNamespace,Pt=Ne.hasOwn,Yf=Ne.isHTMLMimeType,Jf=Ne.isHTMLRawTextElement,Zf=Ne.isHTMLVoidElement,Or=Ne.MIME_TYPE,qe=Ne.NAMESPACE,ge=Symbol(),Us=Ar(),A=Us.DOMException,me=Us.DOMExceptionName,J=Vi();function Ee(t){if(t!==ge)throw new TypeError("Illegal constructor")}function Kf(t){return t!==""}function Qf(t){return t?t.split(/[\t\n\f\r ]+/).filter(Kf):[]}function eh(t,e){return Pt(t,e)||(t[e]=!0),t}function Bs(t){if(!t)return[];var e=Qf(t);return Object.keys(e.reduce(eh,{}))}function th(t){return function(e){return t&&t.indexOf(e)!==-1}}function $s(t){if(!J.QName_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+t+'"')}function Hi(t,e){$s(e),t=t||null;var r=null,n=e;if(e.indexOf(":")>=0){var i=e.split(":");r=i[0],n=i[1]}if(r!==null&&t===null)throw new A(A.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(r==="xml"&&t!==Ne.NAMESPACE.XML)throw new A(A.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((r==="xmlns"||e==="xmlns")&&t!==Ne.NAMESPACE.XMLNS)throw new A(A.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(t===Ne.NAMESPACE.XMLNS&&r!=="xmlns"&&e!=="xmlns")throw new A(A.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[t,r,n]}function qt(t,e){for(var r in t)Pt(t,r)&&(e[r]=t[r])}function De(t,e){var r=t.prototype;if(!(r instanceof e)){let n=function(){};n.prototype=e.prototype,n=new n,qt(r,n),t.prototype=r=n}r.constructor!=t&&(typeof t!="function"&&console.error("unknown Class:"+t),r.constructor=t)}var ve={},Se=ve.ELEMENT_NODE=1,Ut=ve.ATTRIBUTE_NODE=2,Mr=ve.TEXT_NODE=3,qs=ve.CDATA_SECTION_NODE=4,zs=ve.ENTITY_REFERENCE_NODE=5,rh=ve.ENTITY_NODE=6,Gi=ve.PROCESSING_INSTRUCTION_NODE=7,Wi=ve.COMMENT_NODE=8,Lt=ve.DOCUMENT_NODE=9,Vs=ve.DOCUMENT_TYPE_NODE=10,ot=ve.DOCUMENT_FRAGMENT_NODE=11,nh=ve.NOTATION_NODE=12,Y=Ne.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function js(t,e){if(e.length<t.length)return js(e,t);var r=null;for(var n in t){if(t[n]!==e[n])return r;r=t[n]}return r}function Fs(t){return t.guid||(t.guid=Math.random()),t.guid}function ne(){}ne.prototype={length:0,item:function(t){return t>=0&&t<this.length?this[t]:null},toString:function(t){var e;typeof t=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:t}:t?e={requireWellFormed:!!t.requireWellFormed,splitCDATASections:t.splitCDATASections!==!1,nodeFilter:t.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var r=[],n=0;n<this.length;n++)Ki(this[n],r,null,e);return r.join("")},filter:function(t){return Array.prototype.filter.call(this,t)},indexOf:function(t){return Array.prototype.indexOf.call(this,t)}};ne.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Ue(t,e){this._node=t,this._refresh=e,vn(this)}function vn(t){var e=t._node._inc||t._node.ownerDocument._inc;if(t._inc!==e){var r=t._refresh(t._node);if(ta(t,"length",r.length),!t.$$length||r.length<t.$$length)for(var n=r.length;n in t;n++)Pt(t,n)&&delete t[n];qt(r,t),t._inc=e}}Ue.prototype.item=function(t){return vn(this),this[t]||null};De(Ue,ne);function $t(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function Hs(t,e){for(var r=0;r<t.length;){if(t[r]===e)return r;r++}}function Xi(t,e,r){if(!e)return t._noNsIndex;var n=t._nsIndex[e];return!n&&r&&(n=t._nsIndex[e]=Object.create(null)),n}function ih(t,e,r){var n=Xi(t,e,!1),i=n&&n[r];return i||null}function oh(t,e){Xi(t,e.namespaceURI,!0)[e.localName]=e}function sh(t,e){var r=Xi(t,e.namespaceURI,!1);r&&delete r[e.localName]}function ah(t,e,r,n){if(n?e[Hs(e,n)]=r:(e[e.length]=r,e.length++),oh(e,r),t){r.ownerElement=t;var i=t.ownerDocument;i&&(n&&Xs(i,t,n),uh(i,t,r))}}function ks(t,e,r){var n=Hs(e,r);if(n>=0){for(var i=e.length-1;n<=i;)e[n]=e[++n];if(e.length=i,sh(e,r),t){var o=t.ownerDocument;o&&Xs(o,t,r),r.ownerElement=null}}}$t.prototype={length:0,item:ne.prototype.item,getNamedItem:function(t){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());for(var e=0;e<this.length;){var r=this[e];if(r.nodeName===t)return r;e++}return null},setNamedItem:function(t){var e=t.ownerElement;if(e&&e!==this._ownerElement)throw new A(A.INUSE_ATTRIBUTE_ERR);var r=ih(this,t.namespaceURI,t.localName);return r===t?t:(ah(this._ownerElement,this,t,r),r)},setNamedItemNS:function(t){return this.setNamedItem(t)},removeNamedItem:function(t){var e=this.getNamedItem(t);if(!e)throw new A(A.NOT_FOUND_ERR,t);return ks(this._ownerElement,this,e),e},removeNamedItemNS:function(t,e){var r=this.getNamedItemNS(t,e);if(!r)throw new A(A.NOT_FOUND_ERR,t?t+" : "+e:e);return ks(this._ownerElement,this,r),r},getNamedItemNS:function(t,e){t||(t=null);for(var r=0;r<this.length;){var n=this[r];if(n.localName===e&&n.namespaceURI===t)return n;r++}return null}};$t.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Gs(){}Gs.prototype={hasFeature:function(t,e){return!0},createDocument:function(t,e,r){var n=Or.XML_APPLICATION;t===qe.HTML?n=Or.XML_XHTML_APPLICATION:t===qe.SVG&&(n=Or.XML_SVG_IMAGE);var i=new We(ge,{contentType:n});if(i.implementation=this,i.childNodes=new ne,i.doctype=r||null,r&&i.appendChild(r),e){var o=i.createElementNS(t,e);i.appendChild(o)}return i},createDocumentType:function(t,e,r,n){$s(t);var i=new An(ge);return i.name=t,i.nodeName=t,i.publicId=e||"",i.systemId=r||"",i.internalSubset=n||"",i.childNodes=new ne,i},createHTMLDocument:function(t){var e=new We(ge,{contentType:Or.HTML});if(e.implementation=this,e.childNodes=new ne,t!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var r=e.createElement("html");e.appendChild(r);var n=e.createElement("head");if(r.appendChild(n),typeof t=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(t)),n.appendChild(i)}r.appendChild(e.createElement("body"))}return e}};function U(t){Ee(t)}U.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,parentNode:null,get parentElement(){return this.parentNode&&this.parentNode.nodeType===this.ELEMENT_NODE?this.parentNode:null},childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,baseURI:"about:blank",get isConnected(){var t=this.getRootNode();return t&&t.nodeType===t.DOCUMENT_NODE},contains:function(t){if(!t)return!1;var e=t;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(t){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(t){if(!t)return!1;for(var e=[{node:this,other:t}];e.length>0;){var r=e.pop(),n=r.node,i=r.other;if(n.nodeType!==i.nodeType)return!1;switch(n.nodeType){case n.DOCUMENT_TYPE_NODE:if(n.name!==i.name||n.publicId!==i.publicId||n.systemId!==i.systemId)return!1;break;case n.ELEMENT_NODE:if(n.namespaceURI!==i.namespaceURI||n.prefix!==i.prefix||n.localName!==i.localName||n.attributes.length!==i.attributes.length)return!1;for(var o=0;o<n.attributes.length;o++){var s=n.attributes.item(o),a=i.getAttributeNodeNS(s.namespaceURI,s.localName);if(!a)return!1;e.push({node:s,other:a})}break;case n.ATTRIBUTE_NODE:if(n.namespaceURI!==i.namespaceURI||n.localName!==i.localName||n.value!==i.value)return!1;break;case n.PROCESSING_INSTRUCTION_NODE:if(n.target!==i.target||n.data!==i.data)return!1;break;case n.TEXT_NODE:case n.CDATA_SECTION_NODE:case n.COMMENT_NODE:if(n.data!==i.data)return!1;break}if(n.childNodes.length!==i.childNodes.length)return!1;for(var o=n.childNodes.length-1;o>=0;o--)e.push({node:n.childNodes[o],other:i.childNodes[o]})}return!0},isSameNode:function(t){return this===t},insertBefore:function(t,e){return Dn(this,t,e)},replaceChild:function(t,e){Dn(this,t,e,Zs),e&&this.removeChild(e)},removeChild:function(t){return Ys(this,t)},appendChild:function(t){return this.insertBefore(t,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(t){return ea(this.ownerDocument||this,this,t)},normalize:function(){ce(this,null,{enter:function(t){for(var e=t.firstChild;e;){var r=e.nextSibling;if(r!==null&&r.nodeType===Mr&&e.nodeType===Mr){for(var n=[],i=r;i!==null&&i.nodeType===Mr;)n.push(i.data),i=i.nextSibling;for(var o=e.nextSibling;o!==i;){var s=o.nextSibling;o.parentNode=null,o.previousSibling=null,o.nextSibling=null,o=s}e.nextSibling=i,i!==null?i.previousSibling=e:t.lastChild=e,e.appendData(n.join("")),Yi(t.ownerDocument,t),e=i}else e=r}return!0}})},isSupported:function(t,e){return this.ownerDocument.implementation.hasFeature(t,e)},lookupPrefix:function(t){for(var e=this;e;){var r=e._nsMap;if(r){for(var n in r)if(Pt(r,n)&&r[n]===t)return n}e=e.nodeType==Ut?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(t){for(var e=this;e;){var r=e._nsMap;if(r&&Pt(r,t))return r[t];e=e.nodeType==Ut?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(t){var e=this.lookupPrefix(t);return e==null},compareDocumentPosition:function(t){if(this===t)return 0;var e=t,r=this,n=null,i=null;if(e instanceof wt&&(n=e,e=n.ownerElement),r instanceof wt&&(i=r,r=i.ownerElement,n&&e&&r===e))for(var o=0,s;s=r.attributes[o];o++){if(s===n)return Y.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Y.DOCUMENT_POSITION_PRECEDING;if(s===i)return Y.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Y.DOCUMENT_POSITION_FOLLOWING}if(!e||!r||r.ownerDocument!==e.ownerDocument)return Y.DOCUMENT_POSITION_DISCONNECTED+Y.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(Fs(r.ownerDocument)>Fs(e.ownerDocument)?Y.DOCUMENT_POSITION_FOLLOWING:Y.DOCUMENT_POSITION_PRECEDING);if(i&&e===r)return Y.DOCUMENT_POSITION_CONTAINS+Y.DOCUMENT_POSITION_PRECEDING;if(n&&e===r)return Y.DOCUMENT_POSITION_CONTAINED_BY+Y.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===r)return Y.DOCUMENT_POSITION_CONTAINED_BY+Y.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=r.parentNode;c;){if(!n&&c===e)return Y.DOCUMENT_POSITION_CONTAINS+Y.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var f=js(a,u);for(var h in f.childNodes){var d=f.childNodes[h];if(d===r)return Y.DOCUMENT_POSITION_FOLLOWING;if(d===e)return Y.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(d)>=0)return Y.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(d)>=0)return Y.DOCUMENT_POSITION_PRECEDING}return 0}};function Ws(t){return t=="<"&&"&lt;"||t==">"&&"&gt;"||t=="&"&&"&amp;"||t=='"'&&"&quot;"||"&#"+t.charCodeAt()+";"}qt(ve,U);qt(ve,U.prototype);qt(Y,U);qt(Y,U.prototype);function En(t,e){ce(t,null,{enter:function(r){return e(r)?ce.STOP:!0}})}function ce(t,e,r){for(var n=[{node:t,context:e,phase:ce.ENTER}];n.length>0;){var i=n.pop();if(i.phase===ce.ENTER){var o=r.enter(i.node,i.context);if(o===ce.STOP)return ce.STOP;if(n.push({node:i.node,context:o,phase:ce.EXIT}),o==null)continue;for(var s=i.node.lastChild;s;)n.push({node:s,context:o,phase:ce.ENTER}),s=s.previousSibling}else r.exit&&r.exit(i.node,i.context)}}ce.STOP=Symbol("walkDOM.STOP");ce.ENTER=0;ce.EXIT=1;function We(t,e){Ee(t);var r=e||{};this.ownerDocument=this,this.contentType=r.contentType||Or.XML_APPLICATION,this.type=Yf(this.contentType)?"html":"xml"}function uh(t,e,r){t&&t._inc++;var n=r.namespaceURI;n===qe.XMLNS&&(e._nsMap[r.prefix?r.localName:""]=r.value)}function Xs(t,e,r,n){t&&t._inc++;var i=r.namespaceURI;i===qe.XMLNS&&delete e._nsMap[r.prefix?r.localName:""]}function Yi(t,e,r){if(t&&t._inc){t._inc++;var n=e.childNodes;if(r&&!r.nextSibling)n[n.length++]=r;else{for(var i=e.firstChild,o=0;i;)n[o++]=i,i=i.nextSibling;n.length=o,delete n[n.length]}}}function Ys(t,e){if(t!==e.parentNode)throw new A(A.NOT_FOUND_ERR,"child's parent is not parent");var r=e.previousSibling,n=e.nextSibling;return r?r.nextSibling=n:t.firstChild=n,n?n.previousSibling=r:t.lastChild=r,Yi(t.ownerDocument,t),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function lh(t){return t&&(t.nodeType===U.DOCUMENT_NODE||t.nodeType===U.DOCUMENT_FRAGMENT_NODE||t.nodeType===U.ELEMENT_NODE)}function ch(t){return t&&(t.nodeType===U.CDATA_SECTION_NODE||t.nodeType===U.COMMENT_NODE||t.nodeType===U.DOCUMENT_FRAGMENT_NODE||t.nodeType===U.DOCUMENT_TYPE_NODE||t.nodeType===U.ELEMENT_NODE||t.nodeType===U.PROCESSING_INSTRUCTION_NODE||t.nodeType===U.TEXT_NODE)}function st(t){return t&&t.nodeType===U.DOCUMENT_TYPE_NODE}function Ge(t){return t&&t.nodeType===U.ELEMENT_NODE}function Js(t){return t&&t.nodeType===U.TEXT_NODE}function Rs(t,e){var r=t.childNodes||[];if($e(r,Ge)||st(e))return!1;var n=$e(r,st);return!(e&&n&&r.indexOf(n)>r.indexOf(e))}function Ls(t,e){var r=t.childNodes||[];function n(o){return Ge(o)&&o!==e}if($e(r,n))return!1;var i=$e(r,st);return!(e&&i&&r.indexOf(i)>r.indexOf(e))}function fh(t,e,r){if(!lh(t))throw new A(A.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+t.nodeType);if(r&&r.parentNode!==t)throw new A(A.NOT_FOUND_ERR,"child not in parent");if(!ch(e)||st(e)&&t.nodeType!==U.DOCUMENT_NODE)throw new A(A.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+t.nodeType)}function hh(t,e,r){var n=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===U.DOCUMENT_FRAGMENT_NODE){var o=i.filter(Ge);if(o.length>1||$e(i,Js))throw new A(A.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(o.length===1&&!Rs(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(Ge(e)&&!Rs(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(st(e)){if($e(n,st))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var s=$e(n,Ge);if(r&&n.indexOf(s)<n.indexOf(r))throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!r&&s)throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function Zs(t,e,r){var n=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===U.DOCUMENT_FRAGMENT_NODE){var o=i.filter(Ge);if(o.length>1||$e(i,Js))throw new A(A.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(o.length===1&&!Ls(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(Ge(e)&&!Ls(t,r))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(st(e)){if($e(n,function(l){return st(l)&&l!==r}))throw new A(A.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var s=$e(n,Ge);if(r&&n.indexOf(s)<n.indexOf(r))throw new A(A.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function Dn(t,e,r,n){fh(t,e,r),t.nodeType===U.DOCUMENT_NODE&&(n||hh)(t,e,r);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===ot){var o=e.firstChild;if(o==null)return e;var s=e.lastChild}else o=s=e;var a=r?r.previousSibling:t.lastChild;o.previousSibling=a,s.nextSibling=r,a?a.nextSibling=o:t.firstChild=o,r==null?t.lastChild=s:r.previousSibling=s;do o.parentNode=t;while(o!==s&&(o=o.nextSibling));return Yi(t.ownerDocument||t,t,e),e.nodeType==ot&&(e.firstChild=e.lastChild=null),e}We.prototype={implementation:null,nodeName:"#document",nodeType:Lt,doctype:null,documentElement:null,_inc:1,insertBefore:function(t,e){if(t.nodeType===ot){for(var r=t.firstChild;r;){var n=r.nextSibling;this.insertBefore(r,e),r=n}return t}return Dn(this,t,e),t.ownerDocument=this,this.documentElement===null&&t.nodeType===Se&&(this.documentElement=t),t},removeChild:function(t){var e=Ys(this,t);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(t,e){Dn(this,t,e,Zs),t.ownerDocument=this,e&&this.removeChild(e),Ge(t)&&(this.documentElement=t)},importNode:function(t,e){return dh(this,t,e)},getElementById:function(t){var e=null;return En(this.documentElement,function(r){if(r.nodeType==Se&&r.getAttribute("id")==t)return e=r,!0}),e},createElement:function(t){var e=new Xe(ge);e.ownerDocument=this,this.type==="html"&&(t=t.toLowerCase()),Xf(this.contentType)&&(e.namespaceURI=qe.HTML),e.nodeName=t,e.tagName=t,e.localName=t,e.childNodes=new ne;var r=e.attributes=new $t;return r._ownerElement=e,e},createDocumentFragment:function(){var t=new zt(ge);return t.ownerDocument=this,t.childNodes=new ne,t},createTextNode:function(t){var e=new Br(ge);return e.ownerDocument=this,e.childNodes=new ne,e.appendData(t),e},createComment:function(t){var e=new xn(ge);return e.ownerDocument=this,e.childNodes=new ne,e.appendData(t),e},createCDATASection:function(t){if(t.indexOf("]]>")!==-1)throw new A(A.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new Tn(ge);return e.ownerDocument=this,e.childNodes=new ne,e.appendData(t),e},createProcessingInstruction:function(t,e){var r=new Sn(ge);return r.ownerDocument=this,r.childNodes=new ne,r.nodeName=r.target=t,r.nodeValue=r.data=e,r},createAttribute:function(t){if(!J.QName_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'invalid character in name "'+t+'"');return this.type==="html"&&(t=t.toLowerCase()),this._createAttribute(t)},_createAttribute:function(t){var e=new wt(ge);return e.ownerDocument=this,e.childNodes=new ne,e.name=t,e.nodeName=t,e.localName=t,e.specified=!0,e},createEntityReference:function(t){if(!J.Name_exact.test(t))throw new A(A.INVALID_CHARACTER_ERR,'not a valid xml name "'+t+'"');if(this.type==="html")throw new A("document is an html document",me.NotSupportedError);var e=new Cn(ge);return e.ownerDocument=this,e.childNodes=new ne,e.nodeName=t,e},createElementNS:function(t,e){var r=Hi(t,e),n=new Xe(ge),i=n.attributes=new $t;return n.childNodes=new ne,n.ownerDocument=this,n.nodeName=e,n.tagName=e,n.namespaceURI=r[0],n.prefix=r[1],n.localName=r[2],i._ownerElement=n,n},createAttributeNS:function(t,e){var r=Hi(t,e),n=new wt(ge);return n.ownerDocument=this,n.childNodes=new ne,n.nodeName=e,n.name=e,n.specified=!0,n.namespaceURI=r[0],n.prefix=r[1],n.localName=r[2],n}};De(We,U);function Xe(t){Ee(t),this._nsMap=Object.create(null)}Xe.prototype={nodeType:Se,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===qe.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(t){return!!this.getAttributeNode(t)},getAttribute:function(t){var e=this.getAttributeNode(t);return e?e.value:null},getAttributeNode:function(t){return this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase()),this.attributes.getNamedItem(t)},setAttribute:function(t,e){this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());var r=this.getAttributeNode(t);r?r.value=r.nodeValue=""+e:(r=this.ownerDocument._createAttribute(t),r.value=r.nodeValue=""+e,this.setAttributeNode(r))},removeAttribute:function(t){var e=this.getAttributeNode(t);e&&this.removeAttributeNode(e)},setAttributeNode:function(t){return this.attributes.setNamedItem(t)},setAttributeNodeNS:function(t){return this.attributes.setNamedItemNS(t)},removeAttributeNode:function(t){return this.attributes.removeNamedItem(t.nodeName)},removeAttributeNS:function(t,e){var r=this.getAttributeNodeNS(t,e);r&&this.removeAttributeNode(r)},hasAttributeNS:function(t,e){return this.getAttributeNodeNS(t,e)!=null},getAttributeNS:function(t,e){var r=this.getAttributeNodeNS(t,e);return r?r.value:null},setAttributeNS:function(t,e,r){var n=Hi(t,e),i=n[2],o=this.getAttributeNodeNS(t,i);o?o.value=o.nodeValue=""+r:(o=this.ownerDocument.createAttributeNS(t,e),o.value=o.nodeValue=""+r,this.setAttributeNode(o))},getAttributeNodeNS:function(t,e){return this.attributes.getNamedItemNS(t,e)},getElementsByClassName:function(t){var e=Bs(t);return new Ue(this,function(r){var n=[];return e.length>0&&En(r,function(i){if(i!==r&&i.nodeType===Se){var o=i.getAttribute("class");if(o){var s=t===o;if(!s){var a=Bs(o);s=e.every(th(a))}s&&n.push(i)}}}),n})},getElementsByTagName:function(t){var e=(this.nodeType===Lt?this:this.ownerDocument).type==="html",r=t.toLowerCase();return new Ue(this,function(n){var i=[];return En(n,function(o){if(!(o===n||o.nodeType!==Se))if(t==="*")i.push(o);else{var s=o.getQualifiedName(),a=e&&o.namespaceURI===qe.HTML?r:t;s===a&&i.push(o)}}),i})},getElementsByTagNameNS:function(t,e){return new Ue(this,function(r){var n=[];return En(r,function(i){i!==r&&i.nodeType===Se&&(t==="*"||i.namespaceURI===t)&&(e==="*"||i.localName==e)&&n.push(i)}),n})}};We.prototype.getElementsByClassName=Xe.prototype.getElementsByClassName;We.prototype.getElementsByTagName=Xe.prototype.getElementsByTagName;We.prototype.getElementsByTagNameNS=Xe.prototype.getElementsByTagNameNS;De(Xe,U);function wt(t){Ee(t),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}wt.prototype.nodeType=Ut;De(wt,U);function at(t){Ee(t)}at.prototype={data:"",substringData:function(t,e){return this.data.substring(t,t+e)},appendData:function(t){t=this.data+t,this.nodeValue=this.data=t,this.length=t.length},insertData:function(t,e){this.replaceData(t,0,e)},deleteData:function(t,e){this.replaceData(t,e,"")},replaceData:function(t,e,r){var n=this.data.substring(0,t),i=this.data.substring(t+e);r=n+r+i,this.nodeValue=this.data=r,this.length=r.length}};De(at,U);function Br(t){Ee(t)}Br.prototype={nodeName:"#text",nodeType:Mr,splitText:function(t){var e=this.data,r=e.substring(t);e=e.substring(0,t),this.data=this.nodeValue=e,this.length=e.length;var n=this.ownerDocument.createTextNode(r);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}};De(Br,at);function xn(t){Ee(t)}xn.prototype={nodeName:"#comment",nodeType:Wi};De(xn,at);function Tn(t){Ee(t)}Tn.prototype={nodeName:"#cdata-section",nodeType:qs};De(Tn,Br);function An(t){Ee(t)}An.prototype.nodeType=Vs;De(An,U);function Ji(t){Ee(t)}Ji.prototype.nodeType=nh;De(Ji,U);function Zi(t){Ee(t)}Zi.prototype.nodeType=rh;De(Zi,U);function Cn(t){Ee(t)}Cn.prototype.nodeType=zs;De(Cn,U);function zt(t){Ee(t)}zt.prototype.nodeName="#document-fragment";zt.prototype.nodeType=ot;De(zt,U);function Sn(t){Ee(t)}Sn.prototype.nodeType=Gi;De(Sn,at);function Ks(){}Ks.prototype.serializeToString=function(t,e){return Qs.call(t,e)};U.prototype.toString=Qs;function Qs(t){var e;typeof t=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:t}:t!=null?e={requireWellFormed:!!t.requireWellFormed,splitCDATASections:t.splitCDATASections!==!1,nodeFilter:t.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var r=[],n=this.nodeType===Lt&&this.documentElement||this,i=n.prefix,o=n.namespaceURI;if(o&&i==null){var i=n.lookupPrefix(o);if(i==null)var s=[{namespace:o,prefix:null}]}return Ki(this,r,s,e),r.join("")}function Ps(t,e,r){var n=t.prefix||"",i=t.namespaceURI;if(!i||n==="xml"&&i===qe.XML||i===qe.XMLNS)return!1;for(var o=r.length;o--;){var s=r[o];if(s.prefix===n)return s.namespace!==i}return!0}function bn(t,e,r,n){if(n&&!J.QName_exact.test(e))throw new A('The attribute name "'+e+'" is not a valid XML QName',me.InvalidStateError);t.push(" ",e,'="',r.replace(/[<>&"\t\n\r]/g,Ws),'"')}function Ki(t,e,r,n){r||(r=[]);var i=n.nodeFilter,o=n.requireWellFormed,s=n.splitCDATASections,a=t.nodeType===Lt?t:t.ownerDocument,l=a.type==="html";ce(t,{ns:r},{enter:function(u,c){var f=c.ns;if(i)if(u=i(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case Se:var h=u.attributes,d=h.length,g=u.tagName,p=g;if(!l&&!u.prefix&&u.namespaceURI){for(var y,m=0;m<h.length;m++)if(h.item(m).name==="xmlns"){y=h.item(m).value;break}if(!y)for(var w=f.length-1;w>=0;w--){var b=f[w];if(b.prefix===""&&b.namespace===u.namespaceURI){y=b.namespace;break}}if(y!==u.namespaceURI)for(var w=f.length-1;w>=0;w--){var b=f[w];if(b.namespace===u.namespaceURI){b.prefix&&(p=b.prefix+":"+g);break}}}if(o&&!J.QName_exact.test(p))throw new A('The element name "'+p+'" is not a valid XML QName',me.InvalidStateError);e.push("<",p);for(var v=f.slice(),x=0;x<d;x++){var T=h.item(x);T.prefix=="xmlns"?v.push({prefix:T.localName,namespace:T.value}):T.nodeName=="xmlns"&&v.push({prefix:"",namespace:T.value})}for(var x=0;x<d;x++){var T=h.item(x);if(Ps(T,l,v)){var E=T.prefix||"",C=T.namespaceURI;bn(e,E?"xmlns:"+E:"xmlns",C,o),v.push({prefix:E,namespace:C})}var M=i?i(T):T;M&&(typeof M=="string"?e.push(M):bn(e,M.name,M.value,o))}if(g===p&&Ps(u,l,v)){var I=u.prefix||"",C=u.namespaceURI;bn(e,I?"xmlns:"+I:"xmlns",C,o),v.push({prefix:I,namespace:C})}var _=!u.firstChild;if(_&&(l||u.namespaceURI===qe.HTML)&&(_=Zf(g)),_)return e.push("/>"),null;if(e.push(">"),l&&Jf(g)){for(var P=u.firstChild;P;)P.data?e.push(P.data):Ki(P,e,v.slice(),n),P=P.nextSibling;return e.push("</",p,">"),null}return{ns:v,tag:p};case Lt:case ot:if(o&&u.nodeType===Lt&&u.documentElement==null)throw new A("The Document has no documentElement",me.InvalidStateError);return{ns:f};case Ut:return bn(e,u.name,u.value,o),null;case Mr:if(o&&J.InvalidChar.test(u.data))throw new A("The Text node data contains characters outside the XML Char production",me.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Ws)),null;case qs:if(o&&u.data.indexOf("]]>")!==-1)throw new A('The CDATASection data contains "]]>"',me.InvalidStateError);return s?e.push(J.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),J.CDATA_END):e.push(J.CDATA_START,u.data,J.CDATA_END),null;case Wi:if(o){if(J.InvalidChar.test(u.data))throw new A("The comment node data contains characters outside the XML Char production",me.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new A('The comment node data contains "--" or ends with "-"',me.InvalidStateError)}return e.push(J.COMMENT_START,u.data,J.COMMENT_END),null;case Vs:var K=u.publicId,z=u.systemId;if(o){if(!J.Name_exact.test(u.name))throw new A('The doctype name "'+u.name+'" is not a valid XML Name',me.InvalidStateError);if(K&&!J.PubidLiteral_match.test(K))throw new A("DocumentType publicId is not a valid PubidLiteral",me.InvalidStateError);if(z&&z!=="."&&!J.SystemLiteral_match.test(z))throw new A("DocumentType systemId is not a valid SystemLiteral",me.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new A('DocumentType internalSubset contains "]>"',me.InvalidStateError)}return e.push(J.DOCTYPE_DECL_START," ",u.name),K?(e.push(" ",J.PUBLIC," ",K),z&&z!=="."&&e.push(" ",z)):z&&z!=="."&&e.push(" ",J.SYSTEM," ",z),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case Gi:if(o){if(!J.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new A('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',me.InvalidStateError);if(J.InvalidChar.test(u.data))throw new A("The ProcessingInstruction data contains characters outside the XML Char production",me.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new A('The ProcessingInstruction data contains "?>"',me.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case zs:if(o&&!J.Name_exact.test(u.nodeName))throw new A('The entity reference name "'+u.nodeName+'" is not a valid XML Name',me.InvalidStateError);return e.push("&",u.nodeName,";"),null;default:return e.push("??",u.nodeName),null}},exit:function(u,c){c&&c.tag&&e.push("</",c.tag,">")}})}function dh(t,e,r){var n;return ce(e,null,{enter:function(i,o){var s=i.cloneNode(!1);s.ownerDocument=t,s.parentNode=null,o===null?n=s:o.appendChild(s);var a=i.nodeType===Ut||r;return a?s:null}}),n}function ea(t,e,r){var n;return ce(e,null,{enter:function(i,o){var s=new i.constructor(ge);for(var a in i)if(Pt(i,a)){var l=i[a];typeof l!="object"&&l!=s[a]&&(s[a]=l)}i.childNodes&&(s.childNodes=new ne),s.ownerDocument=t;var u=r;switch(s.nodeType){case Se:var c=i.attributes,f=s.attributes=new $t,h=c.length;f._ownerElement=s;for(var d=0;d<h;d++)s.setAttributeNode(ea(t,c.item(d),!0));break;case Ut:u=!0}return o!==null?o.appendChild(s):n=s,u?s:null}}),n}function ta(t,e,r){t[e]=r}function ji(t){for(var e=[],r=t.firstChild;r;)r.nodeType===Se&&e.push(r),r=r.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Ue.prototype,"length",{get:function(){return vn(this),this.$$length}}),Object.defineProperty(U.prototype,"textContent",{get:function(){if(this.nodeType===Se||this.nodeType===ot){var t=[];return ce(this,null,{enter:function(e){if(e.nodeType===Se||e.nodeType===ot)return!0;if(e.nodeType===Gi||e.nodeType===Wi)return null;t.push(e.nodeValue)}}),t.join("")}return this.nodeValue},set:function(t){switch(this.nodeType){case Se:case ot:for(;this.firstChild;)this.removeChild(this.firstChild);(t||String(t))&&this.appendChild(this.ownerDocument.createTextNode(t));break;default:this.data=t,this.value=t,this.nodeValue=t}}}),Object.defineProperty(at.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(t){this._data=t,this.length=typeof t=="string"?t.length:0}}),Object.defineProperty(at.prototype,"nodeValue",{get:function(){return this.data},set:function(t){this.data=t},enumerable:!0,configurable:!0}),Object.defineProperty(Xe.prototype,"children",{get:function(){return new Ue(this,ji)}}),Object.defineProperty(We.prototype,"children",{get:function(){return new Ue(this,ji)}}),Object.defineProperty(zt.prototype,"children",{get:function(){return new Ue(this,ji)}}),ta=function(t,e,r){t["$$"+e]=r})}catch{}Z._updateLiveList=vn;Z.Attr=wt;Z.CDATASection=Tn;Z.CharacterData=at;Z.Comment=xn;Z.Document=We;Z.DocumentFragment=zt;Z.DocumentType=An;Z.DOMImplementation=Gs;Z.Element=Xe;Z.Entity=Zi;Z.EntityReference=Cn;Z.LiveNodeList=Ue;Z.NamedNodeMap=$t;Z.Node=U;Z.NodeList=ne;Z.Notation=Ji;Z.Text=Br;Z.ProcessingInstruction=Sn;Z.walkDOM=ce;Z.XMLSerializer=Ks});var na=Ze(Fr=>{"use strict";var ra=yt().freeze;Fr.XML_ENTITIES=ra({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});Fr.HTML_ENTITIES=ra({Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",AMP:"&",amp:"&",And:"\u2A53",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",ap:"\u2248",apacir:"\u2A6F",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",Barwed:"\u2306",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",Because:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxDL:"\u2557",boxDl:"\u2556",boxdL:"\u2555",boxdl:"\u2510",boxDR:"\u2554",boxDr:"\u2553",boxdR:"\u2552",boxdr:"\u250C",boxH:"\u2550",boxh:"\u2500",boxHD:"\u2566",boxHd:"\u2564",boxhD:"\u2565",boxhd:"\u252C",boxHU:"\u2569",boxHu:"\u2567",boxhU:"\u2568",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxUL:"\u255D",boxUl:"\u255C",boxuL:"\u255B",boxul:"\u2518",boxUR:"\u255A",boxUr:"\u2559",boxuR:"\u2558",boxur:"\u2514",boxV:"\u2551",boxv:"\u2502",boxVH:"\u256C",boxVh:"\u256B",boxvH:"\u256A",boxvh:"\u253C",boxVL:"\u2563",boxVl:"\u2562",boxvL:"\u2561",boxvl:"\u2524",boxVR:"\u2560",boxVr:"\u255F",boxvR:"\u255E",boxvr:"\u251C",bprime:"\u2035",Breve:"\u02D8",breve:"\u02D8",brvbar:"\xA6",Bscr:"\u212C",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",Bumpeq:"\u224E",bumpeq:"\u224F",Cacute:"\u0106",cacute:"\u0107",Cap:"\u22D2",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",Ccaron:"\u010C",ccaron:"\u010D",Ccedil:"\xC7",ccedil:"\xE7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",Cdot:"\u010A",cdot:"\u010B",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",CenterDot:"\xB7",centerdot:"\xB7",Cfr:"\u212D",cfr:"\u{1D520}",CHcy:"\u0427",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",Chi:"\u03A7",chi:"\u03C7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cirE:"\u29C3",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",Colon:"\u2237",colon:":",Colone:"\u2A74",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",Conint:"\u222F",conint:"\u222E",ContourIntegral:"\u222E",Copf:"\u2102",copf:"\u{1D554}",coprod:"\u2210",Coproduct:"\u2210",COPY:"\xA9",copy:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",Cross:"\u2A2F",cross:"\u2717",Cscr:"\u{1D49E}",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",Cup:"\u22D3",cup:"\u222A",cupbrcap:"\u2A48",CupCap:"\u224D",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",Dagger:"\u2021",dagger:"\u2020",daleth:"\u2138",Darr:"\u21A1",dArr:"\u21D3",darr:"\u2193",dash:"\u2010",Dashv:"\u2AE4",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",Dcaron:"\u010E",dcaron:"\u010F",Dcy:"\u0414",dcy:"\u0434",DD:"\u2145",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",Delta:"\u0394",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",Dfr:"\u{1D507}",dfr:"\u{1D521}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",Diamond:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",DJcy:"\u0402",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",Dopf:"\u{1D53B}",dopf:"\u{1D555}",Dot:"\xA8",dot:"\u02D9",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",Downarrow:"\u21D3",downarrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",Dscr:"\u{1D49F}",dscr:"\u{1D4B9}",DScy:"\u0405",dscy:"\u0455",dsol:"\u29F6",Dstrok:"\u0110",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",DZcy:"\u040F",dzcy:"\u045F",dzigrarr:"\u27FF",Eacute:"\xC9",eacute:"\xE9",easter:"\u2A6E",Ecaron:"\u011A",ecaron:"\u011B",ecir:"\u2256",Ecirc:"\xCA",ecirc:"\xEA",ecolon:"\u2255",Ecy:"\u042D",ecy:"\u044D",eDDot:"\u2A77",Edot:"\u0116",eDot:"\u2251",edot:"\u0117",ee:"\u2147",efDot:"\u2252",Efr:"\u{1D508}",efr:"\u{1D522}",eg:"\u2A9A",Egrave:"\xC8",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",Emacr:"\u0112",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",ENG:"\u014A",eng:"\u014B",ensp:"\u2002",Eogon:"\u0118",eogon:"\u0119",Eopf:"\u{1D53C}",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",Escr:"\u2130",escr:"\u212F",esdot:"\u2250",Esim:"\u2A73",esim:"\u2242",Eta:"\u0397",eta:"\u03B7",ETH:"\xD0",eth:"\xF0",Euml:"\xCB",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",ExponentialE:"\u2147",exponentiale:"\u2147",fallingdotseq:"\u2252",Fcy:"\u0424",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",Ffr:"\u{1D509}",ffr:"\u{1D523}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",Fopf:"\u{1D53D}",fopf:"\u{1D557}",ForAll:"\u2200",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",Fscr:"\u2131",fscr:"\u{1D4BB}",gacute:"\u01F5",Gamma:"\u0393",gamma:"\u03B3",Gammad:"\u03DC",gammad:"\u03DD",gap:"\u2A86",Gbreve:"\u011E",gbreve:"\u011F",Gcedil:"\u0122",Gcirc:"\u011C",gcirc:"\u011D",Gcy:"\u0413",gcy:"\u0433",Gdot:"\u0120",gdot:"\u0121",gE:"\u2267",ge:"\u2265",gEl:"\u2A8C",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",Gfr:"\u{1D50A}",gfr:"\u{1D524}",Gg:"\u22D9",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",GJcy:"\u0403",gjcy:"\u0453",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gnE:"\u2269",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",Gopf:"\u{1D53E}",gopf:"\u{1D558}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",Gt:"\u226B",GT:">",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",HARDcy:"\u042A",hardcy:"\u044A",hArr:"\u21D4",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",Hcirc:"\u0124",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",Hfr:"\u210C",hfr:"\u{1D525}",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",Hopf:"\u210D",hopf:"\u{1D559}",horbar:"\u2015",HorizontalLine:"\u2500",Hscr:"\u210B",hscr:"\u{1D4BD}",hslash:"\u210F",Hstrok:"\u0126",hstrok:"\u0127",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",Iacute:"\xCD",iacute:"\xED",ic:"\u2063",Icirc:"\xCE",icirc:"\xEE",Icy:"\u0418",icy:"\u0438",Idot:"\u0130",IEcy:"\u0415",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",Ifr:"\u2111",ifr:"\u{1D526}",Igrave:"\xCC",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",IJlig:"\u0132",ijlig:"\u0133",Im:"\u2111",Imacr:"\u012A",imacr:"\u012B",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",Int:"\u222C",int:"\u222B",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",IOcy:"\u0401",iocy:"\u0451",Iogon:"\u012E",iogon:"\u012F",Iopf:"\u{1D540}",iopf:"\u{1D55A}",Iota:"\u0399",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",Iscr:"\u2110",iscr:"\u{1D4BE}",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",Itilde:"\u0128",itilde:"\u0129",Iukcy:"\u0406",iukcy:"\u0456",Iuml:"\xCF",iuml:"\xEF",Jcirc:"\u0134",jcirc:"\u0135",Jcy:"\u0419",jcy:"\u0439",Jfr:"\u{1D50D}",jfr:"\u{1D527}",jmath:"\u0237",Jopf:"\u{1D541}",jopf:"\u{1D55B}",Jscr:"\u{1D4A5}",jscr:"\u{1D4BF}",Jsercy:"\u0408",jsercy:"\u0458",Jukcy:"\u0404",jukcy:"\u0454",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",Kcedil:"\u0136",kcedil:"\u0137",Kcy:"\u041A",kcy:"\u043A",Kfr:"\u{1D50E}",kfr:"\u{1D528}",kgreen:"\u0138",KHcy:"\u0425",khcy:"\u0445",KJcy:"\u040C",kjcy:"\u045C",Kopf:"\u{1D542}",kopf:"\u{1D55C}",Kscr:"\u{1D4A6}",kscr:"\u{1D4C0}",lAarr:"\u21DA",Lacute:"\u0139",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",Lambda:"\u039B",lambda:"\u03BB",Lang:"\u27EA",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",Larr:"\u219E",lArr:"\u21D0",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",lAtail:"\u291B",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lBarr:"\u290E",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",Lcaron:"\u013D",lcaron:"\u013E",Lcedil:"\u013B",lcedil:"\u013C",lceil:"\u2308",lcub:"{",Lcy:"\u041B",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",lE:"\u2266",le:"\u2264",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",Leftarrow:"\u21D0",leftarrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",LeftRightArrow:"\u2194",Leftrightarrow:"\u21D4",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",lEg:"\u2A8B",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",Lfr:"\u{1D50F}",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",LJcy:"\u0409",ljcy:"\u0459",Ll:"\u22D8",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",Lmidot:"\u013F",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lnE:"\u2268",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",LongLeftArrow:"\u27F5",Longleftarrow:"\u27F8",longleftarrow:"\u27F5",LongLeftRightArrow:"\u27F7",Longleftrightarrow:"\u27FA",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",LongRightArrow:"\u27F6",Longrightarrow:"\u27F9",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",Lopf:"\u{1D543}",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",Lscr:"\u2112",lscr:"\u{1D4C1}",Lsh:"\u21B0",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",Lstrok:"\u0141",lstrok:"\u0142",Lt:"\u226A",LT:"<",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",Map:"\u2905",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",Mcy:"\u041C",mcy:"\u043C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",Mopf:"\u{1D544}",mopf:"\u{1D55E}",mp:"\u2213",Mscr:"\u2133",mscr:"\u{1D4C2}",mstpos:"\u223E",Mu:"\u039C",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",Nacute:"\u0143",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",Ncy:"\u041D",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",neArr:"\u21D7",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
2
+ `,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"});Fr.entityMap=Fr.HTML_ENTITIES});var ha=Ze(_n=>{"use strict";var Wt=yt(),k=Vi(),aa=Ar(),ph=Wt.isHTMLEscapableRawTextElement,mh=Wt.isHTMLMimeType,gh=Wt.isHTMLRawTextElement,Lr=Wt.hasOwn,ia=Wt.NAMESPACE,yh=aa.ParseError,wh=aa.DOMException,Vt=0,ut=1,jt=2,kr=3,Ht=4,Gt=5,Rr=6,Nn=7;function ua(){}ua.prototype={parse:function(t,e,r){var n=this.domBuilder;n.startDocument(),vh(e,e=Object.create(null)),bh(t,e,r,n,this.errorHandler),n.endDocument()}};var eo=/&#?\w+;?/g;function bh(t,e,r,n,i){var o=mh(n.mimeType);t.indexOf(k.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function s(q){if(q>65535){q-=65536;var Ae=55296+(q>>10),Zr=56320+(q&1023);return String.fromCharCode(Ae,Zr)}else return String.fromCharCode(q)}function a(q){var Ae=q[q.length-1]===";"?q:q+";";if(!o&&Ae!==q)return i.error("EntityRef: expecting ;"),q;var Zr=k.Reference.exec(Ae);if(!Zr||Zr[0].length!==Ae.length)return i.error("entity not matching Reference production: "+q),q;var Kr=Ae.slice(1,-1);return Lr(r,Kr)?r[Kr]:Kr.charAt(0)==="#"?s(parseInt(Kr.substring(1).replace("x","0x"))):(i.error("entity not found:"+q),q)}function l(q){if(q>y){var Ae=t.substring(y,q).replace(eo,a);h&&d(y),n.characters(Ae,0,q-y),y=q}}var u=0,c=0,f=/\r\n?|\n|$/g,h=n.locator;function d(q,Ae){for(;q>=c&&(Ae=f.exec(t));)u=c,c=Ae.index+Ae[0].length,h.lineNumber++;h.columnNumber=q-u+1}for(var g=[{currentNSMap:e}],p=[],y=0;;){try{var m=t.indexOf("<",y);if(m<0){if(!o&&p.length>0)return i.fatalError("unclosed xml tag(s): "+p.join(", "));if(!t.substring(y).match(/^\s*$/)){var w=n.doc,b=w.createTextNode(t.substring(y));if(w.documentElement)return i.error("Extra content at the end of the document");w.appendChild(b),n.currentElement=b}return}if(m>y){var v=t.substring(y,m);!o&&p.length===0&&(v=v.replace(new RegExp(k.S_OPT.source,"g"),""),v&&i.error("Unexpected content outside root element: '"+v+"'")),l(m)}switch(t.charAt(m+1)){case"/":var R=t.indexOf(">",m+2),x=t.substring(m+2,R>0?R:void 0);if(!x)return i.fatalError("end tag name missing");var T=k.reg("^",k.QName_group,k.S_OPT,"$"),E=R>0&&T.exec(x);if(!E){var C=R>0&&k.reg("^",k.QName_group).exec(x);if(o&&C)i.warning('end tag name contains invalid trailing characters: "'+x+'"'),E=C;else if(C&&new RegExp(T.source,T.flags+"m").test(x))i.error('end tag name is followed by a line break and trailing content: "'+x+'"'),E=C;else return i.fatalError('end tag name contains invalid characters: "'+x+'"')}if(!n.currentElement&&!n.doc.documentElement)return;var M=p[p.length-1]||n.currentElement.tagName||n.doc.documentElement.tagName||"";if(M!==E[1]){var I=E[1].toLowerCase();if(!o||M.toLowerCase()!==I)return i.fatalError('Opening and ending tag mismatch: "'+M+'" != "'+x+'"')}var _=g.pop();p.pop();var P=_.localNSMap;if(n.endElement(_.uri,_.localName,M),P)for(var K in P)Lr(P,K)&&n.endPrefixMapping(K);R++;break;case"?":h&&d(m),R=Th(t,m,n,i);break;case"!":h&&d(m),R=ca(t,m,n,i,o);break;default:h&&d(m);var z=new fa,ee=g[g.length-1].currentNSMap,R=Eh(t,m,z,ee,a,i,o),Fo=z.length;if(z.closed||(o&&Wt.isHTMLVoidElement(z.tagName)?z.closed=!0:p.push(z.tagName)),h&&Fo){for(var pl=oa(h,{}),wi=0;wi<Fo;wi++){var ko=z[wi];d(ko.offset),ko.locator=oa(h,{})}n.locator=pl,sa(z,n,ee)&&g.push(z),n.locator=h}else sa(z,n,ee)&&g.push(z);o&&!z.closed?R=Dh(t,R,z.tagName,a,n):R++}}catch(q){if(q instanceof yh)throw q;if(q instanceof wh)return i.fatalError("Error constructing the DOM: "+q.name+": "+q.message,q);i.error("element parse error: "+q),R=-1}R>y?y=R:l(Math.max(m,y)+1)}}function oa(t,e){return e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber,e}function Eh(t,e,r,n,i,o,s){function a(d,g,p){if(Lr(r.attributeNames,d))return o.fatalError("Attribute "+d+" redefined");if(!s&&g.indexOf("<")>=0)return o.fatalError("Unescaped '<' not allowed in attributes values");r.addValue(d,g.replace(/[\t\n\r]/g," ").replace(eo,i),p)}for(var l,u,c=++e,f=Vt;;){var h=t.charAt(c);if(f===Vt&&h==="<")throw new Error("unexpected < in tag name: "+t.slice(e,c));switch(h){case"=":if(f===ut)l=t.slice(e,c),f=kr;else if(f===jt)f=kr;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(f===kr||f===ut)if(f===ut&&(o.warning('attribute value must after "="'),l=t.slice(e,c)),e=c+1,c=t.indexOf(h,e),c>0)u=t.slice(e,c),a(l,u,e-1),f=Gt;else throw new Error("attribute value no end '"+h+"' match");else if(f==Ht)u=t.slice(e,c),a(l,u,e),o.warning('attribute "'+l+'" missed start quot('+h+")!!"),e=c+1,f=Gt;else throw new Error('attribute value must after "="');break;case"/":switch(f){case Vt:r.setTagName(t.slice(e,c));case Gt:case Rr:case Nn:f=Nn,r.closed=!0;case Ht:case ut:break;case jt:r.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return o.error("unexpected end of input"),f==Vt&&r.setTagName(t.slice(e,c)),c;case">":switch(f){case Vt:r.setTagName(t.slice(e,c));case Gt:case Rr:case Nn:break;case Ht:case ut:u=t.slice(e,c),u.slice(-1)==="/"&&(r.closed=!0,u=u.slice(0,-1));case jt:f===jt&&(u=l),f==Ht?(o.warning('attribute "'+u+'" missed quot(")!'),a(l,u,e)):(s||o.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case kr:if(!s)return o.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":h=" ";default:if(h<=" ")switch(f){case Vt:r.setTagName(t.slice(e,c)),f=Rr;break;case ut:l=t.slice(e,c),f=jt;break;case Ht:var u=t.slice(e,c);o.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Gt:f=Rr;break}else switch(f){case jt:s||o.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,f=ut;break;case Gt:o.warning('attribute space is required"'+l+'"!!');case Rr:f=ut,e=c;break;case kr:f=Ht,e=c;break;case Nn:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function sa(t,e,r){for(var n=t.tagName,i=null,f=t.length;f--;){var o=t[f],s=o.qName,a=o.value,h=s.indexOf(":");if(h>0)var l=o.prefix=s.slice(0,h),u=s.slice(h+1),c=l==="xmlns"&&u;else u=s,l=null,c=s==="xmlns"&&"";o.localName=u,c!==!1&&(i==null&&(i=Object.create(null),r=Object.create(r)),r[c]=i[c]=a,o.uri=ia.XMLNS,e.startPrefixMapping(c,a))}for(var f=t.length;f--;)o=t[f],o.prefix&&(o.prefix==="xml"&&(o.uri=ia.XML),o.prefix!=="xmlns"&&(o.uri=r[o.prefix]));var h=n.indexOf(":");h>0?(l=t.prefix=n.slice(0,h),u=t.localName=n.slice(h+1)):(l=null,u=t.localName=n);var d=t.uri=r[l||""];if(e.startElement(d,u,n,t),t.closed){if(e.endElement(d,u,n),i)for(l in i)Lr(i,l)&&e.endPrefixMapping(l)}else return t.currentNSMap=r,t.localNSMap=i,!0}function Dh(t,e,r,n,i){var o=ph(r);if(o||gh(r)){var s=new RegExp("</"+r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");s.lastIndex=e;var a=s.exec(t),l=a?a.index:-1;if(l<0)return e+1;var u=t.substring(e+1,l);return o&&(u=u.replace(eo,n)),i.characters(u,0,u.length),l}return e+1}function vh(t,e){for(var r in t)Lr(t,r)&&(e[r]=t[r])}function la(t,e){var r=e;function n(c){return c=c||0,t.charAt(r+c)}function i(c){c=c||1,r+=c}function o(){for(var c=0;r<t.length;){var f=n();if(f!==" "&&f!==`
3
+ `&&f!==" "&&f!=="\r")return c;c++,i()}return-1}function s(){return t.substring(r)}function a(c){return t.substring(r,r+c.length)===c}function l(c){return t.substring(r,r+c.length).toUpperCase()===c.toUpperCase()}function u(c){var f=k.reg("^",c),h=f.exec(s());return h?(i(h[0].length),h[0]):null}return{char:n,getIndex:function(){return r},getMatch:u,getSource:function(){return t},skip:i,skipBlanks:o,substringFromIndex:s,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function xh(t,e){function r(a,l){var u=k.PI.exec(a.substringFromIndex());return u?u[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+a.getIndex()):(a.skip(u[0].length),u[0]):l.fatalError("processing instruction is not well-formed at position "+a.getIndex())}var n=t.getSource();if(t.char()==="["){t.skip(1);for(var i=t.getIndex();t.getIndex()<n.length;){if(t.skipBlanks(),t.char()==="]"){var o=n.substring(i,t.getIndex());return t.skip(1),o}var s=null;if(t.char()==="<"&&t.char(1)==="!")switch(t.char(2)){case"E":t.char(3)==="L"?s=t.getMatch(k.elementdecl):t.char(3)==="N"&&(s=t.getMatch(k.EntityDecl));break;case"A":s=t.getMatch(k.AttlistDecl);break;case"N":s=t.getMatch(k.NotationDecl);break;case"-":s=t.getMatch(k.Comment);break}else if(t.char()==="<"&&t.char(1)==="?")s=r(t,e);else if(t.char()==="%")s=t.getMatch(k.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!s)return e.fatalError("Error in internal subset at position "+t.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function ca(t,e,r,n,i){var o=la(t,e);switch(i?o.char(2).toUpperCase():o.char(2)){case"-":var s=o.getMatch(k.Comment);return s?(r.comment(s,k.COMMENT_START.length,s.length-k.COMMENT_START.length-k.COMMENT_END.length),o.getIndex()):n.fatalError("comment is not well-formed at position "+o.getIndex());case"[":var a=o.getMatch(k.CDSect);return a?!i&&!r.currentElement?n.fatalError("CDATA outside of element"):(r.startCDATA(),r.characters(a,k.CDATA_START.length,a.length-k.CDATA_START.length-k.CDATA_END.length),r.endCDATA(),o.getIndex()):n.fatalError("Invalid CDATA starting at position "+e);case"D":{if(r.doc&&r.doc.documentElement)return n.fatalError("Doctype not allowed inside or after documentElement at position "+o.getIndex());if(i?!o.substringStartsWithCaseInsensitive(k.DOCTYPE_DECL_START):!o.substringStartsWith(k.DOCTYPE_DECL_START))return n.fatalError("Expected "+k.DOCTYPE_DECL_START+" at position "+o.getIndex());if(o.skip(k.DOCTYPE_DECL_START.length),o.skipBlanks()<1)return n.fatalError("Expected whitespace after "+k.DOCTYPE_DECL_START+" at position "+o.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=o.getMatch(k.Name),!l.name)return n.fatalError("doctype name missing or contains unexpected characters at position "+o.getIndex());if(i&&l.name.toLowerCase()!=="html"&&n.warning("Unexpected DOCTYPE in HTML document at position "+o.getIndex()),o.skipBlanks(),o.substringStartsWith(k.PUBLIC)||o.substringStartsWith(k.SYSTEM)){var u=k.ExternalID_match.exec(o.substringFromIndex());if(!u)return n.fatalError("doctype external id is not well-formed at position "+o.getIndex());u.groups.SystemLiteralOnly!==void 0?l.systemId=u.groups.SystemLiteralOnly:(l.systemId=u.groups.SystemLiteral,l.publicId=u.groups.PubidLiteral),o.skip(u[0].length)}else if(i&&o.substringStartsWithCaseInsensitive(k.SYSTEM)){if(o.skip(k.SYSTEM.length),o.skipBlanks()<1)return n.fatalError("Expected whitespace after "+k.SYSTEM+" at position "+o.getIndex());if(l.systemId=o.getMatch(k.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return n.fatalError("Expected "+k.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+k.SYSTEM+" at position "+o.getIndex())}return i&&l.systemId&&!k.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&n.warning("Unexpected doctype.systemId in HTML document at position "+o.getIndex()),i||(o.skipBlanks(),l.internalSubset=xh(o,n)),o.skipBlanks(),o.char()!==">"?n.fatalError("doctype not terminated with > at position "+o.getIndex()):(o.skip(1),r.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),r.endDTD(),o.getIndex())}default:return n.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function Th(t,e,r,n){var i=t.substring(e).match(k.PI);if(!i)return n.fatalError("Invalid processing instruction starting at position "+e);if(i[1].toLowerCase()==="xml"){if(e>0)return n.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!k.XMLDecl.test(t.substring(e)))return n.fatalError("xml declaration is not well-formed")}return r.processingInstruction(i[1],i[2]),e+i[0].length}function fa(){this.attributeNames=Object.create(null)}fa.prototype={setTagName:function(t){if(!k.QName_exact.test(t))throw new Error("invalid tagName:"+t);this.tagName=t},addValue:function(t,e,r){if(!k.QName_exact.test(t))throw new Error("invalid attribute:"+t);this.attributeNames[t]=this.length,this[this.length++]={qName:t,value:e,offset:r}},length:0,getLocalName:function(t){return this[t].localName},getLocator:function(t){return this[t].locator},getQName:function(t){return this[t].qName},getURI:function(t){return this[t].uri},getValue:function(t){return this[t].value}};_n.XMLReader=ua;_n.parseUtils=la;_n.parseDoctypeCommentOrCData=ca});var ba=Ze(Yt=>{"use strict";var bt=yt(),Ah=Qi(),Ch=Ar(),da=na(),Sh=ha(),Nh=Ah.DOMImplementation,_h=bt.hasDefaultHTMLNamespace,Ih=bt.isHTMLMimeType,Oh=bt.isValidMimeType,ga=bt.MIME_TYPE,to=bt.NAMESPACE,pa=Ch.ParseError,Mh=Sh.XMLReader;function ya(t){return t.replace(/\r[\n\u0085]/g,`
4
4
  `).replace(/[\r\u0085\u2028\u2029]/g,`
5
- `)}function ta(t){if(t=t||{},t.locator===void 0&&(t.locator=!0),this.assign=t.assign||pt.assign,this.domHandler=t.domHandler||En,this.onError=t.onError||t.errorHandler,t.errorHandler&&typeof t.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");t.errorHandler&&t.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=t.normalizeLineEndings||ea,this.locator=!!t.locator,this.xmlns=this.assign(Object.create(null),t.xmlns)}ta.prototype.parseFromString=function(t,e){if(!zf(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var r=this.assign(Object.create(null),this.xmlns),n=Jo.XML_ENTITIES,i=r[""]||null;qf(e)?(n=Jo.HTML_ENTITIES,i=$i.HTML):e===Ko.XML_SVG_IMAGE&&(i=$i.SVG),r[""]=i,r.xml=r.xml||$i.XML;var s=new this.domHandler({mimeType:e,defaultNamespace:i,onError:this.onError}),o=this.locator?{}:void 0;this.locator&&s.setDocumentLocator(o);var a=new jf;a.errorHandler=s,a.domBuilder=s;var l=!pt.isHTMLMimeType(e);return l&&typeof t!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(t)),r,n),s.doc.documentElement||a.errorHandler.fatalError("missing root element"),s.doc};function En(t){var e=t||{};this.mimeType=e.mimeType||Ko.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}function qt(t,e){e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber}En.prototype={startDocument:function(){var t=new $f;this.doc=Vf(this.mimeType)?t.createHTMLDocument(!1):t.createDocument(this.defaultNamespace,"")},startElement:function(t,e,r,n){var i=this.doc,s=i.createElementNS(t,r||e),o=n.length;wn(this,s),this.currentElement=s,this.locator&&qt(this.locator,s);for(var a=0;a<o;a++){var t=n.getURI(a),l=n.getValue(a),r=n.getQName(a),u=i.createAttributeNS(t,r);this.locator&&qt(n.getLocator(a),u),u.value=u.nodeValue=l,s.setAttributeNode(u)}},endElement:function(t,e,r){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(t,e){},endPrefixMapping:function(t){},processingInstruction:function(t,e){var r=this.doc.createProcessingInstruction(t,e);this.locator&&qt(this.locator,r),wn(this,r)},ignorableWhitespace:function(t,e,r){},characters:function(t,e,r){if(t=Qo.apply(this,arguments),t){if(this.cdata)var n=this.doc.createCDATASection(t);else var n=this.doc.createTextNode(t);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(t)&&this.doc.appendChild(n),this.locator&&qt(this.locator,n)}},skippedEntity:function(t){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(t){t&&(t.lineNumber=0),this.locator=t},comment:function(t,e,r){t=Qo.apply(this,arguments);var n=this.doc.createComment(t);this.locator&&qt(this.locator,n),wn(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(t,e,r,n){var i=this.doc.implementation;if(i&&i.createDocumentType){var s=i.createDocumentType(t,e,r,n);this.locator&&qt(this.locator,s),wn(this,s),this.doc.doctype=s}},reportError:function(t,e){if(typeof this.onError=="function")try{this.onError(t,e,this)}catch(r){throw new Zo("Reporting "+t+' "'+e+'" caused '+r,this.locator)}else console.error("[xmldom "+t+"] "+e,Hf(this.locator))},warning:function(t){this.reportError("warning",t)},error:function(t){this.reportError("error",t)},fatalError:function(t,e){throw this.reportError("fatalError",t),new Zo(t,this.locator,e)}};function Hf(t){if(t)return`
6
- @#[line:`+t.lineNumber+",col:"+t.columnNumber+"]"}function Qo(t,e,r){return typeof t=="string"?t.substr(e,r):t.length>=e+r||e?new java.lang.String(t,e,r)+"":t}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){En.prototype[t]=function(){return null}});function wn(t,e){t.currentElement?t.currentElement.appendChild(e):t.doc.appendChild(e)}function Gf(t){if(t==="error")throw"onErrorStopParsing"}function Xf(){throw"onWarningStopParsing"}Vt.__DOMHandler=En;Vt.DOMParser=ta;Vt.normalizeLineEndings=ea;Vt.onErrorStopParsing=Gf;Vt.onWarningStopParsing=Xf});var qi=Ge(U=>{"use strict";var zt=ht();U.assign=zt.assign;U.hasDefaultHTMLNamespace=zt.hasDefaultHTMLNamespace;U.isHTMLMimeType=zt.isHTMLMimeType;U.isValidMimeType=zt.isValidMimeType;U.MIME_TYPE=zt.MIME_TYPE;U.NAMESPACE=zt.NAMESPACE;var bn=dr();U.DOMException=bn.DOMException;U.DOMExceptionName=bn.DOMExceptionName;U.ExceptionCode=bn.ExceptionCode;U.ParseError=bn.ParseError;var re=Pi();U.Attr=re.Attr;U.CDATASection=re.CDATASection;U.CharacterData=re.CharacterData;U.Comment=re.Comment;U.Document=re.Document;U.DocumentFragment=re.DocumentFragment;U.DocumentType=re.DocumentType;U.DOMImplementation=re.DOMImplementation;U.Element=re.Element;U.Entity=re.Entity;U.EntityReference=re.EntityReference;U.LiveNodeList=re.LiveNodeList;U.NamedNodeMap=re.NamedNodeMap;U.Node=re.Node;U.NodeList=re.NodeList;U.Notation=re.Notation;U.ProcessingInstruction=re.ProcessingInstruction;U.Text=re.Text;U.XMLSerializer=re.XMLSerializer;var Dn=ra();U.DOMParser=Dn.DOMParser;U.normalizeLineEndings=Dn.normalizeLineEndings;U.onErrorStopParsing=Dn.onErrorStopParsing;U.onWarningStopParsing=Dn.onWarningStopParsing});var De={"assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt":new URL("./files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt",import.meta.url),"assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt":new URL("./files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt",import.meta.url),"assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt":new URL("./files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt",import.meta.url),"assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt":new URL("./files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt",import.meta.url),"assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt":new URL("./files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt",import.meta.url)};/*!
5
+ `)}function wa(t){if(t=t||{},t.locator===void 0&&(t.locator=!0),this.assign=t.assign||bt.assign,this.domHandler=t.domHandler||On,this.onError=t.onError||t.errorHandler,t.errorHandler&&typeof t.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");t.errorHandler&&t.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=t.normalizeLineEndings||ya,this.locator=!!t.locator,this.xmlns=this.assign(Object.create(null),t.xmlns)}wa.prototype.parseFromString=function(t,e){if(!Oh(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var r=this.assign(Object.create(null),this.xmlns),n=da.XML_ENTITIES,i=r[""]||null;_h(e)?(n=da.HTML_ENTITIES,i=to.HTML):e===ga.XML_SVG_IMAGE&&(i=to.SVG),r[""]=i,r.xml=r.xml||to.XML;var o=new this.domHandler({mimeType:e,defaultNamespace:i,onError:this.onError}),s=this.locator?{}:void 0;this.locator&&o.setDocumentLocator(s);var a=new Mh;a.errorHandler=o,a.domBuilder=o;var l=!bt.isHTMLMimeType(e);return l&&typeof t!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(t)),r,n),o.doc.documentElement||a.errorHandler.fatalError("missing root element"),o.doc};function On(t){var e=t||{};this.mimeType=e.mimeType||ga.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}function Xt(t,e){e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber}On.prototype={startDocument:function(){var t=new Nh;this.doc=Ih(this.mimeType)?t.createHTMLDocument(!1):t.createDocument(this.defaultNamespace,"")},startElement:function(t,e,r,n){var i=this.doc,o=i.createElementNS(t,r||e),s=n.length;In(this,o),this.currentElement=o,this.locator&&Xt(this.locator,o);for(var a=0;a<s;a++){var t=n.getURI(a),l=n.getValue(a),r=n.getQName(a),u=i.createAttributeNS(t,r);this.locator&&Xt(n.getLocator(a),u),u.value=u.nodeValue=l,o.setAttributeNode(u)}},endElement:function(t,e,r){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(t,e){},endPrefixMapping:function(t){},processingInstruction:function(t,e){var r=this.doc.createProcessingInstruction(t,e);this.locator&&Xt(this.locator,r),In(this,r)},ignorableWhitespace:function(t,e,r){},characters:function(t,e,r){if(t=ma.apply(this,arguments),t){if(this.cdata)var n=this.doc.createCDATASection(t);else var n=this.doc.createTextNode(t);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(t)&&this.doc.appendChild(n),this.locator&&Xt(this.locator,n)}},skippedEntity:function(t){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(t){t&&(t.lineNumber=0),this.locator=t},comment:function(t,e,r){t=ma.apply(this,arguments);var n=this.doc.createComment(t);this.locator&&Xt(this.locator,n),In(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(t,e,r,n){var i=this.doc.implementation;if(i&&i.createDocumentType){var o=i.createDocumentType(t,e,r,n);this.locator&&Xt(this.locator,o),In(this,o),this.doc.doctype=o}},reportError:function(t,e){if(typeof this.onError=="function")try{this.onError(t,e,this)}catch(r){throw new pa("Reporting "+t+' "'+e+'" caused '+r,this.locator)}else console.error("[xmldom "+t+"] "+e,Bh(this.locator))},warning:function(t){this.reportError("warning",t)},error:function(t){this.reportError("error",t)},fatalError:function(t,e){throw this.reportError("fatalError",t),new pa(t,this.locator,e)}};function Bh(t){if(t)return`
6
+ @#[line:`+t.lineNumber+",col:"+t.columnNumber+"]"}function ma(t,e,r){return typeof t=="string"?t.substr(e,r):t.length>=e+r||e?new java.lang.String(t,e,r)+"":t}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){On.prototype[t]=function(){return null}});function In(t,e){t.currentElement?t.currentElement.appendChild(e):t.doc.appendChild(e)}function Fh(t){if(t==="error")throw"onErrorStopParsing"}function kh(){throw"onWarningStopParsing"}Yt.__DOMHandler=On;Yt.DOMParser=wa;Yt.normalizeLineEndings=ya;Yt.onErrorStopParsing=Fh;Yt.onWarningStopParsing=kh});var ro=Ze($=>{"use strict";var Jt=yt();$.assign=Jt.assign;$.hasDefaultHTMLNamespace=Jt.hasDefaultHTMLNamespace;$.isHTMLMimeType=Jt.isHTMLMimeType;$.isValidMimeType=Jt.isValidMimeType;$.MIME_TYPE=Jt.MIME_TYPE;$.NAMESPACE=Jt.NAMESPACE;var Mn=Ar();$.DOMException=Mn.DOMException;$.DOMExceptionName=Mn.DOMExceptionName;$.ExceptionCode=Mn.ExceptionCode;$.ParseError=Mn.ParseError;var ie=Qi();$.Attr=ie.Attr;$.CDATASection=ie.CDATASection;$.CharacterData=ie.CharacterData;$.Comment=ie.Comment;$.Document=ie.Document;$.DocumentFragment=ie.DocumentFragment;$.DocumentType=ie.DocumentType;$.DOMImplementation=ie.DOMImplementation;$.Element=ie.Element;$.Entity=ie.Entity;$.EntityReference=ie.EntityReference;$.LiveNodeList=ie.LiveNodeList;$.NamedNodeMap=ie.NamedNodeMap;$.Node=ie.Node;$.NodeList=ie.NodeList;$.Notation=ie.Notation;$.ProcessingInstruction=ie.ProcessingInstruction;$.Text=ie.Text;$.XMLSerializer=ie.XMLSerializer;var Bn=ba();$.DOMParser=Bn.DOMParser;$.normalizeLineEndings=Bn.normalizeLineEndings;$.onErrorStopParsing=Bn.onErrorStopParsing;$.onWarningStopParsing=Bn.onWarningStopParsing});var Ce={"assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt":new URL("./files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt",import.meta.url),"assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt":new URL("./files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt",import.meta.url),"assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt":new URL("./files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt",import.meta.url),"assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt":new URL("./files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt",import.meta.url),"assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt":new URL("./files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt",import.meta.url)};/*!
7
7
  * decimal.js v10.6.0
8
8
  * An arbitrary-precision Decimal type for JavaScript.
9
9
  * https://github.com/MikeMcl/decimal.js
10
10
  * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
11
11
  * MIT Licence
12
- */var Tt=9e15,Je=1e9,ii="0123456789abcdef",jr="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Hr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",si={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Tt,maxE:Tt,crypto:!1},Ts,Ue,B=!0,Xr="[DecimalError] ",We=Xr+"Invalid argument: ",xs=Xr+"Precision limit exceeded",As=Xr+"crypto unavailable",Cs="[object Decimal]",ce=Math.floor,ee=Math.pow,_u=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Su=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Nu=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,_s=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ae=1e7,S=7,Iu=9007199254740991,Ou=jr.length-1,oi=Hr.length-1,D={toStringTag:Cs};D.absoluteValue=D.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),_(t)};D.ceil=function(){return _(new this.constructor(this),this.e+1,2)};D.clampedTo=D.clamp=function(t,e){var r,n=this,i=n.constructor;if(t=new i(t),e=new i(e),!t.s||!e.s)return new i(NaN);if(t.gt(e))throw Error(We+e);return r=n.cmp(t),r<0?t:n.cmp(e)>0?e:new i(n)};D.comparedTo=D.cmp=function(t){var e,r,n,i,s=this,o=s.d,a=(t=new s.constructor(t)).d,l=s.s,u=t.s;if(!o||!a)return!l||!u?NaN:l!==u?l:o===a?0:!o^l<0?1:-1;if(!o[0]||!a[0])return o[0]?l:a[0]?-u:0;if(l!==u)return l;if(s.e!==t.e)return s.e>t.e^l<0?1:-1;for(n=o.length,i=a.length,e=0,r=n<i?n:i;e<r;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return n===i?0:n>i^l<0?1:-1};D.cosine=D.cos=function(){var t,e,r=this,n=r.constructor;return r.d?r.d[0]?(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+S,n.rounding=1,r=Bu(n,Bs(n,r)),n.precision=t,n.rounding=e,_(Ue==2||Ue==3?r.neg():r,t,e,!0)):new n(1):new n(NaN)};D.cubeRoot=D.cbrt=function(){var t,e,r,n,i,s,o,a,l,u,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(B=!1,s=c.s*ee(c.s*c,1/3),!s||Math.abs(s)==1/0?(r=oe(c.d),t=c.e,(s=(t-r.length+1)%3)&&(r+=s==1||s==-2?"0":"00"),s=ee(r,1/3),t=ce((t+1)/3)-(t%3==(t<0?-1:2)),s==1/0?r="5e"+t:(r=s.toExponential(),r=r.slice(0,r.indexOf("e")+1)+t),n=new f(r),n.s=c.s):n=new f(s.toString()),o=(t=f.precision)+3;;)if(a=n,l=a.times(a).times(a),u=l.plus(c),n=H(u.plus(c).times(a),u.plus(l),o+2,1),oe(a.d).slice(0,o)===(r=oe(n.d)).slice(0,o))if(r=r.slice(o-3,o+1),r=="9999"||!i&&r=="4999"){if(!i&&(_(a,t+1,0),a.times(a).times(a).eq(c))){n=a;break}o+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(_(n,t+1,1),e=!n.times(n).times(n).eq(c));break}return B=!0,_(n,t,f.rounding,e)};D.decimalPlaces=D.dp=function(){var t,e=this.d,r=NaN;if(e){if(t=e.length-1,r=(t-ce(this.e/S))*S,t=e[t],t)for(;t%10==0;t/=10)r--;r<0&&(r=0)}return r};D.dividedBy=D.div=function(t){return H(this,new this.constructor(t))};D.dividedToIntegerBy=D.divToInt=function(t){var e=this,r=e.constructor;return _(H(e,new r(t),0,1,1),r.precision,r.rounding)};D.equals=D.eq=function(t){return this.cmp(t)===0};D.floor=function(){return _(new this.constructor(this),this.e+1,3)};D.greaterThan=D.gt=function(t){return this.cmp(t)>0};D.greaterThanOrEqualTo=D.gte=function(t){var e=this.cmp(t);return e==1||e===0};D.hyperbolicCosine=D.cosh=function(){var t,e,r,n,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;r=o.precision,n=o.rounding,o.precision=r+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(t=Math.ceil(i/3),e=(1/Wr(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),s=xt(o,1,s.times(e),new o(1),!0);for(var l,u=t,c=new o(8);u--;)l=s.times(s),s=a.minus(l.times(c.minus(l.times(c))));return _(s,o.precision=r,o.rounding=n,!0)};D.hyperbolicSine=D.sinh=function(){var t,e,r,n,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(e=s.precision,r=s.rounding,s.precision=e+Math.max(i.e,i.sd())+4,s.rounding=1,n=i.d.length,n<3)i=xt(s,2,i,i,!0);else{t=1.4*Math.sqrt(n),t=t>16?16:t|0,i=i.times(1/Wr(5,t)),i=xt(s,2,i,i,!0);for(var o,a=new s(5),l=new s(16),u=new s(20);t--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(u))))}return s.precision=e,s.rounding=r,_(i,e,r,!0)};D.hyperbolicTangent=D.tanh=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+7,n.rounding=1,H(r.sinh(),r.cosh(),n.precision=t,n.rounding=e)):new n(r.s)};D.inverseCosine=D.acos=function(){var t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return r!==-1?r===0?t.isNeg()?Ie(e,n,i):new e(0):new e(NaN):t.isZero()?Ie(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=n,e.rounding=i,t.times(2))};D.inverseHyperbolicCosine=D.acosh=function(){var t,e,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(t=n.precision,e=n.rounding,n.precision=t+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,B=!1,r=r.times(r).minus(1).sqrt().plus(r),B=!0,n.precision=t,n.rounding=e,r.ln()):new n(r)};D.inverseHyperbolicSine=D.asinh=function(){var t,e,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,B=!1,r=r.times(r).plus(1).sqrt().plus(r),B=!0,n.precision=t,n.rounding=e,r.ln())};D.inverseHyperbolicTangent=D.atanh=function(){var t,e,r,n,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=s.precision,e=s.rounding,n=i.sd(),Math.max(n,t)<2*-i.e-1?_(new s(i),t,e,!0):(s.precision=r=n-i.e,i=H(i.plus(1),new s(1).minus(i),r+t,1),s.precision=t+4,s.rounding=1,i=i.ln(),s.precision=t,s.rounding=e,i.times(.5))):new s(NaN)};D.inverseSine=D.asin=function(){var t,e,r,n,i=this,s=i.constructor;return i.isZero()?new s(i):(e=i.abs().cmp(1),r=s.precision,n=s.rounding,e!==-1?e===0?(t=Ie(s,r+4,n).times(.5),t.s=i.s,t):new s(NaN):(s.precision=r+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=r,s.rounding=n,i.times(2)))};D.inverseTangent=D.atan=function(){var t,e,r,n,i,s,o,a,l,u=this,c=u.constructor,f=c.precision,h=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&f+4<=oi)return o=Ie(c,f+4,h).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(f+4<=oi)return o=Ie(c,f+4,h).times(.5),o.s=u.s,o}for(c.precision=a=f+10,c.rounding=1,r=Math.min(28,a/S+2|0),t=r;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(B=!1,e=Math.ceil(a/S),n=1,l=u.times(u),o=new c(u),i=u;t!==-1;)if(i=i.times(l),s=o.minus(i.div(n+=2)),i=i.times(l),o=s.plus(i.div(n+=2)),o.d[e]!==void 0)for(t=e;o.d[t]===s.d[t]&&t--;);return r&&(o=o.times(2<<r-1)),B=!0,_(o,c.precision=f,c.rounding=h,!0)};D.isFinite=function(){return!!this.d};D.isInteger=D.isInt=function(){return!!this.d&&ce(this.e/S)>this.d.length-2};D.isNaN=function(){return!this.s};D.isNegative=D.isNeg=function(){return this.s<0};D.isPositive=D.isPos=function(){return this.s>0};D.isZero=function(){return!!this.d&&this.d[0]===0};D.lessThan=D.lt=function(t){return this.cmp(t)<0};D.lessThanOrEqualTo=D.lte=function(t){return this.cmp(t)<1};D.logarithm=D.log=function(t){var e,r,n,i,s,o,a,l,u=this,c=u.constructor,f=c.precision,h=c.rounding,d=5;if(t==null)t=new c(10),e=!0;else{if(t=new c(t),r=t.d,t.s<0||!r||!r[0]||t.eq(1))return new c(NaN);e=t.eq(10)}if(r=u.d,u.s<0||!r||!r[0]||u.eq(1))return new c(r&&!r[0]?-1/0:u.s!=1?NaN:r?0:1/0);if(e)if(r.length>1)s=!0;else{for(i=r[0];i%10===0;)i/=10;s=i!==1}if(B=!1,a=f+d,o=Ye(u,a),n=e?Gr(c,a+10):Ye(t,a),l=H(o,n,a,1),er(l.d,i=f,h))do if(a+=10,o=Ye(u,a),n=e?Gr(c,a+10):Ye(t,a),l=H(o,n,a,1),!s){+oe(l.d).slice(i+1,i+15)+1==1e14&&(l=_(l,f+1,0));break}while(er(l.d,i+=10,h));return B=!0,_(l,f,h)};D.minus=D.sub=function(t){var e,r,n,i,s,o,a,l,u,c,f,h,d=this,p=d.constructor;if(t=new p(t),!d.d||!t.d)return!d.s||!t.s?t=new p(NaN):d.d?t.s=-t.s:t=new p(t.d||d.s!==t.s?d:NaN),t;if(d.s!=t.s)return t.s=-t.s,d.plus(t);if(u=d.d,h=t.d,a=p.precision,l=p.rounding,!u[0]||!h[0]){if(h[0])t.s=-t.s;else if(u[0])t=new p(d);else return new p(l===3?-0:0);return B?_(t,a,l):t}if(r=ce(t.e/S),c=ce(d.e/S),u=u.slice(),s=c-r,s){for(f=s<0,f?(e=u,s=-s,o=h.length):(e=h,r=c,o=u.length),n=Math.max(Math.ceil(a/S),o)+2,s>n&&(s=n,e.length=1),e.reverse(),n=s;n--;)e.push(0);e.reverse()}else{for(n=u.length,o=h.length,f=n<o,f&&(o=n),n=0;n<o;n++)if(u[n]!=h[n]){f=u[n]<h[n];break}s=0}for(f&&(e=u,u=h,h=e,t.s=-t.s),o=u.length,n=h.length-o;n>0;--n)u[o++]=0;for(n=h.length;n>s;){if(u[--n]<h[n]){for(i=n;i&&u[--i]===0;)u[i]=Ae-1;--u[i],u[n]+=Ae}u[n]-=h[n]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--r;return u[0]?(t.d=u,t.e=Yr(u,r),B?_(t,a,l):t):new p(l===3?-0:0)};D.modulo=D.mod=function(t){var e,r=this,n=r.constructor;return t=new n(t),!r.d||!t.s||t.d&&!t.d[0]?new n(NaN):!t.d||r.d&&!r.d[0]?_(new n(r),n.precision,n.rounding):(B=!1,n.modulo==9?(e=H(r,t.abs(),0,3,1),e.s*=t.s):e=H(r,t,0,n.modulo,1),e=e.times(t),B=!0,r.minus(e))};D.naturalExponential=D.exp=function(){return ai(this)};D.naturalLogarithm=D.ln=function(){return Ye(this)};D.negated=D.neg=function(){var t=new this.constructor(this);return t.s=-t.s,_(t)};D.plus=D.add=function(t){var e,r,n,i,s,o,a,l,u,c,f=this,h=f.constructor;if(t=new h(t),!f.d||!t.d)return!f.s||!t.s?t=new h(NaN):f.d||(t=new h(t.d||f.s===t.s?f:NaN)),t;if(f.s!=t.s)return t.s=-t.s,f.minus(t);if(u=f.d,c=t.d,a=h.precision,l=h.rounding,!u[0]||!c[0])return c[0]||(t=new h(f)),B?_(t,a,l):t;if(s=ce(f.e/S),n=ce(t.e/S),u=u.slice(),i=s-n,i){for(i<0?(r=u,i=-i,o=c.length):(r=c,n=s,o=u.length),s=Math.ceil(a/S),o=s>o?s+1:o+1,i>o&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for(o=u.length,i=c.length,o-i<0&&(i=o,r=c,c=u,u=r),e=0;i;)e=(u[--i]=u[i]+c[i]+e)/Ae|0,u[i]%=Ae;for(e&&(u.unshift(e),++n),o=u.length;u[--o]==0;)u.pop();return t.d=u,t.e=Yr(u,n),B?_(t,a,l):t};D.precision=D.sd=function(t){var e,r=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(We+t);return r.d?(e=Ss(r.d),t&&r.e+1>e&&(e=r.e+1)):e=NaN,e};D.round=function(){var t=this,e=t.constructor;return _(new e(t),t.e+1,e.rounding)};D.sine=D.sin=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+S,n.rounding=1,r=ku(n,Bs(n,r)),n.precision=t,n.rounding=e,_(Ue>2?r.neg():r,t,e,!0)):new n(NaN)};D.squareRoot=D.sqrt=function(){var t,e,r,n,i,s,o=this,a=o.d,l=o.e,u=o.s,c=o.constructor;if(u!==1||!a||!a[0])return new c(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);for(B=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=oe(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=ce((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),n=new c(e)):n=new c(u.toString()),r=(l=c.precision)+3;;)if(s=n,n=s.plus(H(o,s,r+2,1)).times(.5),oe(s.d).slice(0,r)===(e=oe(n.d)).slice(0,r))if(e=e.slice(r-3,r+1),e=="9999"||!i&&e=="4999"){if(!i&&(_(s,l+1,0),s.times(s).eq(o))){n=s;break}r+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(_(n,l+1,1),t=!n.times(n).eq(o));break}return B=!0,_(n,l,c.rounding,t)};D.tangent=D.tan=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+10,n.rounding=1,r=r.sin(),r.s=1,r=H(r,new n(1).minus(r.times(r)).sqrt(),t+10,0),n.precision=t,n.rounding=e,_(Ue==2||Ue==4?r.neg():r,t,e,!0)):new n(NaN)};D.times=D.mul=function(t){var e,r,n,i,s,o,a,l,u,c=this,f=c.constructor,h=c.d,d=(t=new f(t)).d;if(t.s*=c.s,!h||!h[0]||!d||!d[0])return new f(!t.s||h&&!h[0]&&!d||d&&!d[0]&&!h?NaN:!h||!d?t.s/0:t.s*0);for(r=ce(c.e/S)+ce(t.e/S),l=h.length,u=d.length,l<u&&(s=h,h=d,d=s,o=l,l=u,u=o),s=[],o=l+u,n=o;n--;)s.push(0);for(n=u;--n>=0;){for(e=0,i=l+n;i>n;)a=s[i]+d[n]*h[i-n-1]+e,s[i--]=a%Ae|0,e=a/Ae|0;s[i]=(s[i]+e)%Ae|0}for(;!s[--o];)s.pop();return e?++r:s.shift(),t.d=s,t.e=Yr(s,r),B?_(t,f.precision,f.rounding):t};D.toBinary=function(t,e){return ui(this,2,t,e)};D.toDecimalPlaces=D.toDP=function(t,e){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(pe(t,0,Je),e===void 0?e=n.rounding:pe(e,0,8),_(r,t+r.e+1,e))};D.toExponential=function(t,e){var r,n=this,i=n.constructor;return t===void 0?r=Oe(n,!0):(pe(t,0,Je),e===void 0?e=i.rounding:pe(e,0,8),n=_(new i(n),t+1,e),r=Oe(n,!0,t+1)),n.isNeg()&&!n.isZero()?"-"+r:r};D.toFixed=function(t,e){var r,n,i=this,s=i.constructor;return t===void 0?r=Oe(i):(pe(t,0,Je),e===void 0?e=s.rounding:pe(e,0,8),n=_(new s(i),t+i.e+1,e),r=Oe(n,!1,t+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r};D.toFraction=function(t){var e,r,n,i,s,o,a,l,u,c,f,h,d=this,p=d.d,m=d.constructor;if(!p)return new m(d);if(u=r=new m(1),n=l=new m(0),e=new m(n),s=e.e=Ss(p)-d.e-1,o=s%S,e.d[0]=ee(10,o<0?S+o:o),t==null)t=s>0?e:u;else{if(a=new m(t),!a.isInt()||a.lt(u))throw Error(We+a);t=a.gt(e)?s>0?e:u:a}for(B=!1,a=new m(oe(p)),c=m.precision,m.precision=s=p.length*S*2;f=H(a,e,0,1,1),i=r.plus(f.times(n)),i.cmp(t)!=1;)r=n,n=i,i=u,u=l.plus(f.times(i)),l=i,i=e,e=a.minus(f.times(i)),a=i;return i=H(t.minus(r),n,0,1,1),l=l.plus(i.times(u)),r=r.plus(i.times(n)),l.s=u.s=d.s,h=H(u,n,s,1).minus(d).abs().cmp(H(l,r,s,1).minus(d).abs())<1?[u,n]:[l,r],m.precision=c,B=!0,h};D.toHexadecimal=D.toHex=function(t,e){return ui(this,16,t,e)};D.toNearest=function(t,e){var r=this,n=r.constructor;if(r=new n(r),t==null){if(!r.d)return r;t=new n(1),e=n.rounding}else{if(t=new n(t),e===void 0?e=n.rounding:pe(e,0,8),!r.d)return t.s?r:t;if(!t.d)return t.s&&(t.s=r.s),t}return t.d[0]?(B=!1,r=H(r,t,0,e,1).times(t),B=!0,_(r)):(t.s=r.s,r=t),r};D.toNumber=function(){return+this};D.toOctal=function(t,e){return ui(this,8,t,e)};D.toPower=D.pow=function(t){var e,r,n,i,s,o,a=this,l=a.constructor,u=+(t=new l(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new l(ee(+a,u));if(a=new l(a),a.eq(1))return a;if(n=l.precision,s=l.rounding,t.eq(1))return _(a,n,s);if(e=ce(t.e/S),e>=t.d.length-1&&(r=u<0?-u:u)<=Iu)return i=Ns(l,a,r,n),t.s<0?new l(1).div(i):_(i,n,s);if(o=a.s,o<0){if(e<t.d.length-1)return new l(NaN);if((t.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return r=ee(+a,u),e=r==0||!isFinite(r)?ce(u*(Math.log("0."+oe(a.d))/Math.LN10+a.e+1)):new l(r+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(B=!1,l.rounding=a.s=1,r=Math.min(12,(e+"").length),i=ai(t.times(Ye(a,n+r)),n),i.d&&(i=_(i,n+5,1),er(i.d,n,s)&&(e=n+10,i=_(ai(t.times(Ye(a,e+r)),e),e+5,1),+oe(i.d).slice(n+1,n+15)+1==1e14&&(i=_(i,n+1,0)))),i.s=o,B=!0,l.rounding=s,_(i,n,s))};D.toPrecision=function(t,e){var r,n=this,i=n.constructor;return t===void 0?r=Oe(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(pe(t,1,Je),e===void 0?e=i.rounding:pe(e,0,8),n=_(new i(n),t,e),r=Oe(n,t<=n.e||n.e<=i.toExpNeg,t)),n.isNeg()&&!n.isZero()?"-"+r:r};D.toSignificantDigits=D.toSD=function(t,e){var r=this,n=r.constructor;return t===void 0?(t=n.precision,e=n.rounding):(pe(t,1,Je),e===void 0?e=n.rounding:pe(e,0,8)),_(new n(r),t,e)};D.toString=function(){var t=this,e=t.constructor,r=Oe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+r:r};D.truncated=D.trunc=function(){return _(new this.constructor(this),this.e+1,1)};D.valueOf=D.toJSON=function(){var t=this,e=t.constructor,r=Oe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+r:r};function oe(t){var e,r,n,i=t.length-1,s="",o=t[0];if(i>0){for(s+=o,e=1;e<i;e++)n=t[e]+"",r=S-n.length,r&&(s+=Xe(r)),s+=n;o=t[e],n=o+"",r=S-n.length,r&&(s+=Xe(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function pe(t,e,r){if(t!==~~t||t<e||t>r)throw Error(We+t)}function er(t,e,r,n){var i,s,o,a;for(s=t[0];s>=10;s/=10)--e;return--e<0?(e+=S,i=0):(i=Math.ceil((e+1)/S),e%=S),s=ee(10,S-e),a=t[i]%s|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),o=r<4&&a==99999||r>3&&a==49999||a==5e4||a==0):o=(r<4&&a+1==s||r>3&&a+1==s/2)&&(t[i+1]/s/100|0)==ee(10,e-2)-1||(a==s/2||a==0)&&(t[i+1]/s/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),o=(n||r<4)&&a==9999||!n&&r>3&&a==4999):o=((n||r<4)&&a+1==s||!n&&r>3&&a+1==s/2)&&(t[i+1]/s/1e3|0)==ee(10,e-3)-1,o}function Vr(t,e,r){for(var n,i=[0],s,o=0,a=t.length;o<a;){for(s=i.length;s--;)i[s]*=e;for(i[0]+=ii.indexOf(t.charAt(o++)),n=0;n<i.length;n++)i[n]>r-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/r|0,i[n]%=r)}return i.reverse()}function Bu(t,e){var r,n,i;if(e.isZero())return e;n=e.d.length,n<32?(r=Math.ceil(n/3),i=(1/Wr(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),t.precision+=r,e=xt(t,1,e.times(i),new t(1));for(var s=r;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return t.precision-=r,e}var H=(function(){function t(n,i,s){var o,a=0,l=n.length;for(n=n.slice();l--;)o=n[l]*i+a,n[l]=o%s|0,a=o/s|0;return a&&n.unshift(a),n}function e(n,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(n[a]!=i[a]){l=n[a]>i[a]?1:-1;break}return l}function r(n,i,s,o){for(var a=0;s--;)n[s]-=a,a=n[s]<i[s]?1:0,n[s]=a*o+n[s]-i[s];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,s,o,a,l){var u,c,f,h,d,p,m,g,y,E,w,v,x,T,b,C,I,O,L,$,se=n.constructor,V=n.s==i.s?1:-1,Q=n.d,F=i.d;if(!Q||!Q[0]||!F||!F[0])return new se(!n.s||!i.s||(Q?F&&Q[0]==F[0]:!F)?NaN:Q&&Q[0]==0||!F?V*0:V/0);for(l?(d=1,c=n.e-i.e):(l=Ae,d=S,c=ce(n.e/d)-ce(i.e/d)),L=F.length,I=Q.length,y=new se(V),E=y.d=[],f=0;F[f]==(Q[f]||0);f++);if(F[f]>(Q[f]||0)&&c--,s==null?(T=s=se.precision,o=se.rounding):a?T=s+(n.e-i.e)+1:T=s,T<0)E.push(1),p=!0;else{if(T=T/d+2|0,f=0,L==1){for(h=0,F=F[0],T++;(f<I||h)&&T--;f++)b=h*l+(Q[f]||0),E[f]=b/F|0,h=b%F|0;p=h||f<I}else{for(h=l/(F[0]+1)|0,h>1&&(F=t(F,h,l),Q=t(Q,h,l),L=F.length,I=Q.length),C=L,w=Q.slice(0,L),v=w.length;v<L;)w[v++]=0;$=F.slice(),$.unshift(0),O=F[0],F[1]>=l/2&&++O;do h=0,u=e(F,w,L,v),u<0?(x=w[0],L!=v&&(x=x*l+(w[1]||0)),h=x/O|0,h>1?(h>=l&&(h=l-1),m=t(F,h,l),g=m.length,v=w.length,u=e(m,w,g,v),u==1&&(h--,r(m,L<g?$:F,g,l))):(h==0&&(u=h=1),m=F.slice()),g=m.length,g<v&&m.unshift(0),r(w,m,v,l),u==-1&&(v=w.length,u=e(F,w,L,v),u<1&&(h++,r(w,L<v?$:F,v,l))),v=w.length):u===0&&(h++,w=[0]),E[f++]=h,u&&w[0]?w[v++]=Q[C]||0:(w=[Q[C]],v=1);while((C++<I||w[0]!==void 0)&&T--);p=w[0]!==void 0}E[0]||E.shift()}if(d==1)y.e=c,Ts=p;else{for(f=1,h=E[0];h>=10;h/=10)f++;y.e=f+c*d-1,_(y,a?s+y.e+1:s,o,p)}return y}})();function _(t,e,r,n){var i,s,o,a,l,u,c,f,h,d=t.constructor;e:if(e!=null){if(f=t.d,!f)return t;for(i=1,a=f[0];a>=10;a/=10)i++;if(s=e-i,s<0)s+=S,o=e,c=f[h=0],l=c/ee(10,i-o-1)%10|0;else if(h=Math.ceil((s+1)/S),a=f.length,h>=a)if(n){for(;a++<=h;)f.push(0);c=l=0,i=1,s%=S,o=s-S+1}else break e;else{for(c=a=f[h],i=1;a>=10;a/=10)i++;s%=S,o=s-S+i,l=o<0?0:c/ee(10,i-o-1)%10|0}if(n=n||e<0||f[h+1]!==void 0||(o<0?c:c%ee(10,i-o-1)),u=r<4?(l||n)&&(r==0||r==(t.s<0?3:2)):l>5||l==5&&(r==4||n||r==6&&(s>0?o>0?c/ee(10,i-o):0:f[h-1])%10&1||r==(t.s<0?8:7)),e<1||!f[0])return f.length=0,u?(e-=t.e+1,f[0]=ee(10,(S-e%S)%S),t.e=-e||0):f[0]=t.e=0,t;if(s==0?(f.length=h,a=1,h--):(f.length=h+1,a=ee(10,S-s),f[h]=o>0?(c/ee(10,i-o)%ee(10,o)|0)*a:0),u)for(;;)if(h==0){for(s=1,o=f[0];o>=10;o/=10)s++;for(o=f[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(t.e++,f[0]==Ae&&(f[0]=1));break}else{if(f[h]+=a,f[h]!=Ae)break;f[h--]=0,a=1}for(s=f.length;f[--s]===0;)f.pop()}return B&&(t.e>d.maxE?(t.d=null,t.e=NaN):t.e<d.minE&&(t.e=0,t.d=[0])),t}function Oe(t,e,r){if(!t.isFinite())return Os(t);var n,i=t.e,s=oe(t.d),o=s.length;return e?(r&&(n=r-o)>0?s=s.charAt(0)+"."+s.slice(1)+Xe(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(t.e<0?"e":"e+")+t.e):i<0?(s="0."+Xe(-i-1)+s,r&&(n=r-o)>0&&(s+=Xe(n))):i>=o?(s+=Xe(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+Xe(n))):((n=i+1)<o&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-o)>0&&(i+1===o&&(s+="."),s+=Xe(n))),s}function Yr(t,e){var r=t[0];for(e*=S;r>=10;r/=10)e++;return e}function Gr(t,e,r){if(e>Ou)throw B=!0,r&&(t.precision=r),Error(xs);return _(new t(jr),e,1,!0)}function Ie(t,e,r){if(e>oi)throw Error(xs);return _(new t(Hr),e,r,!0)}function Ss(t){var e=t.length-1,r=e*S+1;if(e=t[e],e){for(;e%10==0;e/=10)r--;for(e=t[0];e>=10;e/=10)r++}return r}function Xe(t){for(var e="";t--;)e+="0";return e}function Ns(t,e,r,n){var i,s=new t(1),o=Math.ceil(n/S+4);for(B=!1;;){if(r%2&&(s=s.times(e),Ds(s.d,o)&&(i=!0)),r=ce(r/2),r===0){r=s.d.length-1,i&&s.d[r]===0&&++s.d[r];break}e=e.times(e),Ds(e.d,o)}return B=!0,s}function bs(t){return t.d[t.d.length-1]&1}function Is(t,e,r){for(var n,i,s=new t(e[0]),o=0;++o<e.length;){if(i=new t(e[o]),!i.s){s=i;break}n=s.cmp(i),(n===r||n===0&&s.s===r)&&(s=i)}return s}function ai(t,e){var r,n,i,s,o,a,l,u=0,c=0,f=0,h=t.constructor,d=h.rounding,p=h.precision;if(!t.d||!t.d[0]||t.e>17)return new h(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(e==null?(B=!1,l=p):l=e,a=new h(.03125);t.e>-2;)t=t.times(a),f+=5;for(n=Math.log(ee(2,f))/Math.LN10*2+5|0,l+=n,r=s=o=new h(1),h.precision=l;;){if(s=_(s.times(t),l,1),r=r.times(++c),a=o.plus(H(s,r,l,1)),oe(a.d).slice(0,l)===oe(o.d).slice(0,l)){for(i=f;i--;)o=_(o.times(o),l,1);if(e==null)if(u<3&&er(o.d,l-n,d,u))h.precision=l+=10,r=s=a=new h(1),c=0,u++;else return _(o,h.precision=p,d,B=!0);else return h.precision=p,o}o=a}}function Ye(t,e){var r,n,i,s,o,a,l,u,c,f,h,d=1,p=10,m=t,g=m.d,y=m.constructor,E=y.rounding,w=y.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new y(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);if(e==null?(B=!1,c=w):c=e,y.precision=c+=p,r=oe(g),n=r.charAt(0),Math.abs(s=m.e)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)m=m.times(t),r=oe(m.d),n=r.charAt(0),d++;s=m.e,n>1?(m=new y("0."+r),s++):m=new y(n+"."+r.slice(1))}else return u=Gr(y,c+2,w).times(s+""),m=Ye(new y(n+"."+r.slice(1)),c-p).plus(u),y.precision=w,e==null?_(m,w,E,B=!0):m;for(f=m,l=o=m=H(m.minus(1),m.plus(1),c,1),h=_(m.times(m),c,1),i=3;;){if(o=_(o.times(h),c,1),u=l.plus(H(o,new y(i),c,1)),oe(u.d).slice(0,c)===oe(l.d).slice(0,c))if(l=l.times(2),s!==0&&(l=l.plus(Gr(y,c+2,w).times(s+""))),l=H(l,new y(d),c,1),e==null)if(er(l.d,c-p,E,a))y.precision=c+=p,u=o=m=H(f.minus(1),f.plus(1),c,1),h=_(m.times(m),c,1),i=a=1;else return _(l,y.precision=w,E,B=!0);else return y.precision=w,l;l=u,i+=2}}function Os(t){return String(t.s*t.s/0)}function zr(t,e){var r,n,i;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),n=0;e.charCodeAt(n)===48;n++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(n,i),e){if(i-=n,t.e=r=r-n-1,t.d=[],n=(r+1)%S,r<0&&(n+=S),n<i){for(n&&t.d.push(+e.slice(0,n)),i-=S;n<i;)t.d.push(+e.slice(n,n+=S));e=e.slice(n),n=S-e.length}else n-=i;for(;n--;)e+="0";t.d.push(+e),B&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function Mu(t,e){var r,n,i,s,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),_s.test(e))return zr(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(Su.test(e))r=16,e=e.toLowerCase();else if(_u.test(e))r=2;else if(Nu.test(e))r=8;else throw Error(We+e);for(s=e.search(/p/i),s>0?(l=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),s=e.indexOf("."),o=s>=0,n=t.constructor,o&&(e=e.replace(".",""),a=e.length,s=a-s,i=Ns(n,new n(r),s,s*2)),u=Vr(e,r,Ae),c=u.length-1,s=c;u[s]===0;--s)u.pop();return s<0?new n(t.s*0):(t.e=Yr(u,c),t.d=u,B=!1,o&&(t=H(t,i,a*4)),l&&(t=t.times(Math.abs(l)<54?ee(2,l):tr.pow(2,l))),B=!0,t)}function ku(t,e){var r,n=e.d.length;if(n<3)return e.isZero()?e:xt(t,2,e,e);r=1.4*Math.sqrt(n),r=r>16?16:r|0,e=e.times(1/Wr(5,r)),e=xt(t,2,e,e);for(var i,s=new t(5),o=new t(16),a=new t(20);r--;)i=e.times(e),e=e.times(s.plus(i.times(o.times(i).minus(a))));return e}function xt(t,e,r,n,i){var s,o,a,l,u=1,c=t.precision,f=Math.ceil(c/S);for(B=!1,l=r.times(r),a=new t(n);;){if(o=H(a.times(l),new t(e++*e++),c,1),a=i?n.plus(o):n.minus(o),n=H(o.times(l),new t(e++*e++),c,1),o=a.plus(n),o.d[f]!==void 0){for(s=f;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=n,n=o,o=s,u++}return B=!0,o.d.length=f+1,o}function Wr(t,e){for(var r=t;--e;)r*=t;return r}function Bs(t,e){var r,n=e.s<0,i=Ie(t,t.precision,1),s=i.times(.5);if(e=e.abs(),e.lte(s))return Ue=n?4:1,e;if(r=e.divToInt(i),r.isZero())Ue=n?3:2;else{if(e=e.minus(r.times(i)),e.lte(s))return Ue=bs(r)?n?2:3:n?4:1,e;Ue=bs(r)?n?1:4:n?3:2}return e.minus(i).abs()}function ui(t,e,r,n){var i,s,o,a,l,u,c,f,h,d=t.constructor,p=r!==void 0;if(p?(pe(r,1,Je),n===void 0?n=d.rounding:pe(n,0,8)):(r=d.precision,n=d.rounding),!t.isFinite())c=Os(t);else{for(c=Oe(t),o=c.indexOf("."),p?(i=2,e==16?r=r*4-3:e==8&&(r=r*3-2)):i=e,o>=0&&(c=c.replace(".",""),h=new d(1),h.e=c.length-o,h.d=Vr(Oe(h),10,i),h.e=h.d.length),f=Vr(c,10,i),s=l=f.length;f[--l]==0;)f.pop();if(!f[0])c=p?"0p+0":"0";else{if(o<0?s--:(t=new d(t),t.d=f,t.e=s,t=H(t,h,r,n,0,i),f=t.d,s=t.e,u=Ts),o=f[r],a=i/2,u=u||f[r+1]!==void 0,u=n<4?(o!==void 0||u)&&(n===0||n===(t.s<0?3:2)):o>a||o===a&&(n===4||u||n===6&&f[r-1]&1||n===(t.s<0?8:7)),f.length=r,u)for(;++f[--r]>i-1;)f[r]=0,r||(++s,f.unshift(1));for(l=f.length;!f[l-1];--l);for(o=0,c="";o<l;o++)c+=ii.charAt(f[o]);if(p){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)c+="0";for(f=Vr(c,i,e),l=f.length;!f[l-1];--l);for(o=1,c="1.";o<l;o++)c+=ii.charAt(f[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)c="0"+c;c="0."+c}else if(++s>l)for(s-=l;s--;)c+="0";else s<l&&(c=c.slice(0,s)+"."+c.slice(s))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return t.s<0?"-"+c:c}function Ds(t,e){if(t.length>e)return t.length=e,!0}function Fu(t){return new this(t).abs()}function Ru(t){return new this(t).acos()}function Lu(t){return new this(t).acosh()}function Pu(t,e){return new this(t).plus(e)}function Uu(t){return new this(t).asin()}function $u(t){return new this(t).asinh()}function qu(t){return new this(t).atan()}function Vu(t){return new this(t).atanh()}function zu(t,e){t=new this(t),e=new this(e);var r,n=this.precision,i=this.rounding,s=n+4;return!t.s||!e.s?r=new this(NaN):!t.d&&!e.d?(r=Ie(this,s,1).times(e.s>0?.25:.75),r.s=t.s):!e.d||t.isZero()?(r=e.s<0?Ie(this,n,i):new this(0),r.s=t.s):!t.d||e.isZero()?(r=Ie(this,s,1).times(.5),r.s=t.s):e.s<0?(this.precision=s,this.rounding=1,r=this.atan(H(t,e,s,1)),e=Ie(this,s,1),this.precision=n,this.rounding=i,r=t.s<0?r.minus(e):r.plus(e)):r=this.atan(H(t,e,s,1)),r}function ju(t){return new this(t).cbrt()}function Hu(t){return _(t=new this(t),t.e+1,2)}function Gu(t,e,r){return new this(t).clamp(e,r)}function Xu(t){if(!t||typeof t!="object")throw Error(Xr+"Object expected");var e,r,n,i=t.defaults===!0,s=["precision",1,Je,"rounding",0,8,"toExpNeg",-Tt,0,"toExpPos",0,Tt,"maxE",0,Tt,"minE",-Tt,0,"modulo",0,9];for(e=0;e<s.length;e+=3)if(r=s[e],i&&(this[r]=si[r]),(n=t[r])!==void 0)if(ce(n)===n&&n>=s[e+1]&&n<=s[e+2])this[r]=n;else throw Error(We+r+": "+n);if(r="crypto",i&&(this[r]=si[r]),(n=t[r])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[r]=!0;else throw Error(As);else this[r]=!1;else throw Error(We+r+": "+n);return this}function Yu(t){return new this(t).cos()}function Wu(t){return new this(t).cosh()}function Ms(t){var e,r,n;function i(s){var o,a,l,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,vs(s)){u.s=s.s,B?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(l=typeof s,l==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,a=s;a>=10;a/=10)o++;B?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return zr(u,s.toString())}if(l==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(a===43&&(s=s.slice(1)),u.s=1),_s.test(s)?zr(u,s):Mu(u,s);if(l==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,zr(u,s.toString());throw Error(We+s)}if(i.prototype=D,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Xu,i.clone=Ms,i.isDecimal=vs,i.abs=Fu,i.acos=Ru,i.acosh=Lu,i.add=Pu,i.asin=Uu,i.asinh=$u,i.atan=qu,i.atanh=Vu,i.atan2=zu,i.cbrt=ju,i.ceil=Hu,i.clamp=Gu,i.cos=Yu,i.cosh=Wu,i.div=Ju,i.exp=Zu,i.floor=Qu,i.hypot=Ku,i.ln=el,i.log=tl,i.log10=nl,i.log2=rl,i.max=il,i.min=sl,i.mod=ol,i.mul=al,i.pow=ul,i.random=ll,i.round=cl,i.sign=fl,i.sin=hl,i.sinh=dl,i.sqrt=pl,i.sub=ml,i.sum=gl,i.tan=yl,i.tanh=wl,i.trunc=El,t===void 0&&(t={}),t&&t.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)t.hasOwnProperty(r=n[e++])||(t[r]=this[r]);return i.config(t),i}function Ju(t,e){return new this(t).div(e)}function Zu(t){return new this(t).exp()}function Qu(t){return _(t=new this(t),t.e+1,3)}function Ku(){var t,e,r=new this(0);for(B=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)r.d&&(r=r.plus(e.times(e)));else{if(e.s)return B=!0,new this(1/0);r=e}return B=!0,r.sqrt()}function vs(t){return t instanceof tr||t&&t.toStringTag===Cs||!1}function el(t){return new this(t).ln()}function tl(t,e){return new this(t).log(e)}function rl(t){return new this(t).log(2)}function nl(t){return new this(t).log(10)}function il(){return Is(this,arguments,-1)}function sl(){return Is(this,arguments,1)}function ol(t,e){return new this(t).mod(e)}function al(t,e){return new this(t).mul(e)}function ul(t,e){return new this(t).pow(e)}function ll(t){var e,r,n,i,s=0,o=new this(1),a=[];if(t===void 0?t=this.precision:pe(t,1,Je),n=Math.ceil(t/S),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));s<n;)i=e[s],i>=429e7?e[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);s<n;)i=e[s]+(e[s+1]<<8)+(e[s+2]<<16)+((e[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,s):(a.push(i%1e7),s+=4);s=n/4}else throw Error(As);else for(;s<n;)a[s++]=Math.random()*1e7|0;for(n=a[--s],t%=S,n&&t&&(i=ee(10,S-t),a[s]=(n/i|0)*i);a[s]===0;s--)a.pop();if(s<0)r=0,a=[0];else{for(r=-1;a[0]===0;r-=S)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<S&&(r-=S-n)}return o.e=r,o.d=a,o}function cl(t){return _(t=new this(t),t.e+1,this.rounding)}function fl(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function hl(t){return new this(t).sin()}function dl(t){return new this(t).sinh()}function pl(t){return new this(t).sqrt()}function ml(t,e){return new this(t).sub(e)}function gl(){var t=0,e=arguments,r=new this(e[t]);for(B=!1;r.s&&++t<e.length;)r=r.plus(e[t]);return B=!0,_(r,this.precision,this.rounding)}function yl(t){return new this(t).tan()}function wl(t){return new this(t).tanh()}function El(t){return _(t=new this(t),t.e+1,1)}D[Symbol.for("nodejs.util.inspect.custom")]=D.toString;D[Symbol.toStringTag]="Decimal";var tr=D.constructor=Ms(si);jr=new tr(jr);Hr=new tr(Hr);var ks=tr;var bl=20,Dl=1,at=1e6,Fs=1e6,vl=-7,Tl=21,xl=!1,rr="[big.js] ",ut=rr+"Invalid ",Jr=ut+"decimal places",Al=ut+"rounding mode",Rs=rr+"Division by zero",z={},Be=void 0,Cl=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Ls(){function t(e){var r=this;if(!(r instanceof t))return e===Be?Ls():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(ut+"value");e=e===0&&1/e<0?"-0":String(e)}_l(r,e)}r.constructor=t}return t.prototype=z,t.DP=bl,t.RM=Dl,t.NE=vl,t.PE=Tl,t.strict=xl,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function _l(t,e){var r,n,i;if(!Cl.test(e))throw Error(ut+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&e.charAt(n)=="0";)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}return t}function lt(t,e,r,n){var i=t.c;if(r===Be&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(Al);if(e<1)n=r===3&&(n||!!i[0])||e===0&&(r===1&&i[0]>=5||r===2&&(i[0]>5||i[0]===5&&(n||i[1]!==Be))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=r===1&&i[e]>=5||r===2&&(i[e]>5||i[e]===5&&(n||i[e+1]!==Be||i[e-1]&1))||r===3&&(n||!!i[0]),i.length=e,n){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function ct(t,e,r){var n=t.e,i=t.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>s)for(n-=s;n--;)i+="0";else n<s&&(i=i.slice(0,n)+"."+i.slice(n));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}z.abs=function(){var t=new this.constructor(this);return t.s=1,t};z.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,s=r.s,o=t.s,a=r.e,l=t.e;if(!n[0]||!i[0])return n[0]?s:i[0]?-o:0;if(s!=o)return s;if(e=s<0,a!=l)return a>l^e?1:-1;for(o=(a=n.length)<(l=i.length)?a:l,s=-1;++s<o;)if(n[s]!=i[s])return n[s]>i[s]^e?1:-1;return a==l?0:a>l^e?1:-1};z.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,s=e.s==t.s?1:-1,o=r.DP;if(o!==~~o||o<0||o>at)throw Error(Jr);if(!i[0])throw Error(Rs);if(!n[0])return t.s=s,t.c=[t.e=0],t;var a,l,u,c,f,h=i.slice(),d=a=i.length,p=n.length,m=n.slice(0,a),g=m.length,y=t,E=y.c=[],w=0,v=o+(y.e=e.e-t.e)+1;for(y.s=s,s=v<0?0:v,h.unshift(0);g++<a;)m.push(0);do{for(u=0;u<10;u++){if(a!=(g=m.length))c=a>g?1:-1;else for(f=-1,c=0;++f<a;)if(i[f]!=m[f]){c=i[f]>m[f]?1:-1;break}if(c<0){for(l=g==a?i:h;g;){if(m[--g]<l[g]){for(f=g;f&&!m[--f];)m[f]=9;--m[f],m[g]+=10}m[g]-=l[g]}for(;!m[0];)m.shift()}else break}E[w++]=c?u:++u,m[0]&&c?m[g]=n[d]||0:m=[n[d]]}while((d++<p||m[0]!==Be)&&s--);return!E[0]&&w!=1&&(E.shift(),y.e--,v--),w>v&&lt(y,v,r.RM,m[0]!==Be),y};z.eq=function(t){return this.cmp(t)===0};z.gt=function(t){return this.cmp(t)>0};z.gte=function(t){return this.cmp(t)>-1};z.lt=function(t){return this.cmp(t)<0};z.lte=function(t){return this.cmp(t)<1};z.minus=z.sub=function(t){var e,r,n,i,s=this,o=s.constructor,a=s.s,l=(t=new o(t)).s;if(a!=l)return t.s=-l,s.plus(t);var u=s.c.slice(),c=s.e,f=t.c,h=t.e;if(!u[0]||!f[0])return f[0]?t.s=-l:u[0]?t=new o(s):t.s=1,t;if(a=c-h){for((i=a<0)?(a=-a,n=u):(h=c,n=f),n.reverse(),l=a;l--;)n.push(0);n.reverse()}else for(r=((i=u.length<f.length)?u:f).length,a=l=0;l<r;l++)if(u[l]!=f[l]){i=u[l]<f[l];break}if(i&&(n=u,u=f,f=n,t.s=-t.s),(l=(r=f.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;r>a;){if(u[--r]<f[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=f[r]}for(;u[--l]===0;)u.pop();for(;u[0]===0;)u.shift(),--h;return u[0]||(t.s=1,u=[h=0]),t.c=u,t.e=h,t};z.mod=function(t){var e,r=this,n=r.constructor,i=r.s,s=(t=new n(t)).s;if(!t.c[0])throw Error(Rs);return r.s=t.s=1,e=t.cmp(r)==1,r.s=i,t.s=s,e?new n(r):(i=n.DP,s=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=s,this.minus(r.times(t)))};z.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};z.plus=z.add=function(t){var e,r,n,i=this,s=i.constructor;if(t=new s(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var o=i.e,a=i.c,l=t.e,u=t.c;if(!a[0]||!u[0])return u[0]||(a[0]?t=new s(i):t.s=i.s),t;if(a=a.slice(),e=o-l){for(e>0?(l=o,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+u[e]+r)/10|0;for(r&&(a.unshift(r),++l),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=l,t};z.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-Fs||t>Fs)throw Error(ut+"exponent");for(i&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return i?r.div(n):n};z.prec=function(t,e){if(t!==~~t||t<1||t>at)throw Error(ut+"precision");return lt(new this.constructor(this),t,e)};z.round=function(t,e){if(t===Be)t=0;else if(t!==~~t||t<-at||t>at)throw Error(Jr);return lt(new this.constructor(this),t+this.e+1,e)};z.sqrt=function(){var t,e,r,n=this,i=n.constructor,s=n.s,o=n.e,a=new i("0.5");if(!n.c[0])return new i(n);if(s<0)throw Error(rr+"No square root");s=Math.sqrt(+ct(n,!0,!0)),s===0||s===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):t=new i(s+""),o=t.e+(i.DP+=4);do r=t,t=a.times(r.plus(n.div(r)));while(r.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return lt(t,(i.DP-=4)+t.e+1,i.RM)};z.times=z.mul=function(t){var e,r=this,n=r.constructor,i=r.c,s=(t=new n(t)).c,o=i.length,a=s.length,l=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!s[0])return t.c=[t.e=0],t;for(t.e=l+u,o<a&&(e=i,i=s,s=e,u=o,o=a,a=u),e=new Array(u=o+a);u--;)e[u]=0;for(l=a;l--;){for(a=0,u=o+l;u>l;)a=e[u]+s[l]*i[u-l-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t};z.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==Be){if(t!==~~t||t<0||t>at)throw Error(Jr);for(r=lt(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return ct(r,!0,!!n)};z.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==Be){if(t!==~~t||t<0||t>at)throw Error(Jr);for(r=lt(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return ct(r,!1,!!n)};z[Symbol.for("nodejs.util.inspect.custom")]=z.toJSON=z.toString=function(){var t=this,e=t.constructor;return ct(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};z.toNumber=function(){var t=+ct(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(rr+"Imprecise conversion");return t};z.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==Be){if(t!==~~t||t<1||t>at)throw Error(ut+"precision");for(r=lt(new n(r),t,e);r.c.length<t;)r.c.push(0)}return ct(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)};z.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(rr+"valueOf disallowed");return ct(t,t.e<=e.NE||t.e>=e.PE,!0)};var Sl=Ls(),Ps=Sl;var Ei={};Es(Ei,{DecodeError:()=>fe,Decoder:()=>_e,EXT_TIMESTAMP:()=>ci,Encoder:()=>At,ExtData:()=>Ce,ExtensionCodec:()=>Ze,decode:()=>Xs,decodeArrayStream:()=>Js,decodeAsync:()=>Ws,decodeMulti:()=>Ys,decodeMultiStream:()=>Zs,decodeTimestampExtension:()=>mi,decodeTimestampToTimeSpec:()=>pi,encode:()=>Kr,encodeDateToTimeSpec:()=>hi,encodeTimeSpecToTimestamp:()=>fi,encodeTimestampExtension:()=>di});function Us(t){let e=t.length,r=0,n=0;for(;n<e;){let i=t.charCodeAt(n++);if((i&4294967168)===0){r++;continue}else if((i&4294965248)===0)r+=2;else{if(i>=55296&&i<=56319&&n<e){let s=t.charCodeAt(n);(s&64512)===56320&&(++n,i=((i&1023)<<10)+(s&1023)+65536)}(i&4294901760)===0?r+=3:r+=4}}return r}function Nl(t,e,r){let n=t.length,i=r,s=0;for(;s<n;){let o=t.charCodeAt(s++);if((o&4294967168)===0){e[i++]=o;continue}else if((o&4294965248)===0)e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<n){let a=t.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128):(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128)}e[i++]=o&63|128}}var Il=new TextEncoder,Ol=50;function Bl(t,e,r){Il.encodeInto(t,e.subarray(r))}function $s(t,e,r){t.length>Ol?Bl(t,e,r):Nl(t,e,r)}var Ml=4096;function li(t,e,r){let n=e,i=n+r,s=[],o="";for(;n<i;){let a=t[n++];if((a&128)===0)s.push(a);else if((a&224)===192){let l=t[n++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=t[n++]&63,u=t[n++]&63;s.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=t[n++]&63,u=t[n++]&63,c=t[n++]&63,f=(a&7)<<18|l<<12|u<<6|c;f>65535&&(f-=65536,s.push(f>>>10&1023|55296),f=56320|f&1023),s.push(f)}else s.push(a);s.length>=Ml&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var kl=new TextDecoder,Fl=200;function Rl(t,e,r){let n=t.subarray(e,e+r);return kl.decode(n)}function qs(t,e,r){return r>Fl?Rl(t,e,r):li(t,e,r)}var Ce=class{type;data;constructor(e,r){this.type=e,this.data=r}};var fe=class t extends Error{constructor(e){super(e);let r=Object.create(t.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};function Vs(t,e,r){let n=r/4294967296,i=r;t.setUint32(e,n),t.setUint32(e+4,i)}function Zr(t,e,r){let n=Math.floor(r/4294967296),i=r;t.setUint32(e,n),t.setUint32(e+4,i)}function Qr(t,e){let r=t.getInt32(e),n=t.getUint32(e+4);return r*4294967296+n}function zs(t,e){let r=t.getUint32(e),n=t.getUint32(e+4);return r*4294967296+n}var ci=-1,Ll=4294967296-1,Pl=17179869184-1;function fi({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Pl)if(e===0&&t<=Ll){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{let r=t/4294967296,n=t&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|r&3),s.setUint32(4,n),i}else{let r=new Uint8Array(12),n=new DataView(r.buffer);return n.setUint32(0,e),Zr(n,4,t),r}}function hi(t){let e=t.getTime(),r=Math.floor(e/1e3),n=(e-r*1e3)*1e6,i=Math.floor(n/1e9);return{sec:r+i,nsec:n-i*1e9}}function di(t){if(t instanceof Date){let e=hi(t);return fi(e)}else return null}function pi(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let r=e.getUint32(0),n=e.getUint32(4),i=(r&3)*4294967296+n,s=r>>>2;return{sec:i,nsec:s}}case 12:{let r=Qr(e,4),n=e.getUint32(0);return{sec:r,nsec:n}}default:throw new fe(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function mi(t){let e=pi(t);return new Date(e.sec*1e3+e.nsec/1e6)}var js={type:ci,encode:di,decode:mi};var Ze=class t{static defaultCodec=new t;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(js)}register({type:e,encode:r,decode:n}){if(e>=0)this.encoders[e]=r,this.decoders[e]=n;else{let i=-1-e;this.builtInEncoders[i]=r,this.builtInDecoders[i]=n}}tryToEncode(e,r){for(let n=0;n<this.builtInEncoders.length;n++){let i=this.builtInEncoders[n];if(i!=null){let s=i(e,r);if(s!=null){let o=-1-n;return new Ce(o,s)}}}for(let n=0;n<this.encoders.length;n++){let i=this.encoders[n];if(i!=null){let s=i(e,r);if(s!=null){let o=n;return new Ce(o,s)}}}return e instanceof Ce?e:null}decode(e,r,n){let i=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return i?i(e,r,n):new Ce(r,e)}};function Ul(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function nr(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Ul(t)?new Uint8Array(t):Uint8Array.from(t)}var $l=100,ql=2048,At=class t{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ze.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??$l,this.initialBufferSize=e?.initialBufferSize??ql,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,r)}ensureBufferSizeToWrite(e){let r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){let r=new ArrayBuffer(e),n=new Uint8Array(r),i=new DataView(r);n.set(this.bytes),this.view=i,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Us(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),$s(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,r){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);let n=nr(e);this.writeU8a(n)}encodeArray(e,r){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let i of e)this.doEncode(i,r+1)}countWithoutUndefined(e,r){let n=0;for(let i of r)e[i]!==void 0&&n++;return n}encodeMap(e,r){let n=Object.keys(e);this.sortKeys&&n.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let s of n){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,r+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),i=n.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(n);return}let r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Vs(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Zr(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function Kr(t,e){return new At(e).encodeSharedRef(t)}function en(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}var Vl=16,zl=16,tn=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Vl,r=zl){this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,n){let i=this.caches[n-1];e:for(let s of i){let o=s.bytes;for(let a=0;a<n;a++)if(o[a]!==e[r+a])continue e;return s.str}return null}store(e,r){let n=this.caches[e.length-1],i={bytes:e,str:r};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)}decode(e,r,n){let i=this.find(e,r,n);if(i!=null)return this.hit++,i;this.miss++;let s=li(e,r,n),o=Uint8Array.prototype.slice.call(e,r,r+n);return this.store(o,s),s}};var gi="array",or="map_key",Gs="map_value",jl=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new fe("The type of key must be string or number but "+typeof t)},yi=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let r=this.getUninitializedStateFromPool();r.type=gi,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){let r=this.getUninitializedStateFromPool();r.type=or,r.readCount=0,r.size=e,r.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===gi){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===or||e.type===Gs){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},sr=-1,wi=new DataView(new ArrayBuffer(0)),Hl=new Uint8Array(wi.buffer);try{wi.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Hs=new RangeError("Insufficient data"),Gl=new tn,_e=class t{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=wi;bytes=Hl;headByte=sr;stack=new yi;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ze.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Gl,this.mapKeyConverter=e?.mapKeyConverter??jl}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=sr,this.stack.reset()}setBuffer(e){let r=nr(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===sr&&!this.hasRemaining(1))this.setBuffer(e);else{let r=this.bytes.subarray(this.pos),n=nr(e),i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:r,pos:n}=this;return new RangeError(`Extra ${r.byteLength-n} of ${r.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let r=!1,n;for await(let a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),r=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:i,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${en(i)} at ${o} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let n=r,i=-1;for await(let s of e){if(r&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(i=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else{let i=e-160;r=this.decodeString(i,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){let i=this.lookU8();r=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();r=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();r=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e===196){let i=this.lookU8();r=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();r=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();r=this.decodeBinary(i,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();r=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();r=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();r=this.decodeExtension(i,4)}else throw new fe(`Unrecognized type byte: ${en(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let i=n.top();if(i.type===gi)if(i.array[i.position]=r,i.position++,i.position===i.size)r=i.array,n.release(i);else continue e;else if(i.type===or){if(r==="__proto__")throw new fe("The key __proto__ is not allowed");i.key=this.mapKeyConverter(r),i.type=Gs;continue e}else if(i.map[i.key]=r,i.readCount++,i.readCount===i.size)r=i.map,n.release(i);else{i.key=null,i.type=or;continue e}}return r}}readHeadByte(){return this.headByte===sr&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=sr}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new fe(`Unrecognized array type byte: ${en(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new fe(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new fe(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new fe(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw Hs;let n=this.pos+r,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,n,e):i=qs(this.bytes,n,e),this.pos+=r+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===or:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new fe(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw Hs;let n=this.pos+r,i=this.bytes.subarray(n,n+e);return this.pos+=r+e,i}decodeExtension(e,r){if(e>this.maxExtLength)throw new fe(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+r),i=this.decodeBinary(e,r+1);return this.extensionCodec.decode(i,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=zs(this.view,this.pos);return this.pos+=8,e}readI64(){let e=Qr(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Xs(t,e){return new _e(e).decode(t)}function Ys(t,e){return new _e(e).decodeMulti(t)}function Xl(t){return t[Symbol.asyncIterator]!=null}async function*Yl(t){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}function rn(t){return Xl(t)?t:Yl(t)}async function Ws(t,e){let r=rn(t);return new _e(e).decodeAsync(r)}function Js(t,e){let r=rn(t);return new _e(e).decodeArrayStream(r)}function Zs(t,e){let r=rn(t);return new _e(e).decodeStream(r)}var vn=ni(qi(),1),Vi=ks,zi=Ps,Re=Ei,na=vn.DOMParser,ia=vn.XMLSerializer;var sa=Re!==null;function oa(){if(!sa)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var aa=Yf();function Yf(){if(!sa)return null;let t=new TextEncoder,e=new TextDecoder,r=new Re.ExtensionCodec;return r.register({type:-1,encode:n=>{if(n instanceof Date){let i=Le(n);if(i==="D"||i==="H")return null}return Re.encodeTimestampExtension(n)},decode:n=>Re.decodeTimestampExtension(n)}),r.register({type:1,encode:n=>ie(n)?t.encode(n.toString()):null,decode:n=>jt(e.decode(n))}),r.register({type:2,encode:n=>{if(n instanceof Date&&Le(n)==="D"){let i=n.getUTCFullYear(),s=String(n.getUTCMonth()+1).padStart(2,"0"),o=String(n.getUTCDate()).padStart(2,"0");return t.encode(`${i}-${s}-${o}`)}return null},decode:n=>new Date(e.decode(n)+"T00:00:00.000Z")}),r.register({type:3,encode:n=>{if(n instanceof Date&&Le(n)==="H"){let i=String(n.getUTCHours()).padStart(2,"0"),s=String(n.getUTCMinutes()).padStart(2,"0"),o=String(n.getUTCSeconds()).padStart(2,"0"),a=String(n.getUTCMilliseconds()).padStart(3,"0");return t.encode(`${i}:${s}:${o}.${a}`)}return null},decode:n=>{let i=e.decode(n),s=i.indexOf("."),o=s>=0?i.substring(0,s):i,a=s>=0?i.substring(s+1):"0",[l,u,c]=o.split(":"),f=Math.round(+a.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,f))}}),r.register({type:4,encode:n=>{let i=ji(n);if(i!==null){let[s,o]=i;return t.encode(`${s}:${o(n)}`)}return null},decode:n=>{let i=e.decode(n),s=i.indexOf(":"),o=i.slice(0,s),a=i.slice(s+1),l=it[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),r}function ua(t){return oa(),Re.encode(t,{extensionCodec:aa})}function la(t){return oa(),Re.decode(t,{extensionCodec:aa})}function xn(t,e=!1){let r=An(t);if(r===null)return[!1,String(t)];let[n,i,s]=r;return s&&!e?[!1,String(t)]:[!0,`${i(t)}::${n}`]}function Hi(t){if(!t.includes("::"))return[!1,t];let e=t.lastIndexOf("::"),r=t.slice(0,e),n=t.slice(e+2),i=it[n];if(i===void 0)return[!1,t];let[,s]=i;return[!0,s(r)]}function Tn(t,e,r){if(t!==null&&typeof t=="object"&&!Array.isArray(t)){let n={};for(let[i,s]of Object.entries(t))n[i]=Tn(s,e,r);return n}return Array.isArray(t)?t.map(n=>Tn(n,e,r)):r(t)?e(t):t}function Gi(t){let e=An(t);if(e!==null){let[r,n,i]=e;return i?[t,!1]:[`${n(t)}::${r}`,!0]}if(Array.isArray(t)){let r=!1;return[t.map(i=>{let[s,o]=Gi(i);return o&&(r=!0),s}),r]}if(t!==null&&typeof t=="object"){let r=!1,n={};for(let[i,s]of Object.entries(t)){let[o,a]=Gi(s);a&&(r=!0),n[i]=o}return[n,r]}return[t,!1]}function Wf(t,e=!1){let[r,n]=xn(t,e);if(r)return n;let[i,s]=Gi(t),o=JSON.stringify(i);return s?`${o}::JS`:o}function Jf(t){return JSON.stringify(t)}function Zf(t){if(!Re)throw new Error("@msgpack/msgpack is required for MessagePack support");return Re.encode(t)}function xe(t,e=null,{raw:r=!1,qs:n=!1,_forceSuffix:i=!1}={}){if(n)return`${fa(t)}::QS`;if(r){if(e===null||e==="json")return Jf(t);if(e==="msgpack")return Zf(t);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let s=Wf(t,i);return e==="json"?`"${s}"`:s}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${ca(t)}</tytx_root>`;if(e==="msgpack")return ua(t);throw new Error(`Unknown transport: ${e}`)}}var Ht,Xi;typeof window<"u"&&window.DOMParser?(Ht=window.DOMParser,Xi=window.XMLSerializer):(Ht=na,Xi=ia);function ha(t){if(t===null||typeof t!="object"||Array.isArray(t))return!1;let e=Object.keys(t);if(e.length!==1)return!1;let r=t[e[0]];return r!==null&&typeof r=="object"&&"value"in r}function da(t,e,r){let n=t.createElement(e),i=r.attrs||{},s=r.value;for(let[o,a]of Object.entries(i))n.setAttribute(o,xe(a,null,{_forceSuffix:!0}));if(Array.isArray(s))for(let o of s)if(ha(o)){let[a]=Object.keys(o),l=o[a],u=da(t,a,l);n.appendChild(u)}else{n.textContent=xe(s);break}else n.textContent=xe(s);return n}function ca(t){if(!Ht)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(ha(t)){let[e]=Object.keys(t),r=t[e],n=new Ht().parseFromString("<root/>","text/xml"),i=da(n,e,r);return new Xi().serializeToString(i)}else return xe(t)}function Yi(t){let e={};for(let n=0;n<t.attributes.length;n++){let i=t.attributes[n];e[i.name]=K(i.value)}let r=[];for(let n=0;n<t.childNodes.length;n++){let i=t.childNodes[n];i.nodeType===1&&r.push(i)}if(r.length>0)if(r.length===1){let n=r[0],i=Yi(n);return{attrs:e,value:{[n.tagName]:i}}}else{let n=[];for(let i of r){let s=Yi(i);n.push({[i.tagName]:s})}return{attrs:e,value:n}}return{attrs:e,value:K(t.textContent)}}function pa(t){if(!Ht)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let n=new Ht().parseFromString(t,"text/xml").documentElement;if(n.tagName==="tytx_root"){let s=null;for(let o=0;o<n.childNodes.length;o++)if(n.childNodes[o].nodeType===1){s=n.childNodes[o];break}if(!s)return K(n.textContent);n=s}let i=Yi(n);return{[n.tagName]:i}}function Qf(t){return typeof t=="string"}function Kf(t){let[e,r]=Hi(t);if(e)return r;let n=t;n.endsWith("::JS")&&(n=n.slice(0,-4));let i;try{i=JSON.parse(n)}catch{return t}return Tn(i,eh,Qf)}function eh(t){return t.includes("::")?Hi(t)[1]:t}function th(t){let e=pa(t);return typeof e=="string"?K(e):e}function rh(t){return la(t)}function K(t,e=null){if(t===null)return null;if(e===null||e==="json"){let r=t;return e==="json"&&t.startsWith('"')&&t.endsWith('"')&&(r=t.slice(1,-1)),Kf(r)}else{if(e==="xml")return th(t);if(e==="msgpack")return rh(t);throw new Error(`Unknown transport: ${e}`)}}function fa(t){if(Array.isArray(t))return t.map(e=>String(e)).join("&");if(t!==null&&typeof t=="object"){let e=[];for(let[r,n]of Object.entries(t)){let[i,s]=xn(n,!0);i?e.push(`${r}=${s}`):e.push(`${r}=${n}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof t}`)}function ma(t){if(!t)return[];let e=t.split("&"),r=e.map(o=>o.includes("=")),n=r.every(Boolean),i=!r.some(Boolean);if(!n&&!i)throw new Error("QS format error: mixed items with and without '='");if(i)return e.map(o=>K(o));let s={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);s[l]=K(u)}return s}var ya=Vi||zi||Number,nh=Vi?"decimal.js":zi?"big.js":"number";function jt(t){return new ya(t)}function ie(t){return nh==="number"?!1:t instanceof ya}function Le(t){let e=t.getUTCFullYear()===1970&&t.getUTCMonth()===0&&t.getUTCDate()===1,r=t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0;return e&&!r?"H":r&&!e?"D":"DHZ"}function ih(t){return t.toString()}function sh(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0");return`${e}-${r}-${n}`}function oh(t){return t.toISOString()}function ah(t){let e=String(t.getUTCHours()).padStart(2,"0"),r=String(t.getUTCMinutes()).padStart(2,"0"),n=String(t.getUTCSeconds()).padStart(2,"0"),i=String(t.getUTCMilliseconds()).padStart(3,"0");return`${e}:${r}:${n}.${i}`}function uh(t){return t?"true":"false"}function lh(t){return t.toString()}function ch(t){return t.toString()}function fh(t){let e="";for(let r=0;r<t.length;r+=32768)e+=String.fromCharCode.apply(null,t.subarray(r,r+32768));return btoa(e)}var Cn=[],Wi=new Map;function ji(t){if(t===null||typeof t!="object")return null;for(let e=Object.getPrototypeOf(t);e!==null;e=Object.getPrototypeOf(e))for(let[r,n,i,s]of Cn)if(r.prototype===e)return[n,i,s];return null}function An(t){if(t===null)return["NN",()=>"",!0];if(ie(t))return["N",ih,!1];if(t instanceof Uint8Array)return["RAW",fh,!1];if(t instanceof Date){let e=Le(t);return e==="D"?["D",sh,!1]:e==="H"?["H",ah,!1]:["DHZ",oh,!1]}return typeof t=="boolean"?["B",uh,!0]:typeof t=="number"?Number.isInteger(t)?["L",lh,!0]:["R",ch,!0]:ji(t)}function hh(t){return jt(t)}function dh(t){let[e,r,n]=t.split("-").map(Number);return new Date(Date.UTC(e,r-1,n,0,0,0,0))}function ga(t){return new Date(t)}function ph(t){let[e,r,n]=t.split(":"),[i,s]=n.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(r),Number(i),Number(s||0)))}function mh(t){return t.toLowerCase()==="true"}function gh(t){return parseInt(t,10)}function yh(t){return parseFloat(t)}function wh(t){return t}function Eh(t){return null}var bh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function Dh(t){if(!bh.test(t))throw new Error(`RAW payload is not standard padded base64: '${t}'`);let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function vh(t){return ma(t)}var Th=/^[A-Z]+$/,it={N:[Object,hh],D:[Date,dh],DH:[Date,ga],DHZ:[Date,ga],H:[Date,ph],L:[Number,gh],R:[Number,yh],T:[String,wh],B:[Boolean,mh],QS:[Object,vh],NN:[null,Eh],RAW:[Uint8Array,Dh]};function Ji(t){return Object.hasOwn(it,t)?it[t][0]:null}function Zi(t,e,r,n,i=!1){if(typeof e!="string"||!Th.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let s=it[e];if(s!==void 0&&s[0]!==t){let o=s[0]===null?"null":s[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}Cn=Cn.filter(([o])=>o!==t),Cn.push([t,e,r,i]),it[e]=[t,n]}function Qi(t,e){Wi.set(t,e)}function Gt(t){return Wi.has(t)?Wi.get(t):{}}function ne(t,e,r,n){let i=null,s=[];for(let o of t.getRows()){let a=t.value(o,e),l=a instanceof Date&&Number.isFinite(a.getTime())?"time":typeof a=="string"||typeof a=="boolean"?"category":typeof a=="number"&&Number.isFinite(a)?"value":null;if(!l||i&&l!==i)throw new TypeError("Choose a column with consistent text, numeric, boolean or date values");i=l;let u=l==="time"?a.getTime():typeof a=="boolean"?String(a):a,c=r.map(f=>t.value(o,f));if(c.some(f=>typeof f!="number"||!Number.isFinite(f)))throw new TypeError("Selected measures require finite numeric values");s.push([u,...c])}return{source:s,kind:i??n?.kind??"category"}}function Xt(t,e,r,n,i){if(!e||!r||e===r)throw new TypeError("Choose two different dimensions for 3D bars");if(!n)throw new TypeError("Choose a measure for 3D bars");let s=i?i.dimensions.map(l=>l.values.map(u=>l.kind==="time"?new Date(u).toISOString():String(u))):[[],[]],o=s.map(l=>new Map(l.map((u,c)=>[u,c]))),a=[];for(let l of t.getRows()){let u=[e,r].map((f,h)=>{let d=t.value(l,f),p=d instanceof Date&&Number.isFinite(d.getTime())?d.toISOString():["string","boolean"].includes(typeof d)||typeof d=="number"&&Number.isFinite(d)?String(d):null;if(p===null)throw new TypeError("3D dimensions require text, numeric, boolean or date values");return o[h].has(p)||(o[h].set(p,s[h].length),s[h].push(p)),o[h].get(p)}),c=t.value(l,n);if(typeof c!="number"||!Number.isFinite(c))throw new TypeError("Selected measure requires finite numeric values");a.push([...u,c])}return{dimensions:s,source:a}}var st=["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"];function mt(t,e=!1){let r=e?0:1/0,n=e?0:-1/0;for(let i of t)Number.isFinite(i)&&(r=Math.min(r,i),n=Math.max(n,i));if(r===1/0)return[0,1];if(r===n){let i=Math.abs(r)*.05||1;return e&&r===0?[0,1]:[r-i,n+i]}return[r,n]}function Cr(t,e){return e==="time"?new Date(t).toISOString().slice(0,10):String(t)}function _n(t,{category:e,fields:r,settings:n,structure:i,type:s}){let{source:o,kind:a}=ne(t,e,r),l=[...new Set(o.map(b=>b[0]))],u={kind:a,values:l,range:mt(l)},c={};for(let b of["left","right"]){let C=r.map((O,L)=>L).filter(O=>n[O].axis===b),I=[];for(let O of o)if(["stackedBar","stackedArea"].includes(s.id))I.push(C.reduce((L,$)=>L+Math.max(0,O[$+1]),0),C.reduce((L,$)=>L+Math.min(0,O[$+1]),0));else for(let L of C)I.push(O[L+1]);c[b]=mt(I,!0)}let f=s.controls.includes("secondDimension")?i.getItem("secondCaptionField"):null,h=f?ne(t,f,[]):null,d=[u,...h?[{kind:h.kind,values:[...new Set(h.source.map(b=>b[0]))],range:mt(h.source.map(b=>b[0]))}]:[]],p=s.id==="map"?i.getItem("mapValueField"):null,m=p?i.getItem("geoJSON"):null,g=m?new Set(m.features.map(b=>b.properties.name)):null,y=p?t.getRows().filter(b=>!g||g.has(String(t.value(b,e)))).map(b=>t.value(b,p)):[];if(y.some(b=>typeof b!="number"||!Number.isFinite(b)))throw new TypeError("Selected map measure requires finite numeric values");let E=y.some(b=>b<0),[w,v]=mt(y);E?(v=Math.max(Math.abs(w),Math.abs(v)),w=-v):w=Math.max(0,w);let x=s.id==="mapBar3D"?new Set(i.getItem("geoJSON").features.map(b=>b.properties.name)):null,T=o.filter(b=>!x||x.has(String(b[0]))).flatMap(b=>b.slice(1));return{dimension:u,dimensions:d,axes:c,z:mt(T,s.id!=="mapBar3D"||i.getItem("mapBarScale")!=="extent"),labels:l.map(b=>Cr(b,a)),map:{min:w,max:v,signed:E},count:l.length}}var Sn=864e5,Nn={minute:6e4,hour:36e5,day:Sn,week:7*Sn},wa=4*Sn;function ze(t,e){if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError("Temporal snapshots require Date values");if(Object.hasOwn(Nn,e))return Math.floor((t.getTime()-(e==="week"?wa:0))/Nn[e]);if(e==="month")return t.getUTCFullYear()*12+t.getUTCMonth();if(e==="year")return t.getUTCFullYear();throw new TypeError("Time step must be minute, hour, day, week, month or year")}function Ki(t,e){if(Object.hasOwn(Nn,e))return new Date(t*Nn[e]+(e==="week"?wa:0));let r=new Date(0);if(e==="month")r.setUTCFullYear(Math.floor(t/12),t-Math.floor(t/12)*12,1);else if(e==="year")r.setUTCFullYear(t,0,1);else throw new TypeError("Time step must be minute, hour, day, week, month or year");return r}function Ea(t,e){let r=1/0,n=-1/0,i=!1;for(let u of e?t.getRows():[]){let c=t.value(u,e);c!=null&&(ze(c,"day"),r=Math.min(r,c.getTime()),n=Math.max(n,c.getTime()),i||=Le(c)!=="D")}let s=i?["minute","hour","day","week","month","year"]:["day","week","month","year"],o=r===1/0?null:new Date(r),a=r===1/0?null:new Date(n),l=o?s.find(u=>ze(a,u)-ze(o,u)<=36)??"year":"day";return{hasClock:i,steps:s,suggested:l,first:o,last:a}}function In(t,e){let r=t.toISOString();return e==="week"?`${r.slice(0,10)} \u2013 ${new Date(t.getTime()+6*Sn).toISOString().slice(0,10)} UTC`:e==="hour"||e==="minute"?`${r.slice(0,16).replace("T"," ")} UTC`:r.slice(0,e==="year"?4:e==="month"?7:10)}var _r=class{constructor(e){this.view=e,this.field=""}invalidateDomains(){this.domainKey=null}domains(e){if(!this.field)return null;let r=JSON.stringify([this.field,this.step,e.category,e.fields,e.settings,e.type.id,e.structure.getItem("secondCaptionField"),e.structure.getItem("mapValueField"),e.structure.getItem("mapBarScale")]),n=e.structure.getItem("geoJSON");if(r!==this.domainKey||n!==this.domainGeoJSON){let i=this.view.getRows().filter(s=>this.value(s,this.field)!=null);this.domainValue=_n({getRows:()=>i,value:(s,o)=>this.value(s,o)},e),this.domainKey=r,this.domainGeoJSON=n}return this.domainValue}setPeriod(e,r,n,i="previous"){if(!["previous","empty"].includes(i))throw new TypeError("Empty periods require previous or empty");this.field=e,this.date=r,this.step=n,this.empty=i}value(e,r){return this.view.value(e,r)}getRows(){let e=this.view.getRows();if(this.snapshotDate=null,!this.field)return e;if(this.date==null)return[];let r=ze(this.date,this.step),n=this.empty==="empty"?r:-1/0,i=e.map(o=>{let a=this.value(o,this.field);return{row:o,period:a==null?null:ze(a,this.step)}});if(this.empty==="previous")for(let o of i)o.period!==null&&o.period<=r&&(n=Math.max(n,o.period));let s=i.filter(o=>o.period===n).map(o=>o.row);return s.length&&(this.snapshotDate=Ki(n,this.step)),s}};var J={};Es(J,{defineCollection:()=>es});Kt(J,hm);import*as hm from"@gramlot/gramlot/components";import{defineCollection as Ah}from"@gramlot/gramlot/components";function es(t){if(t.name!=="charts")throw new Error("Unexpected bundled collection");let e=[],r={echartsGlLicense:De["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:De["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:De["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:De["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:De["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]};t.css?.forEach((n,i)=>{n.href=e[i].href});for(let[n,i]of Object.entries(t.assets??{}))i.href=r[n].href;return Ah({...t,css:e,assets:r})}function On(t,e){return t.parameters=Ch(t.constructor.gramlotComponent,e),Object.fromEntries(Object.entries(e).filter(([r])=>!Object.hasOwn(t.parameters,r)))}function Ch(t,e){return Object.fromEntries(Object.entries(t.parameters).map(([r,n])=>[r,Object.hasOwn(e,r)?e[r]:n.default]))}function je(t){return class extends t{constructor(){super();let e=this.attachShadow({mode:"open"}),r=this.ownerDocument.createElement("style");r.textContent=`:host{box-sizing:border-box;display:block;min-width:0;font:inherit;color:var(--gramlot-ink,CanvasText)}
12
+ */var It=9e15,tt=1e9,bi="0123456789abcdef",rn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",nn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ei={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-It,maxE:It,crypto:!1},qo,He,B=!0,sn="[DecimalError] ",et=sn+"Invalid argument: ",zo=sn+"Precision limit exceeded",Vo=sn+"crypto unavailable",jo="[object Decimal]",de=Math.floor,re=Math.pow,ml=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,gl=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,yl=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ho=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ie=1e7,N=7,wl=9007199254740991,bl=rn.length-1,Di=nn.length-1,D={toStringTag:jo};D.absoluteValue=D.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),S(t)};D.ceil=function(){return S(new this.constructor(this),this.e+1,2)};D.clampedTo=D.clamp=function(t,e){var r,n=this,i=n.constructor;if(t=new i(t),e=new i(e),!t.s||!e.s)return new i(NaN);if(t.gt(e))throw Error(et+e);return r=n.cmp(t),r<0?t:n.cmp(e)>0?e:new i(n)};D.comparedTo=D.cmp=function(t){var e,r,n,i,o=this,s=o.d,a=(t=new o.constructor(t)).d,l=o.s,u=t.s;if(!s||!a)return!l||!u?NaN:l!==u?l:s===a?0:!s^l<0?1:-1;if(!s[0]||!a[0])return s[0]?l:a[0]?-u:0;if(l!==u)return l;if(o.e!==t.e)return o.e>t.e^l<0?1:-1;for(n=s.length,i=a.length,e=0,r=n<i?n:i;e<r;++e)if(s[e]!==a[e])return s[e]>a[e]^l<0?1:-1;return n===i?0:n>i^l<0?1:-1};D.cosine=D.cos=function(){var t,e,r=this,n=r.constructor;return r.d?r.d[0]?(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+N,n.rounding=1,r=El(n,Jo(n,r)),n.precision=t,n.rounding=e,S(He==2||He==3?r.neg():r,t,e,!0)):new n(1):new n(NaN)};D.cubeRoot=D.cbrt=function(){var t,e,r,n,i,o,s,a,l,u,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(B=!1,o=c.s*re(c.s*c,1/3),!o||Math.abs(o)==1/0?(r=ue(c.d),t=c.e,(o=(t-r.length+1)%3)&&(r+=o==1||o==-2?"0":"00"),o=re(r,1/3),t=de((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?r="5e"+t:(r=o.toExponential(),r=r.slice(0,r.indexOf("e")+1)+t),n=new f(r),n.s=c.s):n=new f(o.toString()),s=(t=f.precision)+3;;)if(a=n,l=a.times(a).times(a),u=l.plus(c),n=H(u.plus(c).times(a),u.plus(l),s+2,1),ue(a.d).slice(0,s)===(r=ue(n.d)).slice(0,s))if(r=r.slice(s-3,s+1),r=="9999"||!i&&r=="4999"){if(!i&&(S(a,t+1,0),a.times(a).times(a).eq(c))){n=a;break}s+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(S(n,t+1,1),e=!n.times(n).times(n).eq(c));break}return B=!0,S(n,t,f.rounding,e)};D.decimalPlaces=D.dp=function(){var t,e=this.d,r=NaN;if(e){if(t=e.length-1,r=(t-de(this.e/N))*N,t=e[t],t)for(;t%10==0;t/=10)r--;r<0&&(r=0)}return r};D.dividedBy=D.div=function(t){return H(this,new this.constructor(t))};D.dividedToIntegerBy=D.divToInt=function(t){var e=this,r=e.constructor;return S(H(e,new r(t),0,1,1),r.precision,r.rounding)};D.equals=D.eq=function(t){return this.cmp(t)===0};D.floor=function(){return S(new this.constructor(this),this.e+1,3)};D.greaterThan=D.gt=function(t){return this.cmp(t)>0};D.greaterThanOrEqualTo=D.gte=function(t){var e=this.cmp(t);return e==1||e===0};D.hyperbolicCosine=D.cosh=function(){var t,e,r,n,i,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;r=s.precision,n=s.rounding,s.precision=r+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(t=Math.ceil(i/3),e=(1/un(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=Ot(s,1,o.times(e),new s(1),!0);for(var l,u=t,c=new s(8);u--;)l=o.times(o),o=a.minus(l.times(c.minus(l.times(c))));return S(o,s.precision=r,s.rounding=n,!0)};D.hyperbolicSine=D.sinh=function(){var t,e,r,n,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(e=o.precision,r=o.rounding,o.precision=e+Math.max(i.e,i.sd())+4,o.rounding=1,n=i.d.length,n<3)i=Ot(o,2,i,i,!0);else{t=1.4*Math.sqrt(n),t=t>16?16:t|0,i=i.times(1/un(5,t)),i=Ot(o,2,i,i,!0);for(var s,a=new o(5),l=new o(16),u=new o(20);t--;)s=i.times(i),i=i.times(a.plus(s.times(l.times(s).plus(u))))}return o.precision=e,o.rounding=r,S(i,e,r,!0)};D.hyperbolicTangent=D.tanh=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+7,n.rounding=1,H(r.sinh(),r.cosh(),n.precision=t,n.rounding=e)):new n(r.s)};D.inverseCosine=D.acos=function(){var t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return r!==-1?r===0?t.isNeg()?Re(e,n,i):new e(0):new e(NaN):t.isZero()?Re(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=n,e.rounding=i,t.times(2))};D.inverseHyperbolicCosine=D.acosh=function(){var t,e,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(t=n.precision,e=n.rounding,n.precision=t+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,B=!1,r=r.times(r).minus(1).sqrt().plus(r),B=!0,n.precision=t,n.rounding=e,r.ln()):new n(r)};D.inverseHyperbolicSine=D.asinh=function(){var t,e,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,B=!1,r=r.times(r).plus(1).sqrt().plus(r),B=!0,n.precision=t,n.rounding=e,r.ln())};D.inverseHyperbolicTangent=D.atanh=function(){var t,e,r,n,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=o.precision,e=o.rounding,n=i.sd(),Math.max(n,t)<2*-i.e-1?S(new o(i),t,e,!0):(o.precision=r=n-i.e,i=H(i.plus(1),new o(1).minus(i),r+t,1),o.precision=t+4,o.rounding=1,i=i.ln(),o.precision=t,o.rounding=e,i.times(.5))):new o(NaN)};D.inverseSine=D.asin=function(){var t,e,r,n,i=this,o=i.constructor;return i.isZero()?new o(i):(e=i.abs().cmp(1),r=o.precision,n=o.rounding,e!==-1?e===0?(t=Re(o,r+4,n).times(.5),t.s=i.s,t):new o(NaN):(o.precision=r+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=r,o.rounding=n,i.times(2)))};D.inverseTangent=D.atan=function(){var t,e,r,n,i,o,s,a,l,u=this,c=u.constructor,f=c.precision,h=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&f+4<=Di)return s=Re(c,f+4,h).times(.25),s.s=u.s,s}else{if(!u.s)return new c(NaN);if(f+4<=Di)return s=Re(c,f+4,h).times(.5),s.s=u.s,s}for(c.precision=a=f+10,c.rounding=1,r=Math.min(28,a/N+2|0),t=r;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(B=!1,e=Math.ceil(a/N),n=1,l=u.times(u),s=new c(u),i=u;t!==-1;)if(i=i.times(l),o=s.minus(i.div(n+=2)),i=i.times(l),s=o.plus(i.div(n+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return r&&(s=s.times(2<<r-1)),B=!0,S(s,c.precision=f,c.rounding=h,!0)};D.isFinite=function(){return!!this.d};D.isInteger=D.isInt=function(){return!!this.d&&de(this.e/N)>this.d.length-2};D.isNaN=function(){return!this.s};D.isNegative=D.isNeg=function(){return this.s<0};D.isPositive=D.isPos=function(){return this.s>0};D.isZero=function(){return!!this.d&&this.d[0]===0};D.lessThan=D.lt=function(t){return this.cmp(t)<0};D.lessThanOrEqualTo=D.lte=function(t){return this.cmp(t)<1};D.logarithm=D.log=function(t){var e,r,n,i,o,s,a,l,u=this,c=u.constructor,f=c.precision,h=c.rounding,d=5;if(t==null)t=new c(10),e=!0;else{if(t=new c(t),r=t.d,t.s<0||!r||!r[0]||t.eq(1))return new c(NaN);e=t.eq(10)}if(r=u.d,u.s<0||!r||!r[0]||u.eq(1))return new c(r&&!r[0]?-1/0:u.s!=1?NaN:r?0:1/0);if(e)if(r.length>1)o=!0;else{for(i=r[0];i%10===0;)i/=10;o=i!==1}if(B=!1,a=f+d,s=Qe(u,a),n=e?on(c,a+10):Qe(t,a),l=H(s,n,a,1),hr(l.d,i=f,h))do if(a+=10,s=Qe(u,a),n=e?on(c,a+10):Qe(t,a),l=H(s,n,a,1),!o){+ue(l.d).slice(i+1,i+15)+1==1e14&&(l=S(l,f+1,0));break}while(hr(l.d,i+=10,h));return B=!0,S(l,f,h)};D.minus=D.sub=function(t){var e,r,n,i,o,s,a,l,u,c,f,h,d=this,g=d.constructor;if(t=new g(t),!d.d||!t.d)return!d.s||!t.s?t=new g(NaN):d.d?t.s=-t.s:t=new g(t.d||d.s!==t.s?d:NaN),t;if(d.s!=t.s)return t.s=-t.s,d.plus(t);if(u=d.d,h=t.d,a=g.precision,l=g.rounding,!u[0]||!h[0]){if(h[0])t.s=-t.s;else if(u[0])t=new g(d);else return new g(l===3?-0:0);return B?S(t,a,l):t}if(r=de(t.e/N),c=de(d.e/N),u=u.slice(),o=c-r,o){for(f=o<0,f?(e=u,o=-o,s=h.length):(e=h,r=c,s=u.length),n=Math.max(Math.ceil(a/N),s)+2,o>n&&(o=n,e.length=1),e.reverse(),n=o;n--;)e.push(0);e.reverse()}else{for(n=u.length,s=h.length,f=n<s,f&&(s=n),n=0;n<s;n++)if(u[n]!=h[n]){f=u[n]<h[n];break}o=0}for(f&&(e=u,u=h,h=e,t.s=-t.s),s=u.length,n=h.length-s;n>0;--n)u[s++]=0;for(n=h.length;n>o;){if(u[--n]<h[n]){for(i=n;i&&u[--i]===0;)u[i]=Ie-1;--u[i],u[n]+=Ie}u[n]-=h[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--r;return u[0]?(t.d=u,t.e=an(u,r),B?S(t,a,l):t):new g(l===3?-0:0)};D.modulo=D.mod=function(t){var e,r=this,n=r.constructor;return t=new n(t),!r.d||!t.s||t.d&&!t.d[0]?new n(NaN):!t.d||r.d&&!r.d[0]?S(new n(r),n.precision,n.rounding):(B=!1,n.modulo==9?(e=H(r,t.abs(),0,3,1),e.s*=t.s):e=H(r,t,0,n.modulo,1),e=e.times(t),B=!0,r.minus(e))};D.naturalExponential=D.exp=function(){return vi(this)};D.naturalLogarithm=D.ln=function(){return Qe(this)};D.negated=D.neg=function(){var t=new this.constructor(this);return t.s=-t.s,S(t)};D.plus=D.add=function(t){var e,r,n,i,o,s,a,l,u,c,f=this,h=f.constructor;if(t=new h(t),!f.d||!t.d)return!f.s||!t.s?t=new h(NaN):f.d||(t=new h(t.d||f.s===t.s?f:NaN)),t;if(f.s!=t.s)return t.s=-t.s,f.minus(t);if(u=f.d,c=t.d,a=h.precision,l=h.rounding,!u[0]||!c[0])return c[0]||(t=new h(f)),B?S(t,a,l):t;if(o=de(f.e/N),n=de(t.e/N),u=u.slice(),i=o-n,i){for(i<0?(r=u,i=-i,s=c.length):(r=c,n=o,s=u.length),o=Math.ceil(a/N),s=o>s?o+1:s+1,i>s&&(i=s,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for(s=u.length,i=c.length,s-i<0&&(i=s,r=c,c=u,u=r),e=0;i;)e=(u[--i]=u[i]+c[i]+e)/Ie|0,u[i]%=Ie;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return t.d=u,t.e=an(u,n),B?S(t,a,l):t};D.precision=D.sd=function(t){var e,r=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(et+t);return r.d?(e=Go(r.d),t&&r.e+1>e&&(e=r.e+1)):e=NaN,e};D.round=function(){var t=this,e=t.constructor;return S(new e(t),t.e+1,e.rounding)};D.sine=D.sin=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+N,n.rounding=1,r=vl(n,Jo(n,r)),n.precision=t,n.rounding=e,S(He>2?r.neg():r,t,e,!0)):new n(NaN)};D.squareRoot=D.sqrt=function(){var t,e,r,n,i,o,s=this,a=s.d,l=s.e,u=s.s,c=s.constructor;if(u!==1||!a||!a[0])return new c(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(B=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=ue(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=de((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),n=new c(e)):n=new c(u.toString()),r=(l=c.precision)+3;;)if(o=n,n=o.plus(H(s,o,r+2,1)).times(.5),ue(o.d).slice(0,r)===(e=ue(n.d)).slice(0,r))if(e=e.slice(r-3,r+1),e=="9999"||!i&&e=="4999"){if(!i&&(S(o,l+1,0),o.times(o).eq(s))){n=o;break}r+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(S(n,l+1,1),t=!n.times(n).eq(s));break}return B=!0,S(n,l,c.rounding,t)};D.tangent=D.tan=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+10,n.rounding=1,r=r.sin(),r.s=1,r=H(r,new n(1).minus(r.times(r)).sqrt(),t+10,0),n.precision=t,n.rounding=e,S(He==2||He==4?r.neg():r,t,e,!0)):new n(NaN)};D.times=D.mul=function(t){var e,r,n,i,o,s,a,l,u,c=this,f=c.constructor,h=c.d,d=(t=new f(t)).d;if(t.s*=c.s,!h||!h[0]||!d||!d[0])return new f(!t.s||h&&!h[0]&&!d||d&&!d[0]&&!h?NaN:!h||!d?t.s/0:t.s*0);for(r=de(c.e/N)+de(t.e/N),l=h.length,u=d.length,l<u&&(o=h,h=d,d=o,s=l,l=u,u=s),o=[],s=l+u,n=s;n--;)o.push(0);for(n=u;--n>=0;){for(e=0,i=l+n;i>n;)a=o[i]+d[n]*h[i-n-1]+e,o[i--]=a%Ie|0,e=a/Ie|0;o[i]=(o[i]+e)%Ie|0}for(;!o[--s];)o.pop();return e?++r:o.shift(),t.d=o,t.e=an(o,r),B?S(t,f.precision,f.rounding):t};D.toBinary=function(t,e){return xi(this,2,t,e)};D.toDecimalPlaces=D.toDP=function(t,e){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(be(t,0,tt),e===void 0?e=n.rounding:be(e,0,8),S(r,t+r.e+1,e))};D.toExponential=function(t,e){var r,n=this,i=n.constructor;return t===void 0?r=Le(n,!0):(be(t,0,tt),e===void 0?e=i.rounding:be(e,0,8),n=S(new i(n),t+1,e),r=Le(n,!0,t+1)),n.isNeg()&&!n.isZero()?"-"+r:r};D.toFixed=function(t,e){var r,n,i=this,o=i.constructor;return t===void 0?r=Le(i):(be(t,0,tt),e===void 0?e=o.rounding:be(e,0,8),n=S(new o(i),t+i.e+1,e),r=Le(n,!1,t+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r};D.toFraction=function(t){var e,r,n,i,o,s,a,l,u,c,f,h,d=this,g=d.d,p=d.constructor;if(!g)return new p(d);if(u=r=new p(1),n=l=new p(0),e=new p(n),o=e.e=Go(g)-d.e-1,s=o%N,e.d[0]=re(10,s<0?N+s:s),t==null)t=o>0?e:u;else{if(a=new p(t),!a.isInt()||a.lt(u))throw Error(et+a);t=a.gt(e)?o>0?e:u:a}for(B=!1,a=new p(ue(g)),c=p.precision,p.precision=o=g.length*N*2;f=H(a,e,0,1,1),i=r.plus(f.times(n)),i.cmp(t)!=1;)r=n,n=i,i=u,u=l.plus(f.times(i)),l=i,i=e,e=a.minus(f.times(i)),a=i;return i=H(t.minus(r),n,0,1,1),l=l.plus(i.times(u)),r=r.plus(i.times(n)),l.s=u.s=d.s,h=H(u,n,o,1).minus(d).abs().cmp(H(l,r,o,1).minus(d).abs())<1?[u,n]:[l,r],p.precision=c,B=!0,h};D.toHexadecimal=D.toHex=function(t,e){return xi(this,16,t,e)};D.toNearest=function(t,e){var r=this,n=r.constructor;if(r=new n(r),t==null){if(!r.d)return r;t=new n(1),e=n.rounding}else{if(t=new n(t),e===void 0?e=n.rounding:be(e,0,8),!r.d)return t.s?r:t;if(!t.d)return t.s&&(t.s=r.s),t}return t.d[0]?(B=!1,r=H(r,t,0,e,1).times(t),B=!0,S(r)):(t.s=r.s,r=t),r};D.toNumber=function(){return+this};D.toOctal=function(t,e){return xi(this,8,t,e)};D.toPower=D.pow=function(t){var e,r,n,i,o,s,a=this,l=a.constructor,u=+(t=new l(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new l(re(+a,u));if(a=new l(a),a.eq(1))return a;if(n=l.precision,o=l.rounding,t.eq(1))return S(a,n,o);if(e=de(t.e/N),e>=t.d.length-1&&(r=u<0?-u:u)<=wl)return i=Wo(l,a,r,n),t.s<0?new l(1).div(i):S(i,n,o);if(s=a.s,s<0){if(e<t.d.length-1)return new l(NaN);if((t.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return r=re(+a,u),e=r==0||!isFinite(r)?de(u*(Math.log("0."+ue(a.d))/Math.LN10+a.e+1)):new l(r+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?s/0:0):(B=!1,l.rounding=a.s=1,r=Math.min(12,(e+"").length),i=vi(t.times(Qe(a,n+r)),n),i.d&&(i=S(i,n+5,1),hr(i.d,n,o)&&(e=n+10,i=S(vi(t.times(Qe(a,e+r)),e),e+5,1),+ue(i.d).slice(n+1,n+15)+1==1e14&&(i=S(i,n+1,0)))),i.s=s,B=!0,l.rounding=o,S(i,n,o))};D.toPrecision=function(t,e){var r,n=this,i=n.constructor;return t===void 0?r=Le(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(be(t,1,tt),e===void 0?e=i.rounding:be(e,0,8),n=S(new i(n),t,e),r=Le(n,t<=n.e||n.e<=i.toExpNeg,t)),n.isNeg()&&!n.isZero()?"-"+r:r};D.toSignificantDigits=D.toSD=function(t,e){var r=this,n=r.constructor;return t===void 0?(t=n.precision,e=n.rounding):(be(t,1,tt),e===void 0?e=n.rounding:be(e,0,8)),S(new n(r),t,e)};D.toString=function(){var t=this,e=t.constructor,r=Le(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+r:r};D.truncated=D.trunc=function(){return S(new this.constructor(this),this.e+1,1)};D.valueOf=D.toJSON=function(){var t=this,e=t.constructor,r=Le(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+r:r};function ue(t){var e,r,n,i=t.length-1,o="",s=t[0];if(i>0){for(o+=s,e=1;e<i;e++)n=t[e]+"",r=N-n.length,r&&(o+=Ke(r)),o+=n;s=t[e],n=s+"",r=N-n.length,r&&(o+=Ke(r))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function be(t,e,r){if(t!==~~t||t<e||t>r)throw Error(et+t)}function hr(t,e,r,n){var i,o,s,a;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=N,i=0):(i=Math.ceil((e+1)/N),e%=N),o=re(10,N-e),a=t[i]%o|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=r<4&&a==99999||r>3&&a==49999||a==5e4||a==0):s=(r<4&&a+1==o||r>3&&a+1==o/2)&&(t[i+1]/o/100|0)==re(10,e-2)-1||(a==o/2||a==0)&&(t[i+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(n||r<4)&&a==9999||!n&&r>3&&a==4999):s=((n||r<4)&&a+1==o||!n&&r>3&&a+1==o/2)&&(t[i+1]/o/1e3|0)==re(10,e-3)-1,s}function en(t,e,r){for(var n,i=[0],o,s=0,a=t.length;s<a;){for(o=i.length;o--;)i[o]*=e;for(i[0]+=bi.indexOf(t.charAt(s++)),n=0;n<i.length;n++)i[n]>r-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/r|0,i[n]%=r)}return i.reverse()}function El(t,e){var r,n,i;if(e.isZero())return e;n=e.d.length,n<32?(r=Math.ceil(n/3),i=(1/un(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),t.precision+=r,e=Ot(t,1,e.times(i),new t(1));for(var o=r;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=r,e}var H=(function(){function t(n,i,o){var s,a=0,l=n.length;for(n=n.slice();l--;)s=n[l]*i+a,n[l]=s%o|0,a=s/o|0;return a&&n.unshift(a),n}function e(n,i,o,s){var a,l;if(o!=s)l=o>s?1:-1;else for(a=l=0;a<o;a++)if(n[a]!=i[a]){l=n[a]>i[a]?1:-1;break}return l}function r(n,i,o,s){for(var a=0;o--;)n[o]-=a,a=n[o]<i[o]?1:0,n[o]=a*s+n[o]-i[o];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,o,s,a,l){var u,c,f,h,d,g,p,y,m,w,b,v,x,T,E,C,M,I,_,P,K=n.constructor,z=n.s==i.s?1:-1,ee=n.d,R=i.d;if(!ee||!ee[0]||!R||!R[0])return new K(!n.s||!i.s||(ee?R&&ee[0]==R[0]:!R)?NaN:ee&&ee[0]==0||!R?z*0:z/0);for(l?(d=1,c=n.e-i.e):(l=Ie,d=N,c=de(n.e/d)-de(i.e/d)),_=R.length,M=ee.length,m=new K(z),w=m.d=[],f=0;R[f]==(ee[f]||0);f++);if(R[f]>(ee[f]||0)&&c--,o==null?(T=o=K.precision,s=K.rounding):a?T=o+(n.e-i.e)+1:T=o,T<0)w.push(1),g=!0;else{if(T=T/d+2|0,f=0,_==1){for(h=0,R=R[0],T++;(f<M||h)&&T--;f++)E=h*l+(ee[f]||0),w[f]=E/R|0,h=E%R|0;g=h||f<M}else{for(h=l/(R[0]+1)|0,h>1&&(R=t(R,h,l),ee=t(ee,h,l),_=R.length,M=ee.length),C=_,b=ee.slice(0,_),v=b.length;v<_;)b[v++]=0;P=R.slice(),P.unshift(0),I=R[0],R[1]>=l/2&&++I;do h=0,u=e(R,b,_,v),u<0?(x=b[0],_!=v&&(x=x*l+(b[1]||0)),h=x/I|0,h>1?(h>=l&&(h=l-1),p=t(R,h,l),y=p.length,v=b.length,u=e(p,b,y,v),u==1&&(h--,r(p,_<y?P:R,y,l))):(h==0&&(u=h=1),p=R.slice()),y=p.length,y<v&&p.unshift(0),r(b,p,v,l),u==-1&&(v=b.length,u=e(R,b,_,v),u<1&&(h++,r(b,_<v?P:R,v,l))),v=b.length):u===0&&(h++,b=[0]),w[f++]=h,u&&b[0]?b[v++]=ee[C]||0:(b=[ee[C]],v=1);while((C++<M||b[0]!==void 0)&&T--);g=b[0]!==void 0}w[0]||w.shift()}if(d==1)m.e=c,qo=g;else{for(f=1,h=w[0];h>=10;h/=10)f++;m.e=f+c*d-1,S(m,a?o+m.e+1:o,s,g)}return m}})();function S(t,e,r,n){var i,o,s,a,l,u,c,f,h,d=t.constructor;e:if(e!=null){if(f=t.d,!f)return t;for(i=1,a=f[0];a>=10;a/=10)i++;if(o=e-i,o<0)o+=N,s=e,c=f[h=0],l=c/re(10,i-s-1)%10|0;else if(h=Math.ceil((o+1)/N),a=f.length,h>=a)if(n){for(;a++<=h;)f.push(0);c=l=0,i=1,o%=N,s=o-N+1}else break e;else{for(c=a=f[h],i=1;a>=10;a/=10)i++;o%=N,s=o-N+i,l=s<0?0:c/re(10,i-s-1)%10|0}if(n=n||e<0||f[h+1]!==void 0||(s<0?c:c%re(10,i-s-1)),u=r<4?(l||n)&&(r==0||r==(t.s<0?3:2)):l>5||l==5&&(r==4||n||r==6&&(o>0?s>0?c/re(10,i-s):0:f[h-1])%10&1||r==(t.s<0?8:7)),e<1||!f[0])return f.length=0,u?(e-=t.e+1,f[0]=re(10,(N-e%N)%N),t.e=-e||0):f[0]=t.e=0,t;if(o==0?(f.length=h,a=1,h--):(f.length=h+1,a=re(10,N-o),f[h]=s>0?(c/re(10,i-s)%re(10,s)|0)*a:0),u)for(;;)if(h==0){for(o=1,s=f[0];s>=10;s/=10)o++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(t.e++,f[0]==Ie&&(f[0]=1));break}else{if(f[h]+=a,f[h]!=Ie)break;f[h--]=0,a=1}for(o=f.length;f[--o]===0;)f.pop()}return B&&(t.e>d.maxE?(t.d=null,t.e=NaN):t.e<d.minE&&(t.e=0,t.d=[0])),t}function Le(t,e,r){if(!t.isFinite())return Yo(t);var n,i=t.e,o=ue(t.d),s=o.length;return e?(r&&(n=r-s)>0?o=o.charAt(0)+"."+o.slice(1)+Ke(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):i<0?(o="0."+Ke(-i-1)+o,r&&(n=r-s)>0&&(o+=Ke(n))):i>=s?(o+=Ke(i+1-s),r&&(n=r-i-1)>0&&(o=o+"."+Ke(n))):((n=i+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),r&&(n=r-s)>0&&(i+1===s&&(o+="."),o+=Ke(n))),o}function an(t,e){var r=t[0];for(e*=N;r>=10;r/=10)e++;return e}function on(t,e,r){if(e>bl)throw B=!0,r&&(t.precision=r),Error(zo);return S(new t(rn),e,1,!0)}function Re(t,e,r){if(e>Di)throw Error(zo);return S(new t(nn),e,r,!0)}function Go(t){var e=t.length-1,r=e*N+1;if(e=t[e],e){for(;e%10==0;e/=10)r--;for(e=t[0];e>=10;e/=10)r++}return r}function Ke(t){for(var e="";t--;)e+="0";return e}function Wo(t,e,r,n){var i,o=new t(1),s=Math.ceil(n/N+4);for(B=!1;;){if(r%2&&(o=o.times(e),Uo(o.d,s)&&(i=!0)),r=de(r/2),r===0){r=o.d.length-1,i&&o.d[r]===0&&++o.d[r];break}e=e.times(e),Uo(e.d,s)}return B=!0,o}function Po(t){return t.d[t.d.length-1]&1}function Xo(t,e,r){for(var n,i,o=new t(e[0]),s=0;++s<e.length;){if(i=new t(e[s]),!i.s){o=i;break}n=o.cmp(i),(n===r||n===0&&o.s===r)&&(o=i)}return o}function vi(t,e){var r,n,i,o,s,a,l,u=0,c=0,f=0,h=t.constructor,d=h.rounding,g=h.precision;if(!t.d||!t.d[0]||t.e>17)return new h(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(e==null?(B=!1,l=g):l=e,a=new h(.03125);t.e>-2;)t=t.times(a),f+=5;for(n=Math.log(re(2,f))/Math.LN10*2+5|0,l+=n,r=o=s=new h(1),h.precision=l;;){if(o=S(o.times(t),l,1),r=r.times(++c),a=s.plus(H(o,r,l,1)),ue(a.d).slice(0,l)===ue(s.d).slice(0,l)){for(i=f;i--;)s=S(s.times(s),l,1);if(e==null)if(u<3&&hr(s.d,l-n,d,u))h.precision=l+=10,r=o=a=new h(1),c=0,u++;else return S(s,h.precision=g,d,B=!0);else return h.precision=g,s}s=a}}function Qe(t,e){var r,n,i,o,s,a,l,u,c,f,h,d=1,g=10,p=t,y=p.d,m=p.constructor,w=m.rounding,b=m.precision;if(p.s<0||!y||!y[0]||!p.e&&y[0]==1&&y.length==1)return new m(y&&!y[0]?-1/0:p.s!=1?NaN:y?0:p);if(e==null?(B=!1,c=b):c=e,m.precision=c+=g,r=ue(y),n=r.charAt(0),Math.abs(o=p.e)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)p=p.times(t),r=ue(p.d),n=r.charAt(0),d++;o=p.e,n>1?(p=new m("0."+r),o++):p=new m(n+"."+r.slice(1))}else return u=on(m,c+2,b).times(o+""),p=Qe(new m(n+"."+r.slice(1)),c-g).plus(u),m.precision=b,e==null?S(p,b,w,B=!0):p;for(f=p,l=s=p=H(p.minus(1),p.plus(1),c,1),h=S(p.times(p),c,1),i=3;;){if(s=S(s.times(h),c,1),u=l.plus(H(s,new m(i),c,1)),ue(u.d).slice(0,c)===ue(l.d).slice(0,c))if(l=l.times(2),o!==0&&(l=l.plus(on(m,c+2,b).times(o+""))),l=H(l,new m(d),c,1),e==null)if(hr(l.d,c-g,w,a))m.precision=c+=g,u=s=p=H(f.minus(1),f.plus(1),c,1),h=S(p.times(p),c,1),i=a=1;else return S(l,m.precision=b,w,B=!0);else return m.precision=b,l;l=u,i+=2}}function Yo(t){return String(t.s*t.s/0)}function tn(t,e){var r,n,i;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),n=0;e.charCodeAt(n)===48;n++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(n,i),e){if(i-=n,t.e=r=r-n-1,t.d=[],n=(r+1)%N,r<0&&(n+=N),n<i){for(n&&t.d.push(+e.slice(0,n)),i-=N;n<i;)t.d.push(+e.slice(n,n+=N));e=e.slice(n),n=N-e.length}else n-=i;for(;n--;)e+="0";t.d.push(+e),B&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function Dl(t,e){var r,n,i,o,s,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Ho.test(e))return tn(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(gl.test(e))r=16,e=e.toLowerCase();else if(ml.test(e))r=2;else if(yl.test(e))r=8;else throw Error(et+e);for(o=e.search(/p/i),o>0?(l=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,n=t.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,i=Wo(n,new n(r),o,o*2)),u=en(e,r,Ie),c=u.length-1,o=c;u[o]===0;--o)u.pop();return o<0?new n(t.s*0):(t.e=an(u,c),t.d=u,B=!1,s&&(t=H(t,i,a*4)),l&&(t=t.times(Math.abs(l)<54?re(2,l):dr.pow(2,l))),B=!0,t)}function vl(t,e){var r,n=e.d.length;if(n<3)return e.isZero()?e:Ot(t,2,e,e);r=1.4*Math.sqrt(n),r=r>16?16:r|0,e=e.times(1/un(5,r)),e=Ot(t,2,e,e);for(var i,o=new t(5),s=new t(16),a=new t(20);r--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(a))));return e}function Ot(t,e,r,n,i){var o,s,a,l,u=1,c=t.precision,f=Math.ceil(c/N);for(B=!1,l=r.times(r),a=new t(n);;){if(s=H(a.times(l),new t(e++*e++),c,1),a=i?n.plus(s):n.minus(s),n=H(s.times(l),new t(e++*e++),c,1),s=a.plus(n),s.d[f]!==void 0){for(o=f;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,u++}return B=!0,s.d.length=f+1,s}function un(t,e){for(var r=t;--e;)r*=t;return r}function Jo(t,e){var r,n=e.s<0,i=Re(t,t.precision,1),o=i.times(.5);if(e=e.abs(),e.lte(o))return He=n?4:1,e;if(r=e.divToInt(i),r.isZero())He=n?3:2;else{if(e=e.minus(r.times(i)),e.lte(o))return He=Po(r)?n?2:3:n?4:1,e;He=Po(r)?n?1:4:n?3:2}return e.minus(i).abs()}function xi(t,e,r,n){var i,o,s,a,l,u,c,f,h,d=t.constructor,g=r!==void 0;if(g?(be(r,1,tt),n===void 0?n=d.rounding:be(n,0,8)):(r=d.precision,n=d.rounding),!t.isFinite())c=Yo(t);else{for(c=Le(t),s=c.indexOf("."),g?(i=2,e==16?r=r*4-3:e==8&&(r=r*3-2)):i=e,s>=0&&(c=c.replace(".",""),h=new d(1),h.e=c.length-s,h.d=en(Le(h),10,i),h.e=h.d.length),f=en(c,10,i),o=l=f.length;f[--l]==0;)f.pop();if(!f[0])c=g?"0p+0":"0";else{if(s<0?o--:(t=new d(t),t.d=f,t.e=o,t=H(t,h,r,n,0,i),f=t.d,o=t.e,u=qo),s=f[r],a=i/2,u=u||f[r+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(t.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&f[r-1]&1||n===(t.s<0?8:7)),f.length=r,u)for(;++f[--r]>i-1;)f[r]=0,r||(++o,f.unshift(1));for(l=f.length;!f[l-1];--l);for(s=0,c="";s<l;s++)c+=bi.charAt(f[s]);if(g){if(l>1)if(e==16||e==8){for(s=e==16?4:3,--l;l%s;l++)c+="0";for(f=en(c,i,e),l=f.length;!f[l-1];--l);for(s=1,c="1.";s<l;s++)c+=bi.charAt(f[s])}else c=c.charAt(0)+"."+c.slice(1);c=c+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)c="0"+c;c="0."+c}else if(++o>l)for(o-=l;o--;)c+="0";else o<l&&(c=c.slice(0,o)+"."+c.slice(o))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return t.s<0?"-"+c:c}function Uo(t,e){if(t.length>e)return t.length=e,!0}function xl(t){return new this(t).abs()}function Tl(t){return new this(t).acos()}function Al(t){return new this(t).acosh()}function Cl(t,e){return new this(t).plus(e)}function Sl(t){return new this(t).asin()}function Nl(t){return new this(t).asinh()}function _l(t){return new this(t).atan()}function Il(t){return new this(t).atanh()}function Ol(t,e){t=new this(t),e=new this(e);var r,n=this.precision,i=this.rounding,o=n+4;return!t.s||!e.s?r=new this(NaN):!t.d&&!e.d?(r=Re(this,o,1).times(e.s>0?.25:.75),r.s=t.s):!e.d||t.isZero()?(r=e.s<0?Re(this,n,i):new this(0),r.s=t.s):!t.d||e.isZero()?(r=Re(this,o,1).times(.5),r.s=t.s):e.s<0?(this.precision=o,this.rounding=1,r=this.atan(H(t,e,o,1)),e=Re(this,o,1),this.precision=n,this.rounding=i,r=t.s<0?r.minus(e):r.plus(e)):r=this.atan(H(t,e,o,1)),r}function Ml(t){return new this(t).cbrt()}function Bl(t){return S(t=new this(t),t.e+1,2)}function Fl(t,e,r){return new this(t).clamp(e,r)}function kl(t){if(!t||typeof t!="object")throw Error(sn+"Object expected");var e,r,n,i=t.defaults===!0,o=["precision",1,tt,"rounding",0,8,"toExpNeg",-It,0,"toExpPos",0,It,"maxE",0,It,"minE",-It,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(r=o[e],i&&(this[r]=Ei[r]),(n=t[r])!==void 0)if(de(n)===n&&n>=o[e+1]&&n<=o[e+2])this[r]=n;else throw Error(et+r+": "+n);if(r="crypto",i&&(this[r]=Ei[r]),(n=t[r])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[r]=!0;else throw Error(Vo);else this[r]=!1;else throw Error(et+r+": "+n);return this}function Rl(t){return new this(t).cos()}function Ll(t){return new this(t).cosh()}function Zo(t){var e,r,n;function i(o){var s,a,l,u=this;if(!(u instanceof i))return new i(o);if(u.constructor=i,$o(o)){u.s=o.s,B?!o.d||o.e>i.maxE?(u.e=NaN,u.d=null):o.e<i.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(l=typeof o,l==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;B?s>i.maxE?(u.e=NaN,u.d=null):s<i.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return tn(u,o.toString())}if(l==="string")return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),Ho.test(o)?tn(u,o):Dl(u,o);if(l==="bigint")return o<0?(o=-o,u.s=-1):u.s=1,tn(u,o.toString());throw Error(et+o)}if(i.prototype=D,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=kl,i.clone=Zo,i.isDecimal=$o,i.abs=xl,i.acos=Tl,i.acosh=Al,i.add=Cl,i.asin=Sl,i.asinh=Nl,i.atan=_l,i.atanh=Il,i.atan2=Ol,i.cbrt=Ml,i.ceil=Bl,i.clamp=Fl,i.cos=Rl,i.cosh=Ll,i.div=Pl,i.exp=Ul,i.floor=$l,i.hypot=ql,i.ln=zl,i.log=Vl,i.log10=Hl,i.log2=jl,i.max=Gl,i.min=Wl,i.mod=Xl,i.mul=Yl,i.pow=Jl,i.random=Zl,i.round=Kl,i.sign=Ql,i.sin=ec,i.sinh=tc,i.sqrt=rc,i.sub=nc,i.sum=ic,i.tan=oc,i.tanh=sc,i.trunc=ac,t===void 0&&(t={}),t&&t.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)t.hasOwnProperty(r=n[e++])||(t[r]=this[r]);return i.config(t),i}function Pl(t,e){return new this(t).div(e)}function Ul(t){return new this(t).exp()}function $l(t){return S(t=new this(t),t.e+1,3)}function ql(){var t,e,r=new this(0);for(B=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)r.d&&(r=r.plus(e.times(e)));else{if(e.s)return B=!0,new this(1/0);r=e}return B=!0,r.sqrt()}function $o(t){return t instanceof dr||t&&t.toStringTag===jo||!1}function zl(t){return new this(t).ln()}function Vl(t,e){return new this(t).log(e)}function jl(t){return new this(t).log(2)}function Hl(t){return new this(t).log(10)}function Gl(){return Xo(this,arguments,-1)}function Wl(){return Xo(this,arguments,1)}function Xl(t,e){return new this(t).mod(e)}function Yl(t,e){return new this(t).mul(e)}function Jl(t,e){return new this(t).pow(e)}function Zl(t){var e,r,n,i,o=0,s=new this(1),a=[];if(t===void 0?t=this.precision:be(t,1,tt),n=Math.ceil(t/N),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));o<n;)i=e[o],i>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);o<n;)i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(i%1e7),o+=4);o=n/4}else throw Error(Vo);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],t%=N,n&&t&&(i=re(10,N-t),a[o]=(n/i|0)*i);a[o]===0;o--)a.pop();if(o<0)r=0,a=[0];else{for(r=-1;a[0]===0;r-=N)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<N&&(r-=N-n)}return s.e=r,s.d=a,s}function Kl(t){return S(t=new this(t),t.e+1,this.rounding)}function Ql(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function ec(t){return new this(t).sin()}function tc(t){return new this(t).sinh()}function rc(t){return new this(t).sqrt()}function nc(t,e){return new this(t).sub(e)}function ic(){var t=0,e=arguments,r=new this(e[t]);for(B=!1;r.s&&++t<e.length;)r=r.plus(e[t]);return B=!0,S(r,this.precision,this.rounding)}function oc(t){return new this(t).tan()}function sc(t){return new this(t).tanh()}function ac(t){return S(t=new this(t),t.e+1,1)}D[Symbol.for("nodejs.util.inspect.custom")]=D.toString;D[Symbol.toStringTag]="Decimal";var dr=D.constructor=Zo(Ei);rn=new dr(rn);nn=new dr(nn);var Ko=dr;var uc=20,lc=1,ht=1e6,Qo=1e6,cc=-7,fc=21,hc=!1,pr="[big.js] ",dt=pr+"Invalid ",ln=dt+"decimal places",dc=dt+"rounding mode",es=pr+"Division by zero",V={},Pe=void 0,pc=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function ts(){function t(e){var r=this;if(!(r instanceof t))return e===Pe?ts():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(dt+"value");e=e===0&&1/e<0?"-0":String(e)}mc(r,e)}r.constructor=t}return t.prototype=V,t.DP=uc,t.RM=lc,t.NE=cc,t.PE=fc,t.strict=hc,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function mc(t,e){var r,n,i;if(!pc.test(e))throw Error(dt+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&e.charAt(n)=="0";)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}return t}function pt(t,e,r,n){var i=t.c;if(r===Pe&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(dc);if(e<1)n=r===3&&(n||!!i[0])||e===0&&(r===1&&i[0]>=5||r===2&&(i[0]>5||i[0]===5&&(n||i[1]!==Pe))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=r===1&&i[e]>=5||r===2&&(i[e]>5||i[e]===5&&(n||i[e+1]!==Pe||i[e-1]&1))||r===3&&(n||!!i[0]),i.length=e,n){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function mt(t,e,r){var n=t.e,i=t.c.join(""),o=i.length;if(e)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}V.abs=function(){var t=new this.constructor(this);return t.s=1,t};V.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,s=t.s,a=r.e,l=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(e=o<0,a!=l)return a>l^e?1:-1;for(s=(a=n.length)<(l=i.length)?a:l,o=-1;++o<s;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return a==l?0:a>l^e?1:-1};V.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,o=e.s==t.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>ht)throw Error(ln);if(!i[0])throw Error(es);if(!n[0])return t.s=o,t.c=[t.e=0],t;var a,l,u,c,f,h=i.slice(),d=a=i.length,g=n.length,p=n.slice(0,a),y=p.length,m=t,w=m.c=[],b=0,v=s+(m.e=e.e-t.e)+1;for(m.s=o,o=v<0?0:v,h.unshift(0);y++<a;)p.push(0);do{for(u=0;u<10;u++){if(a!=(y=p.length))c=a>y?1:-1;else for(f=-1,c=0;++f<a;)if(i[f]!=p[f]){c=i[f]>p[f]?1:-1;break}if(c<0){for(l=y==a?i:h;y;){if(p[--y]<l[y]){for(f=y;f&&!p[--f];)p[f]=9;--p[f],p[y]+=10}p[y]-=l[y]}for(;!p[0];)p.shift()}else break}w[b++]=c?u:++u,p[0]&&c?p[y]=n[d]||0:p=[n[d]]}while((d++<g||p[0]!==Pe)&&o--);return!w[0]&&b!=1&&(w.shift(),m.e--,v--),b>v&&pt(m,v,r.RM,p[0]!==Pe),m};V.eq=function(t){return this.cmp(t)===0};V.gt=function(t){return this.cmp(t)>0};V.gte=function(t){return this.cmp(t)>-1};V.lt=function(t){return this.cmp(t)<0};V.lte=function(t){return this.cmp(t)<1};V.minus=V.sub=function(t){var e,r,n,i,o=this,s=o.constructor,a=o.s,l=(t=new s(t)).s;if(a!=l)return t.s=-l,o.plus(t);var u=o.c.slice(),c=o.e,f=t.c,h=t.e;if(!u[0]||!f[0])return f[0]?t.s=-l:u[0]?t=new s(o):t.s=1,t;if(a=c-h){for((i=a<0)?(a=-a,n=u):(h=c,n=f),n.reverse(),l=a;l--;)n.push(0);n.reverse()}else for(r=((i=u.length<f.length)?u:f).length,a=l=0;l<r;l++)if(u[l]!=f[l]){i=u[l]<f[l];break}if(i&&(n=u,u=f,f=n,t.s=-t.s),(l=(r=f.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;r>a;){if(u[--r]<f[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=f[r]}for(;u[--l]===0;)u.pop();for(;u[0]===0;)u.shift(),--h;return u[0]||(t.s=1,u=[h=0]),t.c=u,t.e=h,t};V.mod=function(t){var e,r=this,n=r.constructor,i=r.s,o=(t=new n(t)).s;if(!t.c[0])throw Error(es);return r.s=t.s=1,e=t.cmp(r)==1,r.s=i,t.s=o,e?new n(r):(i=n.DP,o=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=o,this.minus(r.times(t)))};V.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};V.plus=V.add=function(t){var e,r,n,i=this,o=i.constructor;if(t=new o(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var s=i.e,a=i.c,l=t.e,u=t.c;if(!a[0]||!u[0])return u[0]||(a[0]?t=new o(i):t.s=i.s),t;if(a=a.slice(),e=s-l){for(e>0?(l=s,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+u[e]+r)/10|0;for(r&&(a.unshift(r),++l),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=l,t};V.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-Qo||t>Qo)throw Error(dt+"exponent");for(i&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return i?r.div(n):n};V.prec=function(t,e){if(t!==~~t||t<1||t>ht)throw Error(dt+"precision");return pt(new this.constructor(this),t,e)};V.round=function(t,e){if(t===Pe)t=0;else if(t!==~~t||t<-ht||t>ht)throw Error(ln);return pt(new this.constructor(this),t+this.e+1,e)};V.sqrt=function(){var t,e,r,n=this,i=n.constructor,o=n.s,s=n.e,a=new i("0.5");if(!n.c[0])return new i(n);if(o<0)throw Error(pr+"No square root");o=Math.sqrt(+mt(n,!0,!0)),o===0||o===1/0?(e=n.c.join(""),e.length+s&1||(e+="0"),o=Math.sqrt(e),s=((s+1)/2|0)-(s<0||s&1),t=new i((o==1/0?"5e":(o=o.toExponential()).slice(0,o.indexOf("e")+1))+s)):t=new i(o+""),s=t.e+(i.DP+=4);do r=t,t=a.times(r.plus(n.div(r)));while(r.c.slice(0,s).join("")!==t.c.slice(0,s).join(""));return pt(t,(i.DP-=4)+t.e+1,i.RM)};V.times=V.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,s=i.length,a=o.length,l=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=l+u,s<a&&(e=i,i=o,o=e,u=s,s=a,a=u),e=new Array(u=s+a);u--;)e[u]=0;for(l=a;l--;){for(a=0,u=s+l;u>l;)a=e[u]+o[l]*i[u-l-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t};V.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==Pe){if(t!==~~t||t<0||t>ht)throw Error(ln);for(r=pt(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return mt(r,!0,!!n)};V.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==Pe){if(t!==~~t||t<0||t>ht)throw Error(ln);for(r=pt(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return mt(r,!1,!!n)};V[Symbol.for("nodejs.util.inspect.custom")]=V.toJSON=V.toString=function(){var t=this,e=t.constructor;return mt(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};V.toNumber=function(){var t=+mt(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(pr+"Imprecise conversion");return t};V.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==Pe){if(t!==~~t||t<1||t>ht)throw Error(dt+"precision");for(r=pt(new n(r),t,e);r.c.length<t;)r.c.push(0)}return mt(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)};V.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(pr+"valueOf disallowed");return mt(t,t.e<=e.NE||t.e>=e.PE,!0)};var gc=ts(),rs=gc;var Fi={};Ro(Fi,{DecodeError:()=>pe,Decoder:()=>Me,EXT_TIMESTAMP:()=>Ai,Encoder:()=>Mt,ExtData:()=>Oe,ExtensionCodec:()=>rt,decode:()=>fs,decodeArrayStream:()=>ps,decodeAsync:()=>ds,decodeMulti:()=>hs,decodeMultiStream:()=>ms,decodeTimestampExtension:()=>Ii,decodeTimestampToTimeSpec:()=>_i,encode:()=>hn,encodeDateToTimeSpec:()=>Si,encodeTimeSpecToTimestamp:()=>Ci,encodeTimestampExtension:()=>Ni});function ns(t){let e=t.length,r=0,n=0;for(;n<e;){let i=t.charCodeAt(n++);if((i&4294967168)===0){r++;continue}else if((i&4294965248)===0)r+=2;else{if(i>=55296&&i<=56319&&n<e){let o=t.charCodeAt(n);(o&64512)===56320&&(++n,i=((i&1023)<<10)+(o&1023)+65536)}(i&4294901760)===0?r+=3:r+=4}}return r}function yc(t,e,r){let n=t.length,i=r,o=0;for(;o<n;){let s=t.charCodeAt(o++);if((s&4294967168)===0){e[i++]=s;continue}else if((s&4294965248)===0)e[i++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<n){let a=t.charCodeAt(o);(a&64512)===56320&&(++o,s=((s&1023)<<10)+(a&1023)+65536)}(s&4294901760)===0?(e[i++]=s>>12&15|224,e[i++]=s>>6&63|128):(e[i++]=s>>18&7|240,e[i++]=s>>12&63|128,e[i++]=s>>6&63|128)}e[i++]=s&63|128}}var wc=new TextEncoder,bc=50;function Ec(t,e,r){wc.encodeInto(t,e.subarray(r))}function is(t,e,r){t.length>bc?Ec(t,e,r):yc(t,e,r)}var Dc=4096;function Ti(t,e,r){let n=e,i=n+r,o=[],s="";for(;n<i;){let a=t[n++];if((a&128)===0)o.push(a);else if((a&224)===192){let l=t[n++]&63;o.push((a&31)<<6|l)}else if((a&240)===224){let l=t[n++]&63,u=t[n++]&63;o.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=t[n++]&63,u=t[n++]&63,c=t[n++]&63,f=(a&7)<<18|l<<12|u<<6|c;f>65535&&(f-=65536,o.push(f>>>10&1023|55296),f=56320|f&1023),o.push(f)}else o.push(a);o.length>=Dc&&(s+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(s+=String.fromCharCode(...o)),s}var vc=new TextDecoder,xc=200;function Tc(t,e,r){let n=t.subarray(e,e+r);return vc.decode(n)}function os(t,e,r){return r>xc?Tc(t,e,r):Ti(t,e,r)}var Oe=class{type;data;constructor(e,r){this.type=e,this.data=r}};var pe=class t extends Error{constructor(e){super(e);let r=Object.create(t.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:t.name})}};function ss(t,e,r){let n=r/4294967296,i=r;t.setUint32(e,n),t.setUint32(e+4,i)}function cn(t,e,r){let n=Math.floor(r/4294967296),i=r;t.setUint32(e,n),t.setUint32(e+4,i)}function fn(t,e){let r=t.getInt32(e),n=t.getUint32(e+4);return r*4294967296+n}function as(t,e){let r=t.getUint32(e),n=t.getUint32(e+4);return r*4294967296+n}var Ai=-1,Ac=4294967296-1,Cc=17179869184-1;function Ci({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Cc)if(e===0&&t<=Ac){let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{let r=t/4294967296,n=t&4294967295,i=new Uint8Array(8),o=new DataView(i.buffer);return o.setUint32(0,e<<2|r&3),o.setUint32(4,n),i}else{let r=new Uint8Array(12),n=new DataView(r.buffer);return n.setUint32(0,e),cn(n,4,t),r}}function Si(t){let e=t.getTime(),r=Math.floor(e/1e3),n=(e-r*1e3)*1e6,i=Math.floor(n/1e9);return{sec:r+i,nsec:n-i*1e9}}function Ni(t){if(t instanceof Date){let e=Si(t);return Ci(e)}else return null}function _i(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let r=e.getUint32(0),n=e.getUint32(4),i=(r&3)*4294967296+n,o=r>>>2;return{sec:i,nsec:o}}case 12:{let r=fn(e,4),n=e.getUint32(0);return{sec:r,nsec:n}}default:throw new pe(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Ii(t){let e=_i(t);return new Date(e.sec*1e3+e.nsec/1e6)}var us={type:Ai,encode:Ni,decode:Ii};var rt=class t{static defaultCodec=new t;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(us)}register({type:e,encode:r,decode:n}){if(e>=0)this.encoders[e]=r,this.decoders[e]=n;else{let i=-1-e;this.builtInEncoders[i]=r,this.builtInDecoders[i]=n}}tryToEncode(e,r){for(let n=0;n<this.builtInEncoders.length;n++){let i=this.builtInEncoders[n];if(i!=null){let o=i(e,r);if(o!=null){let s=-1-n;return new Oe(s,o)}}}for(let n=0;n<this.encoders.length;n++){let i=this.encoders[n];if(i!=null){let o=i(e,r);if(o!=null){let s=n;return new Oe(s,o)}}}return e instanceof Oe?e:null}decode(e,r,n){let i=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return i?i(e,r,n):new Oe(r,e)}};function Sc(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function mr(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Sc(t)?new Uint8Array(t):Uint8Array.from(t)}var Nc=100,_c=2048,Mt=class t{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??rt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Nc,this.initialBufferSize=e?.initialBufferSize??_c,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,r)}ensureBufferSizeToWrite(e){let r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){let r=new ArrayBuffer(e),n=new Uint8Array(r),i=new DataView(r);n.set(this.bytes),this.view=i,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=ns(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),is(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,r){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);let n=mr(e);this.writeU8a(n)}encodeArray(e,r){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let i of e)this.doEncode(i,r+1)}countWithoutUndefined(e,r){let n=0;for(let i of r)e[i]!==void 0&&n++;return n}encodeMap(e,r){let n=Object.keys(e);this.sortKeys&&n.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let o of n){let s=e[o];this.ignoreUndefined&&s===void 0||(this.encodeString(o),this.doEncode(s,r+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),i=n.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(n);return}let r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),ss(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),cn(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function hn(t,e){return new Mt(e).encodeSharedRef(t)}function dn(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}var Ic=16,Oc=16,pn=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Ic,r=Oc){this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,n){let i=this.caches[n-1];e:for(let o of i){let s=o.bytes;for(let a=0;a<n;a++)if(s[a]!==e[r+a])continue e;return o.str}return null}store(e,r){let n=this.caches[e.length-1],i={bytes:e,str:r};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)}decode(e,r,n){let i=this.find(e,r,n);if(i!=null)return this.hit++,i;this.miss++;let o=Ti(e,r,n),s=Uint8Array.prototype.slice.call(e,r,r+n);return this.store(s,o),o}};var Oi="array",wr="map_key",cs="map_value",Mc=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new pe("The type of key must be string or number but "+typeof t)},Mi=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let r=this.getUninitializedStateFromPool();r.type=Oi,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){let r=this.getUninitializedStateFromPool();r.type=wr,r.readCount=0,r.size=e,r.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Oi){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===wr||e.type===cs){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},yr=-1,Bi=new DataView(new ArrayBuffer(0)),Bc=new Uint8Array(Bi.buffer);try{Bi.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var ls=new RangeError("Insufficient data"),Fc=new pn,Me=class t{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Bi;bytes=Bc;headByte=yr;stack=new Mi;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??rt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Fc,this.mapKeyConverter=e?.mapKeyConverter??Mc}clone(){return new t({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=yr,this.stack.reset()}setBuffer(e){let r=mr(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===yr&&!this.hasRemaining(1))this.setBuffer(e);else{let r=this.bytes.subarray(this.pos),n=mr(e),i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:r,pos:n}=this;return new RangeError(`Extra ${r.byteLength-n} of ${r.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let r=!1,n;for await(let a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),r=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:i,pos:o,totalPos:s}=this;throw new RangeError(`Insufficient data in parsing ${dn(i)} at ${s} (${o} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let n=r,i=-1;for await(let o of e){if(r&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o),n&&(i=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(s){if(!(s instanceof RangeError))throw s}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else{let i=e-160;r=this.decodeString(i,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){let i=this.lookU8();r=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();r=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();r=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else r=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else r={}}else if(e===196){let i=this.lookU8();r=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();r=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();r=this.decodeBinary(i,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();r=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();r=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();r=this.decodeExtension(i,4)}else throw new pe(`Unrecognized type byte: ${dn(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let i=n.top();if(i.type===Oi)if(i.array[i.position]=r,i.position++,i.position===i.size)r=i.array,n.release(i);else continue e;else if(i.type===wr){if(r==="__proto__")throw new pe("The key __proto__ is not allowed");i.key=this.mapKeyConverter(r),i.type=cs;continue e}else if(i.map[i.key]=r,i.readCount++,i.readCount===i.size)r=i.map,n.release(i);else{i.key=null,i.type=wr;continue e}}return r}}readHeadByte(){return this.headByte===yr&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=yr}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new pe(`Unrecognized array type byte: ${dn(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new pe(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new pe(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new pe(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw ls;let n=this.pos+r,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,n,e):i=os(this.bytes,n,e),this.pos+=r+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===wr:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new pe(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw ls;let n=this.pos+r,i=this.bytes.subarray(n,n+e);return this.pos+=r+e,i}decodeExtension(e,r){if(e>this.maxExtLength)throw new pe(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+r),i=this.decodeBinary(e,r+1);return this.extensionCodec.decode(i,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=as(this.view,this.pos);return this.pos+=8,e}readI64(){let e=fn(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function fs(t,e){return new Me(e).decode(t)}function hs(t,e){return new Me(e).decodeMulti(t)}function kc(t){return t[Symbol.asyncIterator]!=null}async function*Rc(t){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}function mn(t){return kc(t)?t:Rc(t)}async function ds(t,e){let r=mn(t);return new Me(e).decodeAsync(r)}function ps(t,e){let r=mn(t);return new Me(e).decodeArrayStream(r)}function ms(t,e){let r=mn(t);return new Me(e).decodeStream(r)}var Fn=Qr(ro(),1),no=Ko,io=rs,ze=Fi,Ea=Fn.DOMParser,Da=Fn.XMLSerializer;var va=ze!==null;function xa(){if(!va)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var Ta=Rh();function Rh(){if(!va)return null;let t=new TextEncoder,e=new TextDecoder,r=new ze.ExtensionCodec;return r.register({type:-1,encode:n=>{if(n instanceof Date){let i=Ve(n);if(i==="D"||i==="H")return null}return ze.encodeTimestampExtension(n)},decode:n=>ze.decodeTimestampExtension(n)}),r.register({type:1,encode:n=>se(n)?t.encode(n.toString()):null,decode:n=>Zt(e.decode(n))}),r.register({type:2,encode:n=>{if(n instanceof Date&&Ve(n)==="D"){let i=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0");return t.encode(`${i}-${o}-${s}`)}return null},decode:n=>new Date(e.decode(n)+"T00:00:00.000Z")}),r.register({type:3,encode:n=>{if(n instanceof Date&&Ve(n)==="H"){let i=String(n.getUTCHours()).padStart(2,"0"),o=String(n.getUTCMinutes()).padStart(2,"0"),s=String(n.getUTCSeconds()).padStart(2,"0"),a=String(n.getUTCMilliseconds()).padStart(3,"0");return t.encode(`${i}:${o}:${s}.${a}`)}return null},decode:n=>{let i=e.decode(n),o=i.indexOf("."),s=o>=0?i.substring(0,o):i,a=o>=0?i.substring(o+1):"0",[l,u,c]=s.split(":"),f=Math.round(+a.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,f))}}),r.register({type:4,encode:n=>{let i=oo(n);if(i!==null){let[o,s]=i;return t.encode(`${o}:${s(n)}`)}return null},decode:n=>{let i=e.decode(n),o=i.indexOf(":"),s=i.slice(0,o),a=i.slice(o+1),l=lt[s];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${s}`}}),r}function Aa(t){return xa(),ze.encode(t,{extensionCodec:Ta})}function Ca(t){return xa(),ze.decode(t,{extensionCodec:Ta})}function Rn(t,e=!1){let r=Ln(t);if(r===null)return[!1,String(t)];let[n,i,o]=r;return o&&!e?[!1,String(t)]:[!0,`${i(t)}::${n}`]}function so(t){if(!t.includes("::"))return[!1,t];let e=t.lastIndexOf("::"),r=t.slice(0,e),n=t.slice(e+2),i=lt[n];if(i===void 0)return[!1,t];let[,o]=i;return[!0,o(r)]}function kn(t,e,r){if(t!==null&&typeof t=="object"&&!Array.isArray(t)){let n={};for(let[i,o]of Object.entries(t))n[i]=kn(o,e,r);return n}return Array.isArray(t)?t.map(n=>kn(n,e,r)):r(t)?e(t):t}function ao(t){let e=Ln(t);if(e!==null){let[r,n,i]=e;return i?[t,!1]:[`${n(t)}::${r}`,!0]}if(Array.isArray(t)){let r=!1;return[t.map(i=>{let[o,s]=ao(i);return s&&(r=!0),o}),r]}if(t!==null&&typeof t=="object"){let r=!1,n={};for(let[i,o]of Object.entries(t)){let[s,a]=ao(o);a&&(r=!0),n[i]=s}return[n,r]}return[t,!1]}function Lh(t,e=!1){let[r,n]=Rn(t,e);if(r)return n;let[i,o]=ao(t),s=JSON.stringify(i);return o?`${s}::JS`:s}function Ph(t){return JSON.stringify(t)}function Uh(t){if(!ze)throw new Error("@msgpack/msgpack is required for MessagePack support");return ze.encode(t)}function _e(t,e=null,{raw:r=!1,qs:n=!1,_forceSuffix:i=!1}={}){if(n)return`${Na(t)}::QS`;if(r){if(e===null||e==="json")return Ph(t);if(e==="msgpack")return Uh(t);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let o=Lh(t,i);return e==="json"?`"${o}"`:o}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${Sa(t)}</tytx_root>`;if(e==="msgpack")return Aa(t);throw new Error(`Unknown transport: ${e}`)}}var Kt,uo;typeof window<"u"&&window.DOMParser?(Kt=window.DOMParser,uo=window.XMLSerializer):(Kt=Ea,uo=Da);function _a(t){if(t===null||typeof t!="object"||Array.isArray(t))return!1;let e=Object.keys(t);if(e.length!==1)return!1;let r=t[e[0]];return r!==null&&typeof r=="object"&&"value"in r}function Ia(t,e,r){let n=t.createElement(e),i=r.attrs||{},o=r.value;for(let[s,a]of Object.entries(i))n.setAttribute(s,_e(a,null,{_forceSuffix:!0}));if(Array.isArray(o))for(let s of o)if(_a(s)){let[a]=Object.keys(s),l=s[a],u=Ia(t,a,l);n.appendChild(u)}else{n.textContent=_e(o);break}else n.textContent=_e(o);return n}function Sa(t){if(!Kt)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(_a(t)){let[e]=Object.keys(t),r=t[e],n=new Kt().parseFromString("<root/>","text/xml"),i=Ia(n,e,r);return new uo().serializeToString(i)}else return _e(t)}function lo(t){let e={};for(let n=0;n<t.attributes.length;n++){let i=t.attributes[n];e[i.name]=te(i.value)}let r=[];for(let n=0;n<t.childNodes.length;n++){let i=t.childNodes[n];i.nodeType===1&&r.push(i)}if(r.length>0)if(r.length===1){let n=r[0],i=lo(n);return{attrs:e,value:{[n.tagName]:i}}}else{let n=[];for(let i of r){let o=lo(i);n.push({[i.tagName]:o})}return{attrs:e,value:n}}return{attrs:e,value:te(t.textContent)}}function Oa(t){if(!Kt)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let n=new Kt().parseFromString(t,"text/xml").documentElement;if(n.tagName==="tytx_root"){let o=null;for(let s=0;s<n.childNodes.length;s++)if(n.childNodes[s].nodeType===1){o=n.childNodes[s];break}if(!o)return te(n.textContent);n=o}let i=lo(n);return{[n.tagName]:i}}function $h(t){return typeof t=="string"}function qh(t){let[e,r]=so(t);if(e)return r;let n=t;n.endsWith("::JS")&&(n=n.slice(0,-4));let i;try{i=JSON.parse(n)}catch{return t}return kn(i,zh,$h)}function zh(t){return t.includes("::")?so(t)[1]:t}function Vh(t){let e=Oa(t);return typeof e=="string"?te(e):e}function jh(t){return Ca(t)}function te(t,e=null){if(t===null)return null;if(e===null||e==="json"){let r=t;return e==="json"&&t.startsWith('"')&&t.endsWith('"')&&(r=t.slice(1,-1)),qh(r)}else{if(e==="xml")return Vh(t);if(e==="msgpack")return jh(t);throw new Error(`Unknown transport: ${e}`)}}function Na(t){if(Array.isArray(t))return t.map(e=>String(e)).join("&");if(t!==null&&typeof t=="object"){let e=[];for(let[r,n]of Object.entries(t)){let[i,o]=Rn(n,!0);i?e.push(`${r}=${o}`):e.push(`${r}=${n}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof t}`)}function Ma(t){if(!t)return[];let e=t.split("&"),r=e.map(s=>s.includes("=")),n=r.every(Boolean),i=!r.some(Boolean);if(!n&&!i)throw new Error("QS format error: mixed items with and without '='");if(i)return e.map(s=>te(s));let o={};for(let s of e){let a=s.indexOf("="),l=s.slice(0,a),u=s.slice(a+1);o[l]=te(u)}return o}var Fa=no||io||Number,Hh=no?"decimal.js":io?"big.js":"number";function Zt(t){return new Fa(t)}function se(t){return Hh==="number"?!1:t instanceof Fa}function Ve(t){let e=t.getUTCFullYear()===1970&&t.getUTCMonth()===0&&t.getUTCDate()===1,r=t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0;return e&&!r?"H":r&&!e?"D":"DHZ"}function Gh(t){return t.toString()}function Wh(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0");return`${e}-${r}-${n}`}function Xh(t){return t.toISOString()}function Yh(t){let e=String(t.getUTCHours()).padStart(2,"0"),r=String(t.getUTCMinutes()).padStart(2,"0"),n=String(t.getUTCSeconds()).padStart(2,"0"),i=String(t.getUTCMilliseconds()).padStart(3,"0");return`${e}:${r}:${n}.${i}`}function Jh(t){return t?"true":"false"}function Zh(t){return t.toString()}function Kh(t){return t.toString()}function Qh(t){let e="";for(let r=0;r<t.length;r+=32768)e+=String.fromCharCode.apply(null,t.subarray(r,r+32768));return btoa(e)}var Pn=[],co=new Map;function oo(t){if(t===null||typeof t!="object")return null;for(let e=Object.getPrototypeOf(t);e!==null;e=Object.getPrototypeOf(e))for(let[r,n,i,o]of Pn)if(r.prototype===e)return[n,i,o];return null}function Ln(t){if(t===null)return["NN",()=>"",!0];if(se(t))return["N",Gh,!1];if(t instanceof Uint8Array)return["RAW",Qh,!1];if(t instanceof Date){let e=Ve(t);return e==="D"?["D",Wh,!1]:e==="H"?["H",Yh,!1]:["DHZ",Xh,!1]}return typeof t=="boolean"?["B",Jh,!0]:typeof t=="number"?Number.isInteger(t)?["L",Zh,!0]:["R",Kh,!0]:oo(t)}function ed(t){return Zt(t)}function td(t){let[e,r,n]=t.split("-").map(Number);return new Date(Date.UTC(e,r-1,n,0,0,0,0))}function Ba(t){return new Date(t)}function rd(t){let[e,r,n]=t.split(":"),[i,o]=n.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(r),Number(i),Number(o||0)))}function nd(t){return t.toLowerCase()==="true"}function id(t){return parseInt(t,10)}function od(t){return parseFloat(t)}function sd(t){return t}function ad(t){return null}var ud=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function ld(t){if(!ud.test(t))throw new Error(`RAW payload is not standard padded base64: '${t}'`);let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function cd(t){return Ma(t)}var fd=/^[A-Z]+$/,lt={N:[Object,ed],D:[Date,td],DH:[Date,Ba],DHZ:[Date,Ba],H:[Date,rd],L:[Number,id],R:[Number,od],T:[String,sd],B:[Boolean,nd],QS:[Object,cd],NN:[null,ad],RAW:[Uint8Array,ld]};function fo(t){return Object.hasOwn(lt,t)?lt[t][0]:null}function ho(t,e,r,n,i=!1){if(typeof e!="string"||!fd.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let o=lt[e];if(o!==void 0&&o[0]!==t){let s=o[0]===null?"null":o[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${s}`)}Pn=Pn.filter(([s])=>s!==t),Pn.push([t,e,r,i]),lt[e]=[t,n]}function po(t,e){co.set(t,e)}function Qt(t){return co.has(t)?co.get(t):{}}function oe(t,e,r,n){let i=null,o=[];for(let s of t.getRows()){let a=t.value(s,e),l=a instanceof Date&&Number.isFinite(a.getTime())?"time":typeof a=="string"||typeof a=="boolean"?"category":typeof a=="number"&&Number.isFinite(a)?"value":null;if(!l||i&&l!==i)throw new TypeError("Choose a column with consistent text, numeric, boolean or date values");i=l;let u=l==="time"?a.getTime():typeof a=="boolean"?String(a):a,c=r.map(f=>t.value(s,f));if(c.some(f=>typeof f!="number"||!Number.isFinite(f)))throw new TypeError("Selected measures require finite numeric values");o.push([u,...c])}return{source:o,kind:i??n?.kind??"category"}}function er(t,e,r,n,i){if(!e||!r||e===r)throw new TypeError("Choose two different dimensions for 3D bars");if(!n)throw new TypeError("Choose a measure for 3D bars");let o=i?i.dimensions.map(l=>l.values.map(u=>l.kind==="time"?new Date(u).toISOString():String(u))):[[],[]],s=o.map(l=>new Map(l.map((u,c)=>[u,c]))),a=[];for(let l of t.getRows()){let u=[e,r].map((f,h)=>{let d=t.value(l,f),g=d instanceof Date&&Number.isFinite(d.getTime())?d.toISOString():["string","boolean"].includes(typeof d)||typeof d=="number"&&Number.isFinite(d)?String(d):null;if(g===null)throw new TypeError("3D dimensions require text, numeric, boolean or date values");return s[h].has(g)||(s[h].set(g,o[h].length),o[h].push(g)),s[h].get(g)}),c=t.value(l,n);if(typeof c!="number"||!Number.isFinite(c))throw new TypeError("Selected measure requires finite numeric values");a.push([...u,c])}return{dimensions:o,source:a}}var X=["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"];function Et(t,e=!1){let r=e?0:1/0,n=e?0:-1/0;for(let i of t)Number.isFinite(i)&&(r=Math.min(r,i),n=Math.max(n,i));if(r===1/0)return[0,1];if(r===n){let i=Math.abs(r)*.05||1;return e&&r===0?[0,1]:[r-i,n+i]}return[r,n]}function Pr(t,e){return e==="time"?new Date(t).toISOString().slice(0,10):String(t)}function Un(t,{category:e,fields:r,settings:n,structure:i,type:o}){let{source:s,kind:a}=oe(t,e,r),l=[...new Set(s.map(E=>E[0]))],u={kind:a,values:l,range:Et(l)},c={};for(let E of["left","right"]){let C=r.map((I,_)=>_).filter(I=>n[I].axis===E),M=[];for(let I of s)if(["stackedBar","stackedArea"].includes(o.id))M.push(C.reduce((_,P)=>_+Math.max(0,I[P+1]),0),C.reduce((_,P)=>_+Math.min(0,I[P+1]),0));else for(let _ of C)M.push(I[_+1]);c[E]=Et(M,!0)}let f=o.syntax.some(E=>E.parameter==="secondCaptionField")?i.getItem("secondCaptionField"):null,h=f?oe(t,f,[]):null,d=[u,...h?[{kind:h.kind,values:[...new Set(h.source.map(E=>E[0]))],range:Et(h.source.map(E=>E[0]))}]:[]],g=o.id==="map"?i.getItem("mapValueField"):null,p=g?i.getItem("geoJSON"):null,y=p?new Set(p.features.map(E=>E.properties.name)):null,m=g?t.getRows().filter(E=>!y||y.has(String(t.value(E,e)))).map(E=>t.value(E,g)):[];if(m.some(E=>typeof E!="number"||!Number.isFinite(E)))throw new TypeError("Selected map measure requires finite numeric values");let w=m.some(E=>E<0),[b,v]=Et(m);w?(v=Math.max(Math.abs(b),Math.abs(v)),b=-v):b=Math.max(0,b);let x=o.id==="mapBar3D"?new Set(i.getItem("geoJSON").features.map(E=>E.properties.name)):null,T=s.filter(E=>!x||x.has(String(E[0]))).flatMap(E=>E.slice(1));return{dimension:u,dimensions:d,axes:c,z:Et(T,o.id!=="mapBar3D"||i.getItem("mapBarScale")!=="extent"),labels:l.map(E=>Pr(E,a)),map:{min:b,max:v,signed:w},count:l.length}}var $n=864e5,qn={minute:6e4,hour:36e5,day:$n,week:7*$n},ka=4*$n;function Ye(t,e){if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError("Temporal snapshots require Date values");if(Object.hasOwn(qn,e))return Math.floor((t.getTime()-(e==="week"?ka:0))/qn[e]);if(e==="month")return t.getUTCFullYear()*12+t.getUTCMonth();if(e==="year")return t.getUTCFullYear();throw new TypeError("Time step must be minute, hour, day, week, month or year")}function mo(t,e){if(Object.hasOwn(qn,e))return new Date(t*qn[e]+(e==="week"?ka:0));let r=new Date(0);if(e==="month")r.setUTCFullYear(Math.floor(t/12),t-Math.floor(t/12)*12,1);else if(e==="year")r.setUTCFullYear(t,0,1);else throw new TypeError("Time step must be minute, hour, day, week, month or year");return r}function Ra(t,e){let r=1/0,n=-1/0,i=!1;for(let u of e?t.getRows():[]){let c=t.value(u,e);c!=null&&(Ye(c,"day"),r=Math.min(r,c.getTime()),n=Math.max(n,c.getTime()),i||=Ve(c)!=="D")}let o=i?["minute","hour","day","week","month","year"]:["day","week","month","year"],s=r===1/0?null:new Date(r),a=r===1/0?null:new Date(n),l=s?o.find(u=>Ye(a,u)-Ye(s,u)<=36)??"year":"day";return{hasClock:i,steps:o,suggested:l,first:s,last:a}}function zn(t,e){let r=t.toISOString();return e==="week"?`${r.slice(0,10)} \u2013 ${new Date(t.getTime()+6*$n).toISOString().slice(0,10)} UTC`:e==="hour"||e==="minute"?`${r.slice(0,16).replace("T"," ")} UTC`:r.slice(0,e==="year"?4:e==="month"?7:10)}var Ur=class{constructor(e){this.view=e,this.field=""}invalidateDomains(){this.domainKey=null}domains(e){if(!this.field||e.type.domains===!1)return null;let r=JSON.stringify([this.field,this.step,e.category,e.fields,e.settings,e.type.id,e.structure.getItem("secondCaptionField"),e.structure.getItem("mapValueField"),e.structure.getItem("mapBarScale")]),n=e.structure.getItem("geoJSON");if(r!==this.domainKey||n!==this.domainGeoJSON){let i=this.view.getRows().filter(o=>this.value(o,this.field)!=null);this.domainValue=Un({getRows:()=>i,value:(o,s)=>this.value(o,s)},e),this.domainKey=r,this.domainGeoJSON=n}return this.domainValue}setPeriod(e,r,n,i="previous"){if(!["previous","empty"].includes(i))throw new TypeError("Empty periods require previous or empty");this.field=e,this.date=r,this.step=n,this.empty=i}get rowMode(){return this.view.rowMode}value(e,r){return this.view.value(e,r)}getRows(){let e=this.view.getRows();if(this.snapshotDate=null,!this.field)return e;if(this.date==null)return[];let r=Ye(this.date,this.step),n=this.empty==="empty"?r:-1/0,i=e.map(s=>{let a=this.value(s,this.field);return{row:s,period:a==null?null:Ye(a,this.step)}});if(this.empty==="previous")for(let s of i)s.period!==null&&s.period<=r&&(n=Math.max(n,s.period));let o=i.filter(s=>s.period===n).map(s=>s.row);return o.length&&(this.snapshotDate=mo(n,this.step)),o}};var G={};Ro(G,{defineCollection:()=>go});fr(G,dg);import*as dg from"@gramlot/gramlot/components";import{defineCollection as dd}from"@gramlot/gramlot/components";function go(t){if(t.name!=="charts")throw new Error("Unexpected bundled collection");let e=[],r={echartsGlLicense:Ce["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:Ce["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:Ce["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:Ce["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:Ce["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]};t.css?.forEach((n,i)=>{n.href=e[i].href});for(let[n,i]of Object.entries(t.assets??{}))i.href=r[n].href;return dd({...t,css:e,assets:r})}function Vn(t,e){return t.parameters=pd(t.constructor.gramlotComponent,e),Object.fromEntries(Object.entries(e).filter(([r])=>!Object.hasOwn(t.parameters,r)))}function pd(t,e){return Object.fromEntries(Object.entries(t.parameters).map(([r,n])=>[r,Object.hasOwn(e,r)?e[r]:n.default]))}function Be(t){return class extends t{constructor(){super();let e=this.attachShadow({mode:"open"}),r=this.ownerDocument.createElement("style");r.textContent=`:host{box-sizing:border-box;display:block;min-width:0;font:inherit;color:var(--gramlot-ink,CanvasText)}
13
13
  *,*::before,*::after{box-sizing:border-box}.control-box{min-width:0}slot{display:contents}
14
- ::slotted(*){min-width:0;max-width:100%}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",this.control=this.controlBox,this.control.id="control",this.control.append(this.ownerDocument.createElement("slot")),e.append(r,this.controlBox)}projectAttributes(e){return On(this,e)}}}je.parameters={};function He(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),t=>t.toString(16).padStart(2,"0")).join("")}var ts=new WeakMap;function ba(t){if(!ts.has(t)){let e=`chart_time_${He()}`;class r{tick(i){let s=i.getAttr("configpath"),o=i.getRelativeData(s);if(!o.getItem("timePlaying")||!o.getItem("timeField"))return;let a=o.getItem("timeIndex")+1,l=o.getItem("timeMax");a<=l&&i.setRelativeData(`${s}.timeIndex`,a),a>=l&&i.setRelativeData(`${s}.timePlaying`,!1)}}t.logicRegistry.register(r,{group:e,resource:"gramlot:charts"}),ts.set(t,`${e}.tick`)}return ts.get(t)}var Da=(0,J.defineComponent)({name:"chartTimeline",tag:"gramlot-chart-timeline",base:je,sourceContext:!0,bagStore:!0,parameters:{storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},timeField:{dtype:"T",binding:"read"},timeStep:{dtype:"T",binding:"read"},timeIndex:{dtype:"R",binding:"read"}},implementation:t=>class extends t{#e;#t;#s;#r;#n=!1;#i=!1;#o;#u;#c;#a;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){this.#t=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#n&&this.#f(),n}connectedCallback(){this.#n=!0,this.#f()}#f(){let e=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);e!==this.#s&&(this.#r?.(),this.#s=e,this.#c=null,this.#r=e.subscribe(()=>{this.#c=null,this.#l()})),this.#l()}#l(){if(!this.#i){this.#i=!0;try{let e=this.#e.sourceNode,r=this.parameters.configpath,n=e.getRelativeData(r),i=(m,g)=>{let y=n.getItem(m);(y instanceof Date&&g instanceof Date?y.getTime()!==g.getTime():y!==g)&&e.setRelativeData(`${r}.${m}`,g)},{timeField:s,timeStep:o}=this.parameters;(!this.#c||s!==this.#a)&&(this.#c=Ea(this.#s,s),this.#a=s);let a=this.#c,l=o==="auto"?a.suggested:o;i("timeHasClock",a.hasClock),i("timeUnit",l);let u=JSON.stringify([s,l]),c=n.getItem("timeIndex"),f=this.#o!==void 0&&u!==this.#o;f&&(c=0,i("timePlaying",!1)),this.#o=u;let h=s&&a.first?{min:ze(a.first,l),max:ze(a.last,l)}:null;!f&&h&&this.#u!==void 0&&h.min!==this.#u&&n.getItem("timeValue")instanceof Date&&(c=ze(n.getItem("timeValue"),l)-h.min),this.#u=h?.min;let d=h?h.max-h.min:0;if(!Number.isInteger(c))throw new TypeError("Time index requires an integer");c=Math.max(0,Math.min(d,c));let p=h?Ki(h.min+c,l):null;i("timeMax",d),i("timeIndex",c),i("timeValue",p),i("timeLabel",p?In(p,l):"No temporal data"),(!h||d===0)&&i("timePlaying",!1)}finally{this.#i=!1}}}disconnectedCallback(){this.#n=!1,this.#r?.(),this.#r=null,this.#s=null;let e=this.parameters.configpath;this.#e.sourceNode.setRelativeData(`${e}.timePlaying`,!1)}}});import{Bag as Ir,fromTytx as Fh,toTytx as Rh}from"@gramlot/gramlot";var _h,rs,Bn=class{static label="Vega";static async load(){rs=await(_h??=import("./modules/vega.module-2QCOVQ3A.js"))}#e;#t;#s;#r=!1;#n=Promise.resolve();#i;#o;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}update(e,r,n=()=>!0){let i=JSON.stringify({...r,data:r.data.map(({values:a,...l})=>l)}),s=async()=>{if(this.#r||!n())return;if(i!==this.#s)this.#t?.finalize(),this.#e.replaceChildren(),this.#t=new rs.View(rs.parse(r),{renderer:"svg",container:this.#e,hover:!0}),this.#s=i;else for(let l of r.data)l.values&&this.#t.data(l.name,l.values);let a=this.#e.getBoundingClientRect();this.#i=Math.max(1,Math.round(a.width)),this.#o=Math.max(1,Math.round(a.height)),await this.#t.width(this.#i).height(this.#o).runAsync(),this.#r&&this.#t.finalize()},o=this.#n.then(s);return this.#n=o.catch(()=>{}),o}render_bar(e){return this.#u(e,!0)}render_line(e){return this.#u(e,!1)}#u({view:e,category:r,fields:n,settings:i,domains:s},o){let{source:a,kind:l}=ne(e,r,n,s?.dimension),u=o&&l!=="time",c=this.#c();c.data=[{name:"rows",values:a.map((f,h)=>({x:f[0],index:h}))},...n.map((f,h)=>({name:`series${h}`,values:a.map(d=>({x:d[0],y:d[h+1],label:l==="time"?new Date(d[0]).toISOString().slice(0,10):String(d[0])}))}))],c.scales=[{name:"x",type:u?"band":l==="time"?"utc":l==="category"?"point":"linear",domain:s?u||l==="category"?s.dimension.values:s.dimension.range:{data:"rows",field:"x"},range:"width",...u?{padding:.2}:{zero:!1,padding:.5}},{name:"color",type:"ordinal",domain:n,range:i.map(f=>f.color)}],c.axes=[{orient:"bottom",scale:"x",labelOverlap:!0,title:r}];for(let f of["left","right"]){let h=n.map((d,p)=>p).filter(d=>i[d].axis===f);h.length&&(c.scales.push({name:f,type:"linear",domain:s?s.axes[f]:{fields:h.map(d=>({data:`series${d}`,field:"y"}))},range:"height",zero:!0,nice:!0}),c.axes.push({orient:f,scale:f,grid:f==="left",title:h.map(d=>n[d]).join(", "),format:"~s"}))}return c.legends=[{fill:"color",orient:"bottom",direction:"horizontal",title:null}],o&&(c.signals=[{name:"groupWidth",update:u?"bandwidth('x')":"min(60, width / max(1, length(data('rows'))) * 0.7)"}]),c.marks=n.flatMap((f,h)=>{let d={scale:i[h].axis,field:"y"};if(o)return{name:`measure${h}`,type:"rect",from:{data:`series${h}`},encode:{update:{x:{signal:`scale('x',datum.x) ${u?"":"- groupWidth / 2"} + groupWidth * ${h} / ${n.length}`},width:{signal:`groupWidth / ${n.length} * 0.9`},y:{signal:`scale('${i[h].axis}',max(0,datum.y))`},y2:{signal:`scale('${i[h].axis}',min(0,datum.y))`},fill:{value:i[h].color},tooltip:{signal:'datum.label + ": " + datum.y'}}}};let p={x:{scale:"x",field:"x"},y:d,tooltip:{signal:'datum.label + ": " + datum.y'}};return[{name:`measure${h}`,type:"line",from:{data:`series${h}`},encode:{update:{...p,stroke:{value:i[h].color},strokeWidth:{value:2}}}},{name:`points${h}`,type:"symbol",from:{data:`series${h}`},encode:{update:{...p,fill:{value:i[h].color},size:{signal:`length(data('series${h}')) === 1 ? 36 : 0`}}}}]}),c}render_pie({view:e,category:r,fields:n,domains:i}){let{source:s,kind:o}=ne(e,r,n,i?.dimension);if(s.some(u=>u[1]<0))throw new TypeError("Pie requires nonnegative values. Configuration retained.");let a=this.#c();a.data=[{name:"slices",values:n.length?s.map((u,c)=>({index:c,label:o==="time"?new Date(u[0]).toISOString().slice(0,10):String(u[0]),value:u[1]})):[],transform:[{type:"pie",field:"value",sort:!1}]}],a.scales=[{name:"color",type:"ordinal",domain:i?i.labels:{data:"slices",field:"label"},range:i?st:{scheme:"tableau10"}}],a.legends=[{fill:"color",orient:"bottom",direction:"horizontal",columns:3,title:null}];let l={x:{signal:"width / 2"},y:{signal:"height / 2"}};return a.marks=[{name:"pieSlices",type:"arc",from:{data:"slices"},encode:{update:{...l,startAngle:{field:"startAngle"},endAngle:{field:"endAngle"},outerRadius:{signal:"min(width,height) * 0.46"},fill:{scale:"color",field:"label"},stroke:{value:"#fff"},tooltip:{signal:'datum.label + ": " + datum.value'}}}},{name:"sliceLabels",type:"text",from:{data:"slices"},encode:{update:{...l,radius:{signal:"min(width,height) * 0.30"},theta:{signal:"(datum.startAngle + datum.endAngle) / 2"},text:{field:"label"},align:{value:"center"},baseline:{value:"middle"},fill:{value:"#222"},limit:{signal:"min(width,height) * 0.25"}}}}],a}#c(){return{background:"#fff",autosize:{type:"fit",contains:"padding",resize:!0},padding:12,data:[],scales:[],axes:[],marks:[],config:{axis:{labelColor:"#333",titleColor:"#333",gridColor:"#eee"},legend:{labelColor:"#333"}}}}resize(){if(this.#r||!this.#t)return;let e=this.#e.getBoundingClientRect(),r=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));if(r===this.#i&&n===this.#o)return;this.#i=r,this.#o=n;let i=async()=>{this.#r||await this.#t.width(this.#i).height(this.#o).resize().runAsync()};this.#n=this.#n.then(i).catch(()=>{})}dispose(){this.#r=!0,this.#t?.finalize()}};var Sh,va,Ta,Mn=class{static label="uPlot";static async load(){await(Sh??=Promise.all([import("./modules/uPlot.esm-5JJNHHRF.js"),import("./modules/uPlot.min-N3E3FA74.js")]).then(([e,r])=>{va=e.default,Ta=r.default}))}#e;#t;#s;#r;#n=!1;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}render_line({view:e,category:r,fields:n,settings:i,domains:s}){let{source:o,kind:a}=ne(e,r,n,s?.dimension);if(o.length&&a==="category")throw new TypeError("uPlot requires a numeric or date X field. Configuration retained.");if(o.some((l,u)=>u>0&&l[0]<=o[u-1][0]))throw new TypeError("uPlot requires distinct X values in ascending order. Prepare the store upstream. Configuration retained.");return{category:r,fields:n,settings:i,domains:s,time:a==="time",data:[o.map(l=>a==="time"?l[0]/1e3:l[0]),...n.map((l,u)=>o.map(c=>c[u+1]))]}}update(e,r,n=()=>!0){if(this.#n||!n())return;let{data:i,...s}=r,o=JSON.stringify(s);if(this.#s||(this.#s=this.#e.ownerDocument.createElement("style"),this.#s.textContent=Ta+`
15
- .uplot{color:#333;background:#fff;font-size:12px}.u-legend{font-size:12px;max-height:90px;overflow:auto}`,this.#e.append(this.#s)),o!==this.#r){this.#t?.destroy();let{category:a,fields:l,settings:u,time:c,domains:f}=r,h=this.#e.getBoundingClientRect(),d={x:{time:c,...f?{range:()=>f.dimension.range.map(m=>c?m/1e3:m)}:{}}},p=[{label:a,stroke:"#333",font:"12px sans-serif"}];for(let m of["left","right"]){let g=l.filter((y,E)=>u[E].axis===m);g.length&&(d[m]={time:!1,...f?{range:()=>f.axes[m]}:{}},p.push({scale:m,side:m==="left"?3:1,label:g.join(", "),stroke:"#333",font:"12px sans-serif",grid:{show:m==="left",stroke:"#e5e7eb"}}))}this.#t=new va({width:Math.max(1,Math.round(h.width)),height:Math.max(1,Math.round(h.height)-50),pxAlign:!1,scales:d,axes:p,series:[{label:a},...l.map((m,g)=>({label:m,stroke:u[g].color,scale:u[g].axis,width:1.5}))]},i,this.#e),this.#r=o}else this.#t.setData(i);this.resize()}resize(){if(this.#n||!this.#t)return;let e=this.#e.getBoundingClientRect(),r=this.#t.root.querySelector(".u-legend"),n=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.floor(e.height-r.getBoundingClientRect().height));(this.#t.width!==n||this.#t.height!==i)&&this.#t.setSize({width:n,height:i})}dispose(){this.#n=!0,this.#t?.destroy(),this.#t=null,this.#s?.remove()}};var Yt=ni(Cu(),1);var xa={id:"bar",label:"Bars",controls:["category","measures"],threeD:!1,measureLimit:null};var Aa={id:"line",label:"Lines",controls:["category","measures"],threeD:!1,measureLimit:null};var Ca={id:"area",label:"Area",controls:["category","measures"],threeD:!1,measureLimit:null};var _a={id:"stackedBar",label:"Stacked bars",controls:["category","measures"],threeD:!1,measureLimit:null};var Sa={id:"stackedArea",label:"Stacked area",controls:["category","measures"],threeD:!1,measureLimit:null};var Na={id:"horizontalBar",label:"Horizontal bars",controls:["category","measures"],threeD:!1,measureLimit:null};var Ia={id:"pie",label:"Pie",controls:["category","measures"],threeD:!1,measureLimit:1};var Oa={id:"donut",label:"Donut",controls:["category","measures"],threeD:!1,measureLimit:1};var Ba={id:"scatter",label:"Scatter",controls:["category","measures"],threeD:!1,measureLimit:null};var Ma={id:"bar3D",label:"3D bars",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var ka={id:"line3D",label:"3D lines",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var Fa={id:"scatter3D",label:"3D scatter",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var Ra={id:"surface",label:"Surface",controls:["category","secondDimension","measures"],threeD:!0,measureLimit:null};var La={id:"map",label:"2D map",controls:["category","geoJSON","mapMeasure"],threeD:!1,measureLimit:null};var Pa={id:"mapBar3D",label:"3D bars on map",controls:["category","geoJSON","mapBarScale","measures"],threeD:!0,measureLimit:null};var Ua={id:"map3D",label:"3D map",controls:["category","geoJSON","measures"],threeD:!0,measureLimit:null};var $a={id:"lines3D",label:"3D paths",controls:["category","geoJSON","geometry","measures"],threeD:!0,measureLimit:null};var qa={id:"polygons3D",label:"3D polygons",controls:["category","geometry","measures"],threeD:!0,measureLimit:null};var kn=[xa,Aa,Ca,_a,Sa,Na,Ia,Oa,Ba,Ma,ka,Fa,Ra,La,Pa,Ua,$a,qa],Nh=new Map(kn.map(t=>[t.id,t]));function Fn(t){let e=Nh.get(t);if(!e)throw new TypeError("Choose a supported chart type");return e}function Pe({view:t,category:e,fields:r,settings:n,domains:i},{seriesType:s,radial:o=!1,horizontal:a=!1,stacked:l=!1,scatter:u=!1,area:c=!1,donut:f=!1}){let{source:h,kind:d}=ne(t,e,r,i?.dimension);if(l&&new Set(n.map(g=>g.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(u&&!["value","time"].includes(d))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(o&&h.some(g=>g[1]<0))throw new TypeError("Pie and donut require nonnegative values.");let p=["left","right"].map((g,y)=>({type:"value",position:a?["bottom","top"][y]:g,show:n.some(E=>E.axis===g),name:r.filter((E,w)=>n[w].axis===g).join(", "),...i?{min:i.axes[g][0],max:i.axes[g][1]}:{},splitLine:{show:y===0}})),m={backgroundColor:"#ffffff",useUTC:!0,legend:{show:!0},tooltip:{trigger:o||u?"item":"axis"},grid:{left:80,right:75,top:65,bottom:65}};if(o)m.legend={show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24},m.series=r.map(g=>({id:g,name:g,type:"pie",top:12,bottom:64,left:12,right:12,label:{alignTo:"edge",edgeDistance:10,overflow:"truncate"},labelLayout:{hideOverlap:!0},radius:f?["35%","65%"]:"65%",data:h.map(y=>({name:d==="time"?new Date(y[0]).toISOString().slice(0,10):String(y[0]),value:y[1],...i?{itemStyle:{color:st[i.labels.indexOf(Cr(y[0],d))%st.length]}}:{}}))}));else{let g=a&&d==="time"?h.map(E=>[new Date(E[0]).toISOString().slice(0,10),...E.slice(1)]):h;m.dataset={source:g,sourceHeader:!1};let y={type:a||d==="value"&&s==="bar"?"category":d};y.type==="value"&&(y.scale=!0),i&&(y.type==="category"?(y.data=i.dimension.values.map(E=>Cr(E,d)),m.dataset.source=h.map(E=>[Cr(E[0],d),...E.slice(1)])):(y.min=i.dimension.range[0],y.max=i.dimension.range[1])),m.xAxis=a?p:y,m.yAxis=a?y:p,m.series=r.map((E,w)=>({id:E,name:E,type:s,...s==="line"?{showSymbol:h.length===1}:{},...a?{xAxisIndex:n[w].axis==="right"?1:0}:{yAxisIndex:n[w].axis==="right"?1:0},...l?{stack:"measures"}:{},...c?{areaStyle:{opacity:.3}}:{},itemStyle:{color:n[w].color},lineStyle:{color:n[w].color},encode:a?{x:w+1,y:0}:{x:0,y:w+1}}))}return m}function Va(t,e,r,n,i,s){let o=n.map(d=>Xt(t,e,r,d,s)),a=o[0]?.dimensions??[[],[]],l=n.length,u=.72,c=l?u/l:0,f=100,h=80;return{backgroundColor:"#ffffff",legend:{show:!0,type:"scroll",left:12,right:12,bottom:10,height:24,data:n},tooltip:{renderMode:"richText",formatter:d=>{let[p,m,g]=d.value;return`${e}: ${a[0][Math.round(p)-1]}
16
- ${r}: ${a[1][m]}
17
- ${d.seriesName}: ${g}`}},xAxis3D:{type:"value",name:e,nameGap:35,min:0,max:Math.max(2,a[0].length+1),interval:1,axisLabel:{formatter:d=>a[0][d-1]??""}},yAxis3D:{type:"category",name:r,nameGap:35,data:a[1]},zAxis3D:{type:"value",name:"Value",nameGap:40,...s?{min:s.z[0],max:s.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:f,boxDepth:h,viewControl:{projection:"perspective"},light:{main:{intensity:1.2},ambient:{intensity:.4}}},series:n.map((d,p)=>({id:d,name:d,type:"bar3D",shading:"lambert",barSize:[f/Math.max(2,a[0].length+1)*c*.85,h/Math.max(1,a[1].length)*.55],data:o[p].source.map(([m,g,y])=>[m+1+(p-(l-1)/2)*c,g,y]),itemStyle:{color:i[p].color}}))}}function za(t,e,r,n,i,s,o){let a=t.getRows(),l=m=>a.every(g=>{let y=t.value(g,m);return typeof y=="number"&&Number.isFinite(y)||y instanceof Date&&Number.isFinite(y.getTime())}),u=[r,n].map((m,g)=>({numeric:o?o.dimensions[g].kind!=="category":l(m),date:o?o.dimensions[g].kind==="time":a.length>0&&t.value(a[0],m)instanceof Date}));if(["scatter3D","surface"].includes(e)&&u.some(m=>!m.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let c=i.map(m=>Xt(t,r,n,m,o)),f=c[0]?.dimensions??[[],[]],h=f.map((m,g)=>m.map((y,E)=>u[g].numeric?u[g].date?Date.parse(y):Number(y):E)),d=m=>({type:u[m].numeric?"value":"category",name:[r,n][m],nameGap:35,...u[m].numeric?o?{min:o.dimensions[m].range[0],max:o.dimensions[m].range[1]}:{}:{data:f[m]},...u[m].date?{axisLabel:{formatter:g=>new Date(g).toISOString().slice(0,10)}}:{}}),p=[];return c.forEach((m,g)=>{let y={name:i[g],type:e,itemStyle:{color:s[g].color},lineStyle:{color:s[g].color,width:3}},E=m.source.map(([w,v,x])=>[h[0][w],h[1][v],x]);if(e==="line3D")f[1].forEach((w,v)=>{let x=m.source.filter(T=>T[1]===v).map(([T,,b])=>[h[0][T],h[1][v],b]).sort((T,b)=>T[0]-b[0]);p.push({...y,id:`${i[g]}:${v}`,data:x})});else if(e==="surface"){let w=[...h[0]].sort((T,b)=>T-b),v=[...h[1]].sort((T,b)=>T-b),x=new Map;for(let[T,b,C]of E){let I=JSON.stringify([T,b]);if(x.has(I))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");x.set(I,C)}if(w.length<2||v.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");p.push({...y,id:i[g],dataShape:[v.length,w.length],shading:"lambert",itemStyle:{color:s[g].color,opacity:i.length>1?.7:1},data:v.flatMap(T=>w.map(b=>[b,T,x.get(JSON.stringify([b,T]))??NaN]))})}else p.push({...y,id:i[g],symbolSize:9,data:E})}),{backgroundColor:"#fff",legend:{type:"scroll",left:12,right:12,bottom:10,data:i},tooltip:{renderMode:"richText"},xAxis3D:d(0),yAxis3D:d(1),zAxis3D:{type:"value",name:"Value",nameGap:40,...o?{min:o.z[0],max:o.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:100,boxDepth:80,viewControl:{projection:"perspective"}},series:p}}function ns(t){return Array.isArray(t)&&t.length>=2&&t.length<=3&&t.every(Number.isFinite)}function Rn(t){return Array.isArray(t)&&t.length>0&&t.every(e=>Array.isArray(e)&&e.length>=4&&e.every(ns)&&JSON.stringify(e[0])===JSON.stringify(e.at(-1)))}function ja(t,e,r){if(!r)throw new TypeError("Choose the coordinate field");let n=new Set;return{type:"FeatureCollection",features:t.getRows().map(s=>{let o=String(t.value(s,e)),a=t.value(s,r);if(n.has(o))throw new TypeError("Polygon names must be unique");if(n.add(o),!Rn(a))throw new TypeError("Polygons require closed coordinate rings, including any holes");return{type:"Feature",properties:{name:o},geometry:{type:"Polygon",coordinates:a}}})}}function Ha(t,e,r,n,i,s,o,a){if(!a||a.type!=="FeatureCollection"||!Array.isArray(a.features))throw new TypeError("Provide a GeoJSON FeatureCollection in configuration.geoJSON");for(let p of a.features)if(p.type!=="Feature"||!["Polygon","MultiPolygon"].includes(p.geometry?.type)||typeof p.properties?.name!="string")throw new TypeError("Map features require Polygon/MultiPolygon geometry and properties.name");let l=t.getRows();if(e!=="map3D"&&!n)throw new TypeError("Choose the coordinate field");let u=e==="map3D"?ne(t,r,i).source:null;if(u&&new Set(u.map(p=>p[0])).size!==u.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let c=e==="lines3D"?l.map(p=>{let m=t.value(p,n);if(!Array.isArray(m)||m.length<2||!m.every(ns))throw new TypeError("Paths require a list of at least two longitude/latitude/altitude coordinates");return m}):[],f=[],h=[],d=[];return i.forEach((p,m)=>{let g={left:`${m*100/i.length}%`,width:`${100/i.length}%`,top:35,bottom:60,height:null};d.push({text:p,left:`${(m+.5)*100/i.length}%`,top:8,textAlign:"center",textStyle:{fontSize:13,color:"#333"}});let y=e==="map3D"?u.map(w=>({name:String(w[0]),value:w[m+1]})):l.map(w=>({name:String(t.value(w,r)),value:t.value(w,p)}));if(y.some(w=>typeof w.value!="number"||!Number.isFinite(w.value)||w.value<0))throw new TypeError("Geographic measures require finite nonnegative values");let E={id:p,name:p,type:e,itemStyle:{color:s[m].color},shading:"lambert"};if(e!=="lines3D")f.push({...E,type:"map3D",...g,map:o,label:{show:!0},data:y.map(w=>({...w,height:w.value})),viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});else{h.push({...g,map:o,regionHeight:0,itemStyle:{color:"#e8edf1",opacity:.5},viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});let w=y.map((v,x)=>({...v,coords:c[x],height:v.value}));f.push({...E,coordinateSystem:"geo3D",geo3DIndex:m,data:w,polyline:!0,silent:!1,lineStyle:{color:s[m].color,width:4,opacity:1}})}}),{backgroundColor:"#fff",title:d,legend:{type:"scroll",data:i,left:12,right:12,bottom:10},tooltip:{renderMode:"richText"},geo3D:h,series:f}}function Ga(t,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(t==="")return[];let r=new Set;return t.split(e).map(n=>{let i=n.indexOf(":"),s=i<0?n:n.slice(0,i),o=i<0?n:n.slice(i+1);if(!s||r.has(s))throw new Error("Invalid or duplicate choice code");return r.add(s),{id:s,caption:o}})}function Ln(t){return class extends t{constructor(){super();let e=this.attachShadow({mode:"open"}),r=this.ownerDocument.createElement("style");r.textContent=`:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
14
+ ::slotted(*){min-width:0;max-width:100%}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",this.control=this.controlBox,this.control.id="control",this.control.append(this.ownerDocument.createElement("slot")),e.append(r,this.controlBox)}projectAttributes(e){return Vn(this,e)}}}Be.parameters={};function Je(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),t=>t.toString(16).padStart(2,"0")).join("")}var yo=new WeakMap;function La(t){if(!yo.has(t)){let e=`chart_time_${Je()}`;class r{tick(i){let o=i.getAttr("configpath"),s=i.getRelativeData(o);if(!s.getItem("timePlaying")||!s.getItem("timeField"))return;let a=s.getItem("timeIndex")+1,l=s.getItem("timeMax");a<=l&&i.setRelativeData(`${o}.timeIndex`,a),a>=l&&i.setRelativeData(`${o}.timePlaying`,!1)}}t.logicRegistry.register(r,{group:e,resource:"gramlot:charts"}),yo.set(t,`${e}.tick`)}return yo.get(t)}var Pa=(0,G.defineComponent)({name:"chartTimeline",tag:"gramlot-chart-timeline",base:Be,sourceContext:!0,bagStore:!0,parameters:{storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},timeField:{dtype:"T",binding:"read"},timeStep:{dtype:"T",binding:"read"},timeIndex:{dtype:"R",binding:"read"}},implementation:t=>class extends t{#e;#t;#n;#r;#o=!1;#i=!1;#s;#l;#c;#a;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){this.#t=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#o&&this.#f(),n}connectedCallback(){this.#o=!0,this.#f()}#f(){let e=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);e!==this.#n&&(this.#r?.(),this.#n=e,this.#c=null,this.#r=e.subscribe(()=>{this.#c=null,this.#u()})),this.#u()}#u(){if(!this.#i){this.#i=!0;try{let e=this.#e.sourceNode,r=this.parameters.configpath,n=e.getRelativeData(r),i=(p,y)=>{let m=n.getItem(p);(m instanceof Date&&y instanceof Date?m.getTime()!==y.getTime():m!==y)&&e.setRelativeData(`${r}.${p}`,y)},{timeField:o,timeStep:s}=this.parameters;(!this.#c||o!==this.#a)&&(this.#c=Ra(this.#n,o),this.#a=o);let a=this.#c,l=s==="auto"?a.suggested:s;i("timeHasClock",a.hasClock),i("timeUnit",l);let u=JSON.stringify([o,l]),c=n.getItem("timeIndex"),f=this.#s!==void 0&&u!==this.#s;f&&(c=0,i("timePlaying",!1)),this.#s=u;let h=o&&a.first?{min:Ye(a.first,l),max:Ye(a.last,l)}:null;!f&&h&&this.#l!==void 0&&h.min!==this.#l&&n.getItem("timeValue")instanceof Date&&(c=Ye(n.getItem("timeValue"),l)-h.min),this.#l=h?.min;let d=h?h.max-h.min:0;if(!Number.isInteger(c))throw new TypeError("Time index requires an integer");c=Math.max(0,Math.min(d,c));let g=h?mo(h.min+c,l):null;i("timeMax",d),i("timeIndex",c),i("timeValue",g),i("timeLabel",g?zn(g,l):"No temporal data"),(!h||d===0)&&i("timePlaying",!1)}finally{this.#i=!1}}}disconnectedCallback(){this.#o=!1,this.#r?.(),this.#r=null,this.#n=null;let e=this.parameters.configpath;this.#e.sourceNode.setRelativeData(`${e}.timePlaying`,!1)}}});import{Bag as or,fromTytx as Ad,toTytx as Cd}from"@gramlot/gramlot";var md,wo,jn=class{static label="Vega";static async load(){wo=await(md??=import("./modules/vega.module-2QCOVQ3A.js"))}#e;#t;#n;#r=!1;#o=Promise.resolve();#i;#s;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}update(e,r,n=()=>!0){let i=JSON.stringify({...r,data:r.data.map(({values:a,...l})=>l)}),o=async()=>{if(this.#r||!n())return;if(i!==this.#n)this.#t?.finalize(),this.#e.replaceChildren(),this.#t=new wo.View(wo.parse(r),{renderer:"svg",container:this.#e,hover:!0}),this.#n=i;else for(let l of r.data)l.values&&this.#t.data(l.name,l.values);let a=this.#e.getBoundingClientRect();this.#i=Math.max(1,Math.round(a.width)),this.#s=Math.max(1,Math.round(a.height)),await this.#t.width(this.#i).height(this.#s).runAsync(),this.#r&&this.#t.finalize()},s=this.#o.then(o);return this.#o=s.catch(()=>{}),s}render_bar(e){return this.#l(e,!0)}render_line(e){return this.#l(e,!1)}#l({view:e,category:r,fields:n,settings:i,domains:o},s){let{source:a,kind:l}=oe(e,r,n,o?.dimension),u=s&&l!=="time",c=this.#c();c.data=[{name:"rows",values:a.map((f,h)=>({x:f[0],index:h}))},...n.map((f,h)=>({name:`series${h}`,values:a.map(d=>({x:d[0],y:d[h+1],label:l==="time"?new Date(d[0]).toISOString().slice(0,10):String(d[0])}))}))],c.scales=[{name:"x",type:u?"band":l==="time"?"utc":l==="category"?"point":"linear",domain:o?u||l==="category"?o.dimension.values:o.dimension.range:{data:"rows",field:"x"},range:"width",...u?{padding:.2}:{zero:!1,padding:.5}},{name:"color",type:"ordinal",domain:n,range:i.map(f=>f.color)}],c.axes=[{orient:"bottom",scale:"x",labelOverlap:!0,title:r}];for(let f of["left","right"]){let h=n.map((d,g)=>g).filter(d=>i[d].axis===f);h.length&&(c.scales.push({name:f,type:"linear",domain:o?o.axes[f]:{fields:h.map(d=>({data:`series${d}`,field:"y"}))},range:"height",zero:!0,nice:!0}),c.axes.push({orient:f,scale:f,grid:f==="left",title:h.map(d=>n[d]).join(", "),format:"~s"}))}return c.legends=[{fill:"color",orient:"bottom",direction:"horizontal",title:null}],s&&(c.signals=[{name:"groupWidth",update:u?"bandwidth('x')":"min(60, width / max(1, length(data('rows'))) * 0.7)"}]),c.marks=n.flatMap((f,h)=>{let d={scale:i[h].axis,field:"y"};if(s)return{name:`measure${h}`,type:"rect",from:{data:`series${h}`},encode:{update:{x:{signal:`scale('x',datum.x) ${u?"":"- groupWidth / 2"} + groupWidth * ${h} / ${n.length}`},width:{signal:`groupWidth / ${n.length} * 0.9`},y:{signal:`scale('${i[h].axis}',max(0,datum.y))`},y2:{signal:`scale('${i[h].axis}',min(0,datum.y))`},fill:{value:i[h].color},tooltip:{signal:'datum.label + ": " + datum.y'}}}};let g={x:{scale:"x",field:"x"},y:d,tooltip:{signal:'datum.label + ": " + datum.y'}};return[{name:`measure${h}`,type:"line",from:{data:`series${h}`},encode:{update:{...g,stroke:{value:i[h].color},strokeWidth:{value:2}}}},{name:`points${h}`,type:"symbol",from:{data:`series${h}`},encode:{update:{...g,fill:{value:i[h].color},size:{signal:`length(data('series${h}')) === 1 ? 36 : 0`}}}}]}),c}render_pie({view:e,category:r,fields:n,domains:i}){let{source:o,kind:s}=oe(e,r,n,i?.dimension);if(o.some(u=>u[1]<0))throw new TypeError("Pie requires nonnegative values. Configuration retained.");let a=this.#c();a.data=[{name:"slices",values:n.length?o.map((u,c)=>({index:c,label:s==="time"?new Date(u[0]).toISOString().slice(0,10):String(u[0]),value:u[1]})):[],transform:[{type:"pie",field:"value",sort:!1}]}],a.scales=[{name:"color",type:"ordinal",domain:i?i.labels:{data:"slices",field:"label"},range:i?X:{scheme:"tableau10"}}],a.legends=[{fill:"color",orient:"bottom",direction:"horizontal",columns:3,title:null}];let l={x:{signal:"width / 2"},y:{signal:"height / 2"}};return a.marks=[{name:"pieSlices",type:"arc",from:{data:"slices"},encode:{update:{...l,startAngle:{field:"startAngle"},endAngle:{field:"endAngle"},outerRadius:{signal:"min(width,height) * 0.46"},fill:{scale:"color",field:"label"},stroke:{value:"#fff"},tooltip:{signal:'datum.label + ": " + datum.value'}}}},{name:"sliceLabels",type:"text",from:{data:"slices"},encode:{update:{...l,radius:{signal:"min(width,height) * 0.30"},theta:{signal:"(datum.startAngle + datum.endAngle) / 2"},text:{field:"label"},align:{value:"center"},baseline:{value:"middle"},fill:{value:"#222"},limit:{signal:"min(width,height) * 0.25"}}}}],a}#c(){return{background:"#fff",autosize:{type:"fit",contains:"padding",resize:!0},padding:12,data:[],scales:[],axes:[],marks:[],config:{axis:{labelColor:"#333",titleColor:"#333",gridColor:"#eee"},legend:{labelColor:"#333"}}}}resize(){if(this.#r||!this.#t)return;let e=this.#e.getBoundingClientRect(),r=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));if(r===this.#i&&n===this.#s)return;this.#i=r,this.#s=n;let i=async()=>{this.#r||await this.#t.width(this.#i).height(this.#s).resize().runAsync()};this.#o=this.#o.then(i).catch(()=>{})}dispose(){this.#r=!0,this.#t?.finalize()}};var gd,Ua,$a,Hn=class{static label="uPlot";static async load(){await(gd??=Promise.all([import("./modules/uPlot.esm-5JJNHHRF.js"),import("./modules/uPlot.min-N3E3FA74.js")]).then(([e,r])=>{Ua=e.default,$a=r.default}))}#e;#t;#n;#r;#o=!1;constructor(e){this.#e=e}validate(e){return this[`render_${e.type.id}`](e)}render_line({view:e,category:r,fields:n,settings:i,domains:o}){let{source:s,kind:a}=oe(e,r,n,o?.dimension);if(s.length&&a==="category")throw new TypeError("uPlot requires a numeric or date X field. Configuration retained.");if(s.some((l,u)=>u>0&&l[0]<=s[u-1][0]))throw new TypeError("uPlot requires distinct X values in ascending order. Prepare the store upstream. Configuration retained.");return{category:r,fields:n,settings:i,domains:o,time:a==="time",data:[s.map(l=>a==="time"?l[0]/1e3:l[0]),...n.map((l,u)=>s.map(c=>c[u+1]))]}}update(e,r,n=()=>!0){if(this.#o||!n())return;let{data:i,...o}=r,s=JSON.stringify(o);if(this.#n||(this.#n=this.#e.ownerDocument.createElement("style"),this.#n.textContent=$a+`
15
+ .uplot{color:#333;background:#fff;font-size:12px}.u-legend{font-size:12px;max-height:90px;overflow:auto}`,this.#e.append(this.#n)),s!==this.#r){this.#t?.destroy();let{category:a,fields:l,settings:u,time:c,domains:f}=r,h=this.#e.getBoundingClientRect(),d={x:{time:c,...f?{range:()=>f.dimension.range.map(p=>c?p/1e3:p)}:{}}},g=[{label:a,stroke:"#333",font:"12px sans-serif"}];for(let p of["left","right"]){let y=l.filter((m,w)=>u[w].axis===p);y.length&&(d[p]={time:!1,...f?{range:()=>f.axes[p]}:{}},g.push({scale:p,side:p==="left"?3:1,label:y.join(", "),stroke:"#333",font:"12px sans-serif",grid:{show:p==="left",stroke:"#e5e7eb"}}))}this.#t=new Ua({width:Math.max(1,Math.round(h.width)),height:Math.max(1,Math.round(h.height)-50),pxAlign:!1,scales:d,axes:g,series:[{label:a},...l.map((p,y)=>({label:p,stroke:u[y].color,scale:u[y].axis,width:1.5}))]},i,this.#e),this.#r=s}else this.#t.setData(i);this.resize()}resize(){if(this.#o||!this.#t)return;let e=this.#e.getBoundingClientRect(),r=this.#t.root.querySelector(".u-legend"),n=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.floor(e.height-r.getBoundingClientRect().height));(this.#t.width!==n||this.#t.height!==i)&&this.#t.setSize({width:n,height:i})}dispose(){this.#o=!0,this.#t?.destroy(),this.#t=null,this.#n?.remove()}};var nr=Qr(Lo(),1);var qa={id:"bar",label:"Bars",controls:[],threeD:!1,doc:"Compares values across categories with vertical bars.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"One bar group per value of this column."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var za={id:"line",label:"Lines",controls:[],threeD:!1,doc:"Shows how values change along an ordered category, such as time.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal axis, in row order or time order."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var Va={id:"area",label:"Area",controls:[],threeD:!1,doc:"Shows how values change along an ordered category, filling the area under each line.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal axis, in row order or time order."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var ja={id:"stackedBar",label:"Stacked bars",controls:[],threeD:!1,doc:"Shows the parts of a total for each category, with the measures stacked in one bar.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"One bar per value of this column."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one segment of the bar."}]};var Ha={id:"stackedArea",label:"Stacked area",controls:[],threeD:!1,doc:"Shows the parts of a total along an ordered category, with the areas stacked.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal axis, in row order or time order."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one stacked layer."}]};var Ga={id:"horizontalBar",label:"Horizontal bars",controls:[],threeD:!1,doc:"Compares values across categories with horizontal bars; suited to long category names.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"One bar group per value of this column, on the vertical axis."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series, drawn with its own colour."}]};var Wa={id:"pie",label:"Pie",controls:[],threeD:!1,doc:"Shows the share of each category in a total.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Slice",doc:"One slice per row, named by this column."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The size of each slice; values must not be negative."}]};var Xa={id:"donut",label:"Donut",controls:[],threeD:!1,doc:"Shows the share of each category in a total, as a ring.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Slice",doc:"One slice per row, named by this column."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The size of each slice; values must not be negative."}]};var Ya={id:"scatter",label:"Scatter",controls:[],threeD:!1,doc:"Shows each row as a point, to reveal relations and clusters.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Category",doc:"The horizontal position of each point."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of points, at its height."}]};var Ja={id:"bar3D",label:"3D bars",controls:[],threeD:!0,doc:"Shows a value for each pair of two dimensions as 3D columns.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis of the grid."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis of the grid; it must differ from the first."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of heights on the grid of the two dimensions."}]};var Za={id:"line3D",label:"3D lines",controls:[],threeD:!0,doc:"Shows values along two dimensions as lines in 3D space.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis; it must differ from the first."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of heights on the grid of the two dimensions."}]};var Ka={id:"scatter3D",label:"3D scatter",controls:[],threeD:!0,doc:"Shows each row as a point in 3D space.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis; numeric or date values."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis; numeric or date values."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one series of points, at its height."}]};var Qa={id:"surface",label:"Surface",controls:[],threeD:!0,doc:"Shows a measured surface over a grid of two numeric dimensions.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"First dimension",doc:"The first axis; numeric or date values, at least two distinct."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Second dimension",doc:"The second axis; numeric or date values, at least two distinct."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one surface; each coordinate pair appears once."}]};var eu={id:"map",label:"2D map",controls:["geoJSON"],threeD:!1,doc:"Colours each territory of a GeoJSON map by one measure.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Territory",doc:"Matched to GeoJSON properties.name; one row per territory."},{name:"mapValueField",parameter:"mapValueField",count:1,required:!0,dtype:"numeric",caption:"Map measure",doc:"The value that colours each territory."},{name:"mapLabelField",parameter:"mapLabelField",count:1,required:!1,dtype:null,caption:"Map label",doc:"Text or number shown on each territory."}]};var tu={id:"mapBar3D",label:"3D bars on map",controls:["geoJSON","mapBarScale"],threeD:!0,doc:"Raises 3D columns on the territories of a GeoJSON map.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Territory",doc:"Matched to GeoJSON properties.name; one row per territory."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one column per territory; values must not be negative."}]};var ru={id:"map3D",label:"3D map",controls:["geoJSON"],threeD:!0,doc:"Draws the territories of a GeoJSON map in 3D, one map per measure.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Territory",doc:"Matched to GeoJSON properties.name."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one map; values must not be negative."}]};var nu={id:"lines3D",label:"3D paths",controls:["geoJSON"],threeD:!0,doc:"Draws paths of coordinates on a 3D map.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Path",doc:"The name of each path."},{name:"geometryField",parameter:"geometryField",count:1,required:!0,dtype:null,caption:"Coordinates",doc:"A list of at least two longitude/latitude/altitude coordinates per row."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one set of paths; values must not be negative."}]};var iu={id:"polygons3D",label:"3D polygons",controls:[],threeD:!0,doc:"Draws polygons of coordinates as 3D shapes.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Polygon",doc:"The unique name of each polygon."},{name:"geometryField",parameter:"geometryField",count:1,required:!0,dtype:null,caption:"Coordinates",doc:"Closed coordinate rings per row, including any holes."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one set of polygons; values must not be negative."}]};var ou={id:"funnel",label:"Funnel",controls:[],threeD:!1,domains:!1,doc:"Shows how a quantity shrinks through ordered stages.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Stage",doc:"One stage per row, in row order."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The quantity at each stage; values must not be negative."}]};var su={id:"radar",label:"Radar",controls:[],threeD:!1,domains:!1,doc:"Compares items on several measures; each measure is an axis, each row a polygon.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Item",doc:"One polygon per row; a row with any empty measure is left out."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one axis of the radar."}]};var au={id:"parallel",label:"Parallel coordinates",controls:[],threeD:!1,domains:!1,doc:"Compares rows on several measures; each measure is a vertical axis, each row a line across them.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Item",doc:"One line per row."},{name:"measures",parameter:"valueFields",count:"many",required:!0,dtype:"numeric",caption:"Measures",doc:"Each measure is one axis."}]};var uu={id:"heatmap",label:"Heatmap",controls:[],threeD:!1,domains:!1,doc:"Colours each cell of a grid of two categories by one measure.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"X category",doc:"The columns of the grid."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Y category",doc:"The rows of the grid; it must differ from the X category."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The colour of each cell; one row per pair of categories."}]};var lu={id:"sankey",label:"Sankey",controls:[],threeD:!1,domains:!1,doc:"Shows flows between nodes; the width of each link is its value.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Source",doc:"The node a link starts from."},{name:"secondCaptionField",parameter:"secondCaptionField",count:1,required:!0,dtype:null,caption:"Target",doc:"The node a link ends at; it must differ from the source column, and links must not form a cycle."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"The width of each link; values must not be negative."}]};var cu={id:"candlestick",label:"Candlestick",controls:[],threeD:!1,domains:!1,doc:"Shows the open, high, low and close of each period, as used for prices.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Period",doc:"One candle per row, in row order."},{name:"open",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Open",doc:"The value at the start of the period."},{name:"high",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"High",doc:"The highest value of the period."},{name:"low",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Low",doc:"The lowest value of the period."},{name:"close",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Close",doc:"The value at the end of the period."}]};var fu={id:"boxplot",label:"Boxplot",controls:[],threeD:!1,domains:!1,doc:"Shows the spread of each group with five statistics: minimum, quartiles, median and maximum.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Group",doc:"One box per row."},{name:"min",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Minimum",doc:"The lowest value."},{name:"q1",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"First quartile",doc:"The value below which a quarter of the data falls."},{name:"median",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Median",doc:"The middle value."},{name:"q3",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Third quartile",doc:"The value below which three quarters of the data fall."},{name:"max",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Maximum",doc:"The highest value."}]};var hu={id:"treemap",label:"Treemap",controls:[],threeD:!1,domains:!1,doc:"Shows a hierarchy as nested rectangles whose area is the value.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Label",doc:"The attribute that names each node of the nested Bag."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"Carried by the leaves; a parent is the sum of its children. Values must not be negative."}]};var du={id:"sunburst",label:"Sunburst",controls:[],threeD:!1,domains:!1,doc:"Shows a hierarchy as rings; the angle of each sector is the value.",syntax:[{name:"captionField",parameter:"captionField",count:1,required:!0,dtype:null,caption:"Label",doc:"The attribute that names each node of the nested Bag."},{name:"measure",parameter:"valueFields",count:1,required:!0,dtype:"numeric",caption:"Measure",doc:"Carried by the leaves; a parent is the sum of its children. Values must not be negative."}]};var ye=[qa,za,Va,ja,Ha,Ga,Wa,Xa,Ya,Ja,Za,Ka,Qa,eu,tu,ru,nu,iu,ou,su,au,uu,lu,cu,fu,hu,du],yd=new Map(ye.map(t=>[t.id,t]));function Gn(t){let e=yd.get(t);if(!e)throw new TypeError("Choose a supported chart type");return e}function ct(t,e){return t.syntax.filter(r=>r.parameter===e)}function tr(t){let e=ct(t,"valueFields");return e.every(r=>r.count===1)?e.map(r=>r.name):[]}function je({view:t,category:e,fields:r,settings:n,domains:i},{seriesType:o,radial:s=!1,horizontal:a=!1,stacked:l=!1,scatter:u=!1,area:c=!1,donut:f=!1}){let{source:h,kind:d}=oe(t,e,r,i?.dimension);if(l&&new Set(n.map(y=>y.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(u&&!["value","time"].includes(d))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(s&&h.some(y=>y[1]<0))throw new TypeError("Pie and donut require nonnegative values.");let g=["left","right"].map((y,m)=>({type:"value",position:a?["bottom","top"][m]:y,show:n.some(w=>w.axis===y),name:r.filter((w,b)=>n[b].axis===y).join(", "),...i?{min:i.axes[y][0],max:i.axes[y][1]}:{},splitLine:{show:m===0}})),p={backgroundColor:"#ffffff",useUTC:!0,legend:{show:!0},tooltip:{trigger:s||u?"item":"axis"},grid:{left:80,right:75,top:65,bottom:65}};if(s)p.legend={show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24},p.series=r.map(y=>({id:y,name:y,type:"pie",top:12,bottom:64,left:12,right:12,label:{alignTo:"edge",edgeDistance:10,overflow:"truncate"},labelLayout:{hideOverlap:!0},radius:f?["35%","65%"]:"65%",data:h.map(m=>({name:d==="time"?new Date(m[0]).toISOString().slice(0,10):String(m[0]),value:m[1],...i?{itemStyle:{color:X[i.labels.indexOf(Pr(m[0],d))%X.length]}}:{}}))}));else{let y=a&&d==="time"?h.map(w=>[new Date(w[0]).toISOString().slice(0,10),...w.slice(1)]):h;p.dataset={source:y,sourceHeader:!1};let m={type:a||d==="value"&&o==="bar"?"category":d};m.type==="value"&&(m.scale=!0),i&&(m.type==="category"?(m.data=i.dimension.values.map(w=>Pr(w,d)),p.dataset.source=h.map(w=>[Pr(w[0],d),...w.slice(1)])):(m.min=i.dimension.range[0],m.max=i.dimension.range[1])),p.xAxis=a?g:m,p.yAxis=a?m:g,p.series=r.map((w,b)=>({id:w,name:w,type:o,...o==="line"?{showSymbol:h.length===1}:{},...a?{xAxisIndex:n[b].axis==="right"?1:0}:{yAxisIndex:n[b].axis==="right"?1:0},...l?{stack:"measures"}:{},...c?{areaStyle:{opacity:.3}}:{},itemStyle:{color:n[b].color},lineStyle:{color:n[b].color},encode:a?{x:b+1,y:0}:{x:0,y:b+1}}))}return p}function pu(t,e,r,n,i,o){let s=n.map(d=>er(t,e,r,d,o)),a=s[0]?.dimensions??[[],[]],l=n.length,u=.72,c=l?u/l:0,f=100,h=80;return{backgroundColor:"#ffffff",legend:{show:!0,type:"scroll",left:12,right:12,bottom:10,height:24,data:n},tooltip:{renderMode:"richText",formatter:d=>{let[g,p,y]=d.value;return`${e}: ${a[0][Math.round(g)-1]}
16
+ ${r}: ${a[1][p]}
17
+ ${d.seriesName}: ${y}`}},xAxis3D:{type:"value",name:e,nameGap:35,min:0,max:Math.max(2,a[0].length+1),interval:1,axisLabel:{formatter:d=>a[0][d-1]??""}},yAxis3D:{type:"category",name:r,nameGap:35,data:a[1]},zAxis3D:{type:"value",name:"Value",nameGap:40,...o?{min:o.z[0],max:o.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:f,boxDepth:h,viewControl:{projection:"perspective"},light:{main:{intensity:1.2},ambient:{intensity:.4}}},series:n.map((d,g)=>({id:d,name:d,type:"bar3D",shading:"lambert",barSize:[f/Math.max(2,a[0].length+1)*c*.85,h/Math.max(1,a[1].length)*.55],data:s[g].source.map(([p,y,m])=>[p+1+(g-(l-1)/2)*c,y,m]),itemStyle:{color:i[g].color}}))}}function mu(t,e,r,n,i,o,s){let a=t.getRows(),l=p=>a.every(y=>{let m=t.value(y,p);return typeof m=="number"&&Number.isFinite(m)||m instanceof Date&&Number.isFinite(m.getTime())}),u=[r,n].map((p,y)=>({numeric:s?s.dimensions[y].kind!=="category":l(p),date:s?s.dimensions[y].kind==="time":a.length>0&&t.value(a[0],p)instanceof Date}));if(["scatter3D","surface"].includes(e)&&u.some(p=>!p.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let c=i.map(p=>er(t,r,n,p,s)),f=c[0]?.dimensions??[[],[]],h=f.map((p,y)=>p.map((m,w)=>u[y].numeric?u[y].date?Date.parse(m):Number(m):w)),d=p=>({type:u[p].numeric?"value":"category",name:[r,n][p],nameGap:35,...u[p].numeric?s?{min:s.dimensions[p].range[0],max:s.dimensions[p].range[1]}:{}:{data:f[p]},...u[p].date?{axisLabel:{formatter:y=>new Date(y).toISOString().slice(0,10)}}:{}}),g=[];return c.forEach((p,y)=>{let m={name:i[y],type:e,itemStyle:{color:o[y].color},lineStyle:{color:o[y].color,width:3}},w=p.source.map(([b,v,x])=>[h[0][b],h[1][v],x]);if(e==="line3D")f[1].forEach((b,v)=>{let x=p.source.filter(T=>T[1]===v).map(([T,,E])=>[h[0][T],h[1][v],E]).sort((T,E)=>T[0]-E[0]);g.push({...m,id:`${i[y]}:${v}`,data:x})});else if(e==="surface"){let b=[...h[0]].sort((T,E)=>T-E),v=[...h[1]].sort((T,E)=>T-E),x=new Map;for(let[T,E,C]of w){let M=JSON.stringify([T,E]);if(x.has(M))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");x.set(M,C)}if(b.length<2||v.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");g.push({...m,id:i[y],dataShape:[v.length,b.length],shading:"lambert",itemStyle:{color:o[y].color,opacity:i.length>1?.7:1},data:v.flatMap(T=>b.map(E=>[E,T,x.get(JSON.stringify([E,T]))??NaN]))})}else g.push({...m,id:i[y],symbolSize:9,data:w})}),{backgroundColor:"#fff",legend:{type:"scroll",left:12,right:12,bottom:10,data:i},tooltip:{renderMode:"richText"},xAxis3D:d(0),yAxis3D:d(1),zAxis3D:{type:"value",name:"Value",nameGap:40,...s?{min:s.z[0],max:s.z[1]}:{}},grid3D:{top:8,bottom:64,height:null,left:16,right:16,width:null,boxWidth:100,boxDepth:80,viewControl:{projection:"perspective"}},series:g}}function bo(t){return Array.isArray(t)&&t.length>=2&&t.length<=3&&t.every(Number.isFinite)}function Wn(t){return Array.isArray(t)&&t.length>0&&t.every(e=>Array.isArray(e)&&e.length>=4&&e.every(bo)&&JSON.stringify(e[0])===JSON.stringify(e.at(-1)))}function gu(t,e,r){if(!r)throw new TypeError("Choose the coordinate field");let n=new Set;return{type:"FeatureCollection",features:t.getRows().map(o=>{let s=String(t.value(o,e)),a=t.value(o,r);if(n.has(s))throw new TypeError("Polygon names must be unique");if(n.add(s),!Wn(a))throw new TypeError("Polygons require closed coordinate rings, including any holes");return{type:"Feature",properties:{name:s},geometry:{type:"Polygon",coordinates:a}}})}}function yu(t,e,r,n,i,o,s,a){if(!a||a.type!=="FeatureCollection"||!Array.isArray(a.features))throw new TypeError("Provide a GeoJSON FeatureCollection in configuration.geoJSON");for(let g of a.features)if(g.type!=="Feature"||!["Polygon","MultiPolygon"].includes(g.geometry?.type)||typeof g.properties?.name!="string")throw new TypeError("Map features require Polygon/MultiPolygon geometry and properties.name");let l=t.getRows();if(e!=="map3D"&&!n)throw new TypeError("Choose the coordinate field");let u=e==="map3D"?oe(t,r,i).source:null;if(u&&new Set(u.map(g=>g[0])).size!==u.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let c=e==="lines3D"?l.map(g=>{let p=t.value(g,n);if(!Array.isArray(p)||p.length<2||!p.every(bo))throw new TypeError("Paths require a list of at least two longitude/latitude/altitude coordinates");return p}):[],f=[],h=[],d=[];return i.forEach((g,p)=>{let y={left:`${p*100/i.length}%`,width:`${100/i.length}%`,top:35,bottom:60,height:null};d.push({text:g,left:`${(p+.5)*100/i.length}%`,top:8,textAlign:"center",textStyle:{fontSize:13,color:"#333"}});let m=e==="map3D"?u.map(b=>({name:String(b[0]),value:b[p+1]})):l.map(b=>({name:String(t.value(b,r)),value:t.value(b,g)}));if(m.some(b=>typeof b.value!="number"||!Number.isFinite(b.value)||b.value<0))throw new TypeError("Geographic measures require finite nonnegative values");let w={id:g,name:g,type:e,itemStyle:{color:o[p].color},shading:"lambert"};if(e!=="lines3D")f.push({...w,type:"map3D",...y,map:s,label:{show:!0},data:m.map(b=>({...b,height:b.value})),viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});else{h.push({...y,map:s,regionHeight:0,itemStyle:{color:"#e8edf1",opacity:.5},viewControl:{projection:"perspective",distance:180,alpha:35,beta:20}});let b=m.map((v,x)=>({...v,coords:c[x],height:v.value}));f.push({...w,coordinateSystem:"geo3D",geo3DIndex:p,data:b,polyline:!0,silent:!1,lineStyle:{color:o[p].color,width:4,opacity:1}})}}),{backgroundColor:"#fff",title:d,legend:{type:"scroll",data:i,left:12,right:12,bottom:10},tooltip:{renderMode:"richText"},geo3D:h,series:f}}function wu(t,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(t==="")return[];let r=new Set;return t.split(e).map(n=>{let i=n.indexOf(":"),o=i<0?n:n.slice(0,i),s=i<0?n:n.slice(i+1);if(!o||r.has(o))throw new Error("Invalid or duplicate choice code");return r.add(o),{id:o,caption:s}})}function Xn(t){return class extends t{constructor(){super();let e=this.attachShadow({mode:"open"}),r=this.ownerDocument.createElement("style");r.textContent=`:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
18
18
  input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
19
19
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
20
20
  appearance:none;box-sizing:border-box;width:100%;border:1px solid var(--gramlot-border-control,#7a8798);
@@ -30,18 +30,33 @@ ${d.seriesName}: ${g}`}},xAxis3D:{type:"value",name:e,nameGap:35,min:0,max:Math.
30
30
  input[type=range],input[type=color],button{min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
31
31
  input[type=checkbox],input[type=radio]{min-width:calc(var(--gramlot-touch-target,0px) / 2);min-height:calc(var(--gramlot-touch-target,0px) / 2)}
32
32
  .options{display:grid;gap:.3em .8em} .option{display:flex;align-items:center;gap:.35em;min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
33
- .caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(r,this.controlBox)}projectAttributes(e){return On(this,e)}setPageContext(e){this.pageContext=e}connectedCallback(){}releaseControl(){}get liveWrites(){return this.control.localName==="textarea"||["text","password","range","color"].includes(this.control.type)}validateCandidate(e,r){return r(e),{ok:!0,value:e,isCurrent:()=>this.pageContext.isActive()}}finishValidation(){}validationValueCheck(){return this.constructor.validationValueCheck(this.pageContext)}static validationValueCheck(){let e=this.gramlotComponent.parameters.value.nullable;return(r,n)=>{if(r==null&&!e)throw new TypeError("This component requires a non-null value.");if(r!=null&&n!=null&&typeof r!=typeof n)throw new TypeError("Validation must preserve the component value type.")}}validationSelection(){return this.constructor.validationSelection(this.parameters,this.pageContext)}static validationSelection(){return()=>{throw new TypeError("validate_select requires a constrained choice editor.")}}validateSelection(e){return this.validationSelection()(e)}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,r=>{this.validationValueCheck()(r,e),this.sameControlValue(e,r)||this.writeControlValue(r)})}restoreFormDraft(e){this.control.value=e}restoreFormValue(e){this.writeControlValue(e)}sameControlValue(e,r){return Object.is(e,r)}focus(e){this.control.focus(e)}}}function Ih(t){return class extends Ln(t){constructor(){super(),this.control=this.createControl(),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.setAttribute("autocomplete","off"),this.control.setAttribute("autocorrect","off"),this.control.setAttribute("autocapitalize","off"),this.control.setAttribute("spellcheck","false")),this.control.id="control";let e=this.ownerDocument.createElement("label");e.className="option",this.optionCaption=this.ownerDocument.createElement("span"),this.optionCaption.className="caption",e.append(this.control,this.optionCaption),this.controlBox.append(e)}projectAttributes(e,r){let n=super.projectAttributes(e,r),{disabled:i,readonly:s}=this.parameters;this.control.disabled=!!i,this.control.readOnly=!!s;for(let[o,a]of Object.entries(this.constructor.gramlotComponent.parameters)){if(a.target==="control"){let l=this.parameters[o]??"";String(this.control[o])!==String(l)&&(this.control[o]=l)}a.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[o]??"")}return n}}}Ih.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function Oh(t){return class extends Ln(t){#e=new Map;#t;#s=null;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="options",this.control.id="control",this.control.setAttribute("role",this.multiple?"group":"radiogroup"),this.controlBox.append(this.control),this.control.addEventListener("keydown",e=>{if(!this.multiple||!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;let r=[...this.control.querySelectorAll("input:not(:disabled)")],n=r.indexOf(e.target);if(n<0)return;e.preventDefault();let i=e.key==="Home"?0:e.key==="End"?r.length-1:Math.max(0,Math.min(r.length-1,n+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));r[i].focus()})}choiceOptions(){return Ga(this.parameters.values??"")}projectAttributes(e,r){let n=super.projectAttributes(e,r),i=this.choiceOptions(),s=JSON.stringify(i);if(s!==this.#t){let a=i,l=new Set,u=null;for(let{id:c,caption:f}of a){let h=this.#e.get(c);if(!h){let p=this.ownerDocument.createElement("label");p.className="option";let m=this.ownerDocument.createElement("input");m.type=this.choiceType,m.name="choice",m.value=c;let g=this.ownerDocument.createElement("span");p.append(m,g),h={label:p,input:m,text:g},this.#e.set(c,h)}h.text.textContent=f;let d=u?u.nextSibling:this.control.firstChild;d!==h.label&&this.control.insertBefore(h.label,d),u=h.label,l.add(c)}for(let[c,f]of this.#e)l.has(c)||(f.label.remove(),this.#e.delete(c));this.#t=s}let o=this.parameters.cols;if(!Number.isInteger(o)||o<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${o}, minmax(0, 1fr))`,this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly;for(let{input:a}of this.#e.values())a.disabled=this.control.disabled||this.control.readOnly;return n}readControlValue(){if(this.multiple){let r=(this.#s?this.#s.split(","):[]).filter(n=>!this.#e.has(n)||this.#e.get(n).input.checked);for(let[n,{input:i}]of this.#e)i.checked&&!r.includes(n)&&r.push(n);return r.join(",")||null}for(let[e,{input:r}]of this.#e)if(r.checked)return e;return null}writeControlValue(e){this.#s=e;let r=this.multiple?new Set(e?e.split(","):[]):null;for(let[n,{input:i}]of this.#e)i.checked=this.multiple?r.has(n):n===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,r=>this.writeControlValue(r))}focus(e){let r=[...this.#e.values()];(r.find(({input:n})=>n.checked&&!n.disabled)??r.find(({input:n})=>!n.disabled))?.input.focus(e)}}}Oh.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Sr(t){if(t?.type!=="FeatureCollection"||!Array.isArray(t.features)||!t.features.length)throw new TypeError("Choose a GeoJSON FeatureCollection containing territories.");let e=new Set;for(let r of t.features){let n=r.properties?.name,i=r.geometry;if(r.type!=="Feature"||typeof n!="string"||!n.trim())throw new TypeError("Every territory needs a nonempty properties.name.");if(e.has(n))throw new TypeError(`Duplicate territory name: ${n}`);if(e.add(n),!i||!["Polygon","MultiPolygon"].includes(i.type))throw new TypeError("Territories must use Polygon or MultiPolygon geometry.");let s=i.type==="Polygon"?[i.coordinates]:i.coordinates;if(!Array.isArray(s)||!s.length||!s.every(Rn))throw new TypeError(`Invalid or unclosed coordinate rings: ${n}`)}return t}var Xa=(0,J.defineComponent)({name:"chartGeoJSON",tag:"gramlot-chart-geo-json",base:Ln,sourceContext:!0,parameters:{value:{dtype:"X",nullable:!0,default:null,binding:"twoWay"}},implementation:t=>class extends t{#e;#t=0;constructor(){super();let e=this.ownerDocument;this.control=e.createElement("input"),this.control.type="file",this.control.accept=".geojson,.json,application/geo+json,application/json",this.control.setAttribute("aria-label","Load GeoJSON"),this.control.style.cssText="width:100%;min-width:0;font:inherit",this.message=e.createElement("div"),this.message.setAttribute("role","status"),this.message.style.cssText="font-size:11px;overflow-wrap:anywhere",this.controlBox.append(this.control,this.message),this.control.addEventListener("change",r=>{r.stopPropagation(),this.#r()})}readControlValue(){return this.parameters.value}writeControlValue(e){this.parameters.value=e,this.#s()}setSourceContext(e){this.#e=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#t++,this.#s(),n}#s(){let e=this.parameters.value;this.message.textContent=e?`${e.features.length} territories${e.features.length<=3?": "+e.features.map(r=>r.properties.name).join(", "):" loaded"}`:"No GeoJSON loaded"}async#r(){let e=this.control.files[0];if(!e)return;let r=++this.#t;try{let n=Sr(JSON.parse(await e.text()));if(r!==this.#t||!this.isConnected)return;this.control.value="",this.#e.writeParameter("value",n)}catch(n){r===this.#t&&this.isConnected&&(this.message.textContent=`GeoJSON not loaded: ${n.message}`)}finally{r===this.#t&&(this.control.value="")}}disconnectedCallback(){this.#t++}}});function Pn(t){let e=r=>Math.abs(r.slice(1).reduce((n,i,s)=>n+r[s][0]*i[1]-i[0]*r[s][1],0));return new Map(t.features.map(r=>{let i=[...r.geometry.type==="Polygon"?[r.geometry.coordinates]:r.geometry.coordinates].sort((u,c)=>e(c[0])-e(u[0]))[0],s=i[0].map(u=>u[1]),o=[...new Set(s)].sort((u,c)=>u-c),a=(o[0]+o.at(-1))/2,l=o.slice(1).map((u,c)=>(o[c]+u)/2).sort((u,c)=>Math.abs(u-a)-Math.abs(c-a));for(let u of l){let c=[];for(let h of i)for(let d=1;d<h.length;d++){let p=h[d-1],m=h[d];p[1]>u!=m[1]>u&&c.push(p[0]+(u-p[1])*(m[0]-p[0])/(m[1]-p[1]))}c.sort((h,d)=>h-d);let f=null;for(let h=0;h+1<c.length;h+=2)c[h+1]>c[h]&&(!f||c[h+1]-c[h]>f[1]-f[0])&&(f=[c[h],c[h+1]]);if(f)return[r.properties.name,[(f[0]+f[1])/2,u]]}throw new TypeError(`Territory has no drawable interior: ${r.properties.name}`)}))}function Ya({view:t,category:e,fields:r,settings:n,structure:i,seriesOptions:s,domains:o},a){let l=Sr(i.getItem("geoJSON")),u=i.getItem("mapBarScale")??"zero";if(!["zero","extent"].includes(u))throw new TypeError("Choose zero or extent for geographic bar heights");let c=Pn(l),{source:f}=ne(t,e,r);if(new Set(f.map(O=>String(O[0]))).size!==f.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let h=f.filter(O=>c.has(String(O[0])));if(f.length&&!h.length)throw new TypeError("No store territories match GeoJSON properties.name");let d=h.flatMap(O=>O.slice(1));if(d.some(O=>!Number.isFinite(O)||O<0))throw new TypeError("Geographic bars require finite nonnegative measures");let p=o?o.z:mt(d,u==="zero"),m=u==="zero"?0:p[0],g=p[1],y=l.features.flatMap(O=>(O.geometry.type==="Polygon"?[O.geometry.coordinates]:O.geometry.coordinates).flatMap(L=>L[0].map($=>$[0]))),[E,w]=y.reduce(([O,L],$)=>[Math.min(O,$),Math.max(L,$)],[1/0,-1/0]),v=w-E,x=.45,T=v/100*x*1.25,b=O=>s.getItem(O).getItem("caption")||O,C=r.map((O,L)=>({id:O,name:b(O),type:"bar3D",coordinateSystem:"geo3D",geo3DIndex:0,barSize:x,shading:"lambert",itemStyle:{color:n[L].color},label:{show:!1},emphasis:{label:{show:!0,formatter:$=>Number($.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}},data:h.map($=>{let[se,V]=c.get(String($[0]));return{name:String($[0]),value:[se+(L-(r.length-1)/2)*T,V,$[L+1]]}})})),I=c.values().next().value;return C.push({id:"map-height-reference",type:"scatter3D",coordinateSystem:"geo3D",geo3DIndex:0,silent:!0,symbolSize:0,itemStyle:{opacity:0},label:{show:!1},tooltip:{show:!1},data:[[...I,m],[...I,g]]}),{backgroundColor:"#fff",legend:{type:"scroll",data:r.map(b),bottom:8},title:{text:u==="zero"?"Geographic bars \xB7 baseline 0":"Geographic bars \xB7 truncated baseline",left:"center",top:8,textStyle:{fontSize:14,color:"#27344b"}},tooltip:{renderMode:"richText",formatter:O=>`${O.name}
34
- ${O.seriesName}: ${Number(O.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}`},geo3D:{map:a,top:35,bottom:45,boxWidth:100,boxHeight:35,regionHeight:.15,itemStyle:{color:"#d9e3eb",borderColor:"#8e9ca9",borderWidth:.3},label:{show:!1},shading:"lambert",viewControl:{projection:"perspective",distance:145,minDistance:30,maxDistance:300,alpha:45,beta:0}},series:C}}function Un(t,e,r="value"){if(!["none","name","value","nameValue"].includes(r))throw new TypeError("Choose a supported map label mode");if(r==="none"||!Number.isFinite(e))return"";let n=e.toLocaleString("en-GB",{notation:"compact",maximumFractionDigits:1});return r==="name"?t:r==="value"?n:`${t}
35
- ${n}`}var $n=["#77bce4","#307eb9","#083e80"];function qn(t,e,r,n,i){if(Sr(i),!r)throw new TypeError("Choose a map measure");let{source:s}=ne(t,e,[r]);if(new Set(s.map(d=>String(d[0]))).size!==s.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let o=new Map;for(let d of t.getRows()){let p=String(t.value(d,e)),m=t.value(d,n);if(typeof m!="string"&&typeof m!="number")throw new TypeError("Choose a text or numeric map label field");if(o.has(p)&&o.get(p)!==String(m))throw new TypeError("Map labels must be consistent for each territory");o.set(p,String(m))}let a=new Set(i.features.map(d=>d.properties.name)),l=s.filter(d=>a.has(String(d[0]))).map(([d,p])=>({name:String(d),value:p}));if(s.length&&!l.length)throw new TypeError("No store territories match GeoJSON properties.name");let u=l.map(d=>d.value),c=u.some(d=>d<0),f=u.length?Math.min(...u):0,h=u.length?Math.max(...u):1;if(c)h=Math.max(Math.abs(f),Math.abs(h)),f=-h;else if(f===h){let d=Math.abs(h)*.01||1;f=Math.max(0,f-d),h+=d}return{data:l,labels:o,min:f,max:h,signed:c}}function Wa(t,e,r,n,i,s,o,a,l="value"){let{data:u,labels:c,...f}=qn(t,e,r,n,s),{min:h,max:d,signed:p}=a?a.map:f,m=y=>Number(y).toLocaleString("en-GB",{maximumFractionDigits:2}),g=o||r;return{backgroundColor:"#fff",title:{text:g,left:"center",top:8,textStyle:{color:"#27344b",fontSize:14}},tooltip:{trigger:"item",renderMode:"richText",formatter:y=>`${c.get(y.name)||y.name}
36
- ${g}: ${Number.isFinite(y.value)?m(y.value):"No data"}`},visualMap:{type:"continuous",min:h,max:d,seriesIndex:0,dimension:0,calculable:!0,orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:180,precision:2,formatter:m,textStyle:{color:"#27344b"},inRange:{color:p?["#b73548","#f7f7f7","#2166ac"]:$n},outOfRange:{color:"#e2e5e9"}},series:[{name:g,type:"map",map:i,preserveAspect:"contain",aspectScale:1,roam:!0,top:42,bottom:70,left:20,right:20,itemStyle:{areaColor:"#e2e5e9",borderColor:"#fff",borderWidth:.45},label:{show:!0,color:"#182c46",fontSize:11,textBorderColor:"#fff",textBorderWidth:3,formatter:y=>Un(c.get(y.name)||y.name,y.value,l)},labelLayout:{hideOverlap:!0},emphasis:{label:{show:!0},itemStyle:{borderColor:"#1b273d",borderWidth:2}},data:u}]}}var Bh,Vn=class{static label="ECharts";static async load(e){Fn(e).threeD&&await(Bh??=import("./modules/echarts-gl-CXVTZA6G.js"))}#e;#t;#s;#r;#n;#i=`chart_${He()}`;#o;constructor(e,r={}){this.#s=e,this.#r=r,this.#n=r.renderer??"canvas",this.#e=Yt.init(e,null,r),this.#u()}#u(){this.#e.on("click",e=>{this.#t==="mapBar3D"&&e.seriesType==="bar3D"&&this.#r.onTerritorySelect?.(e.name),this.#t==="map"&&e.componentType==="series"&&e.seriesType==="map"&&this.#r.onTerritorySelect?.(e.name)})}validate(e){return this[`render_${e.type.id}`](e)}update(e,r){this.#t=e.type.id;let n=e.type.threeD?"canvas":this.#r.renderer??"canvas";n!==this.#n&&(this.#e.dispose(),this.#e=Yt.init(this.#s,null,{...this.#r,renderer:n}),this.#n=n,this.#u()),this.#e.setOption(r,{notMerge:!0})}render_bar(e){return Pe(e,{seriesType:"bar"})}render_line(e){return Pe(e,{seriesType:"line"})}render_area(e){return Pe(e,{seriesType:"line",area:!0})}render_stackedBar(e){return Pe(e,{seriesType:"bar",stacked:!0})}render_stackedArea(e){return Pe(e,{seriesType:"line",area:!0,stacked:!0})}render_horizontalBar(e){return Pe(e,{seriesType:"bar",horizontal:!0})}render_pie(e){return Pe(e,{seriesType:"pie",radial:!0})}render_donut(e){return Pe(e,{seriesType:"pie",radial:!0,donut:!0})}render_scatter(e){return Pe(e,{seriesType:"scatter",scatter:!0})}render_bar3D({view:e,category:r,structure:n,fields:i,settings:s,domains:o}){return Va(e,r,n.getItem("secondCaptionField"),i,s,o)}render_line3D(e){return this.#c(e,"line3D")}render_scatter3D(e){return this.#c(e,"scatter3D")}render_surface(e){return this.#c(e,"surface")}#c({view:e,category:r,structure:n,fields:i,settings:s,domains:o},a){return za(e,a,r,n.getItem("secondCaptionField"),i,s,o)}#a(e){return e!==this.#o&&(Yt.registerMap(this.#i,e),this.#o=e),this.#i}render_map({view:e,category:r,structure:n,seriesOptions:i,domains:s}){let o=n.getItem("mapValueField"),a=n.getItem("geoJSON"),l=Wa(e,r,o,n.getItem("mapLabelField"),this.#i,a,i.getItem(o)?.getItem("caption"),s,n.getItem("mapLabelMode")??"value");return this.#a(a),l}render_mapBar3D(e){let r=e.structure.getItem("geoJSON"),n=Ya(e,this.#i);return this.#a(r),n}render_map3D(e){return this.#f(e,"map3D",e.structure.getItem("geoJSON"))}render_lines3D(e){return this.#f(e,"lines3D",e.structure.getItem("geoJSON"))}render_polygons3D(e){return this.#f(e,"polygons3D",ja(e.view,e.category,e.structure.getItem("geometryField")))}#f({view:e,category:r,structure:n,fields:i,settings:s},o,a){let l=Ha(e,o,r,n.getItem("geometryField"),i,s,this.#i,a);return this.#a(a),l}svg(){return this.#e.renderToSVGString()}resize(){this.#e.resize()}dispose(){this.#e.dispose(),this.#o&&Yt.registerMap(this.#i,{type:"FeatureCollection",features:[]})}};function zn({view:t,category:e,structure:r,fields:n,settings:i,domains:s},o,a){let l=r.getItem("secondCaptionField"),u=t.getRows(),c=[e,l].map((g,y)=>({field:g,numeric:s?s.dimensions[y].kind!=="category":u.every(E=>{let w=t.value(E,g);return typeof w=="number"&&Number.isFinite(w)||w instanceof Date&&Number.isFinite(w.getTime())}),date:s?s.dimensions[y].kind==="time":u.length>0&&t.value(u[0],g)instanceof Date}));if(o!=="line3D"&&c.some(g=>!g.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let f=n.map(g=>Xt(t,e,l,g,s)),h=f[0]?.dimensions??[[],[]],d=h.map((g,y)=>g.map((E,w)=>c[y].numeric?c[y].date?Date.parse(E):Number(E):w)),p=g=>({title:{text:c[g].field},type:c[g].date?"date":"linear",...c[g].numeric?s?{range:s.dimensions[g].range,autorange:!1}:{}:{tickvals:d[g],ticktext:h[g],...s?{range:[-.5,h[g].length-.5],autorange:!1}:{}}});a.scene={xaxis:p(0),yaxis:p(1),zaxis:{title:{text:"Value"},...s?{range:s.z,autorange:!1}:{}},aspectmode:"cube"};let m=[];return f.forEach((g,y)=>{let E=i[y].color,w={name:n[y],legendgroup:n[y],showlegend:!0},v=g.source.map(([x,T,b])=>[d[0][x],d[1][T],b]);if(o==="surface"){let x=[...d[0]].sort((C,I)=>C-I),T=[...d[1]].sort((C,I)=>C-I),b=new Map;for(let[C,I,O]of v){let L=JSON.stringify([C,I]);if(b.has(L))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");b.set(L,O)}if(x.length<2||T.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");m.push({...w,type:"surface",x,y:T,z:T.map(C=>x.map(I=>b.get(JSON.stringify([I,C]))??null)),connectgaps:!1,colorscale:[[0,E],[1,E]],showscale:!1,opacity:n.length>1?.7:1})}else o==="line3D"?h[1].forEach((x,T)=>{let b=g.source.filter(C=>C[1]===T).map(([C,,I])=>[d[0][C],d[1][T],I]).sort((C,I)=>C[0]-I[0]);m.push({...w,showlegend:T===0,type:"scatter3d",mode:b.length===1?"lines+markers":"lines",x:b.map(C=>C[0]),y:b.map(C=>C[1]),z:b.map(C=>C[2]),line:{color:E,width:4},marker:{color:E,size:4}})}):m.push({...w,type:"scatter3d",mode:"markers",x:v.map(x=>x[0]),y:v.map(x=>x[1]),z:v.map(x=>x[2]),marker:{color:E,size:4}})}),{data:m,layout:a}}function Ja({view:t,category:e,structure:r,seriesOptions:n,domains:i},s){let o=r.getItem("mapValueField"),a=r.getItem("geoJSON"),{data:l,labels:u,...c}=qn(t,e,o,r.getItem("mapLabelField"),a),{min:f,max:h,signed:d}=i?i.map:c,p=b=>b.map((C,I)=>{let O=C.slice(1).reduce((L,$,se)=>L+C[se][0]*$[1]-$[0]*C[se][1],0);return(I===0?O>0:O<0)?[...C].reverse():C}),m={...a,features:a.features.map(b=>({...b,geometry:{...b.geometry,coordinates:b.geometry.type==="Polygon"?p(b.geometry.coordinates):b.geometry.coordinates.map(p)}}))},g=n.getItem(o)?.getItem("caption")||o;s.title={text:g},s.showlegend=!1,s.margin={l:10,r:70,t:45,b:20},s.geo={visible:!1,showframe:!1,showcoastlines:!1,showland:!1,showocean:!1,showcountries:!1,showlakes:!1,showrivers:!1,fitbounds:"geojson",projection:{type:"mercator"},bgcolor:"#fff"};let y=d?["#b73548","#f7f7f7","#2166ac"]:$n,E={type:"choropleth",geojson:m,featureidkey:"properties.name",locations:l.map(b=>b.name),z:l.map(b=>b.value),zmin:f,zmax:h,colorscale:y.map((b,C)=>[C/2,b]),marker:{line:{color:"#fff",width:.45}},colorbar:{title:{text:g},thickness:14},hovertemplate:"%{location}<br>%{z:.2f}<extra></extra>"},w=Pn(a),v=l.map(b=>({name:b.name,value:b.value,point:w.get(b.name)})),x=a.features.map(b=>b.properties.name).filter(b=>!l.some(C=>C.name===b)),T={type:"choropleth",geojson:m,featureidkey:"properties.name",locations:x,z:x.map(()=>0),colorscale:[[0,"#e2e5e9"],[1,"#e2e5e9"]],showscale:!1,marker:{line:{color:"#fff",width:.45}},hovertemplate:"%{location}<br>No data<extra></extra>"};return{layout:s,data:[T,E,{type:"scattergeo",mode:"text",showlegend:!1,hoverinfo:"skip",lon:v.map(b=>b.point[0]),lat:v.map(b=>b.point[1]),text:v.map(b=>Un(u.get(b.name)||b.name,b.value,r.getItem("mapLabelMode")??"value")),textfont:{color:"#182c46",size:11}}]}}var Mh,Nr,jn=class{static label="Plotly";static async load(){Nr=await(Mh??=import("./modules/plotly.min-4LB7HE7P.js").then(e=>e.default))}#e;#t;#s;#r=!1;#n;#i=!1;#o=Promise.resolve();#u=!1;constructor(e,r={}){this.#e=e,this.#t=r}validate(e){return this[`render_${e.type.id}`](e)}update(e,r,n=()=>!0){let i=async()=>{if(this.#i||!n())return;this.#n||(this.#n=this.#e.ownerDocument.createElement("style"),this.#n.textContent=`.js-plotly-plot,.js-plotly-plot div{margin:0;padding:0;border:0}
33
+ .caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(r,this.controlBox)}projectAttributes(e){return Vn(this,e)}setPageContext(e){this.pageContext=e}connectedCallback(){}releaseControl(){}get liveWrites(){return this.control.localName==="textarea"||["text","password","range","color"].includes(this.control.type)}validateCandidate(e,r){return r(e),{ok:!0,value:e,isCurrent:()=>this.pageContext.isActive()}}finishValidation(){}validationValueCheck(){return this.constructor.validationValueCheck(this.pageContext)}static validationValueCheck(){let e=this.gramlotComponent.parameters.value.nullable;return(r,n)=>{if(r==null&&!e)throw new TypeError("This component requires a non-null value.");if(r!=null&&n!=null&&typeof r!=typeof n)throw new TypeError("Validation must preserve the component value type.")}}validationSelection(){return this.constructor.validationSelection(this.parameters,this.pageContext)}static validationSelection(){return()=>{throw new TypeError("validate_select requires a constrained choice editor.")}}validateSelection(e){return this.validationSelection()(e)}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,r=>{this.validationValueCheck()(r,e),this.sameControlValue(e,r)||this.writeControlValue(r)})}restoreFormDraft(e){this.control.value=e}restoreFormValue(e){this.writeControlValue(e)}sameControlValue(e,r){return Object.is(e,r)}focus(e){this.control.focus(e)}}}function wd(t){return class extends Xn(t){constructor(){super(),this.control=this.createControl(),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.setAttribute("autocomplete","off"),this.control.setAttribute("autocorrect","off"),this.control.setAttribute("autocapitalize","off"),this.control.setAttribute("spellcheck","false")),this.control.id="control";let e=this.ownerDocument.createElement("label");e.className="option",this.optionCaption=this.ownerDocument.createElement("span"),this.optionCaption.className="caption",e.append(this.control,this.optionCaption),this.controlBox.append(e)}projectAttributes(e,r){let n=super.projectAttributes(e,r),{disabled:i,readonly:o}=this.parameters;this.control.disabled=!!i,this.control.readOnly=!!o;for(let[s,a]of Object.entries(this.constructor.gramlotComponent.parameters)){if(a.target==="control"){let l=this.parameters[s]??"";String(this.control[s])!==String(l)&&(this.control[s]=l)}a.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[s]??"")}return n}}}wd.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function bd(t){return class extends Xn(t){#e=new Map;#t;#n=null;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="options",this.control.id="control",this.control.setAttribute("role",this.multiple?"group":"radiogroup"),this.controlBox.append(this.control),this.control.addEventListener("keydown",e=>{if(!this.multiple||!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;let r=[...this.control.querySelectorAll("input:not(:disabled)")],n=r.indexOf(e.target);if(n<0)return;e.preventDefault();let i=e.key==="Home"?0:e.key==="End"?r.length-1:Math.max(0,Math.min(r.length-1,n+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));r[i].focus()})}choiceOptions(){return wu(this.parameters.values??"")}projectAttributes(e,r){let n=super.projectAttributes(e,r),i=this.choiceOptions(),o=JSON.stringify(i);if(o!==this.#t){let a=i,l=new Set,u=null;for(let{id:c,caption:f}of a){let h=this.#e.get(c);if(!h){let g=this.ownerDocument.createElement("label");g.className="option";let p=this.ownerDocument.createElement("input");p.type=this.choiceType,p.name="choice",p.value=c;let y=this.ownerDocument.createElement("span");g.append(p,y),h={label:g,input:p,text:y},this.#e.set(c,h)}h.text.textContent=f;let d=u?u.nextSibling:this.control.firstChild;d!==h.label&&this.control.insertBefore(h.label,d),u=h.label,l.add(c)}for(let[c,f]of this.#e)l.has(c)||(f.label.remove(),this.#e.delete(c));this.#t=o}let s=this.parameters.cols;if(!Number.isInteger(s)||s<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${s}, minmax(0, 1fr))`,this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly;for(let{input:a}of this.#e.values())a.disabled=this.control.disabled||this.control.readOnly;return n}readControlValue(){if(this.multiple){let r=(this.#n?this.#n.split(","):[]).filter(n=>!this.#e.has(n)||this.#e.get(n).input.checked);for(let[n,{input:i}]of this.#e)i.checked&&!r.includes(n)&&r.push(n);return r.join(",")||null}for(let[e,{input:r}]of this.#e)if(r.checked)return e;return null}writeControlValue(e){this.#n=e;let r=this.multiple?new Set(e?e.split(","):[]):null;for(let[n,{input:i}]of this.#e)i.checked=this.multiple?r.has(n):n===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,r=>this.writeControlValue(r))}focus(e){let r=[...this.#e.values()];(r.find(({input:n})=>n.checked&&!n.disabled)??r.find(({input:n})=>!n.disabled))?.input.focus(e)}}}bd.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function $r(t){if(t?.type!=="FeatureCollection"||!Array.isArray(t.features)||!t.features.length)throw new TypeError("Choose a GeoJSON FeatureCollection containing territories.");let e=new Set;for(let r of t.features){let n=r.properties?.name,i=r.geometry;if(r.type!=="Feature"||typeof n!="string"||!n.trim())throw new TypeError("Every territory needs a nonempty properties.name.");if(e.has(n))throw new TypeError(`Duplicate territory name: ${n}`);if(e.add(n),!i||!["Polygon","MultiPolygon"].includes(i.type))throw new TypeError("Territories must use Polygon or MultiPolygon geometry.");let o=i.type==="Polygon"?[i.coordinates]:i.coordinates;if(!Array.isArray(o)||!o.length||!o.every(Wn))throw new TypeError(`Invalid or unclosed coordinate rings: ${n}`)}return t}var bu=(0,G.defineComponent)({name:"chartGeoJSON",tag:"gramlot-chart-geo-json",base:Xn,sourceContext:!0,parameters:{value:{dtype:"X",nullable:!0,default:null,binding:"twoWay"}},implementation:t=>class extends t{#e;#t=0;constructor(){super();let e=this.ownerDocument;this.control=e.createElement("input"),this.control.type="file",this.control.accept=".geojson,.json,application/geo+json,application/json",this.control.setAttribute("aria-label","Load GeoJSON"),this.control.style.cssText="width:100%;min-width:0;font:inherit",this.message=e.createElement("div"),this.message.setAttribute("role","status"),this.message.style.cssText="font-size:11px;overflow-wrap:anywhere",this.controlBox.append(this.control,this.message),this.control.addEventListener("change",r=>{r.stopPropagation(),this.#r()})}readControlValue(){return this.parameters.value}writeControlValue(e){this.parameters.value=e,this.#n()}setSourceContext(e){this.#e=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#t++,this.#n(),n}#n(){let e=this.parameters.value;this.message.textContent=e?`${e.features.length} territories${e.features.length<=3?": "+e.features.map(r=>r.properties.name).join(", "):" loaded"}`:"No GeoJSON loaded"}async#r(){let e=this.control.files[0];if(!e)return;let r=++this.#t;try{let n=$r(JSON.parse(await e.text()));if(r!==this.#t||!this.isConnected)return;this.control.value="",this.#e.writeParameter("value",n)}catch(n){r===this.#t&&this.isConnected&&(this.message.textContent=`GeoJSON not loaded: ${n.message}`)}finally{r===this.#t&&(this.control.value="")}}disconnectedCallback(){this.#t++}}});function Yn(t){let e=r=>Math.abs(r.slice(1).reduce((n,i,o)=>n+r[o][0]*i[1]-i[0]*r[o][1],0));return new Map(t.features.map(r=>{let i=[...r.geometry.type==="Polygon"?[r.geometry.coordinates]:r.geometry.coordinates].sort((u,c)=>e(c[0])-e(u[0]))[0],o=i[0].map(u=>u[1]),s=[...new Set(o)].sort((u,c)=>u-c),a=(s[0]+s.at(-1))/2,l=s.slice(1).map((u,c)=>(s[c]+u)/2).sort((u,c)=>Math.abs(u-a)-Math.abs(c-a));for(let u of l){let c=[];for(let h of i)for(let d=1;d<h.length;d++){let g=h[d-1],p=h[d];g[1]>u!=p[1]>u&&c.push(g[0]+(u-g[1])*(p[0]-g[0])/(p[1]-g[1]))}c.sort((h,d)=>h-d);let f=null;for(let h=0;h+1<c.length;h+=2)c[h+1]>c[h]&&(!f||c[h+1]-c[h]>f[1]-f[0])&&(f=[c[h],c[h+1]]);if(f)return[r.properties.name,[(f[0]+f[1])/2,u]]}throw new TypeError(`Territory has no drawable interior: ${r.properties.name}`)}))}function Eu({view:t,category:e,fields:r,settings:n,structure:i,seriesOptions:o,domains:s},a){let l=$r(i.getItem("geoJSON")),u=i.getItem("mapBarScale")??"zero";if(!["zero","extent"].includes(u))throw new TypeError("Choose zero or extent for geographic bar heights");let c=Yn(l),{source:f}=oe(t,e,r);if(new Set(f.map(I=>String(I[0]))).size!==f.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let h=f.filter(I=>c.has(String(I[0])));if(f.length&&!h.length)throw new TypeError("No store territories match GeoJSON properties.name");let d=h.flatMap(I=>I.slice(1));if(d.some(I=>!Number.isFinite(I)||I<0))throw new TypeError("Geographic bars require finite nonnegative measures");let g=s?s.z:Et(d,u==="zero"),p=u==="zero"?0:g[0],y=g[1],m=l.features.flatMap(I=>(I.geometry.type==="Polygon"?[I.geometry.coordinates]:I.geometry.coordinates).flatMap(_=>_[0].map(P=>P[0]))),[w,b]=m.reduce(([I,_],P)=>[Math.min(I,P),Math.max(_,P)],[1/0,-1/0]),v=b-w,x=.45,T=v/100*x*1.25,E=I=>o.getItem(I).getItem("caption")||I,C=r.map((I,_)=>({id:I,name:E(I),type:"bar3D",coordinateSystem:"geo3D",geo3DIndex:0,barSize:x,shading:"lambert",itemStyle:{color:n[_].color},label:{show:!1},emphasis:{label:{show:!0,formatter:P=>Number(P.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}},data:h.map(P=>{let[K,z]=c.get(String(P[0]));return{name:String(P[0]),value:[K+(_-(r.length-1)/2)*T,z,P[_+1]]}})})),M=c.values().next().value;return C.push({id:"map-height-reference",type:"scatter3D",coordinateSystem:"geo3D",geo3DIndex:0,silent:!0,symbolSize:0,itemStyle:{opacity:0},label:{show:!1},tooltip:{show:!1},data:[[...M,p],[...M,y]]}),{backgroundColor:"#fff",legend:{type:"scroll",data:r.map(E),bottom:8},title:{text:u==="zero"?"Geographic bars \xB7 baseline 0":"Geographic bars \xB7 truncated baseline",left:"center",top:8,textStyle:{fontSize:14,color:"#27344b"}},tooltip:{renderMode:"richText",formatter:I=>`${I.name}
34
+ ${I.seriesName}: ${Number(I.value[2]).toLocaleString("en-GB",{maximumFractionDigits:2})}`},geo3D:{map:a,top:35,bottom:45,boxWidth:100,boxHeight:35,regionHeight:.15,itemStyle:{color:"#d9e3eb",borderColor:"#8e9ca9",borderWidth:.3},label:{show:!1},shading:"lambert",viewControl:{projection:"perspective",distance:145,minDistance:30,maxDistance:300,alpha:45,beta:0}},series:C}}function Jn(t,e,r="value"){if(!["none","name","value","nameValue"].includes(r))throw new TypeError("Choose a supported map label mode");if(r==="none"||!Number.isFinite(e))return"";let n=e.toLocaleString("en-GB",{notation:"compact",maximumFractionDigits:1});return r==="name"?t:r==="value"?n:`${t}
35
+ ${n}`}var Zn=["#77bce4","#307eb9","#083e80"];function Kn(t,e,r,n,i){if($r(i),!r)throw new TypeError("Choose a map measure");let{source:o}=oe(t,e,[r]);if(new Set(o.map(d=>String(d[0]))).size!==o.length)throw new TypeError("Provide one prepared row per territory; aggregate the store upstream");let s=new Map;for(let d of t.getRows()){let g=String(t.value(d,e)),p=t.value(d,n);if(typeof p!="string"&&typeof p!="number")throw new TypeError("Choose a text or numeric map label field");if(s.has(g)&&s.get(g)!==String(p))throw new TypeError("Map labels must be consistent for each territory");s.set(g,String(p))}let a=new Set(i.features.map(d=>d.properties.name)),l=o.filter(d=>a.has(String(d[0]))).map(([d,g])=>({name:String(d),value:g}));if(o.length&&!l.length)throw new TypeError("No store territories match GeoJSON properties.name");let u=l.map(d=>d.value),c=u.some(d=>d<0),f=u.length?Math.min(...u):0,h=u.length?Math.max(...u):1;if(c)h=Math.max(Math.abs(f),Math.abs(h)),f=-h;else if(f===h){let d=Math.abs(h)*.01||1;f=Math.max(0,f-d),h+=d}return{data:l,labels:s,min:f,max:h,signed:c}}function Du(t,e,r,n,i,o,s,a,l="value"){let{data:u,labels:c,...f}=Kn(t,e,r,n,o),{min:h,max:d,signed:g}=a?a.map:f,p=m=>Number(m).toLocaleString("en-GB",{maximumFractionDigits:2}),y=s||r;return{backgroundColor:"#fff",title:{text:y,left:"center",top:8,textStyle:{color:"#27344b",fontSize:14}},tooltip:{trigger:"item",renderMode:"richText",formatter:m=>`${c.get(m.name)||m.name}
36
+ ${y}: ${Number.isFinite(m.value)?p(m.value):"No data"}`},visualMap:{type:"continuous",min:h,max:d,seriesIndex:0,dimension:0,calculable:!0,orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:180,precision:2,formatter:p,textStyle:{color:"#27344b"},inRange:{color:g?["#b73548","#f7f7f7","#2166ac"]:Zn},outOfRange:{color:"#e2e5e9"}},series:[{name:y,type:"map",map:i,preserveAspect:"contain",aspectScale:1,roam:!0,top:42,bottom:70,left:20,right:20,itemStyle:{areaColor:"#e2e5e9",borderColor:"#fff",borderWidth:.45},label:{show:!0,color:"#182c46",fontSize:11,textBorderColor:"#fff",textBorderWidth:3,formatter:m=>Jn(c.get(m.name)||m.name,m.value,l)},labelLayout:{hideOverlap:!0},emphasis:{label:{show:!0},itemStyle:{borderColor:"#1b273d",borderWidth:2}},data:u}]}}import{Bag as Ed}from"@gramlot/gramlot";function we(t,e,r){let n=t.value(e,r);if(n==null)return null;if(typeof n!="number"||!Number.isFinite(n))throw new TypeError(`Measure ${r} requires finite numeric values or empty cells`);return n}function fe(t,e){if(t instanceof Date&&Number.isFinite(t.getTime()))return t.toISOString().slice(0,10);if(["string","number","boolean"].includes(typeof t)&&!(typeof t=="number"&&!Number.isFinite(t)))return String(t);throw new TypeError(`Choose a ${e} column with text, numeric, boolean or date values`)}function ae(t,e){let r=t?.getItem(e)?.getItem("caption");return typeof r=="string"&&r?r:e}function rr(t,e,r){let n=t?.getItem(e)?.getItem(r);return typeof n=="number"&&Number.isFinite(n)?n:null}function Eo(t,e,r){let n=t?.getItem(e)?.getItem(r);return typeof n=="string"&&n?n:null}function Qn({view:t,category:e,fields:r},n,i){if(t.rowMode!=="attributes")throw new TypeError(`${n} needs rowMode='attributes': each node carries the caption and the measure as attributes.`);let[o]=r,s={value:(u,c)=>u.getAttr(c)},a=(u,c,f)=>u.flatMap(h=>{let d=fe(c.value(h,e),e),g=h.staticValue;if(g instanceof Ed){if(h.getAttr(o)!=null)throw new TypeError(`Node ${d} has children and carries ${o}: the value of a parent is the sum of its children. Remove the attribute from ${d}.`);let y=a(g.getNodes(),s,f);return y.length?[{name:d,value:y.reduce((m,w)=>m+w.value,0),children:y,itemStyle:{color:f}}]:[]}let p=we(c,h,o);if(p===null)return[];if(p<0)throw new TypeError(`Node ${d} has a negative ${o}: areas cannot be negative.`);return[{name:d,value:p,itemStyle:{color:f}}]});return t.getRows().flatMap((u,c)=>a([u],t,i[c%i.length]))}function vu({view:t,category:e,fields:r,seriesOptions:n}){let[i]=r,o=[];for(let s of t.getRows()){let a=we(t,s,i);if(a===null)continue;if(a<0)throw new TypeError("Funnel requires nonnegative values.");let l=fe(t.value(s,e),e);o.push({name:l,value:a,itemStyle:{color:X[o.length%X.length]}})}return{backgroundColor:"#ffffff",tooltip:{trigger:"item",formatter:"{b}: {c}"},legend:{show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24,data:o.map(s=>s.name)},series:[{id:i,name:ae(n,i),type:"funnel",top:20,bottom:64,left:"10%",width:"80%",sort:"none",gap:2,label:{show:!0,position:"inside"},data:o}]}}function xu({view:t,category:e,fields:r,seriesOptions:n}){let i=[];for(let s of t.getRows()){let a=r.map(l=>we(t,s,l));a.some(l=>l===null)||i.push({name:fe(t.value(s,e),e),values:a})}let o=r.map((s,a)=>{let l=i.map(f=>f.values[a]).filter(f=>f!==null),u=rr(n,s,"min")??Math.min(0,...l),c=rr(n,s,"max")??(l.length?Math.max(...l):1);return c<=u&&(c=u+1),{name:ae(n,s),min:u,max:c}});return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},legend:{show:!0,type:"scroll",orient:"horizontal",left:12,right:12,bottom:10,height:24,data:i.map(s=>s.name)},radar:{indicator:o,center:["50%","48%"],radius:"62%"},series:[{type:"radar",areaStyle:{opacity:.15},data:i.map((s,a)=>({name:s.name,value:s.values,itemStyle:{color:X[a%X.length]},lineStyle:{color:X[a%X.length]}}))}]}}function Tu({view:t,category:e,fields:r,seriesOptions:n}){let i=[];for(let s of t.getRows()){let a=r.map(l=>we(t,s,l));a.every(l=>l===null)||i.push({name:fe(t.value(s,e),e),values:a})}let o=r.map((s,a)=>{let l={dim:a,name:ae(n,s)},u=rr(n,s,"min"),c=rr(n,s,"max");return u!==null&&(l.min=u),c!==null&&(l.max=c),l});return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},parallel:{left:60,right:60,top:60,bottom:40,parallelAxisDefault:{type:"value",nameLocation:"start",nameGap:20}},parallelAxis:o,series:[{type:"parallel",lineStyle:{width:2,opacity:.7},emphasis:{lineStyle:{width:4,opacity:1}},data:i.map((s,a)=>({name:s.name,value:s.values,lineStyle:{color:X[a%X.length]}}))}]}}function Au({view:t,category:e,structure:r,fields:n,settings:i,seriesOptions:o}){let s=r.getItem("secondCaptionField"),[a]=n,l=[],u=[],c=new Map,f=new Map,h=new Set,d=[],g=(w,b,v)=>(b.has(v)||(b.set(v,w.length),w.push(v)),b.get(v));for(let w of t.getRows()){let b=g(l,c,fe(t.value(w,e),e)),v=g(u,f,fe(t.value(w,s),s)),x=we(t,w,a);if(x===null)continue;let T=`${b}:${v}`;if(h.has(T))throw new TypeError(`Heatmap has two cells for ${l[b]} / ${u[v]}. Prepare one row per pair upstream.`);h.add(T),d.push([b,v,x])}let p=d.length?Math.min(...d.map(w=>w[2])):0,y=d.length?Math.max(...d.map(w=>w[2])):1;p===y&&(p-=1,y+=1);let m=ae(o,a);return{backgroundColor:"#ffffff",tooltip:{trigger:"item",position:"top"},grid:{left:80,right:40,top:36,bottom:110},xAxis:{type:"category",data:l,name:e,splitArea:{show:!0}},yAxis:{type:"category",data:u,name:s,splitArea:{show:!0}},visualMap:{type:"continuous",min:p,max:y,calculable:!0,orient:"horizontal",left:"center",bottom:10,inRange:{color:["#f3f6fb",i[0].color]}},series:[{id:a,name:m,type:"heatmap",data:d,emphasis:{itemStyle:{borderColor:"#333",borderWidth:1}}}]}}function Dd(t){let e=new Map;for(let{source:o,target:s}of t)e.has(o)||e.set(o,[]),e.get(o).push(s);let r=new Map,n=[],i=o=>{r.set(o,1),n.push(o);for(let s of e.get(o)??[]){if(r.get(s)===1)return[...n.slice(n.indexOf(s)),s];if(!r.has(s)){let a=i(s);if(a)return a}}return n.pop(),r.set(o,2),null};for(let o of e.keys())if(!r.has(o)){let s=i(o);if(s)return s}return null}function Cu({view:t,category:e,structure:r,fields:n,seriesOptions:i}){let o=r.getItem("secondCaptionField"),[s]=n,a=new Set,l=[];for(let c of t.getRows()){let f=fe(t.value(c,e),e),h=fe(t.value(c,o),o),d=we(t,c,s);if(d!==null){if(d<0)throw new TypeError("Sankey requires nonnegative link values.");a.add(f),a.add(h),l.push({source:f,target:h,value:d})}}let u=Dd(l);if(u)throw new TypeError(`Sankey links contain a cycle: ${u.join(" \u2192 ")}. Remove or reverse one link.`);return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},series:[{id:s,name:ae(i,s),type:"sankey",left:20,right:120,top:20,bottom:20,emphasis:{focus:"adjacency"},lineStyle:{color:"gradient",curveness:.5},data:[...a].map(c=>({name:c})),links:l}]}}function Su({view:t,category:e,fields:r,seriesOptions:n}){let[i,o,s,a]=r,l=[],u=[];for(let d of t.getRows()){let g=r.map(p=>we(t,d,p));g.some(p=>p===null)||(l.push(fe(t.value(d,e),e)),u.push([g[0],g[3],g[2],g[1]]))}let c=Eo(n,i,"upColor"),f=Eo(n,i,"downColor"),h={};return c&&(h.color=c,h.borderColor=c),f&&(h.color0=f,h.borderColor0=f),{backgroundColor:"#ffffff",tooltip:{trigger:"axis",axisPointer:{type:"cross"}},grid:{left:60,right:30,top:30,bottom:70},xAxis:{type:"category",data:l,name:e,boundaryGap:!0},yAxis:{type:"value",scale:!0},dataZoom:[{type:"inside"}],series:[{id:i,name:ae(n,i),type:"candlestick",data:u,itemStyle:h}]}}function Nu({view:t,category:e,fields:r,seriesOptions:n}){let i=[],o=[];for(let s of t.getRows()){let a=r.map(u=>we(t,s,u));if(a.some(u=>u===null))continue;let l=fe(t.value(s,e),e);if(a.some((u,c)=>c>0&&u<a[c-1]))throw new TypeError(`Boxplot row ${l} must satisfy min <= q1 <= median <= q3 <= max.`);i.push(l),o.push(a)}return{backgroundColor:"#ffffff",tooltip:{trigger:"item"},grid:{left:60,right:30,top:30,bottom:50},xAxis:{type:"category",data:i,name:e,boundaryGap:!0},yAxis:{type:"value",scale:!0},series:[{id:r[0],name:ae(n,r[0]),type:"boxplot",data:o}]}}function _u(t){let e=Qn(t,"Treemap",X),[r]=t.fields;return{backgroundColor:"#ffffff",tooltip:{trigger:"item",formatter:"{b}: {c}"},series:[{id:r,name:ae(t.seriesOptions,r),type:"treemap",left:10,right:10,top:10,bottom:30,roam:!1,nodeClick:"zoomToNode",breadcrumb:{show:!0,bottom:4},label:{show:!0,formatter:"{b}"},itemStyle:{borderColor:"#ffffff",borderWidth:1,gapWidth:1},levels:[{itemStyle:{borderWidth:0,gapWidth:6},upperLabel:{show:!0,height:24,color:"#333333",fontWeight:"bold"}},{itemStyle:{borderWidth:0,gapWidth:3},upperLabel:{show:!0,height:20,color:"#555555"}},{itemStyle:{gapWidth:1}}],data:e}]}}function Iu(t){let e=Qn(t,"Sunburst",X),[r]=t.fields;return{backgroundColor:"#ffffff",tooltip:{trigger:"item",formatter:"{b}: {c}"},series:[{id:r,name:ae(t.seriesOptions,r),type:"sunburst",radius:[0,"92%"],center:["50%","50%"],sort:null,nodeClick:"rootToNode",label:{rotate:"radial",minAngle:8},itemStyle:{borderColor:"#ffffff",borderWidth:1},data:e}]}}var vd,ei=class{static label="ECharts";static async load(e){Gn(e).threeD&&await(vd??=import("./modules/echarts-gl-CXVTZA6G.js"))}#e;#t;#n;#r;#o;#i=`chart_${Je()}`;#s;constructor(e,r={}){this.#n=e,this.#r=r,this.#o=r.renderer??"canvas",this.#e=nr.init(e,null,r),this.#l()}#l(){this.#e.on("click",e=>{this.#t==="mapBar3D"&&e.seriesType==="bar3D"&&this.#r.onTerritorySelect?.(e.name),this.#t==="map"&&e.componentType==="series"&&e.seriesType==="map"&&this.#r.onTerritorySelect?.(e.name)})}validate(e){return this[`render_${e.type.id}`](e)}update(e,r){this.#t=e.type.id;let n=e.type.threeD?"canvas":this.#r.renderer??"canvas";n!==this.#o&&(this.#e.dispose(),this.#e=nr.init(this.#n,null,{...this.#r,renderer:n}),this.#o=n,this.#l()),this.#e.setOption(r,{notMerge:!0})}render_bar(e){return je(e,{seriesType:"bar"})}render_line(e){return je(e,{seriesType:"line"})}render_area(e){return je(e,{seriesType:"line",area:!0})}render_stackedBar(e){return je(e,{seriesType:"bar",stacked:!0})}render_stackedArea(e){return je(e,{seriesType:"line",area:!0,stacked:!0})}render_horizontalBar(e){return je(e,{seriesType:"bar",horizontal:!0})}render_pie(e){return je(e,{seriesType:"pie",radial:!0})}render_donut(e){return je(e,{seriesType:"pie",radial:!0,donut:!0})}render_scatter(e){return je(e,{seriesType:"scatter",scatter:!0})}render_bar3D({view:e,category:r,structure:n,fields:i,settings:o,domains:s}){return pu(e,r,n.getItem("secondCaptionField"),i,o,s)}render_line3D(e){return this.#c(e,"line3D")}render_scatter3D(e){return this.#c(e,"scatter3D")}render_surface(e){return this.#c(e,"surface")}#c({view:e,category:r,structure:n,fields:i,settings:o,domains:s},a){return mu(e,a,r,n.getItem("secondCaptionField"),i,o,s)}#a(e){return e!==this.#s&&(nr.registerMap(this.#i,e),this.#s=e),this.#i}render_map({view:e,category:r,structure:n,seriesOptions:i,domains:o}){let s=n.getItem("mapValueField"),a=n.getItem("geoJSON"),l=Du(e,r,s,n.getItem("mapLabelField"),this.#i,a,i.getItem(s)?.getItem("caption"),o,n.getItem("mapLabelMode")??"value");return this.#a(a),l}render_mapBar3D(e){let r=e.structure.getItem("geoJSON"),n=Eu(e,this.#i);return this.#a(r),n}render_map3D(e){return this.#f(e,"map3D",e.structure.getItem("geoJSON"))}render_lines3D(e){return this.#f(e,"lines3D",e.structure.getItem("geoJSON"))}render_polygons3D(e){return this.#f(e,"polygons3D",gu(e.view,e.category,e.structure.getItem("geometryField")))}#f({view:e,category:r,structure:n,fields:i,settings:o},s,a){let l=yu(e,s,r,n.getItem("geometryField"),i,o,this.#i,a);return this.#a(a),l}render_funnel(e){return vu(e)}render_radar(e){return xu(e)}render_parallel(e){return Tu(e)}render_heatmap(e){return Au(e)}render_sankey(e){return Cu(e)}render_candlestick(e){return Su(e)}render_boxplot(e){return Nu(e)}render_treemap(e){return _u(e)}render_sunburst(e){return Iu(e)}svg(){return this.#e.renderToSVGString()}resize(){this.#e.resize()}dispose(){this.#e.dispose(),this.#s&&nr.registerMap(this.#i,{type:"FeatureCollection",features:[]})}};function ti({view:t,category:e,structure:r,fields:n,settings:i,domains:o},s,a){let l=r.getItem("secondCaptionField"),u=t.getRows(),c=[e,l].map((y,m)=>({field:y,numeric:o?o.dimensions[m].kind!=="category":u.every(w=>{let b=t.value(w,y);return typeof b=="number"&&Number.isFinite(b)||b instanceof Date&&Number.isFinite(b.getTime())}),date:o?o.dimensions[m].kind==="time":u.length>0&&t.value(u[0],y)instanceof Date}));if(s!=="line3D"&&c.some(y=>!y.numeric))throw new TypeError("Choose numeric or date fields for both dimensions");let f=n.map(y=>er(t,e,l,y,o)),h=f[0]?.dimensions??[[],[]],d=h.map((y,m)=>y.map((w,b)=>c[m].numeric?c[m].date?Date.parse(w):Number(w):b)),g=y=>({title:{text:c[y].field},type:c[y].date?"date":"linear",...c[y].numeric?o?{range:o.dimensions[y].range,autorange:!1}:{}:{tickvals:d[y],ticktext:h[y],...o?{range:[-.5,h[y].length-.5],autorange:!1}:{}}});a.scene={xaxis:g(0),yaxis:g(1),zaxis:{title:{text:"Value"},...o?{range:o.z,autorange:!1}:{}},aspectmode:"cube"};let p=[];return f.forEach((y,m)=>{let w=i[m].color,b={name:n[m],legendgroup:n[m],showlegend:!0},v=y.source.map(([x,T,E])=>[d[0][x],d[1][T],E]);if(s==="surface"){let x=[...d[0]].sort((C,M)=>C-M),T=[...d[1]].sort((C,M)=>C-M),E=new Map;for(let[C,M,I]of v){let _=JSON.stringify([C,M]);if(E.has(_))throw new TypeError("Surface has repeated coordinates: prepare unique coordinate pairs upstream");E.set(_,I)}if(x.length<2||T.length<2)throw new TypeError("A surface needs at least two distinct values on each dimension");p.push({...b,type:"surface",x,y:T,z:T.map(C=>x.map(M=>E.get(JSON.stringify([M,C]))??null)),connectgaps:!1,colorscale:[[0,w],[1,w]],showscale:!1,opacity:n.length>1?.7:1})}else s==="line3D"?h[1].forEach((x,T)=>{let E=y.source.filter(C=>C[1]===T).map(([C,,M])=>[d[0][C],d[1][T],M]).sort((C,M)=>C[0]-M[0]);p.push({...b,showlegend:T===0,type:"scatter3d",mode:E.length===1?"lines+markers":"lines",x:E.map(C=>C[0]),y:E.map(C=>C[1]),z:E.map(C=>C[2]),line:{color:w,width:4},marker:{color:w,size:4}})}):p.push({...b,type:"scatter3d",mode:"markers",x:v.map(x=>x[0]),y:v.map(x=>x[1]),z:v.map(x=>x[2]),marker:{color:w,size:4}})}),{data:p,layout:a}}function Ou({view:t,category:e,structure:r,seriesOptions:n,domains:i},o){let s=r.getItem("mapValueField"),a=r.getItem("geoJSON"),{data:l,labels:u,...c}=Kn(t,e,s,r.getItem("mapLabelField"),a),{min:f,max:h,signed:d}=i?i.map:c,g=E=>E.map((C,M)=>{let I=C.slice(1).reduce((_,P,K)=>_+C[K][0]*P[1]-P[0]*C[K][1],0);return(M===0?I>0:I<0)?[...C].reverse():C}),p={...a,features:a.features.map(E=>({...E,geometry:{...E.geometry,coordinates:E.geometry.type==="Polygon"?g(E.geometry.coordinates):E.geometry.coordinates.map(g)}}))},y=n.getItem(s)?.getItem("caption")||s;o.title={text:y},o.showlegend=!1,o.margin={l:10,r:70,t:45,b:20},o.geo={visible:!1,showframe:!1,showcoastlines:!1,showland:!1,showocean:!1,showcountries:!1,showlakes:!1,showrivers:!1,fitbounds:"geojson",projection:{type:"mercator"},bgcolor:"#fff"};let m=d?["#b73548","#f7f7f7","#2166ac"]:Zn,w={type:"choropleth",geojson:p,featureidkey:"properties.name",locations:l.map(E=>E.name),z:l.map(E=>E.value),zmin:f,zmax:h,colorscale:m.map((E,C)=>[C/2,E]),marker:{line:{color:"#fff",width:.45}},colorbar:{title:{text:y},thickness:14},hovertemplate:"%{location}<br>%{z:.2f}<extra></extra>"},b=Yn(a),v=l.map(E=>({name:E.name,value:E.value,point:b.get(E.name)})),x=a.features.map(E=>E.properties.name).filter(E=>!l.some(C=>C.name===E)),T={type:"choropleth",geojson:p,featureidkey:"properties.name",locations:x,z:x.map(()=>0),colorscale:[[0,"#e2e5e9"],[1,"#e2e5e9"]],showscale:!1,marker:{line:{color:"#fff",width:.45}},hovertemplate:"%{location}<br>No data<extra></extra>"};return{layout:o,data:[T,w,{type:"scattergeo",mode:"text",showlegend:!1,hoverinfo:"skip",lon:v.map(E=>E.point[0]),lat:v.map(E=>E.point[1]),text:v.map(E=>Jn(u.get(E.name)||E.name,E.value,r.getItem("mapLabelMode")??"value")),textfont:{color:"#182c46",size:11}}]}}var xd,qr,ri=class{static label="Plotly";static async load(){qr=await(xd??=import("./modules/plotly.min-4LB7HE7P.js").then(e=>e.default))}#e;#t;#n;#r=!1;#o;#i=!1;#s=Promise.resolve();#l=!1;constructor(e,r={}){this.#e=e,this.#t=r}validate(e){return this[`render_${e.type.id}`](e)}update(e,r,n=()=>!0){let i=async()=>{if(this.#i||!n())return;this.#o||(this.#o=this.#e.ownerDocument.createElement("style"),this.#o.textContent=`.js-plotly-plot,.js-plotly-plot div{margin:0;padding:0;border:0}
37
37
  .js-plotly-plot .main-svg{position:absolute;top:0;left:0;pointer-events:none}
38
38
  .js-plotly-plot .main-svg .draglayer{pointer-events:all}
39
39
  .js-plotly-plot .user-select-none{user-select:none;-webkit-user-select:none}
40
- .js-plotly-plot .crisp{shape-rendering:crispEdges}`,this.#e.parentElement.append(this.#n));let o=this.#e.getBoundingClientRect();await Nr.react(this.#e,r.data,{...r.layout,width:Math.max(1,o.width),height:Math.max(1,o.height)},{displayModeBar:!1,responsive:!1,displaylogo:!1,scrollZoom:e.type.id==="map"}),this.#i?Nr.purge(this.#e):(this.#u=!0,this.#s=e.type.id,this.#r||(this.#e.on("plotly_click",a=>{let l=a.points[0];this.#s==="map"&&l?.data.type==="choropleth"&&this.#t.onTerritorySelect?.(l.location)}),this.#e.on("plotly_afterplot",()=>this.#c()),this.#r=!0),this.#c())},s=this.#o.then(i);return this.#o=s.catch(()=>{}),s}#c(){if(this.#s!=="map"||this.#i)return;let e=[],r=this.#e.getBoundingClientRect();for(let n of this.#e.querySelectorAll(".scattergeo text")){n.style.visibility="visible",n.style.pointerEvents="none";let i=n.getBoundingClientRect(),s=e.some(a=>i.left<a.right+4&&i.right>a.left-4&&i.top<a.bottom+2&&i.bottom>a.top-2),o=i.left<r.left||i.right>r.right||i.top<r.top||i.bottom>r.bottom;s||o?n.style.visibility="hidden":n.textContent&&e.push(i)}}render_bar(e){return this.#a(e,{type:"bar"})}render_line(e){return this.#a(e,{type:"scatter"})}render_area(e){return this.#a(e,{type:"scatter",area:!0})}render_stackedBar(e){return this.#a(e,{type:"bar",stacked:!0})}render_stackedArea(e){return this.#a(e,{type:"scatter",area:!0,stacked:!0})}render_horizontalBar(e){return this.#a(e,{type:"bar",horizontal:!0})}render_pie(e){return this.#f(e,!1)}render_donut(e){return this.#f(e,!0)}render_scatter(e){return this.#a(e,{type:"scatter",points:!0})}render_line3D(e){return zn(e,"line3D",this.#l())}render_scatter3D(e){return zn(e,"scatter3D",this.#l())}render_surface(e){return zn(e,"surface",this.#l())}render_map(e){return Ja(e,this.#l())}#a({view:e,category:r,fields:n,settings:i,domains:s},{type:o,area:a=!1,stacked:l=!1,horizontal:u=!1,points:c=!1}){let{source:f,kind:h}=ne(e,r,n,s?.dimension);if(c&&!["value","time"].includes(h))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(l&&new Set(i.map(E=>E.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(l&&new Set(f.map(E=>E[0])).size!==f.length)throw new TypeError("Plotly stacked series require distinct X values. Prepare the store upstream. Configuration retained.");if(l&&a&&f.some(E=>E.slice(1).some(w=>w<0)))throw new TypeError("Plotly stacked areas do not implement separate positive/negative stacks. Choose another type or engine. Configuration retained.");let d=f.map(E=>h==="time"?new Date(E[0]).toISOString():E[0]),p=this.#l(),m=u?"y":"x",g=u?"x":"y";p.barmode=l?"relative":"group",p[m+"axis"]={type:h==="time"&&!u?"date":h==="category"||o==="bar"?"category":"linear",automargin:!0};for(let[E,w]of["left","right"].entries())p[g+"axis"+(E?"2":"")]={side:u?E?"top":"bottom":w,visible:i.some(v=>v.axis===w),automargin:!0,title:{text:n.filter((v,x)=>i[x].axis===w).join(", ")},...E?{overlaying:g}:{},rangemode:"tozero"};if(s){let E=p[m+"axis"];E.type==="category"?(E.categoryorder="array",E.categoryarray=s.dimension.values.map(w=>h==="time"?new Date(w).toISOString():w),E.range=[-.5,E.categoryarray.length-.5]):E.range=s.dimension.range.map(w=>h==="time"?new Date(w).toISOString():w),E.autorange=!1;for(let[w,v]of["left","right"].entries())Object.assign(p[g+"axis"+(w?"2":"")],{range:s.axes[v],autorange:!1})}return{data:n.map((E,w)=>({type:o,name:E,[m]:[...d],[g]:f.map(v=>v[w+1]),[g+"axis"]:g+(i[w].axis==="right"?"2":""),marker:{color:i[w].color},...o==="scatter"?{mode:c?"markers":f.length===1?"lines+markers":"lines",line:{color:i[w].color},...a?{fill:l?"tonexty":"tozeroy",fillcolor:i[w].color+"4d"}:{},...l?{stackgroup:"measures",stackgaps:"infer zero"}:{}}:{orientation:u?"h":"v",...l?{}:{offsetgroup:E},alignmentgroup:"measures"}})),layout:p}}#f({view:e,category:r,fields:n,domains:i},s){let{source:o,kind:a}=ne(e,r,n,i?.dimension),l=o.map(u=>a==="time"?new Date(u[0]).toISOString().slice(0,10):String(u[0]));if(new Set(l).size!==o.length)throw new TypeError("Plotly pie/donut requires distinct category labels. Prepare the store upstream or choose another engine. Configuration retained.");if(o.some(u=>u[1]<0))throw new TypeError("Pie and donut require nonnegative values. Configuration retained.");return{layout:this.#l(),data:n.map(u=>({type:"pie",name:u,sort:!1,hole:s?.5:0,labels:l,...i?{marker:{colors:l.map(c=>st[i.labels.indexOf(c)%st.length])}}:{},values:o.map(c=>c[1]),textposition:"inside",textinfo:"label+percent",automargin:!0}))}}#l(){return{paper_bgcolor:"#fff",plot_bgcolor:"#fff",font:{color:"#333"},showlegend:!0,margin:{l:70,r:70,t:40,b:75},legend:{orientation:"h",y:-.18,x:0},autosize:!0}}resize(){if(this.#i||!this.#u)return;let e=this.#e.getBoundingClientRect();if(this.#e.layout.width===Math.round(e.width)&&this.#e.layout.height===Math.round(e.height))return;let r=()=>{if(this.#i)return;let n=this.#e.getBoundingClientRect();return Nr.relayout(this.#e,{width:Math.max(1,Math.round(n.width)),height:Math.max(1,Math.round(n.height))})};this.#o=this.#o.then(r).catch(()=>{})}dispose(){this.#i=!0,this.#n?.remove(),this.#u&&Nr.purge(this.#e)}};var Wt={echarts:Vn,plotly:jn,vega:Bn,uplot:Mn};function kh(t){let e=Wt[t];if(!Object.hasOwn(Wt,t))throw new TypeError(`Unknown chart engine: ${t}`);return e}function Hn(t){return Object.getOwnPropertyNames(t.prototype).filter(e=>e.startsWith("render_")&&typeof t.prototype[e]=="function").map(e=>e.slice(7))}function is(t,e){let r=kh(t);if(!Hn(r).includes(e))throw new TypeError(`${r.label} does not support ${e}. Choose another type or engine. Configuration retained.`);return r}function Za(t,{configpath:e,storepath:r,rowMode:n,prefix:i}){let s={};function o(d,p,m,g,y){let E=`${i}-${m}`;d.html_label(p,{for:E});let w={id:E,value:`^${e}.${m}`};y&&(w.nodeId=`${i}_${y}`,s[y]=w.nodeId);let v=d.select(w);for(let[x,T]of g){let b={value:x};if(m==="timeStep"&&["minute","hour"].includes(x))b.disabled=`^${e}.timeHasClock:=!{}`;else if(m==="chartType"){let C=Object.entries(Wt).filter(([,I])=>Hn(I).includes(x)).map(([I])=>I);b.disabled=`^${e}.engine:=!${JSON.stringify(C)}.includes({})`,b.hidden=b.disabled}else if(m==="engine"){let C=Hn(Wt[x]);b.disabled=`^${e}.chartType:=!${JSON.stringify(C)}.includes({})`,b.hidden=b.disabled}v.option(T,b)}return v}let a=[["","No columns"]];o(t,"Engine","engine",Object.entries(Wt).map(([d,p])=>[d,p.label])),o(t,"Chart type","chartType",kn.map(d=>[d.id,d.label]));let l=t.details({id:`${i}-animation`});l.summary("Temporal animation");let u=l.div({display:"grid",gap:"4px"});o(u,"Date field","timeField",[["","Off"]],"timeFieldId");let c=u.div({display:`^${e}.timeField:={} ? 'grid' : 'none'`,gap:"4px"});o(c,"Period","timeStep",[["auto","Automatic"],["minute","Minute"],["hour","Hour"],["day","Day"],["week","Week \xB7 Mon\u2013Sun"],["month","Month"],["year","Year"]]),o(c,"Empty periods","timeEmpty",[["previous","Keep previous snapshot"],["empty","Show empty"]]);let f=c.div();f.span("Current period (UTC): "),f.span(`^${e}.timeUnit`),c.html_label("Seconds per frame",{for:`${i}-time-speed`}),c.numberTextBox({id:`${i}-time-speed`,value:`^${e}.timeSpeed`,min:.1,max:10}),t.chartTimeline({storepath:r,rowMode:n,configpath:e,timeField:`^${e}.timeField`,timeStep:`^${e}.timeStep`,timeIndex:`^${e}.timeIndex`});let h={category(d){o(d,"Category / territory field","captionField",a,"categoryId")},geoJSON(d){d.chartGeoJSON({value:`^${e}.geoJSON`}),d.div("Link the category / territory field to GeoJSON properties.name.",{style:"font-size:11px"})},mapMeasure(d){o(d,"Map measure","mapValueField",[["","No measures"]],"mapMeasureId"),o(d,"Map label field","mapLabelField",a,"mapLabelId"),o(d,"Map labels","mapLabelMode",[["none","None"],["name","Names"],["value","Values"],["nameValue","Names and values"]]),d.div("Calculated measures must be supplied as store columns.",{style:"font-size:11px"})},mapBarScale(d){o(d,"Height scale","mapBarScale",[["zero","From zero"],["extent","Data range"]]),d.div("Selected measures share one height scale. Data range truncates the baseline; tooltip values are unchanged.",{style:"font-size:11px"})},secondDimension(d){o(d,"Second dimension","secondCaptionField",a,"secondCategoryId")},geometry(d){o(d,"Coordinate field","geometryField",a,"geometryId")},measures(d){let p=d.menu({presentation:"bar",aria_label:"Measures toolbar"}).menuline({caption:"Measures",aria_label:"Choose measures"}).menu({nodeId:`${i}_measureMenuId`});s.measureMenuId=`${i}_measureMenuId`,p.menuline({caption:"No measures",disabled:!0});let g=d.grid({id:`${i}-measures`,storepath:`${e}.seriesOptions`,rowMode:"values",height:"120px",style:"--gramlot-grid-row-height:24px;--gramlot-grid-font-size:12px;--gramlot-grid-cell-padding:2px 5px",filter:{value:"^true",columns:["selected"],dtype:"T"}}).struct();g.column({field:"caption",name:"Measure",width:"40%"}),g.column({field:"color",name:"Color",width:"30%",edit:{tag:"colorpicker"}}),g.column({field:"axis",name:"Axis",width:"30%",edit:{tag:"filteringSelect",values:"left:Left,right:Right",validate_select:!0}})}};for(let[d,p]of Object.entries(h)){let m=kn.filter(y=>y.controls.includes(d)).map(y=>y.id),g=t.div({display:`^${e}.chartType:=${JSON.stringify(m)}.includes({}) ? "grid" : "none"`,gap:"4px"});p(g)}t.chartFields({storepath:r,rowMode:n,configpath:e,...s})}var Qa=(0,J.defineComponent)({name:"chartPane",tag:"gramlot-chart-pane",base:je,sourceContext:!0,subTags:"*",parameters:{configDefaults:{dtype:"X",nullable:!0},storepath:{dtype:"T"},configpath:{dtype:"T"},rowMode:{dtype:"T",default:"attributes"},gridId:{dtype:"T",nullable:!0}},implementation:t=>class extends t{#e;#t=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}connectedCallback(){if(this.#t)return;let e=this.#e.sourceNode;if(e.value!==null&&e.value.getNode("frame"))return;let r=e.absDatapath(this.parameters.storepath),n=e.absDatapath(this.parameters.configpath),i=e.getRelativeData(n);i==null&&(i=new Ir,e.setRelativeData(n,i));let s=this.parameters.configDefaults;if(s!=null){if(!(s instanceof Ir))throw new TypeError("configDefaults requires a Bag");let T=Fh(Rh(s));for(let b of T.getNodes())i.getNode(b.label)||i.setItem(b.label,b.getValue())}if(!(i instanceof Ir))throw new TypeError("chartPane requires a configuration Bag");let o={mapLabelMode:"value",mapBarScale:"zero",selectedTerritory:"",timeField:"",timeEmpty:"previous",timeSnapshotLabel:"",timeStep:"auto",timeUnit:"month",timeHasClock:!1,timeIndex:0,timeMax:0,timeAtEnd:!0,timeValue:null,timeLabel:"",timePlaying:!1,timeSpeed:.8,engine:"echarts",chartType:"bar",captionField:"",secondCaptionField:"",geometryField:"",mapValueField:"",mapLabelField:"",geoJSON:null,drawer:"close"};for(let[T,b]of Object.entries(o))i.getNode(T)||i.setItem(T,b);if(i.getNode("seriesOptions")||i.setItem("seriesOptions",new Ir),!(i.getItem("seriesOptions")instanceof Ir))throw new TypeError("seriesOptions must be a Bag");let a=new e.builder.source.constructor(null,e.builder),l=e.builder.wrapSource(a).framePane({node_label:"frame",height:"100%"});l.dataFormula({result_path:`${n}.valueFields`,formula:"options.getNodes().filter(n => n.getValue().getItem('selected')).map(n => n.label).join(',')",options:`^${n}.seriesOptions`,_onBuilt:!0});let u=l.top.contentPane({display:"flex",justify_content:"flex-end",align_items:"center",padding:"2px 6px"}),c=JSON.stringify(`${n}.drawer`);u.button({icon:"\u2699",aria_label:"Chart settings",title:"Chart settings",action:`this.SET(${c},this.GET(${c}) === 'close' ? true : 'close');`});let f=e.getAttr("id")??`chart-${He()}`,h=l.center.borderContainer({id:`${f}-layout`,height:"100%"}),d=h.contentPane({region:"right",width:"260px",drawer:`^${n}.drawer`,drawer_style:"display:none",detachable:!0,title:"Chart configuration",padding:"8px",border_left:"1px solid var(--gramlot-border)",background:"var(--gramlot-surface)",overflow:"auto",display:"grid",gap:"4px",align_content:"start",style:"font-size:12px;--gramlot-field-height:26px;--gramlot-field-padding:2px 5px;--gramlot-grid-row-height:26px"}),p={id:`${f}-view`,configpath:n,storepath:r,rowMode:this.parameters.rowMode};for(let T of["mapLabelMode","mapBarScale","selectedTerritory","timeEmpty","timeField","timeValue","timeStep","engine","mapValueField","mapLabelField","geoJSON","geometryField","chartType","captionField","secondCaptionField","valueFields","seriesOptions"])p[T]=`^${n}.${T==="timeStep"?"timeUnit":T}`;this.parameters.gridId&&(p.gridId=this.parameters.gridId),h.contentPane({region:"center",min_width:"0"}).chartView(p),Za(d,{configpath:n,storepath:r,rowMode:this.parameters.rowMode,prefix:f}),l.dataFormula({result_path:`${n}.timeInterval`,formula:"playing ? speed : 0",playing:`^${n}.timePlaying`,speed:`^${n}.timeSpeed`,_onBuilt:!0}),l.dataController({func:ba(e.rootBuilder.binding),configpath:n,_timing:`^${n}.timeInterval`}),l.dataFormula({result_path:`${n}.timeAtEnd`,formula:"index >= max",index:`^${n}.timeIndex`,max:`^${n}.timeMax`,_onBuilt:!0});let m=l.bottom.contentPane({display:`^${n}.timeField:={} ? 'flex' : 'none'`,align_items:"center",flex_wrap:"wrap",gap:"10px",padding:"8px 12px",role:"toolbar",aria_label:"Playback controls",background:"var(--gramlot-surface-subtle)",border_top:"1px solid var(--gramlot-border)"}),g=T=>JSON.stringify(`${n}.${T}`),y=m.div({display:"flex",align_items:"center",gap:"2px",flex_shrink:"0"});y.button({icon:"\u2190",aria_label:"Previous period",title:"Previous period",id:`${f}-time-previous`,disabled:`^${n}.timeIndex:={} <= 0`,action:`this.SET(${g("timePlaying")},false);this.SET(${g("timeIndex")},Math.max(0,this.GET(${g("timeIndex")})-1));`}),y.button({icon:`^${n}.timePlaying:={} ? '\u23F8\uFE0E' : '\u25B6'`,aria_label:`^${n}.timePlaying:={} ? 'Pause' : 'Play'`,title:`^${n}.timePlaying:={} ? 'Pause' : 'Play'`,aria_pressed:`^${n}.timePlaying`,id:`${f}-time-play`,disabled:`^${n}.timeMax:={} === 0`,action:`if(!this.GET(${g("timePlaying")}) && this.GET(${g("timeIndex")}) >= this.GET(${g("timeMax")}))this.SET(${g("timeIndex")},0);this.SET(${g("timePlaying")},!this.GET(${g("timePlaying")}));`}),y.button({icon:"\u25A0",aria_label:"Stop",title:"Stop and return to the beginning",id:`${f}-time-stop`,disabled:`^${n}.timeMax:={} === 0`,action:`this.SET(${g("timePlaying")},false);this.SET(${g("timeIndex")},0);`}),y.button({icon:"\u2192",aria_label:"Next period",title:"Next period",id:`${f}-time-next`,disabled:`^${n}.timeAtEnd`,action:`this.SET(${g("timePlaying")},false);this.SET(${g("timeIndex")},Math.min(this.GET(${g("timeMax")}),this.GET(${g("timeIndex")})+1));`}),m.div({flex:"1",min_width:"120px"}).horizontalSlider({width:"100%",id:`${f}-time-slider`,aria_label:"Temporal snapshot",value:`^${n}.timeIndex`,min:0,max:`^${n}.timeMax`,step:1,live:!0,flex:"1",connect_oninput:`this.SET(${g("timePlaying")},false);`});let w=m.div({display:"grid",gap:"2px",white_space:"nowrap",text_align:"right",font_size:"12px",font_variant_numeric:"tabular-nums"});w.span(`^${n}.timeLabel`,{id:`${f}-time-label`,font_weight:"600"}),w.small(`^${n}.timeSnapshotLabel`,{id:`${f}-snapshot-label`,color:"var(--gramlot-text-secondary)",display:`^${n}.timeSnapshotLabel:={} ? '' : 'none'`});let v=e.rootBuilder.binding.gramlot,x=v.src.prepareSource(a);v.src.renderer.validateCandidate(x),this.#t=!0,e.setValue(x)}}});import{Bag as gs}from"@gramlot/gramlot";var ss=class{#e=new Set;view=null;#t;columns=[];update(e,r){if(!(this.view===e&&this.#t===e.bag&&this.columns===r)){this.view=e,this.#t=e.bag,this.columns=r;for(let n of this.#e)n()}}detach(e){if(this.view===e){this.view=null,this.#t=null,this.columns=[];for(let r of this.#e)r()}}subscribe(e){return this.#e.add(e),()=>this.#e.delete(e)}};function Ka(t){return Object.hasOwn(t,"gridSearch")||Object.defineProperty(t,"gridSearch",{value:new ss,configurable:!0}),t.gridSearch}var Gn=class{bind(e,r,n,i,s){if(!Array.isArray(e)||e.some(o=>typeof o!="number"||!Number.isFinite(o)))throw new TypeError("Sample chart requires an array of finite numbers");if(!Number.isFinite(r)||r<=0||!Number.isFinite(n))throw new TypeError("Sample chart requires a positive step and finite start");if(typeof i!="string"||!i||typeof s!="string"||!s||s.includes(",")||i===s)throw new TypeError("Sample chart requires distinct captionField and one valueFields name");this.samples=e,this.step=r,this.start=n,this.category=i,this.measure=s,this.rows?.length!==e.length&&(this.rows=Array.from(e.keys()))}domains(e,r,n){if(r==null&&n==null)return null;if(!Number.isFinite(r)||!Number.isFinite(n)||r>=n)throw new TypeError("Sample bounds require finite sampleMin < sampleMax");let i=_n(this,e);return i.dimension.range=[this.start,this.start+Math.max(1,this.samples.length-1)*this.step],i.axes={left:[r,n],right:[r,n]},i.z=[r,n],i}getRows(){return this.rows}value(e,r){if(r===this.category)return this.start+e*this.step;if(r===this.measure)return this.samples[e];throw new TypeError(`Unknown sample field: ${r}`)}};function os(t){if(t==null||t==="")return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)||t instanceof Date&&Number.isFinite(t.getTime())||ie(t)&&t.isFinite())return t;throw new TypeError("Column filters require loaded scalar values")}function gt(t){return xe(os(t))}function eu(t){if(!Array.isArray(t))throw new TypeError("Column selection requires an array or null");return Object.freeze([...new Map(t.map(e=>{let r=gt(e);return[r,K(r)]})).values()])}function tu(t){if(t===null)return null;let{from:e,to:r,dtype:n,timeZone:i}=t;if(!["D","DH","DHZ"].includes(n))throw new TypeError("Date range requires a date column");for(let s of[e,r])if(s!==null&&(!(s instanceof Date)||!Number.isFinite(s.getTime())||s.getUTCHours()||s.getUTCMinutes()||s.getUTCSeconds()||s.getUTCMilliseconds()))throw new TypeError("Date bounds require civil dates");if(e&&r&&e>r)throw new RangeError("From must not be after To.");if(n==="DHZ"&&!i)throw new TypeError("DHZ requires a timeZone");return e||r?Object.freeze({from:e?.toISOString().slice(0,10)??null,to:r?.toISOString().slice(0,10)??null,dtype:n,timeZone:i}):null}function Xn(t,e){if(!e)return!0;if(t==null||t==="")return!1;if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError("Date range requires date values");let r;if(e.dtype==="DHZ"){let n=new Intl.DateTimeFormat("en",{timeZone:e.timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(t),i=s=>n.find(o=>o.type===s).value;r=`${i("year")}-${i("month")}-${i("day")}`}else r=t.toISOString().slice(0,10);return(!e.from||r>=e.from)&&(!e.to||r<=e.to)}function yt(t,e){return e===2?t%4===0&&(t%100!==0||t%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function Ee(t,e,r){if(![t,e,r].every(Number.isInteger)||t<1||t>9999||e<1||e>12||r<1||r>yt(t,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(r).padStart(2,"0")}`}function wt(t){if(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=t.split("-").map(Number);return Ee(...e),e}function Or(t,e,r){let n=t-1,i=365*n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+r-1;for(let s=1;s<e;s++)i+=yt(t,s);return i}function Br(t,e){let r=Or(...wt(t))+e;if(!Number.isSafeInteger(r)||r<0||r>Or(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let n=1,i=1e4;for(;i-n>1;){let o=Math.floor((n+i)/2);Or(o,1,1)<=r?n=o:i=o}r-=Or(n,1,1);let s=1;for(;r>=yt(n,s);)r-=yt(n,s++);return Ee(n,s,r+1)}function as(t){return Br(t,-(Or(...wt(t))%7))}function ru(t,e,r=0,n=1){let i=t*12+e-1+r,s=Math.floor(i/12),o=(i%12+12)%12+1,a=i+n-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:Ee(s,o,1),end:Ee(l,u,yt(l,u))}}var Yn={en:{months:{january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12,jan:1,feb:2,mar:3,apr:4,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},weekdays:{monday:0,tuesday:1,wednesday:2,thursday:3,friday:4,saturday:5,sunday:6,mon:0,tue:1,wed:2,thu:3,fri:4,sat:5,sun:6},quarters:{"1st quarter":1,"2nd quarter":2,"3rd quarter":3,"4th quarter":4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["today"],yesterday:["yesterday"],tomorrow:["tomorrow"],this_week:["this week","week"],last_week:["last week"],next_week:["next week"],this_month:["this month","month"],last_month:["last month"],next_month:["next month"],last:["last"],next:["next"],articles:["the"],from:["from","between"],to:["to","and"],no_period:["no period","always"]},date_order:{default:"MDY",GB:"DMY",AU:"DMY",IE:"DMY",NZ:"DMY",IN:"DMY"}},it:{months:{gennaio:1,febbraio:2,marzo:3,aprile:4,maggio:5,giugno:6,luglio:7,agosto:8,settembre:9,ottobre:10,novembre:11,dicembre:12,gen:1,feb:2,mar:3,apr:4,mag:5,giu:6,lug:7,ago:8,set:9,ott:10,nov:11,dic:12},weekdays:{luned\u00EC:0,marted\u00EC:1,mercoled\u00EC:2,gioved\u00EC:3,venerd\u00EC:4,sabato:5,domenica:6,lun:0,mar:1,mer:2,gio:3,ven:4,sab:5,dom:6},quarters:{"1\xBA trimestre":1,"2\xBA trimestre":2,"3\xBA trimestre":3,"4\xBA trimestre":4,"1\xB0 trimestre":1,"2\xB0 trimestre":2,"3\xB0 trimestre":3,"4\xB0 trimestre":4,t1:1,t2:2,t3:3,t4:4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["oggi"],yesterday:["ieri"],tomorrow:["domani"],this_week:["questa settimana","settimana"],last_week:["settimana scorsa"],next_week:["settimana prossima"],this_month:["questo mese","mese"],last_month:["mese scorso"],next_month:["mese prossimo"],last:["scorso","scorsa"],next:["prossimo","prossima"],articles:["il","lo","la"],from:["da","dal","dalla","tra","fra"],to:["a","al","alla","e"],no_period:["-","senza periodo","sempre"]},date_order:{default:"DMY"}}};function nu(t){if(typeof t!="string")throw new RangeError("A supported locale is required.");let e=t.replaceAll("-","_"),r=e.indexOf("_"),n=(r<0?e:e.slice(0,r)).toLowerCase(),i=(r<0?"":e.slice(r+1)).toUpperCase();if(!Object.hasOwn(Yn,n))throw new RangeError(`Unsupported locale: ${t}`);let s=Yn[n];return{dictionary:s,phrases:a=>[...new Set([...s.keywords[a],...Yn.en.keywords[a]])],order:s.date_order[i]??s.date_order.default}}var Et=/^(?:\d{4}|\d{2})$/,iu=/^\d{1,2}$/,Mr=(t,e)=>({ok:!1,error:{code:t,message:e}}),Dt=(t="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:t})},au=(t,e)=>Object.hasOwn(t,e);function bt(t,e){if(t.length===4)return Number(t);let r=e.year+e.twoDigitYearAhead-100;return r+((Number(t)-r)%100+100)%100}function Lh(t,e){if(t.includes(";")){let i=t.split(";").map(s=>s.trim());return i.length!==2?Dt("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:i,range:!0}}if(e.phrases("no_period").includes(t))return{bounds:["",""],range:!0};let r=e.phrases("to"),n=e.phrases("from");for(let i of r)if(t.startsWith(`${i} `))return{bounds:["",t.slice(i.length+1).trim()],range:!0};for(let i of r){let s=` ${i} `;if(!t.includes(s))continue;for(let a of n)if(t.startsWith(`${a} `)){t=t.slice(a.length+1);break}let o=t.split(s).map(a=>a.trim());return o.length!==2?Dt("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let i of n)if(t.startsWith(`${i} `))return{bounds:[t.slice(i.length+1).trim(),""],range:!0};return{bounds:[t,t],range:!1}}function Ph(t,e,r){let n=[[t,0]],i=/^(.+?)\s*([+-])\s*(\d+)$/.exec(t);i&&n.push([i[1],Number(i[2]+i[3])]);let s={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[o,a]of n)for(let[l,u]of Object.entries(s))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return Br(as(e.workdate),(u+a)*7+(r?6:0));if(l.endsWith("_month")){let c=ru(e.year,e.month,u+a);return r?c.end:c.start}return Br(e.workdate,u+a)}return null}function Uh(t,e,r){let n=Object.entries(e.dictionary.quarters).sort((i,s)=>s[0].length-i[0].length);for(let[i,s]of n){let o;if(t===i)o=null;else if(t.startsWith(i)&&Et.test(t.slice(i.length).trim()))o=bt(t.slice(i.length).trim(),e);else if(t.endsWith(i)&&Et.test(t.slice(0,-i.length).trim()))o=bt(t.slice(0,-i.length).trim(),e);else continue;return{year:o,month:r?s*3:s*3-2}}return null}function su(t,e){if(au(e.months,t))return e.months[t];let r=/^m(\d{1,2})$/.exec(t);return r&&Number(r[1])>=1&&Number(r[1])<=12?Number(r[1]):null}function $h(t,e){let r=t.split(/\s+/),n=r.map((u,c)=>su(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!n.length)return null;if(n.length!==1)return Dt();let i=n[0],s=su(r[i],e.dictionary),o=r.slice(0,i),a=r.slice(i+1),l=[...o,...a];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(s>e.month?1:0),month:s};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(s<e.month?1:0),month:s};if(!l.length)return{year:null,month:s};if(!o.length&&a.length===1&&Et.test(a[0]))return{year:bt(a[0],e),month:s};if(o.length===1&&iu.test(o[0])){if(!a.length)return Ee(e.year,s,Number(o[0]));if(a.length===1&&Et.test(a[0]))return Ee(bt(a[0],e),s,Number(o[0]))}return!o.length&&a.length===2&&iu.test(a[0])&&Et.test(a[1])?Ee(bt(a[1],e),s,Number(a[0])):Dt()}function qh(t,e){let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(r)return Ee(...r.slice(1).map(Number));let n=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(t),i={};if(n)e.order.split("").forEach((a,l)=>{i[a]=n[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(t)){let a=t.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;i[l]=t.slice(0,u),t=t.slice(u)}}else return null;if(!Et.test(i.Y)||i.D.length>2||i.M.length>2)return Dt();let s=Number(i.D),o=Number(i.M);return n&&o>12&&s<=12&&([s,o]=[o,s]),Ee(bt(i.Y,e),o,s)}function ou(t,e,r){if(!t)return null;let n=e.phrases("articles");if(t=t.split(/\s+/).filter(s=>!n.includes(s)).join(" "),!t)return Dt();if(Et.test(t))return Ee(bt(t,e),r?12:1,r?31:1);let i=Ph(t,e,r)??Uh(t,e,r)??$h(t,e);return i!==null?i:au(e.dictionary.weekdays,t)?Br(as(e.workdate),e.dictionary.weekdays[t]):qh(t,e)??Dt()}function Vh(t,e,r){if(t===null||typeof t=="string")return t;let n=t.year??r.year,i=typeof e=="string"?wt(e)[0]:e?.year,s=typeof e=="string"?wt(e)[1]:e?.month;return i&&(n>i&&(n=i),n===i&&t.month>s&&n--),Ee(n,t.month,1)}function zh(t,e,r){if(t===null||typeof t=="string")return t;let n=t.year??r.year;if(e!==null){let[i,s]=wt(e);n<i&&(n=i),n===i&&s>t.month&&n++}return Ee(n,t.month,yt(n,t.month))}function us(t,e={}){if(!e||typeof e!="object"||Array.isArray(e))return Mr("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let r;try{let{locale:n="it-IT",workdate:i,twoDigitYearAhead:s=20}=e,[o,a]=wt(i);if(!Number.isInteger(s)||s<0||s>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");r={...nu(n),workdate:i,year:o,month:a,twoDigitYearAhead:s}}catch(n){return Mr("INVALID_CONTEXT",n.message)}if(typeof t!="string")return Mr("INVALID_INPUT","Expression must be a string.");try{let n=t.toLowerCase().trim().replaceAll(",",""),{bounds:i,range:s}=Lh(n,r),o=ou(i[1],r,!0),a=ou(i[0],r,!1),l=Vh(a,o,r),u=zh(o,l,r);return!s&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(n){if(n instanceof RangeError)return Mr("INVALID_DATE",n.message);if(n instanceof SyntaxError)return Mr(n.code,n.message);throw n}}var Jt=new Map;function Wn(t,e,r){let n=JSON.stringify([t,e,r]),i=Jt.get(n);if(i)Jt.delete(n);else{let s=t?Intl.DateTimeFormat:Intl.NumberFormat;if(!s.supportedLocalesOf([e]).length)throw new RangeError(`Unsupported format locale: ${e}`);i=new s(e,r),Jt.size===64&&Jt.delete(Jt.keys().next().value)}return Jt.set(n,i),i}function lu(t){if(t!=null&&(typeof t!="string"||/[{}]/.test(t.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function uu(t,e){return lu(e),e==null?t:e.replaceAll("{}",()=>t)}function jh(t){if(t instanceof Date)return Le(t);if(ie(t))return"N";if(typeof t=="number")return Number.isInteger(t)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function Hh(t,e,{pattern:r="short",locale:n,timeZone:i}){if(!["short","medium","long","full"].includes(r))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof i!="string"||!i))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let s={timeZone:e==="DHZ"?i:"UTC"};return e!=="H"&&(s.dateStyle=r),e!=="D"&&(s.timeStyle=r),Wn(!0,n,s).format(t)}function Jn(t){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(t);if(!e||e[1]==="("!=(e[4]===")")||t.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${t}`);let r=e[3]??"";return{prefix:e[1]??"",suffix:e[4]??"",intl:{useGrouping:e[2].startsWith("#,##")?"always":!1,minimumIntegerDigits:e[2].replace("#,##","").length,minimumFractionDigits:r.replaceAll("#","").length,maximumFractionDigits:r.length}}}function Gh(t){let e=t.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let r=Jn(e[0]);if(r.prefix||r.suffix)throw new RangeError("Positive-section affixes are not implemented");let n=e.length===3?e[1]:null;n!==null&&n!==""&&n!=="-"&&Jn(n);let i=e.length>1?Jn(e.at(-1)):null;return{positive:r,zero:n,negative:i}}function cu(t,e={},r={}){if(t===null)return"";if(typeof e=="string"&&(e={pattern:e}),!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Format options must be a pattern string or an options object");for(let g of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(g))throw new RangeError(`Unsupported format option: ${g}`);e={...e,locale:e.locale??r.locale,timeZone:e.timeZone??r.timeZone};let n=e.dtype===void 0?jh(t):e.dtype,i=["D","H","DHZ"].includes(n);if(!i&&!["L","R","N"].includes(n))throw new RangeError(`Unsupported format dtype: ${n}`);if(i){if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError(`${n} requires a valid Date object`)}else if(!(typeof t=="number"&&Number.isFinite(t))&&!(ie(t)&&!["NaN","Infinity","-Infinity"].includes(t.toString())))throw new TypeError(`${n} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(n==="L"&&!Number.isInteger(t))throw new TypeError("L formatting requires an integer");let{pattern:s,locale:o,mask:a}=e;if(!i&&typeof s!="string")throw new TypeError("Numeric formatting currently requires an explicit pattern");if(typeof o!="string"||!o)throw new TypeError("Formatting currently requires an explicit locale");if(lu(a),i){let g=Hh(t,n,e);return uu(g,a)}let{positive:l,zero:u,negative:c}=Gh(s),f=Wn(!1,o,l.intl),h=ie(t),d=h?t.eq(0):t===0,p=h?t.lt(0):t<0;if(h&&Wn(!1,"en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let m;if(d&&u!==null){if(u==="")return"";if(u==="-")m="-";else{let g=Jn(u);m=g.prefix+Wn(!1,o,g.intl).format(0)+g.suffix}}else{let g=p&&c?c:l,y=h?(p&&c?t.abs():t).toString():p&&c?-t:t===0?0:t;m=g.prefix+f.format(y)+g.suffix}return uu(m,a)}function fu(t){if(t===null)return null;let{value:e,columns:r,dtype:n,locale:i}=t;if(typeof e!="string"||!Array.isArray(r)||!r.length||r.some(u=>typeof u!="string"||!u||u==="rowidx")||!["T","L","R","N","D"].includes(n))throw new TypeError("Invalid collection filter");if(!e.trim())return null;if(n==="T"){let u=t.literal===!0?e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):e,c=new RegExp(u,"i");return f=>c.test(r.map(h=>Xh(f(h),i,t.timeZone)).join(" "))}if(r.length!==1)throw new TypeError("Typed filters require one column");let s=/^\s*(<=|>=|==|!=|[<>=!#])\s*(.+?)\s*$/.exec(e);if(!s)throw new Error("Enter a comparison, for example > 100 or = 12.");let[,o,a]=s,l;if(n==="D"){let u=new Date,c=`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`,f=us(a,{locale:i,workdate:c});if(!f.ok||f.kind!=="date")throw new Error("Enter one complete date after the comparison.");l=new Date(`${f.date}T00:00:00Z`)}else l=Yh(a,i);return u=>{let c=u(r[0]);if(c==null)return!1;if(n==="D"?!(c instanceof Date)||!Number.isFinite(c.getTime()):!(typeof c=="number"&&Number.isFinite(c)||ie(c)&&c.isFinite()))throw new TypeError(`Filter value does not match ${n}`);let f=ie(l)?-l.comparedTo(c):c<l?-1:c>l?1:0;switch(o){case"=":case"==":return f===0;case"!":case"#":case"!=":return f!==0;case"<":return f<0;case">":return f>0;case"<=":return f<=0;case">=":return f>=0}}}function Xh(t,e,r){return t==null?"":typeof t=="string"||typeof t=="boolean"?String(t):cu(t,{pattern:t instanceof Date?"short":"#,##0.####################"},{locale:e,timeZone:r})}function Yh(t,e){let r=new Intl.NumberFormat(e).formatToParts(-12345.6),n=r.find(l=>l.type==="decimal").value,i=r.find(l=>l.type==="group")?.value,s=r.find(l=>l.type==="minusSign").value,o=t.replaceAll(s,"-");if(i&&o.includes(i)){let u=o.split(n)[0].replace(/^[+-]/,"").split(i),c=new Intl.NumberFormat(e).formatToParts(1234567890123).filter(d=>d.type==="integer").map(d=>d.value.length),f=c.at(-1),h=c.at(-2);if(o.split(n).slice(1).some(d=>d.includes(i))||!/^\d+$/.test(u[0])||u[0].length>h||u.slice(1).some((d,p)=>!/^\d+$/.test(d)||d.length!==(p===u.length-2?f:h)))throw new Error("Invalid numeric grouping.");o=o.replaceAll(i,"")}if(o=o.replace(n,"."),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(o))throw new Error("Enter a complete number.");let a=jt(o);if(!ie(a)||!a.isFinite())throw new Error("A finite Decimal backend is required.");return a}function hu(t,e){return(","+t+",").includes(","+e+",")}function du(t){if(typeof t!="string")throw new TypeError("grid checked must refer to a string (empty string for an empty set)");return t}function pu(t){if(typeof t!="string"||!t||t.includes(","))throw new TypeError("grid checkedField requires nonempty text IDs without commas");return t}var mu={network:{maxAttempts:3,delay:1,backoff:2,jitter:!0,on:["TypeError","NetworkError","AbortError"]},aggressive:{maxAttempts:5,delay:.5,backoff:2,jitter:!0,on:["Error"]},gentle:{maxAttempts:2,delay:2,backoff:1.5,jitter:!1,on:["TypeError","NetworkError"]}};function Wh(t){let e=t._retryPolicy;return e==null?null:typeof e=="string"?mu[e]||null:e}function Jh(t,e){return e.some(r=>r==="Error"?!0:t.name===r||t.constructor.name===r)}function Zh(t){return new Promise(e=>setTimeout(e,t))}async function Qh(t,e){if(!e)return t();let r=e.maxAttempts||3,n=e.delay||1,i=e.backoff||2,s=e.jitter!==!1,o=e.on||["Error"],a=null,l=n*1e3;for(let u=0;u<r;u++)try{let c=t();return c instanceof Promise?await c:c}catch(c){if(a=c,u<r-1&&Jh(c,o)){let f=l;s&&(f*=1+Math.random()*.1),await Zh(f),l*=i}else throw c}throw a}var le=class t{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let n={...this.constructor.classKwargs,...e};for(let s of["interval","reactive"])if(Object.hasOwn(n,s))throw new TypeError(`Removed resolver option: ${s}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=n.cacheTime,this._readOnly=n.readOnly,this._asBag=n.asBag,this._retryPolicy=n.retryPolicy,this._kw={};let i=this.constructor.internalParams;for(let[s,o]of Object.entries(n))i.has(s)||(this._kw[s]=o);this._lastUpdate=null,this._node=null,this._lastEffectiveFingerprint=null,this._cachedValue=null,this.init()}init(){}setNode(e){e!==this._node&&!this.readOnly&&this._lastUpdate!==null&&this.reset(),this._node=e,this.onSetResolver(e)}onSetResolver(e){}get node(){return this._node}get cacheTime(){return this._cacheTime}set cacheTime(e){if(typeof e=="boolean")throw new TypeError("cacheTime must be numeric; use a negative value for infinite caching");this._cacheTime=e}get readOnly(){return this._readOnly}get expired(){return this._cacheTime<0?this._lastUpdate===null:this._cacheTime===0||this._lastUpdate===null?!0:(Date.now()-this._lastUpdate)/1e3>this._cacheTime}reset(...e){if(e.length)throw new TypeError("reset() takes no arguments. It invalidates the cache for the next explicit read.");this._lastUpdate=null,this._lastEffectiveFingerprint=null}get cachedValue(){return!this.readOnly&&this._node?this._node._value:this._cachedValue}set cachedValue(e){!this.readOnly&&this._node?this._node.setValue(e,!1):this._cachedValue=e}_computeEffectiveFingerprint(e){return JSON.stringify(Object.entries(e).sort())}_buildEffectiveKw(){let e={...this._kw};if(this._node&&this._node.attr)for(let r of Object.keys(this._kw))Object.hasOwn(this._node.attr,r)&&(e[r]=this._node.attr[r]);return e}resolve(e={}){let{static:r=!1,...n}=e;if(r)return this._node?this._node._value:this.cachedValue;let i=this._buildEffectiveKw();if(Object.keys(n).length>0)return this._load({...i,...n},o=>this._prepareValue(o));let s=this._computeEffectiveFingerprint(i);return s===this._lastEffectiveFingerprint&&!this.expired?this.cachedValue:(this._lastEffectiveFingerprint=s,this._load(i,o=>this._finalize(o)))}_load(e,r){let n=Wh(this),i=()=>this.load(e);if(n)return Qh(i,n).then(r);let s=i();return s&&typeof s.then=="function"?s.then(r):r(s)}_finalize(e){return e=this._prepareValue(e),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_prepareValue(e){let r;return this._asBag===!0?r=!0:this._asBag===!1?r=!1:r=!this._readOnly,r&&e!==null&&e!==void 0&&(e=this._convertToBag(e)),e}_convertToBag(e){let r=t._BagClass;if(!r||e&&typeof e._htraverse=="function")return e;if(typeof e=="string"){if(e=e.trim(),e.startsWith("<")&&r.fromXml)return r.fromXml(e);if((e.startsWith("{")||e.startsWith("["))&&r.fromTytx)return r.fromTytx(e)}return e}static registerBagClass(e){t._BagClass=e}load(e){return null}};le._BagClass=null;var kr=class extends le{static classKwargs={cacheTime:0,readOnly:!1,asBag:!1,retryPolicy:null,callback:null};static classArgs=["callback"];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy","callback"]);constructor(e={}){typeof e=="function"&&(e={callback:e}),super(e),this._callback=e.callback||null}load(e){return this._callback?this._callback.call(this,e):null}};var vt=class t{constructor(e,r,n=null,i=null,s=null,o=null,a=null,l=!0){this.label=r,this._value=null,this._attr={},this._parentBag=null,this._resolver=null,this._nodeSubscribers={},this._onChangedValue=null,this.nodeTag=o,this.xmlTag=a,this._compiled=null,this.parentBag=e,i&&this.setAttr(i,!1,!0,l),n!==null&&this.setValue(n,!1),s&&(this.resolver=s)}get parentBag(){return this._parentBag}set parentBag(e){e===null&&this._value?.parentNode===this&&this._value.setBackref(),this._parentBag=e,e?.backref&&this._value&&typeof this._value._htraverse=="function"&&this._value.setBackref(this,e)}get value(){return this.getValue()}set value(e){this.setValue(e)}getValue(e=!1,r=null,n={}){if(r!==null){let i=K(`${r}::QS`);if(Array.isArray(i)){let s=i.length?i:Object.keys(this._attr),o=s.map(l=>{let u=this.getAttr(l);return!e&&u instanceof le?u.resolve():u}),a=l=>i.length===0?Object.fromEntries(s.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return o.some(l=>l&&typeof l.then=="function")?Promise.all(o).then(a):a(o)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");n={...n,...i}}}return this._resolver!==null?this._resolver.resolve({static:e,...n}):this._value}setValue(e,r=!0,n=null,i=null,s=!0,o=null,a=!1){e instanceof le?(this.resolver=e,e=null):e instanceof t&&(n=n||{},Object.assign(n,e._attr),e.resolver&&(this.resolver=e.resolver),e=e._value);let l=this._value;l!==e&&l?.parentNode===this&&l.setBackref(),this._value=e;let u=l!==this._value,c=r??!0,f=null;if(n!==null){let d={...this._attr};this.setAttr(n,!1,i,s);let p=this._buildAttrDiff(d,this._attr);f=Object.keys(p).length>0?p:null}r=c&&(u||f!==null);let h=f?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),r){let d=f!==null?{oldvalue:l,attrs_diff:f}:{oldvalue:l};for(let p of Object.values(this._nodeSubscribers))p({node:this,info:d,evt:h})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),r&&this._parentBag._onNodeChanged(this,[this.label],h,l,f,o,a))}replace(e){if(!(e instanceof t))throw new TypeError("BagNode.replace expects a BagNode");if(e===this)return this;let r=e.staticValue;r&&typeof r._htraverse=="function"&&(r=r.createChildBag().replace(r));let n=null;e.resolver&&(n=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),n._node=null,n._kw={...e.resolver._kw});let i=this._value,s={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=n,this.setValue(r,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(s,this._attr),l=Object.keys(a).length?a:null,u=i!==r||o!==n;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",f=l?{oldvalue:i,attrs_diff:l}:{oldvalue:i};for(let h of Object.values(this._nodeSubscribers))h({node:this,info:f,evt:c});this._parentBag!==null&&this._parentBag.backref&&this._parentBag._onNodeChanged(this,[this.label],c,i,l)}return this}get staticValue(){return this._value}set staticValue(e){this._value=e}get resolver(){return this._resolver}set resolver(e){this._resolver=e,e&&e.setNode&&e.setNode(this)}resetResolver(){if(!this._resolver)throw new Error("Cannot reset resolver: node has no resolver");this._resolver.reset(),this.setValue(null)}get attr(){return this._attr}getAttr(e=null,r=null){return e?e in this._attr?this._attr[e]:r:this._attr}_buildAttrDiff(e,r){let n={},i=new Set([...Object.keys(e),...Object.keys(r)]);for(let s of i){let o=s in e?e[s]:null,a=s in r?r[s]:null;o!==a&&(n[s]={old:o,new:a})}return n}setAttr(e=null,r=!0,n=!0,i=!0){let s=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=r&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(n?Object.assign(this._attr,s):this._attr={...s},i)for(let u of Object.keys(this._attr))this._attr[u]===null&&delete this._attr[u];if(r&&l!==null){let u=this._buildAttrDiff(l,this._attr);if(Object.keys(u).length>0&&o)for(let c of Object.values(this._nodeSubscribers))c({node:this,info:{attrs_diff:u},evt:"upd_attrs"});if(Object.keys(u).length>0&&this._parentBag!==null&&this._parentBag.backref){let c=r===!0?"true":String(r);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let r of e)if(typeof r=="string"&&r.includes(","))for(let n of r.split(","))delete this._attr[n.trim()];else delete this._attr[r]}hasAttr(e,r=null){return e in this._attr?r!==null?this._attr[e]===r:!0:!1}getInheritedAttributes(){let e={};return this._parentBag&&this._parentBag.parentNode&&(e=this._parentBag.parentNode.getInheritedAttributes()),{...e,...this._attr}}subscribe(e,r){this._nodeSubscribers[e]=r}unsubscribe(e){delete this._nodeSubscribers[e]}get compiled(){return this._compiled||(this._compiled={}),this._compiled}get isBranch(){return this._value!=null&&typeof this._value._htraverse=="function"}get position(){return this._parentBag===null?null:this._parentBag._nodes.index(this.label)}get fullpath(){if(this._parentBag!==null){let e=this._parentBag.fullpath;return e?`${e}.${this.label}`:this.label}return null}get parentNode(){return this._parentBag?this._parentBag.parentNode:null}attributeOwnerNode(e,r=null){let n=this;if(r===null)for(;n&&!(e in n._attr);)n=n.parentNode;else for(;n&&n._attr[e]!==r;)n=n.parentNode;return n}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof t)||this.label!==e.label)return!1;let r=Object.keys(this._attr),n=Object.keys(e._attr);if(r.length!==n.length)return!1;for(let i of r)if(this._attr[i]!==e._attr[i])return!1;return this._resolver!==null?this._resolver===e._resolver:this._value&&typeof this._value.equalTo=="function"?this._value.equalTo(e._value):this._value&&typeof this._value.isEqual=="function"?this._value.isEqual(e._value):this._value===e._value}diff(e){if(this.label!==e.label)return`Other label: ${e.label}`;let r=Object.keys(this._attr),n=Object.keys(e._attr);return r.length!==n.length||r.some(i=>this._attr[i]!==e._attr[i])?`attributes self:${JSON.stringify(this._attr)} --- other:${JSON.stringify(e._attr)}`:this._value!==e._value?`value self:${this._value} --- other:${e._value}`:null}toJson(e=!0){let r=this.value;return r&&typeof r.toJson=="function"&&(r=r.toJson(e,!0)),{label:this.label,value:r,attr:this._attr}}toString(){return`BagNode : ${this.label}`}};var Fr=class t{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(n=>n.label===e);let r=e.match(/^#(\d+)$/);if(r){let n=parseInt(r[1],10);return n<this._list.length?n:-1}if(r=e.match(/^#(\w*)=(.*)$/),r){let[,n,i]=r,s=i.includes("::")?K(i):i;return n?this._list.findIndex(o=>o.getAttr(n)===s):this._list.findIndex(o=>o._value===s)}return-1}_parsePosition(e){let r=this._list.length;if(e==null||e===">")return r;if(typeof e=="number")return e<0&&(e=r+e),Math.max(0,Math.min(e,r));if(e==="<")return 0;if(e.startsWith("#")){let n=this._parseSharpIndex(e.slice(1),e);return Math.min(n,r)}if(e.startsWith("<")){let n=e.slice(1);if(n.startsWith("#")){let s=this._parseSharpIndex(n.slice(1),e);return Math.min(s,r)}let i=this.index(n);if(i<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return i}if(e.startsWith(">")){let n=e.slice(1);if(n.startsWith("#")){let s=this._parseSharpIndex(n.slice(1),e);return Math.min(s+1,r)}let i=this.index(n);if(i<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return i+1}throw new Error(`Invalid node_position '${e}': unrecognized syntax`)}_parseSharpIndex(e,r){if(!/^-?\d+$/.test(e))throw new Error(`Invalid node_position '${r}': '${e}' is not an integer`);let n=parseInt(e,10);if(n<0)throw new Error(`Invalid node_position '${r}': negative index not allowed in '#n' syntax`);return n}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let r=this.index(e);return r>=0?this._list[r]:null}return this._dict[e]||null}set(e,r,n=">",i=null,s=null,o=null,a=!1,l=!0,u=null,c=!0,f=!1,h=null){let d=null;if(e.includes("?")&&([e,d]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(d){let m=d.split("&");if(m.length===1)i={[m[0]]:r};else{if(!Array.isArray(r)||r.length!==m.length)throw new Error("Wrong attributes assignment");i={};for(let g=0;g<m.length;g++)i[m[g]]=r[g]}r=null}let p=this._dict[e];if(p)h&&(p.nodeTag=h),o!==null&&(o===!1?p.resolver=null:p.resolver=o),d?p.setAttr(i,c,!0,l):p.setValue(r,c,i,a,l,u,f);else{let m=s&&s.nodeClass?s.nodeClass:vt;p=new m(s,e,d?null:r,i,o,h,null,l);let g=this._parsePosition(n);this._dict[e]=p,this._list.splice(g,0,p),c&&s&&s.backref&&s._onNodeInserted(p,g,null,u,f)}return f&&p.setValue(null,!1),p}pop(e){let r=this.get(e);if(r){delete this._dict[r.label];let n=this._list.indexOf(r);return n>=0&&this._list.splice(n,1),r}return null}has(e){return e in this._dict}get length(){return this._list.length}clear(){this._dict=Object.create(null),this._list=[]}keys(){return this._list.map(e=>e.label)}values(){return this._list.map(e=>e.getValue())}items(){return this._list.map(e=>[e.label,e.getValue()])}[Symbol.iterator](){return this._list[Symbol.iterator]()}move(e,r,n=!0){if(r<0)return;let i=Array.isArray(e)?e:[e];if(i.length===0||r>=this._list.length)return;let s=this._list[r].label;if(i.length>1){let o=[...i].sort((c,f)=>c-f),a=o[0]<r?1:0,l=[];for(let c=o.length-1;c>=0;c--){let f=o[c];if(f>=0&&f<this._list.length){let h=this._list[f];this._list.splice(f,1),l.push(h),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(h,f)}}let u=this.index(s);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=i[0];if(o===r||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(r,0,a),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,r)}}isEqual(e){if(!(e instanceof t)||this._list.length!==e._list.length)return!1;for(let r=0;r<this._list.length;r++){let n=this._list[r],i=e._list[r];if(!n.isEqual(i))return!1}return!0}};var Eu=ni(qi(),1);var ls="::RSLV:",Kh=new Map,ed=new Map,Zn=new WeakMap,Z=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Rr=class extends le{constructor(e){super({asBag:!1}),Zn.set(this,e)}get payload(){return Zn.get(this)}load(){throw new Z("This resolver is opaque; local execution is unavailable")}};function gu(t){if(!t||typeof t!="object"||Array.isArray(t)||typeof t.resolver_module!="string"||typeof t.resolver_class!="string"||!Array.isArray(t.args??[])||!t.kwargs||typeof t.kwargs!="object"||Array.isArray(t.kwargs))throw new Z("Invalid resolver description")}function yu(t,e=new Set){if(!(t===null||typeof t=="string"||typeof t=="boolean")&&!(typeof t=="number"&&Number.isFinite(t))){if(typeof t!="object"||e.has(t)||!Array.isArray(t)&&Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw new Z("Resolver parameters must be JSON data; callbacks cannot travel");e.add(t);for(let r of Object.values(t))yu(r,e);e.delete(t)}}function Lr(t){if(Zn.has(t))return Zn.get(t);let e=ed.get(t.constructor);if(!e)throw new Z(`Unregistered resolver: ${t.constructor.name}`);let r=e.encode(t),n={resolver_module:e.module,resolver_class:e.name,args:r.args??[],kwargs:r.kwargs??{}};return gu(n),yu(n),ls+JSON.stringify(n)}function Qn(t){if(typeof t!="string"||!t.startsWith(ls))return null;let e=t.slice(ls.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Rr(t);let r;try{r=JSON.parse(e)}catch{throw new Z("Invalid resolver JSON or signed token")}gu(r);let n=Kh.get(JSON.stringify([r.resolver_module,r.resolver_class]));if(!n)return new Rr(t);let i=n.decode({args:r.args??[],kwargs:r.kwargs});if(!(i instanceof n.cls))throw new Z("Resolver decoder returned an incompatible instance");return i}function Kn(t){return Object.fromEntries(Object.entries(t||{}).map(([e,r])=>[e,r instanceof le?Lr(r):r]))}function cs(t){return Object.fromEntries(Object.entries(t||{}).map(([e,r])=>[e,Qn(r)??r]))}var Se="__cls";function Zt(t,e){return t!==null&&t.tytxSuffix===e?t:Ji(e)}function td(t){let e=t.tytxSuffix,r=Object.entries(Gt(e)).filter(([,n])=>n===t).map(([n])=>n);if(r.length===0)throw new Z(`${t.name} is not in the TYTX subtype dictionary of '${e}'`);if(r.length>1)throw new Z(`${t.name} is in the TYTX subtype dictionary of '${e}' under several names: ${r.sort().join(", ")}`);return r[0]}function fs(t,e){let r=Gt(t);if(!Object.hasOwn(r,e))throw new Z(`Unknown Bag class '${e}' for TYTX type '${t}'`);return r[e]}function hs(t,e){return t===e?null:td(t)}function*bu(t,e=[]){for(let r of t){let n=[...e,r.label];yield[n,r];let i=r.getValue(!0);!r.resolver&&i instanceof Ne&&(yield*bu(i,n))}}function rd(t){let e=t.toISOString(),r=t.getUTCFullYear()===1970&&t.getUTCMonth()===0&&t.getUTCDate()===1,n=t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0;if(n&&!r)return e.slice(0,e.indexOf("T"));let i=e.replace(/\.000Z$/,"Z");return r&&!n?i.slice(i.indexOf("T")+1):i}function Qt(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function ot(t){return typeof t=="string"?t.includes("::")?`${t}::T`:t:Array.isArray(t)?t.map(ot):Qt(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,ot(r)])):t}function ds(t){if(!Qt(t))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=t;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var wu=!1,Ne=class t{static tytxSuffix="X";constructor(e=null,r={}){this._nodes=new Fr,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},ds(r),e!=null&&this.fillFrom(e,r)}get parent(){return this._parent}set parent(e){this._parent=e}get parentNode(){return this._parentNode}set parentNode(e){this._parentNode=e}get backref(){return!!this._backref}get nodeClass(){return vt}createChildBag(){return new this.constructor}get fullpath(){if(this._parent!==null&&this._parentNode!==null){let e=this._parent.fullpath;return e?`${e}.${this._parentNode.label}`:this._parentNode.label}return null}relativePath(e){let r=[],n=e;for(;n!==null;){if(n.parentBag===this)return r.push(n.label),r.reverse(),r.join(".");r.push(n.label),n=n.parentNode}return null}get length(){return this._nodes.length}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}get attributes(){return this._parentNode!==null?this._parentNode.getAttr():{}}get rootAttributes(){return this._rootAttributes}set rootAttributes(e){this._rootAttributes=e!==null?{...e}:null}_htraverseBefore(e){let r=this,n;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),n=e.split(".").filter(i=>i)):n=[...e];n.length&&n[0]==="#parent"&&r!==null;)n.shift(),r=r.parent;return[r,n]}_htraverse(e,r=!1,n=!0){let[i,s]=this._htraverseBefore(e);if(i===null)return[null,null];if(s.length===0)return[i,""];for(;s.length>1&&i instanceof t;){let o=s[0];if(o==="#parent"){if(i.parent===null||i.parent===void 0)break;s.shift(),i=i.parent;continue}let a=i._nodes.get(o);if(!a)break;let l=a.getValue(n);if(l instanceof t)s.shift(),i=l;else if(r){let u=i.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),s.shift(),i=u}else break}if(!r)return s.length>1?[null,null]:[i,s[0]];for(;s.length>1;){let o=s.shift();if(o.startsWith("#"))throw new Pr("Not existing index in #n syntax");let a=i.createChildBag();i._nodes.set(o,a,">",null,i,null,!1,!0,"autocreate"),i=a}return[i,s[0]]}get(e,r=null,n=!0,i={}){if(!e)return this;if(e==="#parent")return this.parent;let s=null;e.includes("?")&&([e,s]=e.split("?",2));let o=this._nodes.get(e);return o?o.getValue(n,s,i):r}getItem(e,r=null,n=!1,i={}){if(!e)return this;let[s,o]=this._htraverse(e,!1,n);return s instanceof t?s.get(o,r,n,i):r}setItem(e,r,n=null,i=">",s=!1,o=!0,a=null,l=!1,u=!0,c=null,f=null){if(e==="")throw new RangeError("setItem requires a non-empty path");let[h,d]=this._htraverse(e,!0);return h._nodes.set(d,r,i,n,h,c,s,o,a,u,l,f)}_pop(e,r=null){let n=this._nodes.index(e);if(n>=0){let i=this._nodes.pop(n);return this.backref&&this._onNodeDeleted(i,n,null,r),i}return null}pop(e,r=null,n=null){let i=this.popNode(e,n);return i?i.value:r}delItem(e,r=null,n=null){return this.pop(e,r,n)}popNode(e,r=null){let[n,i]=this._htraverse(e,!1,!0);if(!n||!i)return null;let s=n._nodes.get(i);if(!s)return null;try{return n._pop(i,r)}finally{s.parentBag===n&&n._nodes._dict[s.label]!==s&&(s.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let r of e)r.parentBag=null}getNode(e,r=!0,n=!1,i=null){if(e==null||e==="")return this.parentNode;if(typeof e=="number")return this._nodes.get(e);typeof e=="string"&&(e=e.split("?",1)[0]);let[s,o]=this._htraverse(e,n,r);if(s instanceof t&&o){let a=s._nodes.get(o);if(a)return a;if(n)return s._nodes.set(o,i,">",null,s,null,!1,!0,"autocreate"),s._nodes.get(o)}return null}setBackref(e=null,r=null){let n=this._backref;if(this._backref=!0,this._parent=r,this._parentNode=e,!n){this._nodes._parentBag=this;for(let i of this)i.parentBag=this}}delParentRef(){this._parent=null,this._parentNode=null,this._backref=!1}clearBackref(){if(this._backref){this._backref=!1,this._parent=null,this._parentNode=null,this._nodes._parentBag=null;for(let e of this){e.parentBag=null;let r=e.getValue(!0);r instanceof t&&r.clearBackref()}}}_onNodeChanged(e,r,n,i=null,s=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:r,oldvalue:i,attrs_diff:s,evt:n,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...r],n,i,s,o,a)}_onNodeInserted(e,r,n=null,i=null,s=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof t&&a.setBackref(e,o),n===null&&(n=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:n,ind:r,evt:"ins",reason:i,fired:s});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,r,[this._parentNode.label,...n],i,s)}_onNodeDeleted(e,r,n=null,i=null){for(let s of Object.values(this._delSubscribers))s({node:e,pathlist:n,ind:r,evt:"del",reason:i});this._parent&&this._parentNode&&(n===null&&(n=[]),this._parent._onNodeDeleted(e,r,[this._parentNode.label,...n],i))}_subscribe(e,r,n){n!=null&&(r[e]=n)}subscribe(e,r={}){if(Object.hasOwn(r,"timer")||Object.hasOwn(r,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=null,insert:i=null,delete:s=null,any:o=null}=r;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,n||o),this._subscribe(e,this._insSubscribers,i||o),this._subscribe(e,this._delSubscribers,s||o)}unsubscribe(e,r={}){if(Object.hasOwn(r,"timer")||Object.hasOwn(r,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=!1,insert:i=!1,delete:s=!1,any:o=!1}=r;(n||o)&&delete this._updSubscribers[e],(i||o)&&delete this._insSubscribers[e],(s||o)&&delete this._delSubscribers[e]}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}keys(){return this._nodes.keys()}values(){return this._nodes.values()}items(){return[...this._nodes].map(e=>({key:e.label,value:e.getValue()}))}get nodes(){return this.getNodes()}node(e){return this._nodes.get(e)}setAttr(e=null,r=null,n=!0){let i=t.prototype.getNode.call(this,e,!0,!0);i&&i.setAttr(r,!0,!0,n)}getAttr(e=null,r=null,n=null){let i=this.getNode(e);return i?i.getAttr(r,n):n}delAttr(e=null,...r){let n=this.getNode(e);n&&n.delAttr(...r)}getInheritedAttributes(){return this._parentNode?this._parentNode.getInheritedAttributes():{}}getNodes(e=null){return e?[...this._nodes].filter(r=>e(r)):[...this._nodes]}getNodeByValue(e,r){for(let n of this._nodes){let i=n.value;if(i instanceof t){if(i.getItem(e)===r)return n}else if(i&&i.get&&i.get(e)===r)return n}return null}getNodeByAttr(e,r,n=!1,i=!1){let s=r===void 0,o=n&&typeof r=="string"?r.toLowerCase():r,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let f=n&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(s||f==o)return c}if(c._value instanceof t)if(i){let f=a(c._value);if(f)return f}else u.push(c._value)}for(let c of u){let f=a(c);if(f)return f}return null};return a(this)}isEmpty(e=!1,r=!1){if(this._nodes.length===0)return!0;for(let n of this._nodes){if(n._resolver!==null)return!1;let i=n.getValue(!0);if(i!=null&&!(e&&i===0)&&!(r&&i===""))return!1}return!0}query(e=null,r=null,n=!1,i=!1,s=!0,o=!0,a=null,l=!0){e||(e="#k,#v,#a");let u=this,c;if(typeof e=="string"){if(e.includes(":")){let[d,p]=e.split(":");u=this.getItem(d),e=p}c=e.split(",").map(d=>d.trim())}else c=e;let f=(d,p,m,g,y)=>{if(p==="#k")return d.label;if(p==="#p")return m;if(p==="#n")return d;if(typeof p=="function")return p(d);if(p==="#v"){let E=y();return g&&E instanceof t?null:E}else if(p.startsWith("#v.")){let E=p.split(".").slice(1).join("."),w=y();return w&&w.getItem?w.getItem(E):null}else{if(p==="#__v")return d.getValue(!0);if(p.startsWith("#a")){let E=p.includes(".")?p.split(".").slice(1).join("."):null;return d.getAttr(E)}else{let E=y();return E&&E.getItem?E.getItem(p):null}}};function*h(){let d=0;function*p(m,g){for(let y of m._nodes){let E=g?`${g}.${y.label}`:y.label,w=!1,v,x=()=>(w||(v=y.getValue(l),w=!0),v);if((s&&o||(x()instanceof t?o:s))&&(r===null||r(y))&&(yield c.length===1?f(y,c[0],E,i,x):c.map(b=>f(y,b,E,i,x)),d++,a!==null&&d>=a))return;if(i){let b=x();if(b instanceof t&&(yield*p(b,E),a!==null&&d>=a))return}}}yield*p(u,"")}return n?h():[...h()]}getLeaves(){let e=[],r=(n,i)=>{for(let s of n._nodes){let o=i?`${i}.${s.label}`:s.label,a=s.getValue(!1);a instanceof t?r(a,o):e.push([o,a])}};return r(this,""),e}digest(e=null,r=null,n=!1){typeof r=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),n=r,r=null);let i=this.query(e,r,!1,!1,!0,!0,null,!1);if(n){if(!i||i.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let s=[...i];if(s.length&&Array.isArray(s[0])){let o=s[0].length,a=[];for(let l=0;l<o;l++)a.push(s.map(u=>u[l]));return a}return[s]}return[...i]}columns(e,r=!1){typeof e=="string"&&(e=e.split(","));let n=r?"#a.":"",i=e.map(s=>`${n}${s}`).join(",");return this.digest(i,null,!0)}sum(e="#v",r=!1,n=null){if(r!=null&&typeof r!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(n!=null&&typeof n!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let i=s=>{let o=0,a=!1;for(let l of this.query(s,n)){if(l==null||l===""){a=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(r)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}o+=l}return r&&a?null:o};return e.includes(",")?e.split(",").map(s=>i(s.trim())):i(e)}sort(e="#k:a"){let r=(i,s)=>i==null?[-1,""]:s&&typeof i=="string"?[0,i.toLowerCase()]:[0,i],n=(i,s)=>i[0]!==s[0]?i[0]-s[0]:i[1]<s[1]?-1:i[1]>s[1]?1:0;if(typeof e=="function")this._nodes._list.sort((i,s)=>{let o=e(i),a=e(s);return o<a?-1:o>a?1:0});else{let i=e.split(",");i.reverse();for(let s of i){let o,a;s.includes(":")?[o,a]=s.split(":",2):(o=s,a="a"),o=o.trim(),a=a.trim();let l=a==="d"||a==="D",u=a==="a"||a==="d",c;if(o.toLowerCase()==="#k")c=f=>r(f.label,u);else if(o.toLowerCase()==="#v")c=f=>r(f.value,u);else if(o.toLowerCase().startsWith("#a.")){let f=o.slice(3);c=h=>r(h.getAttr(f),u)}else c=f=>{let h=f.value,d=h instanceof t?h.getItem(o):h?h[o]:null;return r(d,u)};this._nodes._list.sort((f,h)=>{let d=n(c(f),c(h));return l?-d:d})}}return this}equalTo(e){return e instanceof t?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let r=null;e.includes("?")&&([e,r]=e.split("?",2));let n=this.getNode(e);return n===null?!1:r===null?!0:r.split("&").every(i=>i in n.attr)}else if(e&&e.label!==void 0)return[...this._nodes].includes(e);return!1}getResolver(e){let r=this.getNode(e);return r?r.resolver:null}setResolver(e,r){let n=this.getNode(e);n||(this.setItem(e,null),n=this.getNode(e)),n.resolver=r}setCallbackItem(e,r,n={}){let i=new kr({callback:r,...n});this.setResolver(e,i)}move(e,r,n=!0){this._nodes.move(e,r,n)}asDict(e=!1,r=!1,n=!1,i=!1){let s={};for(let o of this._nodes){let a=o.value;if(i&&a==null)continue;let l=o.label;e&&(l=String(l)),r&&(l=l.toLowerCase()),n&&a instanceof t&&(a=t.prototype.asDict.call(a,e,r,n,i)),Object.defineProperty(s,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return s}setdefault(e,r=null){let n=this.getNode(e);return n?n.value:(this.setItem(e,r),r)}deepcopy(e=!1){let r=this.createChildBag();for(let n of this._nodes){let i=n.getValue(!e);i instanceof t&&(i=i.deepcopy(e));let s=new r.nodeClass(r,n.label,i);s.setAttr({...n.attr},!1,!1,!1),s.nodeTag=n.nodeTag,s.xmlTag=n.xmlTag,r._nodes._list.push(s),r._nodes._dict[s.label]=s}return r}update(e,r=null,n=null,i=!1){if(!(e instanceof t)){for(let s in e){let o=e[s];(!i||o!==null||!this._nodes.has(s))&&this.setItem(s,o,null,">",!1,!1,n,!1,n!==!1)}return}for(let s of[...e]){let o=s.label,a=r==="static"?s.resolver:null,l=a?null:s.getValue(),u=s.attr.__replace;delete s.attr.__replace;let c=this._nodes.get(o);if(c)if(c.setAttr(s.attr,n===null?!0:n,!0,!1),s.nodeTag!=null&&(c.nodeTag=s.nodeTag),s.xmlTag!=null&&(c.xmlTag=s.xmlTag),a)c.resolver=a,c.setValue(null,n===null?!0:n,null,null,!1,n);else{s.resolver&&(c.resolver=null);let f=c.getValue();l instanceof t&&f instanceof t&&!u?f.update(l,r,n,i):(!i||l!==null)&&c.setValue(l,n===null?!0:n,null,null,!1,n)}else{let f=this.setItem(o,a||l,s.attr,">",!1,!1,n,!1,n!==!1);f.nodeTag=s.nodeTag,f.xmlTag=s.xmlTag}}}_fillFromBag(e){this.clear();for(let r of e){let n=new this.nodeClass(this,r.label);n.replace(r),n.nodeTag=r.nodeTag,n.xmlTag=r.xmlTag,this._nodes._list.push(n),this._nodes._dict[n.label]=n}}_appendLiteral(e,r,n=null,i=null,s=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let o=new this.nodeClass(this,e,null,n,i,s,null,!1);return r instanceof le?o.resolver=r:o._value=r,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,r={}){let n=ds(r);if(e!=null&&!Qt(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let i=this.createChildBag(),s=new Set,o=(a,l,u)=>{if(s.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);s.add(l);try{let c=Array.isArray(l)?String(l.length).length+1:0,f=Array.isArray(l)?Array.from(l,(h,d)=>[`r_${String(d).padStart(c,"0")}`,h]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(h=>Object.prototype.propertyIsEnumerable.call(l,h)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[h,d]of f){let p=d;n&&(Qt(p)||Array.isArray(p))&&(p=this.createChildBag(),o(p,d,`${u}[${JSON.stringify(h)}]`)),a._appendLiteral(h,p)}}finally{s.delete(l)}};return e!=null&&o(i,e,"$"),this._replacePrepared(i)}_loadSource(e,r={}){return this.fillFrom(e,r)}replace(e){if(!(e instanceof t))throw new TypeError("Bag.replace expects a Bag");if(e===this)return this;let r=this.createChildBag();return r._fillFromBag(e),this._replacePrepared(r)}_replacePrepared(e){for(let n of this._nodes){n.parentBag=null;let i=n.getValue(!0);i instanceof t&&i.clearBackref()}let r=this._nodes;this._nodes=e._nodes,e._nodes=r,this._nodes._parentBag=this.backref?this:null,e._nodes._parentBag=null;for(let n of this._nodes)n.parentBag=this;for(let n of e._nodes)n._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:r=!0,deep:n=!1,kwargs:i={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let s=(o,a)=>{for(let l=0;l<o._nodes.length;l++){let u=o._nodes._list[l],c={...a};"_pathlist"in a&&(c._pathlist=[...a._pathlist,u.label]),"_indexlist"in a&&(c._indexlist=[...a._indexlist,l]);let f=e(u,c,l);if(f)return f;if(f==null&&n){let h=u.getValue(r);if(h instanceof t){let d=s(h,c);if(d)return d}}}return null};return s(this,i)}*traverse(){for(let e of this._nodes){yield e;let r=e.getValue(!0);r instanceof t&&(yield*r.traverse())}}*_iterNodesWithPaths(e=!0,r=""){for(let n of this._nodes){let i=r?`${r}.${n.label}`:n.label;yield[i,n];let s=n.getValue(e);s instanceof t&&(yield*s._iterNodesWithPaths(e,i))}}*_nodeFlattener(e=null){let r=e!==null,n=r?Object.create(null):null,i=0,s=new Map([["[]",this.constructor]]);for(let[o,a]of bu(this)){let l=o.slice(0,-1),u=JSON.stringify(o),c=JSON.stringify(l),f=a.getValue(!0),h,d=null;if(a.resolver)h=Lr(a.resolver);else if(f instanceof t){let g=f.constructor,y=g.tytxSuffix;s.set(u,g),d=hs(g,Zt(s.get(c),y)),h=`::${y}`}else f===null?h="::NN":h=ot(f);if(a.attr&&Object.hasOwn(a.attr,Se))throw new Z(`node '${o}': the attribute '${Se}' is reserved for the Bag class name`);let p=Kn(ot(a.attr));d!==null&&(p[Se]=d);let m=a.nodeTag;r?(yield[l.length?n[c]:null,a.label,m,h,p],f instanceof t&&(n[u]=i,e[i]=o,i++)):yield[l,a.label,m,h,p]}}toTytx(e="json",r=!1){let n=this._toTytxPayload(r),i=this.constructor.tytxSuffix;if(e==="json")return`${n}::${i}`;if(e==="msgpack")return Kr(new Ce(4,new TextEncoder().encode(`${i}:${n}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let r;if(e){let s={};r={rows:[...this._nodeFlattener(s)],paths:s}}else r={rows:[...this._nodeFlattener(null)]};let n=this.constructor,i=hs(n,Zt(null,n.tytxSuffix));return i!==null&&(r[Se]=i),r.rows=r.rows.map(([s,o,a,l,u])=>[ot(s),ot(o),ot(a),l,u]),r.paths&&(r.paths=ot(r.paths)),xe(r)}static fromTytx(e,r="json",n={}){if(Qt(r)&&(n=r,r="json"),ds(n),typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError("fromTytx requires serialized text or bytes");if(r!=="json"&&r!=="msgpack")throw new TypeError(`Unsupported transport: ${r}`);r==="json"&&e instanceof Uint8Array&&(e=new TextDecoder().decode(e));let i=K(e,r==="json"?null:r);if(i instanceof t)return i;if(!Qt(i)&&!Array.isArray(i))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(i,n)}static _fromTytxPayload(e){let r=this.tytxSuffix;if(e==="")return new(Zt(null,r));let n=K(e);if(!n||!Array.isArray(n.rows))throw new Z("Invalid TYTX Bag: expected rows");let i=n.paths,s=i!=null,o=Object.hasOwn(n,Se)?fs(r,n[Se]):Zt(null,r),a=new o,l=new Map([["[]",a]]);for(let u of n.rows){if(!Array.isArray(u)||u.length!==5)throw new Z("Invalid TYTX Bag row");let[c,f,h,d,p]=u,m=c??"";if(s){if(c!==null&&!Object.hasOwn(i,c))throw new Z(`Unknown TYTX parent reference: ${c}`);m=c===null?"":i[c]}if(typeof m=="string"&&(m=m?m.split("."):[]),!Array.isArray(m))throw new Z("Invalid TYTX parent path");let g=JSON.stringify(m);if(!l.has(g))throw new Z(`Missing or undecodable TYTX parent branch: ${m}`);let y=l.get(g),E=JSON.stringify([...m,f]),w=d,v=Qn(w),x=cs(p),T=Object.hasOwn(x,Se)?x[Se]:null;if(delete x[Se],w instanceof t){let C=w.constructor.tytxSuffix,I=T!==null?fs(C,T):Zt(y.constructor,C);w=new I,l.set(E,w)}else if(T!==null)throw new Z(`node '${E}': the attribute '${Se}' is reserved for the Bag class name of a branch`);let b=y._appendLiteral(f,v?null:w,x,v);b.nodeTag=h??null}return a}toXml(e={}){let{pretty:r=!1,encoding:n="UTF-8",docHeader:i=null,selfClosedTags:s=null}=e,o=this._bagToXml(s,r);return i===!0?o=`<?xml version='1.0' encoding='${n}'?>
41
- ${o}`:typeof i=="string"&&(o=`${i}
42
- ${o}`),o}_bagToXml(e=null,r=!1,n=0){let i=[];for(let s of this._nodes)i.push((r?" ".repeat(n):"")+this._nodeToXml(s,e,r,n));return i.join(r?`
43
- `:"")}_nodeToXml(e,r=null,n=!1,i=0){let s=e.xmlTag||e.nodeTag||e.label,o=this._sanitizeTag(s),a=[];if(o!==s&&a.push(`_tag="${this._escapeAttr(s)}"`),e.resolver&&a.push(`_resolver="${this._escapeAttr(Lr(e.resolver))}"`),e.attr)for(let[h,d]of Object.entries(Kn(e.attr)))d!==null&&d!==!1&&d!==void 0&&a.push(`${h}="${this._escapeAttr(String(d))}"`);let l=a.length?" "+a.join(" "):"",u=e.resolver?null:e.getValue(!0);if(u&&typeof u._bagToXml=="function"){n=n&&e.attr?.["xml:space"]!=="preserve";let h=u._bagToXml(r,n,i+1);return h?n?`<${o}${l}>
40
+ .js-plotly-plot .crisp{shape-rendering:crispEdges}`,this.#e.parentElement.append(this.#o));let s=this.#e.getBoundingClientRect();await qr.react(this.#e,r.data,{...r.layout,width:Math.max(1,s.width),height:Math.max(1,s.height)},{displayModeBar:!1,responsive:!1,displaylogo:!1,scrollZoom:e.type.id==="map"}),this.#i?qr.purge(this.#e):(this.#l=!0,this.#n=e.type.id,this.#r||(this.#e.on("plotly_click",a=>{let l=a.points[0];this.#n==="map"&&l?.data.type==="choropleth"&&this.#t.onTerritorySelect?.(l.location)}),this.#e.on("plotly_afterplot",()=>this.#c()),this.#r=!0),this.#c())},o=this.#s.then(i);return this.#s=o.catch(()=>{}),o}#c(){if(this.#n!=="map"||this.#i)return;let e=[],r=this.#e.getBoundingClientRect();for(let n of this.#e.querySelectorAll(".scattergeo text")){n.style.visibility="visible",n.style.pointerEvents="none";let i=n.getBoundingClientRect(),o=e.some(a=>i.left<a.right+4&&i.right>a.left-4&&i.top<a.bottom+2&&i.bottom>a.top-2),s=i.left<r.left||i.right>r.right||i.top<r.top||i.bottom>r.bottom;o||s?n.style.visibility="hidden":n.textContent&&e.push(i)}}render_bar(e){return this.#a(e,{type:"bar"})}render_line(e){return this.#a(e,{type:"scatter"})}render_area(e){return this.#a(e,{type:"scatter",area:!0})}render_stackedBar(e){return this.#a(e,{type:"bar",stacked:!0})}render_stackedArea(e){return this.#a(e,{type:"scatter",area:!0,stacked:!0})}render_horizontalBar(e){return this.#a(e,{type:"bar",horizontal:!0})}render_pie(e){return this.#f(e,!1)}render_donut(e){return this.#f(e,!0)}render_scatter(e){return this.#a(e,{type:"scatter",points:!0})}render_line3D(e){return ti(e,"line3D",this.#u())}render_scatter3D(e){return ti(e,"scatter3D",this.#u())}render_surface(e){return ti(e,"surface",this.#u())}render_map(e){return Ou(e,this.#u())}#a({view:e,category:r,fields:n,settings:i,domains:o},{type:s,area:a=!1,stacked:l=!1,horizontal:u=!1,points:c=!1}){let{source:f,kind:h}=oe(e,r,n,o?.dimension);if(c&&!["value","time"].includes(h))throw new TypeError("Scatter needs a numeric or date dimension. Choose another column.");if(l&&new Set(i.map(w=>w.axis)).size>1)throw new TypeError("Stacked series need the same scale. Assign all selected measures to the same axis.");if(l&&new Set(f.map(w=>w[0])).size!==f.length)throw new TypeError("Plotly stacked series require distinct X values. Prepare the store upstream. Configuration retained.");if(l&&a&&f.some(w=>w.slice(1).some(b=>b<0)))throw new TypeError("Plotly stacked areas do not implement separate positive/negative stacks. Choose another type or engine. Configuration retained.");let d=f.map(w=>h==="time"?new Date(w[0]).toISOString():w[0]),g=this.#u(),p=u?"y":"x",y=u?"x":"y";g.barmode=l?"relative":"group",g[p+"axis"]={type:h==="time"&&!u?"date":h==="category"||s==="bar"?"category":"linear",automargin:!0};for(let[w,b]of["left","right"].entries())g[y+"axis"+(w?"2":"")]={side:u?w?"top":"bottom":b,visible:i.some(v=>v.axis===b),automargin:!0,title:{text:n.filter((v,x)=>i[x].axis===b).join(", ")},...w?{overlaying:y}:{},rangemode:"tozero"};if(o){let w=g[p+"axis"];w.type==="category"?(w.categoryorder="array",w.categoryarray=o.dimension.values.map(b=>h==="time"?new Date(b).toISOString():b),w.range=[-.5,w.categoryarray.length-.5]):w.range=o.dimension.range.map(b=>h==="time"?new Date(b).toISOString():b),w.autorange=!1;for(let[b,v]of["left","right"].entries())Object.assign(g[y+"axis"+(b?"2":"")],{range:o.axes[v],autorange:!1})}return{data:n.map((w,b)=>({type:s,name:w,[p]:[...d],[y]:f.map(v=>v[b+1]),[y+"axis"]:y+(i[b].axis==="right"?"2":""),marker:{color:i[b].color},...s==="scatter"?{mode:c?"markers":f.length===1?"lines+markers":"lines",line:{color:i[b].color},...a?{fill:l?"tonexty":"tozeroy",fillcolor:i[b].color+"4d"}:{},...l?{stackgroup:"measures",stackgaps:"infer zero"}:{}}:{orientation:u?"h":"v",...l?{}:{offsetgroup:w},alignmentgroup:"measures"}})),layout:g}}#f({view:e,category:r,fields:n,domains:i},o){let{source:s,kind:a}=oe(e,r,n,i?.dimension),l=s.map(u=>a==="time"?new Date(u[0]).toISOString().slice(0,10):String(u[0]));if(new Set(l).size!==s.length)throw new TypeError("Plotly pie/donut requires distinct category labels. Prepare the store upstream or choose another engine. Configuration retained.");if(s.some(u=>u[1]<0))throw new TypeError("Pie and donut require nonnegative values. Configuration retained.");return{layout:this.#u(),data:n.map(u=>({type:"pie",name:u,sort:!1,hole:o?.5:0,labels:l,...i?{marker:{colors:l.map(c=>X[i.labels.indexOf(c)%X.length])}}:{},values:s.map(c=>c[1]),textposition:"inside",textinfo:"label+percent",automargin:!0}))}}#u(){return{paper_bgcolor:"#fff",plot_bgcolor:"#fff",font:{color:"#333"},showlegend:!0,margin:{l:70,r:70,t:40,b:75},legend:{orientation:"h",y:-.18,x:0},autosize:!0}}resize(){if(this.#i||!this.#l)return;let e=this.#e.getBoundingClientRect();if(this.#e.layout.width===Math.round(e.width)&&this.#e.layout.height===Math.round(e.height))return;let r=()=>{if(this.#i)return;let n=this.#e.getBoundingClientRect();return qr.relayout(this.#e,{width:Math.max(1,Math.round(n.width)),height:Math.max(1,Math.round(n.height))})};this.#s=this.#s.then(r).catch(()=>{})}dispose(){this.#i=!0,this.#o?.remove(),this.#l&&qr.purge(this.#e)}};var ir={echarts:ei,plotly:ri,vega:jn,uplot:Hn};function Td(t){let e=ir[t];if(!Object.hasOwn(ir,t))throw new TypeError(`Unknown chart engine: ${t}`);return e}function ni(t){return Object.getOwnPropertyNames(t.prototype).filter(e=>e.startsWith("render_")&&typeof t.prototype[e]=="function").map(e=>e.slice(7))}function Do(t,e){let r=Td(t);if(!ni(r).includes(e))throw new TypeError(`${r.label} does not support ${e}. Choose another type or engine. Configuration retained.`);return r}function Mu(t,{configpath:e,storepath:r,rowMode:n,prefix:i}){let o={};function s(m,w,b,v,x,T=`${i}-${b}`){m.html_label(w,{for:T});let E={id:T,value:`^${e}.${b}`};x&&(E.nodeId=`${i}_${x}`,o[x]=E.nodeId);let C=m.select(E);for(let[M,I]of v){let _={value:M};if(b==="timeStep"&&["minute","hour"].includes(M))_.disabled=`^${e}.timeHasClock:=!{}`;else if(b==="chartType"){let P=Object.entries(ir).filter(([,K])=>ni(K).includes(M)).map(([K])=>K);_.disabled=`^${e}.engine:=!${JSON.stringify(P)}.includes({})`,_.hidden=_.disabled}else if(b==="engine"){let P=ni(ir[M]);_.disabled=`^${e}.chartType:=!${JSON.stringify(P)}.includes({})`,_.hidden=_.disabled}C.option(I,_)}return C}let a=[["","No columns"]];s(t,"Engine","engine",Object.entries(ir).map(([m,w])=>[m,w.label])),s(t,"Chart type","chartType",ye.map(m=>[m.id,m.label]));let l=t.details({id:`${i}-animation`});l.summary("Temporal animation");let u=l.div({display:"grid",gap:"4px"});s(u,"Date field","timeField",[["","Off"]],"timeFieldId");let c=u.div({display:`^${e}.timeField:={} ? 'grid' : 'none'`,gap:"4px"});s(c,"Period","timeStep",[["auto","Automatic"],["minute","Minute"],["hour","Hour"],["day","Day"],["week","Week \xB7 Mon\u2013Sun"],["month","Month"],["year","Year"]]),s(c,"Empty periods","timeEmpty",[["previous","Keep previous snapshot"],["empty","Show empty"]]);let f=c.div();f.span("Current period (UTC): "),f.span(`^${e}.timeUnit`),c.html_label("Seconds per frame",{for:`${i}-time-speed`}),c.numberTextBox({id:`${i}-time-speed`,value:`^${e}.timeSpeed`,min:.1,max:10}),t.chartTimeline({storepath:r,rowMode:n,configpath:e,timeField:`^${e}.timeField`,timeStep:`^${e}.timeStep`,timeIndex:`^${e}.timeIndex`});let h={category(m){s(m,"Category / territory field","captionField",a,"categoryId")},geoJSON(m){m.chartGeoJSON({value:`^${e}.geoJSON`}),m.div("Link the category / territory field to GeoJSON properties.name.",{style:"font-size:11px"})},mapMeasure(m){s(m,"Map measure","mapValueField",[["","No measures"]],"mapMeasureId"),s(m,"Map label field","mapLabelField",a,"mapLabelId"),s(m,"Map labels","mapLabelMode",[["none","None"],["name","Names"],["value","Values"],["nameValue","Names and values"]]),m.div("Calculated measures must be supplied as store columns.",{style:"font-size:11px"})},mapBarScale(m){s(m,"Height scale","mapBarScale",[["zero","From zero"],["extent","Data range"]]),m.div("Selected measures share one height scale. Data range truncates the baseline; tooltip values are unchanged.",{style:"font-size:11px"})},secondDimension(m){s(m,"Second dimension","secondCaptionField",a,"secondCategoryId")},geometry(m){s(m,"Coordinate field","geometryField",a,"geometryId")},measures(m){let w=m.menu({presentation:"bar",aria_label:"Measures toolbar"}).menuline({caption:"Measures",aria_label:"Choose measures"}).menu({nodeId:`${i}_measureMenuId`});o.measureMenuId=`${i}_measureMenuId`,w.menuline({caption:"No measures",disabled:!0});let v=m.grid({id:`${i}-measures`,storepath:`${e}.seriesOptions`,rowMode:"values",height:"120px",style:"--gramlot-grid-row-height:24px;--gramlot-grid-font-size:12px;--gramlot-grid-cell-padding:2px 5px",filter:{value:"^true",columns:["selected"],dtype:"T"}}).struct();v.column({field:"caption",name:"Measure",width:"40%"}),v.column({field:"color",name:"Color",width:"30%",edit:{tag:"colorpicker"}}),v.column({field:"axis",name:"Axis",width:"30%",edit:{tag:"filteringSelect",values:"left:Left,right:Right",validate_select:!0}})}},d={category:m=>ct(m,"captionField").length>0,secondDimension:m=>ct(m,"secondCaptionField").length>0,geometry:m=>ct(m,"geometryField").length>0,mapMeasure:m=>ct(m,"mapValueField").length>0,measures:m=>ct(m,"valueFields").some(w=>w.count==="many"),geoJSON:m=>m.controls.includes("geoJSON"),mapBarScale:m=>m.controls.includes("mapBarScale")},g=m=>`^${e}.chartType:=${JSON.stringify(m)}.includes({}) ? "grid" : "none"`;for(let[m,w]of Object.entries(h)){let b=t.div({display:g(ye.filter(d[m]).map(v=>v.id)),gap:"4px"});w(b)}let p=new Map;for(let m of ye)for(let w of tr(m))p.has(w)||p.set(w,{role:ct(m,"valueFields").find(b=>b.name===w),types:[]}),p.get(w).types.push(m.id);let y=[];for(let[m,{role:w,types:b}]of p){let v=t.div({display:g(b),gap:"4px"});s(v,w.caption,`measureRoles.${m}`,[["","Choose a column"]],`measureRole_${m}`,`${i}-role-${m}`),y.push(o[`measureRole_${m}`]),delete o[`measureRole_${m}`]}t.chartFields({storepath:r,rowMode:n,configpath:e,measureRoleIds:y.join(","),...o})}var Bu=(0,G.defineComponent)({name:"chartPane",tag:"gramlot-chart-pane",base:Be,sourceContext:!0,subTags:"*",parameters:{configDefaults:{dtype:"X",nullable:!0},storepath:{dtype:"T"},configpath:{dtype:"T"},rowMode:{dtype:"T",default:"attributes"},gridId:{dtype:"T",nullable:!0}},implementation:t=>class extends t{#e;#t=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}connectedCallback(){if(this.#t)return;let e=this.#e.sourceNode;if(e.value!==null&&e.value.getNode("frame"))return;let r=e.absDatapath(this.parameters.storepath),n=e.absDatapath(this.parameters.configpath),i=e.getRelativeData(n);i==null&&(i=new or,e.setRelativeData(n,i));let o=this.parameters.configDefaults;if(o!=null){if(!(o instanceof or))throw new TypeError("configDefaults requires a Bag");let E=Ad(Cd(o));for(let C of E.getNodes())i.getNode(C.label)||i.setItem(C.label,C.getValue())}if(!(i instanceof or))throw new TypeError("chartPane requires a configuration Bag");let s={mapLabelMode:"value",mapBarScale:"zero",selectedTerritory:"",timeField:"",timeEmpty:"previous",timeSnapshotLabel:"",timeStep:"auto",timeUnit:"month",timeHasClock:!1,timeIndex:0,timeMax:0,timeAtEnd:!0,timeValue:null,timeLabel:"",timePlaying:!1,timeSpeed:.8,engine:"echarts",chartType:"bar",captionField:"",secondCaptionField:"",geometryField:"",mapValueField:"",mapLabelField:"",geoJSON:null,drawer:"close"};for(let[E,C]of Object.entries(s))i.getNode(E)||i.setItem(E,C);if(i.getNode("seriesOptions")||i.setItem("seriesOptions",new or),i.getNode("measureRoles")||i.setItem("measureRoles",new or),!(i.getItem("seriesOptions")instanceof or))throw new TypeError("seriesOptions must be a Bag");let a=new e.builder.source.constructor(null,e.builder),l=e.builder.wrapSource(a).framePane({node_label:"frame",height:"100%"}),u=JSON.stringify(Object.fromEntries(ye.map(E=>[E.id,tr(E)]).filter(([,E])=>E.length)));l.dataFormula({result_path:`${n}.valueFields`,formula:`(${u}[type] ?? null) ? ${u}[type].map(name => roles.getItem(name) || '').filter(Boolean).join(',') : options.getNodes().filter(n => n.getValue().getItem('selected')).map(n => n.label).join(',')`,options:`^${n}.seriesOptions`,roles:`^${n}.measureRoles`,type:`^${n}.chartType`,_onBuilt:!0});let c=l.top.contentPane({display:"flex",justify_content:"flex-end",align_items:"center",padding:"2px 6px"}),f=JSON.stringify(`${n}.drawer`);c.button({icon:"\u2699",aria_label:"Chart settings",title:"Chart settings",action:`this.SET(${f},this.GET(${f}) === 'close' ? true : 'close');`});let h=e.getAttr("id")??`chart-${Je()}`,d=l.center.borderContainer({id:`${h}-layout`,height:"100%"}),g=d.contentPane({region:"right",width:"260px",drawer:`^${n}.drawer`,drawer_style:"display:none",detachable:!0,title:"Chart configuration",padding:"8px",border_left:"1px solid var(--gramlot-border)",background:"var(--gramlot-surface)",overflow:"auto",display:"grid",gap:"4px",align_content:"start",style:"font-size:12px;--gramlot-field-height:26px;--gramlot-field-padding:2px 5px;--gramlot-grid-row-height:26px"}),p={id:`${h}-view`,configpath:n,storepath:r,rowMode:this.parameters.rowMode};for(let E of["mapLabelMode","mapBarScale","selectedTerritory","timeEmpty","timeField","timeValue","timeStep","engine","mapValueField","mapLabelField","geoJSON","geometryField","chartType","captionField","secondCaptionField","valueFields","seriesOptions"])p[E]=`^${n}.${E==="timeStep"?"timeUnit":E}`;this.parameters.gridId&&(p.gridId=this.parameters.gridId),d.contentPane({region:"center",min_width:"0"}).chartView(p),Mu(g,{configpath:n,storepath:r,rowMode:this.parameters.rowMode,prefix:h}),l.dataFormula({result_path:`${n}.timeInterval`,formula:"playing ? speed : 0",playing:`^${n}.timePlaying`,speed:`^${n}.timeSpeed`,_onBuilt:!0}),l.dataController({func:La(e.rootBuilder.binding),configpath:n,_timing:`^${n}.timeInterval`}),l.dataFormula({result_path:`${n}.timeAtEnd`,formula:"index >= max",index:`^${n}.timeIndex`,max:`^${n}.timeMax`,_onBuilt:!0});let y=l.bottom.contentPane({display:`^${n}.timeField:={} ? 'flex' : 'none'`,align_items:"center",flex_wrap:"wrap",gap:"10px",padding:"8px 12px",role:"toolbar",aria_label:"Playback controls",background:"var(--gramlot-surface-subtle)",border_top:"1px solid var(--gramlot-border)"}),m=E=>JSON.stringify(`${n}.${E}`),w=y.div({display:"flex",align_items:"center",gap:"2px",flex_shrink:"0"});w.button({icon:"\u2190",aria_label:"Previous period",title:"Previous period",id:`${h}-time-previous`,disabled:`^${n}.timeIndex:={} <= 0`,action:`this.SET(${m("timePlaying")},false);this.SET(${m("timeIndex")},Math.max(0,this.GET(${m("timeIndex")})-1));`}),w.button({icon:`^${n}.timePlaying:={} ? '\u23F8\uFE0E' : '\u25B6'`,aria_label:`^${n}.timePlaying:={} ? 'Pause' : 'Play'`,title:`^${n}.timePlaying:={} ? 'Pause' : 'Play'`,aria_pressed:`^${n}.timePlaying`,id:`${h}-time-play`,disabled:`^${n}.timeMax:={} === 0`,action:`if(!this.GET(${m("timePlaying")}) && this.GET(${m("timeIndex")}) >= this.GET(${m("timeMax")}))this.SET(${m("timeIndex")},0);this.SET(${m("timePlaying")},!this.GET(${m("timePlaying")}));`}),w.button({icon:"\u25A0",aria_label:"Stop",title:"Stop and return to the beginning",id:`${h}-time-stop`,disabled:`^${n}.timeMax:={} === 0`,action:`this.SET(${m("timePlaying")},false);this.SET(${m("timeIndex")},0);`}),w.button({icon:"\u2192",aria_label:"Next period",title:"Next period",id:`${h}-time-next`,disabled:`^${n}.timeAtEnd`,action:`this.SET(${m("timePlaying")},false);this.SET(${m("timeIndex")},Math.min(this.GET(${m("timeMax")}),this.GET(${m("timeIndex")})+1));`}),y.div({flex:"1",min_width:"120px"}).horizontalSlider({width:"100%",id:`${h}-time-slider`,aria_label:"Temporal snapshot",value:`^${n}.timeIndex`,min:0,max:`^${n}.timeMax`,step:1,live:!0,flex:"1",connect_oninput:`this.SET(${m("timePlaying")},false);`});let v=y.div({display:"grid",gap:"2px",white_space:"nowrap",text_align:"right",font_size:"12px",font_variant_numeric:"tabular-nums"});v.span(`^${n}.timeLabel`,{id:`${h}-time-label`,font_weight:"600"}),v.small(`^${n}.timeSnapshotLabel`,{id:`${h}-snapshot-label`,color:"var(--gramlot-text-secondary)",display:`^${n}.timeSnapshotLabel:={} ? '' : 'none'`});let x=e.rootBuilder.binding.gramlot,T=x.src.prepareSource(a);x.src.renderer.validateCandidate(T),this.#t=!0,e.setValue(T)}}});import{Bag as Bo}from"@gramlot/gramlot";var vo=class{#e=new Set;view=null;#t;columns=[];update(e,r){if(!(this.view===e&&this.#t===e.bag&&this.columns===r)){this.view=e,this.#t=e.bag,this.columns=r;for(let n of this.#e)n()}}detach(e){if(this.view===e){this.view=null,this.#t=null,this.columns=[];for(let r of this.#e)r()}}subscribe(e){return this.#e.add(e),()=>this.#e.delete(e)}};function Fu(t){return Object.hasOwn(t,"gridSearch")||Object.defineProperty(t,"gridSearch",{value:new vo,configurable:!0}),t.gridSearch}var ii=class{bind(e,r,n,i,o){if(!Array.isArray(e)||e.some(s=>typeof s!="number"||!Number.isFinite(s)))throw new TypeError("Sample chart requires an array of finite numbers");if(!Number.isFinite(r)||r<=0||!Number.isFinite(n))throw new TypeError("Sample chart requires a positive step and finite start");if(typeof i!="string"||!i||typeof o!="string"||!o||o.includes(",")||i===o)throw new TypeError("Sample chart requires distinct captionField and one valueFields name");this.samples=e,this.step=r,this.start=n,this.category=i,this.measure=o,this.rows?.length!==e.length&&(this.rows=Array.from(e.keys()))}domains(e,r,n){if(r==null&&n==null)return null;if(!Number.isFinite(r)||!Number.isFinite(n)||r>=n)throw new TypeError("Sample bounds require finite sampleMin < sampleMax");let i=Un(this,e);return i.dimension.range=[this.start,this.start+Math.max(1,this.samples.length-1)*this.step],i.axes={left:[r,n],right:[r,n]},i.z=[r,n],i}getRows(){return this.rows}value(e,r){if(r===this.category)return this.start+e*this.step;if(r===this.measure)return this.samples[e];throw new TypeError(`Unknown sample field: ${r}`)}};function xo(t){if(t==null||t==="")return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)||t instanceof Date&&Number.isFinite(t.getTime())||se(t)&&t.isFinite())return t;throw new TypeError("Column filters require loaded scalar values")}function Dt(t){return _e(xo(t))}function ku(t){if(!Array.isArray(t))throw new TypeError("Column selection requires an array or null");return Object.freeze([...new Map(t.map(e=>{let r=Dt(e);return[r,te(r)]})).values()])}function Ru(t){if(t===null)return null;let{from:e,to:r,dtype:n,timeZone:i}=t;if(!["D","DH","DHZ"].includes(n))throw new TypeError("Date range requires a date column");for(let o of[e,r])if(o!==null&&(!(o instanceof Date)||!Number.isFinite(o.getTime())||o.getUTCHours()||o.getUTCMinutes()||o.getUTCSeconds()||o.getUTCMilliseconds()))throw new TypeError("Date bounds require civil dates");if(e&&r&&e>r)throw new RangeError("From must not be after To.");if(n==="DHZ"&&!i)throw new TypeError("DHZ requires a timeZone");return e||r?Object.freeze({from:e?.toISOString().slice(0,10)??null,to:r?.toISOString().slice(0,10)??null,dtype:n,timeZone:i}):null}function oi(t,e){if(!e)return!0;if(t==null||t==="")return!1;if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError("Date range requires date values");let r;if(e.dtype==="DHZ"){let n=new Intl.DateTimeFormat("en",{timeZone:e.timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(t),i=o=>n.find(s=>s.type===o).value;r=`${i("year")}-${i("month")}-${i("day")}`}else r=t.toISOString().slice(0,10);return(!e.from||r>=e.from)&&(!e.to||r<=e.to)}function vt(t,e){return e===2?t%4===0&&(t%100!==0||t%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function Te(t,e,r){if(![t,e,r].every(Number.isInteger)||t<1||t>9999||e<1||e>12||r<1||r>vt(t,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(r).padStart(2,"0")}`}function xt(t){if(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=t.split("-").map(Number);return Te(...e),e}function zr(t,e,r){let n=t-1,i=365*n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+r-1;for(let o=1;o<e;o++)i+=vt(t,o);return i}function Vr(t,e){let r=zr(...xt(t))+e;if(!Number.isSafeInteger(r)||r<0||r>zr(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let n=1,i=1e4;for(;i-n>1;){let s=Math.floor((n+i)/2);zr(s,1,1)<=r?n=s:i=s}r-=zr(n,1,1);let o=1;for(;r>=vt(n,o);)r-=vt(n,o++);return Te(n,o,r+1)}function To(t){return Vr(t,-(zr(...xt(t))%7))}function Lu(t,e,r=0,n=1){let i=t*12+e-1+r,o=Math.floor(i/12),s=(i%12+12)%12+1,a=i+n-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:Te(o,s,1),end:Te(l,u,vt(l,u))}}var si={en:{months:{january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12,jan:1,feb:2,mar:3,apr:4,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},weekdays:{monday:0,tuesday:1,wednesday:2,thursday:3,friday:4,saturday:5,sunday:6,mon:0,tue:1,wed:2,thu:3,fri:4,sat:5,sun:6},quarters:{"1st quarter":1,"2nd quarter":2,"3rd quarter":3,"4th quarter":4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["today"],yesterday:["yesterday"],tomorrow:["tomorrow"],this_week:["this week","week"],last_week:["last week"],next_week:["next week"],this_month:["this month","month"],last_month:["last month"],next_month:["next month"],last:["last"],next:["next"],articles:["the"],from:["from","between"],to:["to","and"],no_period:["no period","always"]},date_order:{default:"MDY",GB:"DMY",AU:"DMY",IE:"DMY",NZ:"DMY",IN:"DMY"}},it:{months:{gennaio:1,febbraio:2,marzo:3,aprile:4,maggio:5,giugno:6,luglio:7,agosto:8,settembre:9,ottobre:10,novembre:11,dicembre:12,gen:1,feb:2,mar:3,apr:4,mag:5,giu:6,lug:7,ago:8,set:9,ott:10,nov:11,dic:12},weekdays:{luned\u00EC:0,marted\u00EC:1,mercoled\u00EC:2,gioved\u00EC:3,venerd\u00EC:4,sabato:5,domenica:6,lun:0,mar:1,mer:2,gio:3,ven:4,sab:5,dom:6},quarters:{"1\xBA trimestre":1,"2\xBA trimestre":2,"3\xBA trimestre":3,"4\xBA trimestre":4,"1\xB0 trimestre":1,"2\xB0 trimestre":2,"3\xB0 trimestre":3,"4\xB0 trimestre":4,t1:1,t2:2,t3:3,t4:4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["oggi"],yesterday:["ieri"],tomorrow:["domani"],this_week:["questa settimana","settimana"],last_week:["settimana scorsa"],next_week:["settimana prossima"],this_month:["questo mese","mese"],last_month:["mese scorso"],next_month:["mese prossimo"],last:["scorso","scorsa"],next:["prossimo","prossima"],articles:["il","lo","la"],from:["da","dal","dalla","tra","fra"],to:["a","al","alla","e"],no_period:["-","senza periodo","sempre"]},date_order:{default:"DMY"}}};function Pu(t){if(typeof t!="string")throw new RangeError("A supported locale is required.");let e=t.replaceAll("-","_"),r=e.indexOf("_"),n=(r<0?e:e.slice(0,r)).toLowerCase(),i=(r<0?"":e.slice(r+1)).toUpperCase();if(!Object.hasOwn(si,n))throw new RangeError(`Unsupported locale: ${t}`);let o=si[n];return{dictionary:o,phrases:a=>[...new Set([...o.keywords[a],...si.en.keywords[a]])],order:o.date_order[i]??o.date_order.default}}var Tt=/^(?:\d{4}|\d{2})$/,Uu=/^\d{1,2}$/,jr=(t,e)=>({ok:!1,error:{code:t,message:e}}),Ct=(t="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:t})},zu=(t,e)=>Object.hasOwn(t,e);function At(t,e){if(t.length===4)return Number(t);let r=e.year+e.twoDigitYearAhead-100;return r+((Number(t)-r)%100+100)%100}function Sd(t,e){if(t.includes(";")){let i=t.split(";").map(o=>o.trim());return i.length!==2?Ct("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:i,range:!0}}if(e.phrases("no_period").includes(t))return{bounds:["",""],range:!0};let r=e.phrases("to"),n=e.phrases("from");for(let i of r)if(t.startsWith(`${i} `))return{bounds:["",t.slice(i.length+1).trim()],range:!0};for(let i of r){let o=` ${i} `;if(!t.includes(o))continue;for(let a of n)if(t.startsWith(`${a} `)){t=t.slice(a.length+1);break}let s=t.split(o).map(a=>a.trim());return s.length!==2?Ct("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:s,range:!0}}for(let i of n)if(t.startsWith(`${i} `))return{bounds:[t.slice(i.length+1).trim(),""],range:!0};return{bounds:[t,t],range:!1}}function Nd(t,e,r){let n=[[t,0]],i=/^(.+?)\s*([+-])\s*(\d+)$/.exec(t);i&&n.push([i[1],Number(i[2]+i[3])]);let o={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[s,a]of n)for(let[l,u]of Object.entries(o))if(e.phrases(l).includes(s)){if(l.endsWith("_week"))return Vr(To(e.workdate),(u+a)*7+(r?6:0));if(l.endsWith("_month")){let c=Lu(e.year,e.month,u+a);return r?c.end:c.start}return Vr(e.workdate,u+a)}return null}function _d(t,e,r){let n=Object.entries(e.dictionary.quarters).sort((i,o)=>o[0].length-i[0].length);for(let[i,o]of n){let s;if(t===i)s=null;else if(t.startsWith(i)&&Tt.test(t.slice(i.length).trim()))s=At(t.slice(i.length).trim(),e);else if(t.endsWith(i)&&Tt.test(t.slice(0,-i.length).trim()))s=At(t.slice(0,-i.length).trim(),e);else continue;return{year:s,month:r?o*3:o*3-2}}return null}function $u(t,e){if(zu(e.months,t))return e.months[t];let r=/^m(\d{1,2})$/.exec(t);return r&&Number(r[1])>=1&&Number(r[1])<=12?Number(r[1]):null}function Id(t,e){let r=t.split(/\s+/),n=r.map((u,c)=>$u(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!n.length)return null;if(n.length!==1)return Ct();let i=n[0],o=$u(r[i],e.dictionary),s=r.slice(0,i),a=r.slice(i+1),l=[...s,...a];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(o>e.month?1:0),month:o};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(o<e.month?1:0),month:o};if(!l.length)return{year:null,month:o};if(!s.length&&a.length===1&&Tt.test(a[0]))return{year:At(a[0],e),month:o};if(s.length===1&&Uu.test(s[0])){if(!a.length)return Te(e.year,o,Number(s[0]));if(a.length===1&&Tt.test(a[0]))return Te(At(a[0],e),o,Number(s[0]))}return!s.length&&a.length===2&&Uu.test(a[0])&&Tt.test(a[1])?Te(At(a[1],e),o,Number(a[0])):Ct()}function Od(t,e){let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(r)return Te(...r.slice(1).map(Number));let n=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(t),i={};if(n)e.order.split("").forEach((a,l)=>{i[a]=n[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(t)){let a=t.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;i[l]=t.slice(0,u),t=t.slice(u)}}else return null;if(!Tt.test(i.Y)||i.D.length>2||i.M.length>2)return Ct();let o=Number(i.D),s=Number(i.M);return n&&s>12&&o<=12&&([o,s]=[s,o]),Te(At(i.Y,e),s,o)}function qu(t,e,r){if(!t)return null;let n=e.phrases("articles");if(t=t.split(/\s+/).filter(o=>!n.includes(o)).join(" "),!t)return Ct();if(Tt.test(t))return Te(At(t,e),r?12:1,r?31:1);let i=Nd(t,e,r)??_d(t,e,r)??Id(t,e);return i!==null?i:zu(e.dictionary.weekdays,t)?Vr(To(e.workdate),e.dictionary.weekdays[t]):Od(t,e)??Ct()}function Md(t,e,r){if(t===null||typeof t=="string")return t;let n=t.year??r.year,i=typeof e=="string"?xt(e)[0]:e?.year,o=typeof e=="string"?xt(e)[1]:e?.month;return i&&(n>i&&(n=i),n===i&&t.month>o&&n--),Te(n,t.month,1)}function Bd(t,e,r){if(t===null||typeof t=="string")return t;let n=t.year??r.year;if(e!==null){let[i,o]=xt(e);n<i&&(n=i),n===i&&o>t.month&&n++}return Te(n,t.month,vt(n,t.month))}function Ao(t,e={}){if(!e||typeof e!="object"||Array.isArray(e))return jr("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let r;try{let{locale:n="it-IT",workdate:i,twoDigitYearAhead:o=20}=e,[s,a]=xt(i);if(!Number.isInteger(o)||o<0||o>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");r={...Pu(n),workdate:i,year:s,month:a,twoDigitYearAhead:o}}catch(n){return jr("INVALID_CONTEXT",n.message)}if(typeof t!="string")return jr("INVALID_INPUT","Expression must be a string.");try{let n=t.toLowerCase().trim().replaceAll(",",""),{bounds:i,range:o}=Sd(n,r),s=qu(i[1],r,!0),a=qu(i[0],r,!1),l=Md(a,s,r),u=Bd(s,l,r);return!o&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(n){if(n instanceof RangeError)return jr("INVALID_DATE",n.message);if(n instanceof SyntaxError)return jr(n.code,n.message);throw n}}var sr=new Map;function ai(t,e,r){let n=JSON.stringify([t,e,r]),i=sr.get(n);if(i)sr.delete(n);else{let o=t?Intl.DateTimeFormat:Intl.NumberFormat;if(!o.supportedLocalesOf([e]).length)throw new RangeError(`Unsupported format locale: ${e}`);i=new o(e,r),sr.size===64&&sr.delete(sr.keys().next().value)}return sr.set(n,i),i}function ju(t){if(t!=null&&(typeof t!="string"||/[{}]/.test(t.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function Vu(t,e){return ju(e),e==null?t:e.replaceAll("{}",()=>t)}function Fd(t){if(t instanceof Date)return Ve(t);if(se(t))return"N";if(typeof t=="number")return Number.isInteger(t)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function kd(t,e,{pattern:r="short",locale:n,timeZone:i}){if(!["short","medium","long","full"].includes(r))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof i!="string"||!i))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let o={timeZone:e==="DHZ"?i:"UTC"};return e!=="H"&&(o.dateStyle=r),e!=="D"&&(o.timeStyle=r),ai(!0,n,o).format(t)}function ui(t){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(t);if(!e||e[1]==="("!=(e[4]===")")||t.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${t}`);let r=e[3]??"";return{prefix:e[1]??"",suffix:e[4]??"",intl:{useGrouping:e[2].startsWith("#,##")?"always":!1,minimumIntegerDigits:e[2].replace("#,##","").length,minimumFractionDigits:r.replaceAll("#","").length,maximumFractionDigits:r.length}}}function Rd(t){let e=t.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let r=ui(e[0]);if(r.prefix||r.suffix)throw new RangeError("Positive-section affixes are not implemented");let n=e.length===3?e[1]:null;n!==null&&n!==""&&n!=="-"&&ui(n);let i=e.length>1?ui(e.at(-1)):null;return{positive:r,zero:n,negative:i}}function Hu(t,e={},r={}){if(t===null)return"";if(typeof e=="string"&&(e={pattern:e}),!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Format options must be a pattern string or an options object");for(let y of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(y))throw new RangeError(`Unsupported format option: ${y}`);e={...e,locale:e.locale??r.locale,timeZone:e.timeZone??r.timeZone};let n=e.dtype===void 0?Fd(t):e.dtype,i=["D","H","DHZ"].includes(n);if(!i&&!["L","R","N"].includes(n))throw new RangeError(`Unsupported format dtype: ${n}`);if(i){if(!(t instanceof Date)||!Number.isFinite(t.getTime()))throw new TypeError(`${n} requires a valid Date object`)}else if(!(typeof t=="number"&&Number.isFinite(t))&&!(se(t)&&!["NaN","Infinity","-Infinity"].includes(t.toString())))throw new TypeError(`${n} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(n==="L"&&!Number.isInteger(t))throw new TypeError("L formatting requires an integer");let{pattern:o,locale:s,mask:a}=e;if(!i&&typeof o!="string")throw new TypeError("Numeric formatting currently requires an explicit pattern");if(typeof s!="string"||!s)throw new TypeError("Formatting currently requires an explicit locale");if(ju(a),i){let y=kd(t,n,e);return Vu(y,a)}let{positive:l,zero:u,negative:c}=Rd(o),f=ai(!1,s,l.intl),h=se(t),d=h?t.eq(0):t===0,g=h?t.lt(0):t<0;if(h&&ai(!1,"en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let p;if(d&&u!==null){if(u==="")return"";if(u==="-")p="-";else{let y=ui(u);p=y.prefix+ai(!1,s,y.intl).format(0)+y.suffix}}else{let y=g&&c?c:l,m=h?(g&&c?t.abs():t).toString():g&&c?-t:t===0?0:t;p=y.prefix+f.format(m)+y.suffix}return Vu(p,a)}function Gu(t){if(t===null)return null;let{value:e,columns:r,dtype:n,locale:i}=t;if(typeof e!="string"||!Array.isArray(r)||!r.length||r.some(u=>typeof u!="string"||!u||u==="rowidx")||!["T","L","R","N","D"].includes(n))throw new TypeError("Invalid collection filter");if(!e.trim())return null;if(n==="T"){let u=t.literal===!0?e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):e,c=new RegExp(u,"i");return f=>c.test(r.map(h=>Ld(f(h),i,t.timeZone)).join(" "))}if(r.length!==1)throw new TypeError("Typed filters require one column");let o=/^\s*(<=|>=|==|!=|[<>=!#])\s*(.+?)\s*$/.exec(e);if(!o)throw new Error("Enter a comparison, for example > 100 or = 12.");let[,s,a]=o,l;if(n==="D"){let u=new Date,c=`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`,f=Ao(a,{locale:i,workdate:c});if(!f.ok||f.kind!=="date")throw new Error("Enter one complete date after the comparison.");l=new Date(`${f.date}T00:00:00Z`)}else l=Pd(a,i);return u=>{let c=u(r[0]);if(c==null)return!1;if(n==="D"?!(c instanceof Date)||!Number.isFinite(c.getTime()):!(typeof c=="number"&&Number.isFinite(c)||se(c)&&c.isFinite()))throw new TypeError(`Filter value does not match ${n}`);let f=se(l)?-l.comparedTo(c):c<l?-1:c>l?1:0;switch(s){case"=":case"==":return f===0;case"!":case"#":case"!=":return f!==0;case"<":return f<0;case">":return f>0;case"<=":return f<=0;case">=":return f>=0}}}function Ld(t,e,r){return t==null?"":typeof t=="string"||typeof t=="boolean"?String(t):Hu(t,{pattern:t instanceof Date?"short":"#,##0.####################"},{locale:e,timeZone:r})}function Pd(t,e){let r=new Intl.NumberFormat(e).formatToParts(-12345.6),n=r.find(l=>l.type==="decimal").value,i=r.find(l=>l.type==="group")?.value,o=r.find(l=>l.type==="minusSign").value,s=t.replaceAll(o,"-");if(i&&s.includes(i)){let u=s.split(n)[0].replace(/^[+-]/,"").split(i),c=new Intl.NumberFormat(e).formatToParts(1234567890123).filter(d=>d.type==="integer").map(d=>d.value.length),f=c.at(-1),h=c.at(-2);if(s.split(n).slice(1).some(d=>d.includes(i))||!/^\d+$/.test(u[0])||u[0].length>h||u.slice(1).some((d,g)=>!/^\d+$/.test(d)||d.length!==(g===u.length-2?f:h)))throw new Error("Invalid numeric grouping.");s=s.replaceAll(i,"")}if(s=s.replace(n,"."),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(s))throw new Error("Enter a complete number.");let a=Zt(s);if(!se(a)||!a.isFinite())throw new Error("A finite Decimal backend is required.");return a}function Wu(t,e){return(","+t+",").includes(","+e+",")}function Xu(t){if(typeof t!="string")throw new TypeError("grid checked must refer to a string (empty string for an empty set)");return t}function Yu(t){if(typeof t!="string"||!t||t.includes(","))throw new TypeError("grid checkedField requires nonempty text IDs without commas");return t}var Ju={network:{maxAttempts:3,delay:1,backoff:2,jitter:!0,on:["TypeError","NetworkError","AbortError"]},aggressive:{maxAttempts:5,delay:.5,backoff:2,jitter:!0,on:["Error"]},gentle:{maxAttempts:2,delay:2,backoff:1.5,jitter:!1,on:["TypeError","NetworkError"]}};function Ud(t){let e=t._retryPolicy;return e==null?null:typeof e=="string"?Ju[e]||null:e}function $d(t,e){return e.some(r=>r==="Error"?!0:t.name===r||t.constructor.name===r)}function qd(t){return new Promise(e=>setTimeout(e,t))}async function zd(t,e){if(!e)return t();let r=e.maxAttempts||3,n=e.delay||1,i=e.backoff||2,o=e.jitter!==!1,s=e.on||["Error"],a=null,l=n*1e3;for(let u=0;u<r;u++)try{let c=t();return c instanceof Promise?await c:c}catch(c){if(a=c,u<r-1&&$d(c,s)){let f=l;o&&(f*=1+Math.random()*.1),await qd(f),l*=i}else throw c}throw a}var he=class t{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let n={...this.constructor.classKwargs,...e};for(let o of["interval","reactive"])if(Object.hasOwn(n,o))throw new TypeError(`Removed resolver option: ${o}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=n.cacheTime,this._readOnly=n.readOnly,this._asBag=n.asBag,this._retryPolicy=n.retryPolicy,this._kw={};let i=this.constructor.internalParams;for(let[o,s]of Object.entries(n))i.has(o)||(this._kw[o]=s);this._lastUpdate=null,this._node=null,this._lastEffectiveFingerprint=null,this._cachedValue=null,this.init()}init(){}setNode(e){e!==this._node&&!this.readOnly&&this._lastUpdate!==null&&this.reset(),this._node=e,this.onSetResolver(e)}onSetResolver(e){}get node(){return this._node}get cacheTime(){return this._cacheTime}set cacheTime(e){if(typeof e=="boolean")throw new TypeError("cacheTime must be numeric; use a negative value for infinite caching");this._cacheTime=e}get readOnly(){return this._readOnly}get expired(){return this._cacheTime<0?this._lastUpdate===null:this._cacheTime===0||this._lastUpdate===null?!0:(Date.now()-this._lastUpdate)/1e3>this._cacheTime}reset(...e){if(e.length)throw new TypeError("reset() takes no arguments. It invalidates the cache for the next explicit read.");this._lastUpdate=null,this._lastEffectiveFingerprint=null}get cachedValue(){return!this.readOnly&&this._node?this._node._value:this._cachedValue}set cachedValue(e){!this.readOnly&&this._node?this._node.setValue(e,!1):this._cachedValue=e}_computeEffectiveFingerprint(e){return JSON.stringify(Object.entries(e).sort())}_buildEffectiveKw(){let e={...this._kw};if(this._node&&this._node.attr)for(let r of Object.keys(this._kw))Object.hasOwn(this._node.attr,r)&&(e[r]=this._node.attr[r]);return e}resolve(e={}){let{static:r=!1,...n}=e;if(r)return this._node?this._node._value:this.cachedValue;let i=this._buildEffectiveKw();if(Object.keys(n).length>0)return this._load({...i,...n},s=>this._prepareValue(s));let o=this._computeEffectiveFingerprint(i);return o===this._lastEffectiveFingerprint&&!this.expired?this.cachedValue:(this._lastEffectiveFingerprint=o,this._load(i,s=>this._finalize(s)))}_load(e,r){let n=Ud(this),i=()=>this.load(e);if(n)return zd(i,n).then(r);let o=i();return o&&typeof o.then=="function"?o.then(r):r(o)}_finalize(e){return e=this._prepareValue(e),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_prepareValue(e){let r;return this._asBag===!0?r=!0:this._asBag===!1?r=!1:r=!this._readOnly,r&&e!==null&&e!==void 0&&(e=this._convertToBag(e)),e}_convertToBag(e){let r=t._BagClass;if(!r||e&&typeof e._htraverse=="function")return e;if(typeof e=="string"){if(e=e.trim(),e.startsWith("<")&&r.fromXml)return r.fromXml(e);if((e.startsWith("{")||e.startsWith("["))&&r.fromTytx)return r.fromTytx(e)}return e}static registerBagClass(e){t._BagClass=e}load(e){return null}};he._BagClass=null;var Hr=class extends he{static classKwargs={cacheTime:0,readOnly:!1,asBag:!1,retryPolicy:null,callback:null};static classArgs=["callback"];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy","callback"]);constructor(e={}){typeof e=="function"&&(e={callback:e}),super(e),this._callback=e.callback||null}load(e){return this._callback?this._callback.call(this,e):null}};var St=class t{constructor(e,r,n=null,i=null,o=null,s=null,a=null,l=!0){this.label=r,this._value=null,this._attr={},this._parentBag=null,this._resolver=null,this._nodeSubscribers={},this._onChangedValue=null,this.nodeTag=s,this.xmlTag=a,this._compiled=null,this.parentBag=e,i&&this.setAttr(i,!1,!0,l),n!==null&&this.setValue(n,!1),o&&(this.resolver=o)}get parentBag(){return this._parentBag}set parentBag(e){e===null&&this._value?.parentNode===this&&this._value.setBackref(),this._parentBag=e,e?.backref&&this._value&&typeof this._value._htraverse=="function"&&this._value.setBackref(this,e)}get value(){return this.getValue()}set value(e){this.setValue(e)}getValue(e=!1,r=null,n={}){if(r!==null){let i=te(`${r}::QS`);if(Array.isArray(i)){let o=i.length?i:Object.keys(this._attr),s=o.map(l=>{let u=this.getAttr(l);return!e&&u instanceof he?u.resolve():u}),a=l=>i.length===0?Object.fromEntries(o.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return s.some(l=>l&&typeof l.then=="function")?Promise.all(s).then(a):a(s)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");n={...n,...i}}}return this._resolver!==null?this._resolver.resolve({static:e,...n}):this._value}setValue(e,r=!0,n=null,i=null,o=!0,s=null,a=!1){e instanceof he?(this.resolver=e,e=null):e instanceof t&&(n=n||{},Object.assign(n,e._attr),e.resolver&&(this.resolver=e.resolver),e=e._value);let l=this._value;l!==e&&l?.parentNode===this&&l.setBackref(),this._value=e;let u=l!==this._value,c=r??!0,f=null;if(n!==null){let d={...this._attr};this.setAttr(n,!1,i,o);let g=this._buildAttrDiff(d,this._attr);f=Object.keys(g).length>0?g:null}r=c&&(u||f!==null);let h=f?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),r){let d=f!==null?{oldvalue:l,attrs_diff:f}:{oldvalue:l};for(let g of Object.values(this._nodeSubscribers))g({node:this,info:d,evt:h})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),r&&this._parentBag._onNodeChanged(this,[this.label],h,l,f,s,a))}replace(e){if(!(e instanceof t))throw new TypeError("BagNode.replace expects a BagNode");if(e===this)return this;let r=e.staticValue;r&&typeof r._htraverse=="function"&&(r=r.createChildBag().replace(r));let n=null;e.resolver&&(n=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),n._node=null,n._kw={...e.resolver._kw});let i=this._value,o={...this._attr},s=this.resolver;s&&s._node===this&&(s._node=null),this.resolver=n,this.setValue(r,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(o,this._attr),l=Object.keys(a).length?a:null,u=i!==r||s!==n;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",f=l?{oldvalue:i,attrs_diff:l}:{oldvalue:i};for(let h of Object.values(this._nodeSubscribers))h({node:this,info:f,evt:c});this._parentBag!==null&&this._parentBag.backref&&this._parentBag._onNodeChanged(this,[this.label],c,i,l)}return this}get staticValue(){return this._value}set staticValue(e){this._value=e}get resolver(){return this._resolver}set resolver(e){this._resolver=e,e&&e.setNode&&e.setNode(this)}resetResolver(){if(!this._resolver)throw new Error("Cannot reset resolver: node has no resolver");this._resolver.reset(),this.setValue(null)}get attr(){return this._attr}getAttr(e=null,r=null){return e?e in this._attr?this._attr[e]:r:this._attr}_buildAttrDiff(e,r){let n={},i=new Set([...Object.keys(e),...Object.keys(r)]);for(let o of i){let s=o in e?e[o]:null,a=o in r?r[o]:null;s!==a&&(n[o]={old:s,new:a})}return n}setAttr(e=null,r=!0,n=!0,i=!0){let o=e||{},s=Object.keys(this._nodeSubscribers).length>0,l=r&&(s||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(n?Object.assign(this._attr,o):this._attr={...o},i)for(let u of Object.keys(this._attr))this._attr[u]===null&&delete this._attr[u];if(r&&l!==null){let u=this._buildAttrDiff(l,this._attr);if(Object.keys(u).length>0&&s)for(let c of Object.values(this._nodeSubscribers))c({node:this,info:{attrs_diff:u},evt:"upd_attrs"});if(Object.keys(u).length>0&&this._parentBag!==null&&this._parentBag.backref){let c=r===!0?"true":String(r);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let r of e)if(typeof r=="string"&&r.includes(","))for(let n of r.split(","))delete this._attr[n.trim()];else delete this._attr[r]}hasAttr(e,r=null){return e in this._attr?r!==null?this._attr[e]===r:!0:!1}getInheritedAttributes(){let e={};return this._parentBag&&this._parentBag.parentNode&&(e=this._parentBag.parentNode.getInheritedAttributes()),{...e,...this._attr}}subscribe(e,r){this._nodeSubscribers[e]=r}unsubscribe(e){delete this._nodeSubscribers[e]}get compiled(){return this._compiled||(this._compiled={}),this._compiled}get isBranch(){return this._value!=null&&typeof this._value._htraverse=="function"}get position(){return this._parentBag===null?null:this._parentBag._nodes.index(this.label)}get fullpath(){if(this._parentBag!==null){let e=this._parentBag.fullpath;return e?`${e}.${this.label}`:this.label}return null}get parentNode(){return this._parentBag?this._parentBag.parentNode:null}attributeOwnerNode(e,r=null){let n=this;if(r===null)for(;n&&!(e in n._attr);)n=n.parentNode;else for(;n&&n._attr[e]!==r;)n=n.parentNode;return n}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof t)||this.label!==e.label)return!1;let r=Object.keys(this._attr),n=Object.keys(e._attr);if(r.length!==n.length)return!1;for(let i of r)if(this._attr[i]!==e._attr[i])return!1;return this._resolver!==null?this._resolver===e._resolver:this._value&&typeof this._value.equalTo=="function"?this._value.equalTo(e._value):this._value&&typeof this._value.isEqual=="function"?this._value.isEqual(e._value):this._value===e._value}diff(e){if(this.label!==e.label)return`Other label: ${e.label}`;let r=Object.keys(this._attr),n=Object.keys(e._attr);return r.length!==n.length||r.some(i=>this._attr[i]!==e._attr[i])?`attributes self:${JSON.stringify(this._attr)} --- other:${JSON.stringify(e._attr)}`:this._value!==e._value?`value self:${this._value} --- other:${e._value}`:null}toJson(e=!0){let r=this.value;return r&&typeof r.toJson=="function"&&(r=r.toJson(e,!0)),{label:this.label,value:r,attr:this._attr}}toString(){return`BagNode : ${this.label}`}};var Gr=class t{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(n=>n.label===e);let r=e.match(/^#(\d+)$/);if(r){let n=parseInt(r[1],10);return n<this._list.length?n:-1}if(r=e.match(/^#(\w*)=(.*)$/),r){let[,n,i]=r,o=i.includes("::")?te(i):i;return n?this._list.findIndex(s=>s.getAttr(n)===o):this._list.findIndex(s=>s._value===o)}return-1}_parsePosition(e){let r=this._list.length;if(e==null||e===">")return r;if(typeof e=="number")return e<0&&(e=r+e),Math.max(0,Math.min(e,r));if(e==="<")return 0;if(e.startsWith("#")){let n=this._parseSharpIndex(e.slice(1),e);return Math.min(n,r)}if(e.startsWith("<")){let n=e.slice(1);if(n.startsWith("#")){let o=this._parseSharpIndex(n.slice(1),e);return Math.min(o,r)}let i=this.index(n);if(i<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return i}if(e.startsWith(">")){let n=e.slice(1);if(n.startsWith("#")){let o=this._parseSharpIndex(n.slice(1),e);return Math.min(o+1,r)}let i=this.index(n);if(i<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return i+1}throw new Error(`Invalid node_position '${e}': unrecognized syntax`)}_parseSharpIndex(e,r){if(!/^-?\d+$/.test(e))throw new Error(`Invalid node_position '${r}': '${e}' is not an integer`);let n=parseInt(e,10);if(n<0)throw new Error(`Invalid node_position '${r}': negative index not allowed in '#n' syntax`);return n}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let r=this.index(e);return r>=0?this._list[r]:null}return this._dict[e]||null}set(e,r,n=">",i=null,o=null,s=null,a=!1,l=!0,u=null,c=!0,f=!1,h=null){let d=null;if(e.includes("?")&&([e,d]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(d){let p=d.split("&");if(p.length===1)i={[p[0]]:r};else{if(!Array.isArray(r)||r.length!==p.length)throw new Error("Wrong attributes assignment");i={};for(let y=0;y<p.length;y++)i[p[y]]=r[y]}r=null}let g=this._dict[e];if(g)h&&(g.nodeTag=h),s!==null&&(s===!1?g.resolver=null:g.resolver=s),d?g.setAttr(i,c,!0,l):g.setValue(r,c,i,a,l,u,f);else{let p=o&&o.nodeClass?o.nodeClass:St;g=new p(o,e,d?null:r,i,s,h,null,l);let y=this._parsePosition(n);this._dict[e]=g,this._list.splice(y,0,g),c&&o&&o.backref&&o._onNodeInserted(g,y,null,u,f)}return f&&g.setValue(null,!1),g}pop(e){let r=this.get(e);if(r){delete this._dict[r.label];let n=this._list.indexOf(r);return n>=0&&this._list.splice(n,1),r}return null}has(e){return e in this._dict}get length(){return this._list.length}clear(){this._dict=Object.create(null),this._list=[]}keys(){return this._list.map(e=>e.label)}values(){return this._list.map(e=>e.getValue())}items(){return this._list.map(e=>[e.label,e.getValue()])}[Symbol.iterator](){return this._list[Symbol.iterator]()}move(e,r,n=!0){if(r<0)return;let i=Array.isArray(e)?e:[e];if(i.length===0||r>=this._list.length)return;let o=this._list[r].label;if(i.length>1){let s=[...i].sort((c,f)=>c-f),a=s[0]<r?1:0,l=[];for(let c=s.length-1;c>=0;c--){let f=s[c];if(f>=0&&f<this._list.length){let h=this._list[f];this._list.splice(f,1),l.push(h),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(h,f)}}let u=this.index(o);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let s=i[0];if(s===r||s<0||s>=this._list.length)return;let a=this._list[s];this._list.splice(s,1),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,s),this._list.splice(r,0,a),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,r)}}isEqual(e){if(!(e instanceof t)||this._list.length!==e._list.length)return!1;for(let r=0;r<this._list.length;r++){let n=this._list[r],i=e._list[r];if(!n.isEqual(i))return!1}return!0}};var el=Qr(ro(),1);var Co="::RSLV:",Vd=new Map,jd=new Map,li=new WeakMap,Q=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Wr=class extends he{constructor(e){super({asBag:!1}),li.set(this,e)}get payload(){return li.get(this)}load(){throw new Q("This resolver is opaque; local execution is unavailable")}};function Zu(t){if(!t||typeof t!="object"||Array.isArray(t)||typeof t.resolver_module!="string"||typeof t.resolver_class!="string"||!Array.isArray(t.args??[])||!t.kwargs||typeof t.kwargs!="object"||Array.isArray(t.kwargs))throw new Q("Invalid resolver description")}function Ku(t,e=new Set){if(!(t===null||typeof t=="string"||typeof t=="boolean")&&!(typeof t=="number"&&Number.isFinite(t))){if(typeof t!="object"||e.has(t)||!Array.isArray(t)&&Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw new Q("Resolver parameters must be JSON data; callbacks cannot travel");e.add(t);for(let r of Object.values(t))Ku(r,e);e.delete(t)}}function Xr(t){if(li.has(t))return li.get(t);let e=jd.get(t.constructor);if(!e)throw new Q(`Unregistered resolver: ${t.constructor.name}`);let r=e.encode(t),n={resolver_module:e.module,resolver_class:e.name,args:r.args??[],kwargs:r.kwargs??{}};return Zu(n),Ku(n),Co+JSON.stringify(n)}function ci(t){if(typeof t!="string"||!t.startsWith(Co))return null;let e=t.slice(Co.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Wr(t);let r;try{r=JSON.parse(e)}catch{throw new Q("Invalid resolver JSON or signed token")}Zu(r);let n=Vd.get(JSON.stringify([r.resolver_module,r.resolver_class]));if(!n)return new Wr(t);let i=n.decode({args:r.args??[],kwargs:r.kwargs});if(!(i instanceof n.cls))throw new Q("Resolver decoder returned an incompatible instance");return i}function fi(t){return Object.fromEntries(Object.entries(t||{}).map(([e,r])=>[e,r instanceof he?Xr(r):r]))}function So(t){return Object.fromEntries(Object.entries(t||{}).map(([e,r])=>[e,ci(r)??r]))}var Fe="__cls";function ar(t,e){return t!==null&&t.tytxSuffix===e?t:fo(e)}function Hd(t){let e=t.tytxSuffix,r=Object.entries(Qt(e)).filter(([,n])=>n===t).map(([n])=>n);if(r.length===0)throw new Q(`${t.name} is not in the TYTX subtype dictionary of '${e}'`);if(r.length>1)throw new Q(`${t.name} is in the TYTX subtype dictionary of '${e}' under several names: ${r.sort().join(", ")}`);return r[0]}function No(t,e){let r=Qt(t);if(!Object.hasOwn(r,e))throw new Q(`Unknown Bag class '${e}' for TYTX type '${t}'`);return r[e]}function _o(t,e){return t===e?null:Hd(t)}function*tl(t,e=[]){for(let r of t){let n=[...e,r.label];yield[n,r];let i=r.getValue(!0);!r.resolver&&i instanceof ke&&(yield*tl(i,n))}}function Gd(t){let e=t.toISOString(),r=t.getUTCFullYear()===1970&&t.getUTCMonth()===0&&t.getUTCDate()===1,n=t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0;if(n&&!r)return e.slice(0,e.indexOf("T"));let i=e.replace(/\.000Z$/,"Z");return r&&!n?i.slice(i.indexOf("T")+1):i}function ur(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function ft(t){return typeof t=="string"?t.includes("::")?`${t}::T`:t:Array.isArray(t)?t.map(ft):ur(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,ft(r)])):t}function Io(t){if(!ur(t))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=t;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var Qu=!1,ke=class t{static tytxSuffix="X";constructor(e=null,r={}){this._nodes=new Gr,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Io(r),e!=null&&this.fillFrom(e,r)}get parent(){return this._parent}set parent(e){this._parent=e}get parentNode(){return this._parentNode}set parentNode(e){this._parentNode=e}get backref(){return!!this._backref}get nodeClass(){return St}createChildBag(){return new this.constructor}get fullpath(){if(this._parent!==null&&this._parentNode!==null){let e=this._parent.fullpath;return e?`${e}.${this._parentNode.label}`:this._parentNode.label}return null}relativePath(e){let r=[],n=e;for(;n!==null;){if(n.parentBag===this)return r.push(n.label),r.reverse(),r.join(".");r.push(n.label),n=n.parentNode}return null}get length(){return this._nodes.length}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}get attributes(){return this._parentNode!==null?this._parentNode.getAttr():{}}get rootAttributes(){return this._rootAttributes}set rootAttributes(e){this._rootAttributes=e!==null?{...e}:null}_htraverseBefore(e){let r=this,n;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),n=e.split(".").filter(i=>i)):n=[...e];n.length&&n[0]==="#parent"&&r!==null;)n.shift(),r=r.parent;return[r,n]}_htraverse(e,r=!1,n=!0){let[i,o]=this._htraverseBefore(e);if(i===null)return[null,null];if(o.length===0)return[i,""];for(;o.length>1&&i instanceof t;){let s=o[0];if(s==="#parent"){if(i.parent===null||i.parent===void 0)break;o.shift(),i=i.parent;continue}let a=i._nodes.get(s);if(!a)break;let l=a.getValue(n);if(l instanceof t)o.shift(),i=l;else if(r){let u=i.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),o.shift(),i=u}else break}if(!r)return o.length>1?[null,null]:[i,o[0]];for(;o.length>1;){let s=o.shift();if(s.startsWith("#"))throw new Yr("Not existing index in #n syntax");let a=i.createChildBag();i._nodes.set(s,a,">",null,i,null,!1,!0,"autocreate"),i=a}return[i,o[0]]}get(e,r=null,n=!0,i={}){if(!e)return this;if(e==="#parent")return this.parent;let o=null;e.includes("?")&&([e,o]=e.split("?",2));let s=this._nodes.get(e);return s?s.getValue(n,o,i):r}getItem(e,r=null,n=!1,i={}){if(!e)return this;let[o,s]=this._htraverse(e,!1,n);return o instanceof t?o.get(s,r,n,i):r}setItem(e,r,n=null,i=">",o=!1,s=!0,a=null,l=!1,u=!0,c=null,f=null){if(e==="")throw new RangeError("setItem requires a non-empty path");let[h,d]=this._htraverse(e,!0);return h._nodes.set(d,r,i,n,h,c,o,s,a,u,l,f)}_pop(e,r=null){let n=this._nodes.index(e);if(n>=0){let i=this._nodes.pop(n);return this.backref&&this._onNodeDeleted(i,n,null,r),i}return null}pop(e,r=null,n=null){let i=this.popNode(e,n);return i?i.value:r}delItem(e,r=null,n=null){return this.pop(e,r,n)}popNode(e,r=null){let[n,i]=this._htraverse(e,!1,!0);if(!n||!i)return null;let o=n._nodes.get(i);if(!o)return null;try{return n._pop(i,r)}finally{o.parentBag===n&&n._nodes._dict[o.label]!==o&&(o.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let r of e)r.parentBag=null}getNode(e,r=!0,n=!1,i=null){if(e==null||e==="")return this.parentNode;if(typeof e=="number")return this._nodes.get(e);typeof e=="string"&&(e=e.split("?",1)[0]);let[o,s]=this._htraverse(e,n,r);if(o instanceof t&&s){let a=o._nodes.get(s);if(a)return a;if(n)return o._nodes.set(s,i,">",null,o,null,!1,!0,"autocreate"),o._nodes.get(s)}return null}setBackref(e=null,r=null){let n=this._backref;if(this._backref=!0,this._parent=r,this._parentNode=e,!n){this._nodes._parentBag=this;for(let i of this)i.parentBag=this}}delParentRef(){this._parent=null,this._parentNode=null,this._backref=!1}clearBackref(){if(this._backref){this._backref=!1,this._parent=null,this._parentNode=null,this._nodes._parentBag=null;for(let e of this){e.parentBag=null;let r=e.getValue(!0);r instanceof t&&r.clearBackref()}}}_onNodeChanged(e,r,n,i=null,o=null,s=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:r,oldvalue:i,attrs_diff:o,evt:n,reason:s,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...r],n,i,o,s,a)}_onNodeInserted(e,r,n=null,i=null,o=!1){let s=e.parentBag,a=e.getValue(!0);s!==null&&s.backref&&a instanceof t&&a.setBackref(e,s),n===null&&(n=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:n,ind:r,evt:"ins",reason:i,fired:o});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,r,[this._parentNode.label,...n],i,o)}_onNodeDeleted(e,r,n=null,i=null){for(let o of Object.values(this._delSubscribers))o({node:e,pathlist:n,ind:r,evt:"del",reason:i});this._parent&&this._parentNode&&(n===null&&(n=[]),this._parent._onNodeDeleted(e,r,[this._parentNode.label,...n],i))}_subscribe(e,r,n){n!=null&&(r[e]=n)}subscribe(e,r={}){if(Object.hasOwn(r,"timer")||Object.hasOwn(r,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=null,insert:i=null,delete:o=null,any:s=null}=r;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,n||s),this._subscribe(e,this._insSubscribers,i||s),this._subscribe(e,this._delSubscribers,o||s)}unsubscribe(e,r={}){if(Object.hasOwn(r,"timer")||Object.hasOwn(r,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=!1,insert:i=!1,delete:o=!1,any:s=!1}=r;(n||s)&&delete this._updSubscribers[e],(i||s)&&delete this._insSubscribers[e],(o||s)&&delete this._delSubscribers[e]}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}keys(){return this._nodes.keys()}values(){return this._nodes.values()}items(){return[...this._nodes].map(e=>({key:e.label,value:e.getValue()}))}get nodes(){return this.getNodes()}node(e){return this._nodes.get(e)}setAttr(e=null,r=null,n=!0){let i=t.prototype.getNode.call(this,e,!0,!0);i&&i.setAttr(r,!0,!0,n)}getAttr(e=null,r=null,n=null){let i=this.getNode(e);return i?i.getAttr(r,n):n}delAttr(e=null,...r){let n=this.getNode(e);n&&n.delAttr(...r)}getInheritedAttributes(){return this._parentNode?this._parentNode.getInheritedAttributes():{}}getNodes(e=null){return e?[...this._nodes].filter(r=>e(r)):[...this._nodes]}getNodeByValue(e,r){for(let n of this._nodes){let i=n.value;if(i instanceof t){if(i.getItem(e)===r)return n}else if(i&&i.get&&i.get(e)===r)return n}return null}getNodeByAttr(e,r,n=!1,i=!1){let o=r===void 0,s=n&&typeof r=="string"?r.toLowerCase():r,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let f=n&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(o||f==s)return c}if(c._value instanceof t)if(i){let f=a(c._value);if(f)return f}else u.push(c._value)}for(let c of u){let f=a(c);if(f)return f}return null};return a(this)}isEmpty(e=!1,r=!1){if(this._nodes.length===0)return!0;for(let n of this._nodes){if(n._resolver!==null)return!1;let i=n.getValue(!0);if(i!=null&&!(e&&i===0)&&!(r&&i===""))return!1}return!0}query(e=null,r=null,n=!1,i=!1,o=!0,s=!0,a=null,l=!0){e||(e="#k,#v,#a");let u=this,c;if(typeof e=="string"){if(e.includes(":")){let[d,g]=e.split(":");u=this.getItem(d),e=g}c=e.split(",").map(d=>d.trim())}else c=e;let f=(d,g,p,y,m)=>{if(g==="#k")return d.label;if(g==="#p")return p;if(g==="#n")return d;if(typeof g=="function")return g(d);if(g==="#v"){let w=m();return y&&w instanceof t?null:w}else if(g.startsWith("#v.")){let w=g.split(".").slice(1).join("."),b=m();return b&&b.getItem?b.getItem(w):null}else{if(g==="#__v")return d.getValue(!0);if(g.startsWith("#a")){let w=g.includes(".")?g.split(".").slice(1).join("."):null;return d.getAttr(w)}else{let w=m();return w&&w.getItem?w.getItem(g):null}}};function*h(){let d=0;function*g(p,y){for(let m of p._nodes){let w=y?`${y}.${m.label}`:m.label,b=!1,v,x=()=>(b||(v=m.getValue(l),b=!0),v);if((o&&s||(x()instanceof t?s:o))&&(r===null||r(m))&&(yield c.length===1?f(m,c[0],w,i,x):c.map(E=>f(m,E,w,i,x)),d++,a!==null&&d>=a))return;if(i){let E=x();if(E instanceof t&&(yield*g(E,w),a!==null&&d>=a))return}}}yield*g(u,"")}return n?h():[...h()]}getLeaves(){let e=[],r=(n,i)=>{for(let o of n._nodes){let s=i?`${i}.${o.label}`:o.label,a=o.getValue(!1);a instanceof t?r(a,s):e.push([s,a])}};return r(this,""),e}digest(e=null,r=null,n=!1){typeof r=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),n=r,r=null);let i=this.query(e,r,!1,!1,!0,!0,null,!1);if(n){if(!i||i.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let o=[...i];if(o.length&&Array.isArray(o[0])){let s=o[0].length,a=[];for(let l=0;l<s;l++)a.push(o.map(u=>u[l]));return a}return[o]}return[...i]}columns(e,r=!1){typeof e=="string"&&(e=e.split(","));let n=r?"#a.":"",i=e.map(o=>`${n}${o}`).join(",");return this.digest(i,null,!0)}sum(e="#v",r=!1,n=null){if(r!=null&&typeof r!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(n!=null&&typeof n!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let i=o=>{let s=0,a=!1;for(let l of this.query(o,n)){if(l==null||l===""){a=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(r)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}s+=l}return r&&a?null:s};return e.includes(",")?e.split(",").map(o=>i(o.trim())):i(e)}sort(e="#k:a"){let r=(i,o)=>i==null?[-1,""]:o&&typeof i=="string"?[0,i.toLowerCase()]:[0,i],n=(i,o)=>i[0]!==o[0]?i[0]-o[0]:i[1]<o[1]?-1:i[1]>o[1]?1:0;if(typeof e=="function")this._nodes._list.sort((i,o)=>{let s=e(i),a=e(o);return s<a?-1:s>a?1:0});else{let i=e.split(",");i.reverse();for(let o of i){let s,a;o.includes(":")?[s,a]=o.split(":",2):(s=o,a="a"),s=s.trim(),a=a.trim();let l=a==="d"||a==="D",u=a==="a"||a==="d",c;if(s.toLowerCase()==="#k")c=f=>r(f.label,u);else if(s.toLowerCase()==="#v")c=f=>r(f.value,u);else if(s.toLowerCase().startsWith("#a.")){let f=s.slice(3);c=h=>r(h.getAttr(f),u)}else c=f=>{let h=f.value,d=h instanceof t?h.getItem(s):h?h[s]:null;return r(d,u)};this._nodes._list.sort((f,h)=>{let d=n(c(f),c(h));return l?-d:d})}}return this}equalTo(e){return e instanceof t?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let r=null;e.includes("?")&&([e,r]=e.split("?",2));let n=this.getNode(e);return n===null?!1:r===null?!0:r.split("&").every(i=>i in n.attr)}else if(e&&e.label!==void 0)return[...this._nodes].includes(e);return!1}getResolver(e){let r=this.getNode(e);return r?r.resolver:null}setResolver(e,r){let n=this.getNode(e);n||(this.setItem(e,null),n=this.getNode(e)),n.resolver=r}setCallbackItem(e,r,n={}){let i=new Hr({callback:r,...n});this.setResolver(e,i)}move(e,r,n=!0){this._nodes.move(e,r,n)}asDict(e=!1,r=!1,n=!1,i=!1){let o={};for(let s of this._nodes){let a=s.value;if(i&&a==null)continue;let l=s.label;e&&(l=String(l)),r&&(l=l.toLowerCase()),n&&a instanceof t&&(a=t.prototype.asDict.call(a,e,r,n,i)),Object.defineProperty(o,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return o}setdefault(e,r=null){let n=this.getNode(e);return n?n.value:(this.setItem(e,r),r)}deepcopy(e=!1){let r=this.createChildBag();for(let n of this._nodes){let i=n.getValue(!e);i instanceof t&&(i=i.deepcopy(e));let o=new r.nodeClass(r,n.label,i);o.setAttr({...n.attr},!1,!1,!1),o.nodeTag=n.nodeTag,o.xmlTag=n.xmlTag,r._nodes._list.push(o),r._nodes._dict[o.label]=o}return r}update(e,r=null,n=null,i=!1){if(!(e instanceof t)){for(let o in e){let s=e[o];(!i||s!==null||!this._nodes.has(o))&&this.setItem(o,s,null,">",!1,!1,n,!1,n!==!1)}return}for(let o of[...e]){let s=o.label,a=r==="static"?o.resolver:null,l=a?null:o.getValue(),u=o.attr.__replace;delete o.attr.__replace;let c=this._nodes.get(s);if(c)if(c.setAttr(o.attr,n===null?!0:n,!0,!1),o.nodeTag!=null&&(c.nodeTag=o.nodeTag),o.xmlTag!=null&&(c.xmlTag=o.xmlTag),a)c.resolver=a,c.setValue(null,n===null?!0:n,null,null,!1,n);else{o.resolver&&(c.resolver=null);let f=c.getValue();l instanceof t&&f instanceof t&&!u?f.update(l,r,n,i):(!i||l!==null)&&c.setValue(l,n===null?!0:n,null,null,!1,n)}else{let f=this.setItem(s,a||l,o.attr,">",!1,!1,n,!1,n!==!1);f.nodeTag=o.nodeTag,f.xmlTag=o.xmlTag}}}_fillFromBag(e){this.clear();for(let r of e){let n=new this.nodeClass(this,r.label);n.replace(r),n.nodeTag=r.nodeTag,n.xmlTag=r.xmlTag,this._nodes._list.push(n),this._nodes._dict[n.label]=n}}_appendLiteral(e,r,n=null,i=null,o=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let s=new this.nodeClass(this,e,null,n,i,o,null,!1);return r instanceof he?s.resolver=r:s._value=r,this._nodes._dict[e]=s,this._nodes._list.push(s),s}fillFrom(e=null,r={}){let n=Io(r);if(e!=null&&!ur(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let i=this.createChildBag(),o=new Set,s=(a,l,u)=>{if(o.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);o.add(l);try{let c=Array.isArray(l)?String(l.length).length+1:0,f=Array.isArray(l)?Array.from(l,(h,d)=>[`r_${String(d).padStart(c,"0")}`,h]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(h=>Object.prototype.propertyIsEnumerable.call(l,h)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[h,d]of f){let g=d;n&&(ur(g)||Array.isArray(g))&&(g=this.createChildBag(),s(g,d,`${u}[${JSON.stringify(h)}]`)),a._appendLiteral(h,g)}}finally{o.delete(l)}};return e!=null&&s(i,e,"$"),this._replacePrepared(i)}_loadSource(e,r={}){return this.fillFrom(e,r)}replace(e){if(!(e instanceof t))throw new TypeError("Bag.replace expects a Bag");if(e===this)return this;let r=this.createChildBag();return r._fillFromBag(e),this._replacePrepared(r)}_replacePrepared(e){for(let n of this._nodes){n.parentBag=null;let i=n.getValue(!0);i instanceof t&&i.clearBackref()}let r=this._nodes;this._nodes=e._nodes,e._nodes=r,this._nodes._parentBag=this.backref?this:null,e._nodes._parentBag=null;for(let n of this._nodes)n.parentBag=this;for(let n of e._nodes)n._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:r=!0,deep:n=!1,kwargs:i={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let o=(s,a)=>{for(let l=0;l<s._nodes.length;l++){let u=s._nodes._list[l],c={...a};"_pathlist"in a&&(c._pathlist=[...a._pathlist,u.label]),"_indexlist"in a&&(c._indexlist=[...a._indexlist,l]);let f=e(u,c,l);if(f)return f;if(f==null&&n){let h=u.getValue(r);if(h instanceof t){let d=o(h,c);if(d)return d}}}return null};return o(this,i)}*traverse(){for(let e of this._nodes){yield e;let r=e.getValue(!0);r instanceof t&&(yield*r.traverse())}}*_iterNodesWithPaths(e=!0,r=""){for(let n of this._nodes){let i=r?`${r}.${n.label}`:n.label;yield[i,n];let o=n.getValue(e);o instanceof t&&(yield*o._iterNodesWithPaths(e,i))}}*_nodeFlattener(e=null){let r=e!==null,n=r?Object.create(null):null,i=0,o=new Map([["[]",this.constructor]]);for(let[s,a]of tl(this)){let l=s.slice(0,-1),u=JSON.stringify(s),c=JSON.stringify(l),f=a.getValue(!0),h,d=null;if(a.resolver)h=Xr(a.resolver);else if(f instanceof t){let y=f.constructor,m=y.tytxSuffix;o.set(u,y),d=_o(y,ar(o.get(c),m)),h=`::${m}`}else f===null?h="::NN":h=ft(f);if(a.attr&&Object.hasOwn(a.attr,Fe))throw new Q(`node '${s}': the attribute '${Fe}' is reserved for the Bag class name`);let g=fi(ft(a.attr));d!==null&&(g[Fe]=d);let p=a.nodeTag;r?(yield[l.length?n[c]:null,a.label,p,h,g],f instanceof t&&(n[u]=i,e[i]=s,i++)):yield[l,a.label,p,h,g]}}toTytx(e="json",r=!1){let n=this._toTytxPayload(r),i=this.constructor.tytxSuffix;if(e==="json")return`${n}::${i}`;if(e==="msgpack")return hn(new Oe(4,new TextEncoder().encode(`${i}:${n}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let r;if(e){let o={};r={rows:[...this._nodeFlattener(o)],paths:o}}else r={rows:[...this._nodeFlattener(null)]};let n=this.constructor,i=_o(n,ar(null,n.tytxSuffix));return i!==null&&(r[Fe]=i),r.rows=r.rows.map(([o,s,a,l,u])=>[ft(o),ft(s),ft(a),l,u]),r.paths&&(r.paths=ft(r.paths)),_e(r)}static fromTytx(e,r="json",n={}){if(ur(r)&&(n=r,r="json"),Io(n),typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError("fromTytx requires serialized text or bytes");if(r!=="json"&&r!=="msgpack")throw new TypeError(`Unsupported transport: ${r}`);r==="json"&&e instanceof Uint8Array&&(e=new TextDecoder().decode(e));let i=te(e,r==="json"?null:r);if(i instanceof t)return i;if(!ur(i)&&!Array.isArray(i))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(i,n)}static _fromTytxPayload(e){let r=this.tytxSuffix;if(e==="")return new(ar(null,r));let n=te(e);if(!n||!Array.isArray(n.rows))throw new Q("Invalid TYTX Bag: expected rows");let i=n.paths,o=i!=null,s=Object.hasOwn(n,Fe)?No(r,n[Fe]):ar(null,r),a=new s,l=new Map([["[]",a]]);for(let u of n.rows){if(!Array.isArray(u)||u.length!==5)throw new Q("Invalid TYTX Bag row");let[c,f,h,d,g]=u,p=c??"";if(o){if(c!==null&&!Object.hasOwn(i,c))throw new Q(`Unknown TYTX parent reference: ${c}`);p=c===null?"":i[c]}if(typeof p=="string"&&(p=p?p.split("."):[]),!Array.isArray(p))throw new Q("Invalid TYTX parent path");let y=JSON.stringify(p);if(!l.has(y))throw new Q(`Missing or undecodable TYTX parent branch: ${p}`);let m=l.get(y),w=JSON.stringify([...p,f]),b=d,v=ci(b),x=So(g),T=Object.hasOwn(x,Fe)?x[Fe]:null;if(delete x[Fe],b instanceof t){let C=b.constructor.tytxSuffix,M=T!==null?No(C,T):ar(m.constructor,C);b=new M,l.set(w,b)}else if(T!==null)throw new Q(`node '${w}': the attribute '${Fe}' is reserved for the Bag class name of a branch`);let E=m._appendLiteral(f,v?null:b,x,v);E.nodeTag=h??null}return a}toXml(e={}){let{pretty:r=!1,encoding:n="UTF-8",docHeader:i=null,selfClosedTags:o=null}=e,s=this._bagToXml(o,r);return i===!0?s=`<?xml version='1.0' encoding='${n}'?>
41
+ ${s}`:typeof i=="string"&&(s=`${i}
42
+ ${s}`),s}_bagToXml(e=null,r=!1,n=0){let i=[];for(let o of this._nodes)i.push((r?" ".repeat(n):"")+this._nodeToXml(o,e,r,n));return i.join(r?`
43
+ `:"")}_nodeToXml(e,r=null,n=!1,i=0){let o=e.xmlTag||e.nodeTag||e.label,s=this._sanitizeTag(o),a=[];if(s!==o&&a.push(`_tag="${this._escapeAttr(o)}"`),e.resolver&&a.push(`_resolver="${this._escapeAttr(Xr(e.resolver))}"`),e.attr)for(let[h,d]of Object.entries(fi(e.attr)))d!==null&&d!==!1&&d!==void 0&&a.push(`${h}="${this._escapeAttr(String(d))}"`);let l=a.length?" "+a.join(" "):"",u=e.resolver?null:e.getValue(!0);if(u&&typeof u._bagToXml=="function"){n=n&&e.attr?.["xml:space"]!=="preserve";let h=u._bagToXml(r,n,i+1);return h?n?`<${s}${l}>
44
44
  ${h}
45
- ${" ".repeat(i)}</${o}>`:`<${o}${l}>${h}</${o}>`:r===null||r.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`}if(u==null||u==="")return r===null||r.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?rd(u):String(u),f=this._escapeXml(c);return`<${o}${l}>${f}</${o}>`}_sanitizeTag(e){return e?e.replace(/[^a-zA-Z0-9_\-.:]/g,"_"):"_none_"}_escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_escapeAttr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}static fromXml(e,r={}){let{tagAttribute:n=null}=r,i;if(typeof DOMParser<"u"){i=new DOMParser().parseFromString(e,"application/xml");let o=i.querySelector("parsererror");if(o)throw new Error(`XML parse error: ${o.textContent}`)}else i=new Eu.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(i.documentElement,n)}static _xmlElementToBag(e,r=null){let n=new this,i=Array.from(e.childNodes).filter(s=>s.nodeType===1);for(let s of i){let o=s.tagName,a={};for(let m=0;m<s.attributes.length;m++){let g=s.attributes[m];a[g.name]=g.value}let l=Qn(a._resolver);l&&delete a._resolver;let u=String(a._T||"").toUpperCase()==="BAG";Object.assign(a,cs(a));let c=o;"_tag"in a&&(c=a._tag,delete a._tag),r&&r in a&&(c=a[r],delete a[r]);let f=c,h=1;for(;n.getNode(c);)c=`${f}_${h++}`;let d=Array.from(s.childNodes).filter(m=>m.nodeType===1),p;if(d.length>0||u){let m=this._xmlElementToBag(s,r);p=n.setItem(c,m,Object.keys(a).length>0?a:null)}else{let m=s.textContent||"";p=n.setItem(c,m,Object.keys(a).length>0?a:null)}l&&(p.resolver=l),p.xmlTag=o}return n}static async fromUrl(e,r={}){let{timeout:n=30}=r,i={};n&&(i.signal=AbortSignal.timeout(n*1e3));let s=await fetch(e,i),o=s.headers.get("content-type")||"",a=await s.text();if(o.includes("json"))return t.fromTytx(a);if(o.includes("xml"))return t.fromXml(a);let l=a.trim();if(l.startsWith("<"))return t.fromXml(a);if(l.startsWith("{")||l.startsWith("["))return t.fromTytx(a);throw new Pr(`Unsupported content-type: ${o}`)}toJson(e=!0){let r=[];for(let n of this._nodes)r.push(this._nodeToJsonDict(n,e));return e?xe(r):JSON.stringify(r)}_nodeToJsonDict(e,r){let n=e.resolver?null:e.getValue(!0);if(n&&typeof n._nodeToJsonDict=="function"){let s=[];for(let o of n._nodes)s.push(n._nodeToJsonDict(o,r));n=s}let i={label:e.label,value:n,attr:Kn(e.attr)};return e.nodeTag!==null&&(i.tag=e.nodeTag),e.resolver&&(i.resolver=Lr(e.resolver)),i}static fromJson(e,r={}){return wu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),wu=!0),this.fromTytx(e,"json",r)}toStringTree(e=!0,r=null,n="",i=!0){r===null&&(r=new Map);let s=[],o=[...this._nodes];for(let a=0;a<o.length;a++){let l=o[a],u=a===o.length-1,c=l.getValue(e),f=l.getAttr(),h="",d=Object.keys(f);d.length>0&&(h=" ["+d.map(y=>`${y}=${JSON.stringify(f[y])}`).join(", ")+"]");let p=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",m=n+(u?" ":"\u2502 ");if(c instanceof t){let g=l,y=c.backref?"(*)":"";if(r.has(g))s.push(`${n}${p}${l.label}${y}${h} \u2192 (circular ref)`);else{r.set(g,l.label),s.push(`${n}${p}${l.label}${y}${h}`);let E=c.toStringTree(e,r,m,u);E&&s.push(E)}}else{let g;if(c===null)g="null";else if(c===void 0)g="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let y=new TextDecoder("utf-8",{fatal:!1}),E=c instanceof ArrayBuffer?new Uint8Array(c):c;g=y.decode(E)}else typeof c=="string"?c.length>50?g=JSON.stringify(c.slice(0,47)+"..."):g=JSON.stringify(c):g=String(c);s.push(`${n}${p}${l.label}: ${g}${h}`)}}return s.join(`
46
- `)}toString(e=!0,r=null,n=""){r||(r=new Set);let i=[],s=[...this._nodes];for(let o=0;o<s.length;o++){let a=s[o],l=o===s.length-1,u=a.getValue(e),c="",f=a.attr;f&&Object.keys(f).length>0&&(c=` [${Object.entries(f).map(([m,g])=>`${m}=${JSON.stringify(g)}`).join(", ")}]`);let h=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",d=n+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let p=a;if(r.has(p))i.push(`${n}${h}${a.label}${c} \u2192 (circular ref)`);else{r.add(p),i.push(`${n}${h}${a.label}${c}`);let m=u.toString(e,r,d);m&&i.push(m)}}else{let p;u==null?p="null":typeof u=="string"&&u.length>50?p=JSON.stringify(u.slice(0,47)+"..."):typeof u=="string"?p=JSON.stringify(u):p=String(u),i.push(`${n}${h}${a.label}: ${p}${c}`)}}return i.join(`
47
- `)}},Pr=class extends Error{constructor(e){super(e),this.name="BagException"}};le.registerBagClass(Ne);Zi(Ne,"X",t=>t._toTytxPayload(),t=>Ne._fromTytxPayload(t));Qi(Ne.tytxSuffix,{...Gt(Ne.tytxSuffix),Bag:Ne});function ps(t,e){let r=[],n=Object.freeze({full:e.full,rows:Object.freeze([...e.rows]),event:e.event??null,field:e.field??null});for(let i of[...t])if(t.has(i))try{i(n)}catch(s){r.push(s)}if(r.length)throw new AggregateError(r,"Collection notification failed")}var ei=class{#e;#t=null;#s=new Set;#r=new Map;#n="";#i=new Map;#o=null;constructor(e){this.bindStore(e)}get bag(){return this.#e.bag}get rowMode(){return this.#e.rowMode}get sortedBy(){return this.#n}get criteria(){return Du(this.#n)}get filter(){return this.#i.get("search")?.definition??null}get filterSignature(){return JSON.stringify([...this.#i].map(([e,{definition:r}])=>[e,r]))}get filterContributions(){return Object.freeze([...this.#i].map(([e,r])=>Object.freeze([e,Object.freeze({...r})])))}copyFiltersFrom(e){this.filterSignature!==e.filterSignature&&this.#a(this.#u(),this.#n,new Map(e.filterContributions))}get filtered(){return this.#o===null?null:[...this.#o]}isFiltered(){return this.#o!==null}value(e,r){return this.#e.value(e,r)}subscribe(e){return this.#s.add(e),()=>this.#s.delete(e)}connect(){this.#t||(this.synchronize(),this.#t=this.#e.subscribe(e=>this.synchronize(e)))}disconnect(){this.#t?.(),this.#t=null}bindStore(e){if(this.#e===e)return;let r=this.#t!==null;this.disconnect(),this.#e=e,this.#r.clear(),r?this.connect():this.synchronize()}getRows(e=!0){let r=this.#u();return e&&this.#o!==null?this.#o.map(n=>r[n]):r}#u(){return this.#e.getRows().toSorted((e,r)=>(this.#r.get(e)??1/0)-(this.#r.get(r)??1/0))}synchronize(e={full:!0,rows:[]}){if(!e.full&&!this.#n&&!this.#i.size){ps(this.#s,{full:e.full,rows:e.rows});return}this.#a(this.#f(this.#u(),this.criteria),this.#n,this.#i,e)}sort(e){let r=this.#f(this.#u(),Du(e));this.#a(r,e,this.#i)}moveRow(e,r,n=!1){if(e===r||e.parentBag!==this.bag||r.parentBag!==this.bag)return;let i=this.getRows(!1);i.splice(i.indexOf(e),1),i.splice(i.indexOf(r)+Number(n),0,e),this.#a(i,"",this.#i)}applyFilter(e,r="search"){if(!["base","search"].includes(r))throw new TypeError("Unknown collection filter contribution");let n=e===null?null:Object.freeze({...e,columns:Object.freeze([...e.columns])});this.#c(r,n,fu(n))}applySetFilter(e){let r=e===null?null:Object.freeze(e.map(({field:i,value:s})=>{if(typeof i!="string"||!i)throw new TypeError("Set filter requires an identity field");return du(s),Object.freeze({field:i,value:s})})),n=r===null?null:i=>r.every(({field:s,value:o})=>hu(o,pu(i(s))));this.#c("sets",r,n)}columnFilter(e){return this.#i.get(`column:${e}`)?.definition.values??null}columnRange(e){let r=this.#i.get(`column:${e}`)?.definition.range;return r?{...r,from:r.from&&new Date(r.from+"T00:00:00Z"),to:r.to&&new Date(r.to+"T00:00:00Z")}:null}applyColumnFilter(e,r,n=this.columnRange(e)){if(n=tu(n),typeof e!="string"||!e)throw new TypeError("Column filter requires a field");let i=r===null?null:eu(r),s=i?.map(gt),o=i===null&&n===null?null:Object.freeze({field:e,values:i,keys:s&&Object.freeze(s),range:n}),a=o===null?null:l=>Xn(l(e),n)&&(s===void 0||s.includes(gt(l(e))));this.#c(`column:${e}`,o,a)}columnFacets(e){let r=new Map,n=this.#i.get(`column:${e}`)?.definition.range??null,i=this.columnFilter(e),s=i?.map(gt),o=[...this.#i].filter(([a])=>a!==`column:${e}`).map(([,a])=>a.predicate).filter(a=>a!==null);for(let a of this.#u()){let l=os(this.value(a,e)),u=gt(l);r.has(u)||r.set(u,{key:u,value:l,count:0,selected:Xn(l,n)&&(s===void 0||s.includes(u))}),o.every(c=>c(f=>this.value(a,f)))&&r.get(u).count++}for(let a of i??[]){let l=gt(a);r.has(l)||r.set(l,{key:l,value:a,count:0,selected:!0})}return[...r.values()].filter(a=>Xn(a.value,n))}#c(e,r,n){if(JSON.stringify(this.#i.get(e)?.definition??null)===JSON.stringify(r))return;let i=new Map(this.#i);r===null?i.delete(e):i.set(e,{definition:r,predicate:n}),this.#a(this.#u(),this.#n,i)}#a(e,r,n,i={full:!1,rows:[]}){let s=[...n.values()].map(c=>c.predicate).filter(c=>c!==null),o=s.length?e.flatMap((c,f)=>s.every(h=>h(d=>this.value(c,d)))?[f]:[]):null,a=i.full||r!==this.#n||n!==this.#i||e.length!==this.#r.size||e.some((c,f)=>this.#r.get(c)!==f)||JSON.stringify(o)!==JSON.stringify(this.#o);this.#r=new Map(e.map((c,f)=>[c,f])),this.#n=r,this.#i=n,this.#o=o;let l=o===null?null:new Set(o),u=a?[]:i.rows.filter(c=>this.#r.has(c)&&(l===null||l.has(this.#r.get(c))));(a||u.length||i.rows.length)&&ps(this.#s,{full:a,rows:u})}#f(e,r){if(!r.length)return e;let n=e.map(i=>({node:i,keys:r.map(({field:s})=>this.value(i,s))}));for(let i=0;i<r.length;i++)if(new Set(n.map(o=>od(o.keys[i])).filter(o=>o!==null)).size>1)throw new TypeError(`collection view cannot compare mixed types in ${r[i].field}`);return n.sort((i,s)=>{for(let[o,{direction:a}]of r.entries()){let l=ad(i.keys[o],s.keys[o]);if(l)return a==="a"?l:-l}return 0}).map(i=>i.node)}};function Du(t){if(typeof t!="string")throw new TypeError("collection view sortedBy must be a string");if(t==="")return[];let e=new Set;return t.split(",").map(r=>{let n=/^([^,:]+):([ad])$/.exec(r);if(!n||e.has(n[1]))throw new TypeError(`Invalid collection view sort criterion: ${r}`);return e.add(n[1]),{field:n[1],direction:n[2]}})}function od(t){if(t==null)return null;if(typeof t=="number"&&Number.isFinite(t)||ie(t)&&t.isFinite())return"number";if(t instanceof Date&&Number.isFinite(t.getTime()))return"date";if(typeof t=="string"||typeof t=="boolean")return typeof t;throw new TypeError("collection view sort requires loaded finite scalar values")}function ad(t,e){return t==null||e==null?t==null?e==null?0:-1:1:ie(t)?t.comparedTo(e):ie(e)?-e.comparedTo(t):t<e?-1:t>e?1:0}var ti=class{#e=null;#t=null;#s;#r;constructor(e,r){this.#r=new ei(e),r&&this.follow(r),this.#r.connect()}bindStore(e){this.detach(),this.#r.bindStore(e)}get view(){return this.#r}follow(e){if(e.bag!==this.#r.bag||e.rowMode!==this.#r.rowMode)throw new TypeError("Chart and grid must use the same collection");this.#t?.(),this.#e=e,this.#s=void 0,this.#n(),this.#t=e.subscribe(()=>this.#n())}#n(){let e=this.#e.filterSignature;e!==this.#s&&(this.#r.copyFiltersFrom(this.#e),this.#s=e)}detach(){this.#t?.(),this.#t=null,this.#e=null}dispose(){this.detach(),this.#r.disconnect()}};import{Bag as vu}from"@gramlot/gramlot";var ms=new WeakMap;function ud(t){if(!ms.has(t)){let e=`chart_${He()}`;class r{toggleMeasure(i){let s=i.getAttr("selectionPath");i.setRelativeData(s,!i.getRelativeData(s))}}t.logicRegistry.register(r,{group:e,resource:"gramlot:charts"}),ms.set(t,`${e}.toggleMeasure`)}return ms.get(t)}function ld(t){let e=t.getRows(),r=[...new Set(e.flatMap(s=>t.rowMode==="attributes"?Object.keys(s.getAttr()):s.staticValue.getNodes().map(o=>o.label)))],n=r.filter(s=>e.every(o=>{let a=t.value(o,s);return typeof a=="number"&&Number.isFinite(a)})),i=r.filter(s=>e.some(o=>t.value(o,s)instanceof Date)&&e.every(o=>{let a=t.value(o,s);return a==null||a instanceof Date&&Number.isFinite(a.getTime())}));return{fields:r,measures:n,dates:i}}var Tu=(0,J.defineComponent)({name:"chartFields",tag:"gramlot-chart-fields",base:je,sourceContext:!0,bagStore:!0,parameters:{timeFieldId:{dtype:"T"},storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},categoryId:{dtype:"T"},mapMeasureId:{dtype:"T"},mapLabelId:{dtype:"T"},secondCategoryId:{dtype:"T"},geometryId:{dtype:"T"},measureMenuId:{dtype:"T"}},implementation:t=>class extends t{#e;#t;#s;#r;#n;#i=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){if(!(e instanceof vu))throw new TypeError("chartFields requires a Data Bag");this.#t=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#i&&this.#o(),n}connectedCallback(){this.#i=!0,this.#o()}#o(){let r=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);r!==this.#s&&(this.#r?.(),this.#s=r,this.#n=void 0,this.#r=r.subscribe(()=>this.#u(r)),this.#u(r))}#u(e){if(!e.getRows().length)return;let{fields:r,measures:n,dates:i}=ld(e),s=JSON.stringify([r,n,i]);if(s===this.#n)return;let o=this.#e.sourceNode,a=o.getRelativeData(this.parameters.configpath),l=a.getItem("seriesOptions"),u=o.rootBuilder.binding,c=u.nodeIds.get(this.parameters.categoryId),f=u.nodeIds.get(this.parameters.measureMenuId),h=["#5470c6","#ee6666","#3ba272","#fac858","#9a60b4","#73c0de"];for(let p of[...l.getNodes()])n.includes(p.label)||l.popNode(p.label);n.forEach((p,m)=>{l.getNode(p)||l.setItem(p,new vu);let g=l.getItem(p);for(let[y,E]of Object.entries({axis:"left",color:h[m%h.length],caption:p.charAt(0).toUpperCase()+p.slice(1),selected:!0}))g.getNode(y)||g.setItem(y,E)});let d=(p,m,g=y=>y.charAt(0).toUpperCase()+y.slice(1))=>{let y=new Set;for(let E of[...p.value.getNodes()]){let w=E.getAttr("value");m.includes(w)?y.add(w):p.value.popNode(E.label)}m.forEach(E=>{y.has(E)||p.builder.wrapSource(p).option(g(E),{value:E,node_label:`field_${He()}`})}),m.length||p.builder.wrapSource(p).option("No columns",{value:"",node_label:"empty"})};d(c,r),this.parameters.timeFieldId&&(d(u.nodeIds.get(this.parameters.timeFieldId),["",...i],p=>p?p.charAt(0).toUpperCase()+p.slice(1):"Off"),a.getItem("timeField")&&!i.includes(a.getItem("timeField"))&&(a.setItem("timeField",""),a.setItem("timePlaying",!1))),d(u.nodeIds.get(this.parameters.mapMeasureId),n,p=>l.getItem(p).getItem("caption")),d(u.nodeIds.get(this.parameters.mapLabelId),r),n.includes(a.getItem("mapValueField"))||a.setItem("mapValueField",n.find(p=>l.getItem(p).getItem("selected"))??n[0]??""),r.includes(a.getItem("mapLabelField"))||a.setItem("mapLabelField",r.includes(a.getItem("captionField"))?a.getItem("captionField"):r[0]??""),d(u.nodeIds.get(this.parameters.geometryId),r),d(u.nodeIds.get(this.parameters.secondCategoryId),r);for(let p of[...f.value.getNodes()])f.value.popNode(p.label);n.forEach((p,m)=>{let g=`${this.parameters.configpath}.seriesOptions.${p}.selected`;f.builder.wrapSource(f).menuline({node_label:`measure_${m}`,caption:l.getItem(p).getItem("caption"),checked:`^${g}`,selectionPath:g,action:ud(u)})}),n.length||f.builder.wrapSource(f).menuline({caption:"No measures",disabled:!0,node_label:"empty"}),r.includes(a.getItem("captionField"))||a.setItem("captionField",r[0]??""),r.includes(a.getItem("secondCaptionField"))||a.setItem("secondCaptionField",r.find(p=>p!==a.getItem("captionField"))??""),r.includes(a.getItem("geometryField"))||a.setItem("geometryField",r.find(p=>e.getRows().every(m=>Array.isArray(e.value(m,p))))??""),this.#n=s}disconnectedCallback(){this.#i=!1,this.#r?.(),this.#r=null,this.#s=null,this.#n=void 0}}});import{Bag as xu}from"@gramlot/gramlot";function cd(t,e,r){if(!(r instanceof xu))throw new TypeError("seriesOptions requires a Bag");let n=Fn(e.getItem("chartType")),i=e.getItem("captionField"),s=e.getItem("valueFields");if(s!==null&&typeof s!="string")throw new TypeError("valueFields requires comma-separated codes or null");let o=s?s.split(","):[];if(o.some(l=>!l)||new Set(o).size!==o.length)throw new TypeError("valueFields requires distinct nonempty fields");if(typeof i!="string"||!i)throw new TypeError("Chart requires captionField");n.measureLimit!==null&&(o=o.slice(0,n.measureLimit));let a=o.map(l=>{let u=r.getItem(l);if(!(u instanceof xu))throw new TypeError(`Missing seriesOptions for ${l}`);let c=u.getItem("axis"),f=u.getItem("color");if(!["left","right"].includes(c)||typeof f!="string"||!/^#[0-9a-f]{6}$/i.test(f))throw new TypeError("Series requires left/right axis and a six-digit hex color");return{axis:c,color:f}});return{view:t,category:i,structure:e,fields:o,settings:a,seriesOptions:r,type:n}}var Ur=class{#e;#t;#s;#r;#n;#i;#o=0;constructor(e,r,n={}){this.#e=e,this.#t=r,this.#s=n}async prepare(e,r){await is(e,r).load(r)}invalidate(){this.#o++}update(e,r){let n=e.getItem("engine")??"echarts",i=cd(this.#t,e,r);i.domains=this.#s.domains?this.#s.domains(i):null;let s=is(n,i.type.id),o=++this.#o;n!==this.#n&&(this.#r?.dispose(),this.#i?.remove(),this.#i=null,this.#e&&(this.#i=this.#e.ownerDocument.createElement("div"),this.#i.style.cssText="width:100%;height:100%;position:relative",this.#e.append(this.#i)),this.#r=new s(this.#i,this.#s),this.#n=n);let a=this.#r.validate(i);return this.#r.update(i,a,()=>o===this.#o)}svg(){return this.#r.svg()}resize(){this.#r?.resize()}dispose(){this.invalidate(),this.#r?.dispose(),this.#r=null,this.#n=null,this.#i?.remove(),this.#i=null}};var fd=(0,J.defineComponent)({name:"chartView",tag:"gramlot-chart-view",base:je,sourceContext:!0,bagStore:!0,parameters:{sampleMin:{dtype:"R",nullable:!0,binding:"read"},sampleMax:{dtype:"R",nullable:!0,binding:"read"},sampleStep:{dtype:"R",default:1,binding:"read"},sampleStart:{dtype:"R",default:0,binding:"read"},mapLabelMode:{dtype:"T",default:"value",binding:"read"},mapBarScale:{dtype:"T",default:"zero",binding:"read"},selectedTerritory:{dtype:"T",default:"",binding:"twoWay"},configpath:{dtype:"T"},timeEmpty:{dtype:"T",default:"previous",binding:"read"},timeField:{dtype:"T",default:"",binding:"read"},timeValue:{dtype:"X",nullable:!0,binding:"read"},timeStep:{dtype:"T",default:"month",binding:"read"},engine:{dtype:"T",default:"echarts",binding:"read"},mapValueField:{dtype:"T",binding:"read"},mapLabelField:{dtype:"T",binding:"read"},geoJSON:{dtype:"X",nullable:!0,binding:"read"},geometryField:{dtype:"T",binding:"read"},secondCaptionField:{dtype:"T",binding:"read"},seriesOptions:{dtype:"X",binding:"read"},storepath:{dtype:"T"},rowMode:{dtype:"T"},gridId:{dtype:"T"},chartType:{dtype:"T",binding:"read"},captionField:{dtype:"T",binding:"read"},valueFields:{dtype:"T",nullable:!0,binding:"read"}},implementation:t=>class extends t{#e;#t;#s=0;#r=!1;#n;#i;#o;#u;#c;#a;#f;#l;#p;#h;#m=Symbol("chart-options");constructor(){super(),this.control.replaceChildren();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0;overflow:hidden}",this.shadowRoot.append(e),this.#n=this.ownerDocument.createElement("div"),this.#n.setAttribute("role","alert"),this.#n.hidden=!0,this.#n.style.cssText="padding:20px;white-space:normal",this.control=this.ownerDocument.createElement("div"),this.controlBox.append(this.#n,this.control),this.controlBox.style.backgroundColor="#fff",this.#n.style.color="#333",this.control.style.cssText="width:100%;height:100%;min-width:0;background:#fff",this.#p=new this.ownerDocument.defaultView.ResizeObserver(()=>this.#l?.resize())}setSourceContext(e){this.#i=e}setStoreBag(e){if(e!=null&&!(e instanceof gs)&&!Array.isArray(e))throw new TypeError("Chart requires a Data Bag or sample array");this.#o=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#g(),this.#r&&(this.#y(),this.#d()),n}#g(){let e=this.parameters.seriesOptions;if(!(e instanceof gs))throw new TypeError("seriesOptions requires a Bag");e!==this.#h&&(this.#h?.unsubscribe(this.#m,{any:!0}),this.#h=e,e.subscribe(this.#m,{any:()=>this.#d()}))}connectedCallback(){this.#r=!0,this.#g();let e=this.#i.sourceNode.rootBuilder.binding;if(this.parameters.gridId){let r=e.nodeIds.get(this.parameters.gridId);if(!r||r.nodeTag!=="grid")throw new TypeError("gridId requires an existing grid nodeId");if(r.absDatapath(r.getAttr("storepath"))!==this.#i.sourceNode.absDatapath(this.parameters.storepath))throw new TypeError("Chart and grid must use the same storepath");this.#u=Ka(r),this.#c=this.#u.subscribe(()=>this.#w())}this.#y(),this.#d(),this.#p.observe(this.control)}#y(){if(this.parameters.rowMode==="samples"){if(this.parameters.gridId||this.parameters.timeField)throw new TypeError("Sample charts do not use grid filters or temporal playback");this.#e||(this.#f?.(),this.#f=null,this.#a?.dispose(),this.#a=null,this.#l?.dispose(),this.#l=null,this.#e=new Gn),this.#e.bind(this.#o??[],this.parameters.sampleStep,this.parameters.sampleStart,this.parameters.captionField,this.parameters.valueFields),this.#l||(this.#t=new _r(this.#e),this.#l=new Ur(this.control,this.#t,{renderer:"svg",domains:r=>this.#e.domains(r,this.parameters.sampleMin,this.parameters.sampleMax)}));return}this.#e&&(this.#l.dispose(),this.#l=null,this.#e=null);let e=this.#i.sourceNode.rootBuilder.binding.collectionStore(this.#o,this.parameters.rowMode);this.#a?this.#a.view.bag!==this.#o&&this.#a.bindStore(e):(this.#a=new ti(e),this.#t=new _r(this.#a.view),this.#l=new Ur(this.control,this.#t,{renderer:"svg",domains:r=>this.#t.domains(r),onTerritorySelect:r=>this.#i.writeParameter("selectedTerritory",r)}),this.#f=this.#a.view.subscribe(()=>{this.#t.invalidateDomains(),this.#d()})),this.#u&&this.#w()}#w(){let e=this.#u.view;if(!e){this.#a?.detach();return}!this.#a||e.bag!==this.#o||(this.#a.follow(e),this.#d())}async#d(){if(!this.#l)return;let{engine:e,chartType:r,captionField:n,valueFields:i,secondCaptionField:s,geometryField:o,geoJSON:a,mapValueField:l,mapLabelField:u,mapLabelMode:c,mapBarScale:f}=this.parameters,h=++this.#s;this.#l.invalidate();try{this.#t.setPeriod(this.parameters.timeField,this.parameters.timeValue,this.parameters.timeStep,this.parameters.timeEmpty);let d=this.#t.getRows(),p=this.#t.snapshotDate;if(this.parameters.configpath){let g=this.#i.sourceNode,y=`${this.parameters.configpath}.timeSnapshotLabel`,E=p&&p.getTime()!==this.parameters.timeValue.getTime()?`Showing: ${In(p,this.parameters.timeStep)}`:"";g.getRelativeData(y)!==E&&g.setRelativeData(y,E)}if(!d.length&&!(this.parameters.timeField&&this.#a.view.getRows().some(g=>this.#a.view.value(g,this.parameters.timeField)!=null))){this.control.hidden=!0,this.#n.setAttribute("role","status"),this.#n.textContent="No data to display",this.#n.hidden=!1;return}if(await this.#l.prepare(e,r),h!==this.#s||!this.#l)return;this.control.hidden=!1;let m=new gs({engine:e,chartType:r,captionField:n,valueFields:i,secondCaptionField:s,geometryField:o,mapValueField:l,mapLabelField:u,mapLabelMode:c,mapBarScale:f});if(m.setItem("geoJSON",a),await this.#l.update(m,this.#h),h!==this.#s||!this.#l)return;this.#n.setAttribute("role","alert"),this.#n.hidden=!0,this.#n.textContent="",this.#l.resize()}catch(d){if(h!==this.#s||!this.#l)return;this.control.hidden=!0,this.#n.setAttribute("role","alert"),this.#n.textContent=d.message,this.#n.hidden=!1}}disconnectedCallback(){this.#r=!1,this.#s++,this.#h?.unsubscribe(this.#m,{any:!0}),this.#h=null,this.#p.disconnect(),this.#c?.(),this.#f?.(),this.#a?.dispose(),this.#l?.dispose(),this.#e=null,this.#u=this.#a=this.#l=this.#c=this.#f=null}}}),y1=es({name:"charts",assets:{echartsGlLicense:De["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:De["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:De["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:De["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:De["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]},components:[Qa,fd,Tu,Xa,Da]});export{y1 as default};
45
+ ${" ".repeat(i)}</${s}>`:`<${s}${l}>${h}</${s}>`:r===null||r.includes(s)?`<${s}${l}/>`:`<${s}${l}></${s}>`}if(u==null||u==="")return r===null||r.includes(s)?`<${s}${l}/>`:`<${s}${l}></${s}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?Gd(u):String(u),f=this._escapeXml(c);return`<${s}${l}>${f}</${s}>`}_sanitizeTag(e){return e?e.replace(/[^a-zA-Z0-9_\-.:]/g,"_"):"_none_"}_escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_escapeAttr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}static fromXml(e,r={}){let{tagAttribute:n=null}=r,i;if(typeof DOMParser<"u"){i=new DOMParser().parseFromString(e,"application/xml");let s=i.querySelector("parsererror");if(s)throw new Error(`XML parse error: ${s.textContent}`)}else i=new el.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(i.documentElement,n)}static _xmlElementToBag(e,r=null){let n=new this,i=Array.from(e.childNodes).filter(o=>o.nodeType===1);for(let o of i){let s=o.tagName,a={};for(let p=0;p<o.attributes.length;p++){let y=o.attributes[p];a[y.name]=y.value}let l=ci(a._resolver);l&&delete a._resolver;let u=String(a._T||"").toUpperCase()==="BAG";Object.assign(a,So(a));let c=s;"_tag"in a&&(c=a._tag,delete a._tag),r&&r in a&&(c=a[r],delete a[r]);let f=c,h=1;for(;n.getNode(c);)c=`${f}_${h++}`;let d=Array.from(o.childNodes).filter(p=>p.nodeType===1),g;if(d.length>0||u){let p=this._xmlElementToBag(o,r);g=n.setItem(c,p,Object.keys(a).length>0?a:null)}else{let p=o.textContent||"";g=n.setItem(c,p,Object.keys(a).length>0?a:null)}l&&(g.resolver=l),g.xmlTag=s}return n}static async fromUrl(e,r={}){let{timeout:n=30}=r,i={};n&&(i.signal=AbortSignal.timeout(n*1e3));let o=await fetch(e,i),s=o.headers.get("content-type")||"",a=await o.text();if(s.includes("json"))return t.fromTytx(a);if(s.includes("xml"))return t.fromXml(a);let l=a.trim();if(l.startsWith("<"))return t.fromXml(a);if(l.startsWith("{")||l.startsWith("["))return t.fromTytx(a);throw new Yr(`Unsupported content-type: ${s}`)}toJson(e=!0){let r=[];for(let n of this._nodes)r.push(this._nodeToJsonDict(n,e));return e?_e(r):JSON.stringify(r)}_nodeToJsonDict(e,r){let n=e.resolver?null:e.getValue(!0);if(n&&typeof n._nodeToJsonDict=="function"){let o=[];for(let s of n._nodes)o.push(n._nodeToJsonDict(s,r));n=o}let i={label:e.label,value:n,attr:fi(e.attr)};return e.nodeTag!==null&&(i.tag=e.nodeTag),e.resolver&&(i.resolver=Xr(e.resolver)),i}static fromJson(e,r={}){return Qu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),Qu=!0),this.fromTytx(e,"json",r)}toStringTree(e=!0,r=null,n="",i=!0){r===null&&(r=new Map);let o=[],s=[...this._nodes];for(let a=0;a<s.length;a++){let l=s[a],u=a===s.length-1,c=l.getValue(e),f=l.getAttr(),h="",d=Object.keys(f);d.length>0&&(h=" ["+d.map(m=>`${m}=${JSON.stringify(f[m])}`).join(", ")+"]");let g=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",p=n+(u?" ":"\u2502 ");if(c instanceof t){let y=l,m=c.backref?"(*)":"";if(r.has(y))o.push(`${n}${g}${l.label}${m}${h} \u2192 (circular ref)`);else{r.set(y,l.label),o.push(`${n}${g}${l.label}${m}${h}`);let w=c.toStringTree(e,r,p,u);w&&o.push(w)}}else{let y;if(c===null)y="null";else if(c===void 0)y="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let m=new TextDecoder("utf-8",{fatal:!1}),w=c instanceof ArrayBuffer?new Uint8Array(c):c;y=m.decode(w)}else typeof c=="string"?c.length>50?y=JSON.stringify(c.slice(0,47)+"..."):y=JSON.stringify(c):y=String(c);o.push(`${n}${g}${l.label}: ${y}${h}`)}}return o.join(`
46
+ `)}toString(e=!0,r=null,n=""){r||(r=new Set);let i=[],o=[...this._nodes];for(let s=0;s<o.length;s++){let a=o[s],l=s===o.length-1,u=a.getValue(e),c="",f=a.attr;f&&Object.keys(f).length>0&&(c=` [${Object.entries(f).map(([p,y])=>`${p}=${JSON.stringify(y)}`).join(", ")}]`);let h=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",d=n+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let g=a;if(r.has(g))i.push(`${n}${h}${a.label}${c} \u2192 (circular ref)`);else{r.add(g),i.push(`${n}${h}${a.label}${c}`);let p=u.toString(e,r,d);p&&i.push(p)}}else{let g;u==null?g="null":typeof u=="string"&&u.length>50?g=JSON.stringify(u.slice(0,47)+"..."):typeof u=="string"?g=JSON.stringify(u):g=String(u),i.push(`${n}${h}${a.label}: ${g}${c}`)}}return i.join(`
47
+ `)}},Yr=class extends Error{constructor(e){super(e),this.name="BagException"}};he.registerBagClass(ke);ho(ke,"X",t=>t._toTytxPayload(),t=>ke._fromTytxPayload(t));po(ke.tytxSuffix,{...Qt(ke.tytxSuffix),Bag:ke});function Oo(t,e){let r=[],n=Object.freeze({full:e.full,rows:Object.freeze([...e.rows]),event:e.event??null,field:e.field??null});for(let i of[...t])if(t.has(i))try{i(n)}catch(o){r.push(o)}if(r.length)throw new AggregateError(r,"Collection notification failed")}var hi=class{#e;#t=null;#n=new Set;#r=new Map;#o="";#i=new Map;#s=null;constructor(e){this.bindStore(e)}get bag(){return this.#e.bag}get rowMode(){return this.#e.rowMode}get sortedBy(){return this.#o}get criteria(){return rl(this.#o)}get filter(){return this.#i.get("search")?.definition??null}get filterSignature(){return JSON.stringify([...this.#i].map(([e,{definition:r}])=>[e,r]))}get filterContributions(){return Object.freeze([...this.#i].map(([e,r])=>Object.freeze([e,Object.freeze({...r})])))}copyFiltersFrom(e){this.filterSignature!==e.filterSignature&&this.#a(this.#l(),this.#o,new Map(e.filterContributions))}get filtered(){return this.#s===null?null:[...this.#s]}isFiltered(){return this.#s!==null}value(e,r){return this.#e.value(e,r)}subscribe(e){return this.#n.add(e),()=>this.#n.delete(e)}connect(){this.#t||(this.synchronize(),this.#t=this.#e.subscribe(e=>this.synchronize(e)))}disconnect(){this.#t?.(),this.#t=null}bindStore(e){if(this.#e===e)return;let r=this.#t!==null;this.disconnect(),this.#e=e,this.#r.clear(),r?this.connect():this.synchronize()}getRows(e=!0){let r=this.#l();return e&&this.#s!==null?this.#s.map(n=>r[n]):r}#l(){return this.#e.getRows().toSorted((e,r)=>(this.#r.get(e)??1/0)-(this.#r.get(r)??1/0))}synchronize(e={full:!0,rows:[]}){if(!e.full&&!this.#o&&!this.#i.size){Oo(this.#n,{full:e.full,rows:e.rows});return}this.#a(this.#f(this.#l(),this.criteria),this.#o,this.#i,e)}sort(e){let r=this.#f(this.#l(),rl(e));this.#a(r,e,this.#i)}moveRow(e,r,n=!1){if(e===r||e.parentBag!==this.bag||r.parentBag!==this.bag)return;let i=this.getRows(!1);i.splice(i.indexOf(e),1),i.splice(i.indexOf(r)+Number(n),0,e),this.#a(i,"",this.#i)}applyFilter(e,r="search"){if(!["base","search"].includes(r))throw new TypeError("Unknown collection filter contribution");let n=e===null?null:Object.freeze({...e,columns:Object.freeze([...e.columns])});this.#c(r,n,Gu(n))}applySetFilter(e){let r=e===null?null:Object.freeze(e.map(({field:i,value:o})=>{if(typeof i!="string"||!i)throw new TypeError("Set filter requires an identity field");return Xu(o),Object.freeze({field:i,value:o})})),n=r===null?null:i=>r.every(({field:o,value:s})=>Wu(s,Yu(i(o))));this.#c("sets",r,n)}columnFilter(e){return this.#i.get(`column:${e}`)?.definition.values??null}columnRange(e){let r=this.#i.get(`column:${e}`)?.definition.range;return r?{...r,from:r.from&&new Date(r.from+"T00:00:00Z"),to:r.to&&new Date(r.to+"T00:00:00Z")}:null}applyColumnFilter(e,r,n=this.columnRange(e)){if(n=Ru(n),typeof e!="string"||!e)throw new TypeError("Column filter requires a field");let i=r===null?null:ku(r),o=i?.map(Dt),s=i===null&&n===null?null:Object.freeze({field:e,values:i,keys:o&&Object.freeze(o),range:n}),a=s===null?null:l=>oi(l(e),n)&&(o===void 0||o.includes(Dt(l(e))));this.#c(`column:${e}`,s,a)}columnFacets(e){let r=new Map,n=this.#i.get(`column:${e}`)?.definition.range??null,i=this.columnFilter(e),o=i?.map(Dt),s=[...this.#i].filter(([a])=>a!==`column:${e}`).map(([,a])=>a.predicate).filter(a=>a!==null);for(let a of this.#l()){let l=xo(this.value(a,e)),u=Dt(l);r.has(u)||r.set(u,{key:u,value:l,count:0,selected:oi(l,n)&&(o===void 0||o.includes(u))}),s.every(c=>c(f=>this.value(a,f)))&&r.get(u).count++}for(let a of i??[]){let l=Dt(a);r.has(l)||r.set(l,{key:l,value:a,count:0,selected:!0})}return[...r.values()].filter(a=>oi(a.value,n))}#c(e,r,n){if(JSON.stringify(this.#i.get(e)?.definition??null)===JSON.stringify(r))return;let i=new Map(this.#i);r===null?i.delete(e):i.set(e,{definition:r,predicate:n}),this.#a(this.#l(),this.#o,i)}#a(e,r,n,i={full:!1,rows:[]}){let o=[...n.values()].map(c=>c.predicate).filter(c=>c!==null),s=o.length?e.flatMap((c,f)=>o.every(h=>h(d=>this.value(c,d)))?[f]:[]):null,a=i.full||r!==this.#o||n!==this.#i||e.length!==this.#r.size||e.some((c,f)=>this.#r.get(c)!==f)||JSON.stringify(s)!==JSON.stringify(this.#s);this.#r=new Map(e.map((c,f)=>[c,f])),this.#o=r,this.#i=n,this.#s=s;let l=s===null?null:new Set(s),u=a?[]:i.rows.filter(c=>this.#r.has(c)&&(l===null||l.has(this.#r.get(c))));(a||u.length||i.rows.length)&&Oo(this.#n,{full:a,rows:u})}#f(e,r){if(!r.length)return e;let n=e.map(i=>({node:i,keys:r.map(({field:o})=>this.value(i,o))}));for(let i=0;i<r.length;i++)if(new Set(n.map(s=>Jd(s.keys[i])).filter(s=>s!==null)).size>1)throw new TypeError(`collection view cannot compare mixed types in ${r[i].field}`);return n.sort((i,o)=>{for(let[s,{direction:a}]of r.entries()){let l=Zd(i.keys[s],o.keys[s]);if(l)return a==="a"?l:-l}return 0}).map(i=>i.node)}};function rl(t){if(typeof t!="string")throw new TypeError("collection view sortedBy must be a string");if(t==="")return[];let e=new Set;return t.split(",").map(r=>{let n=/^([^,:]+):([ad])$/.exec(r);if(!n||e.has(n[1]))throw new TypeError(`Invalid collection view sort criterion: ${r}`);return e.add(n[1]),{field:n[1],direction:n[2]}})}function Jd(t){if(t==null)return null;if(typeof t=="number"&&Number.isFinite(t)||se(t)&&t.isFinite())return"number";if(t instanceof Date&&Number.isFinite(t.getTime()))return"date";if(typeof t=="string"||typeof t=="boolean")return typeof t;throw new TypeError("collection view sort requires loaded finite scalar values")}function Zd(t,e){return t==null||e==null?t==null?e==null?0:-1:1:se(t)?t.comparedTo(e):se(e)?-e.comparedTo(t):t<e?-1:t>e?1:0}var di=class{#e=null;#t=null;#n;#r;constructor(e,r){this.#r=new hi(e),r&&this.follow(r),this.#r.connect()}bindStore(e){this.detach(),this.#r.bindStore(e)}get view(){return this.#r}follow(e){if(e.bag!==this.#r.bag||e.rowMode!==this.#r.rowMode)throw new TypeError("Chart and grid must use the same collection");this.#t?.(),this.#e=e,this.#n=void 0,this.#o(),this.#t=e.subscribe(()=>this.#o())}#o(){let e=this.#e.filterSignature;e!==this.#n&&(this.#r.copyFiltersFrom(this.#e),this.#n=e)}detach(){this.#t?.(),this.#t=null,this.#e=null}dispose(){this.detach(),this.#r.disconnect()}};import{Bag as pi}from"@gramlot/gramlot";var Mo=new WeakMap;function Kd(t){if(!Mo.has(t)){let e=`chart_${Je()}`;class r{toggleMeasure(i){let o=i.getAttr("selectionPath");i.setRelativeData(o,!i.getRelativeData(o))}}t.logicRegistry.register(r,{group:e,resource:"gramlot:charts"}),Mo.set(t,`${e}.toggleMeasure`)}return Mo.get(t)}function Qd(t){let e=t.getRows(),r=[...new Set(e.flatMap(o=>t.rowMode==="attributes"?Object.keys(o.getAttr()):o.staticValue.getNodes().map(s=>s.label)))],n=r.filter(o=>e.every(s=>{let a=t.value(s,o);return typeof a=="number"&&Number.isFinite(a)})),i=r.filter(o=>e.some(s=>t.value(s,o)instanceof Date)&&e.every(s=>{let a=t.value(s,o);return a==null||a instanceof Date&&Number.isFinite(a.getTime())}));return{fields:r,measures:n,dates:i}}var nl=(0,G.defineComponent)({name:"chartFields",tag:"gramlot-chart-fields",base:Be,sourceContext:!0,bagStore:!0,parameters:{timeFieldId:{dtype:"T"},storepath:{dtype:"T"},rowMode:{dtype:"T"},configpath:{dtype:"T"},categoryId:{dtype:"T"},mapMeasureId:{dtype:"T"},mapLabelId:{dtype:"T"},secondCategoryId:{dtype:"T"},geometryId:{dtype:"T"},measureMenuId:{dtype:"T"},measureRoleIds:{dtype:"T"}},implementation:t=>class extends t{#e;#t;#n;#r;#o;#i=!1;constructor(){super();let e=this.ownerDocument.createElement("style");e.textContent=":host{display:none}",this.shadowRoot.append(e)}setSourceContext(e){this.#e=e}setStoreBag(e){if(!(e instanceof pi))throw new TypeError("chartFields requires a Data Bag");this.#t=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#i&&this.#s(),n}connectedCallback(){this.#i=!0,this.#s()}#s(){let r=this.#e.sourceNode.rootBuilder.binding.collectionStore(this.#t,this.parameters.rowMode);r!==this.#n&&(this.#r?.(),this.#n=r,this.#o=void 0,this.#r=r.subscribe(()=>this.#l(r)),this.#l(r))}#l(e){if(!e.getRows().length)return;let{fields:r,measures:n,dates:i}=Qd(e),o=JSON.stringify([r,n,i]);if(o===this.#o)return;let s=this.#e.sourceNode,a=s.getRelativeData(this.parameters.configpath),l=a.getItem("seriesOptions"),u=s.rootBuilder.binding,c=u.nodeIds.get(this.parameters.categoryId),f=u.nodeIds.get(this.parameters.measureMenuId),h=["#5470c6","#ee6666","#3ba272","#fac858","#9a60b4","#73c0de"];for(let p of[...l.getNodes()])n.includes(p.label)||l.popNode(p.label);n.forEach((p,y)=>{l.getNode(p)||l.setItem(p,new pi);let m=l.getItem(p);for(let[w,b]of Object.entries({axis:"left",color:h[y%h.length],caption:p.charAt(0).toUpperCase()+p.slice(1),selected:!0}))m.getNode(w)||m.setItem(w,b)});let d=(p,y,m=w=>w.charAt(0).toUpperCase()+w.slice(1))=>{let w=new Set;for(let b of[...p.value.getNodes()]){let v=b.getAttr("value");y.includes(v)?w.add(v):p.value.popNode(b.label)}y.forEach(b=>{w.has(b)||p.builder.wrapSource(p).option(m(b),{value:b,node_label:`field_${Je()}`})}),y.length||p.builder.wrapSource(p).option("No columns",{value:"",node_label:"empty"})};d(c,r),this.parameters.timeFieldId&&(d(u.nodeIds.get(this.parameters.timeFieldId),["",...i],p=>p?p.charAt(0).toUpperCase()+p.slice(1):"Off"),a.getItem("timeField")&&!i.includes(a.getItem("timeField"))&&(a.setItem("timeField",""),a.setItem("timePlaying",!1))),d(u.nodeIds.get(this.parameters.mapMeasureId),n,p=>l.getItem(p).getItem("caption")),d(u.nodeIds.get(this.parameters.mapLabelId),r),n.includes(a.getItem("mapValueField"))||a.setItem("mapValueField",n.find(p=>l.getItem(p).getItem("selected"))??n[0]??""),r.includes(a.getItem("mapLabelField"))||a.setItem("mapLabelField",r.includes(a.getItem("captionField"))?a.getItem("captionField"):r[0]??""),d(u.nodeIds.get(this.parameters.geometryId),r);for(let p of this.parameters.measureRoleIds.split(","))d(u.nodeIds.get(p),["",...n],y=>y?l.getItem(y).getItem("caption"):"Choose a column");a.getItem("measureRoles")instanceof pi||a.setItem("measureRoles",new pi);let g=a.getItem("measureRoles");for(let p of ye)tr(p).forEach((y,m)=>{n.includes(g.getItem(y))||g.setItem(y,n[m]??"")});d(u.nodeIds.get(this.parameters.secondCategoryId),r);for(let p of[...f.value.getNodes()])f.value.popNode(p.label);n.forEach((p,y)=>{let m=`${this.parameters.configpath}.seriesOptions.${p}.selected`;f.builder.wrapSource(f).menuline({node_label:`measure_${y}`,caption:l.getItem(p).getItem("caption"),checked:`^${m}`,selectionPath:m,action:Kd(u)})}),n.length||f.builder.wrapSource(f).menuline({caption:"No measures",disabled:!0,node_label:"empty"}),r.includes(a.getItem("captionField"))||a.setItem("captionField",r[0]??""),r.includes(a.getItem("secondCaptionField"))||a.setItem("secondCaptionField",r.find(p=>p!==a.getItem("captionField"))??""),r.includes(a.getItem("geometryField"))||a.setItem("geometryField",r.find(p=>e.getRows().every(y=>Array.isArray(e.value(y,p))))??""),this.#o=o}disconnectedCallback(){this.#i=!1,this.#r?.(),this.#r=null,this.#n=null,this.#o=void 0}}});import{Bag as ol}from"@gramlot/gramlot";var _t=class extends TypeError{constructor(e){super(e.message),this.name="ChartSyntaxError",this.diagnosis=e}};function lr(t){return t.join(", ")}function Nt(t,e,r,n,i,o){throw new _t({type:t.id,role:e?e.name:null,message:r,expected:n,received:i,fix:o})}function ep(t,e){let r=e.getItem("valueFields");r!=null&&typeof r!="string"&&Nt(t,null,"valueFields requires comma-separated codes or null","comma-separated column codes",String(r),'Pass the measures as one string, for example "open,high,low,close".');let n=r?r.split(","):[];return(n.some(i=>!i)||new Set(n).size!==n.length)&&Nt(t,null,"valueFields requires distinct nonempty fields","distinct column codes",r,"Remove the empty or repeated codes from valueFields."),n}function tp(t,e,r){let[n]=e;if(n.count==="many"){n.required&&!r.length&&Nt(t,n,`${t.label} needs at least one measure.`,"one or more measures","none","Choose at least one numeric column as measure.");return}let i=e.map(s=>s.name),o=e.length===1?"one measure":`${e.length} measures in the order ${lr(i)}`;if(r.length<e.length){let s=e[r.length];Nt(t,s,`${t.label} needs ${o}; received ${r.length}.`,o,lr(r)||"none",e.length===1?"Choose one numeric column as measure.":`Choose a column for ${lr(i.slice(r.length))}.`)}r.length>e.length&&Nt(t,null,`${t.label} takes ${o}; received ${r.length}: ${lr(r)}.`,o,lr(r),`Remove ${lr(r.slice(e.length))} from the measures.`)}function il(t,e){for(let o of t.syntax){if(o.parameter==="valueFields"||!o.required)continue;let s=e.getItem(o.parameter);(typeof s!="string"||!s)&&Nt(t,o,`${t.label} needs ${o.caption} (${o.parameter}).`,`a column for ${o.caption}`,"none",`Choose the column for ${o.caption}: ${o.doc}`)}let r=t.syntax.find(o=>o.parameter==="secondCaptionField");if(r&&e.getItem("secondCaptionField")===e.getItem("captionField")){let o=t.syntax[0];Nt(t,r,`${t.label} needs ${r.caption} different from ${o.caption}.`,"two different columns",e.getItem("captionField"),`Choose another column for ${r.caption}.`)}let n=t.syntax.filter(o=>o.parameter==="valueFields");if(!n.length)return[];let i=ep(t,e);return tp(t,n,i),i}function rp(t,e,r){if(!(r instanceof ol))throw new TypeError("seriesOptions requires a Bag");let n=Gn(e.getItem("chartType")),i=e.getItem("captionField"),o=il(n,e),s=o.map(a=>{let l=r.getItem(a);if(!(l instanceof ol))throw new TypeError(`Missing seriesOptions for ${a}`);let u=l.getItem("axis"),c=l.getItem("color");if(!["left","right"].includes(u)||typeof c!="string"||!/^#[0-9a-f]{6}$/i.test(c))throw new TypeError("Series requires left/right axis and a six-digit hex color");return{axis:u,color:c}});return{view:t,category:i,structure:e,fields:o,settings:s,seriesOptions:r,type:n}}var Jr=class{#e;#t;#n;#r;#o;#i;#s=0;constructor(e,r,n={}){this.#e=e,this.#t=r,this.#n=n}async prepare(e,r){await Do(e,r).load(r)}invalidate(){this.#s++}update(e,r){let n=e.getItem("engine")??"echarts",i=rp(this.#t,e,r);i.domains=this.#n.domains?this.#n.domains(i):null;let o=Do(n,i.type.id),s=++this.#s;n!==this.#o&&(this.#r?.dispose(),this.#i?.remove(),this.#i=null,this.#e&&(this.#i=this.#e.ownerDocument.createElement("div"),this.#i.style.cssText="width:100%;height:100%;position:relative",this.#e.append(this.#i)),this.#r=new o(this.#i,this.#n),this.#o=n);let a=this.#r.validate(i);return this.#r.update(i,a,()=>s===this.#s)}svg(){return this.#r.svg()}resize(){this.#r?.resize()}dispose(){this.invalidate(),this.#r?.dispose(),this.#r=null,this.#o=null,this.#i?.remove(),this.#i=null}};var hl=Qr(Lo(),1);var sl=["needle","ring","arc"];function al(t){if(t==null||t==="")return null;let e=Number(t);if(!Number.isFinite(e))throw new TypeError(`gauge requires a number, received '${t}'`);return e}function ul(t){if(t==null||t==="")return[];if(typeof t!="string")throw new TypeError("gauge thresholds requires a string of value:color pairs");let e=t.split(",").map(r=>{let n=/^\s*(-?\d+(?:\.\d+)?)\s*:\s*(\S+)\s*$/.exec(r);if(!n)throw new TypeError(`Invalid gauge threshold '${r.trim()}': use value:color`);return{value:Number(n[1]),color:n[2]}}).sort((r,n)=>r.value-n.value);for(let r=1;r<e.length;r++)if(e[r].value===e[r-1].value)throw new TypeError(`Duplicate gauge threshold ${e[r].value}`);return e}function np(t,e,r){let n=r;for(let i of t)e>=i.value&&(n=i.color);return n}function ip(t,e,r,n){let i=[n,...t.map(a=>a.color)],o=[...t.map(a=>Math.min(1,Math.max(0,(a.value-e)/(r-e)))),1],s=[];return i.forEach((a,l)=>{o[l]>(s.at(-1)?.[0]??0)&&s.push([o[l],a])}),s}function op(t,e){let r=String(Math.round(t*100)/100);return(e??"{}").replaceAll("{}",()=>r)}var sp={needle:{startAngle:225,endAngle:-45,center:["50%","52%"],radius:"78%",width:14,detail:[0,"58%"],title:[0,"82%"]},ring:{startAngle:90,endAngle:-270,center:["50%","50%"],radius:"88%",width:16,detail:[0,"-6%"],title:[0,"28%"]},arc:{startAngle:180,endAngle:0,center:["50%","72%"],radius:"112%",width:16,detail:[0,"-22%"],title:[0,"14%"]}};function ll({value:t,min:e,max:r,mask:n,thresholds:i,presentation:o,caption:s,palette:a}){if(!sl.includes(o))throw new TypeError(`gauge presentation must be one of ${sl.join(", ")}`);if(!(Number.isFinite(e)&&Number.isFinite(r)&&e<r))throw new TypeError("gauge requires min lower than max");if(t!=null&&!Number.isFinite(t))throw new TypeError("gauge requires a finite number");let l=sp[o],u=o==="needle",c=t==null?null:Math.min(r,Math.max(e,t)),f=t==null?"":op(t,n);return{animationDuration:300,series:[{id:"gauge",type:"gauge",min:e,max:r,startAngle:l.startAngle,endAngle:l.endAngle,center:l.center,radius:l.radius,splitNumber:5,pointer:{show:u,length:"62%",width:5,itemStyle:{color:a.ink}},anchor:{show:u,size:10,showAbove:!0,itemStyle:{color:a.ink}},progress:{show:!u,width:l.width,roundCap:!0,itemStyle:{color:t==null?a.accent:np(i,t,a.accent)}},axisLine:{roundCap:!u,lineStyle:{width:l.width,color:u?ip(i,e,r,a.accent):[[1,a.track]]}},axisTick:{show:u,distance:-l.width-4,length:4,lineStyle:{color:a.muted,width:1}},splitLine:{show:u,distance:-l.width-6,length:8,lineStyle:{color:a.muted,width:2}},axisLabel:{show:u,distance:l.width+6,color:a.muted,fontSize:11},title:{show:!0,offsetCenter:l.title,color:a.muted,fontSize:13},detail:{show:!0,offsetCenter:l.detail,color:a.ink,fontSize:22,fontWeight:"bold",valueAnimation:!1,formatter:()=>f},data:c===null?[]:[{value:c,name:s??""}]}]}}var ap={error:"!",info:"i"},gi=`
48
+ .chart-notice{display:flex;align-items:flex-start;gap:10px;padding:16px 20px;font:13px/1.45 var(--gramlot-font-ui,system-ui,sans-serif);color:var(--gramlot-ink,#243449)}
49
+ .chart-notice[hidden]{display:none}
50
+ .chart-notice-icon{flex:none;display:grid;place-items:center;inline-size:20px;block-size:20px;border-radius:50%;font:700 13px/1 var(--gramlot-font-ui,system-ui,sans-serif);color:var(--gramlot-surface,#fff)}
51
+ .chart-notice[data-kind=error] .chart-notice-icon{background:var(--gramlot-error,#b13d48)}
52
+ .chart-notice[data-kind=info] .chart-notice-icon{background:var(--gramlot-text-secondary,#566579)}
53
+ .chart-notice-text{flex:1;min-inline-size:0;white-space:normal;overflow-wrap:anywhere}
54
+ .chart-notice button{flex:none;font:inherit;padding:2px 10px;border:1px solid var(--gramlot-border-control,#a9b4c2);border-radius:var(--gramlot-radius-sm,4px);background:var(--gramlot-surface,#fff);color:inherit;cursor:pointer}
55
+ .chart-notice-dialog{max-inline-size:min(640px,calc(100vw - 32px));border:1px solid var(--gramlot-border,#d5dce5);border-radius:var(--gramlot-radius,6px);padding:20px 24px;background:var(--gramlot-surface,#fff);color:var(--gramlot-ink,#243449);font:13px/1.5 var(--gramlot-font-ui,system-ui,sans-serif)}
56
+ .chart-notice-dialog h2{margin:0 0 12px;font-size:16px}
57
+ .chart-notice-dialog h3{margin:14px 0 4px;font-size:13px}
58
+ .chart-notice-dialog p{margin:0 0 6px}
59
+ .chart-notice-dialog table{border-collapse:collapse;inline-size:100%}
60
+ .chart-notice-dialog th,.chart-notice-dialog td{border-block-end:1px solid var(--gramlot-border,#d5dce5);padding:4px 6px;text-align:start;vertical-align:top}
61
+ .chart-notice-dialog code{font-family:var(--gramlot-font-code,ui-monospace,monospace)}
62
+ .chart-notice-dialog form{margin-block-start:16px;text-align:end}`;function up(t,e){if(t.parameter!=="valueFields"||t.count==="many")return t.parameter;let r=e.filter(n=>n.parameter==="valueFields");return r.length===1?"valueFields":`valueFields, position ${r.indexOf(t)+1}`}function mi(t){return[{title:`What ${t.label.toLowerCase()} shows`,paragraphs:[t.doc]},{title:"Columns it reads",table:[["Column","Parameter","Required","Description"],...t.syntax.map(e=>[e.caption,up(e,t.syntax),e.required?"yes":"no",e.count==="many"?`One or more. ${e.doc}`:e.doc])]}]}function cl(t,e){if(t instanceof _t){let{expected:r,received:n,fix:i}=t.diagnosis;return[{title:"What is wrong",paragraphs:[t.message]},{title:"Expected",paragraphs:[r]},{title:"Received",paragraphs:[n]},{title:"How to fix it",paragraphs:[i]},...mi(e)]}return e?[{title:"What is wrong",paragraphs:[t.message]},...mi(e)]:[{title:"What is wrong",paragraphs:[t.message]},{title:"Supported chart types",paragraphs:[ye.map(r=>`${r.id} (${r.label})`).join(", ")]}]}var cr=class{#e;#t;#n;#r;#o=[];constructor(e){this.#e=e.createElement("div"),this.#e.className="chart-notice",this.#e.hidden=!0,this.#t=e.createElement("span"),this.#t.className="chart-notice-icon",this.#t.setAttribute("aria-hidden","true"),this.#n=e.createElement("div"),this.#n.className="chart-notice-text",this.#n.hidden=!0,this.#n.setAttribute("role","alert");let r=e.createElement("button");r.type="button",r.textContent="More info",r.addEventListener("click",()=>this.open()),this.#r=e.createElement("dialog"),this.#r.className="chart-notice-dialog",this.#e.append(this.#t,this.#n,r,this.#r)}get element(){return this.#e}get hidden(){return this.#e.hidden}get dialog(){return this.#r}get text(){return this.#n}error(e,r,n){this.#i("error","alert",e,r,n)}info(e,r,n){this.#i("info","status",e,r,n)}hide(){this.#e.hidden=this.#n.hidden=!0,this.#n.textContent="",this.#r.open&&this.#r.close()}open(){let e=this.#r.ownerDocument,r=e.createElement("h2");r.textContent=this.#o.title;let n=[r];for(let s of this.#o.items){let a=e.createElement("h3");a.textContent=s.title,n.push(a);for(let l of s.paragraphs??[]){let u=e.createElement("p");u.textContent=l,n.push(u)}if(s.table){let l=e.createElement("table");s.table.forEach((u,c)=>{let f=l.insertRow();for(let h of u){let d=e.createElement(c?"td":"th");d.textContent=h,f.append(d)}}),n.push(l)}}let i=e.createElement("form");i.method="dialog";let o=e.createElement("button");o.textContent="Close",i.append(o),n.push(i),this.#r.replaceChildren(...n),this.#r.showModal()}#i(e,r,n,i,o){this.#e.dataset.kind=e,this.#n.setAttribute("role",r),this.#t.textContent=ap[e],this.#n.textContent=n,this.#o={title:i,items:o},this.#e.hidden=this.#n.hidden=!1}};var fl=[{title:"What a gauge shows",paragraphs:["One number on a dial, a ring or an arc, between min and max. The number is the value of the gauge node."]},{title:"Parameters",table:[["Parameter","Description"],["value","The node value: a finite number. Empty is no value, never zero."],["min, max","The range of the scale; defaults 0 and 100."],["mask","The text of the value, with {} for the number rounded to two decimals; default {}."],["thresholds","Ascending bands as value:color pairs, for example 65:#e6a23c,85:#c23531; a color is a name or a hex code."],["presentation","needle, ring or arc."],["caption","A label under the value."]]}],lp={accent:"#235db2",ink:"#202936",muted:"#526174",track:"#e9edf2"},cp={accent:"#6ea8fe",ink:"#e8edf3",muted:"#a3b0c0",track:"#3a4554"},dl=(0,G.defineComponent)({name:"gauge",tag:"gramlot-gauge",base:Be,parameters:{min:{dtype:"R",default:0,binding:"read"},max:{dtype:"R",default:100,binding:"read"},mask:{dtype:"T",default:"{}",binding:"read"},thresholds:{dtype:"T",default:"",nullable:!0,binding:"read"},presentation:{dtype:"T",default:"needle",binding:"read"},caption:{dtype:"T",default:"",nullable:!0,binding:"read"}},implementation:t=>class extends t{#e;#t;#n;#r;#o;#i;#s;#l=!1;constructor(){super();let e=this.ownerDocument;this.control.replaceChildren();let r=e.createElement("style");r.textContent=":host{height:100%;min-height:160px}.control-box{height:100%;min-height:160px;overflow:hidden}"+gi,this.shadowRoot.append(r),this.#n=new cr(e),this.#t=e.createElement("div"),this.#t.style.cssText="width:100%;height:100%;min-height:160px",this.control.append(this.#n.element,this.#t);let n=e.defaultView;this.#r=new n.ResizeObserver(()=>this.#e?.resize()),this.#o=new n.MutationObserver(()=>this.#u()),this.#i=new n.MutationObserver(()=>this.#u()),this.#s=n.matchMedia("(prefers-color-scheme: dark)")}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#l&&this.#u(),n}connectedCallback(){this.#l=!0,this.#e=hl.init(this.#t,null,{renderer:"svg"}),this.#o.observe(this,{childList:!0,subtree:!0,characterData:!0}),this.#i.observe(this.ownerDocument.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}),this.#s.addEventListener("change",this.#c),this.#r.observe(this.#t),this.#u()}#c=()=>this.#u();#a(){let r=this.#f()?cp:lp,n=this.ownerDocument.defaultView.getComputedStyle(this),i=(o,s)=>n.getPropertyValue(o).trim()||s;return{accent:i("--gramlot-brand-blue",r.accent),ink:i("--gramlot-ink",r.ink),muted:i("--gramlot-text-secondary",r.muted),track:i("--gramlot-surface-subtle",r.track)}}#f(){let e=this.ownerDocument.documentElement.getAttribute("data-theme");return e?e==="dark":this.#s.matches}#u(){if(this.#e)try{let{min:e,max:r,mask:n,thresholds:i,presentation:o,caption:s}=this.parameters,a=al(this.textContent),l=ll({value:a,min:e,max:r,mask:n,thresholds:ul(i),presentation:o,caption:s,palette:this.#a()});if(a===null){this.#t.hidden=!0,this.#n.info("No value","Gauge: no value",[{title:"Why there is no value",paragraphs:["The gauge node is empty. A missing value is shown as no value, never as zero.",'Bind the node to a number, for example gauge("^.cpu").']},...fl]);return}this.#n.hide(),this.#t.hidden=!1,this.#e.setOption(l,{replaceMerge:["series"]})}catch(e){this.#t.hidden=!0,this.#n.error(e.message,"Gauge: the value cannot be shown",[{title:"What is wrong",paragraphs:[e.message]},...fl])}}disconnectedCallback(){this.#l=!1,this.#o.disconnect(),this.#i.disconnect(),this.#r.disconnect(),this.#s.removeEventListener("change",this.#c),this.#e?.dispose(),this.#e=null}}});var yi=(0,G.defineComponent)({name:"chartView",tag:"gramlot-chart-view",base:Be,sourceContext:!0,bagStore:!0,parameters:{sampleMin:{dtype:"R",nullable:!0,binding:"read"},sampleMax:{dtype:"R",nullable:!0,binding:"read"},sampleStep:{dtype:"R",default:1,binding:"read"},sampleStart:{dtype:"R",default:0,binding:"read"},mapLabelMode:{dtype:"T",default:"value",binding:"read"},mapBarScale:{dtype:"T",default:"zero",binding:"read"},selectedTerritory:{dtype:"T",default:"",binding:"twoWay"},configpath:{dtype:"T"},timeEmpty:{dtype:"T",default:"previous",binding:"read"},timeField:{dtype:"T",default:"",binding:"read"},timeValue:{dtype:"X",nullable:!0,binding:"read"},timeStep:{dtype:"T",default:"month",binding:"read"},engine:{dtype:"T",default:"echarts",binding:"read"},mapValueField:{dtype:"T",binding:"read"},mapLabelField:{dtype:"T",binding:"read"},geoJSON:{dtype:"X",nullable:!0,binding:"read"},geometryField:{dtype:"T",binding:"read"},secondCaptionField:{dtype:"T",binding:"read"},seriesOptions:{dtype:"X",binding:"read"},storepath:{dtype:"T"},rowMode:{dtype:"T"},gridId:{dtype:"T"},chartType:{dtype:"T",binding:"read"},captionField:{dtype:"T",binding:"read"},valueFields:{dtype:"T",nullable:!0,binding:"read"}},implementation:t=>class extends t{#e;#t;#n=0;#r=!1;#o;#i;#s;#l;#c;#a;#f;#u;#p;#h;#m=Symbol("chart-options");constructor(){super(),this.control.replaceChildren();let e=this.ownerDocument.createElement("style");e.textContent=":host{height:100%;min-height:0}.control-box{height:100%;min-height:0;overflow:hidden}"+gi,this.shadowRoot.append(e),this.#o=new cr(this.ownerDocument),this.control=this.ownerDocument.createElement("div"),this.controlBox.append(this.#o.element,this.control),this.controlBox.style.backgroundColor="var(--gramlot-surface,#fff)",this.control.style.cssText="width:100%;height:100%;min-width:0;background:#fff",this.#p=new this.ownerDocument.defaultView.ResizeObserver(()=>this.#u?.resize())}setSourceContext(e){this.#i=e}setStoreBag(e){if(e!=null&&!(e instanceof Bo)&&!Array.isArray(e))throw new TypeError("Chart requires a Data Bag or sample array");this.#s=e}projectAttributes(e,r){let n=super.projectAttributes(e,r);return this.#g(),this.#r&&(this.#y(),this.#d()),n}#g(){let e=this.parameters.seriesOptions;if(!(e instanceof Bo))throw new TypeError("seriesOptions requires a Bag");e!==this.#h&&(this.#h?.unsubscribe(this.#m,{any:!0}),this.#h=e,e.subscribe(this.#m,{any:()=>this.#d()}))}connectedCallback(){this.#r=!0,this.#g();let e=this.#i.sourceNode.rootBuilder.binding;if(this.parameters.gridId){let r=e.nodeIds.get(this.parameters.gridId);if(!r||r.nodeTag!=="grid")throw new TypeError("gridId requires an existing grid nodeId");if(r.absDatapath(r.getAttr("storepath"))!==this.#i.sourceNode.absDatapath(this.parameters.storepath))throw new TypeError("Chart and grid must use the same storepath");this.#l=Fu(r),this.#c=this.#l.subscribe(()=>this.#w())}this.#y(),this.#d(),this.#p.observe(this.control)}#y(){if(this.parameters.rowMode==="samples"){if(this.parameters.gridId||this.parameters.timeField)throw new TypeError("Sample charts do not use grid filters or temporal playback");this.#e||(this.#f?.(),this.#f=null,this.#a?.dispose(),this.#a=null,this.#u?.dispose(),this.#u=null,this.#e=new ii),this.#e.bind(this.#s??[],this.parameters.sampleStep,this.parameters.sampleStart,this.parameters.captionField,this.parameters.valueFields),this.#u||(this.#t=new Ur(this.#e),this.#u=new Jr(this.control,this.#t,{renderer:"svg",domains:r=>this.#e.domains(r,this.parameters.sampleMin,this.parameters.sampleMax)}));return}this.#e&&(this.#u.dispose(),this.#u=null,this.#e=null);let e=this.#i.sourceNode.rootBuilder.binding.collectionStore(this.#s,this.parameters.rowMode);this.#a?this.#a.view.bag!==this.#s&&this.#a.bindStore(e):(this.#a=new di(e),this.#t=new Ur(this.#a.view),this.#u=new Jr(this.control,this.#t,{renderer:"svg",domains:r=>this.#t.domains(r),onTerritorySelect:r=>this.#i.writeParameter("selectedTerritory",r)}),this.#f=this.#a.view.subscribe(()=>{this.#t.invalidateDomains(),this.#d()})),this.#l&&this.#w()}#w(){let e=this.#l.view;if(!e){this.#a?.detach();return}!this.#a||e.bag!==this.#s||(this.#a.follow(e),this.#d())}async#d(){if(!this.#u)return;let{engine:e,chartType:r,captionField:n,valueFields:i,secondCaptionField:o,geometryField:s,geoJSON:a,mapValueField:l,mapLabelField:u,mapLabelMode:c,mapBarScale:f}=this.parameters,h=++this.#n;this.#u.invalidate();try{this.#t.setPeriod(this.parameters.timeField,this.parameters.timeValue,this.parameters.timeStep,this.parameters.timeEmpty);let d=this.#t.getRows(),g=this.#t.snapshotDate;if(this.parameters.configpath){let y=this.#i.sourceNode,m=`${this.parameters.configpath}.timeSnapshotLabel`,w=g&&g.getTime()!==this.parameters.timeValue.getTime()?`Showing: ${zn(g,this.parameters.timeStep)}`:"";y.getRelativeData(m)!==w&&y.setRelativeData(m,w)}if(!d.length&&!(this.parameters.timeField&&this.#a.view.getRows().some(y=>this.#a.view.value(y,this.parameters.timeField)!=null))){this.control.hidden=!0,this.#o.info("No data to display","No data to display",this.#b(r));return}if(await this.#u.prepare(e,r),h!==this.#n||!this.#u)return;this.control.hidden=!1;let p=new Bo({engine:e,chartType:r,captionField:n,valueFields:i,secondCaptionField:o,geometryField:s,mapValueField:l,mapLabelField:u,mapLabelMode:c,mapBarScale:f});if(p.setItem("geoJSON",a),await this.#u.update(p,this.#h),h!==this.#n||!this.#u)return;this.#o.hide(),this.#u.resize()}catch(d){if(h!==this.#n||!this.#u)return;this.control.hidden=!0;let g=ye.find(y=>y.id===r)??null,p=d instanceof _t?`${g.label}: the configuration does not match the chart type`:`${g?.label??"Chart"}: the chart cannot be drawn`;this.#o.error(d.message,p,cl(d,g))}}#b(e){let{storepath:r,rowMode:n,gridId:i,timeField:o}=this.parameters,s=[n==="samples"?"The chart reads its samples from the bound array, which is empty.":`The chart reads its rows from storepath ${r} (rowMode ${n}), which has no rows.`];i&&s.push(`It shows only the rows that pass the filter of grid ${i}: the filter may hide every row.`),o&&s.push(`Temporal animation is on: no row has a value in ${o}, its date field.`),s.push("Add rows to the store, or clear the filter, to draw the chart.");let a=ye.find(l=>l.id===e);return[{title:"Why the chart is empty",paragraphs:s},...a?mi(a):[]]}disconnectedCallback(){this.#r=!1,this.#n++,this.#h?.unsubscribe(this.#m,{any:!0}),this.#h=null,this.#p.disconnect(),this.#c?.(),this.#f?.(),this.#a?.dispose(),this.#u?.dispose(),this.#e=null,this.#l=this.#a=this.#u=this.#c=this.#f=null}}});function fp(t){let e=`chart${t.id[0].toUpperCase()}${t.id.slice(1)}`,r=`gramlot-chart-${t.id.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`,n=structuredClone(yi.parameters);delete n.chartType,delete n.valueFields;let i=t.syntax.filter(o=>o.parameter==="valueFields");for(let o of t.syntax){let s=o.parameter==="valueFields"?{dtype:"T",binding:"read"}:n[o.parameter];delete s.default,delete s.nullable,o.required&&(s.required=!0),n[o.parameter==="valueFields"?o.name:o.parameter]=s}return(0,G.defineComponent)({name:e,tag:r,base:yi.base,sourceContext:!0,bagStore:!0,parameters:n,doc:`${t.doc} chartView with chartType '${t.id}'.`,implementation:o=>yi.implementation(class extends o{projectAttributes(s,a){let l=super.projectAttributes(s,a),u=i.map(c=>this.parameters[c.name]).filter(Boolean);return this.parameters={...this.parameters,chartType:t.id,valueFields:u.length?u.join(","):null},l}})})}var hp=ye.map(fp),Fw=go({name:"charts",assets:{echartsGlLicense:Ce["assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt"],clayglLicense:Ce["assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt"],plotlyLicense:Ce["assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt"],vegaLicense:Ce["assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt"],uplotLicense:Ce["assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt"]},components:[Bu,yi,nl,bu,Pa,dl,...hp]});export{Fw as default};