@gramlot/gramlot 0.3.15 → 0.3.17

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 (96) hide show
  1. package/dist/components/editors/__init__.py +1 -1
  2. package/dist/components/editors/assets/collection.js +16162 -11689
  3. package/dist/components/editors/assets/index.js +1 -1
  4. package/dist/components/editors/grammar.json +3 -0
  5. package/dist/components/inputs/__init__.py +1 -1
  6. package/dist/components/inputs/assets/collection.js +134 -179
  7. package/dist/components/inputs/assets/index.js +1 -1
  8. package/dist/components/inputs/grammar.json +19 -0
  9. package/dist/components/layout/__init__.py +1 -1
  10. package/dist/components/layout/assets/collection.js +4643 -3481
  11. package/dist/components/layout/assets/index.js +1 -1
  12. package/dist/components/layout/grammar.json +509 -1
  13. package/dist/components/tree/__init__.py +1 -1
  14. package/dist/components/tree/assets/collection.js +306 -94
  15. package/dist/components/tree/assets/index.js +1 -1
  16. package/dist/components/tree/grammar.json +16 -0
  17. package/dist/components/typst/__init__.py +1 -1
  18. package/dist/components/typst/assets/collection.js +2 -2
  19. package/dist/components/typst/assets/index.js +1 -1
  20. package/dist/gramlot.js +2127 -507
  21. package/dist/gramlot.min.js +95 -40
  22. package/dist/runtime-notices.json +4 -0
  23. package/package.json +12 -8
  24. package/src/binding/device-resolver.js +27 -0
  25. package/src/binding/error-notifications.js +84 -0
  26. package/src/binding/remote-resolver.d.ts +18 -0
  27. package/src/binding/remote.js +11 -4
  28. package/src/binding/runtime.js +6 -2
  29. package/src/bootstrap.js +4 -4
  30. package/src/components/buttons.js +10 -3
  31. package/src/components/code-mirror-engine.js +14 -4
  32. package/src/components/code-mirror.js +2 -3
  33. package/src/components/container.js +1 -1
  34. package/src/components/date-calendar.js +1 -1
  35. package/src/components/formlet-labels.js +5 -4
  36. package/src/components/html-document.js +4 -2
  37. package/src/components/html-editor.js +2 -2
  38. package/src/components/jodit-engine.js +72 -11
  39. package/src/components/labelbox.js +19 -63
  40. package/src/components/layout.js +31 -19
  41. package/src/components/markdown-document.js +1 -1
  42. package/src/components/markdown-editor.js +2 -2
  43. package/src/components/menus.js +7 -6
  44. package/src/components/prose-mirror-engine.js +14 -1
  45. package/src/components/registry.js +2 -0
  46. package/src/components/selected-container.js +107 -14
  47. package/src/components/toolbar-overflow.js +9 -8
  48. package/src/components/transform-pane.js +140 -0
  49. package/src/components/tray-geometry.js +87 -0
  50. package/src/components/tray-pane.js +435 -0
  51. package/src/components/tray-settings.js +62 -0
  52. package/src/components/tree.js +115 -21
  53. package/src/components/typed-editor.js +1 -1
  54. package/src/components/typst-client.js +14 -13
  55. package/src/components/validation.js +1 -1
  56. package/src/components/window-surface.js +281 -0
  57. package/src/components/windows.js +32 -261
  58. package/src/device-frames.js +195 -0
  59. package/src/filesystem.d.ts +12 -5
  60. package/src/filesystem.js +9 -8
  61. package/src/gramlot.d.ts +3 -1
  62. package/src/gramlot.js +11 -4
  63. package/src/handlers/device-handler.d.ts +75 -0
  64. package/src/handlers/device-handler.js +1037 -0
  65. package/src/handlers/dom-handler.d.ts +2 -0
  66. package/src/handlers/dom-handler.js +9 -0
  67. package/src/handlers/rpc-handler.d.ts +2 -2
  68. package/src/http-transport.d.ts +3 -3
  69. package/src/http-transport.js +17 -11
  70. package/src/ide-documents.js +7 -5
  71. package/src/ide-runtime.d.ts +14 -3
  72. package/src/ide-runtime.js +124 -94
  73. package/src/index-page-runtime.d.ts +2 -2
  74. package/src/index-page-runtime.js +91 -43
  75. package/src/index-page-styles.js +1 -1
  76. package/src/index.d.ts +7 -2
  77. package/src/index.js +5 -1
  78. package/src/inout.d.ts +1 -1
  79. package/src/inout.js +5 -1
  80. package/src/mobile-environment.d.ts +6 -0
  81. package/src/mobile-environment.js +52 -0
  82. package/src/navigation-resolver.d.ts +14 -2
  83. package/src/renderer/attributes.js +5 -2
  84. package/src/renderer/drag-drop.js +5 -4
  85. package/src/renderer/gramlot-renderer.d.ts +13 -2
  86. package/src/renderer/gramlot-renderer.js +49 -13
  87. package/src/server/index-page.js +4 -4
  88. package/src/view/controls.js +48 -23
  89. package/src/view/html.js +85 -4
  90. package/src/view/labelbox.js +95 -0
  91. package/themes/gramlot-base/theme.css +4 -0
  92. package/themes/mela/theme.css +62 -15
  93. package/src/date-parser/civil.js +0 -61
  94. package/src/date-parser/index.d.ts +0 -18
  95. package/src/date-parser/index.js +0 -196
  96. package/src/date-parser/locales.js +0 -257
@@ -6,22 +6,79 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- var Qc=Object.create;var Fs=Object.defineProperty;var ed=Object.getOwnPropertyDescriptor;var td=Object.getOwnPropertyNames;var rd=Object.getPrototypeOf,nd=Object.prototype.hasOwnProperty;var lt=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},id=(n,e)=>{for(var t in e)Fs(n,t,{get:e[t],enumerable:!0})},sd=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of td(e))!nd.call(n,i)&&i!==t&&Fs(n,i,{get:()=>e[i],enumerable:!(r=ed(e,i))||r.enumerable});return n};var ya=(n,e,t)=>(t=n!=null?Qc(rd(n)):{},sd(e||!n||!n.__esModule?Fs(t,"default",{value:n,enumerable:!0}):t,n));var Ut=lt(ce=>{"use strict";function Cf(n,e,t){if(t===void 0&&(t=Array.prototype),n&&typeof t.find=="function")return t.find.call(n,e);for(var r=0;r<n.length;r++)if(Ft(n,r)){var i=n[r];if(e.call(void 0,i,r,n))return i}}function pr(n,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(n=e.create(null,e.getOwnPropertyDescriptors(n))),e&&typeof e.freeze=="function"?e.freeze(n):n}function Ft(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Nf(n,e){if(n===null||typeof n!="object")throw new TypeError("target is not an object");for(var t in e)Ft(e,t)&&(n[t]=e[t]);return n}var tl=pr({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 If(n){return Ft(tl,n.toLowerCase())}var rl=pr({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 Of(n){return Ft(rl,n.toLowerCase())}var on=pr({script:!1,style:!1,textarea:!0,title:!0});function Bf(n){var e=n.toLowerCase();return Ft(on,e)&&!on[e]}function Rf(n){var e=n.toLowerCase();return Ft(on,e)&&on[e]}function nl(n){return n===an.HTML}function $f(n){return nl(n)||n===an.XML_XHTML_APPLICATION}var an=pr({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),Mf=Object.keys(an).map(function(n){return an[n]});function Lf(n){return Mf.indexOf(n)>-1}var Pf=pr({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/"});ce.assign=Nf;ce.find=Cf;ce.freeze=pr;ce.HTML_BOOLEAN_ATTRIBUTES=tl;ce.HTML_RAW_TEXT_ELEMENTS=on;ce.HTML_VOID_ELEMENTS=rl;ce.hasDefaultHTMLNamespace=$f;ce.hasOwn=Ft;ce.isHTMLBooleanAttribute=If;ce.isHTMLRawTextElement=Bf;ce.isHTMLEscapableRawTextElement=Rf;ce.isHTMLMimeType=nl;ce.isHTMLVoidElement=Of;ce.isValidMimeType=Lf;ce.MIME_TYPE=an;ce.NAMESPACE=Pf});var fn=lt(dn=>{"use strict";var jf=Ut();function sl(n,e){n.prototype=Object.create(Error.prototype,{constructor:{value:n},name:{value:n.name,enumerable:!0,writable:e}})}var un=jf.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"}),ol=Object.keys(un);function al(n){return typeof n=="number"&&n>=1&&n<=25}function Ff(n){return typeof n=="string"&&n.substring(n.length-un.Error.length)===un.Error}function cn(n,e){al(n)?(this.name=ol[n],this.message=e||""):(this.message=n,this.name=Ff(e)?e:un.Error),Error.captureStackTrace&&Error.captureStackTrace(this,cn)}sl(cn,!0);Object.defineProperties(cn.prototype,{code:{enumerable:!0,get:function(){var n=ol.indexOf(this.name);return al(n)?n:0}}});var ll={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},no=Object.entries(ll);for(ln=0;ln<no.length;ln++)il=no[ln][0],cn[il]=no[ln][1];var il,ln;function io(n,e,t){this.message=n,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,io)}sl(io);dn.DOMException=cn;dn.DOMExceptionName=un;dn.ExceptionCode=ll;dn.ParseError=io});var fo=lt(B=>{"use strict";function pl(n){try{typeof n!="function"&&(n=RegExp);var e=new n("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var br=pl();function mt(n){if(n.source[0]!=="[")throw new Error(n+" can not be used with chars");return n.source.slice(1,n.source.lastIndexOf("]"))}function mr(n,e){if(n.source[0]!=="[")throw new Error("/"+n.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(n.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+n.source+"/");if(e==="-"&&n.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+n.source+"/");return new RegExp(n.source.replace(e,""),br?"u":"")}function M(n){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var r=typeof t=="string";if(r&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return r?t:t.source}).join(""),br?"u":"")}function I(n){if(arguments.length===0)throw new Error("no parameters provided");return M.apply(I,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var Uf="\uFFFD",gt=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;br&&(gt=M("[",mt(gt),"\\u{10000}-\\u{10FFFF}","]"));var qf=new RegExp("[^"+mt(gt)+"]",br?"u":""),Si=/[\x20\x09\x0D\x0A]/,Vf=mt(Si),W=M(Si,"+"),K=M(Si,"*"),hn=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;br&&(hn=M("[",mt(hn),"\\u{10000}-\\u{10FFFF}","]"));var zf=mt(hn),ao=M("[",zf,mt(/[-.0-9\xB7]/),mt(/[\u0300-\u036F\u203F-\u2040]/),"]"),De=M(hn,ao,"*"),Hf=M("^",De,"$"),ul=M(ao,"+"),Wf=M("&",De,";"),Gf=I(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),pn=I(Wf,"|",Gf),mn=M("%",De,";"),lo=I(M('"',I(/[^%&"]/,"|",mn,"|",pn),"*",'"'),"|",M("'",I(/[^%&']/,"|",mn,"|",pn),"*","'")),Xf=I('"',I(/[^<&"]/,"|",pn),"*",'"',"|","'",I(/[^<&']/,"|",pn),"*","'"),Yf=mr(hn,":"),Zf=mr(ao,":"),so=M(Yf,Zf,"*"),Jf=M("^",so,"$"),gn=M(so,I(":",so),"?"),Kf=M("^",gn,"$"),Qf=M("(",gn,")"),gr=I(/"[^"]*"|'[^']*'/),eh=M(/^<\?/,"(",De,")",I(W,"(?!",Si,")(",gt,"*?)"),"?",/\?>/),cl=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,bn=I('"',cl,'*"',"|","'",mr(cl,"'"),"*'"),ml="<!--",gl="-->",th=M(ml,I(mr(gt,"-"),"|",M("-",mr(gt,"-"))),"*",gl),dl="#PCDATA",rh=I(M(/\(/,K,dl,I(K,/\|/,K,gn),"*",K,/\)\*/),"|",M(/\(/,K,dl,K,/\)/)),nh=/[?*+]?/,ih=M(/\([^>]+\)/,nh),sh=I("EMPTY","|","ANY","|",rh,"|",ih),oh="<!ELEMENT",ah=M(oh,W,I(gn,"|",mn),W,I(sh,"|",mn),K,">"),lh=M("NOTATION",W,/\(/,K,De,I(K,/\|/,K,De),"*",K,/\)/),uh=M(/\(/,K,ul,I(K,/\|/,K,ul),"*",K,/\)/),ch=I(lh,"|",uh),dh=I(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",ch),fh=I(/#REQUIRED|#IMPLIED/,"|",I(I("#FIXED",W),"?",Xf)),hh=I(W,De,W,dh,W,fh),ph="<!ATTLIST",mh=M(ph,W,De,hh,"*",K,">"),oo="about:legacy-compat",gh=I('"'+oo+'"',"|","'"+oo+"'"),uo="SYSTEM",Ci="PUBLIC",Ni=I(I(uo,W,gr),"|",I(Ci,W,bn,W,gr)),bh=M("^",I(I(uo,W,"(?<SystemLiteralOnly>",gr,")"),"|",I(Ci,W,"(?<PubidLiteral>",bn,")",W,"(?<SystemLiteral>",gr,")"))),_h=M("^",bn,"$"),wh=M("^",gr,"$"),yh=I(W,"NDATA",W,De),vh=I(lo,"|",I(Ni,yh,"?")),bl="<!ENTITY",Eh=M(bl,W,De,W,vh,K,">"),kh=I(lo,"|",Ni),xh=M(bl,W,"%",W,De,W,kh,K,">"),Ah=I(Eh,"|",xh),Th=M(Ci,W,bn),Dh=M("<!NOTATION",W,De,W,I(Ni,"|",Th),K,">"),co=M(K,"=",K),fl=/1[.]\d+/,Sh=M(W,"version",co,I("'",fl,"'","|",'"',fl,'"')),hl=/[A-Za-z][-A-Za-z0-9._]*/,Ch=I(W,"encoding",co,I('"',hl,'"',"|","'",hl,"'")),Nh=I(W,"standalone",co,I("'",I("yes","|","no"),"'","|",'"',I("yes","|","no"),'"')),Ih=M(/^<\?xml/,Sh,Ch,"?",Nh,"?",K,/\?>/),Oh="<!DOCTYPE",Bh="<![CDATA[",Rh="]]>",$h=/<!\[CDATA\[/,Mh=/\]\]>/,Lh=M(gt,"*?",Mh),Ph=M($h,Lh);B.chars=mt;B.chars_without=mr;B.detectUnicodeSupport=pl;B.reg=M;B.regg=I;B.ABOUT_LEGACY_COMPAT=oo;B.ABOUT_LEGACY_COMPAT_SystemLiteral=gh;B.AttlistDecl=mh;B.CDATA_START=Bh;B.CDATA_END=Rh;B.CDSect=Ph;B.Char=gt;B.Comment=th;B.COMMENT_START=ml;B.COMMENT_END=gl;B.DOCTYPE_DECL_START=Oh;B.elementdecl=ah;B.EntityDecl=Ah;B.EntityValue=lo;B.ExternalID=Ni;B.ExternalID_match=bh;B.Name=De;B.Name_exact=Hf;B.NCName_exact=Jf;B.NotationDecl=Dh;B.Reference=pn;B.PEReference=mn;B.PI=eh;B.PUBLIC=Ci;B.PubidLiteral=bn;B.PubidLiteral_match=_h;B.QName=gn;B.QName_exact=Kf;B.QName_group=Qf;B.S=W;B.SChar_s=Vf;B.S_OPT=K;B.SYSTEM=uo;B.SystemLiteral=gr;B.SystemLiteral_match=wh;B.InvalidChar=qf;B.UNICODE_REPLACEMENT_CHARACTER=Uf;B.UNICODE_SUPPORT=br;B.XMLDecl=Ih});var Eo=lt(te=>{"use strict";var Be=Ut(),Ye=Be.find,jh=Be.hasDefaultHTMLNamespace,wr=Be.hasOwn,Fh=Be.isHTMLMimeType,Uh=Be.isHTMLRawTextElement,qh=Be.isHTMLVoidElement,_n=Be.MIME_TYPE,Ze=Be.NAMESPACE,_e=Symbol(),xl=fn(),x=xl.DOMException,ge=xl.DOMExceptionName,ee=fo();function ke(n){if(n!==_e)throw new TypeError("Illegal constructor")}function Vh(n){return n!==""}function zh(n){return n?n.split(/[\t\n\f\r ]+/).filter(Vh):[]}function Hh(n,e){return wr(n,e)||(n[e]=!0),n}function _l(n){if(!n)return[];var e=zh(n);return Object.keys(e.reduce(Hh,{}))}function Wh(n){return function(e){return n&&n.indexOf(e)!==-1}}function Al(n){if(!ee.QName_exact.test(n))throw new x(x.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+n+'"')}function po(n,e){Al(e),n=n||null;var t=null,r=e;if(e.indexOf(":")>=0){var i=e.split(":");t=i[0],r=i[1]}if(t!==null&&n===null)throw new x(x.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&n!==Be.NAMESPACE.XML)throw new x(x.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&n!==Be.NAMESPACE.XMLNS)throw new x(x.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(n===Be.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new x(x.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[n,t,r]}function Er(n,e){for(var t in n)wr(n,t)&&(e[t]=n[t])}function xe(n,e){var t=n.prototype;if(!(t instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,Er(t,r),n.prototype=t=r}t.constructor!=n&&(typeof n!="function"&&console.error("unknown Class:"+n),t.constructor=n)}var Ae={},Oe=Ae.ELEMENT_NODE=1,yr=Ae.ATTRIBUTE_NODE=2,wn=Ae.TEXT_NODE=3,Tl=Ae.CDATA_SECTION_NODE=4,Dl=Ae.ENTITY_REFERENCE_NODE=5,Gh=Ae.ENTITY_NODE=6,mo=Ae.PROCESSING_INSTRUCTION_NODE=7,go=Ae.COMMENT_NODE=8,_r=Ae.DOCUMENT_NODE=9,Sl=Ae.DOCUMENT_TYPE_NODE=10,bt=Ae.DOCUMENT_FRAGMENT_NODE=11,Xh=Ae.NOTATION_NODE=12,Q=Be.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 Cl(n,e){if(e.length<n.length)return Cl(e,n);var t=null;for(var r in n){if(n[r]!==e[r])return t;t=n[r]}return t}function wl(n){return n.guid||(n.guid=Math.random()),n.guid}function oe(){}oe.prototype={length:0,item:function(n){return n>=0&&n<this.length?this[n]:null},toString:function(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var t=[],r=0;r<this.length;r++)vo(this[r],t,null,e);return t.join("")},filter:function(n){return Array.prototype.filter.call(this,n)},indexOf:function(n){return Array.prototype.indexOf.call(this,n)}};oe.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Xe(n,e){this._node=n,this._refresh=e,Ri(this)}function Ri(n){var e=n._node._inc||n._node.ownerDocument._inc;if(n._inc!==e){var t=n._refresh(n._node);if(Fl(n,"length",t.length),!n.$$length||t.length<n.$$length)for(var r=t.length;r in n;r++)wr(n,r)&&delete n[r];Er(t,n),n._inc=e}}Xe.prototype.item=function(n){return Ri(this),this[n]||null};xe(Xe,oe);function vr(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function Nl(n,e){for(var t=0;t<n.length;){if(n[t]===e)return t;t++}}function bo(n,e,t){if(!e)return n._noNsIndex;var r=n._nsIndex[e];return!r&&t&&(r=n._nsIndex[e]=Object.create(null)),r}function Yh(n,e,t){var r=bo(n,e,!1),i=r&&r[t];return i||null}function Zh(n,e){bo(n,e.namespaceURI,!0)[e.localName]=e}function Jh(n,e){var t=bo(n,e.namespaceURI,!1);t&&delete t[e.localName]}function Kh(n,e,t,r){if(r?e[Nl(e,r)]=t:(e[e.length]=t,e.length++),Zh(e,t),n){t.ownerElement=n;var i=n.ownerDocument;i&&(r&&Bl(i,n,r),Qh(i,n,t))}}function yl(n,e,t){var r=Nl(e,t);if(r>=0){for(var i=e.length-1;r<=i;)e[r]=e[++r];if(e.length=i,Jh(e,t),n){var s=n.ownerDocument;s&&Bl(s,n,t),t.ownerElement=null}}}vr.prototype={length:0,item:oe.prototype.item,getNamedItem:function(n){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());for(var e=0;e<this.length;){var t=this[e];if(t.nodeName===n)return t;e++}return null},setNamedItem:function(n){var e=n.ownerElement;if(e&&e!==this._ownerElement)throw new x(x.INUSE_ATTRIBUTE_ERR);var t=Yh(this,n.namespaceURI,n.localName);return t===n?n:(Kh(this._ownerElement,this,n,t),t)},setNamedItemNS:function(n){return this.setNamedItem(n)},removeNamedItem:function(n){var e=this.getNamedItem(n);if(!e)throw new x(x.NOT_FOUND_ERR,n);return yl(this._ownerElement,this,e),e},removeNamedItemNS:function(n,e){var t=this.getNamedItemNS(n,e);if(!t)throw new x(x.NOT_FOUND_ERR,n?n+" : "+e:e);return yl(this._ownerElement,this,t),t},getNamedItemNS:function(n,e){n||(n=null);for(var t=0;t<this.length;){var r=this[t];if(r.localName===e&&r.namespaceURI===n)return r;t++}return null}};vr.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Il(){}Il.prototype={hasFeature:function(n,e){return!0},createDocument:function(n,e,t){var r=_n.XML_APPLICATION;n===Ze.HTML?r=_n.XML_XHTML_APPLICATION:n===Ze.SVG&&(r=_n.XML_SVG_IMAGE);var i=new nt(_e,{contentType:r});if(i.implementation=this,i.childNodes=new oe,i.doctype=t||null,t&&i.appendChild(t),e){var s=i.createElementNS(n,e);i.appendChild(s)}return i},createDocumentType:function(n,e,t,r){Al(n);var i=new Li(_e);return i.name=n,i.nodeName=n,i.publicId=e||"",i.systemId=t||"",i.internalSubset=r||"",i.childNodes=new oe,i},createHTMLDocument:function(n){var e=new nt(_e,{contentType:_n.HTML});if(e.implementation=this,e.childNodes=new oe,n!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var t=e.createElement("html");e.appendChild(t);var r=e.createElement("head");if(t.appendChild(r),typeof n=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(n)),r.appendChild(i)}t.appendChild(e.createElement("body"))}return e}};function j(n){ke(n)}j.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 n=this.getRootNode();return n&&n.nodeType===n.DOCUMENT_NODE},contains:function(n){if(!n)return!1;var e=n;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(n){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(n){if(!n)return!1;for(var e=[{node:this,other:n}];e.length>0;){var t=e.pop(),r=t.node,i=t.other;if(r.nodeType!==i.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==i.name||r.publicId!==i.publicId||r.systemId!==i.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==i.namespaceURI||r.prefix!==i.prefix||r.localName!==i.localName||r.attributes.length!==i.attributes.length)return!1;for(var s=0;s<r.attributes.length;s++){var o=r.attributes.item(s),a=i.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case r.ATTRIBUTE_NODE:if(r.namespaceURI!==i.namespaceURI||r.localName!==i.localName||r.value!==i.value)return!1;break;case r.PROCESSING_INSTRUCTION_NODE:if(r.target!==i.target||r.data!==i.data)return!1;break;case r.TEXT_NODE:case r.CDATA_SECTION_NODE:case r.COMMENT_NODE:if(r.data!==i.data)return!1;break}if(r.childNodes.length!==i.childNodes.length)return!1;for(var s=r.childNodes.length-1;s>=0;s--)e.push({node:r.childNodes[s],other:i.childNodes[s]})}return!0},isSameNode:function(n){return this===n},insertBefore:function(n,e){return Bi(this,n,e)},replaceChild:function(n,e){Bi(this,n,e,Ml),e&&this.removeChild(e)},removeChild:function(n){return Rl(this,n)},appendChild:function(n){return this.insertBefore(n,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(n){return jl(this.ownerDocument||this,this,n)},normalize:function(){de(this,null,{enter:function(n){for(var e=n.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===wn&&e.nodeType===wn){for(var r=[],i=t;i!==null&&i.nodeType===wn;)r.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:n.lastChild=e,e.appendData(r.join("")),_o(n.ownerDocument,n),e=i}else e=t}return!0}})},isSupported:function(n,e){return this.ownerDocument.implementation.hasFeature(n,e)},lookupPrefix:function(n){for(var e=this;e;){var t=e._nsMap;if(t){for(var r in t)if(wr(t,r)&&t[r]===n)return r}e=e.nodeType==yr?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(n){for(var e=this;e;){var t=e._nsMap;if(t&&wr(t,n))return t[n];e=e.nodeType==yr?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(n){var e=this.lookupPrefix(n);return e==null},compareDocumentPosition:function(n){if(this===n)return 0;var e=n,t=this,r=null,i=null;if(e instanceof qt&&(r=e,e=r.ownerElement),t instanceof qt&&(i=t,t=i.ownerElement,r&&e&&t===e))for(var s=0,o;o=t.attributes[s];s++){if(o===r)return Q.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Q.DOCUMENT_POSITION_PRECEDING;if(o===i)return Q.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Q.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return Q.DOCUMENT_POSITION_DISCONNECTED+Q.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(wl(t.ownerDocument)>wl(e.ownerDocument)?Q.DOCUMENT_POSITION_FOLLOWING:Q.DOCUMENT_POSITION_PRECEDING);if(i&&e===t)return Q.DOCUMENT_POSITION_CONTAINS+Q.DOCUMENT_POSITION_PRECEDING;if(r&&e===t)return Q.DOCUMENT_POSITION_CONTAINED_BY+Q.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===t)return Q.DOCUMENT_POSITION_CONTAINED_BY+Q.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=t.parentNode;c;){if(!r&&c===e)return Q.DOCUMENT_POSITION_CONTAINS+Q.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=Cl(a,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return Q.DOCUMENT_POSITION_FOLLOWING;if(h===e)return Q.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return Q.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(h)>=0)return Q.DOCUMENT_POSITION_PRECEDING}return 0}};function Ol(n){return n=="<"&&"&lt;"||n==">"&&"&gt;"||n=="&"&&"&amp;"||n=='"'&&"&quot;"||"&#"+n.charCodeAt()+";"}Er(Ae,j);Er(Ae,j.prototype);Er(Q,j);Er(Q,j.prototype);function Oi(n,e){de(n,null,{enter:function(t){return e(t)?de.STOP:!0}})}function de(n,e,t){for(var r=[{node:n,context:e,phase:de.ENTER}];r.length>0;){var i=r.pop();if(i.phase===de.ENTER){var s=t.enter(i.node,i.context);if(s===de.STOP)return de.STOP;if(r.push({node:i.node,context:s,phase:de.EXIT}),s==null)continue;for(var o=i.node.lastChild;o;)r.push({node:o,context:s,phase:de.ENTER}),o=o.previousSibling}else t.exit&&t.exit(i.node,i.context)}}de.STOP=Symbol("walkDOM.STOP");de.ENTER=0;de.EXIT=1;function nt(n,e){ke(n);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||_n.XML_APPLICATION,this.type=Fh(this.contentType)?"html":"xml"}function Qh(n,e,t){n&&n._inc++;var r=t.namespaceURI;r===Ze.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function Bl(n,e,t,r){n&&n._inc++;var i=t.namespaceURI;i===Ze.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function _o(n,e,t){if(n&&n._inc){n._inc++;var r=e.childNodes;if(t&&!t.nextSibling)r[r.length++]=t;else{for(var i=e.firstChild,s=0;i;)r[s++]=i,i=i.nextSibling;r.length=s,delete r[r.length]}}}function Rl(n,e){if(n!==e.parentNode)throw new x(x.NOT_FOUND_ERR,"child's parent is not parent");var t=e.previousSibling,r=e.nextSibling;return t?t.nextSibling=r:n.firstChild=r,r?r.previousSibling=t:n.lastChild=t,_o(n.ownerDocument,n),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function ep(n){return n&&(n.nodeType===j.DOCUMENT_NODE||n.nodeType===j.DOCUMENT_FRAGMENT_NODE||n.nodeType===j.ELEMENT_NODE)}function tp(n){return n&&(n.nodeType===j.CDATA_SECTION_NODE||n.nodeType===j.COMMENT_NODE||n.nodeType===j.DOCUMENT_FRAGMENT_NODE||n.nodeType===j.DOCUMENT_TYPE_NODE||n.nodeType===j.ELEMENT_NODE||n.nodeType===j.PROCESSING_INSTRUCTION_NODE||n.nodeType===j.TEXT_NODE)}function _t(n){return n&&n.nodeType===j.DOCUMENT_TYPE_NODE}function rt(n){return n&&n.nodeType===j.ELEMENT_NODE}function $l(n){return n&&n.nodeType===j.TEXT_NODE}function vl(n,e){var t=n.childNodes||[];if(Ye(t,rt)||_t(e))return!1;var r=Ye(t,_t);return!(e&&r&&t.indexOf(r)>t.indexOf(e))}function El(n,e){var t=n.childNodes||[];function r(s){return rt(s)&&s!==e}if(Ye(t,r))return!1;var i=Ye(t,_t);return!(e&&i&&t.indexOf(i)>t.indexOf(e))}function rp(n,e,t){if(!ep(n))throw new x(x.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+n.nodeType);if(t&&t.parentNode!==n)throw new x(x.NOT_FOUND_ERR,"child not in parent");if(!tp(e)||_t(e)&&n.nodeType!==j.DOCUMENT_NODE)throw new x(x.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+n.nodeType)}function np(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===j.DOCUMENT_FRAGMENT_NODE){var s=i.filter(rt);if(s.length>1||Ye(i,$l))throw new x(x.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!vl(n,t))throw new x(x.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(rt(e)&&!vl(n,t))throw new x(x.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(_t(e)){if(Ye(r,_t))throw new x(x.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ye(r,rt);if(t&&r.indexOf(o)<r.indexOf(t))throw new x(x.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&o)throw new x(x.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function Ml(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===j.DOCUMENT_FRAGMENT_NODE){var s=i.filter(rt);if(s.length>1||Ye(i,$l))throw new x(x.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!El(n,t))throw new x(x.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(rt(e)&&!El(n,t))throw new x(x.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(_t(e)){if(Ye(r,function(l){return _t(l)&&l!==t}))throw new x(x.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ye(r,rt);if(t&&r.indexOf(o)<r.indexOf(t))throw new x(x.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function Bi(n,e,t,r){rp(n,e,t),n.nodeType===j.DOCUMENT_NODE&&(r||np)(n,e,t);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===bt){var s=e.firstChild;if(s==null)return e;var o=e.lastChild}else s=o=e;var a=t?t.previousSibling:n.lastChild;s.previousSibling=a,o.nextSibling=t,a?a.nextSibling=s:n.firstChild=s,t==null?n.lastChild=o:t.previousSibling=o;do s.parentNode=n;while(s!==o&&(s=s.nextSibling));return _o(n.ownerDocument||n,n,e),e.nodeType==bt&&(e.firstChild=e.lastChild=null),e}nt.prototype={implementation:null,nodeName:"#document",nodeType:_r,doctype:null,documentElement:null,_inc:1,insertBefore:function(n,e){if(n.nodeType===bt){for(var t=n.firstChild;t;){var r=t.nextSibling;this.insertBefore(t,e),t=r}return n}return Bi(this,n,e),n.ownerDocument=this,this.documentElement===null&&n.nodeType===Oe&&(this.documentElement=n),n},removeChild:function(n){var e=Rl(this,n);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(n,e){Bi(this,n,e,Ml),n.ownerDocument=this,e&&this.removeChild(e),rt(n)&&(this.documentElement=n)},importNode:function(n,e){return ip(this,n,e)},getElementById:function(n){var e=null;return Oi(this.documentElement,function(t){if(t.nodeType==Oe&&t.getAttribute("id")==n)return e=t,!0}),e},createElement:function(n){var e=new it(_e);e.ownerDocument=this,this.type==="html"&&(n=n.toLowerCase()),jh(this.contentType)&&(e.namespaceURI=Ze.HTML),e.nodeName=n,e.tagName=n,e.localName=n,e.childNodes=new oe;var t=e.attributes=new vr;return t._ownerElement=e,e},createDocumentFragment:function(){var n=new kr(_e);return n.ownerDocument=this,n.childNodes=new oe,n},createTextNode:function(n){var e=new yn(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(n),e},createComment:function(n){var e=new $i(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(n),e},createCDATASection:function(n){if(n.indexOf("]]>")!==-1)throw new x(x.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new Mi(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(n),e},createProcessingInstruction:function(n,e){var t=new ji(_e);return t.ownerDocument=this,t.childNodes=new oe,t.nodeName=t.target=n,t.nodeValue=t.data=e,t},createAttribute:function(n){if(!ee.QName_exact.test(n))throw new x(x.INVALID_CHARACTER_ERR,'invalid character in name "'+n+'"');return this.type==="html"&&(n=n.toLowerCase()),this._createAttribute(n)},_createAttribute:function(n){var e=new qt(_e);return e.ownerDocument=this,e.childNodes=new oe,e.name=n,e.nodeName=n,e.localName=n,e.specified=!0,e},createEntityReference:function(n){if(!ee.Name_exact.test(n))throw new x(x.INVALID_CHARACTER_ERR,'not a valid xml name "'+n+'"');if(this.type==="html")throw new x("document is an html document",ge.NotSupportedError);var e=new Pi(_e);return e.ownerDocument=this,e.childNodes=new oe,e.nodeName=n,e},createElementNS:function(n,e){var t=po(n,e),r=new it(_e),i=r.attributes=new vr;return r.childNodes=new oe,r.ownerDocument=this,r.nodeName=e,r.tagName=e,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],i._ownerElement=r,r},createAttributeNS:function(n,e){var t=po(n,e),r=new qt(_e);return r.ownerDocument=this,r.childNodes=new oe,r.nodeName=e,r.name=e,r.specified=!0,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],r}};xe(nt,j);function it(n){ke(n),this._nsMap=Object.create(null)}it.prototype={nodeType:Oe,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Ze.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(n){return!!this.getAttributeNode(n)},getAttribute:function(n){var e=this.getAttributeNode(n);return e?e.value:null},getAttributeNode:function(n){return this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase()),this.attributes.getNamedItem(n)},setAttribute:function(n,e){this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());var t=this.getAttributeNode(n);t?t.value=t.nodeValue=""+e:(t=this.ownerDocument._createAttribute(n),t.value=t.nodeValue=""+e,this.setAttributeNode(t))},removeAttribute:function(n){var e=this.getAttributeNode(n);e&&this.removeAttributeNode(e)},setAttributeNode:function(n){return this.attributes.setNamedItem(n)},setAttributeNodeNS:function(n){return this.attributes.setNamedItemNS(n)},removeAttributeNode:function(n){return this.attributes.removeNamedItem(n.nodeName)},removeAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);t&&this.removeAttributeNode(t)},hasAttributeNS:function(n,e){return this.getAttributeNodeNS(n,e)!=null},getAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);return t?t.value:null},setAttributeNS:function(n,e,t){var r=po(n,e),i=r[2],s=this.getAttributeNodeNS(n,i);s?s.value=s.nodeValue=""+t:(s=this.ownerDocument.createAttributeNS(n,e),s.value=s.nodeValue=""+t,this.setAttributeNode(s))},getAttributeNodeNS:function(n,e){return this.attributes.getNamedItemNS(n,e)},getElementsByClassName:function(n){var e=_l(n);return new Xe(this,function(t){var r=[];return e.length>0&&Oi(t,function(i){if(i!==t&&i.nodeType===Oe){var s=i.getAttribute("class");if(s){var o=n===s;if(!o){var a=_l(s);o=e.every(Wh(a))}o&&r.push(i)}}}),r})},getElementsByTagName:function(n){var e=(this.nodeType===_r?this:this.ownerDocument).type==="html",t=n.toLowerCase();return new Xe(this,function(r){var i=[];return Oi(r,function(s){if(!(s===r||s.nodeType!==Oe))if(n==="*")i.push(s);else{var o=s.getQualifiedName(),a=e&&s.namespaceURI===Ze.HTML?t:n;o===a&&i.push(s)}}),i})},getElementsByTagNameNS:function(n,e){return new Xe(this,function(t){var r=[];return Oi(t,function(i){i!==t&&i.nodeType===Oe&&(n==="*"||i.namespaceURI===n)&&(e==="*"||i.localName==e)&&r.push(i)}),r})}};nt.prototype.getElementsByClassName=it.prototype.getElementsByClassName;nt.prototype.getElementsByTagName=it.prototype.getElementsByTagName;nt.prototype.getElementsByTagNameNS=it.prototype.getElementsByTagNameNS;xe(it,j);function qt(n){ke(n),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}qt.prototype.nodeType=yr;xe(qt,j);function wt(n){ke(n)}wt.prototype={data:"",substringData:function(n,e){return this.data.substring(n,n+e)},appendData:function(n){n=this.data+n,this.nodeValue=this.data=n,this.length=n.length},insertData:function(n,e){this.replaceData(n,0,e)},deleteData:function(n,e){this.replaceData(n,e,"")},replaceData:function(n,e,t){var r=this.data.substring(0,n),i=this.data.substring(n+e);t=r+t+i,this.nodeValue=this.data=t,this.length=t.length}};xe(wt,j);function yn(n){ke(n)}yn.prototype={nodeName:"#text",nodeType:wn,splitText:function(n){var e=this.data,t=e.substring(n);e=e.substring(0,n),this.data=this.nodeValue=e,this.length=e.length;var r=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};xe(yn,wt);function $i(n){ke(n)}$i.prototype={nodeName:"#comment",nodeType:go};xe($i,wt);function Mi(n){ke(n)}Mi.prototype={nodeName:"#cdata-section",nodeType:Tl};xe(Mi,yn);function Li(n){ke(n)}Li.prototype.nodeType=Sl;xe(Li,j);function wo(n){ke(n)}wo.prototype.nodeType=Xh;xe(wo,j);function yo(n){ke(n)}yo.prototype.nodeType=Gh;xe(yo,j);function Pi(n){ke(n)}Pi.prototype.nodeType=Dl;xe(Pi,j);function kr(n){ke(n)}kr.prototype.nodeName="#document-fragment";kr.prototype.nodeType=bt;xe(kr,j);function ji(n){ke(n)}ji.prototype.nodeType=mo;xe(ji,wt);function Ll(){}Ll.prototype.serializeToString=function(n,e){return Pl.call(n,e)};j.prototype.toString=Pl;function Pl(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n!=null?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var t=[],r=this.nodeType===_r&&this.documentElement||this,i=r.prefix,s=r.namespaceURI;if(s&&i==null){var i=r.lookupPrefix(s);if(i==null)var o=[{namespace:s,prefix:null}]}return vo(this,t,o,e),t.join("")}function kl(n,e,t){var r=n.prefix||"",i=n.namespaceURI;if(!i||r==="xml"&&i===Ze.XML||i===Ze.XMLNS)return!1;for(var s=t.length;s--;){var o=t[s];if(o.prefix===r)return o.namespace!==i}return!0}function Ii(n,e,t,r){if(r&&!ee.QName_exact.test(e))throw new x('The attribute name "'+e+'" is not a valid XML QName',ge.InvalidStateError);n.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,Ol),'"')}function vo(n,e,t,r){t||(t=[]);var i=r.nodeFilter,s=r.requireWellFormed,o=r.splitCDATASections,a=n.nodeType===_r?n:n.ownerDocument,l=a.type==="html";de(n,{ns:t},{enter:function(u,c){var d=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 Oe:var f=u.attributes,h=f.length,p=u.tagName,m=p;if(!l&&!u.prefix&&u.namespaceURI){for(var b,g=0;g<f.length;g++)if(f.item(g).name==="xmlns"){b=f.item(g).value;break}if(!b)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.prefix===""&&w.namespace===u.namespaceURI){b=w.namespace;break}}if(b!==u.namespaceURI)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.namespace===u.namespaceURI){w.prefix&&(m=w.prefix+":"+p);break}}}if(s&&!ee.QName_exact.test(m))throw new x('The element name "'+m+'" is not a valid XML QName',ge.InvalidStateError);e.push("<",m);for(var v=d.slice(),k=0;k<h;k++){var E=f.item(k);E.prefix=="xmlns"?v.push({prefix:E.localName,namespace:E.value}):E.nodeName=="xmlns"&&v.push({prefix:"",namespace:E.value})}for(var k=0;k<h;k++){var E=f.item(k);if(kl(E,l,v)){var C=E.prefix||"",L=E.namespaceURI;Ii(e,C?"xmlns:"+C:"xmlns",L,s),v.push({prefix:C,namespace:L})}var q=i?i(E):E;q&&(typeof q=="string"?e.push(q):Ii(e,q.name,q.value,s))}if(p===m&&kl(u,l,v)){var ve=u.prefix||"",L=u.namespaceURI;Ii(e,ve?"xmlns:"+ve:"xmlns",L,s),v.push({prefix:ve,namespace:L})}var Z=!u.firstChild;if(Z&&(l||u.namespaceURI===Ze.HTML)&&(Z=qh(p)),Z)return e.push("/>"),null;if(e.push(">"),l&&Uh(p)){for(var ne=u.firstChild;ne;)ne.data?e.push(ne.data):vo(ne,e,v.slice(),r),ne=ne.nextSibling;return e.push("</",m,">"),null}return{ns:v,tag:m};case _r:case bt:if(s&&u.nodeType===_r&&u.documentElement==null)throw new x("The Document has no documentElement",ge.InvalidStateError);return{ns:d};case yr:return Ii(e,u.name,u.value,s),null;case wn:if(s&&ee.InvalidChar.test(u.data))throw new x("The Text node data contains characters outside the XML Char production",ge.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Ol)),null;case Tl:if(s&&u.data.indexOf("]]>")!==-1)throw new x('The CDATASection data contains "]]>"',ge.InvalidStateError);return o?e.push(ee.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),ee.CDATA_END):e.push(ee.CDATA_START,u.data,ee.CDATA_END),null;case go:if(s){if(ee.InvalidChar.test(u.data))throw new x("The comment node data contains characters outside the XML Char production",ge.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new x('The comment node data contains "--" or ends with "-"',ge.InvalidStateError)}return e.push(ee.COMMENT_START,u.data,ee.COMMENT_END),null;case Sl:var Ne=u.publicId,G=u.systemId;if(s){if(!ee.Name_exact.test(u.name))throw new x('The doctype name "'+u.name+'" is not a valid XML Name',ge.InvalidStateError);if(Ne&&!ee.PubidLiteral_match.test(Ne))throw new x("DocumentType publicId is not a valid PubidLiteral",ge.InvalidStateError);if(G&&G!=="."&&!ee.SystemLiteral_match.test(G))throw new x("DocumentType systemId is not a valid SystemLiteral",ge.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new x('DocumentType internalSubset contains "]>"',ge.InvalidStateError)}return e.push(ee.DOCTYPE_DECL_START," ",u.name),Ne?(e.push(" ",ee.PUBLIC," ",Ne),G&&G!=="."&&e.push(" ",G)):G&&G!=="."&&e.push(" ",ee.SYSTEM," ",G),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case mo:if(s){if(!ee.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new x('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',ge.InvalidStateError);if(ee.InvalidChar.test(u.data))throw new x("The ProcessingInstruction data contains characters outside the XML Char production",ge.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new x('The ProcessingInstruction data contains "?>"',ge.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Dl:if(s&&!ee.Name_exact.test(u.nodeName))throw new x('The entity reference name "'+u.nodeName+'" is not a valid XML Name',ge.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 ip(n,e,t){var r;return de(e,null,{enter:function(i,s){var o=i.cloneNode(!1);o.ownerDocument=n,o.parentNode=null,s===null?r=o:s.appendChild(o);var a=i.nodeType===yr||t;return a?o:null}}),r}function jl(n,e,t){var r;return de(e,null,{enter:function(i,s){var o=new i.constructor(_e);for(var a in i)if(wr(i,a)){var l=i[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}i.childNodes&&(o.childNodes=new oe),o.ownerDocument=n;var u=t;switch(o.nodeType){case Oe:var c=i.attributes,d=o.attributes=new vr,f=c.length;d._ownerElement=o;for(var h=0;h<f;h++)o.setAttributeNode(jl(n,c.item(h),!0));break;case yr:u=!0}return s!==null?s.appendChild(o):r=o,u?o:null}}),r}function Fl(n,e,t){n[e]=t}function ho(n){for(var e=[],t=n.firstChild;t;)t.nodeType===Oe&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Xe.prototype,"length",{get:function(){return Ri(this),this.$$length}}),Object.defineProperty(j.prototype,"textContent",{get:function(){if(this.nodeType===Oe||this.nodeType===bt){var n=[];return de(this,null,{enter:function(e){if(e.nodeType===Oe||e.nodeType===bt)return!0;if(e.nodeType===mo||e.nodeType===go)return null;n.push(e.nodeValue)}}),n.join("")}return this.nodeValue},set:function(n){switch(this.nodeType){case Oe:case bt:for(;this.firstChild;)this.removeChild(this.firstChild);(n||String(n))&&this.appendChild(this.ownerDocument.createTextNode(n));break;default:this.data=n,this.value=n,this.nodeValue=n}}}),Object.defineProperty(wt.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(n){this._data=n,this.length=typeof n=="string"?n.length:0}}),Object.defineProperty(wt.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!0,configurable:!0}),Object.defineProperty(it.prototype,"children",{get:function(){return new Xe(this,ho)}}),Object.defineProperty(nt.prototype,"children",{get:function(){return new Xe(this,ho)}}),Object.defineProperty(kr.prototype,"children",{get:function(){return new Xe(this,ho)}}),Fl=function(n,e,t){n["$$"+e]=t})}catch{}te._updateLiveList=Ri;te.Attr=qt;te.CDATASection=Mi;te.CharacterData=wt;te.Comment=$i;te.Document=nt;te.DocumentFragment=kr;te.DocumentType=Li;te.DOMImplementation=Il;te.Element=it;te.Entity=yo;te.EntityReference=Pi;te.LiveNodeList=Xe;te.NamedNodeMap=vr;te.Node=j;te.NodeList=oe;te.Notation=wo;te.Text=yn;te.ProcessingInstruction=ji;te.walkDOM=de;te.XMLSerializer=Ll});var ql=lt(vn=>{"use strict";var Ul=Ut().freeze;vn.XML_ENTITIES=Ul({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});vn.HTML_ENTITIES=Ul({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:`
10
- `,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"});vn.entityMap=vn.HTML_ENTITIES});var Jl=lt(Ui=>{"use strict";var Sr=Ut(),R=fo(),Wl=fn(),sp=Sr.isHTMLEscapableRawTextElement,op=Sr.isHTMLMimeType,ap=Sr.isHTMLRawTextElement,xn=Sr.hasOwn,Vl=Sr.NAMESPACE,lp=Wl.ParseError,up=Wl.DOMException,xr=0,yt=1,Ar=2,En=3,Tr=4,Dr=5,kn=6,Fi=7;function Gl(){}Gl.prototype={parse:function(n,e,t){var r=this.domBuilder;r.startDocument(),hp(e,e=Object.create(null)),cp(n,e,t,r,this.errorHandler),r.endDocument()}};var ko=/&#?\w+;?/g;function cp(n,e,t,r,i){var s=op(r.mimeType);n.indexOf(R.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function o(V){if(V>65535){V-=65536;var Ie=55296+(V>>10),di=56320+(V&1023);return String.fromCharCode(Ie,di)}else return String.fromCharCode(V)}function a(V){var Ie=V[V.length-1]===";"?V:V+";";if(!s&&Ie!==V)return i.error("EntityRef: expecting ;"),V;var di=R.Reference.exec(Ie);if(!di||di[0].length!==Ie.length)return i.error("entity not matching Reference production: "+V),V;var fi=Ie.slice(1,-1);return xn(t,fi)?t[fi]:fi.charAt(0)==="#"?o(parseInt(fi.substring(1).replace("x","0x"))):(i.error("entity not found:"+V),V)}function l(V){if(V>b){var Ie=n.substring(b,V).replace(ko,a);f&&h(b),r.characters(Ie,0,V-b),b=V}}var u=0,c=0,d=/\r\n?|\n|$/g,f=r.locator;function h(V,Ie){for(;V>=c&&(Ie=d.exec(n));)u=c,c=Ie.index+Ie[0].length,f.lineNumber++;f.columnNumber=V-u+1}for(var p=[{currentNSMap:e}],m=[],b=0;;){try{var g=n.indexOf("<",b);if(g<0){if(!s&&m.length>0)return i.fatalError("unclosed xml tag(s): "+m.join(", "));if(!n.substring(b).match(/^\s*$/)){var _=r.doc,w=_.createTextNode(n.substring(b));if(_.documentElement)return i.error("Extra content at the end of the document");_.appendChild(w),r.currentElement=w}return}if(g>b){var v=n.substring(b,g);!s&&m.length===0&&(v=v.replace(new RegExp(R.S_OPT.source,"g"),""),v&&i.error("Unexpected content outside root element: '"+v+"'")),l(g)}switch(n.charAt(g+1)){case"/":var $=n.indexOf(">",g+2),k=n.substring(g+2,$>0?$:void 0);if(!k)return i.fatalError("end tag name missing");var E=R.reg("^",R.QName_group,R.S_OPT,"$"),C=$>0&&E.exec(k);if(!C){var L=$>0&&R.reg("^",R.QName_group).exec(k);if(s&&L)i.warning('end tag name contains invalid trailing characters: "'+k+'"'),C=L;else if(L&&new RegExp(E.source,E.flags+"m").test(k))i.error('end tag name is followed by a line break and trailing content: "'+k+'"'),C=L;else return i.fatalError('end tag name contains invalid characters: "'+k+'"')}if(!r.currentElement&&!r.doc.documentElement)return;var q=m[m.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if(q!==C[1]){var ve=C[1].toLowerCase();if(!s||q.toLowerCase()!==ve)return i.fatalError('Opening and ending tag mismatch: "'+q+'" != "'+k+'"')}var Z=p.pop();m.pop();var ne=Z.localNSMap;if(r.endElement(Z.uri,Z.localName,q),ne)for(var Ne in ne)xn(ne,Ne)&&r.endPrefixMapping(Ne);$++;break;case"?":f&&h(g),$=mp(n,g,r,i);break;case"!":f&&h(g),$=Yl(n,g,r,i,s);break;default:f&&h(g);var G=new Zl,ie=p[p.length-1].currentNSMap,$=dp(n,g,G,ie,a,i,s),_a=G.length;if(G.closed||(s&&Sr.isHTMLVoidElement(G.tagName)?G.closed=!0:m.push(G.tagName)),f&&_a){for(var Kc=zl(f,{}),js=0;js<_a;js++){var wa=G[js];h(wa.offset),wa.locator=zl(f,{})}r.locator=Kc,Hl(G,r,ie)&&p.push(G),r.locator=f}else Hl(G,r,ie)&&p.push(G);s&&!G.closed?$=fp(n,$,G.tagName,a,r):$++}}catch(V){if(V instanceof lp)throw V;if(V instanceof up)return i.fatalError("Error constructing the DOM: "+V.name+": "+V.message,V);i.error("element parse error: "+V),$=-1}$>b?b=$:l(Math.max(g,b)+1)}}function zl(n,e){return e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber,e}function dp(n,e,t,r,i,s,o){function a(h,p,m){if(xn(t.attributeNames,h))return s.fatalError("Attribute "+h+" redefined");if(!o&&p.indexOf("<")>=0)return s.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,p.replace(/[\t\n\r]/g," ").replace(ko,i),m)}for(var l,u,c=++e,d=xr;;){var f=n.charAt(c);if(d===xr&&f==="<")throw new Error("unexpected < in tag name: "+n.slice(e,c));switch(f){case"=":if(d===yt)l=n.slice(e,c),d=En;else if(d===Ar)d=En;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===En||d===yt)if(d===yt&&(s.warning('attribute value must after "="'),l=n.slice(e,c)),e=c+1,c=n.indexOf(f,e),c>0)u=n.slice(e,c),a(l,u,e-1),d=Dr;else throw new Error("attribute value no end '"+f+"' match");else if(d==Tr)u=n.slice(e,c),a(l,u,e),s.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Dr;else throw new Error('attribute value must after "="');break;case"/":switch(d){case xr:t.setTagName(n.slice(e,c));case Dr:case kn:case Fi:d=Fi,t.closed=!0;case Tr:case yt:break;case Ar:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),d==xr&&t.setTagName(n.slice(e,c)),c;case">":switch(d){case xr:t.setTagName(n.slice(e,c));case Dr:case kn:case Fi:break;case Tr:case yt:u=n.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Ar:d===Ar&&(u=l),d==Tr?(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 En:if(!o)return s.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case xr:t.setTagName(n.slice(e,c)),d=kn;break;case yt:l=n.slice(e,c),d=Ar;break;case Tr:var u=n.slice(e,c);s.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Dr:d=kn;break}else switch(d){case Ar:o||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,d=yt;break;case Dr:s.warning('attribute space is required"'+l+'"!!');case kn:d=yt,e=c;break;case En:d=Tr,e=c;break;case Fi:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function Hl(n,e,t){for(var r=n.tagName,i=null,d=n.length;d--;){var s=n[d],o=s.qName,a=s.value,f=o.indexOf(":");if(f>0)var l=s.prefix=o.slice(0,f),u=o.slice(f+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";s.localName=u,c!==!1&&(i==null&&(i=Object.create(null),t=Object.create(t)),t[c]=i[c]=a,s.uri=Vl.XMLNS,e.startPrefixMapping(c,a))}for(var d=n.length;d--;)s=n[d],s.prefix&&(s.prefix==="xml"&&(s.uri=Vl.XML),s.prefix!=="xmlns"&&(s.uri=t[s.prefix]));var f=r.indexOf(":");f>0?(l=n.prefix=r.slice(0,f),u=n.localName=r.slice(f+1)):(l=null,u=n.localName=r);var h=n.uri=t[l||""];if(e.startElement(h,u,r,n),n.closed){if(e.endElement(h,u,r),i)for(l in i)xn(i,l)&&e.endPrefixMapping(l)}else return n.currentNSMap=t,n.localNSMap=i,!0}function fp(n,e,t,r,i){var s=sp(t);if(s||ap(t)){var o=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(n),l=a?a.index:-1;if(l<0)return e+1;var u=n.substring(e+1,l);return s&&(u=u.replace(ko,r)),i.characters(u,0,u.length),l}return e+1}function hp(n,e){for(var t in n)xn(n,t)&&(e[t]=n[t])}function Xl(n,e){var t=e;function r(c){return c=c||0,n.charAt(t+c)}function i(c){c=c||1,t+=c}function s(){for(var c=0;t<n.length;){var d=r();if(d!==" "&&d!==`
11
- `&&d!==" "&&d!=="\r")return c;c++,i()}return-1}function o(){return n.substring(t)}function a(c){return n.substring(t,t+c.length)===c}function l(c){return n.substring(t,t+c.length).toUpperCase()===c.toUpperCase()}function u(c){var d=R.reg("^",c),f=d.exec(o());return f?(i(f[0].length),f[0]):null}return{char:r,getIndex:function(){return t},getMatch:u,getSource:function(){return n},skip:i,skipBlanks:s,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function pp(n,e){function t(a,l){var u=R.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 r=n.getSource();if(n.char()==="["){n.skip(1);for(var i=n.getIndex();n.getIndex()<r.length;){if(n.skipBlanks(),n.char()==="]"){var s=r.substring(i,n.getIndex());return n.skip(1),s}var o=null;if(n.char()==="<"&&n.char(1)==="!")switch(n.char(2)){case"E":n.char(3)==="L"?o=n.getMatch(R.elementdecl):n.char(3)==="N"&&(o=n.getMatch(R.EntityDecl));break;case"A":o=n.getMatch(R.AttlistDecl);break;case"N":o=n.getMatch(R.NotationDecl);break;case"-":o=n.getMatch(R.Comment);break}else if(n.char()==="<"&&n.char(1)==="?")o=t(n,e);else if(n.char()==="%")o=n.getMatch(R.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!o)return e.fatalError("Error in internal subset at position "+n.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function Yl(n,e,t,r,i){var s=Xl(n,e);switch(i?s.char(2).toUpperCase():s.char(2)){case"-":var o=s.getMatch(R.Comment);return o?(t.comment(o,R.COMMENT_START.length,o.length-R.COMMENT_START.length-R.COMMENT_END.length),s.getIndex()):r.fatalError("comment is not well-formed at position "+s.getIndex());case"[":var a=s.getMatch(R.CDSect);return a?!i&&!t.currentElement?r.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(a,R.CDATA_START.length,a.length-R.CDATA_START.length-R.CDATA_END.length),t.endCDATA(),s.getIndex()):r.fatalError("Invalid CDATA starting at position "+e);case"D":{if(t.doc&&t.doc.documentElement)return r.fatalError("Doctype not allowed inside or after documentElement at position "+s.getIndex());if(i?!s.substringStartsWithCaseInsensitive(R.DOCTYPE_DECL_START):!s.substringStartsWith(R.DOCTYPE_DECL_START))return r.fatalError("Expected "+R.DOCTYPE_DECL_START+" at position "+s.getIndex());if(s.skip(R.DOCTYPE_DECL_START.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+R.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(R.Name),!l.name)return r.fatalError("doctype name missing or contains unexpected characters at position "+s.getIndex());if(i&&l.name.toLowerCase()!=="html"&&r.warning("Unexpected DOCTYPE in HTML document at position "+s.getIndex()),s.skipBlanks(),s.substringStartsWith(R.PUBLIC)||s.substringStartsWith(R.SYSTEM)){var u=R.ExternalID_match.exec(s.substringFromIndex());if(!u)return r.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(R.SYSTEM)){if(s.skip(R.SYSTEM.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+R.SYSTEM+" at position "+s.getIndex());if(l.systemId=s.getMatch(R.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return r.fatalError("Expected "+R.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+R.SYSTEM+" at position "+s.getIndex())}return i&&l.systemId&&!R.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&r.warning("Unexpected doctype.systemId in HTML document at position "+s.getIndex()),i||(s.skipBlanks(),l.internalSubset=pp(s,r)),s.skipBlanks(),s.char()!==">"?r.fatalError("doctype not terminated with > at position "+s.getIndex()):(s.skip(1),t.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),t.endDTD(),s.getIndex())}default:return r.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function mp(n,e,t,r){var i=n.substring(e).match(R.PI);if(!i)return r.fatalError("Invalid processing instruction starting at position "+e);if(i[1].toLowerCase()==="xml"){if(e>0)return r.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!R.XMLDecl.test(n.substring(e)))return r.fatalError("xml declaration is not well-formed")}return t.processingInstruction(i[1],i[2]),e+i[0].length}function Zl(){this.attributeNames=Object.create(null)}Zl.prototype={setTagName:function(n){if(!R.QName_exact.test(n))throw new Error("invalid tagName:"+n);this.tagName=n},addValue:function(n,e,t){if(!R.QName_exact.test(n))throw new Error("invalid attribute:"+n);this.attributeNames[n]=this.length,this[this.length++]={qName:n,value:e,offset:t}},length:0,getLocalName:function(n){return this[n].localName},getLocator:function(n){return this[n].locator},getQName:function(n){return this[n].qName},getURI:function(n){return this[n].uri},getValue:function(n){return this[n].value}};Ui.XMLReader=Gl;Ui.parseUtils=Xl;Ui.parseDoctypeCommentOrCData=Yl});var iu=lt(Nr=>{"use strict";var Vt=Ut(),gp=Eo(),bp=fn(),Kl=ql(),_p=Jl(),wp=gp.DOMImplementation,yp=Vt.hasDefaultHTMLNamespace,vp=Vt.isHTMLMimeType,Ep=Vt.isValidMimeType,tu=Vt.MIME_TYPE,xo=Vt.NAMESPACE,Ql=bp.ParseError,kp=_p.XMLReader;function ru(n){return n.replace(/\r[\n\u0085]/g,`
9
+ var gd=Object.create;var Zs=Object.defineProperty;var bd=Object.getOwnPropertyDescriptor;var _d=Object.getOwnPropertyNames;var wd=Object.getPrototypeOf,yd=Object.prototype.hasOwnProperty;var dt=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},vd=(n,e)=>{for(var t in e)Zs(n,t,{get:e[t],enumerable:!0})},Ed=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _d(e))!yd.call(n,i)&&i!==t&&Zs(n,i,{get:()=>e[i],enumerable:!(r=bd(e,i))||r.enumerable});return n};var Ia=(n,e,t)=>(t=n!=null?gd(wd(n)):{},Ed(e||!n||!n.__esModule?Zs(t,"default",{value:n,enumerable:!0}):t,n));var zt=dt(me=>{"use strict";function Gf(n,e,t){if(t===void 0&&(t=Array.prototype),n&&typeof t.find=="function")return t.find.call(n,e);for(var r=0;r<n.length;r++)if(Vt(n,r)){var i=n[r];if(e.call(void 0,i,r,n))return i}}function br(n,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(n=e.create(null,e.getOwnPropertyDescriptors(n))),e&&typeof e.freeze=="function"?e.freeze(n):n}function Vt(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Xf(n,e){if(n===null||typeof n!="object")throw new TypeError("target is not an object");for(var t in e)Vt(e,t)&&(n[t]=e[t]);return n}var pl=br({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 Yf(n){return Vt(pl,n.toLowerCase())}var ml=br({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 Zf(n){return Vt(ml,n.toLowerCase())}var fn=br({script:!1,style:!1,textarea:!0,title:!0});function Jf(n){var e=n.toLowerCase();return Vt(fn,e)&&!fn[e]}function Kf(n){var e=n.toLowerCase();return Vt(fn,e)&&fn[e]}function gl(n){return n===hn.HTML}function Qf(n){return gl(n)||n===hn.XML_XHTML_APPLICATION}var hn=br({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),eh=Object.keys(hn).map(function(n){return hn[n]});function th(n){return eh.indexOf(n)>-1}var rh=br({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/"});me.assign=Xf;me.find=Gf;me.freeze=br;me.HTML_BOOLEAN_ATTRIBUTES=pl;me.HTML_RAW_TEXT_ELEMENTS=fn;me.HTML_VOID_ELEMENTS=ml;me.hasDefaultHTMLNamespace=Qf;me.hasOwn=Vt;me.isHTMLBooleanAttribute=Yf;me.isHTMLRawTextElement=Jf;me.isHTMLEscapableRawTextElement=Kf;me.isHTMLMimeType=gl;me.isHTMLVoidElement=Zf;me.isValidMimeType=th;me.MIME_TYPE=hn;me.NAMESPACE=rh});var _n=dt(bn=>{"use strict";var nh=zt();function _l(n,e){n.prototype=Object.create(Error.prototype,{constructor:{value:n},name:{value:n.name,enumerable:!0,writable:e}})}var mn=nh.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"}),wl=Object.keys(mn);function yl(n){return typeof n=="number"&&n>=1&&n<=25}function ih(n){return typeof n=="string"&&n.substring(n.length-mn.Error.length)===mn.Error}function gn(n,e){yl(n)?(this.name=wl[n],this.message=e||""):(this.message=n,this.name=ih(e)?e:mn.Error),Error.captureStackTrace&&Error.captureStackTrace(this,gn)}_l(gn,!0);Object.defineProperties(gn.prototype,{code:{enumerable:!0,get:function(){var n=wl.indexOf(this.name);return yl(n)?n:0}}});var vl={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},po=Object.entries(vl);for(pn=0;pn<po.length;pn++)bl=po[pn][0],gn[bl]=po[pn][1];var bl,pn;function mo(n,e,t){this.message=n,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,mo)}_l(mo);bn.DOMException=gn;bn.DOMExceptionName=mn;bn.ExceptionCode=vl;bn.ParseError=mo});var Eo=dt($=>{"use strict";function Dl(n){try{typeof n!="function"&&(n=RegExp);var e=new n("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var yr=Dl();function _t(n){if(n.source[0]!=="[")throw new Error(n+" can not be used with chars");return n.source.slice(1,n.source.lastIndexOf("]"))}function _r(n,e){if(n.source[0]!=="[")throw new Error("/"+n.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(n.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+n.source+"/");if(e==="-"&&n.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+n.source+"/");return new RegExp(n.source.replace(e,""),yr?"u":"")}function P(n){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var r=typeof t=="string";if(r&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return r?t:t.source}).join(""),yr?"u":"")}function B(n){if(arguments.length===0)throw new Error("no parameters provided");return P.apply(B,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var sh="\uFFFD",wt=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;yr&&(wt=P("[",_t(wt),"\\u{10000}-\\u{10FFFF}","]"));var oh=new RegExp("[^"+_t(wt)+"]",yr?"u":""),Mi=/[\x20\x09\x0D\x0A]/,ah=_t(Mi),X=P(Mi,"+"),te=P(Mi,"*"),wn=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;yr&&(wn=P("[",_t(wn),"\\u{10000}-\\u{10FFFF}","]"));var lh=_t(wn),_o=P("[",lh,_t(/[-.0-9\xB7]/),_t(/[\u0300-\u036F\u203F-\u2040]/),"]"),Be=P(wn,_o,"*"),uh=P("^",Be,"$"),El=P(_o,"+"),ch=P("&",Be,";"),dh=B(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),yn=B(ch,"|",dh),vn=P("%",Be,";"),wo=B(P('"',B(/[^%&"]/,"|",vn,"|",yn),"*",'"'),"|",P("'",B(/[^%&']/,"|",vn,"|",yn),"*","'")),fh=B('"',B(/[^<&"]/,"|",yn),"*",'"',"|","'",B(/[^<&']/,"|",yn),"*","'"),hh=_r(wn,":"),ph=_r(_o,":"),go=P(hh,ph,"*"),mh=P("^",go,"$"),En=P(go,B(":",go),"?"),gh=P("^",En,"$"),bh=P("(",En,")"),wr=B(/"[^"]*"|'[^']*'/),_h=P(/^<\?/,"(",Be,")",B(X,"(?!",Mi,")(",wt,"*?)"),"?",/\?>/),xl=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,xn=B('"',xl,'*"',"|","'",_r(xl,"'"),"*'"),Cl="<!--",Sl="-->",wh=P(Cl,B(_r(wt,"-"),"|",P("-",_r(wt,"-"))),"*",Sl),kl="#PCDATA",yh=B(P(/\(/,te,kl,B(te,/\|/,te,En),"*",te,/\)\*/),"|",P(/\(/,te,kl,te,/\)/)),vh=/[?*+]?/,Eh=P(/\([^>]+\)/,vh),xh=B("EMPTY","|","ANY","|",yh,"|",Eh),kh="<!ELEMENT",Ah=P(kh,X,B(En,"|",vn),X,B(xh,"|",vn),te,">"),Th=P("NOTATION",X,/\(/,te,Be,B(te,/\|/,te,Be),"*",te,/\)/),Dh=P(/\(/,te,El,B(te,/\|/,te,El),"*",te,/\)/),Ch=B(Th,"|",Dh),Sh=B(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Ch),Nh=B(/#REQUIRED|#IMPLIED/,"|",B(B("#FIXED",X),"?",fh)),Ih=B(X,Be,X,Sh,X,Nh),Oh="<!ATTLIST",Bh=P(Oh,X,Be,Ih,"*",te,">"),bo="about:legacy-compat",Rh=B('"'+bo+'"',"|","'"+bo+"'"),yo="SYSTEM",Li="PUBLIC",Pi=B(B(yo,X,wr),"|",B(Li,X,xn,X,wr)),$h=P("^",B(B(yo,X,"(?<SystemLiteralOnly>",wr,")"),"|",B(Li,X,"(?<PubidLiteral>",xn,")",X,"(?<SystemLiteral>",wr,")"))),Mh=P("^",xn,"$"),Lh=P("^",wr,"$"),Ph=B(X,"NDATA",X,Be),jh=B(wo,"|",B(Pi,Ph,"?")),Nl="<!ENTITY",Fh=P(Nl,X,Be,X,jh,te,">"),qh=B(wo,"|",Pi),Uh=P(Nl,X,"%",X,Be,X,qh,te,">"),Vh=B(Fh,"|",Uh),zh=P(Li,X,xn),Hh=P("<!NOTATION",X,Be,X,B(Pi,"|",zh),te,">"),vo=P(te,"=",te),Al=/1[.]\d+/,Wh=P(X,"version",vo,B("'",Al,"'","|",'"',Al,'"')),Tl=/[A-Za-z][-A-Za-z0-9._]*/,Gh=B(X,"encoding",vo,B('"',Tl,'"',"|","'",Tl,"'")),Xh=B(X,"standalone",vo,B("'",B("yes","|","no"),"'","|",'"',B("yes","|","no"),'"')),Yh=P(/^<\?xml/,Wh,Gh,"?",Xh,"?",te,/\?>/),Zh="<!DOCTYPE",Jh="<![CDATA[",Kh="]]>",Qh=/<!\[CDATA\[/,ep=/\]\]>/,tp=P(wt,"*?",ep),rp=P(Qh,tp);$.chars=_t;$.chars_without=_r;$.detectUnicodeSupport=Dl;$.reg=P;$.regg=B;$.ABOUT_LEGACY_COMPAT=bo;$.ABOUT_LEGACY_COMPAT_SystemLiteral=Rh;$.AttlistDecl=Bh;$.CDATA_START=Jh;$.CDATA_END=Kh;$.CDSect=rp;$.Char=wt;$.Comment=wh;$.COMMENT_START=Cl;$.COMMENT_END=Sl;$.DOCTYPE_DECL_START=Zh;$.elementdecl=Ah;$.EntityDecl=Vh;$.EntityValue=wo;$.ExternalID=Pi;$.ExternalID_match=$h;$.Name=Be;$.Name_exact=uh;$.NCName_exact=mh;$.NotationDecl=Hh;$.Reference=yn;$.PEReference=vn;$.PI=_h;$.PUBLIC=Li;$.PubidLiteral=xn;$.PubidLiteral_match=Mh;$.QName=En;$.QName_exact=gh;$.QName_group=bh;$.S=X;$.SChar_s=ah;$.S_OPT=te;$.SYSTEM=yo;$.SystemLiteral=wr;$.SystemLiteral_match=Lh;$.InvalidChar=oh;$.UNICODE_REPLACEMENT_CHARACTER=sh;$.UNICODE_SUPPORT=yr;$.XMLDecl=Yh});var Oo=dt(ie=>{"use strict";var Pe=zt(),Ke=Pe.find,np=Pe.hasDefaultHTMLNamespace,Er=Pe.hasOwn,ip=Pe.isHTMLMimeType,sp=Pe.isHTMLRawTextElement,op=Pe.isHTMLVoidElement,kn=Pe.MIME_TYPE,Qe=Pe.NAMESPACE,ke=Symbol(),Ll=_n(),k=Ll.DOMException,xe=Ll.DOMExceptionName,ne=Eo();function Se(n){if(n!==ke)throw new TypeError("Illegal constructor")}function ap(n){return n!==""}function lp(n){return n?n.split(/[\t\n\f\r ]+/).filter(ap):[]}function up(n,e){return Er(n,e)||(n[e]=!0),n}function Il(n){if(!n)return[];var e=lp(n);return Object.keys(e.reduce(up,{}))}function cp(n){return function(e){return n&&n.indexOf(e)!==-1}}function Pl(n){if(!ne.QName_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+n+'"')}function ko(n,e){Pl(e),n=n||null;var t=null,r=e;if(e.indexOf(":")>=0){var i=e.split(":");t=i[0],r=i[1]}if(t!==null&&n===null)throw new k(k.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&n!==Pe.NAMESPACE.XML)throw new k(k.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&n!==Pe.NAMESPACE.XMLNS)throw new k(k.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(n===Pe.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new k(k.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[n,t,r]}function Ar(n,e){for(var t in n)Er(n,t)&&(e[t]=n[t])}function Ne(n,e){var t=n.prototype;if(!(t instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,Ar(t,r),n.prototype=t=r}t.constructor!=n&&(typeof n!="function"&&console.error("unknown Class:"+n),t.constructor=n)}var Ie={},Le=Ie.ELEMENT_NODE=1,xr=Ie.ATTRIBUTE_NODE=2,An=Ie.TEXT_NODE=3,jl=Ie.CDATA_SECTION_NODE=4,Fl=Ie.ENTITY_REFERENCE_NODE=5,dp=Ie.ENTITY_NODE=6,Ao=Ie.PROCESSING_INSTRUCTION_NODE=7,To=Ie.COMMENT_NODE=8,vr=Ie.DOCUMENT_NODE=9,ql=Ie.DOCUMENT_TYPE_NODE=10,yt=Ie.DOCUMENT_FRAGMENT_NODE=11,fp=Ie.NOTATION_NODE=12,re=Pe.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 Ul(n,e){if(e.length<n.length)return Ul(e,n);var t=null;for(var r in n){if(n[r]!==e[r])return t;t=n[r]}return t}function Ol(n){return n.guid||(n.guid=Math.random()),n.guid}function ue(){}ue.prototype={length:0,item:function(n){return n>=0&&n<this.length?this[n]:null},toString:function(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var t=[],r=0;r<this.length;r++)Io(this[r],t,null,e);return t.join("")},filter:function(n){return Array.prototype.filter.call(this,n)},indexOf:function(n){return Array.prototype.indexOf.call(this,n)}};ue.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Je(n,e){this._node=n,this._refresh=e,Ui(this)}function Ui(n){var e=n._node._inc||n._node.ownerDocument._inc;if(n._inc!==e){var t=n._refresh(n._node);if(Ql(n,"length",t.length),!n.$$length||t.length<n.$$length)for(var r=t.length;r in n;r++)Er(n,r)&&delete n[r];Ar(t,n),n._inc=e}}Je.prototype.item=function(n){return Ui(this),this[n]||null};Ne(Je,ue);function kr(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function Vl(n,e){for(var t=0;t<n.length;){if(n[t]===e)return t;t++}}function Do(n,e,t){if(!e)return n._noNsIndex;var r=n._nsIndex[e];return!r&&t&&(r=n._nsIndex[e]=Object.create(null)),r}function hp(n,e,t){var r=Do(n,e,!1),i=r&&r[t];return i||null}function pp(n,e){Do(n,e.namespaceURI,!0)[e.localName]=e}function mp(n,e){var t=Do(n,e.namespaceURI,!1);t&&delete t[e.localName]}function gp(n,e,t,r){if(r?e[Vl(e,r)]=t:(e[e.length]=t,e.length++),pp(e,t),n){t.ownerElement=n;var i=n.ownerDocument;i&&(r&&Wl(i,n,r),bp(i,n,t))}}function Bl(n,e,t){var r=Vl(e,t);if(r>=0){for(var i=e.length-1;r<=i;)e[r]=e[++r];if(e.length=i,mp(e,t),n){var s=n.ownerDocument;s&&Wl(s,n,t),t.ownerElement=null}}}kr.prototype={length:0,item:ue.prototype.item,getNamedItem:function(n){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());for(var e=0;e<this.length;){var t=this[e];if(t.nodeName===n)return t;e++}return null},setNamedItem:function(n){var e=n.ownerElement;if(e&&e!==this._ownerElement)throw new k(k.INUSE_ATTRIBUTE_ERR);var t=hp(this,n.namespaceURI,n.localName);return t===n?n:(gp(this._ownerElement,this,n,t),t)},setNamedItemNS:function(n){return this.setNamedItem(n)},removeNamedItem:function(n){var e=this.getNamedItem(n);if(!e)throw new k(k.NOT_FOUND_ERR,n);return Bl(this._ownerElement,this,e),e},removeNamedItemNS:function(n,e){var t=this.getNamedItemNS(n,e);if(!t)throw new k(k.NOT_FOUND_ERR,n?n+" : "+e:e);return Bl(this._ownerElement,this,t),t},getNamedItemNS:function(n,e){n||(n=null);for(var t=0;t<this.length;){var r=this[t];if(r.localName===e&&r.namespaceURI===n)return r;t++}return null}};kr.prototype[Symbol.iterator]=function(){var n=this,e=0;return{next:function(){return e<n.length?{value:n[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function zl(){}zl.prototype={hasFeature:function(n,e){return!0},createDocument:function(n,e,t){var r=kn.XML_APPLICATION;n===Qe.HTML?r=kn.XML_XHTML_APPLICATION:n===Qe.SVG&&(r=kn.XML_SVG_IMAGE);var i=new ot(ke,{contentType:r});if(i.implementation=this,i.childNodes=new ue,i.doctype=t||null,t&&i.appendChild(t),e){var s=i.createElementNS(n,e);i.appendChild(s)}return i},createDocumentType:function(n,e,t,r){Pl(n);var i=new Hi(ke);return i.name=n,i.nodeName=n,i.publicId=e||"",i.systemId=t||"",i.internalSubset=r||"",i.childNodes=new ue,i},createHTMLDocument:function(n){var e=new ot(ke,{contentType:kn.HTML});if(e.implementation=this,e.childNodes=new ue,n!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var t=e.createElement("html");e.appendChild(t);var r=e.createElement("head");if(t.appendChild(r),typeof n=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(n)),r.appendChild(i)}t.appendChild(e.createElement("body"))}return e}};function F(n){Se(n)}F.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 n=this.getRootNode();return n&&n.nodeType===n.DOCUMENT_NODE},contains:function(n){if(!n)return!1;var e=n;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(n){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(n){if(!n)return!1;for(var e=[{node:this,other:n}];e.length>0;){var t=e.pop(),r=t.node,i=t.other;if(r.nodeType!==i.nodeType)return!1;switch(r.nodeType){case r.DOCUMENT_TYPE_NODE:if(r.name!==i.name||r.publicId!==i.publicId||r.systemId!==i.systemId)return!1;break;case r.ELEMENT_NODE:if(r.namespaceURI!==i.namespaceURI||r.prefix!==i.prefix||r.localName!==i.localName||r.attributes.length!==i.attributes.length)return!1;for(var s=0;s<r.attributes.length;s++){var o=r.attributes.item(s),a=i.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case r.ATTRIBUTE_NODE:if(r.namespaceURI!==i.namespaceURI||r.localName!==i.localName||r.value!==i.value)return!1;break;case r.PROCESSING_INSTRUCTION_NODE:if(r.target!==i.target||r.data!==i.data)return!1;break;case r.TEXT_NODE:case r.CDATA_SECTION_NODE:case r.COMMENT_NODE:if(r.data!==i.data)return!1;break}if(r.childNodes.length!==i.childNodes.length)return!1;for(var s=r.childNodes.length-1;s>=0;s--)e.push({node:r.childNodes[s],other:i.childNodes[s]})}return!0},isSameNode:function(n){return this===n},insertBefore:function(n,e){return qi(this,n,e)},replaceChild:function(n,e){qi(this,n,e,Yl),e&&this.removeChild(e)},removeChild:function(n){return Gl(this,n)},appendChild:function(n){return this.insertBefore(n,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(n){return Kl(this.ownerDocument||this,this,n)},normalize:function(){ge(this,null,{enter:function(n){for(var e=n.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===An&&e.nodeType===An){for(var r=[],i=t;i!==null&&i.nodeType===An;)r.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:n.lastChild=e,e.appendData(r.join("")),Co(n.ownerDocument,n),e=i}else e=t}return!0}})},isSupported:function(n,e){return this.ownerDocument.implementation.hasFeature(n,e)},lookupPrefix:function(n){for(var e=this;e;){var t=e._nsMap;if(t){for(var r in t)if(Er(t,r)&&t[r]===n)return r}e=e.nodeType==xr?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(n){for(var e=this;e;){var t=e._nsMap;if(t&&Er(t,n))return t[n];e=e.nodeType==xr?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(n){var e=this.lookupPrefix(n);return e==null},compareDocumentPosition:function(n){if(this===n)return 0;var e=n,t=this,r=null,i=null;if(e instanceof Ht&&(r=e,e=r.ownerElement),t instanceof Ht&&(i=t,t=i.ownerElement,r&&e&&t===e))for(var s=0,o;o=t.attributes[s];s++){if(o===r)return re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+re.DOCUMENT_POSITION_PRECEDING;if(o===i)return re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+re.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return re.DOCUMENT_POSITION_DISCONNECTED+re.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(Ol(t.ownerDocument)>Ol(e.ownerDocument)?re.DOCUMENT_POSITION_FOLLOWING:re.DOCUMENT_POSITION_PRECEDING);if(i&&e===t)return re.DOCUMENT_POSITION_CONTAINS+re.DOCUMENT_POSITION_PRECEDING;if(r&&e===t)return re.DOCUMENT_POSITION_CONTAINED_BY+re.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===t)return re.DOCUMENT_POSITION_CONTAINED_BY+re.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=t.parentNode;c;){if(!r&&c===e)return re.DOCUMENT_POSITION_CONTAINS+re.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=Ul(a,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return re.DOCUMENT_POSITION_FOLLOWING;if(h===e)return re.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return re.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(h)>=0)return re.DOCUMENT_POSITION_PRECEDING}return 0}};function Hl(n){return n=="<"&&"&lt;"||n==">"&&"&gt;"||n=="&"&&"&amp;"||n=='"'&&"&quot;"||"&#"+n.charCodeAt()+";"}Ar(Ie,F);Ar(Ie,F.prototype);Ar(re,F);Ar(re,F.prototype);function Fi(n,e){ge(n,null,{enter:function(t){return e(t)?ge.STOP:!0}})}function ge(n,e,t){for(var r=[{node:n,context:e,phase:ge.ENTER}];r.length>0;){var i=r.pop();if(i.phase===ge.ENTER){var s=t.enter(i.node,i.context);if(s===ge.STOP)return ge.STOP;if(r.push({node:i.node,context:s,phase:ge.EXIT}),s==null)continue;for(var o=i.node.lastChild;o;)r.push({node:o,context:s,phase:ge.ENTER}),o=o.previousSibling}else t.exit&&t.exit(i.node,i.context)}}ge.STOP=Symbol("walkDOM.STOP");ge.ENTER=0;ge.EXIT=1;function ot(n,e){Se(n);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||kn.XML_APPLICATION,this.type=ip(this.contentType)?"html":"xml"}function bp(n,e,t){n&&n._inc++;var r=t.namespaceURI;r===Qe.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function Wl(n,e,t,r){n&&n._inc++;var i=t.namespaceURI;i===Qe.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function Co(n,e,t){if(n&&n._inc){n._inc++;var r=e.childNodes;if(t&&!t.nextSibling)r[r.length++]=t;else{for(var i=e.firstChild,s=0;i;)r[s++]=i,i=i.nextSibling;r.length=s,delete r[r.length]}}}function Gl(n,e){if(n!==e.parentNode)throw new k(k.NOT_FOUND_ERR,"child's parent is not parent");var t=e.previousSibling,r=e.nextSibling;return t?t.nextSibling=r:n.firstChild=r,r?r.previousSibling=t:n.lastChild=t,Co(n.ownerDocument,n),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function _p(n){return n&&(n.nodeType===F.DOCUMENT_NODE||n.nodeType===F.DOCUMENT_FRAGMENT_NODE||n.nodeType===F.ELEMENT_NODE)}function wp(n){return n&&(n.nodeType===F.CDATA_SECTION_NODE||n.nodeType===F.COMMENT_NODE||n.nodeType===F.DOCUMENT_FRAGMENT_NODE||n.nodeType===F.DOCUMENT_TYPE_NODE||n.nodeType===F.ELEMENT_NODE||n.nodeType===F.PROCESSING_INSTRUCTION_NODE||n.nodeType===F.TEXT_NODE)}function vt(n){return n&&n.nodeType===F.DOCUMENT_TYPE_NODE}function st(n){return n&&n.nodeType===F.ELEMENT_NODE}function Xl(n){return n&&n.nodeType===F.TEXT_NODE}function Rl(n,e){var t=n.childNodes||[];if(Ke(t,st)||vt(e))return!1;var r=Ke(t,vt);return!(e&&r&&t.indexOf(r)>t.indexOf(e))}function $l(n,e){var t=n.childNodes||[];function r(s){return st(s)&&s!==e}if(Ke(t,r))return!1;var i=Ke(t,vt);return!(e&&i&&t.indexOf(i)>t.indexOf(e))}function yp(n,e,t){if(!_p(n))throw new k(k.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+n.nodeType);if(t&&t.parentNode!==n)throw new k(k.NOT_FOUND_ERR,"child not in parent");if(!wp(e)||vt(e)&&n.nodeType!==F.DOCUMENT_NODE)throw new k(k.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+n.nodeType)}function vp(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var s=i.filter(st);if(s.length>1||Ke(i,Xl))throw new k(k.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Rl(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(st(e)&&!Rl(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(vt(e)){if(Ke(r,vt))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ke(r,st);if(t&&r.indexOf(o)<r.indexOf(t))throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&o)throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function Yl(n,e,t){var r=n.childNodes||[],i=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var s=i.filter(st);if(s.length>1||Ke(i,Xl))throw new k(k.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!$l(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(st(e)&&!$l(n,t))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(vt(e)){if(Ke(r,function(l){return vt(l)&&l!==t}))throw new k(k.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ke(r,st);if(t&&r.indexOf(o)<r.indexOf(t))throw new k(k.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function qi(n,e,t,r){yp(n,e,t),n.nodeType===F.DOCUMENT_NODE&&(r||vp)(n,e,t);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===yt){var s=e.firstChild;if(s==null)return e;var o=e.lastChild}else s=o=e;var a=t?t.previousSibling:n.lastChild;s.previousSibling=a,o.nextSibling=t,a?a.nextSibling=s:n.firstChild=s,t==null?n.lastChild=o:t.previousSibling=o;do s.parentNode=n;while(s!==o&&(s=s.nextSibling));return Co(n.ownerDocument||n,n,e),e.nodeType==yt&&(e.firstChild=e.lastChild=null),e}ot.prototype={implementation:null,nodeName:"#document",nodeType:vr,doctype:null,documentElement:null,_inc:1,insertBefore:function(n,e){if(n.nodeType===yt){for(var t=n.firstChild;t;){var r=t.nextSibling;this.insertBefore(t,e),t=r}return n}return qi(this,n,e),n.ownerDocument=this,this.documentElement===null&&n.nodeType===Le&&(this.documentElement=n),n},removeChild:function(n){var e=Gl(this,n);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(n,e){qi(this,n,e,Yl),n.ownerDocument=this,e&&this.removeChild(e),st(n)&&(this.documentElement=n)},importNode:function(n,e){return Ep(this,n,e)},getElementById:function(n){var e=null;return Fi(this.documentElement,function(t){if(t.nodeType==Le&&t.getAttribute("id")==n)return e=t,!0}),e},createElement:function(n){var e=new at(ke);e.ownerDocument=this,this.type==="html"&&(n=n.toLowerCase()),np(this.contentType)&&(e.namespaceURI=Qe.HTML),e.nodeName=n,e.tagName=n,e.localName=n,e.childNodes=new ue;var t=e.attributes=new kr;return t._ownerElement=e,e},createDocumentFragment:function(){var n=new Tr(ke);return n.ownerDocument=this,n.childNodes=new ue,n},createTextNode:function(n){var e=new Tn(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createComment:function(n){var e=new Vi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createCDATASection:function(n){if(n.indexOf("]]>")!==-1)throw new k(k.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new zi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.appendData(n),e},createProcessingInstruction:function(n,e){var t=new Gi(ke);return t.ownerDocument=this,t.childNodes=new ue,t.nodeName=t.target=n,t.nodeValue=t.data=e,t},createAttribute:function(n){if(!ne.QName_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'invalid character in name "'+n+'"');return this.type==="html"&&(n=n.toLowerCase()),this._createAttribute(n)},_createAttribute:function(n){var e=new Ht(ke);return e.ownerDocument=this,e.childNodes=new ue,e.name=n,e.nodeName=n,e.localName=n,e.specified=!0,e},createEntityReference:function(n){if(!ne.Name_exact.test(n))throw new k(k.INVALID_CHARACTER_ERR,'not a valid xml name "'+n+'"');if(this.type==="html")throw new k("document is an html document",xe.NotSupportedError);var e=new Wi(ke);return e.ownerDocument=this,e.childNodes=new ue,e.nodeName=n,e},createElementNS:function(n,e){var t=ko(n,e),r=new at(ke),i=r.attributes=new kr;return r.childNodes=new ue,r.ownerDocument=this,r.nodeName=e,r.tagName=e,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],i._ownerElement=r,r},createAttributeNS:function(n,e){var t=ko(n,e),r=new Ht(ke);return r.ownerDocument=this,r.childNodes=new ue,r.nodeName=e,r.name=e,r.specified=!0,r.namespaceURI=t[0],r.prefix=t[1],r.localName=t[2],r}};Ne(ot,F);function at(n){Se(n),this._nsMap=Object.create(null)}at.prototype={nodeType:Le,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(n){return!!this.getAttributeNode(n)},getAttribute:function(n){var e=this.getAttributeNode(n);return e?e.value:null},getAttributeNode:function(n){return this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase()),this.attributes.getNamedItem(n)},setAttribute:function(n,e){this._isInHTMLDocumentAndNamespace()&&(n=n.toLowerCase());var t=this.getAttributeNode(n);t?t.value=t.nodeValue=""+e:(t=this.ownerDocument._createAttribute(n),t.value=t.nodeValue=""+e,this.setAttributeNode(t))},removeAttribute:function(n){var e=this.getAttributeNode(n);e&&this.removeAttributeNode(e)},setAttributeNode:function(n){return this.attributes.setNamedItem(n)},setAttributeNodeNS:function(n){return this.attributes.setNamedItemNS(n)},removeAttributeNode:function(n){return this.attributes.removeNamedItem(n.nodeName)},removeAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);t&&this.removeAttributeNode(t)},hasAttributeNS:function(n,e){return this.getAttributeNodeNS(n,e)!=null},getAttributeNS:function(n,e){var t=this.getAttributeNodeNS(n,e);return t?t.value:null},setAttributeNS:function(n,e,t){var r=ko(n,e),i=r[2],s=this.getAttributeNodeNS(n,i);s?s.value=s.nodeValue=""+t:(s=this.ownerDocument.createAttributeNS(n,e),s.value=s.nodeValue=""+t,this.setAttributeNode(s))},getAttributeNodeNS:function(n,e){return this.attributes.getNamedItemNS(n,e)},getElementsByClassName:function(n){var e=Il(n);return new Je(this,function(t){var r=[];return e.length>0&&Fi(t,function(i){if(i!==t&&i.nodeType===Le){var s=i.getAttribute("class");if(s){var o=n===s;if(!o){var a=Il(s);o=e.every(cp(a))}o&&r.push(i)}}}),r})},getElementsByTagName:function(n){var e=(this.nodeType===vr?this:this.ownerDocument).type==="html",t=n.toLowerCase();return new Je(this,function(r){var i=[];return Fi(r,function(s){if(!(s===r||s.nodeType!==Le))if(n==="*")i.push(s);else{var o=s.getQualifiedName(),a=e&&s.namespaceURI===Qe.HTML?t:n;o===a&&i.push(s)}}),i})},getElementsByTagNameNS:function(n,e){return new Je(this,function(t){var r=[];return Fi(t,function(i){i!==t&&i.nodeType===Le&&(n==="*"||i.namespaceURI===n)&&(e==="*"||i.localName==e)&&r.push(i)}),r})}};ot.prototype.getElementsByClassName=at.prototype.getElementsByClassName;ot.prototype.getElementsByTagName=at.prototype.getElementsByTagName;ot.prototype.getElementsByTagNameNS=at.prototype.getElementsByTagNameNS;Ne(at,F);function Ht(n){Se(n),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}Ht.prototype.nodeType=xr;Ne(Ht,F);function Et(n){Se(n)}Et.prototype={data:"",substringData:function(n,e){return this.data.substring(n,n+e)},appendData:function(n){n=this.data+n,this.nodeValue=this.data=n,this.length=n.length},insertData:function(n,e){this.replaceData(n,0,e)},deleteData:function(n,e){this.replaceData(n,e,"")},replaceData:function(n,e,t){var r=this.data.substring(0,n),i=this.data.substring(n+e);t=r+t+i,this.nodeValue=this.data=t,this.length=t.length}};Ne(Et,F);function Tn(n){Se(n)}Tn.prototype={nodeName:"#text",nodeType:An,splitText:function(n){var e=this.data,t=e.substring(n);e=e.substring(0,n),this.data=this.nodeValue=e,this.length=e.length;var r=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};Ne(Tn,Et);function Vi(n){Se(n)}Vi.prototype={nodeName:"#comment",nodeType:To};Ne(Vi,Et);function zi(n){Se(n)}zi.prototype={nodeName:"#cdata-section",nodeType:jl};Ne(zi,Tn);function Hi(n){Se(n)}Hi.prototype.nodeType=ql;Ne(Hi,F);function So(n){Se(n)}So.prototype.nodeType=fp;Ne(So,F);function No(n){Se(n)}No.prototype.nodeType=dp;Ne(No,F);function Wi(n){Se(n)}Wi.prototype.nodeType=Fl;Ne(Wi,F);function Tr(n){Se(n)}Tr.prototype.nodeName="#document-fragment";Tr.prototype.nodeType=yt;Ne(Tr,F);function Gi(n){Se(n)}Gi.prototype.nodeType=Ao;Ne(Gi,Et);function Zl(){}Zl.prototype.serializeToString=function(n,e){return Jl.call(n,e)};F.prototype.toString=Jl;function Jl(n){var e;typeof n=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:n}:n!=null?e={requireWellFormed:!!n.requireWellFormed,splitCDATASections:n.splitCDATASections!==!1,nodeFilter:n.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var t=[],r=this.nodeType===vr&&this.documentElement||this,i=r.prefix,s=r.namespaceURI;if(s&&i==null){var i=r.lookupPrefix(s);if(i==null)var o=[{namespace:s,prefix:null}]}return Io(this,t,o,e),t.join("")}function Ml(n,e,t){var r=n.prefix||"",i=n.namespaceURI;if(!i||r==="xml"&&i===Qe.XML||i===Qe.XMLNS)return!1;for(var s=t.length;s--;){var o=t[s];if(o.prefix===r)return o.namespace!==i}return!0}function ji(n,e,t,r){if(r&&!ne.QName_exact.test(e))throw new k('The attribute name "'+e+'" is not a valid XML QName',xe.InvalidStateError);n.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,Hl),'"')}function Io(n,e,t,r){t||(t=[]);var i=r.nodeFilter,s=r.requireWellFormed,o=r.splitCDATASections,a=n.nodeType===vr?n:n.ownerDocument,l=a.type==="html";ge(n,{ns:t},{enter:function(u,c){var d=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 Le:var f=u.attributes,h=f.length,m=u.tagName,p=m;if(!l&&!u.prefix&&u.namespaceURI){for(var b,g=0;g<f.length;g++)if(f.item(g).name==="xmlns"){b=f.item(g).value;break}if(!b)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.prefix===""&&w.namespace===u.namespaceURI){b=w.namespace;break}}if(b!==u.namespaceURI)for(var _=d.length-1;_>=0;_--){var w=d[_];if(w.namespace===u.namespaceURI){w.prefix&&(p=w.prefix+":"+m);break}}}if(s&&!ne.QName_exact.test(p))throw new k('The element name "'+p+'" is not a valid XML QName',xe.InvalidStateError);e.push("<",p);for(var E=d.slice(),D=0;D<h;D++){var y=f.item(D);y.prefix=="xmlns"?E.push({prefix:y.localName,namespace:y.value}):y.nodeName=="xmlns"&&E.push({prefix:"",namespace:y.value})}for(var D=0;D<h;D++){var y=f.item(D);if(Ml(y,l,E)){var T=y.prefix||"",S=y.namespaceURI;ji(e,T?"xmlns:"+T:"xmlns",S,s),E.push({prefix:T,namespace:S})}var I=i?i(y):y;I&&(typeof I=="string"?e.push(I):ji(e,I.name,I.value,s))}if(m===p&&Ml(u,l,E)){var W=u.prefix||"",S=u.namespaceURI;ji(e,W?"xmlns:"+W:"xmlns",S,s),E.push({prefix:W,namespace:S})}var ee=!u.firstChild;if(ee&&(l||u.namespaceURI===Qe.HTML)&&(ee=op(m)),ee)return e.push("/>"),null;if(e.push(">"),l&&sp(m)){for(var se=u.firstChild;se;)se.data?e.push(se.data):Io(se,e,E.slice(),r),se=se.nextSibling;return e.push("</",p,">"),null}return{ns:E,tag:p};case vr:case yt:if(s&&u.nodeType===vr&&u.documentElement==null)throw new k("The Document has no documentElement",xe.InvalidStateError);return{ns:d};case xr:return ji(e,u.name,u.value,s),null;case An:if(s&&ne.InvalidChar.test(u.data))throw new k("The Text node data contains characters outside the XML Char production",xe.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,Hl)),null;case jl:if(s&&u.data.indexOf("]]>")!==-1)throw new k('The CDATASection data contains "]]>"',xe.InvalidStateError);return o?e.push(ne.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),ne.CDATA_END):e.push(ne.CDATA_START,u.data,ne.CDATA_END),null;case To:if(s){if(ne.InvalidChar.test(u.data))throw new k("The comment node data contains characters outside the XML Char production",xe.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new k('The comment node data contains "--" or ends with "-"',xe.InvalidStateError)}return e.push(ne.COMMENT_START,u.data,ne.COMMENT_END),null;case ql:var he=u.publicId,Y=u.systemId;if(s){if(!ne.Name_exact.test(u.name))throw new k('The doctype name "'+u.name+'" is not a valid XML Name',xe.InvalidStateError);if(he&&!ne.PubidLiteral_match.test(he))throw new k("DocumentType publicId is not a valid PubidLiteral",xe.InvalidStateError);if(Y&&Y!=="."&&!ne.SystemLiteral_match.test(Y))throw new k("DocumentType systemId is not a valid SystemLiteral",xe.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new k('DocumentType internalSubset contains "]>"',xe.InvalidStateError)}return e.push(ne.DOCTYPE_DECL_START," ",u.name),he?(e.push(" ",ne.PUBLIC," ",he),Y&&Y!=="."&&e.push(" ",Y)):Y&&Y!=="."&&e.push(" ",ne.SYSTEM," ",Y),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case Ao:if(s){if(!ne.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new k('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',xe.InvalidStateError);if(ne.InvalidChar.test(u.data))throw new k("The ProcessingInstruction data contains characters outside the XML Char production",xe.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new k('The ProcessingInstruction data contains "?>"',xe.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case Fl:if(s&&!ne.Name_exact.test(u.nodeName))throw new k('The entity reference name "'+u.nodeName+'" is not a valid XML Name',xe.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 Ep(n,e,t){var r;return ge(e,null,{enter:function(i,s){var o=i.cloneNode(!1);o.ownerDocument=n,o.parentNode=null,s===null?r=o:s.appendChild(o);var a=i.nodeType===xr||t;return a?o:null}}),r}function Kl(n,e,t){var r;return ge(e,null,{enter:function(i,s){var o=new i.constructor(ke);for(var a in i)if(Er(i,a)){var l=i[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}i.childNodes&&(o.childNodes=new ue),o.ownerDocument=n;var u=t;switch(o.nodeType){case Le:var c=i.attributes,d=o.attributes=new kr,f=c.length;d._ownerElement=o;for(var h=0;h<f;h++)o.setAttributeNode(Kl(n,c.item(h),!0));break;case xr:u=!0}return s!==null?s.appendChild(o):r=o,u?o:null}}),r}function Ql(n,e,t){n[e]=t}function xo(n){for(var e=[],t=n.firstChild;t;)t.nodeType===Le&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Je.prototype,"length",{get:function(){return Ui(this),this.$$length}}),Object.defineProperty(F.prototype,"textContent",{get:function(){if(this.nodeType===Le||this.nodeType===yt){var n=[];return ge(this,null,{enter:function(e){if(e.nodeType===Le||e.nodeType===yt)return!0;if(e.nodeType===Ao||e.nodeType===To)return null;n.push(e.nodeValue)}}),n.join("")}return this.nodeValue},set:function(n){switch(this.nodeType){case Le:case yt:for(;this.firstChild;)this.removeChild(this.firstChild);(n||String(n))&&this.appendChild(this.ownerDocument.createTextNode(n));break;default:this.data=n,this.value=n,this.nodeValue=n}}}),Object.defineProperty(Et.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(n){this._data=n,this.length=typeof n=="string"?n.length:0}}),Object.defineProperty(Et.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!0,configurable:!0}),Object.defineProperty(at.prototype,"children",{get:function(){return new Je(this,xo)}}),Object.defineProperty(ot.prototype,"children",{get:function(){return new Je(this,xo)}}),Object.defineProperty(Tr.prototype,"children",{get:function(){return new Je(this,xo)}}),Ql=function(n,e,t){n["$$"+e]=t})}catch{}ie._updateLiveList=Ui;ie.Attr=Ht;ie.CDATASection=zi;ie.CharacterData=Et;ie.Comment=Vi;ie.Document=ot;ie.DocumentFragment=Tr;ie.DocumentType=Hi;ie.DOMImplementation=zl;ie.Element=at;ie.Entity=No;ie.EntityReference=Wi;ie.LiveNodeList=Je;ie.NamedNodeMap=kr;ie.Node=F;ie.NodeList=ue;ie.Notation=So;ie.Text=Tn;ie.ProcessingInstruction=Gi;ie.walkDOM=ge;ie.XMLSerializer=Zl});var tu=dt(Dn=>{"use strict";var eu=zt().freeze;Dn.XML_ENTITIES=eu({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});Dn.HTML_ENTITIES=eu({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:`
10
+ `,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"});Dn.entityMap=Dn.HTML_ENTITIES});var cu=dt(Yi=>{"use strict";var Ir=zt(),M=Eo(),su=_n(),xp=Ir.isHTMLEscapableRawTextElement,kp=Ir.isHTMLMimeType,Ap=Ir.isHTMLRawTextElement,Nn=Ir.hasOwn,ru=Ir.NAMESPACE,Tp=su.ParseError,Dp=su.DOMException,Dr=0,xt=1,Cr=2,Cn=3,Sr=4,Nr=5,Sn=6,Xi=7;function ou(){}ou.prototype={parse:function(n,e,t){var r=this.domBuilder;r.startDocument(),Ip(e,e=Object.create(null)),Cp(n,e,t,r,this.errorHandler),r.endDocument()}};var Bo=/&#?\w+;?/g;function Cp(n,e,t,r,i){var s=kp(r.mimeType);n.indexOf(M.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function o(z){if(z>65535){z-=65536;var Me=55296+(z>>10),_i=56320+(z&1023);return String.fromCharCode(Me,_i)}else return String.fromCharCode(z)}function a(z){var Me=z[z.length-1]===";"?z:z+";";if(!s&&Me!==z)return i.error("EntityRef: expecting ;"),z;var _i=M.Reference.exec(Me);if(!_i||_i[0].length!==Me.length)return i.error("entity not matching Reference production: "+z),z;var wi=Me.slice(1,-1);return Nn(t,wi)?t[wi]:wi.charAt(0)==="#"?o(parseInt(wi.substring(1).replace("x","0x"))):(i.error("entity not found:"+z),z)}function l(z){if(z>b){var Me=n.substring(b,z).replace(Bo,a);f&&h(b),r.characters(Me,0,z-b),b=z}}var u=0,c=0,d=/\r\n?|\n|$/g,f=r.locator;function h(z,Me){for(;z>=c&&(Me=d.exec(n));)u=c,c=Me.index+Me[0].length,f.lineNumber++;f.columnNumber=z-u+1}for(var m=[{currentNSMap:e}],p=[],b=0;;){try{var g=n.indexOf("<",b);if(g<0){if(!s&&p.length>0)return i.fatalError("unclosed xml tag(s): "+p.join(", "));if(!n.substring(b).match(/^\s*$/)){var _=r.doc,w=_.createTextNode(n.substring(b));if(_.documentElement)return i.error("Extra content at the end of the document");_.appendChild(w),r.currentElement=w}return}if(g>b){var E=n.substring(b,g);!s&&p.length===0&&(E=E.replace(new RegExp(M.S_OPT.source,"g"),""),E&&i.error("Unexpected content outside root element: '"+E+"'")),l(g)}switch(n.charAt(g+1)){case"/":var L=n.indexOf(">",g+2),D=n.substring(g+2,L>0?L:void 0);if(!D)return i.fatalError("end tag name missing");var y=M.reg("^",M.QName_group,M.S_OPT,"$"),T=L>0&&y.exec(D);if(!T){var S=L>0&&M.reg("^",M.QName_group).exec(D);if(s&&S)i.warning('end tag name contains invalid trailing characters: "'+D+'"'),T=S;else if(S&&new RegExp(y.source,y.flags+"m").test(D))i.error('end tag name is followed by a line break and trailing content: "'+D+'"'),T=S;else return i.fatalError('end tag name contains invalid characters: "'+D+'"')}if(!r.currentElement&&!r.doc.documentElement)return;var I=p[p.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if(I!==T[1]){var W=T[1].toLowerCase();if(!s||I.toLowerCase()!==W)return i.fatalError('Opening and ending tag mismatch: "'+I+'" != "'+D+'"')}var ee=m.pop();p.pop();var se=ee.localNSMap;if(r.endElement(ee.uri,ee.localName,I),se)for(var he in se)Nn(se,he)&&r.endPrefixMapping(he);L++;break;case"?":f&&h(g),L=Bp(n,g,r,i);break;case"!":f&&h(g),L=lu(n,g,r,i,s);break;default:f&&h(g);var Y=new uu,ae=m[m.length-1].currentNSMap,L=Sp(n,g,Y,ae,a,i,s),Sa=Y.length;if(Y.closed||(s&&Ir.isHTMLVoidElement(Y.tagName)?Y.closed=!0:p.push(Y.tagName)),f&&Sa){for(var md=nu(f,{}),Ys=0;Ys<Sa;Ys++){var Na=Y[Ys];h(Na.offset),Na.locator=nu(f,{})}r.locator=md,iu(Y,r,ae)&&m.push(Y),r.locator=f}else iu(Y,r,ae)&&m.push(Y);s&&!Y.closed?L=Np(n,L,Y.tagName,a,r):L++}}catch(z){if(z instanceof Tp)throw z;if(z instanceof Dp)return i.fatalError("Error constructing the DOM: "+z.name+": "+z.message,z);i.error("element parse error: "+z),L=-1}L>b?b=L:l(Math.max(g,b)+1)}}function nu(n,e){return e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber,e}function Sp(n,e,t,r,i,s,o){function a(h,m,p){if(Nn(t.attributeNames,h))return s.fatalError("Attribute "+h+" redefined");if(!o&&m.indexOf("<")>=0)return s.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,m.replace(/[\t\n\r]/g," ").replace(Bo,i),p)}for(var l,u,c=++e,d=Dr;;){var f=n.charAt(c);if(d===Dr&&f==="<")throw new Error("unexpected < in tag name: "+n.slice(e,c));switch(f){case"=":if(d===xt)l=n.slice(e,c),d=Cn;else if(d===Cr)d=Cn;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===Cn||d===xt)if(d===xt&&(s.warning('attribute value must after "="'),l=n.slice(e,c)),e=c+1,c=n.indexOf(f,e),c>0)u=n.slice(e,c),a(l,u,e-1),d=Nr;else throw new Error("attribute value no end '"+f+"' match");else if(d==Sr)u=n.slice(e,c),a(l,u,e),s.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Nr;else throw new Error('attribute value must after "="');break;case"/":switch(d){case Dr:t.setTagName(n.slice(e,c));case Nr:case Sn:case Xi:d=Xi,t.closed=!0;case Sr:case xt:break;case Cr:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),d==Dr&&t.setTagName(n.slice(e,c)),c;case">":switch(d){case Dr:t.setTagName(n.slice(e,c));case Nr:case Sn:case Xi:break;case Sr:case xt:u=n.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Cr:d===Cr&&(u=l),d==Sr?(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 Cn:if(!o)return s.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case Dr:t.setTagName(n.slice(e,c)),d=Sn;break;case xt:l=n.slice(e,c),d=Cr;break;case Sr:var u=n.slice(e,c);s.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Nr:d=Sn;break}else switch(d){case Cr:o||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,d=xt;break;case Nr:s.warning('attribute space is required"'+l+'"!!');case Sn:d=xt,e=c;break;case Cn:d=Sr,e=c;break;case Xi:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function iu(n,e,t){for(var r=n.tagName,i=null,d=n.length;d--;){var s=n[d],o=s.qName,a=s.value,f=o.indexOf(":");if(f>0)var l=s.prefix=o.slice(0,f),u=o.slice(f+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";s.localName=u,c!==!1&&(i==null&&(i=Object.create(null),t=Object.create(t)),t[c]=i[c]=a,s.uri=ru.XMLNS,e.startPrefixMapping(c,a))}for(var d=n.length;d--;)s=n[d],s.prefix&&(s.prefix==="xml"&&(s.uri=ru.XML),s.prefix!=="xmlns"&&(s.uri=t[s.prefix]));var f=r.indexOf(":");f>0?(l=n.prefix=r.slice(0,f),u=n.localName=r.slice(f+1)):(l=null,u=n.localName=r);var h=n.uri=t[l||""];if(e.startElement(h,u,r,n),n.closed){if(e.endElement(h,u,r),i)for(l in i)Nn(i,l)&&e.endPrefixMapping(l)}else return n.currentNSMap=t,n.localNSMap=i,!0}function Np(n,e,t,r,i){var s=xp(t);if(s||Ap(t)){var o=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(n),l=a?a.index:-1;if(l<0)return e+1;var u=n.substring(e+1,l);return s&&(u=u.replace(Bo,r)),i.characters(u,0,u.length),l}return e+1}function Ip(n,e){for(var t in n)Nn(n,t)&&(e[t]=n[t])}function au(n,e){var t=e;function r(c){return c=c||0,n.charAt(t+c)}function i(c){c=c||1,t+=c}function s(){for(var c=0;t<n.length;){var d=r();if(d!==" "&&d!==`
11
+ `&&d!==" "&&d!=="\r")return c;c++,i()}return-1}function o(){return n.substring(t)}function a(c){return n.substring(t,t+c.length)===c}function l(c){return n.substring(t,t+c.length).toUpperCase()===c.toUpperCase()}function u(c){var d=M.reg("^",c),f=d.exec(o());return f?(i(f[0].length),f[0]):null}return{char:r,getIndex:function(){return t},getMatch:u,getSource:function(){return n},skip:i,skipBlanks:s,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function Op(n,e){function t(a,l){var u=M.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 r=n.getSource();if(n.char()==="["){n.skip(1);for(var i=n.getIndex();n.getIndex()<r.length;){if(n.skipBlanks(),n.char()==="]"){var s=r.substring(i,n.getIndex());return n.skip(1),s}var o=null;if(n.char()==="<"&&n.char(1)==="!")switch(n.char(2)){case"E":n.char(3)==="L"?o=n.getMatch(M.elementdecl):n.char(3)==="N"&&(o=n.getMatch(M.EntityDecl));break;case"A":o=n.getMatch(M.AttlistDecl);break;case"N":o=n.getMatch(M.NotationDecl);break;case"-":o=n.getMatch(M.Comment);break}else if(n.char()==="<"&&n.char(1)==="?")o=t(n,e);else if(n.char()==="%")o=n.getMatch(M.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!o)return e.fatalError("Error in internal subset at position "+n.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function lu(n,e,t,r,i){var s=au(n,e);switch(i?s.char(2).toUpperCase():s.char(2)){case"-":var o=s.getMatch(M.Comment);return o?(t.comment(o,M.COMMENT_START.length,o.length-M.COMMENT_START.length-M.COMMENT_END.length),s.getIndex()):r.fatalError("comment is not well-formed at position "+s.getIndex());case"[":var a=s.getMatch(M.CDSect);return a?!i&&!t.currentElement?r.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(a,M.CDATA_START.length,a.length-M.CDATA_START.length-M.CDATA_END.length),t.endCDATA(),s.getIndex()):r.fatalError("Invalid CDATA starting at position "+e);case"D":{if(t.doc&&t.doc.documentElement)return r.fatalError("Doctype not allowed inside or after documentElement at position "+s.getIndex());if(i?!s.substringStartsWithCaseInsensitive(M.DOCTYPE_DECL_START):!s.substringStartsWith(M.DOCTYPE_DECL_START))return r.fatalError("Expected "+M.DOCTYPE_DECL_START+" at position "+s.getIndex());if(s.skip(M.DOCTYPE_DECL_START.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+M.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(M.Name),!l.name)return r.fatalError("doctype name missing or contains unexpected characters at position "+s.getIndex());if(i&&l.name.toLowerCase()!=="html"&&r.warning("Unexpected DOCTYPE in HTML document at position "+s.getIndex()),s.skipBlanks(),s.substringStartsWith(M.PUBLIC)||s.substringStartsWith(M.SYSTEM)){var u=M.ExternalID_match.exec(s.substringFromIndex());if(!u)return r.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(M.SYSTEM)){if(s.skip(M.SYSTEM.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+M.SYSTEM+" at position "+s.getIndex());if(l.systemId=s.getMatch(M.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return r.fatalError("Expected "+M.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+M.SYSTEM+" at position "+s.getIndex())}return i&&l.systemId&&!M.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&r.warning("Unexpected doctype.systemId in HTML document at position "+s.getIndex()),i||(s.skipBlanks(),l.internalSubset=Op(s,r)),s.skipBlanks(),s.char()!==">"?r.fatalError("doctype not terminated with > at position "+s.getIndex()):(s.skip(1),t.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),t.endDTD(),s.getIndex())}default:return r.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function Bp(n,e,t,r){var i=n.substring(e).match(M.PI);if(!i)return r.fatalError("Invalid processing instruction starting at position "+e);if(i[1].toLowerCase()==="xml"){if(e>0)return r.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!M.XMLDecl.test(n.substring(e)))return r.fatalError("xml declaration is not well-formed")}return t.processingInstruction(i[1],i[2]),e+i[0].length}function uu(){this.attributeNames=Object.create(null)}uu.prototype={setTagName:function(n){if(!M.QName_exact.test(n))throw new Error("invalid tagName:"+n);this.tagName=n},addValue:function(n,e,t){if(!M.QName_exact.test(n))throw new Error("invalid attribute:"+n);this.attributeNames[n]=this.length,this[this.length++]={qName:n,value:e,offset:t}},length:0,getLocalName:function(n){return this[n].localName},getLocator:function(n){return this[n].locator},getQName:function(n){return this[n].qName},getURI:function(n){return this[n].uri},getValue:function(n){return this[n].value}};Yi.XMLReader=ou;Yi.parseUtils=au;Yi.parseDoctypeCommentOrCData=lu});var bu=dt(Br=>{"use strict";var Wt=zt(),Rp=Oo(),$p=_n(),du=tu(),Mp=cu(),Lp=Rp.DOMImplementation,Pp=Wt.hasDefaultHTMLNamespace,jp=Wt.isHTMLMimeType,Fp=Wt.isValidMimeType,pu=Wt.MIME_TYPE,Ro=Wt.NAMESPACE,fu=$p.ParseError,qp=Mp.XMLReader;function mu(n){return n.replace(/\r[\n\u0085]/g,`
12
12
  `).replace(/[\r\u0085\u2028\u2029]/g,`
13
- `)}function nu(n){if(n=n||{},n.locator===void 0&&(n.locator=!0),this.assign=n.assign||Vt.assign,this.domHandler=n.domHandler||Vi,this.onError=n.onError||n.errorHandler,n.errorHandler&&typeof n.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");n.errorHandler&&n.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=n.normalizeLineEndings||ru,this.locator=!!n.locator,this.xmlns=this.assign(Object.create(null),n.xmlns)}nu.prototype.parseFromString=function(n,e){if(!Ep(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),r=Kl.XML_ENTITIES,i=t[""]||null;yp(e)?(r=Kl.HTML_ENTITIES,i=xo.HTML):e===tu.XML_SVG_IMAGE&&(i=xo.SVG),t[""]=i,t.xml=t.xml||xo.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 kp;a.errorHandler=s,a.domBuilder=s;var l=!Vt.isHTMLMimeType(e);return l&&typeof n!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(n)),t,r),s.doc.documentElement||a.errorHandler.fatalError("missing root element"),s.doc};function Vi(n){var e=n||{};this.mimeType=e.mimeType||tu.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 Cr(n,e){e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber}Vi.prototype={startDocument:function(){var n=new wp;this.doc=vp(this.mimeType)?n.createHTMLDocument(!1):n.createDocument(this.defaultNamespace,"")},startElement:function(n,e,t,r){var i=this.doc,s=i.createElementNS(n,t||e),o=r.length;qi(this,s),this.currentElement=s,this.locator&&Cr(this.locator,s);for(var a=0;a<o;a++){var n=r.getURI(a),l=r.getValue(a),t=r.getQName(a),u=i.createAttributeNS(n,t);this.locator&&Cr(r.getLocator(a),u),u.value=u.nodeValue=l,s.setAttributeNode(u)}},endElement:function(n,e,t){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(n,e){},endPrefixMapping:function(n){},processingInstruction:function(n,e){var t=this.doc.createProcessingInstruction(n,e);this.locator&&Cr(this.locator,t),qi(this,t)},ignorableWhitespace:function(n,e,t){},characters:function(n,e,t){if(n=eu.apply(this,arguments),n){if(this.cdata)var r=this.doc.createCDATASection(n);else var r=this.doc.createTextNode(n);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(n)&&this.doc.appendChild(r),this.locator&&Cr(this.locator,r)}},skippedEntity:function(n){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(n){n&&(n.lineNumber=0),this.locator=n},comment:function(n,e,t){n=eu.apply(this,arguments);var r=this.doc.createComment(n);this.locator&&Cr(this.locator,r),qi(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(n,e,t,r){var i=this.doc.implementation;if(i&&i.createDocumentType){var s=i.createDocumentType(n,e,t,r);this.locator&&Cr(this.locator,s),qi(this,s),this.doc.doctype=s}},reportError:function(n,e){if(typeof this.onError=="function")try{this.onError(n,e,this)}catch(t){throw new Ql("Reporting "+n+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+n+"] "+e,xp(this.locator))},warning:function(n){this.reportError("warning",n)},error:function(n){this.reportError("error",n)},fatalError:function(n,e){throw this.reportError("fatalError",n),new Ql(n,this.locator,e)}};function xp(n){if(n)return`
14
- @#[line:`+n.lineNumber+",col:"+n.columnNumber+"]"}function eu(n,e,t){return typeof n=="string"?n.substr(e,t):n.length>=e+t||e?new java.lang.String(n,e,t)+"":n}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(n){Vi.prototype[n]=function(){return null}});function qi(n,e){n.currentElement?n.currentElement.appendChild(e):n.doc.appendChild(e)}function Ap(n){if(n==="error")throw"onErrorStopParsing"}function Tp(){throw"onWarningStopParsing"}Nr.__DOMHandler=Vi;Nr.DOMParser=nu;Nr.normalizeLineEndings=ru;Nr.onErrorStopParsing=Ap;Nr.onWarningStopParsing=Tp});var Ao=lt(F=>{"use strict";var Ir=Ut();F.assign=Ir.assign;F.hasDefaultHTMLNamespace=Ir.hasDefaultHTMLNamespace;F.isHTMLMimeType=Ir.isHTMLMimeType;F.isValidMimeType=Ir.isValidMimeType;F.MIME_TYPE=Ir.MIME_TYPE;F.NAMESPACE=Ir.NAMESPACE;var zi=fn();F.DOMException=zi.DOMException;F.DOMExceptionName=zi.DOMExceptionName;F.ExceptionCode=zi.ExceptionCode;F.ParseError=zi.ParseError;var ae=Eo();F.Attr=ae.Attr;F.CDATASection=ae.CDATASection;F.CharacterData=ae.CharacterData;F.Comment=ae.Comment;F.Document=ae.Document;F.DocumentFragment=ae.DocumentFragment;F.DocumentType=ae.DocumentType;F.DOMImplementation=ae.DOMImplementation;F.Element=ae.Element;F.Entity=ae.Entity;F.EntityReference=ae.EntityReference;F.LiveNodeList=ae.LiveNodeList;F.NamedNodeMap=ae.NamedNodeMap;F.Node=ae.Node;F.NodeList=ae.NodeList;F.Notation=ae.Notation;F.ProcessingInstruction=ae.ProcessingInstruction;F.Text=ae.Text;F.XMLSerializer=ae.XMLSerializer;var Hi=iu();F.DOMParser=Hi.DOMParser;F.normalizeLineEndings=Hi.normalizeLineEndings;F.onErrorStopParsing=Hi.onErrorStopParsing;F.onWarningStopParsing=Hi.onWarningStopParsing});var Yr=class{#e=new Map;registerGroup(e,t={}){if(typeof e!="string"||!e||e.includes(":"))throw new TypeError("Extension command namespace must be nonempty and unqualified");if(this.#e.has(e))throw new Error(`Duplicate command namespace: ${e}`);if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(i=>!["author","description"].includes(i))||Object.values(t).some(i=>typeof i!="string"))throw new TypeError(`Invalid command group metadata: ${e}`);let r=new Map;return this.#e.set(e,{metadata:{...t},commands:r}),Object.freeze({register(i,s){if(typeof i!="string"||!i||i.includes(":"))throw new TypeError("Invalid command name");if(r.has(i))throw new Error(`Duplicate command: ${e}:${i}`);if(!s||typeof s!="object"||Array.isArray(s)||!Object.hasOwn(s,"label")||!Object.hasOwn(s,"publish")||Object.keys(s).some(o=>!["label","publish","icon","iconSrc","tooltip"].includes(o))||Object.values(s).some(o=>typeof o!="string"))throw new TypeError(`Invalid command definition: ${e}:${i}`);r.set(i,Object.freeze({...s}))}})}get(e){let t=e.indexOf(":");return this.#e.get(e.slice(0,t))?.commands.get(e.slice(t+1))}toDocument(){return{document_format:{name:"gramlot_commands",version:"1.0"},groups:Object.fromEntries([...this.#e].map(([e,{metadata:t,commands:r}])=>[e,{...t,commands:Object.fromEntries(r)}]))}}};var Zr=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:r="/gramlot/close",navigator:i=globalThis.navigator,XMLHttpRequest:s=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=r,this.navigator=i,this.XMLHttpRequest=s}get supportsCallSync(){return!0}async call(e,t){let r=await this.fetcher(this.rpcUrl,{method:"POST",credentials:"same-origin",signal:t,headers:{"Content-Type":"application/json"},body:e});if(r.status!==200)throw new Error(`rpc failed: HTTP ${r.status}`);return r.text()}callSync(e){let t=new this.XMLHttpRequest;if(t.open("POST",this.rpcUrl,!1),t.setRequestHeader("Content-Type","application/json"),t.send(e),t.status!==200)throw new Error(`rpc failed: HTTP ${t.status}`);return t.responseText}close(e,{beacon:t=!1}={}){let r=JSON.stringify({pageId:e});t?this.navigator.sendBeacon(this.closeUrl,new Blob([r],{type:"application/json"})):this.fetcher(this.closeUrl,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/json"},body:r})}dispose(){}};var ut=class{createTransport({rpcUrl:e,closeUrl:t,document:r}){let i=r.defaultView;return new Zr(e,{closeUrl:t,navigator:i.navigator,XMLHttpRequest:i.XMLHttpRequest})}};function z(n){if(typeof n!="string"||!["^","="].includes(n[0])||n.startsWith("=="))return null;let e=n.indexOf(":");if(e<0)return null;let t=n[e+1]==="=";return{pointer:n.slice(0,e),expression:t,body:n.slice(e+(t?2:1))}}var va=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function $t(n,e){let t="",r=!1;for(let i=0;i<n.length;){if(n[i]!=="{"&&n[i]!=="}"){t+=n[i++];continue}let s=n.slice(i).match(va);if(!s)throw new SyntaxError("Invalid pointer template placeholder");let o=s[1]??"",a=o.startsWith("?"),l=e(a?o.slice(1):o);l==null||l===""&&!a?r=!0:t+=String(l),i+=s[0].length}return r?null:t}function Jr(n){let e=[],t=new Set,r="",i=!0;for(let s=0;s<n.length;){let o=s,a=n[s];if(a==='"'||a==="'"||a==="`"){for(s++;s<n.length;){if(n[s]==="\\"){s+=2;continue}if(n[s++]===a)break}r+=n.slice(o,s),i=!1;continue}if(n.startsWith("//",s)){s=n.indexOf(`
15
- `,s),s<0&&(s=n.length),r+=n.slice(o,s);continue}if(n.startsWith("/*",s)){let c=n.indexOf("*/",s+2);s=c<0?n.length:c+2,r+=n.slice(o,s);continue}if(a==="/"&&i){let c=!1;for(s++;s<n.length;){let d=n[s++];if(d==="\\"){s++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(n[s]??"")&&s<n.length;)s++;r+=n.slice(o,s),i=!1;continue}let l=a==="{"?n.slice(s).match(va):null;if(l){let c=l[1]??"";if(c.startsWith("?"))throw new SyntaxError("Optional slots are supported in pointer templates only");r+=`_pointerValues[${e.length}]`,e.push(c),s+=l[0].length,i=!1;continue}let u=n.slice(s).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),r+=u[0],s+=u[0].length,i=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}r+=a,s++,/\s/.test(a)||(i=/[([{,:;=!?&|+*%~<>\/-]/.test(a))}return{text:r,slots:e,identifiers:t}}function Ea(n,e,t=()=>null){let r=new Map,i=[],s=o=>{if(r.has(o))return r.get(o);if(!n.has(o))throw new Error(`Referenced Source attribute '${o}' does not exist`);if(i.includes(o))throw new Error(`Cyclic attribute dependency: ${[...i,o].join(" -> ")}`);i.push(o);try{let a=n.get(o),l=typeof o=="string"?z(a):null,u=e.get(o);if(l){let c=d=>d?s(d):e.get(o);if(l.expression){let d=Jr(l.body);u=t(o,a,d,d.slots.map(c))}else u=$t(l.body,c),e.get(o)==null&&(u=null)}return r.set(o,u),u}finally{i.pop()}};return new Map([...n.keys()].map(o=>[o,s(o)]))}function ze(n,e){let t=new Map([...Object.entries(n.getAttr()),...n.fixedAttrItems()]),r=new Set,i=[],s=o=>{let a=z(o);if(!a)return;let l=[];a.expression?l.push(...Jr(a.body).slots):$t(a.body,u=>(l.push(u),""));for(let u of l.filter(Boolean)){if(!t.has(u))throw new Error(`Referenced Source attribute '${u}' does not exist`);if(i.includes(u))throw new Error(`Cyclic attribute dependency: ${[...i,u].join(" -> ")}`);r.has(u)||(i.push(u),s(t.get(u)),i.pop(),r.add(u))}};return s(e),r}var dr=9e15,ht=1e9,Us="0123456789abcdef",mi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",gi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",qs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-dr,maxE:dr,crypto:!1},Ta,tt,O=!0,_i="[DecimalError] ",ft=_i+"Invalid argument: ",Da=_i+"Precision limit exceeded",Sa=_i+"crypto unavailable",Ca="[object Decimal]",pe=Math.floor,se=Math.pow,od=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ad=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ld=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Na=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Me=1e7,N=7,ud=9007199254740991,cd=mi.length-1,Vs=gi.length-1,y={toStringTag:Ca};y.absoluteValue=y.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),S(n)};y.ceil=function(){return S(new this.constructor(this),this.e+1,2)};y.clampedTo=y.clamp=function(n,e){var t,r=this,i=r.constructor;if(n=new i(n),e=new i(e),!n.s||!e.s)return new i(NaN);if(n.gt(e))throw Error(ft+e);return t=r.cmp(n),t<0?n:r.cmp(e)>0?e:new i(r)};y.comparedTo=y.cmp=function(n){var e,t,r,i,s=this,o=s.d,a=(n=new s.constructor(n)).d,l=s.s,u=n.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!==n.e)return s.e>n.e^l<0?1:-1;for(r=o.length,i=a.length,e=0,t=r<i?r:i;e<t;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return r===i?0:r>i^l<0?1:-1};y.cosine=y.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+N,r.rounding=1,t=dd(r,$a(r,t)),r.precision=n,r.rounding=e,S(tt==2||tt==3?t.neg():t,n,e,!0)):new r(1):new r(NaN)};y.cubeRoot=y.cbrt=function(){var n,e,t,r,i,s,o,a,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(O=!1,s=c.s*se(c.s*c,1/3),!s||Math.abs(s)==1/0?(t=ue(c.d),n=c.e,(s=(n-t.length+1)%3)&&(t+=s==1||s==-2?"0":"00"),s=se(t,1/3),n=pe((n+1)/3)-(n%3==(n<0?-1:2)),s==1/0?t="5e"+n:(t=s.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new d(t),r.s=c.s):r=new d(s.toString()),o=(n=d.precision)+3;;)if(a=r,l=a.times(a).times(a),u=l.plus(c),r=X(u.plus(c).times(a),u.plus(l),o+2,1),ue(a.d).slice(0,o)===(t=ue(r.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(S(a,n+1,0),a.times(a).times(a).eq(c))){r=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(S(r,n+1,1),e=!r.times(r).times(r).eq(c));break}return O=!0,S(r,n,d.rounding,e)};y.decimalPlaces=y.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-pe(this.e/N))*N,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};y.dividedBy=y.div=function(n){return X(this,new this.constructor(n))};y.dividedToIntegerBy=y.divToInt=function(n){var e=this,t=e.constructor;return S(X(e,new t(n),0,1,1),t.precision,t.rounding)};y.equals=y.eq=function(n){return this.cmp(n)===0};y.floor=function(){return S(new this.constructor(this),this.e+1,3)};y.greaterThan=y.gt=function(n){return this.cmp(n)>0};y.greaterThanOrEqualTo=y.gte=function(n){var e=this.cmp(n);return e==1||e===0};y.hyperbolicCosine=y.cosh=function(){var n,e,t,r,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;t=o.precision,r=o.rounding,o.precision=t+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(n=Math.ceil(i/3),e=(1/yi(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),s=fr(o,1,s.times(e),new o(1),!0);for(var l,u=n,c=new o(8);u--;)l=s.times(s),s=a.minus(l.times(c.minus(l.times(c))));return S(s,o.precision=t,o.rounding=r,!0)};y.hyperbolicSine=y.sinh=function(){var n,e,t,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(e=s.precision,t=s.rounding,s.precision=e+Math.max(i.e,i.sd())+4,s.rounding=1,r=i.d.length,r<3)i=fr(s,2,i,i,!0);else{n=1.4*Math.sqrt(r),n=n>16?16:n|0,i=i.times(1/yi(5,n)),i=fr(s,2,i,i,!0);for(var o,a=new s(5),l=new s(16),u=new s(20);n--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(u))))}return s.precision=e,s.rounding=t,S(i,e,t,!0)};y.hyperbolicTangent=y.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,X(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)};y.inverseCosine=y.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,i=e.rounding;return t!==-1?t===0?n.isNeg()?He(e,r,i):new e(0):new e(NaN):n.isZero()?He(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=r,e.rounding=i,n.times(2))};y.inverseHyperbolicCosine=y.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,O=!1,t=t.times(t).minus(1).sqrt().plus(t),O=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)};y.inverseHyperbolicSine=y.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,O=!1,t=t.times(t).plus(1).sqrt().plus(t),O=!0,r.precision=n,r.rounding=e,t.ln())};y.inverseHyperbolicTangent=y.atanh=function(){var n,e,t,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(n=s.precision,e=s.rounding,r=i.sd(),Math.max(r,n)<2*-i.e-1?S(new s(i),n,e,!0):(s.precision=t=r-i.e,i=X(i.plus(1),new s(1).minus(i),t+n,1),s.precision=n+4,s.rounding=1,i=i.ln(),s.precision=n,s.rounding=e,i.times(.5))):new s(NaN)};y.inverseSine=y.asin=function(){var n,e,t,r,i=this,s=i.constructor;return i.isZero()?new s(i):(e=i.abs().cmp(1),t=s.precision,r=s.rounding,e!==-1?e===0?(n=He(s,t+4,r).times(.5),n.s=i.s,n):new s(NaN):(s.precision=t+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=r,i.times(2)))};y.inverseTangent=y.atan=function(){var n,e,t,r,i,s,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&d+4<=Vs)return o=He(c,d+4,f).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(d+4<=Vs)return o=He(c,d+4,f).times(.5),o.s=u.s,o}for(c.precision=a=d+10,c.rounding=1,t=Math.min(28,a/N+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(O=!1,e=Math.ceil(a/N),r=1,l=u.times(u),o=new c(u),i=u;n!==-1;)if(i=i.times(l),s=o.minus(i.div(r+=2)),i=i.times(l),o=s.plus(i.div(r+=2)),o.d[e]!==void 0)for(n=e;o.d[n]===s.d[n]&&n--;);return t&&(o=o.times(2<<t-1)),O=!0,S(o,c.precision=d,c.rounding=f,!0)};y.isFinite=function(){return!!this.d};y.isInteger=y.isInt=function(){return!!this.d&&pe(this.e/N)>this.d.length-2};y.isNaN=function(){return!this.s};y.isNegative=y.isNeg=function(){return this.s<0};y.isPositive=y.isPos=function(){return this.s>0};y.isZero=function(){return!!this.d&&this.d[0]===0};y.lessThan=y.lt=function(n){return this.cmp(n)<0};y.lessThanOrEqualTo=y.lte=function(n){return this.cmp(n)<1};y.logarithm=y.log=function(n){var e,t,r,i,s,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding,h=5;if(n==null)n=new c(10),e=!0;else{if(n=new c(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new c(NaN);e=n.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new c(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)s=!0;else{for(i=t[0];i%10===0;)i/=10;s=i!==1}if(O=!1,a=d+h,o=dt(u,a),r=e?bi(c,a+10):dt(n,a),l=X(o,r,a,1),Kr(l.d,i=d,f))do if(a+=10,o=dt(u,a),r=e?bi(c,a+10):dt(n,a),l=X(o,r,a,1),!s){+ue(l.d).slice(i+1,i+15)+1==1e14&&(l=S(l,d+1,0));break}while(Kr(l.d,i+=10,f));return O=!0,S(l,d,f)};y.minus=y.sub=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,p=h.constructor;if(n=new p(n),!h.d||!n.d)return!h.s||!n.s?n=new p(NaN):h.d?n.s=-n.s:n=new p(n.d||h.s!==n.s?h:NaN),n;if(h.s!=n.s)return n.s=-n.s,h.plus(n);if(u=h.d,f=n.d,a=p.precision,l=p.rounding,!u[0]||!f[0]){if(f[0])n.s=-n.s;else if(u[0])n=new p(h);else return new p(l===3?-0:0);return O?S(n,a,l):n}if(t=pe(n.e/N),c=pe(h.e/N),u=u.slice(),s=c-t,s){for(d=s<0,d?(e=u,s=-s,o=f.length):(e=f,t=c,o=u.length),r=Math.max(Math.ceil(a/N),o)+2,s>r&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse()}else{for(r=u.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(u[r]!=f[r]){d=u[r]<f[r];break}s=0}for(d&&(e=u,u=f,f=e,n.s=-n.s),o=u.length,r=f.length-o;r>0;--r)u[o++]=0;for(r=f.length;r>s;){if(u[--r]<f[r]){for(i=r;i&&u[--i]===0;)u[i]=Me-1;--u[i],u[r]+=Me}u[r]-=f[r]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=wi(u,t),O?S(n,a,l):n):new p(l===3?-0:0)};y.modulo=y.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?S(new r(t),r.precision,r.rounding):(O=!1,r.modulo==9?(e=X(t,n.abs(),0,3,1),e.s*=n.s):e=X(t,n,0,r.modulo,1),e=e.times(n),O=!0,t.minus(e))};y.naturalExponential=y.exp=function(){return zs(this)};y.naturalLogarithm=y.ln=function(){return dt(this)};y.negated=y.neg=function(){var n=new this.constructor(this);return n.s=-n.s,S(n)};y.plus=y.add=function(n){var e,t,r,i,s,o,a,l,u,c,d=this,f=d.constructor;if(n=new f(n),!d.d||!n.d)return!d.s||!n.s?n=new f(NaN):d.d||(n=new f(n.d||d.s===n.s?d:NaN)),n;if(d.s!=n.s)return n.s=-n.s,d.minus(n);if(u=d.d,c=n.d,a=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(n=new f(d)),O?S(n,a,l):n;if(s=pe(d.e/N),r=pe(n.e/N),u=u.slice(),i=s-r,i){for(i<0?(t=u,i=-i,o=c.length):(t=c,r=s,o=u.length),s=Math.ceil(a/N),o=s>o?s+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=u.length,i=c.length,o-i<0&&(i=o,t=c,c=u,u=t),e=0;i;)e=(u[--i]=u[i]+c[i]+e)/Me|0,u[i]%=Me;for(e&&(u.unshift(e),++r),o=u.length;u[--o]==0;)u.pop();return n.d=u,n.e=wi(u,r),O?S(n,a,l):n};y.precision=y.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(ft+n);return t.d?(e=Ia(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};y.round=function(){var n=this,e=n.constructor;return S(new e(n),n.e+1,e.rounding)};y.sine=y.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+N,r.rounding=1,t=hd(r,$a(r,t)),r.precision=n,r.rounding=e,S(tt>2?t.neg():t,n,e,!0)):new r(NaN)};y.squareRoot=y.sqrt=function(){var n,e,t,r,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(O=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=ue(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=pe((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),r=new c(e)):r=new c(u.toString()),t=(l=c.precision)+3;;)if(s=r,r=s.plus(X(o,s,t+2,1)).times(.5),ue(s.d).slice(0,t)===(e=ue(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(S(s,l+1,0),s.times(s).eq(o))){r=s;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(S(r,l+1,1),n=!r.times(r).eq(o));break}return O=!0,S(r,l,c.rounding,n)};y.tangent=y.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,t=t.sin(),t.s=1,t=X(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,S(tt==2||tt==4?t.neg():t,n,e,!0)):new r(NaN)};y.times=y.mul=function(n){var e,t,r,i,s,o,a,l,u,c=this,d=c.constructor,f=c.d,h=(n=new d(n)).d;if(n.s*=c.s,!f||!f[0]||!h||!h[0])return new d(!n.s||f&&!f[0]&&!h||h&&!h[0]&&!f?NaN:!f||!h?n.s/0:n.s*0);for(t=pe(c.e/N)+pe(n.e/N),l=f.length,u=h.length,l<u&&(s=f,f=h,h=s,o=l,l=u,u=o),s=[],o=l+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=l+r;i>r;)a=s[i]+h[r]*f[i-r-1]+e,s[i--]=a%Me|0,e=a/Me|0;s[i]=(s[i]+e)%Me|0}for(;!s[--o];)s.pop();return e?++t:s.shift(),n.d=s,n.e=wi(s,t),O?S(n,d.precision,d.rounding):n};y.toBinary=function(n,e){return Hs(this,2,n,e)};y.toDecimalPlaces=y.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),n===void 0?t:(Ee(n,0,ht),e===void 0?e=r.rounding:Ee(e,0,8),S(t,n+t.e+1,e))};y.toExponential=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=We(r,!0):(Ee(n,0,ht),e===void 0?e=i.rounding:Ee(e,0,8),r=S(new i(r),n+1,e),t=We(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t};y.toFixed=function(n,e){var t,r,i=this,s=i.constructor;return n===void 0?t=We(i):(Ee(n,0,ht),e===void 0?e=s.rounding:Ee(e,0,8),r=S(new s(i),n+i.e+1,e),t=We(r,!1,n+r.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};y.toFraction=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,p=h.d,m=h.constructor;if(!p)return new m(h);if(u=t=new m(1),r=l=new m(0),e=new m(r),s=e.e=Ia(p)-h.e-1,o=s%N,e.d[0]=se(10,o<0?N+o:o),n==null)n=s>0?e:u;else{if(a=new m(n),!a.isInt()||a.lt(u))throw Error(ft+a);n=a.gt(e)?s>0?e:u:a}for(O=!1,a=new m(ue(p)),c=m.precision,m.precision=s=p.length*N*2;d=X(a,e,0,1,1),i=t.plus(d.times(r)),i.cmp(n)!=1;)t=r,r=i,i=u,u=l.plus(d.times(i)),l=i,i=e,e=a.minus(d.times(i)),a=i;return i=X(n.minus(t),r,0,1,1),l=l.plus(i.times(u)),t=t.plus(i.times(r)),l.s=u.s=h.s,f=X(u,r,s,1).minus(h).abs().cmp(X(l,t,s,1).minus(h).abs())<1?[u,r]:[l,t],m.precision=c,O=!0,f};y.toHexadecimal=y.toHex=function(n,e){return Hs(this,16,n,e)};y.toNearest=function(n,e){var t=this,r=t.constructor;if(t=new r(t),n==null){if(!t.d)return t;n=new r(1),e=r.rounding}else{if(n=new r(n),e===void 0?e=r.rounding:Ee(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(O=!1,t=X(t,n,0,e,1).times(n),O=!0,S(t)):(n.s=t.s,t=n),t};y.toNumber=function(){return+this};y.toOctal=function(n,e){return Hs(this,8,n,e)};y.toPower=y.pow=function(n){var e,t,r,i,s,o,a=this,l=a.constructor,u=+(n=new l(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new l(se(+a,u));if(a=new l(a),a.eq(1))return a;if(r=l.precision,s=l.rounding,n.eq(1))return S(a,r,s);if(e=pe(n.e/N),e>=n.d.length-1&&(t=u<0?-u:u)<=ud)return i=Oa(l,a,t,r),n.s<0?new l(1).div(i):S(i,r,s);if(o=a.s,o<0){if(e<n.d.length-1)return new l(NaN);if((n.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=se(+a,u),e=t==0||!isFinite(t)?pe(u*(Math.log("0."+ue(a.d))/Math.LN10+a.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(O=!1,l.rounding=a.s=1,t=Math.min(12,(e+"").length),i=zs(n.times(dt(a,r+t)),r),i.d&&(i=S(i,r+5,1),Kr(i.d,r,s)&&(e=r+10,i=S(zs(n.times(dt(a,e+t)),e),e+5,1),+ue(i.d).slice(r+1,r+15)+1==1e14&&(i=S(i,r+1,0)))),i.s=o,O=!0,l.rounding=s,S(i,r,s))};y.toPrecision=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=We(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Ee(n,1,ht),e===void 0?e=i.rounding:Ee(e,0,8),r=S(new i(r),n,e),t=We(r,n<=r.e||r.e<=i.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t};y.toSignificantDigits=y.toSD=function(n,e){var t=this,r=t.constructor;return n===void 0?(n=r.precision,e=r.rounding):(Ee(n,1,ht),e===void 0?e=r.rounding:Ee(e,0,8)),S(new r(t),n,e)};y.toString=function(){var n=this,e=n.constructor,t=We(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};y.truncated=y.trunc=function(){return S(new this.constructor(this),this.e+1,1)};y.valueOf=y.toJSON=function(){var n=this,e=n.constructor,t=We(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function ue(n){var e,t,r,i=n.length-1,s="",o=n[0];if(i>0){for(s+=o,e=1;e<i;e++)r=n[e]+"",t=N-r.length,t&&(s+=ct(t)),s+=r;o=n[e],r=o+"",t=N-r.length,t&&(s+=ct(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function Ee(n,e,t){if(n!==~~n||n<e||n>t)throw Error(ft+n)}function Kr(n,e,t,r){var i,s,o,a;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=N,i=0):(i=Math.ceil((e+1)/N),e%=N),s=se(10,N-e),a=n[i]%s|0,r==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==s||t>3&&a+1==s/2)&&(n[i+1]/s/100|0)==se(10,e-2)-1||(a==s/2||a==0)&&(n[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=(r||t<4)&&a==9999||!r&&t>3&&a==4999):o=((r||t<4)&&a+1==s||!r&&t>3&&a+1==s/2)&&(n[i+1]/s/1e3|0)==se(10,e-3)-1,o}function hi(n,e,t){for(var r,i=[0],s,o=0,a=n.length;o<a;){for(s=i.length;s--;)i[s]*=e;for(i[0]+=Us.indexOf(n.charAt(o++)),r=0;r<i.length;r++)i[r]>t-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/t|0,i[r]%=t)}return i.reverse()}function dd(n,e){var t,r,i;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),i=(1/yi(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),n.precision+=t,e=fr(n,1,e.times(i),new n(1));for(var s=t;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}var X=(function(){function n(r,i,s){var o,a=0,l=r.length;for(r=r.slice();l--;)o=r[l]*i+a,r[l]=o%s|0,a=o/s|0;return a&&r.unshift(a),r}function e(r,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(r[a]!=i[a]){l=r[a]>i[a]?1:-1;break}return l}function t(r,i,s,o){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*o+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o,a,l){var u,c,d,f,h,p,m,b,g,_,w,v,k,E,C,L,q,ve,Z,ne,Ne=r.constructor,G=r.s==i.s?1:-1,ie=r.d,$=i.d;if(!ie||!ie[0]||!$||!$[0])return new Ne(!r.s||!i.s||(ie?$&&ie[0]==$[0]:!$)?NaN:ie&&ie[0]==0||!$?G*0:G/0);for(l?(h=1,c=r.e-i.e):(l=Me,h=N,c=pe(r.e/h)-pe(i.e/h)),Z=$.length,q=ie.length,g=new Ne(G),_=g.d=[],d=0;$[d]==(ie[d]||0);d++);if($[d]>(ie[d]||0)&&c--,s==null?(E=s=Ne.precision,o=Ne.rounding):a?E=s+(r.e-i.e)+1:E=s,E<0)_.push(1),p=!0;else{if(E=E/h+2|0,d=0,Z==1){for(f=0,$=$[0],E++;(d<q||f)&&E--;d++)C=f*l+(ie[d]||0),_[d]=C/$|0,f=C%$|0;p=f||d<q}else{for(f=l/($[0]+1)|0,f>1&&($=n($,f,l),ie=n(ie,f,l),Z=$.length,q=ie.length),L=Z,w=ie.slice(0,Z),v=w.length;v<Z;)w[v++]=0;ne=$.slice(),ne.unshift(0),ve=$[0],$[1]>=l/2&&++ve;do f=0,u=e($,w,Z,v),u<0?(k=w[0],Z!=v&&(k=k*l+(w[1]||0)),f=k/ve|0,f>1?(f>=l&&(f=l-1),m=n($,f,l),b=m.length,v=w.length,u=e(m,w,b,v),u==1&&(f--,t(m,Z<b?ne:$,b,l))):(f==0&&(u=f=1),m=$.slice()),b=m.length,b<v&&m.unshift(0),t(w,m,v,l),u==-1&&(v=w.length,u=e($,w,Z,v),u<1&&(f++,t(w,Z<v?ne:$,v,l))),v=w.length):u===0&&(f++,w=[0]),_[d++]=f,u&&w[0]?w[v++]=ie[L]||0:(w=[ie[L]],v=1);while((L++<q||w[0]!==void 0)&&E--);p=w[0]!==void 0}_[0]||_.shift()}if(h==1)g.e=c,Ta=p;else{for(d=1,f=_[0];f>=10;f/=10)d++;g.e=d+c*h-1,S(g,a?s+g.e+1:s,o,p)}return g}})();function S(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor;e:if(e!=null){if(d=n.d,!d)return n;for(i=1,a=d[0];a>=10;a/=10)i++;if(s=e-i,s<0)s+=N,o=e,c=d[f=0],l=c/se(10,i-o-1)%10|0;else if(f=Math.ceil((s+1)/N),a=d.length,f>=a)if(r){for(;a++<=f;)d.push(0);c=l=0,i=1,s%=N,o=s-N+1}else break e;else{for(c=a=d[f],i=1;a>=10;a/=10)i++;s%=N,o=s-N+i,l=o<0?0:c/se(10,i-o-1)%10|0}if(r=r||e<0||d[f+1]!==void 0||(o<0?c:c%se(10,i-o-1)),u=t<4?(l||r)&&(t==0||t==(n.s<0?3:2)):l>5||l==5&&(t==4||r||t==6&&(s>0?o>0?c/se(10,i-o):0:d[f-1])%10&1||t==(n.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=n.e+1,d[0]=se(10,(N-e%N)%N),n.e=-e||0):d[0]=n.e=0,n;if(s==0?(d.length=f,a=1,f--):(d.length=f+1,a=se(10,N-s),d[f]=o>0?(c/se(10,i-o)%se(10,o)|0)*a:0),u)for(;;)if(f==0){for(s=1,o=d[0];o>=10;o/=10)s++;for(o=d[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(n.e++,d[0]==Me&&(d[0]=1));break}else{if(d[f]+=a,d[f]!=Me)break;d[f--]=0,a=1}for(s=d.length;d[--s]===0;)d.pop()}return O&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function We(n,e,t){if(!n.isFinite())return Ra(n);var r,i=n.e,s=ue(n.d),o=s.length;return e?(t&&(r=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+ct(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):i<0?(s="0."+ct(-i-1)+s,t&&(r=t-o)>0&&(s+=ct(r))):i>=o?(s+=ct(i+1-o),t&&(r=t-i-1)>0&&(s=s+"."+ct(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),t&&(r=t-o)>0&&(i+1===o&&(s+="."),s+=ct(r))),s}function wi(n,e){var t=n[0];for(e*=N;t>=10;t/=10)e++;return e}function bi(n,e,t){if(e>cd)throw O=!0,t&&(n.precision=t),Error(Da);return S(new n(mi),e,1,!0)}function He(n,e,t){if(e>Vs)throw Error(Da);return S(new n(gi),e,t,!0)}function Ia(n){var e=n.length-1,t=e*N+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function ct(n){for(var e="";n--;)e+="0";return e}function Oa(n,e,t,r){var i,s=new n(1),o=Math.ceil(r/N+4);for(O=!1;;){if(t%2&&(s=s.times(e),xa(s.d,o)&&(i=!0)),t=pe(t/2),t===0){t=s.d.length-1,i&&s.d[t]===0&&++s.d[t];break}e=e.times(e),xa(e.d,o)}return O=!0,s}function ka(n){return n.d[n.d.length-1]&1}function Ba(n,e,t){for(var r,i,s=new n(e[0]),o=0;++o<e.length;){if(i=new n(e[o]),!i.s){s=i;break}r=s.cmp(i),(r===t||r===0&&s.s===t)&&(s=i)}return s}function zs(n,e){var t,r,i,s,o,a,l,u=0,c=0,d=0,f=n.constructor,h=f.rounding,p=f.precision;if(!n.d||!n.d[0]||n.e>17)return new f(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(e==null?(O=!1,l=p):l=e,a=new f(.03125);n.e>-2;)n=n.times(a),d+=5;for(r=Math.log(se(2,d))/Math.LN10*2+5|0,l+=r,t=s=o=new f(1),f.precision=l;;){if(s=S(s.times(n),l,1),t=t.times(++c),a=o.plus(X(s,t,l,1)),ue(a.d).slice(0,l)===ue(o.d).slice(0,l)){for(i=d;i--;)o=S(o.times(o),l,1);if(e==null)if(u<3&&Kr(o.d,l-r,h,u))f.precision=l+=10,t=s=a=new f(1),c=0,u++;else return S(o,f.precision=p,h,O=!0);else return f.precision=p,o}o=a}}function dt(n,e){var t,r,i,s,o,a,l,u,c,d,f,h=1,p=10,m=n,b=m.d,g=m.constructor,_=g.rounding,w=g.precision;if(m.s<0||!b||!b[0]||!m.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:m.s!=1?NaN:b?0:m);if(e==null?(O=!1,c=w):c=e,g.precision=c+=p,t=ue(b),r=t.charAt(0),Math.abs(s=m.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)m=m.times(n),t=ue(m.d),r=t.charAt(0),h++;s=m.e,r>1?(m=new g("0."+t),s++):m=new g(r+"."+t.slice(1))}else return u=bi(g,c+2,w).times(s+""),m=dt(new g(r+"."+t.slice(1)),c-p).plus(u),g.precision=w,e==null?S(m,w,_,O=!0):m;for(d=m,l=o=m=X(m.minus(1),m.plus(1),c,1),f=S(m.times(m),c,1),i=3;;){if(o=S(o.times(f),c,1),u=l.plus(X(o,new g(i),c,1)),ue(u.d).slice(0,c)===ue(l.d).slice(0,c))if(l=l.times(2),s!==0&&(l=l.plus(bi(g,c+2,w).times(s+""))),l=X(l,new g(h),c,1),e==null)if(Kr(l.d,c-p,_,a))g.precision=c+=p,u=o=m=X(d.minus(1),d.plus(1),c,1),f=S(m.times(m),c,1),i=a=1;else return S(l,g.precision=w,_,O=!0);else return g.precision=w,l;l=u,i+=2}}function Ra(n){return String(n.s*n.s/0)}function pi(n,e){var t,r,i;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%N,t<0&&(r+=N),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=N;r<i;)n.d.push(+e.slice(r,r+=N));e=e.slice(r),r=N-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),O&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function fd(n,e){var t,r,i,s,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Na.test(e))return pi(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(ad.test(e))t=16,e=e.toLowerCase();else if(od.test(e))t=2;else if(ld.test(e))t=8;else throw Error(ft+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,r=n.constructor,o&&(e=e.replace(".",""),a=e.length,s=a-s,i=Oa(r,new r(t),s,s*2)),u=hi(e,t,Me),c=u.length-1,s=c;u[s]===0;--s)u.pop();return s<0?new r(n.s*0):(n.e=wi(u,c),n.d=u,O=!1,o&&(n=X(n,i,a*4)),l&&(n=n.times(Math.abs(l)<54?se(2,l):Qr.pow(2,l))),O=!0,n)}function hd(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:fr(n,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/yi(5,t)),e=fr(n,2,e,e);for(var i,s=new n(5),o=new n(16),a=new n(20);t--;)i=e.times(e),e=e.times(s.plus(i.times(o.times(i).minus(a))));return e}function fr(n,e,t,r,i){var s,o,a,l,u=1,c=n.precision,d=Math.ceil(c/N);for(O=!1,l=t.times(t),a=new n(r);;){if(o=X(a.times(l),new n(e++*e++),c,1),a=i?r.plus(o):r.minus(o),r=X(o.times(l),new n(e++*e++),c,1),o=a.plus(r),o.d[d]!==void 0){for(s=d;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=r,r=o,o=s,u++}return O=!0,o.d.length=d+1,o}function yi(n,e){for(var t=n;--e;)t*=n;return t}function $a(n,e){var t,r=e.s<0,i=He(n,n.precision,1),s=i.times(.5);if(e=e.abs(),e.lte(s))return tt=r?4:1,e;if(t=e.divToInt(i),t.isZero())tt=r?3:2;else{if(e=e.minus(t.times(i)),e.lte(s))return tt=ka(t)?r?2:3:r?4:1,e;tt=ka(t)?r?1:4:r?3:2}return e.minus(i).abs()}function Hs(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor,p=t!==void 0;if(p?(Ee(t,1,ht),r===void 0?r=h.rounding:Ee(r,0,8)):(t=h.precision,r=h.rounding),!n.isFinite())c=Ra(n);else{for(c=We(n),o=c.indexOf("."),p?(i=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):i=e,o>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-o,f.d=hi(We(f),10,i),f.e=f.d.length),d=hi(c,10,i),s=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=p?"0p+0":"0";else{if(o<0?s--:(n=new h(n),n.d=d,n.e=s,n=X(n,f,t,r,0,i),d=n.d,s=n.e,u=Ta),o=d[t],a=i/2,u=u||d[t+1]!==void 0,u=r<4?(o!==void 0||u)&&(r===0||r===(n.s<0?3:2)):o>a||o===a&&(r===4||u||r===6&&d[t-1]&1||r===(n.s<0?8:7)),d.length=t,u)for(;++d[--t]>i-1;)d[t]=0,t||(++s,d.unshift(1));for(l=d.length;!d[l-1];--l);for(o=0,c="";o<l;o++)c+=Us.charAt(d[o]);if(p){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)c+="0";for(d=hi(c,i,e),l=d.length;!d[l-1];--l);for(o=1,c="1.";o<l;o++)c+=Us.charAt(d[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 n.s<0?"-"+c:c}function xa(n,e){if(n.length>e)return n.length=e,!0}function pd(n){return new this(n).abs()}function md(n){return new this(n).acos()}function gd(n){return new this(n).acosh()}function bd(n,e){return new this(n).plus(e)}function _d(n){return new this(n).asin()}function wd(n){return new this(n).asinh()}function yd(n){return new this(n).atan()}function vd(n){return new this(n).atanh()}function Ed(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,s=r+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=He(this,s,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?He(this,r,i):new this(0),t.s=n.s):!n.d||e.isZero()?(t=He(this,s,1).times(.5),t.s=n.s):e.s<0?(this.precision=s,this.rounding=1,t=this.atan(X(n,e,s,1)),e=He(this,s,1),this.precision=r,this.rounding=i,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(X(n,e,s,1)),t}function kd(n){return new this(n).cbrt()}function xd(n){return S(n=new this(n),n.e+1,2)}function Ad(n,e,t){return new this(n).clamp(e,t)}function Td(n){if(!n||typeof n!="object")throw Error(_i+"Object expected");var e,t,r,i=n.defaults===!0,s=["precision",1,ht,"rounding",0,8,"toExpNeg",-dr,0,"toExpPos",0,dr,"maxE",0,dr,"minE",-dr,0,"modulo",0,9];for(e=0;e<s.length;e+=3)if(t=s[e],i&&(this[t]=qs[t]),(r=n[t])!==void 0)if(pe(r)===r&&r>=s[e+1]&&r<=s[e+2])this[t]=r;else throw Error(ft+t+": "+r);if(t="crypto",i&&(this[t]=qs[t]),(r=n[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Sa);else this[t]=!1;else throw Error(ft+t+": "+r);return this}function Dd(n){return new this(n).cos()}function Sd(n){return new this(n).cosh()}function Ma(n){var e,t,r;function i(s){var o,a,l,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,Aa(s)){u.s=s.s,O?!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++;O?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 pi(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),Na.test(s)?pi(u,s):fd(u,s);if(l==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,pi(u,s.toString());throw Error(ft+s)}if(i.prototype=y,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=Td,i.clone=Ma,i.isDecimal=Aa,i.abs=pd,i.acos=md,i.acosh=gd,i.add=bd,i.asin=_d,i.asinh=wd,i.atan=yd,i.atanh=vd,i.atan2=Ed,i.cbrt=kd,i.ceil=xd,i.clamp=Ad,i.cos=Dd,i.cosh=Sd,i.div=Cd,i.exp=Nd,i.floor=Id,i.hypot=Od,i.ln=Bd,i.log=Rd,i.log10=Md,i.log2=$d,i.max=Ld,i.min=Pd,i.mod=jd,i.mul=Fd,i.pow=Ud,i.random=qd,i.round=Vd,i.sign=zd,i.sin=Hd,i.sinh=Wd,i.sqrt=Gd,i.sub=Xd,i.sum=Yd,i.tan=Zd,i.tanh=Jd,i.trunc=Kd,n===void 0&&(n={}),n&&n.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)n.hasOwnProperty(t=r[e++])||(n[t]=this[t]);return i.config(n),i}function Cd(n,e){return new this(n).div(e)}function Nd(n){return new this(n).exp()}function Id(n){return S(n=new this(n),n.e+1,3)}function Od(){var n,e,t=new this(0);for(O=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return O=!0,new this(1/0);t=e}return O=!0,t.sqrt()}function Aa(n){return n instanceof Qr||n&&n.toStringTag===Ca||!1}function Bd(n){return new this(n).ln()}function Rd(n,e){return new this(n).log(e)}function $d(n){return new this(n).log(2)}function Md(n){return new this(n).log(10)}function Ld(){return Ba(this,arguments,-1)}function Pd(){return Ba(this,arguments,1)}function jd(n,e){return new this(n).mod(e)}function Fd(n,e){return new this(n).mul(e)}function Ud(n,e){return new this(n).pow(e)}function qd(n){var e,t,r,i,s=0,o=new this(1),a=[];if(n===void 0?n=this.precision:Ee(n,1,ht),r=Math.ceil(n/N),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));s<r;)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(r*=4);s<r;)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=r/4}else throw Error(Sa);else for(;s<r;)a[s++]=Math.random()*1e7|0;for(r=a[--s],n%=N,r&&n&&(i=se(10,N-n),a[s]=(r/i|0)*i);a[s]===0;s--)a.pop();if(s<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=N)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<N&&(t-=N-r)}return o.e=t,o.d=a,o}function Vd(n){return S(n=new this(n),n.e+1,this.rounding)}function zd(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function Hd(n){return new this(n).sin()}function Wd(n){return new this(n).sinh()}function Gd(n){return new this(n).sqrt()}function Xd(n,e){return new this(n).sub(e)}function Yd(){var n=0,e=arguments,t=new this(e[n]);for(O=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return O=!0,S(t,this.precision,this.rounding)}function Zd(n){return new this(n).tan()}function Jd(n){return new this(n).tanh()}function Kd(n){return S(n=new this(n),n.e+1,1)}y[Symbol.for("nodejs.util.inspect.custom")]=y.toString;y[Symbol.toStringTag]="Decimal";var Qr=y.constructor=Ma(qs);mi=new Qr(mi);gi=new Qr(gi);var La=Qr;var Qd=20,ef=1,Mt=1e6,Pa=1e6,tf=-7,rf=21,nf=!1,en="[big.js] ",Lt=en+"Invalid ",vi=Lt+"decimal places",sf=Lt+"rounding mode",ja=en+"Division by zero",H={},Ge=void 0,of=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Fa(){function n(e){var t=this;if(!(t instanceof n))return e===Ge?Fa():new n(e);if(e instanceof n)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(n.strict===!0&&typeof e!="bigint")throw TypeError(Lt+"value");e=e===0&&1/e<0?"-0":String(e)}af(t,e)}t.constructor=n}return n.prototype=H,n.DP=Qd,n.RM=ef,n.NE=tf,n.PE=rf,n.strict=nf,n.roundDown=0,n.roundHalfUp=1,n.roundHalfEven=2,n.roundUp=3,n}function af(n,e){var t,r,i;if(!of.test(e))throw Error(Lt+"number");for(n.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)n.c=[n.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(n.e=t-r-1,n.c=[],t=0;r<=i;)n.c[t++]=+e.charAt(r++)}return n}function Pt(n,e,t,r){var i=n.c;if(t===Ge&&(t=n.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(sf);if(e<1)r=t===3&&(r||!!i[0])||e===0&&(t===1&&i[0]>=5||t===2&&(i[0]>5||i[0]===5&&(r||i[1]!==Ge))),i.length=1,r?(n.e=n.e-e+1,i[0]=1):i[0]=n.e=0;else if(e<i.length){if(r=t===1&&i[e]>=5||t===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==Ge||i[e-1]&1))||t===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++n.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return n}function jt(n,e,t){var r=n.e,i=n.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>s)for(r-=s;r--;)i+="0";else r<s&&(i=i.slice(0,r)+"."+i.slice(r));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return n.s<0&&t?"-"+i:i}H.abs=function(){var n=new this.constructor(this);return n.s=1,n};H.cmp=function(n){var e,t=this,r=t.c,i=(n=new t.constructor(n)).c,s=t.s,o=n.s,a=t.e,l=n.e;if(!r[0]||!i[0])return r[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=r.length)<(l=i.length)?a:l,s=-1;++s<o;)if(r[s]!=i[s])return r[s]>i[s]^e?1:-1;return a==l?0:a>l^e?1:-1};H.div=function(n){var e=this,t=e.constructor,r=e.c,i=(n=new t(n)).c,s=e.s==n.s?1:-1,o=t.DP;if(o!==~~o||o<0||o>Mt)throw Error(vi);if(!i[0])throw Error(ja);if(!r[0])return n.s=s,n.c=[n.e=0],n;var a,l,u,c,d,f=i.slice(),h=a=i.length,p=r.length,m=r.slice(0,a),b=m.length,g=n,_=g.c=[],w=0,v=o+(g.e=e.e-n.e)+1;for(g.s=s,s=v<0?0:v,f.unshift(0);b++<a;)m.push(0);do{for(u=0;u<10;u++){if(a!=(b=m.length))c=a>b?1:-1;else for(d=-1,c=0;++d<a;)if(i[d]!=m[d]){c=i[d]>m[d]?1:-1;break}if(c<0){for(l=b==a?i:f;b;){if(m[--b]<l[b]){for(d=b;d&&!m[--d];)m[d]=9;--m[d],m[b]+=10}m[b]-=l[b]}for(;!m[0];)m.shift()}else break}_[w++]=c?u:++u,m[0]&&c?m[b]=r[h]||0:m=[r[h]]}while((h++<p||m[0]!==Ge)&&s--);return!_[0]&&w!=1&&(_.shift(),g.e--,v--),w>v&&Pt(g,v,t.RM,m[0]!==Ge),g};H.eq=function(n){return this.cmp(n)===0};H.gt=function(n){return this.cmp(n)>0};H.gte=function(n){return this.cmp(n)>-1};H.lt=function(n){return this.cmp(n)<0};H.lte=function(n){return this.cmp(n)<1};H.minus=H.sub=function(n){var e,t,r,i,s=this,o=s.constructor,a=s.s,l=(n=new o(n)).s;if(a!=l)return n.s=-l,s.plus(n);var u=s.c.slice(),c=s.e,d=n.c,f=n.e;if(!u[0]||!d[0])return d[0]?n.s=-l:u[0]?n=new o(s):n.s=1,n;if(a=c-f){for((i=a<0)?(a=-a,r=u):(f=c,r=d),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(t=((i=u.length<d.length)?u:d).length,a=l=0;l<t;l++)if(u[l]!=d[l]){i=u[l]<d[l];break}if(i&&(r=u,u=d,d=r,n.s=-n.s),(l=(t=d.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;t>a;){if(u[--t]<d[t]){for(e=t;e&&!u[--e];)u[e]=9;--u[e],u[t]+=10}u[t]-=d[t]}for(;u[--l]===0;)u.pop();for(;u[0]===0;)u.shift(),--f;return u[0]||(n.s=1,u=[f=0]),n.c=u,n.e=f,n};H.mod=function(n){var e,t=this,r=t.constructor,i=t.s,s=(n=new r(n)).s;if(!n.c[0])throw Error(ja);return t.s=n.s=1,e=n.cmp(t)==1,t.s=i,n.s=s,e?new r(t):(i=r.DP,s=r.RM,r.DP=r.RM=0,t=t.div(n),r.DP=i,r.RM=s,this.minus(t.times(n)))};H.neg=function(){var n=new this.constructor(this);return n.s=-n.s,n};H.plus=H.add=function(n){var e,t,r,i=this,s=i.constructor;if(n=new s(n),i.s!=n.s)return n.s=-n.s,i.minus(n);var o=i.e,a=i.c,l=n.e,u=n.c;if(!a[0]||!u[0])return u[0]||(a[0]?n=new s(i):n.s=i.s),n;if(a=a.slice(),e=o-l){for(e>0?(l=o,r=u):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-u.length<0&&(r=u,u=a,a=r),e=u.length,t=0;e;a[e]%=10)t=(a[--e]=a[e]+u[e]+t)/10|0;for(t&&(a.unshift(t),++l),e=a.length;a[--e]===0;)a.pop();return n.c=a,n.e=l,n};H.pow=function(n){var e=this,t=new e.constructor("1"),r=t,i=n<0;if(n!==~~n||n<-Pa||n>Pa)throw Error(Lt+"exponent");for(i&&(n=-n);n&1&&(r=r.times(e)),n>>=1,!!n;)e=e.times(e);return i?t.div(r):r};H.prec=function(n,e){if(n!==~~n||n<1||n>Mt)throw Error(Lt+"precision");return Pt(new this.constructor(this),n,e)};H.round=function(n,e){if(n===Ge)n=0;else if(n!==~~n||n<-Mt||n>Mt)throw Error(vi);return Pt(new this.constructor(this),n+this.e+1,e)};H.sqrt=function(){var n,e,t,r=this,i=r.constructor,s=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(s<0)throw Error(en+"No square root");s=Math.sqrt(+jt(r,!0,!0)),s===0||s===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),n=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):n=new i(s+""),o=n.e+(i.DP+=4);do t=n,n=a.times(t.plus(r.div(t)));while(t.c.slice(0,o).join("")!==n.c.slice(0,o).join(""));return Pt(n,(i.DP-=4)+n.e+1,i.RM)};H.times=H.mul=function(n){var e,t=this,r=t.constructor,i=t.c,s=(n=new r(n)).c,o=i.length,a=s.length,l=t.e,u=n.e;if(n.s=t.s==n.s?1:-1,!i[0]||!s[0])return n.c=[n.e=0],n;for(n.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?++n.e:e.shift(),l=e.length;!e[--l];)e.pop();return n.c=e,n};H.toExponential=function(n,e){var t=this,r=t.c[0];if(n!==Ge){if(n!==~~n||n<0||n>Mt)throw Error(vi);for(t=Pt(new t.constructor(t),++n,e);t.c.length<n;)t.c.push(0)}return jt(t,!0,!!r)};H.toFixed=function(n,e){var t=this,r=t.c[0];if(n!==Ge){if(n!==~~n||n<0||n>Mt)throw Error(vi);for(t=Pt(new t.constructor(t),n+t.e+1,e),n=n+t.e+1;t.c.length<n;)t.c.push(0)}return jt(t,!1,!!r)};H[Symbol.for("nodejs.util.inspect.custom")]=H.toJSON=H.toString=function(){var n=this,e=n.constructor;return jt(n,n.e<=e.NE||n.e>=e.PE,!!n.c[0])};H.toNumber=function(){var n=+jt(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(n.toString()))throw Error(en+"Imprecise conversion");return n};H.toPrecision=function(n,e){var t=this,r=t.constructor,i=t.c[0];if(n!==Ge){if(n!==~~n||n<1||n>Mt)throw Error(Lt+"precision");for(t=Pt(new r(t),n,e);t.c.length<n;)t.c.push(0)}return jt(t,n<=t.e||t.e<=r.NE||t.e>=r.PE,!!i)};H.valueOf=function(){var n=this,e=n.constructor;if(e.strict===!0)throw Error(en+"valueOf disallowed");return jt(n,n.e<=e.NE||n.e>=e.PE,!0)};var lf=Fa(),Ua=lf;var ro={};id(ro,{DecodeError:()=>me,Decoder:()=>Pe,EXT_TIMESTAMP:()=>Gs,Encoder:()=>hr,ExtData:()=>Le,ExtensionCodec:()=>pt,decode:()=>Za,decodeArrayStream:()=>Qa,decodeAsync:()=>Ka,decodeMulti:()=>Ja,decodeMultiStream:()=>el,decodeTimestampExtension:()=>Ks,decodeTimestampToTimeSpec:()=>Js,encode:()=>xi,encodeDateToTimeSpec:()=>Ys,encodeTimeSpecToTimestamp:()=>Xs,encodeTimestampExtension:()=>Zs});function qa(n){let e=n.length,t=0,r=0;for(;r<e;){let i=n.charCodeAt(r++);if((i&4294967168)===0){t++;continue}else if((i&4294965248)===0)t+=2;else{if(i>=55296&&i<=56319&&r<e){let s=n.charCodeAt(r);(s&64512)===56320&&(++r,i=((i&1023)<<10)+(s&1023)+65536)}(i&4294901760)===0?t+=3:t+=4}}return t}function uf(n,e,t){let r=n.length,i=t,s=0;for(;s<r;){let o=n.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<r){let a=n.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 cf=new TextEncoder,df=50;function ff(n,e,t){cf.encodeInto(n,e.subarray(t))}function Va(n,e,t){n.length>df?ff(n,e,t):uf(n,e,t)}var hf=4096;function Ws(n,e,t){let r=e,i=r+t,s=[],o="";for(;r<i;){let a=n[r++];if((a&128)===0)s.push(a);else if((a&224)===192){let l=n[r++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=n[r++]&63,u=n[r++]&63;s.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=n[r++]&63,u=n[r++]&63,c=n[r++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d)}else s.push(a);s.length>=hf&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var pf=new TextDecoder,mf=200;function gf(n,e,t){let r=n.subarray(e,e+t);return pf.decode(r)}function za(n,e,t){return t>mf?gf(n,e,t):Ws(n,e,t)}var Le=class{type;data;constructor(e,t){this.type=e,this.data=t}};var me=class n extends Error{constructor(e){super(e);let t=Object.create(n.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:n.name})}};function Ha(n,e,t){let r=t/4294967296,i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function Ei(n,e,t){let r=Math.floor(t/4294967296),i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function ki(n,e){let t=n.getInt32(e),r=n.getUint32(e+4);return t*4294967296+r}function Wa(n,e){let t=n.getUint32(e),r=n.getUint32(e+4);return t*4294967296+r}var Gs=-1,bf=4294967296-1,_f=17179869184-1;function Xs({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=_f)if(e===0&&n<=bf){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,r=n&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|t&3),s.setUint32(4,r),i}else{let t=new Uint8Array(12),r=new DataView(t.buffer);return r.setUint32(0,e),Ei(r,4,n),t}}function Ys(n){let e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,i=Math.floor(r/1e9);return{sec:t+i,nsec:r-i*1e9}}function Zs(n){if(n instanceof Date){let e=Ys(n);return Xs(e)}else return null}function Js(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),r=e.getUint32(4),i=(t&3)*4294967296+r,s=t>>>2;return{sec:i,nsec:s}}case 12:{let t=ki(e,4),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new me(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function Ks(n){let e=Js(n);return new Date(e.sec*1e3+e.nsec/1e6)}var Ga={type:Gs,encode:Zs,decode:Ks};var pt=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(Ga)}register({type:e,encode:t,decode:r}){if(e>=0)this.encoders[e]=t,this.decoders[e]=r;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=r}}tryToEncode(e,t){for(let r=0;r<this.builtInEncoders.length;r++){let i=this.builtInEncoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=-1-r;return new Le(o,s)}}}for(let r=0;r<this.encoders.length;r++){let i=this.encoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=r;return new Le(o,s)}}}return e instanceof Le?e:null}decode(e,t,r){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,r):new Le(t,e)}};function wf(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function tn(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):wf(n)?new Uint8Array(n):Uint8Array.from(n)}var yf=100,vf=2048,hr=class n{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??pt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??yf,this.initialBufferSize=e?.initialBufferSize??vf,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 n({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,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);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,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),r=new Uint8Array(t),i=new DataView(t);r.set(this.bytes),this.view=i,this.bytes=r}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 r=qa(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),Va(e,this.bytes,this.pos),this.pos+=r}encodeObject(e,t){let r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let r=tn(e);this.writeU8a(r)}encodeArray(e,t){let r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let r=0;for(let i of t)e[i]!==void 0&&r++;return r}encodeMap(e,t){let r=Object.keys(e);this.sortKeys&&r.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.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 r){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),i=r.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(r);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}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),Ha(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Ei(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 xi(n,e){return new hr(e).encodeSharedRef(n)}function Ai(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}var Ef=16,kf=16,Ti=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Ef,t=kf){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,r){let i=this.caches[r-1];e:for(let s of i){let o=s.bytes;for(let a=0;a<r;a++)if(o[a]!==e[t+a])continue e;return s.str}return null}store(e,t){let r=this.caches[e.length-1],i={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=i:r.push(i)}decode(e,t,r){let i=this.find(e,t,r);if(i!=null)return this.hit++,i;this.miss++;let s=Ws(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,s),s}};var Qs="array",sn="map_key",Ya="map_value",xf=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new me("The type of key must be string or number but "+typeof n)},eo=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Qs,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=sn,t.readCount=0,t.size=e,t.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===Qs){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===sn||e.type===Ya){let r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},nn=-1,to=new DataView(new ArrayBuffer(0)),Af=new Uint8Array(to.buffer);try{to.getInt8(0)}catch(n){if(!(n 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 Xa=new RangeError("Insufficient data"),Tf=new Ti,Pe=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=to;bytes=Af;headByte=nn;stack=new eo;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??pt.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:Tf,this.mapKeyConverter=e?.mapKeyConverter??xf}clone(){return new n({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=nn,this.stack.reset()}setBuffer(e){let t=tn(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===nn&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),r=tn(e),i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:r}=this;return new RangeError(`Extra ${t.byteLength-r} of ${t.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 t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}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 t=!1,r;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{r=this.doDecodeSync(),t=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return r}let{headByte:i,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${Ai(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,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let r=t,i=-1;for await(let s of e){if(t&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),r&&(i=this.readArraySize(),r=!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(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else{let i=e-160;t=this.decodeString(i,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===196){let i=this.lookU8();t=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();t=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();t=this.decodeBinary(i,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();t=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();t=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();t=this.decodeExtension(i,4)}else throw new me(`Unrecognized type byte: ${Ai(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let i=r.top();if(i.type===Qs)if(i.array[i.position]=t,i.position++,i.position===i.size)t=i.array,r.release(i);else continue e;else if(i.type===sn){if(t==="__proto__")throw new me("The key __proto__ is not allowed");i.key=this.mapKeyConverter(t),i.type=Ya;continue e}else if(i.map[i.key]=t,i.readCount++,i.readCount===i.size)t=i.map,r.release(i);else{i.key=null,i.type=sn;continue e}}return t}}readHeadByte(){return this.headByte===nn&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=nn}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 me(`Unrecognized array type byte: ${Ai(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new me(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new me(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new me(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Xa;let r=this.pos+t,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,r,e):i=za(this.bytes,r,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===sn:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new me(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Xa;let r=this.pos+t,i=this.bytes.subarray(r,r+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new me(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,r,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=Wa(this.view,this.pos);return this.pos+=8,e}readI64(){let e=ki(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 Za(n,e){return new Pe(e).decode(n)}function Ja(n,e){return new Pe(e).decodeMulti(n)}function Df(n){return n[Symbol.asyncIterator]!=null}async function*Sf(n){let e=n.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}function Di(n){return Df(n)?n:Sf(n)}async function Ka(n,e){let t=Di(n);return new Pe(e).decodeAsync(t)}function Qa(n,e){let t=Di(n);return new Pe(e).decodeArrayStream(t)}function el(n,e){let t=Di(n);return new Pe(e).decodeStream(t)}var Wi=ya(Ao(),1),To=La,Do=Ua,Je=ro,su=Wi.DOMParser,ou=Wi.XMLSerializer;var au=Je!==null;function lu(){if(!au)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var uu=Dp();function Dp(){if(!au)return null;let n=new TextEncoder,e=new TextDecoder,t=new Je.ExtensionCodec;return t.register({type:-1,encode:r=>{if(r instanceof Date){let i=vt(r);if(i==="D"||i==="H")return null}return Je.encodeTimestampExtension(r)},decode:r=>Je.decodeTimestampExtension(r)}),t.register({type:1,encode:r=>fe(r)?n.encode(r.toString()):null,decode:r=>Et(e.decode(r))}),t.register({type:2,encode:r=>{if(r instanceof Date&&vt(r)==="D"){let i=r.getUTCFullYear(),s=String(r.getUTCMonth()+1).padStart(2,"0"),o=String(r.getUTCDate()).padStart(2,"0");return n.encode(`${i}-${s}-${o}`)}return null},decode:r=>new Date(e.decode(r)+"T00:00:00.000Z")}),t.register({type:3,encode:r=>{if(r instanceof Date&&vt(r)==="H"){let i=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=String(r.getUTCMilliseconds()).padStart(3,"0");return n.encode(`${i}:${s}:${o}.${a}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf("."),o=s>=0?i.substring(0,s):i,a=s>=0?i.substring(s+1):"0",[l,u,c]=o.split(":"),d=Math.round(+a.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,d))}}),t.register({type:4,encode:r=>{let i=So(r);if(i!==null){let[s,o]=i;return n.encode(`${s}:${o(r)}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf(":"),o=i.slice(0,s),a=i.slice(s+1),l=kt[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),t}function cu(n){return lu(),Je.encode(n,{extensionCodec:uu})}function du(n){return lu(),Je.decode(n,{extensionCodec:uu})}function Xi(n,e=!1){let t=Yi(n);if(t===null)return[!1,String(n)];let[r,i,s]=t;return s&&!e?[!1,String(n)]:[!0,`${i(n)}::${r}`]}function Co(n){if(!n.includes("::"))return[!1,n];let e=n.lastIndexOf("::"),t=n.slice(0,e),r=n.slice(e+2),i=kt[r];if(i===void 0)return[!1,n];let[,s]=i;return[!0,s(t)]}function Gi(n,e,t){if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r={};for(let[i,s]of Object.entries(n))r[i]=Gi(s,e,t);return r}return Array.isArray(n)?n.map(r=>Gi(r,e,t)):t(n)?e(n):n}function No(n){let e=Yi(n);if(e!==null){let[t,r,i]=e;return i?[n,!1]:[`${r(n)}::${t}`,!0]}if(Array.isArray(n)){let t=!1;return[n.map(i=>{let[s,o]=No(i);return o&&(t=!0),s}),t]}if(n!==null&&typeof n=="object"){let t=!1,r={};for(let[i,s]of Object.entries(n)){let[o,a]=No(s);a&&(t=!0),r[i]=o}return[r,t]}return[n,!1]}function Sp(n,e=!1){let[t,r]=Xi(n,e);if(t)return r;let[i,s]=No(n),o=JSON.stringify(i);return s?`${o}::JS`:o}function Cp(n){return JSON.stringify(n)}function Np(n){if(!Je)throw new Error("@msgpack/msgpack is required for MessagePack support");return Je.encode(n)}function U(n,e=null,{raw:t=!1,qs:r=!1,_forceSuffix:i=!1}={}){if(r)return`${hu(n)}::QS`;if(t){if(e===null||e==="json")return Cp(n);if(e==="msgpack")return Np(n);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=Sp(n,i);return e==="json"?`"${s}"`:s}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${fu(n)}</tytx_root>`;if(e==="msgpack")return cu(n);throw new Error(`Unknown transport: ${e}`)}}var Or,Io;typeof window<"u"&&window.DOMParser?(Or=window.DOMParser,Io=window.XMLSerializer):(Or=su,Io=ou);function pu(n){if(n===null||typeof n!="object"||Array.isArray(n))return!1;let e=Object.keys(n);if(e.length!==1)return!1;let t=n[e[0]];return t!==null&&typeof t=="object"&&"value"in t}function mu(n,e,t){let r=n.createElement(e),i=t.attrs||{},s=t.value;for(let[o,a]of Object.entries(i))r.setAttribute(o,U(a,null,{_forceSuffix:!0}));if(Array.isArray(s))for(let o of s)if(pu(o)){let[a]=Object.keys(o),l=o[a],u=mu(n,a,l);r.appendChild(u)}else{r.textContent=U(s);break}else r.textContent=U(s);return r}function fu(n){if(!Or)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(pu(n)){let[e]=Object.keys(n),t=n[e],r=new Or().parseFromString("<root/>","text/xml"),i=mu(r,e,t);return new Io().serializeToString(i)}else return U(n)}function Oo(n){let e={};for(let r=0;r<n.attributes.length;r++){let i=n.attributes[r];e[i.name]=P(i.value)}let t=[];for(let r=0;r<n.childNodes.length;r++){let i=n.childNodes[r];i.nodeType===1&&t.push(i)}if(t.length>0)if(t.length===1){let r=t[0],i=Oo(r);return{attrs:e,value:{[r.tagName]:i}}}else{let r=[];for(let i of t){let s=Oo(i);r.push({[i.tagName]:s})}return{attrs:e,value:r}}return{attrs:e,value:P(n.textContent)}}function gu(n){if(!Or)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let r=new Or().parseFromString(n,"text/xml").documentElement;if(r.tagName==="tytx_root"){let s=null;for(let o=0;o<r.childNodes.length;o++)if(r.childNodes[o].nodeType===1){s=r.childNodes[o];break}if(!s)return P(r.textContent);r=s}let i=Oo(r);return{[r.tagName]:i}}function Ip(n){return typeof n=="string"}function Op(n){let[e,t]=Co(n);if(e)return t;let r=n;r.endsWith("::JS")&&(r=r.slice(0,-4));let i;try{i=JSON.parse(r)}catch{return n}return Gi(i,Bp,Ip)}function Bp(n){return n.includes("::")?Co(n)[1]:n}function Rp(n){let e=gu(n);return typeof e=="string"?P(e):e}function $p(n){return du(n)}function P(n,e=null){if(n===null)return null;if(e===null||e==="json"){let t=n;return e==="json"&&n.startsWith('"')&&n.endsWith('"')&&(t=n.slice(1,-1)),Op(t)}else{if(e==="xml")return Rp(n);if(e==="msgpack")return $p(n);throw new Error(`Unknown transport: ${e}`)}}function hu(n){if(Array.isArray(n))return n.map(e=>String(e)).join("&");if(n!==null&&typeof n=="object"){let e=[];for(let[t,r]of Object.entries(n)){let[i,s]=Xi(r,!0);i?e.push(`${t}=${s}`):e.push(`${t}=${r}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof n}`)}function bu(n){if(!n)return[];let e=n.split("&"),t=e.map(o=>o.includes("=")),r=t.every(Boolean),i=!t.some(Boolean);if(!r&&!i)throw new Error("QS format error: mixed items with and without '='");if(i)return e.map(o=>P(o));let s={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);s[l]=P(u)}return s}var wu=To||Do||Number,yu=To?"decimal.js":Do?"big.js":"number";function Ro(){return yu}function Et(n){return new wu(n)}function fe(n){return yu==="number"?!1:n instanceof wu}function vt(n){let e=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,t=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;return e&&!t?"H":t&&!e?"D":"DHZ"}function Mp(n){return n.toString()}function Lp(n){let e=n.getUTCFullYear(),t=String(n.getUTCMonth()+1).padStart(2,"0"),r=String(n.getUTCDate()).padStart(2,"0");return`${e}-${t}-${r}`}function Pp(n){return n.toISOString()}function jp(n){let e=String(n.getUTCHours()).padStart(2,"0"),t=String(n.getUTCMinutes()).padStart(2,"0"),r=String(n.getUTCSeconds()).padStart(2,"0"),i=String(n.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${r}.${i}`}function Fp(n){return n?"true":"false"}function Up(n){return n.toString()}function qp(n){return n.toString()}function Vp(n){let e="";for(let t=0;t<n.length;t+=32768)e+=String.fromCharCode.apply(null,n.subarray(t,t+32768));return btoa(e)}var Zi=[],Bo=new Map;function So(n){if(n===null||typeof n!="object")return null;for(let e=Object.getPrototypeOf(n);e!==null;e=Object.getPrototypeOf(e))for(let[t,r,i,s]of Zi)if(t.prototype===e)return[r,i,s];return null}function Yi(n){if(n===null)return["NN",()=>"",!0];if(fe(n))return["N",Mp,!1];if(n instanceof Uint8Array)return["RAW",Vp,!1];if(n instanceof Date){let e=vt(n);return e==="D"?["D",Lp,!1]:e==="H"?["H",jp,!1]:["DHZ",Pp,!1]}return typeof n=="boolean"?["B",Fp,!0]:typeof n=="number"?Number.isInteger(n)?["L",Up,!0]:["R",qp,!0]:So(n)}function zp(n){return Et(n)}function Hp(n){let[e,t,r]=n.split("-").map(Number);return new Date(Date.UTC(e,t-1,r,0,0,0,0))}function _u(n){return new Date(n)}function Wp(n){let[e,t,r]=n.split(":"),[i,s]=r.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(i),Number(s||0)))}function Gp(n){return n.toLowerCase()==="true"}function Xp(n){return parseInt(n,10)}function Yp(n){return parseFloat(n)}function Zp(n){return n}function Jp(n){return null}var Kp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function Qp(n){if(!Kp.test(n))throw new Error(`RAW payload is not standard padded base64: '${n}'`);let e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function em(n){return bu(n)}var tm=/^[A-Z]+$/,kt={N:[Object,zp],D:[Date,Hp],DH:[Date,_u],DHZ:[Date,_u],H:[Date,Wp],L:[Number,Xp],R:[Number,Yp],T:[String,Zp],B:[Boolean,Gp],QS:[Object,em],NN:[null,Jp],RAW:[Uint8Array,Qp]};function An(n){return Object.hasOwn(kt,n)?kt[n][0]:null}function $o(n,e,t,r,i=!1){if(typeof e!="string"||!tm.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let s=kt[e];if(s!==void 0&&s[0]!==n){let o=s[0]===null?"null":s[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}Zi=Zi.filter(([o])=>o!==n),Zi.push([n,e,t,i]),kt[e]=[n,r]}function zt(n,e){Bo.set(n,e)}function Re(n){return Bo.has(n)?Bo.get(n):{}}var vu={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 nm(n){let e=n._retryPolicy;return e==null?null:typeof e=="string"?vu[e]||null:e}function im(n,e){return e.some(t=>t==="Error"?!0:n.name===t||n.constructor.name===t)}function sm(n){return new Promise(e=>setTimeout(e,n))}async function om(n,e){if(!e)return n();let t=e.maxAttempts||3,r=e.delay||1,i=e.backoff||2,s=e.jitter!==!1,o=e.on||["Error"],a=null,l=r*1e3;for(let u=0;u<t;u++)try{let c=n();return c instanceof Promise?await c:c}catch(c){if(a=c,u<t-1&&im(c,o)){let d=l;s&&(d*=1+Math.random()*.1),await sm(d),l*=i}else throw c}throw a}var J=class n{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let r={...this.constructor.classKwargs,...e};for(let s of["interval","reactive"])if(Object.hasOwn(r,s))throw new TypeError(`Removed resolver option: ${s}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=r.cacheTime,this._readOnly=r.readOnly,this._asBag=r.asBag,this._retryPolicy=r.retryPolicy,this._kw={};let i=this.constructor.internalParams;for(let[s,o]of Object.entries(r))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())}resolve(e={}){let{static:t=!1,...r}=e;if(t)return this._node?this._node._value:this.cachedValue;let i={...this._kw};if(this._node&&this._node.attr){let u=this.constructor.internalParams;for(let[c,d]of Object.entries(this._node.attr))u.has(c)||(i[c]=d)}Object.assign(i,r);let s=this._computeEffectiveFingerprint(i);if(s===this._lastEffectiveFingerprint&&!this.expired)return this.cachedValue;this._lastEffectiveFingerprint=s;let o=nm(this),a=()=>this.load(i);if(o)return om(a,o).then(u=>this._finalize(u));let l=a();return l&&typeof l.then=="function"?l.then(u=>this._finalize(u)):this._finalize(l)}_finalize(e){let t;return this._asBag===!0?t=!0:this._asBag===!1?t=!1:t=!this._readOnly,t&&e!==null&&e!==void 0&&(e=this._convertToBag(e)),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_convertToBag(e){let t=n._BagClass;if(!t||e&&typeof e._htraverse=="function")return e;if(typeof e=="string"){if(e=e.trim(),e.startsWith("<")&&t.fromXml)return t.fromXml(e);if((e.startsWith("{")||e.startsWith("["))&&t.fromTytx)return t.fromTytx(e)}return e}static registerBagClass(e){n._BagClass=e}load(e){return null}};J._BagClass=null;var xt=class extends J{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 je=class n{constructor(e,t,r=null,i=null,s=null,o=null,a=null,l=!0){this.label=t,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),r!==null&&this.setValue(r,!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,t=null,r={}){if(t!==null){let i=P(`${t}::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 J?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");r={...r,...i}}}return this._resolver!==null?this._resolver.resolve({static:e,...r}):this._value}setValue(e,t=!0,r=null,i=null,s=!0,o=null,a=!1){e instanceof J?(this.resolver=e,e=null):e instanceof n&&(r=r||{},Object.assign(r,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=t??!0,d=null;if(r!==null){let h={...this._attr};this.setAttr(r,!1,i,s);let p=this._buildAttrDiff(h,this._attr);d=Object.keys(p).length>0?p:null}t=c&&(u||d!==null);let f=d?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),t){let h=d!==null?{oldvalue:l,attrs_diff:d}:{oldvalue:l};for(let p of Object.values(this._nodeSubscribers))p({node:this,info:h,evt:f})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),t&&this._parentBag._onNodeChanged(this,[this.label],f,l,d,o,a))}replace(e){if(!(e instanceof n))throw new TypeError("BagNode.replace expects a BagNode");if(e===this)return this;let t=e.staticValue;t&&typeof t._htraverse=="function"&&(t=t.createChildBag().replace(t));let r=null;e.resolver&&(r=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),r._node=null,r._kw={...e.resolver._kw});let i=this._value,s={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=r,this.setValue(t,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(s,this._attr),l=Object.keys(a).length?a:null,u=i!==t||o!==r;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:i,attrs_diff:l}:{oldvalue:i};for(let f of Object.values(this._nodeSubscribers))f({node:this,info:d,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,t=null){return e?e in this._attr?this._attr[e]:t:this._attr}_buildAttrDiff(e,t){let r={},i=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of i){let o=s in e?e[s]:null,a=s in t?t[s]:null;o!==a&&(r[s]={old:o,new:a})}return r}setAttr(e=null,t=!0,r=!0,i=!0){let s=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=t&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(r?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(t&&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=t===!0?"true":String(t);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let t of e)if(typeof t=="string"&&t.includes(","))for(let r of t.split(","))delete this._attr[r.trim()];else delete this._attr[t]}hasAttr(e,t=null){return e in this._attr?t!==null?this._attr[e]===t:!0:!1}getInheritedAttributes(){let e={};return this._parentBag&&this._parentBag.parentNode&&(e=this._parentBag.parentNode.getInheritedAttributes()),{...e,...this._attr}}subscribe(e,t){this._nodeSubscribers[e]=t}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,t=null){let r=this;if(t===null)for(;r&&!(e in r._attr);)r=r.parentNode;else for(;r&&r._attr[e]!==t;)r=r.parentNode;return r}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof n)||this.label!==e.label)return!1;let t=Object.keys(this._attr),r=Object.keys(e._attr);if(t.length!==r.length)return!1;for(let i of t)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 t=Object.keys(this._attr),r=Object.keys(e._attr);return t.length!==r.length||t.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 t=this.value;return t&&typeof t.toJson=="function"&&(t=t.toJson(e,!0)),{label:this.label,value:t,attr:this._attr}}toString(){return`BagNode : ${this.label}`}};var Tn=class n{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(r=>r.label===e);let t=e.match(/^#(\d+)$/);if(t){let r=parseInt(t[1],10);return r<this._list.length?r:-1}if(t=e.match(/^#(\w*)=(.*)$/),t){let[,r,i]=t,s=i.includes("::")?P(i):i;return r?this._list.findIndex(o=>o.getAttr(r)===s):this._list.findIndex(o=>o._value===s)}return-1}_parsePosition(e){let t=this._list.length;if(e==null||e===">")return t;if(typeof e=="number")return e<0&&(e=t+e),Math.max(0,Math.min(e,t));if(e==="<")return 0;if(e.startsWith("#")){let r=this._parseSharpIndex(e.slice(1),e);return Math.min(r,t)}if(e.startsWith("<")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i}if(e.startsWith(">")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s+1,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i+1}throw new Error(`Invalid node_position '${e}': unrecognized syntax`)}_parseSharpIndex(e,t){if(!/^-?\d+$/.test(e))throw new Error(`Invalid node_position '${t}': '${e}' is not an integer`);let r=parseInt(e,10);if(r<0)throw new Error(`Invalid node_position '${t}': negative index not allowed in '#n' syntax`);return r}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let t=this.index(e);return t>=0?this._list[t]:null}return this._dict[e]||null}set(e,t,r=">",i=null,s=null,o=null,a=!1,l=!0,u=null,c=!0,d=!1,f=null){let h=null;if(e.includes("?")&&([e,h]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(h){let m=h.split("&");if(m.length===1)i={[m[0]]:t};else{if(!Array.isArray(t)||t.length!==m.length)throw new Error("Wrong attributes assignment");i={};for(let b=0;b<m.length;b++)i[m[b]]=t[b]}t=null}let p=this._dict[e];if(p)f&&(p.nodeTag=f),o!==null&&(o===!1?p.resolver=null:p.resolver=o),h?p.setAttr(i,c,!0,l):p.setValue(t,c,i,a,l,u,d);else{let m=s&&s.nodeClass?s.nodeClass:je;p=new m(s,e,h?null:t,i,o,f,null,l);let b=this._parsePosition(r);this._dict[e]=p,this._list.splice(b,0,p),c&&s&&s.backref&&s._onNodeInserted(p,b,null,u,d)}return d&&p.setValue(null,!1),p}pop(e){let t=this.get(e);if(t){delete this._dict[t.label];let r=this._list.indexOf(t);return r>=0&&this._list.splice(r,1),t}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,t,r=!0){if(t<0)return;let i=Array.isArray(e)?e:[e];if(i.length===0||t>=this._list.length)return;let s=this._list[t].label;if(i.length>1){let o=[...i].sort((c,d)=>c-d),a=o[0]<t?1:0,l=[];for(let c=o.length-1;c>=0;c--){let d=o[c];if(d>=0&&d<this._list.length){let f=this._list[d];this._list.splice(d,1),l.push(f),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(s);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=i[0];if(o===t||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(t,0,a),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,t)}}isEqual(e){if(!(e instanceof n)||this._list.length!==e._list.length)return!1;for(let t=0;t<this._list.length;t++){let r=this._list[t],i=e._list[t];if(!r.isEqual(i))return!1}return!0}};var Au=ya(Ao(),1);var Mo="::RSLV:",am=new Map,lm=new Map,Ji=new WeakMap,re=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Dn=class extends J{constructor(e){super({asBag:!1}),Ji.set(this,e)}get payload(){return Ji.get(this)}load(){throw new re("This resolver is opaque; local execution is unavailable")}};function Eu(n){if(!n||typeof n!="object"||Array.isArray(n)||typeof n.resolver_module!="string"||typeof n.resolver_class!="string"||!Array.isArray(n.args??[])||!n.kwargs||typeof n.kwargs!="object"||Array.isArray(n.kwargs))throw new re("Invalid resolver description")}function ku(n,e=new Set){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n)||!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new re("Resolver parameters must be JSON data; callbacks cannot travel");e.add(n);for(let t of Object.values(n))ku(t,e);e.delete(n)}}function Sn(n){if(Ji.has(n))return Ji.get(n);let e=lm.get(n.constructor);if(!e)throw new re(`Unregistered resolver: ${n.constructor.name}`);let t=e.encode(n),r={resolver_module:e.module,resolver_class:e.name,args:t.args??[],kwargs:t.kwargs??{}};return Eu(r),ku(r),Mo+JSON.stringify(r)}function Ki(n){if(typeof n!="string"||!n.startsWith(Mo))return null;let e=n.slice(Mo.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Dn(n);let t;try{t=JSON.parse(e)}catch{throw new re("Invalid resolver JSON or signed token")}Eu(t);let r=am.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!r)return new Dn(n);let i=r.decode({args:t.args??[],kwargs:t.kwargs});if(!(i instanceof r.cls))throw new re("Resolver decoder returned an incompatible instance");return i}function Qi(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,t instanceof J?Sn(t):t]))}function Lo(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,Ki(t)??t]))}var Fe="__cls";function Br(n,e){return n!==null&&n.tytxSuffix===e?n:An(e)}function um(n){let e=n.tytxSuffix,t=Object.entries(Re(e)).filter(([,r])=>r===n).map(([r])=>r);if(t.length===0)throw new re(`${n.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new re(`${n.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function Po(n,e){let t=Re(n);if(!Object.hasOwn(t,e))throw new re(`Unknown Bag class '${e}' for TYTX type '${n}'`);return t[e]}function jo(n,e){return n===e?null:um(n)}function*Tu(n,e=[]){for(let t of n){let r=[...e,t.label];yield[r,t];let i=t.getValue(!0);!t.resolver&&i instanceof D&&(yield*Tu(i,r))}}function cm(n){let e=n.toISOString(),t=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,r=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;if(r&&!t)return e.slice(0,e.indexOf("T"));let i=e.replace(/\.000Z$/,"Z");return t&&!r?i.slice(i.indexOf("T")+1):i}function Rr(n){if(n===null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function At(n){return typeof n=="string"?n.includes("::")?`${n}::T`:n:Array.isArray(n)?n.map(At):Rr(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,At(t)])):n}function Fo(n){if(!Rr(n))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=n;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var xu=!1,D=class n{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new Tn,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Fo(t),e!=null&&this.fillFrom(e,t)}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 je}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 t=[],r=e;for(;r!==null;){if(r.parentBag===this)return t.push(r.label),t.reverse(),t.join(".");t.push(r.label),r=r.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 t=this,r;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),r=e.split(".").filter(i=>i)):r=[...e];r.length&&r[0]==="#parent"&&t!==null;)r.shift(),t=t.parent;return[t,r]}_htraverse(e,t=!1,r=!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 n;){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(r);if(l instanceof n)s.shift(),i=l;else if(t){let u=i.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),s.shift(),i=u}else break}if(!t)return s.length>1?[null,null]:[i,s[0]];for(;s.length>1;){let o=s.shift();if(o.startsWith("#"))throw new Cn("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,t=null,r=!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(r,s,i):t}getItem(e,t=null,r=!1,i={}){if(!e)return this;let[s,o]=this._htraverse(e,!1,r);return s instanceof n?s.get(o,t,r,i):t}setItem(e,t,r=null,i=">",s=!1,o=!0,a=null,l=!1,u=!0,c=null,d=null){if(e==="")throw new RangeError("setItem requires a non-empty path");let[f,h]=this._htraverse(e,!0);return f._nodes.set(h,t,i,r,f,c,s,o,a,u,l,d)}_pop(e,t=null){let r=this._nodes.index(e);if(r>=0){let i=this._nodes.pop(r);return this.backref&&this._onNodeDeleted(i,r,t),i}return null}pop(e,t=null,r=null){let i=this.popNode(e,r);return i?i.value:t}delItem(e,t=null,r=null){return this.pop(e,t,r)}popNode(e,t=null){let[r,i]=this._htraverse(e,!1,!0);if(!r||!i)return null;let s=r._nodes.get(i);if(!s)return null;try{return r._pop(i,t)}finally{s.parentBag===r&&r._nodes._dict[s.label]!==s&&(s.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let t of e)t.parentBag=null}getNode(e,t=!0,r=!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,r,t);if(s instanceof n&&o){let a=s._nodes.get(o);if(a)return a;if(r)return s._nodes.set(o,i,">",null,s,null,!1,!0,"autocreate"),s._nodes.get(o)}return null}setBackref(e=null,t=null){let r=this._backref;if(this._backref=!0,this._parent=t,this._parentNode=e,!r){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 t=e.getValue(!0);t instanceof n&&t.clearBackref()}}}_onNodeChanged(e,t,r,i=null,s=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:i,attrs_diff:s,evt:r,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],r,i,s,o,a)}_onNodeInserted(e,t,r=null,i=null,s=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof n&&a.setBackref(e,o),r===null&&(r=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:r,ind:t,evt:"ins",reason:i,fired:s});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...r],i,s)}_onNodeDeleted(e,t,r=null,i=null){for(let s of Object.values(this._delSubscribers))s({node:e,pathlist:r,ind:t,evt:"del",reason:i});this._parent&&this._parentNode&&(r===null&&(r=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...r],i))}_subscribe(e,t,r){r!=null&&(t[e]=r)}subscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:r=null,insert:i=null,delete:s=null,any:o=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,r||o),this._subscribe(e,this._insSubscribers,i||o),this._subscribe(e,this._delSubscribers,s||o)}unsubscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:r=!1,insert:i=!1,delete:s=!1,any:o=!1}=t;(r||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,t=null,r=!0){let i=n.prototype.getNode.call(this,e,!0,!0);i&&i.setAttr(t,!0,!0,r)}getAttr(e=null,t=null,r=null){let i=this.getNode(e);return i?i.getAttr(t,r):r}delAttr(e=null,...t){let r=this.getNode(e);r&&r.delAttr(...t)}getInheritedAttributes(){return this._parentNode?this._parentNode.getInheritedAttributes():{}}getNodes(e=null){return e?[...this._nodes].filter(t=>e(t)):[...this._nodes]}getNodeByValue(e,t){for(let r of this._nodes){let i=r.value;if(i instanceof n){if(i.getItem(e)===t)return r}else if(i&&i.get&&i.get(e)===t)return r}return null}getNodeByAttr(e,t,r=!1,i=!1){let s=t===void 0,o=r&&typeof t=="string"?t.toLowerCase():t,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let d=r&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(s||d==o)return c}if(c._value instanceof n)if(i){let d=a(c._value);if(d)return d}else u.push(c._value)}for(let c of u){let d=a(c);if(d)return d}return null};return a(this)}isEmpty(e=!1,t=!1){if(this._nodes.length===0)return!0;for(let r of this._nodes){if(r._resolver!==null)return!1;let i=r.getValue(!0);if(i!=null&&!(e&&i===0)&&!(t&&i===""))return!1}return!0}query(e=null,t=null,r=!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[h,p]=e.split(":");u=this.getItem(h),e=p}c=e.split(",").map(h=>h.trim())}else c=e;let d=(h,p,m,b,g)=>{if(p==="#k")return h.label;if(p==="#p")return m;if(p==="#n")return h;if(typeof p=="function")return p(h);if(p==="#v"){let _=g();return b&&_ instanceof n?null:_}else if(p.startsWith("#v.")){let _=p.split(".").slice(1).join("."),w=g();return w&&w.getItem?w.getItem(_):null}else{if(p==="#__v")return h.getValue(!0);if(p.startsWith("#a")){let _=p.includes(".")?p.split(".").slice(1).join("."):null;return h.getAttr(_)}else{let _=g();return _&&_.getItem?_.getItem(p):null}}};function*f(){let h=0;function*p(m,b){for(let g of m._nodes){let _=b?`${b}.${g.label}`:g.label,w=!1,v,k=()=>(w||(v=g.getValue(l),w=!0),v);if((s&&o||(k()instanceof n?o:s))&&(t===null||t(g))&&(yield c.length===1?d(g,c[0],_,i,k):c.map(C=>d(g,C,_,i,k)),h++,a!==null&&h>=a))return;if(i){let C=k();if(C instanceof n&&(yield*p(C,_),a!==null&&h>=a))return}}}yield*p(u,"")}return r?f():[...f()]}getLeaves(){let e=[],t=(r,i)=>{for(let s of r._nodes){let o=i?`${i}.${s.label}`:s.label,a=s.getValue(!1);a instanceof n?t(a,o):e.push([o,a])}};return t(this,""),e}digest(e=null,t=null,r=!1){typeof t=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),r=t,t=null);let i=this.query(e,t,!1,!1,!0,!0,null,!1);if(r){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,t=!1){typeof e=="string"&&(e=e.split(","));let r=t?"#a.":"",i=e.map(s=>`${r}${s}`).join(",");return this.digest(i,null,!0)}sum(e="#v",t=!1,r=null){if(t!=null&&typeof t!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(r!=null&&typeof r!="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,r)){if(l==null||l===""){a=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(t)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}o+=l}return t&&a?null:o};return e.includes(",")?e.split(",").map(s=>i(s.trim())):i(e)}sort(e="#k:a"){let t=(i,s)=>i==null?[-1,""]:s&&typeof i=="string"?[0,i.toLowerCase()]:[0,i],r=(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=d=>t(d.label,u);else if(o.toLowerCase()==="#v")c=d=>t(d.value,u);else if(o.toLowerCase().startsWith("#a.")){let d=o.slice(3);c=f=>t(f.getAttr(d),u)}else c=d=>{let f=d.value,h=f instanceof n?f.getItem(o):f?f[o]:null;return t(h,u)};this._nodes._list.sort((d,f)=>{let h=r(c(d),c(f));return l?-h:h})}}return this}equalTo(e){return e instanceof n?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let t=null;e.includes("?")&&([e,t]=e.split("?",2));let r=this.getNode(e);return r===null?!1:t===null?!0:t.split("&").every(i=>i in r.attr)}else if(e&&e.label!==void 0)return[...this._nodes].includes(e);return!1}getResolver(e){let t=this.getNode(e);return t?t.resolver:null}setResolver(e,t){let r=this.getNode(e);r||(this.setItem(e,null),r=this.getNode(e)),r.resolver=t}setCallbackItem(e,t,r={}){let i=new xt({callback:t,...r});this.setResolver(e,i)}move(e,t,r=!0){this._nodes.move(e,t,r)}asDict(e=!1,t=!1,r=!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)),t&&(l=l.toLowerCase()),r&&a instanceof n&&(a=n.prototype.asDict.call(a,e,t,r,i)),Object.defineProperty(s,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return s}setdefault(e,t=null){let r=this.getNode(e);return r?r.value:(this.setItem(e,t),t)}deepcopy(e=!1){let t=this.createChildBag();for(let r of this._nodes){let i=r.getValue(!e);i instanceof n&&(i=i.deepcopy(e));let s=new t.nodeClass(t,r.label,i);s.setAttr({...r.attr},!1,!1,!1),s.nodeTag=r.nodeTag,s.xmlTag=r.xmlTag,t._nodes._list.push(s),t._nodes._dict[s.label]=s}return t}update(e,t=null,r=null,i=!1){if(!(e instanceof n)){for(let s in e){let o=e[s];(!i||o!==null||!this._nodes.has(s))&&this.setItem(s,o,null,">",!1,!1,r,!1,r!==!1)}return}for(let s of[...e]){let o=s.label,a=t==="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,r===null?!0:r,!0,!1),s.nodeTag!=null&&(c.nodeTag=s.nodeTag),s.xmlTag!=null&&(c.xmlTag=s.xmlTag),a)c.resolver=a,c.setValue(null,r===null?!0:r,null,null,!1,r);else{s.resolver&&(c.resolver=null);let d=c.getValue();l instanceof n&&d instanceof n&&!u?d.update(l,t,r,i):(!i||l!==null)&&c.setValue(l,r===null?!0:r,null,null,!1,r)}else{let d=this.setItem(o,a||l,s.attr,">",!1,!1,r,!1,r!==!1);d.nodeTag=s.nodeTag,d.xmlTag=s.xmlTag}}}_fillFromBag(e){this.clear();for(let t of e){let r=new this.nodeClass(this,t.label);r.replace(t),r.nodeTag=t.nodeTag,r.xmlTag=t.xmlTag,this._nodes._list.push(r),this._nodes._dict[r.label]=r}}_appendLiteral(e,t,r=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,r,i,s,null,!1);return t instanceof J?o.resolver=t:o._value=t,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,t={}){let r=Fo(t);if(e!=null&&!Rr(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,d=Array.isArray(l)?Array.from(l,(f,h)=>[`r_${String(h).padStart(c,"0")}`,f]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(f=>Object.prototype.propertyIsEnumerable.call(l,f)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[f,h]of d){let p=h;r&&(Rr(p)||Array.isArray(p))&&(p=this.createChildBag(),o(p,h,`${u}[${JSON.stringify(f)}]`)),a._appendLiteral(f,p)}}finally{s.delete(l)}};return e!=null&&o(i,e,"$"),this._replacePrepared(i)}_loadSource(e,t={}){return this.fillFrom(e,t)}replace(e){if(!(e instanceof n))throw new TypeError("Bag.replace expects a Bag");if(e===this)return this;let t=this.createChildBag();return t._fillFromBag(e),this._replacePrepared(t)}_replacePrepared(e){for(let r of this._nodes){r.parentBag=null;let i=r.getValue(!0);i instanceof n&&i.clearBackref()}let t=this._nodes;this._nodes=e._nodes,e._nodes=t,this._nodes._parentBag=this.backref?this:null,e._nodes._parentBag=null;for(let r of this._nodes)r.parentBag=this;for(let r of e._nodes)r._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:t=!0,deep:r=!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 d=e(u,c,l);if(d)return d;if(d==null&&r){let f=u.getValue(t);if(f instanceof n){let h=s(f,c);if(h)return h}}}return null};return s(this,i)}*traverse(){for(let e of this._nodes){yield e;let t=e.getValue(!0);t instanceof n&&(yield*t.traverse())}}*_iterNodesWithPaths(e=!0,t=""){for(let r of this._nodes){let i=t?`${t}.${r.label}`:r.label;yield[i,r];let s=r.getValue(e);s instanceof n&&(yield*s._iterNodesWithPaths(e,i))}}*_nodeFlattener(e=null){let t=e!==null,r=t?Object.create(null):null,i=0,s=new Map([["[]",this.constructor]]);for(let[o,a]of Tu(this)){let l=o.slice(0,-1),u=JSON.stringify(o),c=JSON.stringify(l),d=a.getValue(!0),f,h=null;if(a.resolver)f=Sn(a.resolver);else if(d instanceof n){let b=d.constructor,g=b.tytxSuffix;s.set(u,b),h=jo(b,Br(s.get(c),g)),f=`::${g}`}else d===null?f="::NN":f=At(d);if(a.attr&&Object.hasOwn(a.attr,Fe))throw new re(`node '${o}': the attribute '${Fe}' is reserved for the Bag class name`);let p=Qi(At(a.attr));h!==null&&(p[Fe]=h);let m=a.nodeTag;t?(yield[l.length?r[c]:null,a.label,m,f,p],d instanceof n&&(r[u]=i,e[i]=o,i++)):yield[l,a.label,m,f,p]}}toTytx(e="json",t=!1){let r=this._toTytxPayload(t),i=this.constructor.tytxSuffix;if(e==="json")return`${r}::${i}`;if(e==="msgpack")return xi(new Le(4,new TextEncoder().encode(`${i}:${r}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let s={};t={rows:[...this._nodeFlattener(s)],paths:s}}else t={rows:[...this._nodeFlattener(null)]};let r=this.constructor,i=jo(r,Br(null,r.tytxSuffix));return i!==null&&(t[Fe]=i),t.rows=t.rows.map(([s,o,a,l,u])=>[At(s),At(o),At(a),l,u]),t.paths&&(t.paths=At(t.paths)),U(t)}static fromTytx(e,t="json",r={}){if(Rr(t)&&(r=t,t="json"),Fo(r),typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError("fromTytx requires serialized text or bytes");if(t!=="json"&&t!=="msgpack")throw new TypeError(`Unsupported transport: ${t}`);t==="json"&&e instanceof Uint8Array&&(e=new TextDecoder().decode(e));let i=P(e,t==="json"?null:t);if(i instanceof n)return i;if(!Rr(i)&&!Array.isArray(i))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(i,r)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Br(null,t));let r=P(e);if(!r||!Array.isArray(r.rows))throw new re("Invalid TYTX Bag: expected rows");let i=r.paths,s=i!=null,o=Object.hasOwn(r,Fe)?Po(t,r[Fe]):Br(null,t),a=new o,l=new Map([["[]",a]]);for(let u of r.rows){if(!Array.isArray(u)||u.length!==5)throw new re("Invalid TYTX Bag row");let[c,d,f,h,p]=u,m=c??"";if(s){if(c!==null&&!Object.hasOwn(i,c))throw new re(`Unknown TYTX parent reference: ${c}`);m=c===null?"":i[c]}if(typeof m=="string"&&(m=m?m.split("."):[]),!Array.isArray(m))throw new re("Invalid TYTX parent path");let b=JSON.stringify(m);if(!l.has(b))throw new re(`Missing or undecodable TYTX parent branch: ${m}`);let g=l.get(b),_=JSON.stringify([...m,d]),w=h,v=Ki(w),k=Lo(p),E=Object.hasOwn(k,Fe)?k[Fe]:null;if(delete k[Fe],w instanceof n){let L=w.constructor.tytxSuffix,q=E!==null?Po(L,E):Br(g.constructor,L);w=new q,l.set(_,w)}else if(E!==null)throw new re(`node '${_}': the attribute '${Fe}' is reserved for the Bag class name of a branch`);let C=g._appendLiteral(d,v?null:w,k,v);C.nodeTag=f??null}return a}toXml(e={}){let{pretty:t=!1,encoding:r="UTF-8",docHeader:i=null,selfClosedTags:s=null}=e,o=this._bagToXml(s,t);return i===!0?o=`<?xml version='1.0' encoding='${r}'?>
13
+ `)}function gu(n){if(n=n||{},n.locator===void 0&&(n.locator=!0),this.assign=n.assign||Wt.assign,this.domHandler=n.domHandler||Ji,this.onError=n.onError||n.errorHandler,n.errorHandler&&typeof n.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");n.errorHandler&&n.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=n.normalizeLineEndings||mu,this.locator=!!n.locator,this.xmlns=this.assign(Object.create(null),n.xmlns)}gu.prototype.parseFromString=function(n,e){if(!Fp(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),r=du.XML_ENTITIES,i=t[""]||null;Pp(e)?(r=du.HTML_ENTITIES,i=Ro.HTML):e===pu.XML_SVG_IMAGE&&(i=Ro.SVG),t[""]=i,t.xml=t.xml||Ro.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 qp;a.errorHandler=s,a.domBuilder=s;var l=!Wt.isHTMLMimeType(e);return l&&typeof n!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(n)),t,r),s.doc.documentElement||a.errorHandler.fatalError("missing root element"),s.doc};function Ji(n){var e=n||{};this.mimeType=e.mimeType||pu.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 Or(n,e){e.lineNumber=n.lineNumber,e.columnNumber=n.columnNumber}Ji.prototype={startDocument:function(){var n=new Lp;this.doc=jp(this.mimeType)?n.createHTMLDocument(!1):n.createDocument(this.defaultNamespace,"")},startElement:function(n,e,t,r){var i=this.doc,s=i.createElementNS(n,t||e),o=r.length;Zi(this,s),this.currentElement=s,this.locator&&Or(this.locator,s);for(var a=0;a<o;a++){var n=r.getURI(a),l=r.getValue(a),t=r.getQName(a),u=i.createAttributeNS(n,t);this.locator&&Or(r.getLocator(a),u),u.value=u.nodeValue=l,s.setAttributeNode(u)}},endElement:function(n,e,t){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(n,e){},endPrefixMapping:function(n){},processingInstruction:function(n,e){var t=this.doc.createProcessingInstruction(n,e);this.locator&&Or(this.locator,t),Zi(this,t)},ignorableWhitespace:function(n,e,t){},characters:function(n,e,t){if(n=hu.apply(this,arguments),n){if(this.cdata)var r=this.doc.createCDATASection(n);else var r=this.doc.createTextNode(n);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(n)&&this.doc.appendChild(r),this.locator&&Or(this.locator,r)}},skippedEntity:function(n){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(n){n&&(n.lineNumber=0),this.locator=n},comment:function(n,e,t){n=hu.apply(this,arguments);var r=this.doc.createComment(n);this.locator&&Or(this.locator,r),Zi(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(n,e,t,r){var i=this.doc.implementation;if(i&&i.createDocumentType){var s=i.createDocumentType(n,e,t,r);this.locator&&Or(this.locator,s),Zi(this,s),this.doc.doctype=s}},reportError:function(n,e){if(typeof this.onError=="function")try{this.onError(n,e,this)}catch(t){throw new fu("Reporting "+n+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+n+"] "+e,Up(this.locator))},warning:function(n){this.reportError("warning",n)},error:function(n){this.reportError("error",n)},fatalError:function(n,e){throw this.reportError("fatalError",n),new fu(n,this.locator,e)}};function Up(n){if(n)return`
14
+ @#[line:`+n.lineNumber+",col:"+n.columnNumber+"]"}function hu(n,e,t){return typeof n=="string"?n.substr(e,t):n.length>=e+t||e?new java.lang.String(n,e,t)+"":n}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(n){Ji.prototype[n]=function(){return null}});function Zi(n,e){n.currentElement?n.currentElement.appendChild(e):n.doc.appendChild(e)}function Vp(n){if(n==="error")throw"onErrorStopParsing"}function zp(){throw"onWarningStopParsing"}Br.__DOMHandler=Ji;Br.DOMParser=gu;Br.normalizeLineEndings=mu;Br.onErrorStopParsing=Vp;Br.onWarningStopParsing=zp});var $o=dt(q=>{"use strict";var Rr=zt();q.assign=Rr.assign;q.hasDefaultHTMLNamespace=Rr.hasDefaultHTMLNamespace;q.isHTMLMimeType=Rr.isHTMLMimeType;q.isValidMimeType=Rr.isValidMimeType;q.MIME_TYPE=Rr.MIME_TYPE;q.NAMESPACE=Rr.NAMESPACE;var Ki=_n();q.DOMException=Ki.DOMException;q.DOMExceptionName=Ki.DOMExceptionName;q.ExceptionCode=Ki.ExceptionCode;q.ParseError=Ki.ParseError;var ce=Oo();q.Attr=ce.Attr;q.CDATASection=ce.CDATASection;q.CharacterData=ce.CharacterData;q.Comment=ce.Comment;q.Document=ce.Document;q.DocumentFragment=ce.DocumentFragment;q.DocumentType=ce.DocumentType;q.DOMImplementation=ce.DOMImplementation;q.Element=ce.Element;q.Entity=ce.Entity;q.EntityReference=ce.EntityReference;q.LiveNodeList=ce.LiveNodeList;q.NamedNodeMap=ce.NamedNodeMap;q.Node=ce.Node;q.NodeList=ce.NodeList;q.Notation=ce.Notation;q.ProcessingInstruction=ce.ProcessingInstruction;q.Text=ce.Text;q.XMLSerializer=ce.XMLSerializer;var Qi=bu();q.DOMParser=Qi.DOMParser;q.normalizeLineEndings=Qi.normalizeLineEndings;q.onErrorStopParsing=Qi.onErrorStopParsing;q.onWarningStopParsing=Qi.onWarningStopParsing});var yi=new WeakMap,Oa=`
15
+ --gramlot-toolbar-thickness:56px; --gramlot-toolbar-control-size:44px; --gramlot-toolbar-padding:6px;
16
+ `,Ba=`
17
+ box-sizing:border-box; height:100dvh; min-height:0; overflow:auto;
18
+ padding:env(safe-area-inset-top) max(12px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
19
+ background:var(--gramlot-chrome-background,color-mix(in srgb,var(--gramlot-surface-subtle,Canvas) 88%,var(--gramlot-ink,CanvasText) 12%)); color:var(--gramlot-ink,CanvasText);
20
+ `,xd=`
21
+ [data-gramlot-viewport]{--gramlot-toolbar-thickness:42px;--gramlot-toolbar-control-size:36px;--gramlot-toolbar-padding:2px 3px;}
22
+ :root[data-gramlot-touch="on"] [data-gramlot-viewport]{${Oa}}
23
+ :root[data-gramlot-touch="on"] [data-gramlot-viewport="root"]{${Ba}}
24
+ :root[data-gramlot-touch="on"] [data-gramlot-viewport="root"] > *{max-height:100%;}
25
+ @media(pointer:coarse){
26
+ :root:not([data-gramlot-touch="off"]) [data-gramlot-viewport]{${Oa}}
27
+ :root:not([data-gramlot-touch="off"]) [data-gramlot-viewport="root"]{${Ba}}
28
+ :root:not([data-gramlot-touch="off"]) [data-gramlot-viewport="root"] > *{max-height:100%;}
29
+ }
30
+ `,en=class n{static install({document:e,root:t}){return yi.has(t)||yi.set(t,new n(e,t)),yi.get(t)}constructor(e,t){this.document=e,this.root=t,this.releases=[],this.closed=!1,t.setAttribute("data-gramlot-viewport",e.defaultView.parent===e.defaultView?"root":"child");let r=e.querySelector('meta[name="viewport"]');r||(r=e.createElement("meta"),r.name="viewport",r.content="width=device-width,initial-scale=1",e.head.append(r));let i=r.content.split(",").map(s=>s.trim()).filter(s=>!s.startsWith("viewport-fit="));r.content=[...i,"viewport-fit=cover"].join(","),this.style=e.createElement("style"),this.style.textContent=xd,e.head.append(this.style)}subscribeAppearance(e){let t=this.document.defaultView,r=t.matchMedia("(prefers-color-scheme: dark)"),i=()=>{let a=t.getComputedStyle(this.document.documentElement).colorScheme;e({dark:a==="dark"||!["light","dark"].includes(a)&&r.matches})},s=new t.MutationObserver(i);s.observe(this.document.documentElement,{attributes:!0,attributeFilter:["data-theme","style","class"]}),r.addEventListener("change",i),i();let o=()=>{s.disconnect(),r.removeEventListener("change",i)};return this.releases.push(o),o}dispose(){if(!this.closed){this.closed=!0;for(let e of this.releases)e();this.style.remove(),this.root.removeAttribute("data-gramlot-viewport"),yi.delete(this.root)}}};var tn=class{#e=new Map;registerGroup(e,t={}){if(typeof e!="string"||!e||e.includes(":"))throw new TypeError("Extension command namespace must be nonempty and unqualified");if(this.#e.has(e))throw new Error(`Duplicate command namespace: ${e}`);if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(i=>!["author","description"].includes(i))||Object.values(t).some(i=>typeof i!="string"))throw new TypeError(`Invalid command group metadata: ${e}`);let r=new Map;return this.#e.set(e,{metadata:{...t},commands:r}),Object.freeze({register(i,s){if(typeof i!="string"||!i||i.includes(":"))throw new TypeError("Invalid command name");if(r.has(i))throw new Error(`Duplicate command: ${e}:${i}`);if(!s||typeof s!="object"||Array.isArray(s)||!Object.hasOwn(s,"label")||!Object.hasOwn(s,"publish")||Object.keys(s).some(o=>!["label","publish","icon","iconSrc","tooltip"].includes(o))||Object.values(s).some(o=>typeof o!="string"))throw new TypeError(`Invalid command definition: ${e}:${i}`);r.set(i,Object.freeze({...s}))}})}get(e){let t=e.indexOf(":");return this.#e.get(e.slice(0,t))?.commands.get(e.slice(t+1))}toDocument(){return{document_format:{name:"gramlot_commands",version:"1.0"},groups:Object.fromEntries([...this.#e].map(([e,{metadata:t,commands:r}])=>[e,{...t,commands:Object.fromEntries(r)}]))}}};var rn=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:r="/gramlot/close",navigator:i=globalThis.navigator,XMLHttpRequest:s=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=r,this.navigator=i,this.XMLHttpRequest=s}get supportsCallSync(){return!0}async call(e,t){let r=await this.fetcher(this.rpcUrl,{method:"POST",credentials:"same-origin",signal:t,headers:{"Content-Type":"application/json"},body:e});if(r.status!==200)throw new Error(`rpc failed: HTTP ${r.status}`);return r.text()}callSync(e){let t=new this.XMLHttpRequest;if(t.open("POST",this.rpcUrl,!1),t.setRequestHeader("Content-Type","application/json"),t.send(e),t.status!==200)throw new Error(`rpc failed: HTTP ${t.status}`);return t.responseText}close(e){if(typeof this.closeUrl!="string"||!this.closeUrl.trim())throw new TypeError("HttpTransport.closeUrl must be nonempty text");if(typeof this.navigator?.sendBeacon!="function")throw new TypeError("HttpTransport requires navigator.sendBeacon");let t=new Blob([JSON.stringify({pageId:e})],{type:"application/json"});try{this.navigator.sendBeacon(this.closeUrl,t)}catch(r){if(r.name==="TypeError")throw r}}dispose(){}};var ft=class{createTransport({rpcUrl:e,closeUrl:t,document:r}){let i=r.defaultView;return new rn(e,{closeUrl:t,navigator:i.navigator,XMLHttpRequest:i.XMLHttpRequest})}};function H(n){if(typeof n!="string"||!["^","="].includes(n[0])||n.startsWith("=="))return null;let e=n.indexOf(":");if(e<0)return null;let t=n[e+1]==="=";return{pointer:n.slice(0,e),expression:t,body:n.slice(e+(t?2:1))}}var Ra=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function Pt(n,e){let t="",r=!1;for(let i=0;i<n.length;){if(n[i]!=="{"&&n[i]!=="}"){t+=n[i++];continue}let s=n.slice(i).match(Ra);if(!s)throw new SyntaxError("Invalid pointer template placeholder");let o=s[1]??"",a=o.startsWith("?"),l=e(a?o.slice(1):o);l==null||l===""&&!a?r=!0:t+=String(l),i+=s[0].length}return r?null:t}function nn(n){let e=[],t=new Set,r="",i=!0;for(let s=0;s<n.length;){let o=s,a=n[s];if(a==='"'||a==="'"||a==="`"){for(s++;s<n.length;){if(n[s]==="\\"){s+=2;continue}if(n[s++]===a)break}r+=n.slice(o,s),i=!1;continue}if(n.startsWith("//",s)){s=n.indexOf(`
31
+ `,s),s<0&&(s=n.length),r+=n.slice(o,s);continue}if(n.startsWith("/*",s)){let c=n.indexOf("*/",s+2);s=c<0?n.length:c+2,r+=n.slice(o,s);continue}if(a==="/"&&i){let c=!1;for(s++;s<n.length;){let d=n[s++];if(d==="\\"){s++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(n[s]??"")&&s<n.length;)s++;r+=n.slice(o,s),i=!1;continue}let l=a==="{"?n.slice(s).match(Ra):null;if(l){let c=l[1]??"";if(c.startsWith("?"))throw new SyntaxError("Optional slots are supported in pointer templates only");r+=`_pointerValues[${e.length}]`,e.push(c),s+=l[0].length,i=!1;continue}let u=n.slice(s).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),r+=u[0],s+=u[0].length,i=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}r+=a,s++,/\s/.test(a)||(i=/[([{,:;=!?&|+*%~<>\/-]/.test(a))}return{text:r,slots:e,identifiers:t}}function $a(n,e,t=()=>null){let r=new Map,i=[],s=o=>{if(r.has(o))return r.get(o);if(!n.has(o))throw new Error(`Referenced Source attribute '${o}' does not exist`);if(i.includes(o))throw new Error(`Cyclic attribute dependency: ${[...i,o].join(" -> ")}`);i.push(o);try{let a=n.get(o),l=typeof o=="string"?H(a):null,u=e.get(o);if(l){let c=d=>d?s(d):e.get(o);if(l.expression){let d=nn(l.body);u=t(o,a,d,d.slots.map(c))}else u=Pt(l.body,c),e.get(o)==null&&(u=null)}return r.set(o,u),u}finally{i.pop()}};return new Map([...n.keys()].map(o=>[o,s(o)]))}function Ge(n,e){let t=new Map([...Object.entries(n.getAttr()),...n.fixedAttrItems()]),r=new Set,i=[],s=o=>{let a=H(o);if(!a)return;let l=[];a.expression?l.push(...nn(a.body).slots):Pt(a.body,u=>(l.push(u),""));for(let u of l.filter(Boolean)){if(!t.has(u))throw new Error(`Referenced Source attribute '${u}' does not exist`);if(i.includes(u))throw new Error(`Cyclic attribute dependency: ${[...i,u].join(" -> ")}`);r.has(u)||(i.push(u),s(t.get(u)),i.pop(),r.add(u))}};return s(e),r}var pr=9e15,gt=1e9,Js="0123456789abcdef",xi="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ki="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ks={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-pr,maxE:pr,crypto:!1},ja,it,R=!0,Ti="[DecimalError] ",mt=Ti+"Invalid argument: ",Fa=Ti+"Precision limit exceeded",qa=Ti+"crypto unavailable",Ua="[object Decimal]",ve=Math.floor,le=Math.pow,kd=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ad=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Td=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Va=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,qe=1e7,O=7,Dd=9007199254740991,Cd=xi.length-1,Qs=ki.length-1,v={toStringTag:Ua};v.absoluteValue=v.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),N(n)};v.ceil=function(){return N(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(n,e){var t,r=this,i=r.constructor;if(n=new i(n),e=new i(e),!n.s||!e.s)return new i(NaN);if(n.gt(e))throw Error(mt+e);return t=r.cmp(n),t<0?n:r.cmp(e)>0?e:new i(r)};v.comparedTo=v.cmp=function(n){var e,t,r,i,s=this,o=s.d,a=(n=new s.constructor(n)).d,l=s.s,u=n.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!==n.e)return s.e>n.e^l<0?1:-1;for(r=o.length,i=a.length,e=0,t=r<i?r:i;e<t;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return r===i?0:r>i^l<0?1:-1};v.cosine=v.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+O,r.rounding=1,t=Sd(r,Xa(r,t)),r.precision=n,r.rounding=e,N(it==2||it==3?t.neg():t,n,e,!0)):new r(1):new r(NaN)};v.cubeRoot=v.cbrt=function(){var n,e,t,r,i,s,o,a,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(R=!1,s=c.s*le(c.s*c,1/3),!s||Math.abs(s)==1/0?(t=pe(c.d),n=c.e,(s=(n-t.length+1)%3)&&(t+=s==1||s==-2?"0":"00"),s=le(t,1/3),n=ve((n+1)/3)-(n%3==(n<0?-1:2)),s==1/0?t="5e"+n:(t=s.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new d(t),r.s=c.s):r=new d(s.toString()),o=(n=d.precision)+3;;)if(a=r,l=a.times(a).times(a),u=l.plus(c),r=Z(u.plus(c).times(a),u.plus(l),o+2,1),pe(a.d).slice(0,o)===(t=pe(r.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(N(a,n+1,0),a.times(a).times(a).eq(c))){r=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(N(r,n+1,1),e=!r.times(r).times(r).eq(c));break}return R=!0,N(r,n,d.rounding,e)};v.decimalPlaces=v.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-ve(this.e/O))*O,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};v.dividedBy=v.div=function(n){return Z(this,new this.constructor(n))};v.dividedToIntegerBy=v.divToInt=function(n){var e=this,t=e.constructor;return N(Z(e,new t(n),0,1,1),t.precision,t.rounding)};v.equals=v.eq=function(n){return this.cmp(n)===0};v.floor=function(){return N(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(n){return this.cmp(n)>0};v.greaterThanOrEqualTo=v.gte=function(n){var e=this.cmp(n);return e==1||e===0};v.hyperbolicCosine=v.cosh=function(){var n,e,t,r,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;t=o.precision,r=o.rounding,o.precision=t+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(n=Math.ceil(i/3),e=(1/Ci(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),s=mr(o,1,s.times(e),new o(1),!0);for(var l,u=n,c=new o(8);u--;)l=s.times(s),s=a.minus(l.times(c.minus(l.times(c))));return N(s,o.precision=t,o.rounding=r,!0)};v.hyperbolicSine=v.sinh=function(){var n,e,t,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(e=s.precision,t=s.rounding,s.precision=e+Math.max(i.e,i.sd())+4,s.rounding=1,r=i.d.length,r<3)i=mr(s,2,i,i,!0);else{n=1.4*Math.sqrt(r),n=n>16?16:n|0,i=i.times(1/Ci(5,n)),i=mr(s,2,i,i,!0);for(var o,a=new s(5),l=new s(16),u=new s(20);n--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(u))))}return s.precision=e,s.rounding=t,N(i,e,t,!0)};v.hyperbolicTangent=v.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,Z(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)};v.inverseCosine=v.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,i=e.rounding;return t!==-1?t===0?n.isNeg()?Xe(e,r,i):new e(0):new e(NaN):n.isZero()?Xe(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=r,e.rounding=i,n.times(2))};v.inverseHyperbolicCosine=v.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,R=!1,t=t.times(t).minus(1).sqrt().plus(t),R=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)};v.inverseHyperbolicSine=v.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,R=!1,t=t.times(t).plus(1).sqrt().plus(t),R=!0,r.precision=n,r.rounding=e,t.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var n,e,t,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(n=s.precision,e=s.rounding,r=i.sd(),Math.max(r,n)<2*-i.e-1?N(new s(i),n,e,!0):(s.precision=t=r-i.e,i=Z(i.plus(1),new s(1).minus(i),t+n,1),s.precision=n+4,s.rounding=1,i=i.ln(),s.precision=n,s.rounding=e,i.times(.5))):new s(NaN)};v.inverseSine=v.asin=function(){var n,e,t,r,i=this,s=i.constructor;return i.isZero()?new s(i):(e=i.abs().cmp(1),t=s.precision,r=s.rounding,e!==-1?e===0?(n=Xe(s,t+4,r).times(.5),n.s=i.s,n):new s(NaN):(s.precision=t+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=r,i.times(2)))};v.inverseTangent=v.atan=function(){var n,e,t,r,i,s,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&d+4<=Qs)return o=Xe(c,d+4,f).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(d+4<=Qs)return o=Xe(c,d+4,f).times(.5),o.s=u.s,o}for(c.precision=a=d+10,c.rounding=1,t=Math.min(28,a/O+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(R=!1,e=Math.ceil(a/O),r=1,l=u.times(u),o=new c(u),i=u;n!==-1;)if(i=i.times(l),s=o.minus(i.div(r+=2)),i=i.times(l),o=s.plus(i.div(r+=2)),o.d[e]!==void 0)for(n=e;o.d[n]===s.d[n]&&n--;);return t&&(o=o.times(2<<t-1)),R=!0,N(o,c.precision=d,c.rounding=f,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&ve(this.e/O)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(n){return this.cmp(n)<0};v.lessThanOrEqualTo=v.lte=function(n){return this.cmp(n)<1};v.logarithm=v.log=function(n){var e,t,r,i,s,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding,h=5;if(n==null)n=new c(10),e=!0;else{if(n=new c(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new c(NaN);e=n.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new c(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)s=!0;else{for(i=t[0];i%10===0;)i/=10;s=i!==1}if(R=!1,a=d+h,o=pt(u,a),r=e?Ai(c,a+10):pt(n,a),l=Z(o,r,a,1),sn(l.d,i=d,f))do if(a+=10,o=pt(u,a),r=e?Ai(c,a+10):pt(n,a),l=Z(o,r,a,1),!s){+pe(l.d).slice(i+1,i+15)+1==1e14&&(l=N(l,d+1,0));break}while(sn(l.d,i+=10,f));return R=!0,N(l,d,f)};v.minus=v.sub=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,m=h.constructor;if(n=new m(n),!h.d||!n.d)return!h.s||!n.s?n=new m(NaN):h.d?n.s=-n.s:n=new m(n.d||h.s!==n.s?h:NaN),n;if(h.s!=n.s)return n.s=-n.s,h.plus(n);if(u=h.d,f=n.d,a=m.precision,l=m.rounding,!u[0]||!f[0]){if(f[0])n.s=-n.s;else if(u[0])n=new m(h);else return new m(l===3?-0:0);return R?N(n,a,l):n}if(t=ve(n.e/O),c=ve(h.e/O),u=u.slice(),s=c-t,s){for(d=s<0,d?(e=u,s=-s,o=f.length):(e=f,t=c,o=u.length),r=Math.max(Math.ceil(a/O),o)+2,s>r&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse()}else{for(r=u.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(u[r]!=f[r]){d=u[r]<f[r];break}s=0}for(d&&(e=u,u=f,f=e,n.s=-n.s),o=u.length,r=f.length-o;r>0;--r)u[o++]=0;for(r=f.length;r>s;){if(u[--r]<f[r]){for(i=r;i&&u[--i]===0;)u[i]=qe-1;--u[i],u[r]+=qe}u[r]-=f[r]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=Di(u,t),R?N(n,a,l):n):new m(l===3?-0:0)};v.modulo=v.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?N(new r(t),r.precision,r.rounding):(R=!1,r.modulo==9?(e=Z(t,n.abs(),0,3,1),e.s*=n.s):e=Z(t,n,0,r.modulo,1),e=e.times(n),R=!0,t.minus(e))};v.naturalExponential=v.exp=function(){return eo(this)};v.naturalLogarithm=v.ln=function(){return pt(this)};v.negated=v.neg=function(){var n=new this.constructor(this);return n.s=-n.s,N(n)};v.plus=v.add=function(n){var e,t,r,i,s,o,a,l,u,c,d=this,f=d.constructor;if(n=new f(n),!d.d||!n.d)return!d.s||!n.s?n=new f(NaN):d.d||(n=new f(n.d||d.s===n.s?d:NaN)),n;if(d.s!=n.s)return n.s=-n.s,d.minus(n);if(u=d.d,c=n.d,a=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(n=new f(d)),R?N(n,a,l):n;if(s=ve(d.e/O),r=ve(n.e/O),u=u.slice(),i=s-r,i){for(i<0?(t=u,i=-i,o=c.length):(t=c,r=s,o=u.length),s=Math.ceil(a/O),o=s>o?s+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=u.length,i=c.length,o-i<0&&(i=o,t=c,c=u,u=t),e=0;i;)e=(u[--i]=u[i]+c[i]+e)/qe|0,u[i]%=qe;for(e&&(u.unshift(e),++r),o=u.length;u[--o]==0;)u.pop();return n.d=u,n.e=Di(u,r),R?N(n,a,l):n};v.precision=v.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(mt+n);return t.d?(e=za(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};v.round=function(){var n=this,e=n.constructor;return N(new e(n),n.e+1,e.rounding)};v.sine=v.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+O,r.rounding=1,t=Id(r,Xa(r,t)),r.precision=n,r.rounding=e,N(it>2?t.neg():t,n,e,!0)):new r(NaN)};v.squareRoot=v.sqrt=function(){var n,e,t,r,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(R=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=pe(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=ve((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),r=new c(e)):r=new c(u.toString()),t=(l=c.precision)+3;;)if(s=r,r=s.plus(Z(o,s,t+2,1)).times(.5),pe(s.d).slice(0,t)===(e=pe(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(N(s,l+1,0),s.times(s).eq(o))){r=s;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(N(r,l+1,1),n=!r.times(r).eq(o));break}return R=!0,N(r,l,c.rounding,n)};v.tangent=v.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,t=t.sin(),t.s=1,t=Z(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,N(it==2||it==4?t.neg():t,n,e,!0)):new r(NaN)};v.times=v.mul=function(n){var e,t,r,i,s,o,a,l,u,c=this,d=c.constructor,f=c.d,h=(n=new d(n)).d;if(n.s*=c.s,!f||!f[0]||!h||!h[0])return new d(!n.s||f&&!f[0]&&!h||h&&!h[0]&&!f?NaN:!f||!h?n.s/0:n.s*0);for(t=ve(c.e/O)+ve(n.e/O),l=f.length,u=h.length,l<u&&(s=f,f=h,h=s,o=l,l=u,u=o),s=[],o=l+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=l+r;i>r;)a=s[i]+h[r]*f[i-r-1]+e,s[i--]=a%qe|0,e=a/qe|0;s[i]=(s[i]+e)%qe|0}for(;!s[--o];)s.pop();return e?++t:s.shift(),n.d=s,n.e=Di(s,t),R?N(n,d.precision,d.rounding):n};v.toBinary=function(n,e){return to(this,2,n,e)};v.toDecimalPlaces=v.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),n===void 0?t:(Ce(n,0,gt),e===void 0?e=r.rounding:Ce(e,0,8),N(t,n+t.e+1,e))};v.toExponential=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=Ye(r,!0):(Ce(n,0,gt),e===void 0?e=i.rounding:Ce(e,0,8),r=N(new i(r),n+1,e),t=Ye(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t};v.toFixed=function(n,e){var t,r,i=this,s=i.constructor;return n===void 0?t=Ye(i):(Ce(n,0,gt),e===void 0?e=s.rounding:Ce(e,0,8),r=N(new s(i),n+i.e+1,e),t=Ye(r,!1,n+r.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};v.toFraction=function(n){var e,t,r,i,s,o,a,l,u,c,d,f,h=this,m=h.d,p=h.constructor;if(!m)return new p(h);if(u=t=new p(1),r=l=new p(0),e=new p(r),s=e.e=za(m)-h.e-1,o=s%O,e.d[0]=le(10,o<0?O+o:o),n==null)n=s>0?e:u;else{if(a=new p(n),!a.isInt()||a.lt(u))throw Error(mt+a);n=a.gt(e)?s>0?e:u:a}for(R=!1,a=new p(pe(m)),c=p.precision,p.precision=s=m.length*O*2;d=Z(a,e,0,1,1),i=t.plus(d.times(r)),i.cmp(n)!=1;)t=r,r=i,i=u,u=l.plus(d.times(i)),l=i,i=e,e=a.minus(d.times(i)),a=i;return i=Z(n.minus(t),r,0,1,1),l=l.plus(i.times(u)),t=t.plus(i.times(r)),l.s=u.s=h.s,f=Z(u,r,s,1).minus(h).abs().cmp(Z(l,t,s,1).minus(h).abs())<1?[u,r]:[l,t],p.precision=c,R=!0,f};v.toHexadecimal=v.toHex=function(n,e){return to(this,16,n,e)};v.toNearest=function(n,e){var t=this,r=t.constructor;if(t=new r(t),n==null){if(!t.d)return t;n=new r(1),e=r.rounding}else{if(n=new r(n),e===void 0?e=r.rounding:Ce(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(R=!1,t=Z(t,n,0,e,1).times(n),R=!0,N(t)):(n.s=t.s,t=n),t};v.toNumber=function(){return+this};v.toOctal=function(n,e){return to(this,8,n,e)};v.toPower=v.pow=function(n){var e,t,r,i,s,o,a=this,l=a.constructor,u=+(n=new l(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new l(le(+a,u));if(a=new l(a),a.eq(1))return a;if(r=l.precision,s=l.rounding,n.eq(1))return N(a,r,s);if(e=ve(n.e/O),e>=n.d.length-1&&(t=u<0?-u:u)<=Dd)return i=Ha(l,a,t,r),n.s<0?new l(1).div(i):N(i,r,s);if(o=a.s,o<0){if(e<n.d.length-1)return new l(NaN);if((n.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=le(+a,u),e=t==0||!isFinite(t)?ve(u*(Math.log("0."+pe(a.d))/Math.LN10+a.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(R=!1,l.rounding=a.s=1,t=Math.min(12,(e+"").length),i=eo(n.times(pt(a,r+t)),r),i.d&&(i=N(i,r+5,1),sn(i.d,r,s)&&(e=r+10,i=N(eo(n.times(pt(a,e+t)),e),e+5,1),+pe(i.d).slice(r+1,r+15)+1==1e14&&(i=N(i,r+1,0)))),i.s=o,R=!0,l.rounding=s,N(i,r,s))};v.toPrecision=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=Ye(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Ce(n,1,gt),e===void 0?e=i.rounding:Ce(e,0,8),r=N(new i(r),n,e),t=Ye(r,n<=r.e||r.e<=i.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t};v.toSignificantDigits=v.toSD=function(n,e){var t=this,r=t.constructor;return n===void 0?(n=r.precision,e=r.rounding):(Ce(n,1,gt),e===void 0?e=r.rounding:Ce(e,0,8)),N(new r(t),n,e)};v.toString=function(){var n=this,e=n.constructor,t=Ye(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};v.truncated=v.trunc=function(){return N(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var n=this,e=n.constructor,t=Ye(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function pe(n){var e,t,r,i=n.length-1,s="",o=n[0];if(i>0){for(s+=o,e=1;e<i;e++)r=n[e]+"",t=O-r.length,t&&(s+=ht(t)),s+=r;o=n[e],r=o+"",t=O-r.length,t&&(s+=ht(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function Ce(n,e,t){if(n!==~~n||n<e||n>t)throw Error(mt+n)}function sn(n,e,t,r){var i,s,o,a;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=O,i=0):(i=Math.ceil((e+1)/O),e%=O),s=le(10,O-e),a=n[i]%s|0,r==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==s||t>3&&a+1==s/2)&&(n[i+1]/s/100|0)==le(10,e-2)-1||(a==s/2||a==0)&&(n[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=(r||t<4)&&a==9999||!r&&t>3&&a==4999):o=((r||t<4)&&a+1==s||!r&&t>3&&a+1==s/2)&&(n[i+1]/s/1e3|0)==le(10,e-3)-1,o}function vi(n,e,t){for(var r,i=[0],s,o=0,a=n.length;o<a;){for(s=i.length;s--;)i[s]*=e;for(i[0]+=Js.indexOf(n.charAt(o++)),r=0;r<i.length;r++)i[r]>t-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/t|0,i[r]%=t)}return i.reverse()}function Sd(n,e){var t,r,i;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),i=(1/Ci(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),n.precision+=t,e=mr(n,1,e.times(i),new n(1));for(var s=t;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}var Z=(function(){function n(r,i,s){var o,a=0,l=r.length;for(r=r.slice();l--;)o=r[l]*i+a,r[l]=o%s|0,a=o/s|0;return a&&r.unshift(a),r}function e(r,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(r[a]!=i[a]){l=r[a]>i[a]?1:-1;break}return l}function t(r,i,s,o){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*o+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o,a,l){var u,c,d,f,h,m,p,b,g,_,w,E,D,y,T,S,I,W,ee,se,he=r.constructor,Y=r.s==i.s?1:-1,ae=r.d,L=i.d;if(!ae||!ae[0]||!L||!L[0])return new he(!r.s||!i.s||(ae?L&&ae[0]==L[0]:!L)?NaN:ae&&ae[0]==0||!L?Y*0:Y/0);for(l?(h=1,c=r.e-i.e):(l=qe,h=O,c=ve(r.e/h)-ve(i.e/h)),ee=L.length,I=ae.length,g=new he(Y),_=g.d=[],d=0;L[d]==(ae[d]||0);d++);if(L[d]>(ae[d]||0)&&c--,s==null?(y=s=he.precision,o=he.rounding):a?y=s+(r.e-i.e)+1:y=s,y<0)_.push(1),m=!0;else{if(y=y/h+2|0,d=0,ee==1){for(f=0,L=L[0],y++;(d<I||f)&&y--;d++)T=f*l+(ae[d]||0),_[d]=T/L|0,f=T%L|0;m=f||d<I}else{for(f=l/(L[0]+1)|0,f>1&&(L=n(L,f,l),ae=n(ae,f,l),ee=L.length,I=ae.length),S=ee,w=ae.slice(0,ee),E=w.length;E<ee;)w[E++]=0;se=L.slice(),se.unshift(0),W=L[0],L[1]>=l/2&&++W;do f=0,u=e(L,w,ee,E),u<0?(D=w[0],ee!=E&&(D=D*l+(w[1]||0)),f=D/W|0,f>1?(f>=l&&(f=l-1),p=n(L,f,l),b=p.length,E=w.length,u=e(p,w,b,E),u==1&&(f--,t(p,ee<b?se:L,b,l))):(f==0&&(u=f=1),p=L.slice()),b=p.length,b<E&&p.unshift(0),t(w,p,E,l),u==-1&&(E=w.length,u=e(L,w,ee,E),u<1&&(f++,t(w,ee<E?se:L,E,l))),E=w.length):u===0&&(f++,w=[0]),_[d++]=f,u&&w[0]?w[E++]=ae[S]||0:(w=[ae[S]],E=1);while((S++<I||w[0]!==void 0)&&y--);m=w[0]!==void 0}_[0]||_.shift()}if(h==1)g.e=c,ja=m;else{for(d=1,f=_[0];f>=10;f/=10)d++;g.e=d+c*h-1,N(g,a?s+g.e+1:s,o,m)}return g}})();function N(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor;e:if(e!=null){if(d=n.d,!d)return n;for(i=1,a=d[0];a>=10;a/=10)i++;if(s=e-i,s<0)s+=O,o=e,c=d[f=0],l=c/le(10,i-o-1)%10|0;else if(f=Math.ceil((s+1)/O),a=d.length,f>=a)if(r){for(;a++<=f;)d.push(0);c=l=0,i=1,s%=O,o=s-O+1}else break e;else{for(c=a=d[f],i=1;a>=10;a/=10)i++;s%=O,o=s-O+i,l=o<0?0:c/le(10,i-o-1)%10|0}if(r=r||e<0||d[f+1]!==void 0||(o<0?c:c%le(10,i-o-1)),u=t<4?(l||r)&&(t==0||t==(n.s<0?3:2)):l>5||l==5&&(t==4||r||t==6&&(s>0?o>0?c/le(10,i-o):0:d[f-1])%10&1||t==(n.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=n.e+1,d[0]=le(10,(O-e%O)%O),n.e=-e||0):d[0]=n.e=0,n;if(s==0?(d.length=f,a=1,f--):(d.length=f+1,a=le(10,O-s),d[f]=o>0?(c/le(10,i-o)%le(10,o)|0)*a:0),u)for(;;)if(f==0){for(s=1,o=d[0];o>=10;o/=10)s++;for(o=d[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(n.e++,d[0]==qe&&(d[0]=1));break}else{if(d[f]+=a,d[f]!=qe)break;d[f--]=0,a=1}for(s=d.length;d[--s]===0;)d.pop()}return R&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function Ye(n,e,t){if(!n.isFinite())return Ga(n);var r,i=n.e,s=pe(n.d),o=s.length;return e?(t&&(r=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+ht(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):i<0?(s="0."+ht(-i-1)+s,t&&(r=t-o)>0&&(s+=ht(r))):i>=o?(s+=ht(i+1-o),t&&(r=t-i-1)>0&&(s=s+"."+ht(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),t&&(r=t-o)>0&&(i+1===o&&(s+="."),s+=ht(r))),s}function Di(n,e){var t=n[0];for(e*=O;t>=10;t/=10)e++;return e}function Ai(n,e,t){if(e>Cd)throw R=!0,t&&(n.precision=t),Error(Fa);return N(new n(xi),e,1,!0)}function Xe(n,e,t){if(e>Qs)throw Error(Fa);return N(new n(ki),e,t,!0)}function za(n){var e=n.length-1,t=e*O+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function ht(n){for(var e="";n--;)e+="0";return e}function Ha(n,e,t,r){var i,s=new n(1),o=Math.ceil(r/O+4);for(R=!1;;){if(t%2&&(s=s.times(e),La(s.d,o)&&(i=!0)),t=ve(t/2),t===0){t=s.d.length-1,i&&s.d[t]===0&&++s.d[t];break}e=e.times(e),La(e.d,o)}return R=!0,s}function Ma(n){return n.d[n.d.length-1]&1}function Wa(n,e,t){for(var r,i,s=new n(e[0]),o=0;++o<e.length;){if(i=new n(e[o]),!i.s){s=i;break}r=s.cmp(i),(r===t||r===0&&s.s===t)&&(s=i)}return s}function eo(n,e){var t,r,i,s,o,a,l,u=0,c=0,d=0,f=n.constructor,h=f.rounding,m=f.precision;if(!n.d||!n.d[0]||n.e>17)return new f(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(e==null?(R=!1,l=m):l=e,a=new f(.03125);n.e>-2;)n=n.times(a),d+=5;for(r=Math.log(le(2,d))/Math.LN10*2+5|0,l+=r,t=s=o=new f(1),f.precision=l;;){if(s=N(s.times(n),l,1),t=t.times(++c),a=o.plus(Z(s,t,l,1)),pe(a.d).slice(0,l)===pe(o.d).slice(0,l)){for(i=d;i--;)o=N(o.times(o),l,1);if(e==null)if(u<3&&sn(o.d,l-r,h,u))f.precision=l+=10,t=s=a=new f(1),c=0,u++;else return N(o,f.precision=m,h,R=!0);else return f.precision=m,o}o=a}}function pt(n,e){var t,r,i,s,o,a,l,u,c,d,f,h=1,m=10,p=n,b=p.d,g=p.constructor,_=g.rounding,w=g.precision;if(p.s<0||!b||!b[0]||!p.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:p.s!=1?NaN:b?0:p);if(e==null?(R=!1,c=w):c=e,g.precision=c+=m,t=pe(b),r=t.charAt(0),Math.abs(s=p.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)p=p.times(n),t=pe(p.d),r=t.charAt(0),h++;s=p.e,r>1?(p=new g("0."+t),s++):p=new g(r+"."+t.slice(1))}else return u=Ai(g,c+2,w).times(s+""),p=pt(new g(r+"."+t.slice(1)),c-m).plus(u),g.precision=w,e==null?N(p,w,_,R=!0):p;for(d=p,l=o=p=Z(p.minus(1),p.plus(1),c,1),f=N(p.times(p),c,1),i=3;;){if(o=N(o.times(f),c,1),u=l.plus(Z(o,new g(i),c,1)),pe(u.d).slice(0,c)===pe(l.d).slice(0,c))if(l=l.times(2),s!==0&&(l=l.plus(Ai(g,c+2,w).times(s+""))),l=Z(l,new g(h),c,1),e==null)if(sn(l.d,c-m,_,a))g.precision=c+=m,u=o=p=Z(d.minus(1),d.plus(1),c,1),f=N(p.times(p),c,1),i=a=1;else return N(l,g.precision=w,_,R=!0);else return g.precision=w,l;l=u,i+=2}}function Ga(n){return String(n.s*n.s/0)}function Ei(n,e){var t,r,i;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%O,t<0&&(r+=O),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=O;r<i;)n.d.push(+e.slice(r,r+=O));e=e.slice(r),r=O-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),R&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Nd(n,e){var t,r,i,s,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Va.test(e))return Ei(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(Ad.test(e))t=16,e=e.toLowerCase();else if(kd.test(e))t=2;else if(Td.test(e))t=8;else throw Error(mt+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,r=n.constructor,o&&(e=e.replace(".",""),a=e.length,s=a-s,i=Ha(r,new r(t),s,s*2)),u=vi(e,t,qe),c=u.length-1,s=c;u[s]===0;--s)u.pop();return s<0?new r(n.s*0):(n.e=Di(u,c),n.d=u,R=!1,o&&(n=Z(n,i,a*4)),l&&(n=n.times(Math.abs(l)<54?le(2,l):on.pow(2,l))),R=!0,n)}function Id(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:mr(n,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/Ci(5,t)),e=mr(n,2,e,e);for(var i,s=new n(5),o=new n(16),a=new n(20);t--;)i=e.times(e),e=e.times(s.plus(i.times(o.times(i).minus(a))));return e}function mr(n,e,t,r,i){var s,o,a,l,u=1,c=n.precision,d=Math.ceil(c/O);for(R=!1,l=t.times(t),a=new n(r);;){if(o=Z(a.times(l),new n(e++*e++),c,1),a=i?r.plus(o):r.minus(o),r=Z(o.times(l),new n(e++*e++),c,1),o=a.plus(r),o.d[d]!==void 0){for(s=d;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=r,r=o,o=s,u++}return R=!0,o.d.length=d+1,o}function Ci(n,e){for(var t=n;--e;)t*=n;return t}function Xa(n,e){var t,r=e.s<0,i=Xe(n,n.precision,1),s=i.times(.5);if(e=e.abs(),e.lte(s))return it=r?4:1,e;if(t=e.divToInt(i),t.isZero())it=r?3:2;else{if(e=e.minus(t.times(i)),e.lte(s))return it=Ma(t)?r?2:3:r?4:1,e;it=Ma(t)?r?1:4:r?3:2}return e.minus(i).abs()}function to(n,e,t,r){var i,s,o,a,l,u,c,d,f,h=n.constructor,m=t!==void 0;if(m?(Ce(t,1,gt),r===void 0?r=h.rounding:Ce(r,0,8)):(t=h.precision,r=h.rounding),!n.isFinite())c=Ga(n);else{for(c=Ye(n),o=c.indexOf("."),m?(i=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):i=e,o>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-o,f.d=vi(Ye(f),10,i),f.e=f.d.length),d=vi(c,10,i),s=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=m?"0p+0":"0";else{if(o<0?s--:(n=new h(n),n.d=d,n.e=s,n=Z(n,f,t,r,0,i),d=n.d,s=n.e,u=ja),o=d[t],a=i/2,u=u||d[t+1]!==void 0,u=r<4?(o!==void 0||u)&&(r===0||r===(n.s<0?3:2)):o>a||o===a&&(r===4||u||r===6&&d[t-1]&1||r===(n.s<0?8:7)),d.length=t,u)for(;++d[--t]>i-1;)d[t]=0,t||(++s,d.unshift(1));for(l=d.length;!d[l-1];--l);for(o=0,c="";o<l;o++)c+=Js.charAt(d[o]);if(m){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)c+="0";for(d=vi(c,i,e),l=d.length;!d[l-1];--l);for(o=1,c="1.";o<l;o++)c+=Js.charAt(d[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 n.s<0?"-"+c:c}function La(n,e){if(n.length>e)return n.length=e,!0}function Od(n){return new this(n).abs()}function Bd(n){return new this(n).acos()}function Rd(n){return new this(n).acosh()}function $d(n,e){return new this(n).plus(e)}function Md(n){return new this(n).asin()}function Ld(n){return new this(n).asinh()}function Pd(n){return new this(n).atan()}function jd(n){return new this(n).atanh()}function Fd(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,s=r+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=Xe(this,s,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?Xe(this,r,i):new this(0),t.s=n.s):!n.d||e.isZero()?(t=Xe(this,s,1).times(.5),t.s=n.s):e.s<0?(this.precision=s,this.rounding=1,t=this.atan(Z(n,e,s,1)),e=Xe(this,s,1),this.precision=r,this.rounding=i,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(Z(n,e,s,1)),t}function qd(n){return new this(n).cbrt()}function Ud(n){return N(n=new this(n),n.e+1,2)}function Vd(n,e,t){return new this(n).clamp(e,t)}function zd(n){if(!n||typeof n!="object")throw Error(Ti+"Object expected");var e,t,r,i=n.defaults===!0,s=["precision",1,gt,"rounding",0,8,"toExpNeg",-pr,0,"toExpPos",0,pr,"maxE",0,pr,"minE",-pr,0,"modulo",0,9];for(e=0;e<s.length;e+=3)if(t=s[e],i&&(this[t]=Ks[t]),(r=n[t])!==void 0)if(ve(r)===r&&r>=s[e+1]&&r<=s[e+2])this[t]=r;else throw Error(mt+t+": "+r);if(t="crypto",i&&(this[t]=Ks[t]),(r=n[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(qa);else this[t]=!1;else throw Error(mt+t+": "+r);return this}function Hd(n){return new this(n).cos()}function Wd(n){return new this(n).cosh()}function Ya(n){var e,t,r;function i(s){var o,a,l,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,Pa(s)){u.s=s.s,R?!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++;R?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 Ei(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),Va.test(s)?Ei(u,s):Nd(u,s);if(l==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,Ei(u,s.toString());throw Error(mt+s)}if(i.prototype=v,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=zd,i.clone=Ya,i.isDecimal=Pa,i.abs=Od,i.acos=Bd,i.acosh=Rd,i.add=$d,i.asin=Md,i.asinh=Ld,i.atan=Pd,i.atanh=jd,i.atan2=Fd,i.cbrt=qd,i.ceil=Ud,i.clamp=Vd,i.cos=Hd,i.cosh=Wd,i.div=Gd,i.exp=Xd,i.floor=Yd,i.hypot=Zd,i.ln=Jd,i.log=Kd,i.log10=ef,i.log2=Qd,i.max=tf,i.min=rf,i.mod=nf,i.mul=sf,i.pow=of,i.random=af,i.round=lf,i.sign=uf,i.sin=cf,i.sinh=df,i.sqrt=ff,i.sub=hf,i.sum=pf,i.tan=mf,i.tanh=gf,i.trunc=bf,n===void 0&&(n={}),n&&n.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)n.hasOwnProperty(t=r[e++])||(n[t]=this[t]);return i.config(n),i}function Gd(n,e){return new this(n).div(e)}function Xd(n){return new this(n).exp()}function Yd(n){return N(n=new this(n),n.e+1,3)}function Zd(){var n,e,t=new this(0);for(R=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return R=!0,new this(1/0);t=e}return R=!0,t.sqrt()}function Pa(n){return n instanceof on||n&&n.toStringTag===Ua||!1}function Jd(n){return new this(n).ln()}function Kd(n,e){return new this(n).log(e)}function Qd(n){return new this(n).log(2)}function ef(n){return new this(n).log(10)}function tf(){return Wa(this,arguments,-1)}function rf(){return Wa(this,arguments,1)}function nf(n,e){return new this(n).mod(e)}function sf(n,e){return new this(n).mul(e)}function of(n,e){return new this(n).pow(e)}function af(n){var e,t,r,i,s=0,o=new this(1),a=[];if(n===void 0?n=this.precision:Ce(n,1,gt),r=Math.ceil(n/O),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));s<r;)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(r*=4);s<r;)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=r/4}else throw Error(qa);else for(;s<r;)a[s++]=Math.random()*1e7|0;for(r=a[--s],n%=O,r&&n&&(i=le(10,O-n),a[s]=(r/i|0)*i);a[s]===0;s--)a.pop();if(s<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=O)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<O&&(t-=O-r)}return o.e=t,o.d=a,o}function lf(n){return N(n=new this(n),n.e+1,this.rounding)}function uf(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function cf(n){return new this(n).sin()}function df(n){return new this(n).sinh()}function ff(n){return new this(n).sqrt()}function hf(n,e){return new this(n).sub(e)}function pf(){var n=0,e=arguments,t=new this(e[n]);for(R=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return R=!0,N(t,this.precision,this.rounding)}function mf(n){return new this(n).tan()}function gf(n){return new this(n).tanh()}function bf(n){return N(n=new this(n),n.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var on=v.constructor=Ya(Ks);xi=new on(xi);ki=new on(ki);var Za=on;var _f=20,wf=1,jt=1e6,Ja=1e6,yf=-7,vf=21,Ef=!1,an="[big.js] ",Ft=an+"Invalid ",Si=Ft+"decimal places",xf=Ft+"rounding mode",Ka=an+"Division by zero",G={},Ze=void 0,kf=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Qa(){function n(e){var t=this;if(!(t instanceof n))return e===Ze?Qa():new n(e);if(e instanceof n)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(n.strict===!0&&typeof e!="bigint")throw TypeError(Ft+"value");e=e===0&&1/e<0?"-0":String(e)}Af(t,e)}t.constructor=n}return n.prototype=G,n.DP=_f,n.RM=wf,n.NE=yf,n.PE=vf,n.strict=Ef,n.roundDown=0,n.roundHalfUp=1,n.roundHalfEven=2,n.roundUp=3,n}function Af(n,e){var t,r,i;if(!kf.test(e))throw Error(Ft+"number");for(n.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),i=e.length,r=0;r<i&&e.charAt(r)=="0";)++r;if(r==i)n.c=[n.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(n.e=t-r-1,n.c=[],t=0;r<=i;)n.c[t++]=+e.charAt(r++)}return n}function qt(n,e,t,r){var i=n.c;if(t===Ze&&(t=n.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(xf);if(e<1)r=t===3&&(r||!!i[0])||e===0&&(t===1&&i[0]>=5||t===2&&(i[0]>5||i[0]===5&&(r||i[1]!==Ze))),i.length=1,r?(n.e=n.e-e+1,i[0]=1):i[0]=n.e=0;else if(e<i.length){if(r=t===1&&i[e]>=5||t===2&&(i[e]>5||i[e]===5&&(r||i[e+1]!==Ze||i[e-1]&1))||t===3&&(r||!!i[0]),i.length=e,r){for(;++i[--e]>9;)if(i[e]=0,e===0){++n.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return n}function Ut(n,e,t){var r=n.e,i=n.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(r<0?"e":"e+")+r;else if(r<0){for(;++r;)i="0"+i;i="0."+i}else if(r>0)if(++r>s)for(r-=s;r--;)i+="0";else r<s&&(i=i.slice(0,r)+"."+i.slice(r));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return n.s<0&&t?"-"+i:i}G.abs=function(){var n=new this.constructor(this);return n.s=1,n};G.cmp=function(n){var e,t=this,r=t.c,i=(n=new t.constructor(n)).c,s=t.s,o=n.s,a=t.e,l=n.e;if(!r[0]||!i[0])return r[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=r.length)<(l=i.length)?a:l,s=-1;++s<o;)if(r[s]!=i[s])return r[s]>i[s]^e?1:-1;return a==l?0:a>l^e?1:-1};G.div=function(n){var e=this,t=e.constructor,r=e.c,i=(n=new t(n)).c,s=e.s==n.s?1:-1,o=t.DP;if(o!==~~o||o<0||o>jt)throw Error(Si);if(!i[0])throw Error(Ka);if(!r[0])return n.s=s,n.c=[n.e=0],n;var a,l,u,c,d,f=i.slice(),h=a=i.length,m=r.length,p=r.slice(0,a),b=p.length,g=n,_=g.c=[],w=0,E=o+(g.e=e.e-n.e)+1;for(g.s=s,s=E<0?0:E,f.unshift(0);b++<a;)p.push(0);do{for(u=0;u<10;u++){if(a!=(b=p.length))c=a>b?1:-1;else for(d=-1,c=0;++d<a;)if(i[d]!=p[d]){c=i[d]>p[d]?1:-1;break}if(c<0){for(l=b==a?i:f;b;){if(p[--b]<l[b]){for(d=b;d&&!p[--d];)p[d]=9;--p[d],p[b]+=10}p[b]-=l[b]}for(;!p[0];)p.shift()}else break}_[w++]=c?u:++u,p[0]&&c?p[b]=r[h]||0:p=[r[h]]}while((h++<m||p[0]!==Ze)&&s--);return!_[0]&&w!=1&&(_.shift(),g.e--,E--),w>E&&qt(g,E,t.RM,p[0]!==Ze),g};G.eq=function(n){return this.cmp(n)===0};G.gt=function(n){return this.cmp(n)>0};G.gte=function(n){return this.cmp(n)>-1};G.lt=function(n){return this.cmp(n)<0};G.lte=function(n){return this.cmp(n)<1};G.minus=G.sub=function(n){var e,t,r,i,s=this,o=s.constructor,a=s.s,l=(n=new o(n)).s;if(a!=l)return n.s=-l,s.plus(n);var u=s.c.slice(),c=s.e,d=n.c,f=n.e;if(!u[0]||!d[0])return d[0]?n.s=-l:u[0]?n=new o(s):n.s=1,n;if(a=c-f){for((i=a<0)?(a=-a,r=u):(f=c,r=d),r.reverse(),l=a;l--;)r.push(0);r.reverse()}else for(t=((i=u.length<d.length)?u:d).length,a=l=0;l<t;l++)if(u[l]!=d[l]){i=u[l]<d[l];break}if(i&&(r=u,u=d,d=r,n.s=-n.s),(l=(t=d.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;t>a;){if(u[--t]<d[t]){for(e=t;e&&!u[--e];)u[e]=9;--u[e],u[t]+=10}u[t]-=d[t]}for(;u[--l]===0;)u.pop();for(;u[0]===0;)u.shift(),--f;return u[0]||(n.s=1,u=[f=0]),n.c=u,n.e=f,n};G.mod=function(n){var e,t=this,r=t.constructor,i=t.s,s=(n=new r(n)).s;if(!n.c[0])throw Error(Ka);return t.s=n.s=1,e=n.cmp(t)==1,t.s=i,n.s=s,e?new r(t):(i=r.DP,s=r.RM,r.DP=r.RM=0,t=t.div(n),r.DP=i,r.RM=s,this.minus(t.times(n)))};G.neg=function(){var n=new this.constructor(this);return n.s=-n.s,n};G.plus=G.add=function(n){var e,t,r,i=this,s=i.constructor;if(n=new s(n),i.s!=n.s)return n.s=-n.s,i.minus(n);var o=i.e,a=i.c,l=n.e,u=n.c;if(!a[0]||!u[0])return u[0]||(a[0]?n=new s(i):n.s=i.s),n;if(a=a.slice(),e=o-l){for(e>0?(l=o,r=u):(e=-e,r=a),r.reverse();e--;)r.push(0);r.reverse()}for(a.length-u.length<0&&(r=u,u=a,a=r),e=u.length,t=0;e;a[e]%=10)t=(a[--e]=a[e]+u[e]+t)/10|0;for(t&&(a.unshift(t),++l),e=a.length;a[--e]===0;)a.pop();return n.c=a,n.e=l,n};G.pow=function(n){var e=this,t=new e.constructor("1"),r=t,i=n<0;if(n!==~~n||n<-Ja||n>Ja)throw Error(Ft+"exponent");for(i&&(n=-n);n&1&&(r=r.times(e)),n>>=1,!!n;)e=e.times(e);return i?t.div(r):r};G.prec=function(n,e){if(n!==~~n||n<1||n>jt)throw Error(Ft+"precision");return qt(new this.constructor(this),n,e)};G.round=function(n,e){if(n===Ze)n=0;else if(n!==~~n||n<-jt||n>jt)throw Error(Si);return qt(new this.constructor(this),n+this.e+1,e)};G.sqrt=function(){var n,e,t,r=this,i=r.constructor,s=r.s,o=r.e,a=new i("0.5");if(!r.c[0])return new i(r);if(s<0)throw Error(an+"No square root");s=Math.sqrt(+Ut(r,!0,!0)),s===0||s===1/0?(e=r.c.join(""),e.length+o&1||(e+="0"),s=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),n=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):n=new i(s+""),o=n.e+(i.DP+=4);do t=n,n=a.times(t.plus(r.div(t)));while(t.c.slice(0,o).join("")!==n.c.slice(0,o).join(""));return qt(n,(i.DP-=4)+n.e+1,i.RM)};G.times=G.mul=function(n){var e,t=this,r=t.constructor,i=t.c,s=(n=new r(n)).c,o=i.length,a=s.length,l=t.e,u=n.e;if(n.s=t.s==n.s?1:-1,!i[0]||!s[0])return n.c=[n.e=0],n;for(n.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?++n.e:e.shift(),l=e.length;!e[--l];)e.pop();return n.c=e,n};G.toExponential=function(n,e){var t=this,r=t.c[0];if(n!==Ze){if(n!==~~n||n<0||n>jt)throw Error(Si);for(t=qt(new t.constructor(t),++n,e);t.c.length<n;)t.c.push(0)}return Ut(t,!0,!!r)};G.toFixed=function(n,e){var t=this,r=t.c[0];if(n!==Ze){if(n!==~~n||n<0||n>jt)throw Error(Si);for(t=qt(new t.constructor(t),n+t.e+1,e),n=n+t.e+1;t.c.length<n;)t.c.push(0)}return Ut(t,!1,!!r)};G[Symbol.for("nodejs.util.inspect.custom")]=G.toJSON=G.toString=function(){var n=this,e=n.constructor;return Ut(n,n.e<=e.NE||n.e>=e.PE,!!n.c[0])};G.toNumber=function(){var n=+Ut(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(n.toString()))throw Error(an+"Imprecise conversion");return n};G.toPrecision=function(n,e){var t=this,r=t.constructor,i=t.c[0];if(n!==Ze){if(n!==~~n||n<1||n>jt)throw Error(Ft+"precision");for(t=qt(new r(t),n,e);t.c.length<n;)t.c.push(0)}return Ut(t,n<=t.e||t.e<=r.NE||t.e>=r.PE,!!i)};G.valueOf=function(){var n=this,e=n.constructor;if(e.strict===!0)throw Error(an+"valueOf disallowed");return Ut(n,n.e<=e.NE||n.e>=e.PE,!0)};var Tf=Qa(),el=Tf;var ho={};vd(ho,{DecodeError:()=>Ee,Decoder:()=>Ve,EXT_TIMESTAMP:()=>no,Encoder:()=>gr,ExtData:()=>Ue,ExtensionCodec:()=>bt,decode:()=>ul,decodeArrayStream:()=>fl,decodeAsync:()=>dl,decodeMulti:()=>cl,decodeMultiStream:()=>hl,decodeTimestampExtension:()=>lo,decodeTimestampToTimeSpec:()=>ao,encode:()=>Oi,encodeDateToTimeSpec:()=>so,encodeTimeSpecToTimestamp:()=>io,encodeTimestampExtension:()=>oo});function tl(n){let e=n.length,t=0,r=0;for(;r<e;){let i=n.charCodeAt(r++);if((i&4294967168)===0){t++;continue}else if((i&4294965248)===0)t+=2;else{if(i>=55296&&i<=56319&&r<e){let s=n.charCodeAt(r);(s&64512)===56320&&(++r,i=((i&1023)<<10)+(s&1023)+65536)}(i&4294901760)===0?t+=3:t+=4}}return t}function Df(n,e,t){let r=n.length,i=t,s=0;for(;s<r;){let o=n.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<r){let a=n.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 Cf=new TextEncoder,Sf=50;function Nf(n,e,t){Cf.encodeInto(n,e.subarray(t))}function rl(n,e,t){n.length>Sf?Nf(n,e,t):Df(n,e,t)}var If=4096;function ro(n,e,t){let r=e,i=r+t,s=[],o="";for(;r<i;){let a=n[r++];if((a&128)===0)s.push(a);else if((a&224)===192){let l=n[r++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=n[r++]&63,u=n[r++]&63;s.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=n[r++]&63,u=n[r++]&63,c=n[r++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d)}else s.push(a);s.length>=If&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var Of=new TextDecoder,Bf=200;function Rf(n,e,t){let r=n.subarray(e,e+t);return Of.decode(r)}function nl(n,e,t){return t>Bf?Rf(n,e,t):ro(n,e,t)}var Ue=class{type;data;constructor(e,t){this.type=e,this.data=t}};var Ee=class n extends Error{constructor(e){super(e);let t=Object.create(n.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:n.name})}};function il(n,e,t){let r=t/4294967296,i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function Ni(n,e,t){let r=Math.floor(t/4294967296),i=t;n.setUint32(e,r),n.setUint32(e+4,i)}function Ii(n,e){let t=n.getInt32(e),r=n.getUint32(e+4);return t*4294967296+r}function sl(n,e){let t=n.getUint32(e),r=n.getUint32(e+4);return t*4294967296+r}var no=-1,$f=4294967296-1,Mf=17179869184-1;function io({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=Mf)if(e===0&&n<=$f){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,r=n&4294967295,i=new Uint8Array(8),s=new DataView(i.buffer);return s.setUint32(0,e<<2|t&3),s.setUint32(4,r),i}else{let t=new Uint8Array(12),r=new DataView(t.buffer);return r.setUint32(0,e),Ni(r,4,n),t}}function so(n){let e=n.getTime(),t=Math.floor(e/1e3),r=(e-t*1e3)*1e6,i=Math.floor(r/1e9);return{sec:t+i,nsec:r-i*1e9}}function oo(n){if(n instanceof Date){let e=so(n);return io(e)}else return null}function ao(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),r=e.getUint32(4),i=(t&3)*4294967296+r,s=t>>>2;return{sec:i,nsec:s}}case 12:{let t=Ii(e,4),r=e.getUint32(0);return{sec:t,nsec:r}}default:throw new Ee(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function lo(n){let e=ao(n);return new Date(e.sec*1e3+e.nsec/1e6)}var ol={type:no,encode:oo,decode:lo};var bt=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(ol)}register({type:e,encode:t,decode:r}){if(e>=0)this.encoders[e]=t,this.decoders[e]=r;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=r}}tryToEncode(e,t){for(let r=0;r<this.builtInEncoders.length;r++){let i=this.builtInEncoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=-1-r;return new Ue(o,s)}}}for(let r=0;r<this.encoders.length;r++){let i=this.encoders[r];if(i!=null){let s=i(e,t);if(s!=null){let o=r;return new Ue(o,s)}}}return e instanceof Ue?e:null}decode(e,t,r){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,r):new Ue(t,e)}};function Lf(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function ln(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Lf(n)?new Uint8Array(n):Uint8Array.from(n)}var Pf=100,jf=2048,gr=class n{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??bt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Pf,this.initialBufferSize=e?.initialBufferSize??jf,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 n({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,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);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,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),r=new Uint8Array(t),i=new DataView(t);r.set(this.bytes),this.view=i,this.bytes=r}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 r=tl(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),rl(e,this.bytes,this.pos),this.pos+=r}encodeObject(e,t){let r=this.extensionCodec.tryToEncode(e,this.context);if(r!=null)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let r=ln(e);this.writeU8a(r)}encodeArray(e,t){let r=e.length;if(r<16)this.writeU8(144+r);else if(r<65536)this.writeU8(220),this.writeU16(r);else if(r<4294967296)this.writeU8(221),this.writeU32(r);else throw new Error(`Too large array: ${r}`);for(let i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let r=0;for(let i of t)e[i]!==void 0&&r++;return r}encodeMap(e,t){let r=Object.keys(e);this.sortKeys&&r.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,r):r.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 r){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let r=e.data(this.pos+6),i=r.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(r);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}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),il(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Ni(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 Oi(n,e){return new gr(e).encodeSharedRef(n)}function Bi(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}var Ff=16,qf=16,Ri=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Ff,t=qf){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let r=0;r<this.maxKeyLength;r++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,r){let i=this.caches[r-1];e:for(let s of i){let o=s.bytes;for(let a=0;a<r;a++)if(o[a]!==e[t+a])continue e;return s.str}return null}store(e,t){let r=this.caches[e.length-1],i={bytes:e,str:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=i:r.push(i)}decode(e,t,r){let i=this.find(e,t,r);if(i!=null)return this.hit++,i;this.miss++;let s=ro(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,s),s}};var uo="array",dn="map_key",ll="map_value",Uf=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new Ee("The type of key must be string or number but "+typeof n)},co=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=uo,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=dn,t.readCount=0,t.size=e,t.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===uo){let r=e;r.size=0,r.array=void 0,r.position=0,r.type=void 0}if(e.type===dn||e.type===ll){let r=e;r.size=0,r.map=void 0,r.readCount=0,r.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},cn=-1,fo=new DataView(new ArrayBuffer(0)),Vf=new Uint8Array(fo.buffer);try{fo.getInt8(0)}catch(n){if(!(n 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 al=new RangeError("Insufficient data"),zf=new Ri,Ve=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=fo;bytes=Vf;headByte=cn;stack=new co;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??bt.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:zf,this.mapKeyConverter=e?.mapKeyConverter??Uf}clone(){return new n({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=cn,this.stack.reset()}setBuffer(e){let t=ln(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===cn&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),r=ln(e),i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:r}=this;return new RangeError(`Extra ${t.byteLength-r} of ${t.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 t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}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 t=!1,r;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{r=this.doDecodeSync(),t=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return r}let{headByte:i,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${Bi(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,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let r=t,i=-1;for await(let s of e){if(t&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),r&&(i=this.readArraySize(),r=!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(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else{let i=e-160;t=this.decodeString(i,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===196){let i=this.lookU8();t=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();t=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();t=this.decodeBinary(i,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();t=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();t=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();t=this.decodeExtension(i,4)}else throw new Ee(`Unrecognized type byte: ${Bi(e)}`);this.complete();let r=this.stack;for(;r.length>0;){let i=r.top();if(i.type===uo)if(i.array[i.position]=t,i.position++,i.position===i.size)t=i.array,r.release(i);else continue e;else if(i.type===dn){if(t==="__proto__")throw new Ee("The key __proto__ is not allowed");i.key=this.mapKeyConverter(t),i.type=ll;continue e}else if(i.map[i.key]=t,i.readCount++,i.readCount===i.size)t=i.map,r.release(i);else{i.key=null,i.type=dn;continue e}}return t}}readHeadByte(){return this.headByte===cn&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=cn}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 Ee(`Unrecognized array type byte: ${Bi(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Ee(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Ee(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new Ee(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw al;let r=this.pos+t,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,r,e):i=nl(this.bytes,r,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===dn:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Ee(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw al;let r=this.pos+t,i=this.bytes.subarray(r,r+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new Ee(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let r=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,r,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=sl(this.view,this.pos);return this.pos+=8,e}readI64(){let e=Ii(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 ul(n,e){return new Ve(e).decode(n)}function cl(n,e){return new Ve(e).decodeMulti(n)}function Hf(n){return n[Symbol.asyncIterator]!=null}async function*Wf(n){let e=n.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}function $i(n){return Hf(n)?n:Wf(n)}async function dl(n,e){let t=$i(n);return new Ve(e).decodeAsync(t)}function fl(n,e){let t=$i(n);return new Ve(e).decodeArrayStream(t)}function hl(n,e){let t=$i(n);return new Ve(e).decodeStream(t)}var es=Ia($o(),1),Mo=Za,Lo=el,et=ho,_u=es.DOMParser,wu=es.XMLSerializer;var yu=et!==null;function vu(){if(!yu)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var Eu=Hp();function Hp(){if(!yu)return null;let n=new TextEncoder,e=new TextDecoder,t=new et.ExtensionCodec;return t.register({type:-1,encode:r=>{if(r instanceof Date){let i=kt(r);if(i==="D"||i==="H")return null}return et.encodeTimestampExtension(r)},decode:r=>et.decodeTimestampExtension(r)}),t.register({type:1,encode:r=>be(r)?n.encode(r.toString()):null,decode:r=>At(e.decode(r))}),t.register({type:2,encode:r=>{if(r instanceof Date&&kt(r)==="D"){let i=r.getUTCFullYear(),s=String(r.getUTCMonth()+1).padStart(2,"0"),o=String(r.getUTCDate()).padStart(2,"0");return n.encode(`${i}-${s}-${o}`)}return null},decode:r=>new Date(e.decode(r)+"T00:00:00.000Z")}),t.register({type:3,encode:r=>{if(r instanceof Date&&kt(r)==="H"){let i=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=String(r.getUTCMilliseconds()).padStart(3,"0");return n.encode(`${i}:${s}:${o}.${a}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf("."),o=s>=0?i.substring(0,s):i,a=s>=0?i.substring(s+1):"0",[l,u,c]=o.split(":"),d=Math.round(+a.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,d))}}),t.register({type:4,encode:r=>{let i=Po(r);if(i!==null){let[s,o]=i;return n.encode(`${s}:${o(r)}`)}return null},decode:r=>{let i=e.decode(r),s=i.indexOf(":"),o=i.slice(0,s),a=i.slice(s+1),l=Tt[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),t}function xu(n){return vu(),et.encode(n,{extensionCodec:Eu})}function ku(n){return vu(),et.decode(n,{extensionCodec:Eu})}function rs(n,e=!1){let t=ns(n);if(t===null)return[!1,String(n)];let[r,i,s]=t;return s&&!e?[!1,String(n)]:[!0,`${i(n)}::${r}`]}function jo(n){if(!n.includes("::"))return[!1,n];let e=n.lastIndexOf("::"),t=n.slice(0,e),r=n.slice(e+2),i=Tt[r];if(i===void 0)return[!1,n];let[,s]=i;return[!0,s(t)]}function ts(n,e,t){if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r={};for(let[i,s]of Object.entries(n))r[i]=ts(s,e,t);return r}return Array.isArray(n)?n.map(r=>ts(r,e,t)):t(n)?e(n):n}function Fo(n){let e=ns(n);if(e!==null){let[t,r,i]=e;return i?[n,!1]:[`${r(n)}::${t}`,!0]}if(Array.isArray(n)){let t=!1;return[n.map(i=>{let[s,o]=Fo(i);return o&&(t=!0),s}),t]}if(n!==null&&typeof n=="object"){let t=!1,r={};for(let[i,s]of Object.entries(n)){let[o,a]=Fo(s);a&&(t=!0),r[i]=o}return[r,t]}return[n,!1]}function Wp(n,e=!1){let[t,r]=rs(n,e);if(t)return r;let[i,s]=Fo(n),o=JSON.stringify(i);return s?`${o}::JS`:o}function Gp(n){return JSON.stringify(n)}function Xp(n){if(!et)throw new Error("@msgpack/msgpack is required for MessagePack support");return et.encode(n)}function U(n,e=null,{raw:t=!1,qs:r=!1,_forceSuffix:i=!1}={}){if(r)return`${Tu(n)}::QS`;if(t){if(e===null||e==="json")return Gp(n);if(e==="msgpack")return Xp(n);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=Wp(n,i);return e==="json"?`"${s}"`:s}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${Au(n)}</tytx_root>`;if(e==="msgpack")return xu(n);throw new Error(`Unknown transport: ${e}`)}}var $r,qo;typeof window<"u"&&window.DOMParser?($r=window.DOMParser,qo=window.XMLSerializer):($r=_u,qo=wu);function Du(n){if(n===null||typeof n!="object"||Array.isArray(n))return!1;let e=Object.keys(n);if(e.length!==1)return!1;let t=n[e[0]];return t!==null&&typeof t=="object"&&"value"in t}function Cu(n,e,t){let r=n.createElement(e),i=t.attrs||{},s=t.value;for(let[o,a]of Object.entries(i))r.setAttribute(o,U(a,null,{_forceSuffix:!0}));if(Array.isArray(s))for(let o of s)if(Du(o)){let[a]=Object.keys(o),l=o[a],u=Cu(n,a,l);r.appendChild(u)}else{r.textContent=U(s);break}else r.textContent=U(s);return r}function Au(n){if(!$r)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(Du(n)){let[e]=Object.keys(n),t=n[e],r=new $r().parseFromString("<root/>","text/xml"),i=Cu(r,e,t);return new qo().serializeToString(i)}else return U(n)}function Uo(n){let e={};for(let r=0;r<n.attributes.length;r++){let i=n.attributes[r];e[i.name]=j(i.value)}let t=[];for(let r=0;r<n.childNodes.length;r++){let i=n.childNodes[r];i.nodeType===1&&t.push(i)}if(t.length>0)if(t.length===1){let r=t[0],i=Uo(r);return{attrs:e,value:{[r.tagName]:i}}}else{let r=[];for(let i of t){let s=Uo(i);r.push({[i.tagName]:s})}return{attrs:e,value:r}}return{attrs:e,value:j(n.textContent)}}function Su(n){if(!$r)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let r=new $r().parseFromString(n,"text/xml").documentElement;if(r.tagName==="tytx_root"){let s=null;for(let o=0;o<r.childNodes.length;o++)if(r.childNodes[o].nodeType===1){s=r.childNodes[o];break}if(!s)return j(r.textContent);r=s}let i=Uo(r);return{[r.tagName]:i}}function Yp(n){return typeof n=="string"}function Zp(n){let[e,t]=jo(n);if(e)return t;let r=n;r.endsWith("::JS")&&(r=r.slice(0,-4));let i;try{i=JSON.parse(r)}catch{return n}return ts(i,Jp,Yp)}function Jp(n){return n.includes("::")?jo(n)[1]:n}function Kp(n){let e=Su(n);return typeof e=="string"?j(e):e}function Qp(n){return ku(n)}function j(n,e=null){if(n===null)return null;if(e===null||e==="json"){let t=n;return e==="json"&&n.startsWith('"')&&n.endsWith('"')&&(t=n.slice(1,-1)),Zp(t)}else{if(e==="xml")return Kp(n);if(e==="msgpack")return Qp(n);throw new Error(`Unknown transport: ${e}`)}}function Tu(n){if(Array.isArray(n))return n.map(e=>String(e)).join("&");if(n!==null&&typeof n=="object"){let e=[];for(let[t,r]of Object.entries(n)){let[i,s]=rs(r,!0);i?e.push(`${t}=${s}`):e.push(`${t}=${r}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof n}`)}function Nu(n){if(!n)return[];let e=n.split("&"),t=e.map(o=>o.includes("=")),r=t.every(Boolean),i=!t.some(Boolean);if(!r&&!i)throw new Error("QS format error: mixed items with and without '='");if(i)return e.map(o=>j(o));let s={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);s[l]=j(u)}return s}var Ou=Mo||Lo||Number,Bu=Mo?"decimal.js":Lo?"big.js":"number";function zo(){return Bu}function At(n){return new Ou(n)}function be(n){return Bu==="number"?!1:n instanceof Ou}function kt(n){let e=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,t=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;return e&&!t?"H":t&&!e?"D":"DHZ"}function em(n){return n.toString()}function tm(n){let e=n.getUTCFullYear(),t=String(n.getUTCMonth()+1).padStart(2,"0"),r=String(n.getUTCDate()).padStart(2,"0");return`${e}-${t}-${r}`}function rm(n){return n.toISOString()}function nm(n){let e=String(n.getUTCHours()).padStart(2,"0"),t=String(n.getUTCMinutes()).padStart(2,"0"),r=String(n.getUTCSeconds()).padStart(2,"0"),i=String(n.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${r}.${i}`}function im(n){return n?"true":"false"}function sm(n){return n.toString()}function om(n){return n.toString()}function am(n){let e="";for(let t=0;t<n.length;t+=32768)e+=String.fromCharCode.apply(null,n.subarray(t,t+32768));return btoa(e)}var is=[],Vo=new Map;function Po(n){if(n===null||typeof n!="object")return null;for(let e=Object.getPrototypeOf(n);e!==null;e=Object.getPrototypeOf(e))for(let[t,r,i,s]of is)if(t.prototype===e)return[r,i,s];return null}function ns(n){if(n===null)return["NN",()=>"",!0];if(be(n))return["N",em,!1];if(n instanceof Uint8Array)return["RAW",am,!1];if(n instanceof Date){let e=kt(n);return e==="D"?["D",tm,!1]:e==="H"?["H",nm,!1]:["DHZ",rm,!1]}return typeof n=="boolean"?["B",im,!0]:typeof n=="number"?Number.isInteger(n)?["L",sm,!0]:["R",om,!0]:Po(n)}function lm(n){return At(n)}function um(n){let[e,t,r]=n.split("-").map(Number);return new Date(Date.UTC(e,t-1,r,0,0,0,0))}function Iu(n){return new Date(n)}function cm(n){let[e,t,r]=n.split(":"),[i,s]=r.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(i),Number(s||0)))}function dm(n){return n.toLowerCase()==="true"}function fm(n){return parseInt(n,10)}function hm(n){return parseFloat(n)}function pm(n){return n}function mm(n){return null}var gm=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function bm(n){if(!gm.test(n))throw new Error(`RAW payload is not standard padded base64: '${n}'`);let e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function _m(n){return Nu(n)}var wm=/^[A-Z]+$/,Tt={N:[Object,lm],D:[Date,um],DH:[Date,Iu],DHZ:[Date,Iu],H:[Date,cm],L:[Number,fm],R:[Number,hm],T:[String,pm],B:[Boolean,dm],QS:[Object,_m],NN:[null,mm],RAW:[Uint8Array,bm]};function In(n){return Object.hasOwn(Tt,n)?Tt[n][0]:null}function Ho(n,e,t,r,i=!1){if(typeof e!="string"||!wm.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let s=Tt[e];if(s!==void 0&&s[0]!==n){let o=s[0]===null?"null":s[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}is=is.filter(([o])=>o!==n),is.push([n,e,t,i]),Tt[e]=[n,r]}function Gt(n,e){Vo.set(n,e)}function je(n){return Vo.has(n)?Vo.get(n):{}}var Ru={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 vm(n){let e=n._retryPolicy;return e==null?null:typeof e=="string"?Ru[e]||null:e}function Em(n,e){return e.some(t=>t==="Error"?!0:n.name===t||n.constructor.name===t)}function xm(n){return new Promise(e=>setTimeout(e,n))}async function km(n,e){if(!e)return n();let t=e.maxAttempts||3,r=e.delay||1,i=e.backoff||2,s=e.jitter!==!1,o=e.on||["Error"],a=null,l=r*1e3;for(let u=0;u<t;u++)try{let c=n();return c instanceof Promise?await c:c}catch(c){if(a=c,u<t-1&&Em(c,o)){let d=l;s&&(d*=1+Math.random()*.1),await xm(d),l*=i}else throw c}throw a}var K=class n{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let r={...this.constructor.classKwargs,...e};for(let s of["interval","reactive"])if(Object.hasOwn(r,s))throw new TypeError(`Removed resolver option: ${s}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=r.cacheTime,this._readOnly=r.readOnly,this._asBag=r.asBag,this._retryPolicy=r.retryPolicy,this._kw={};let i=this.constructor.internalParams;for(let[s,o]of Object.entries(r))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())}resolve(e={}){let{static:t=!1,...r}=e;if(t)return this._node?this._node._value:this.cachedValue;let i={...this._kw};if(this._node&&this._node.attr){let u=this.constructor.internalParams;for(let[c,d]of Object.entries(this._node.attr))u.has(c)||(i[c]=d)}Object.assign(i,r);let s=this._computeEffectiveFingerprint(i);if(s===this._lastEffectiveFingerprint&&!this.expired)return this.cachedValue;this._lastEffectiveFingerprint=s;let o=vm(this),a=()=>this.load(i);if(o)return km(a,o).then(u=>this._finalize(u));let l=a();return l&&typeof l.then=="function"?l.then(u=>this._finalize(u)):this._finalize(l)}_finalize(e){let t;return this._asBag===!0?t=!0:this._asBag===!1?t=!1:t=!this._readOnly,t&&e!==null&&e!==void 0&&(e=this._convertToBag(e)),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_convertToBag(e){let t=n._BagClass;if(!t||e&&typeof e._htraverse=="function")return e;if(typeof e=="string"){if(e=e.trim(),e.startsWith("<")&&t.fromXml)return t.fromXml(e);if((e.startsWith("{")||e.startsWith("["))&&t.fromTytx)return t.fromTytx(e)}return e}static registerBagClass(e){n._BagClass=e}load(e){return null}};K._BagClass=null;var Dt=class extends K{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 ze=class n{constructor(e,t,r=null,i=null,s=null,o=null,a=null,l=!0){this.label=t,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),r!==null&&this.setValue(r,!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,t=null,r={}){if(t!==null){let i=j(`${t}::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 K?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");r={...r,...i}}}return this._resolver!==null?this._resolver.resolve({static:e,...r}):this._value}setValue(e,t=!0,r=null,i=null,s=!0,o=null,a=!1){e instanceof K?(this.resolver=e,e=null):e instanceof n&&(r=r||{},Object.assign(r,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=t??!0,d=null;if(r!==null){let h={...this._attr};this.setAttr(r,!1,i,s);let m=this._buildAttrDiff(h,this._attr);d=Object.keys(m).length>0?m:null}t=c&&(u||d!==null);let f=d?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),t){let h=d!==null?{oldvalue:l,attrs_diff:d}:{oldvalue:l};for(let m of Object.values(this._nodeSubscribers))m({node:this,info:h,evt:f})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),t&&this._parentBag._onNodeChanged(this,[this.label],f,l,d,o,a))}replace(e){if(!(e instanceof n))throw new TypeError("BagNode.replace expects a BagNode");if(e===this)return this;let t=e.staticValue;t&&typeof t._htraverse=="function"&&(t=t.createChildBag().replace(t));let r=null;e.resolver&&(r=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),r._node=null,r._kw={...e.resolver._kw});let i=this._value,s={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=r,this.setValue(t,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(s,this._attr),l=Object.keys(a).length?a:null,u=i!==t||o!==r;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:i,attrs_diff:l}:{oldvalue:i};for(let f of Object.values(this._nodeSubscribers))f({node:this,info:d,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,t=null){return e?e in this._attr?this._attr[e]:t:this._attr}_buildAttrDiff(e,t){let r={},i=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of i){let o=s in e?e[s]:null,a=s in t?t[s]:null;o!==a&&(r[s]={old:o,new:a})}return r}setAttr(e=null,t=!0,r=!0,i=!0){let s=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=t&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(r?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(t&&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=t===!0?"true":String(t);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let t of e)if(typeof t=="string"&&t.includes(","))for(let r of t.split(","))delete this._attr[r.trim()];else delete this._attr[t]}hasAttr(e,t=null){return e in this._attr?t!==null?this._attr[e]===t:!0:!1}getInheritedAttributes(){let e={};return this._parentBag&&this._parentBag.parentNode&&(e=this._parentBag.parentNode.getInheritedAttributes()),{...e,...this._attr}}subscribe(e,t){this._nodeSubscribers[e]=t}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,t=null){let r=this;if(t===null)for(;r&&!(e in r._attr);)r=r.parentNode;else for(;r&&r._attr[e]!==t;)r=r.parentNode;return r}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof n)||this.label!==e.label)return!1;let t=Object.keys(this._attr),r=Object.keys(e._attr);if(t.length!==r.length)return!1;for(let i of t)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 t=Object.keys(this._attr),r=Object.keys(e._attr);return t.length!==r.length||t.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 t=this.value;return t&&typeof t.toJson=="function"&&(t=t.toJson(e,!0)),{label:this.label,value:t,attr:this._attr}}toString(){return`BagNode : ${this.label}`}};var On=class n{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(r=>r.label===e);let t=e.match(/^#(\d+)$/);if(t){let r=parseInt(t[1],10);return r<this._list.length?r:-1}if(t=e.match(/^#(\w*)=(.*)$/),t){let[,r,i]=t,s=i.includes("::")?j(i):i;return r?this._list.findIndex(o=>o.getAttr(r)===s):this._list.findIndex(o=>o._value===s)}return-1}_parsePosition(e){let t=this._list.length;if(e==null||e===">")return t;if(typeof e=="number")return e<0&&(e=t+e),Math.max(0,Math.min(e,t));if(e==="<")return 0;if(e.startsWith("#")){let r=this._parseSharpIndex(e.slice(1),e);return Math.min(r,t)}if(e.startsWith("<")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i}if(e.startsWith(">")){let r=e.slice(1);if(r.startsWith("#")){let s=this._parseSharpIndex(r.slice(1),e);return Math.min(s+1,t)}let i=this.index(r);if(i<0)throw new Error(`Invalid node_position '${e}': label '${r}' not found`);return i+1}throw new Error(`Invalid node_position '${e}': unrecognized syntax`)}_parseSharpIndex(e,t){if(!/^-?\d+$/.test(e))throw new Error(`Invalid node_position '${t}': '${e}' is not an integer`);let r=parseInt(e,10);if(r<0)throw new Error(`Invalid node_position '${t}': negative index not allowed in '#n' syntax`);return r}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let t=this.index(e);return t>=0?this._list[t]:null}return this._dict[e]||null}set(e,t,r=">",i=null,s=null,o=null,a=!1,l=!0,u=null,c=!0,d=!1,f=null){let h=null;if(e.includes("?")&&([e,h]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(h){let p=h.split("&");if(p.length===1)i={[p[0]]:t};else{if(!Array.isArray(t)||t.length!==p.length)throw new Error("Wrong attributes assignment");i={};for(let b=0;b<p.length;b++)i[p[b]]=t[b]}t=null}let m=this._dict[e];if(m)f&&(m.nodeTag=f),o!==null&&(o===!1?m.resolver=null:m.resolver=o),h?m.setAttr(i,c,!0,l):m.setValue(t,c,i,a,l,u,d);else{let p=s&&s.nodeClass?s.nodeClass:ze;m=new p(s,e,h?null:t,i,o,f,null,l);let b=this._parsePosition(r);this._dict[e]=m,this._list.splice(b,0,m),c&&s&&s.backref&&s._onNodeInserted(m,b,null,u,d)}return d&&m.setValue(null,!1),m}pop(e){let t=this.get(e);if(t){delete this._dict[t.label];let r=this._list.indexOf(t);return r>=0&&this._list.splice(r,1),t}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,t,r=!0){if(t<0)return;let i=Array.isArray(e)?e:[e];if(i.length===0||t>=this._list.length)return;let s=this._list[t].label;if(i.length>1){let o=[...i].sort((c,d)=>c-d),a=o[0]<t?1:0,l=[];for(let c=o.length-1;c>=0;c--){let d=o[c];if(d>=0&&d<this._list.length){let f=this._list[d];this._list.splice(d,1),l.push(f),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(s);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=i[0];if(o===t||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(t,0,a),r&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,t)}}isEqual(e){if(!(e instanceof n)||this._list.length!==e._list.length)return!1;for(let t=0;t<this._list.length;t++){let r=this._list[t],i=e._list[t];if(!r.isEqual(i))return!1}return!0}};var Pu=Ia($o(),1);var Wo="::RSLV:",Am=new Map,Tm=new Map,ss=new WeakMap,oe=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},Bn=class extends K{constructor(e){super({asBag:!1}),ss.set(this,e)}get payload(){return ss.get(this)}load(){throw new oe("This resolver is opaque; local execution is unavailable")}};function $u(n){if(!n||typeof n!="object"||Array.isArray(n)||typeof n.resolver_module!="string"||typeof n.resolver_class!="string"||!Array.isArray(n.args??[])||!n.kwargs||typeof n.kwargs!="object"||Array.isArray(n.kwargs))throw new oe("Invalid resolver description")}function Mu(n,e=new Set){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n)||!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new oe("Resolver parameters must be JSON data; callbacks cannot travel");e.add(n);for(let t of Object.values(n))Mu(t,e);e.delete(n)}}function Rn(n){if(ss.has(n))return ss.get(n);let e=Tm.get(n.constructor);if(!e)throw new oe(`Unregistered resolver: ${n.constructor.name}`);let t=e.encode(n),r={resolver_module:e.module,resolver_class:e.name,args:t.args??[],kwargs:t.kwargs??{}};return $u(r),Mu(r),Wo+JSON.stringify(r)}function os(n){if(typeof n!="string"||!n.startsWith(Wo))return null;let e=n.slice(Wo.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new Bn(n);let t;try{t=JSON.parse(e)}catch{throw new oe("Invalid resolver JSON or signed token")}$u(t);let r=Am.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!r)return new Bn(n);let i=r.decode({args:t.args??[],kwargs:t.kwargs});if(!(i instanceof r.cls))throw new oe("Resolver decoder returned an incompatible instance");return i}function as(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,t instanceof K?Rn(t):t]))}function Go(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[e,os(t)??t]))}var He="__cls";function Mr(n,e){return n!==null&&n.tytxSuffix===e?n:In(e)}function Dm(n){let e=n.tytxSuffix,t=Object.entries(je(e)).filter(([,r])=>r===n).map(([r])=>r);if(t.length===0)throw new oe(`${n.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new oe(`${n.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function Xo(n,e){let t=je(n);if(!Object.hasOwn(t,e))throw new oe(`Unknown Bag class '${e}' for TYTX type '${n}'`);return t[e]}function Yo(n,e){return n===e?null:Dm(n)}function*ju(n,e=[]){for(let t of n){let r=[...e,t.label];yield[r,t];let i=t.getValue(!0);!t.resolver&&i instanceof x&&(yield*ju(i,r))}}function Cm(n){let e=n.toISOString(),t=n.getUTCFullYear()===1970&&n.getUTCMonth()===0&&n.getUTCDate()===1,r=n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0;if(r&&!t)return e.slice(0,e.indexOf("T"));let i=e.replace(/\.000Z$/,"Z");return t&&!r?i.slice(i.indexOf("T")+1):i}function Lr(n){if(n===null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Ct(n){return typeof n=="string"?n.includes("::")?`${n}::T`:n:Array.isArray(n)?n.map(Ct):Lr(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,Ct(t)])):n}function Zo(n){if(!Lr(n))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=n;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var Lu=!1,x=class n{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new On,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Zo(t),e!=null&&this.fillFrom(e,t)}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 ze}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 t=[],r=e;for(;r!==null;){if(r.parentBag===this)return t.push(r.label),t.reverse(),t.join(".");t.push(r.label),r=r.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 t=this,r;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),r=e.split(".").filter(i=>i)):r=[...e];r.length&&r[0]==="#parent"&&t!==null;)r.shift(),t=t.parent;return[t,r]}_htraverse(e,t=!1,r=!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 n;){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(r);if(l instanceof n)s.shift(),i=l;else if(t){let u=i.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),s.shift(),i=u}else break}if(!t)return s.length>1?[null,null]:[i,s[0]];for(;s.length>1;){let o=s.shift();if(o.startsWith("#"))throw new $n("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,t=null,r=!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(r,s,i):t}getItem(e,t=null,r=!1,i={}){if(!e)return this;let[s,o]=this._htraverse(e,!1,r);return s instanceof n?s.get(o,t,r,i):t}setItem(e,t,r=null,i=">",s=!1,o=!0,a=null,l=!1,u=!0,c=null,d=null){if(e==="")throw new RangeError("setItem requires a non-empty path");let[f,h]=this._htraverse(e,!0);return f._nodes.set(h,t,i,r,f,c,s,o,a,u,l,d)}_pop(e,t=null){let r=this._nodes.index(e);if(r>=0){let i=this._nodes.pop(r);return this.backref&&this._onNodeDeleted(i,r,t),i}return null}pop(e,t=null,r=null){let i=this.popNode(e,r);return i?i.value:t}delItem(e,t=null,r=null){return this.pop(e,t,r)}popNode(e,t=null){let[r,i]=this._htraverse(e,!1,!0);if(!r||!i)return null;let s=r._nodes.get(i);if(!s)return null;try{return r._pop(i,t)}finally{s.parentBag===r&&r._nodes._dict[s.label]!==s&&(s.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let t of e)t.parentBag=null}getNode(e,t=!0,r=!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,r,t);if(s instanceof n&&o){let a=s._nodes.get(o);if(a)return a;if(r)return s._nodes.set(o,i,">",null,s,null,!1,!0,"autocreate"),s._nodes.get(o)}return null}setBackref(e=null,t=null){let r=this._backref;if(this._backref=!0,this._parent=t,this._parentNode=e,!r){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 t=e.getValue(!0);t instanceof n&&t.clearBackref()}}}_onNodeChanged(e,t,r,i=null,s=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:i,attrs_diff:s,evt:r,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],r,i,s,o,a)}_onNodeInserted(e,t,r=null,i=null,s=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof n&&a.setBackref(e,o),r===null&&(r=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:r,ind:t,evt:"ins",reason:i,fired:s});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...r],i,s)}_onNodeDeleted(e,t,r=null,i=null){for(let s of Object.values(this._delSubscribers))s({node:e,pathlist:r,ind:t,evt:"del",reason:i});this._parent&&this._parentNode&&(r===null&&(r=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...r],i))}_subscribe(e,t,r){r!=null&&(t[e]=r)}subscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:r=null,insert:i=null,delete:s=null,any:o=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,r||o),this._subscribe(e,this._insSubscribers,i||o),this._subscribe(e,this._delSubscribers,s||o)}unsubscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:r=!1,insert:i=!1,delete:s=!1,any:o=!1}=t;(r||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,t=null,r=!0){let i=n.prototype.getNode.call(this,e,!0,!0);i&&i.setAttr(t,!0,!0,r)}getAttr(e=null,t=null,r=null){let i=this.getNode(e);return i?i.getAttr(t,r):r}delAttr(e=null,...t){let r=this.getNode(e);r&&r.delAttr(...t)}getInheritedAttributes(){return this._parentNode?this._parentNode.getInheritedAttributes():{}}getNodes(e=null){return e?[...this._nodes].filter(t=>e(t)):[...this._nodes]}getNodeByValue(e,t){for(let r of this._nodes){let i=r.value;if(i instanceof n){if(i.getItem(e)===t)return r}else if(i&&i.get&&i.get(e)===t)return r}return null}getNodeByAttr(e,t,r=!1,i=!1){let s=t===void 0,o=r&&typeof t=="string"?t.toLowerCase():t,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let d=r&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(s||d==o)return c}if(c._value instanceof n)if(i){let d=a(c._value);if(d)return d}else u.push(c._value)}for(let c of u){let d=a(c);if(d)return d}return null};return a(this)}isEmpty(e=!1,t=!1){if(this._nodes.length===0)return!0;for(let r of this._nodes){if(r._resolver!==null)return!1;let i=r.getValue(!0);if(i!=null&&!(e&&i===0)&&!(t&&i===""))return!1}return!0}query(e=null,t=null,r=!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[h,m]=e.split(":");u=this.getItem(h),e=m}c=e.split(",").map(h=>h.trim())}else c=e;let d=(h,m,p,b,g)=>{if(m==="#k")return h.label;if(m==="#p")return p;if(m==="#n")return h;if(typeof m=="function")return m(h);if(m==="#v"){let _=g();return b&&_ instanceof n?null:_}else if(m.startsWith("#v.")){let _=m.split(".").slice(1).join("."),w=g();return w&&w.getItem?w.getItem(_):null}else{if(m==="#__v")return h.getValue(!0);if(m.startsWith("#a")){let _=m.includes(".")?m.split(".").slice(1).join("."):null;return h.getAttr(_)}else{let _=g();return _&&_.getItem?_.getItem(m):null}}};function*f(){let h=0;function*m(p,b){for(let g of p._nodes){let _=b?`${b}.${g.label}`:g.label,w=!1,E,D=()=>(w||(E=g.getValue(l),w=!0),E);if((s&&o||(D()instanceof n?o:s))&&(t===null||t(g))&&(yield c.length===1?d(g,c[0],_,i,D):c.map(T=>d(g,T,_,i,D)),h++,a!==null&&h>=a))return;if(i){let T=D();if(T instanceof n&&(yield*m(T,_),a!==null&&h>=a))return}}}yield*m(u,"")}return r?f():[...f()]}getLeaves(){let e=[],t=(r,i)=>{for(let s of r._nodes){let o=i?`${i}.${s.label}`:s.label,a=s.getValue(!1);a instanceof n?t(a,o):e.push([o,a])}};return t(this,""),e}digest(e=null,t=null,r=!1){typeof t=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),r=t,t=null);let i=this.query(e,t,!1,!1,!0,!0,null,!1);if(r){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,t=!1){typeof e=="string"&&(e=e.split(","));let r=t?"#a.":"",i=e.map(s=>`${r}${s}`).join(",");return this.digest(i,null,!0)}sum(e="#v",t=!1,r=null){if(t!=null&&typeof t!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(r!=null&&typeof r!="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,r)){if(l==null||l===""){a=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(t)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}o+=l}return t&&a?null:o};return e.includes(",")?e.split(",").map(s=>i(s.trim())):i(e)}sort(e="#k:a"){let t=(i,s)=>i==null?[-1,""]:s&&typeof i=="string"?[0,i.toLowerCase()]:[0,i],r=(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=d=>t(d.label,u);else if(o.toLowerCase()==="#v")c=d=>t(d.value,u);else if(o.toLowerCase().startsWith("#a.")){let d=o.slice(3);c=f=>t(f.getAttr(d),u)}else c=d=>{let f=d.value,h=f instanceof n?f.getItem(o):f?f[o]:null;return t(h,u)};this._nodes._list.sort((d,f)=>{let h=r(c(d),c(f));return l?-h:h})}}return this}equalTo(e){return e instanceof n?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let t=null;e.includes("?")&&([e,t]=e.split("?",2));let r=this.getNode(e);return r===null?!1:t===null?!0:t.split("&").every(i=>i in r.attr)}else if(e&&e.label!==void 0)return[...this._nodes].includes(e);return!1}getResolver(e){let t=this.getNode(e);return t?t.resolver:null}setResolver(e,t){let r=this.getNode(e);r||(this.setItem(e,null),r=this.getNode(e)),r.resolver=t}setCallbackItem(e,t,r={}){let i=new Dt({callback:t,...r});this.setResolver(e,i)}move(e,t,r=!0){this._nodes.move(e,t,r)}asDict(e=!1,t=!1,r=!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)),t&&(l=l.toLowerCase()),r&&a instanceof n&&(a=n.prototype.asDict.call(a,e,t,r,i)),Object.defineProperty(s,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return s}setdefault(e,t=null){let r=this.getNode(e);return r?r.value:(this.setItem(e,t),t)}deepcopy(e=!1){let t=this.createChildBag();for(let r of this._nodes){let i=r.getValue(!e);i instanceof n&&(i=i.deepcopy(e));let s=new t.nodeClass(t,r.label,i);s.setAttr({...r.attr},!1,!1,!1),s.nodeTag=r.nodeTag,s.xmlTag=r.xmlTag,t._nodes._list.push(s),t._nodes._dict[s.label]=s}return t}update(e,t=null,r=null,i=!1){if(!(e instanceof n)){for(let s in e){let o=e[s];(!i||o!==null||!this._nodes.has(s))&&this.setItem(s,o,null,">",!1,!1,r,!1,r!==!1)}return}for(let s of[...e]){let o=s.label,a=t==="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,r===null?!0:r,!0,!1),s.nodeTag!=null&&(c.nodeTag=s.nodeTag),s.xmlTag!=null&&(c.xmlTag=s.xmlTag),a)c.resolver=a,c.setValue(null,r===null?!0:r,null,null,!1,r);else{s.resolver&&(c.resolver=null);let d=c.getValue();l instanceof n&&d instanceof n&&!u?d.update(l,t,r,i):(!i||l!==null)&&c.setValue(l,r===null?!0:r,null,null,!1,r)}else{let d=this.setItem(o,a||l,s.attr,">",!1,!1,r,!1,r!==!1);d.nodeTag=s.nodeTag,d.xmlTag=s.xmlTag}}}_fillFromBag(e){this.clear();for(let t of e){let r=new this.nodeClass(this,t.label);r.replace(t),r.nodeTag=t.nodeTag,r.xmlTag=t.xmlTag,this._nodes._list.push(r),this._nodes._dict[r.label]=r}}_appendLiteral(e,t,r=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,r,i,s,null,!1);return t instanceof K?o.resolver=t:o._value=t,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,t={}){let r=Zo(t);if(e!=null&&!Lr(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,d=Array.isArray(l)?Array.from(l,(f,h)=>[`r_${String(h).padStart(c,"0")}`,f]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(f=>Object.prototype.propertyIsEnumerable.call(l,f)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[f,h]of d){let m=h;r&&(Lr(m)||Array.isArray(m))&&(m=this.createChildBag(),o(m,h,`${u}[${JSON.stringify(f)}]`)),a._appendLiteral(f,m)}}finally{s.delete(l)}};return e!=null&&o(i,e,"$"),this._replacePrepared(i)}_loadSource(e,t={}){return this.fillFrom(e,t)}replace(e){if(!(e instanceof n))throw new TypeError("Bag.replace expects a Bag");if(e===this)return this;let t=this.createChildBag();return t._fillFromBag(e),this._replacePrepared(t)}_replacePrepared(e){for(let r of this._nodes){r.parentBag=null;let i=r.getValue(!0);i instanceof n&&i.clearBackref()}let t=this._nodes;this._nodes=e._nodes,e._nodes=t,this._nodes._parentBag=this.backref?this:null,e._nodes._parentBag=null;for(let r of this._nodes)r.parentBag=this;for(let r of e._nodes)r._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:t=!0,deep:r=!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 d=e(u,c,l);if(d)return d;if(d==null&&r){let f=u.getValue(t);if(f instanceof n){let h=s(f,c);if(h)return h}}}return null};return s(this,i)}*traverse(){for(let e of this._nodes){yield e;let t=e.getValue(!0);t instanceof n&&(yield*t.traverse())}}*_iterNodesWithPaths(e=!0,t=""){for(let r of this._nodes){let i=t?`${t}.${r.label}`:r.label;yield[i,r];let s=r.getValue(e);s instanceof n&&(yield*s._iterNodesWithPaths(e,i))}}*_nodeFlattener(e=null){let t=e!==null,r=t?Object.create(null):null,i=0,s=new Map([["[]",this.constructor]]);for(let[o,a]of ju(this)){let l=o.slice(0,-1),u=JSON.stringify(o),c=JSON.stringify(l),d=a.getValue(!0),f,h=null;if(a.resolver)f=Rn(a.resolver);else if(d instanceof n){let b=d.constructor,g=b.tytxSuffix;s.set(u,b),h=Yo(b,Mr(s.get(c),g)),f=`::${g}`}else d===null?f="::NN":f=Ct(d);if(a.attr&&Object.hasOwn(a.attr,He))throw new oe(`node '${o}': the attribute '${He}' is reserved for the Bag class name`);let m=as(Ct(a.attr));h!==null&&(m[He]=h);let p=a.nodeTag;t?(yield[l.length?r[c]:null,a.label,p,f,m],d instanceof n&&(r[u]=i,e[i]=o,i++)):yield[l,a.label,p,f,m]}}toTytx(e="json",t=!1){let r=this._toTytxPayload(t),i=this.constructor.tytxSuffix;if(e==="json")return`${r}::${i}`;if(e==="msgpack")return Oi(new Ue(4,new TextEncoder().encode(`${i}:${r}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let s={};t={rows:[...this._nodeFlattener(s)],paths:s}}else t={rows:[...this._nodeFlattener(null)]};let r=this.constructor,i=Yo(r,Mr(null,r.tytxSuffix));return i!==null&&(t[He]=i),t.rows=t.rows.map(([s,o,a,l,u])=>[Ct(s),Ct(o),Ct(a),l,u]),t.paths&&(t.paths=Ct(t.paths)),U(t)}static fromTytx(e,t="json",r={}){if(Lr(t)&&(r=t,t="json"),Zo(r),typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError("fromTytx requires serialized text or bytes");if(t!=="json"&&t!=="msgpack")throw new TypeError(`Unsupported transport: ${t}`);t==="json"&&e instanceof Uint8Array&&(e=new TextDecoder().decode(e));let i=j(e,t==="json"?null:t);if(i instanceof n)return i;if(!Lr(i)&&!Array.isArray(i))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(i,r)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Mr(null,t));let r=j(e);if(!r||!Array.isArray(r.rows))throw new oe("Invalid TYTX Bag: expected rows");let i=r.paths,s=i!=null,o=Object.hasOwn(r,He)?Xo(t,r[He]):Mr(null,t),a=new o,l=new Map([["[]",a]]);for(let u of r.rows){if(!Array.isArray(u)||u.length!==5)throw new oe("Invalid TYTX Bag row");let[c,d,f,h,m]=u,p=c??"";if(s){if(c!==null&&!Object.hasOwn(i,c))throw new oe(`Unknown TYTX parent reference: ${c}`);p=c===null?"":i[c]}if(typeof p=="string"&&(p=p?p.split("."):[]),!Array.isArray(p))throw new oe("Invalid TYTX parent path");let b=JSON.stringify(p);if(!l.has(b))throw new oe(`Missing or undecodable TYTX parent branch: ${p}`);let g=l.get(b),_=JSON.stringify([...p,d]),w=h,E=os(w),D=Go(m),y=Object.hasOwn(D,He)?D[He]:null;if(delete D[He],w instanceof n){let S=w.constructor.tytxSuffix,I=y!==null?Xo(S,y):Mr(g.constructor,S);w=new I,l.set(_,w)}else if(y!==null)throw new oe(`node '${_}': the attribute '${He}' is reserved for the Bag class name of a branch`);let T=g._appendLiteral(d,E?null:w,D,E);T.nodeTag=f??null}return a}toXml(e={}){let{pretty:t=!1,encoding:r="UTF-8",docHeader:i=null,selfClosedTags:s=null}=e,o=this._bagToXml(s,t);return i===!0?o=`<?xml version='1.0' encoding='${r}'?>
16
32
  ${o}`:typeof i=="string"&&(o=`${i}
17
33
  ${o}`),o}_bagToXml(e=null,t=!1,r=0){let i=[];for(let s of this._nodes)i.push((t?" ".repeat(r):"")+this._nodeToXml(s,e,t,r));return i.join(t?`
18
- `:"")}_nodeToXml(e,t=null,r=!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(Sn(e.resolver))}"`),e.attr)for(let[f,h]of Object.entries(Qi(e.attr)))h!==null&&h!==!1&&h!==void 0&&a.push(`${f}="${this._escapeAttr(String(h))}"`);let l=a.length?" "+a.join(" "):"",u=e.resolver?null:e.getValue(!0);if(u&&typeof u._bagToXml=="function"){r=r&&e.attr?.["xml:space"]!=="preserve";let f=u._bagToXml(t,r,i+1);return f?r?`<${o}${l}>
34
+ `:"")}_nodeToXml(e,t=null,r=!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(Rn(e.resolver))}"`),e.attr)for(let[f,h]of Object.entries(as(e.attr)))h!==null&&h!==!1&&h!==void 0&&a.push(`${f}="${this._escapeAttr(String(h))}"`);let l=a.length?" "+a.join(" "):"",u=e.resolver?null:e.getValue(!0);if(u&&typeof u._bagToXml=="function"){r=r&&e.attr?.["xml:space"]!=="preserve";let f=u._bagToXml(t,r,i+1);return f?r?`<${o}${l}>
19
35
  ${f}
20
- ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`}if(u==null||u==="")return t===null||t.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?cm(u):String(u),d=this._escapeXml(c);return`<${o}${l}>${d}</${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,t={}){let{tagAttribute:r=null}=t,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 Au.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(i.documentElement,r)}static _xmlElementToBag(e,t=null){let r=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 b=s.attributes[m];a[b.name]=b.value}let l=Ki(a._resolver);l&&delete a._resolver;let u=String(a._T||"").toUpperCase()==="BAG";Object.assign(a,Lo(a));let c=o;"_tag"in a&&(c=a._tag,delete a._tag),t&&t in a&&(c=a[t],delete a[t]);let d=c,f=1;for(;r.getNode(c);)c=`${d}_${f++}`;let h=Array.from(s.childNodes).filter(m=>m.nodeType===1),p;if(h.length>0||u){let m=this._xmlElementToBag(s,t);p=r.setItem(c,m,Object.keys(a).length>0?a:null)}else{let m=s.textContent||"";p=r.setItem(c,m,Object.keys(a).length>0?a:null)}l&&(p.resolver=l),p.xmlTag=o}return r}static async fromUrl(e,t={}){let{timeout:r=30}=t,i={};r&&(i.signal=AbortSignal.timeout(r*1e3));let s=await fetch(e,i),o=s.headers.get("content-type")||"",a=await s.text();if(o.includes("json"))return n.fromTytx(a);if(o.includes("xml"))return n.fromXml(a);let l=a.trim();if(l.startsWith("<"))return n.fromXml(a);if(l.startsWith("{")||l.startsWith("["))return n.fromTytx(a);throw new Cn(`Unsupported content-type: ${o}`)}toJson(e=!0){let t=[];for(let r of this._nodes)t.push(this._nodeToJsonDict(r,e));return e?U(t):JSON.stringify(t)}_nodeToJsonDict(e,t){let r=e.resolver?null:e.getValue(!0);if(r&&typeof r._nodeToJsonDict=="function"){let s=[];for(let o of r._nodes)s.push(r._nodeToJsonDict(o,t));r=s}let i={label:e.label,value:r,attr:Qi(e.attr)};return e.nodeTag!==null&&(i.tag=e.nodeTag),e.resolver&&(i.resolver=Sn(e.resolver)),i}static fromJson(e,t={}){return xu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),xu=!0),this.fromTytx(e,"json",t)}toStringTree(e=!0,t=null,r="",i=!0){t===null&&(t=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),d=l.getAttr(),f="",h=Object.keys(d);h.length>0&&(f=" ["+h.map(g=>`${g}=${JSON.stringify(d[g])}`).join(", ")+"]");let p=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",m=r+(u?" ":"\u2502 ");if(c instanceof n){let b=l,g=c.backref?"(*)":"";if(t.has(b))s.push(`${r}${p}${l.label}${g}${f} \u2192 (circular ref)`);else{t.set(b,l.label),s.push(`${r}${p}${l.label}${g}${f}`);let _=c.toStringTree(e,t,m,u);_&&s.push(_)}}else{let b;if(c===null)b="null";else if(c===void 0)b="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let g=new TextDecoder("utf-8",{fatal:!1}),_=c instanceof ArrayBuffer?new Uint8Array(c):c;b=g.decode(_)}else typeof c=="string"?c.length>50?b=JSON.stringify(c.slice(0,47)+"..."):b=JSON.stringify(c):b=String(c);s.push(`${r}${p}${l.label}: ${b}${f}`)}}return s.join(`
21
- `)}toString(e=!0,t=null,r=""){t||(t=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="",d=a.attr;d&&Object.keys(d).length>0&&(c=` [${Object.entries(d).map(([m,b])=>`${m}=${JSON.stringify(b)}`).join(", ")}]`);let f=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",h=r+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let p=a;if(t.has(p))i.push(`${r}${f}${a.label}${c} \u2192 (circular ref)`);else{t.add(p),i.push(`${r}${f}${a.label}${c}`);let m=u.toString(e,t,h);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(`${r}${f}${a.label}: ${p}${c}`)}}return i.join(`
22
- `)}},Cn=class extends Error{constructor(e){super(e),this.name="BagException"}};J.registerBagClass(D);$o(D,"X",n=>n._toTytxPayload(),n=>D._fromTytxPayload(n));zt(D.tytxSuffix,{...Re(D.tytxSuffix),Bag:D});var Du=new Set(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]);function Su(n){return n.endsWith("_")&&Du.has(n.slice(0,-1))?n.slice(0,-1):n}function Cu(n){let e=Su(n);return e!==n?e:n.startsWith("_")&&Du.has(n.slice(1))?n.slice(1):n}function Nn(n,{renderTag:e=null,ns:t=null,dialectName:r=null}={}){let i=e||n;if(!i)return i;if(i=Su(i),t&&!e){let s=`${r}_`;i.startsWith(s)&&(i=i.slice(s.length)),i=`${t}:${i}`}return i}var $r=Symbol("value"),Ht=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function he(n){return Object.entries(n||{}).filter(([e])=>!Ht.has(e)).map(([e,t])=>[Cu(e),t])}var we=class extends je{constructor(e,t,r=null,i=null,s=null,o=null,a=null){super(e,t,r,i,s,o,a),this._builder=e?._insertingBuilder??e?._builder??null,this._targetId=null}get builder(){if(this._builder)return this._builder;let e=this.parentBag;return e?e._builder:null}get data(){return this.builder.data}get rootBuilder(){return this.parentBag.root._builder}_getMeta(e){let t=this.getAttr("_meta")||{},r=e.split(",").map(i=>i.trim());return r.length===1?t[r[0]]!==void 0?t[r[0]]:null:r.map(i=>t[i]!==void 0?t[i]:null)}pointerType(e){return typeof e=="string"&&(e[0]==="^"||e[0]==="=")&&!e.startsWith("==")?e[0]:null}pointers(){this.builder.validateCustomTypes(this);let e=[];for(let[t,r]of Object.entries(this.getAttr()||{}))this.pointerType(r)==="^"&&e.push([t,r.split(":",1)[0]]);return this.pointerType(this.value)==="^"&&e.push(["",this.value.split(":",1)[0]]),e}fixedAttrItems(){return he(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set($r,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(z(e)?.pointer??e).slice(1));let r=null;return e.includes("?")&&([e,r]=e.split("?",2)),e.startsWith("#")?this._finalizeAbsPath(this._resolveSymbolicDatapath(e,t),r):(e.startsWith(".")&&(e=this._composeRelativeDatapath(e,t)),this._finalizeAbsPath(e,r))}_finalizeAbsPath(e,t){return e=this._collapseParentDatapath(e,e),t?`${e}?${t}`:e}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");i!=null&&(e=e==="."?i:i+e),r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let r=[];for(let i of e.split("."))if(i==="#parent"){if(r.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);r.pop()}else r.push(i);return r.join(".")}_resolveSymbolicDatapath(e,t){let r=e.slice(1),i=r.indexOf("."),s=i===-1?r:r.slice(0,i),o=i===-1?"":r.slice(i+1),a;if(s==="FORM")a=this._findMarkedDatapathAncestor(!0,!1,t);else if(s==="ANCHOR")a=this._findMarkedDatapathAncestor(!1,!0,t);else{let l=this.rootBuilder;if(!l)throw new Error(`#<id>: cannot resolve ${t} on a node without builder`);if(a=l.source.getNodeByAttr("nodeId",s),a==null)throw new Error(`#<id>: cannot resolve ${t}`)}return a.absDatapath(o?`.${o}`:".")}_findMarkedDatapathAncestor(e,t,r){let i=this;for(;i!=null;){let o=i.getAttr()||{};if(e&&(o.formId!=null||o.form===!0)||t&&"_anchor"in o)return i;i=i.parentNode}let s=e?"FORM":"ANCHOR";throw new Error(`#${s}: no marked ancestor found for ${r}`)}getRelativeData(e,t=null,{autocreate:r=!1}={}){let i=this.data,s=this.absDatapath(e);return r&&i.getItem(s)==null&&i.setItem(s,t),i.getItem(s,t)}setRelativeData(e,t,{attributes:r=null,fired:i=!1,reason:s=null}={}){let o=this.data,a=this.absDatapath(e);o.setItem(a,t,r,">",!1,!0,s===null?!0:s,i)}fireEvent(e,t=!0,{attributes:r=null,reason:i=null}={}){this.setRelativeData(e,t,{attributes:r,fired:!0,reason:i})}SET(e,t){this.setRelativeData(e,t)}GET(e){return this.getRelativeData(e)}PUT(e,t){this.setRelativeData(e,t,{reason:!1})}FIRE(e,t=!0){this.setRelativeData(e,t,{fired:!0})}},A=class n extends D{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return we}_setBuilderItem(e,t,r,...i){let s=t?.map(([a])=>[a,a._builder])||null;if(t)for(let[a,l]of t)a._builder=l;let o=this._insertingBuilder;this._insertingBuilder=e;try{return this.setItem(r,...i)}catch(a){if(this.node(r)==null&&s)for(let[l,u]of s)l._builder=u;throw a}finally{this._insertingBuilder=o}}bindBuilder(e){if(!e)throw new Error("SourceBag.bindBuilder requires a builder");let t=this._builderBindingPlan(e);for(let[r,i]of t)r._builder=i;return this.setBackref(),this}_builderBindingPlan(e){let t=[],r=new WeakSet,i=(s,o)=>{if(r.has(s))throw new Error("source contains a cyclic or shared SourceBag branch");r.add(s),t.push([s,o]);for(let a of s.getNodes()){let l=o,u=a._getMeta("subbuilder");u!=null&&(l=o._resolveSubbuilderReference(u,a.getAttr()||{},a.nodeTag)),t.push([a,l]);let c=a.getValue(!0);c instanceof n&&i(c,l)}};return i(this,e),t}};if((Re(A.tytxSuffix).SourceBag??A)!==A)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");zt(A.tytxSuffix,{...Re(A.tytxSuffix),SourceBag:A});function pm(n){if(n.length===0)return{value:null,attrs:{}};let e=n[0];if(e!==null&&typeof e=="object"){let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null)return{value:null,attrs:e}}return{value:e,attrs:n[1]||{}}}var mm=new Set(["then","toJSON"]),Iu=new WeakMap;function Y(n){return Iu.get(n)||n}function In(n){if(n==null)return n;n=Y(n);let e=n._builder||n.parentBag&&n.parentBag._builder;return e?e.wrapSource(n):n}function Ou(n,e){let t=e instanceof D,r=new Proxy(e,{get(i,s){if(typeof s=="symbol"||s.startsWith("_")||mm.has(s))return Reflect.get(i,s,i);let o=n.schemaTag(s);if(t&&o)return Nu(n,i,o,t);if(s in i){let l=Reflect.get(i,s,i);return typeof l=="function"?l.bind(i):l}if(o)return Nu(n,i,o,t);let a=n.containerMethod(s);if(a)return(...l)=>n[a](n.wrapSource(i),...l)}});return Iu.set(r,e),r}function Nu(n,e,t,r){return(...i)=>{let{value:s,attrs:o}=pm(i),a=r?n.bagCall(e,t,s,o):n.commandOnNode(e,t,s,o);return a.builder.wrapSource(a)}}function Uo(n,e,{transport:t="json"}={}){let r=P(n,t==="json"?null:t);if(!(r instanceof A))throw new TypeError("TYTX payload did not decode to SourceBag");return r.bindBuilder(e)}var Ru=/^[A-Za-z_][A-Za-z0-9_]*$/,gm=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),bm=new Set(["framework","value","attribute"]),_m=new Map([["builtins.str",n=>typeof n=="string"],["builtins.int",n=>Number.isInteger(n)],["builtins.float",n=>typeof n=="number"&&Number.isFinite(n)],["builtins.bool",n=>typeof n=="boolean"],["builtins.list",n=>Array.isArray(n)],["builtins.dict",n=>n!==null&&typeof n=="object"&&!Array.isArray(n)],["builtins.tuple",n=>Array.isArray(n)],["builtins.set",n=>Array.isArray(n)||n instanceof Set],["builtins.NoneType",n=>n===null],["builtins.object",n=>!0]]);function Gt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function T(n,e){throw new TypeError(`${n}: ${e}`)}function Ke(n,e,t,r){Gt(n)||T(r,"must be an object");for(let i of Object.keys(n))e.includes(i)||T(r,`unknown field '${i}'`);for(let i of t)Object.hasOwn(n,i)||T(r,`missing field '${i}'`)}function Xt(n,e){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n))return n.forEach((t,r)=>Xt(t,`${e}[${r}]`));if(Gt(n))return Object.entries(n).forEach(([t,r])=>Xt(r,`${e}.${t}`));T(e,"must be lossless JSON data")}}function wm(n,e){let t="",r=!1;for(let i=0;i<n.length;i++){let s=n[i];if(s==="\\"){t+=s+(n[++i]??"");continue}s==="["&&(r=!0),!r&&s==="."&&!(e&16)?t+="[^\\n]":!r&&s==="^"&&e&8?t+="(?:^|(?<=\\n))":!r&&s==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=s,s==="]"&&(r=!1)}return t}function Wt(n,e,t=!1,r=null){if(n===null)return null;switch(Ke(n,["kind","dtype","module","name","origin","arguments","items","values","base","metadata","pattern","flags","ge","le","gt","lt","value"],["kind"],e),n.kind){case"custom":return Ke(n,["kind","name"],["kind","name"],e),r||T(e,"custom references require a catalog; nested catalog references are unsupported"),r.resolve(n.name,e);case"dtype":{Ke(n,["kind","dtype"],["kind","dtype"],e);let i=n.dtype;typeof i!="string"&&T(e,"dtype must be a string");let s=An(i);return!s&&i!=="NN"&&T(e,`unknown dtype '${i}'`),{...n,test:a=>i==="NN"?a===null:i==="N"?fe(a)&&!["NaN","Infinity","-Infinity"].includes(a.toString()):s===Number?typeof a=="number"&&Number.isFinite(a)&&(i!=="L"||Number.isInteger(a)):s===String?typeof a=="string":s===Boolean?typeof a=="boolean":s===Date?a instanceof Date&&Number.isFinite(a.getTime()):s===Object?Gt(a)&&[Object.prototype,null].includes(Object.getPrototypeOf(a)):a instanceof s}}case"any":return{...n,test:i=>!0};case"type":{(typeof n.module!="string"||typeof n.name!="string")&&T(e,"type requires string module/name");let i=`${n.module}.${n.name}`;if(i==="collections.abc.Callable")return{...n,test:o=>typeof o=="function",portable:!1};let s=_m.get(i);return s||T(e,`unsupported type '${i}'`),{...n,test:s}}case"union":{(!Array.isArray(n.items)||!n.items.length)&&T(e,"union items must be non-empty");let i=n.items.map((s,o)=>Wt(s,`${e}.items[${o}]`,!0,r));return{...n,items:i,inputConstraint:i.some(s=>s.inputConstraint),test:s=>i.some(o=>o.test&&o.test(s))}}case"literal":return Array.isArray(n.values)||T(e,"literal values must be an array"),n.values.forEach((i,s)=>Xt(i,`${e}.values[${s}]`)),{...n,test:i=>n.values.some(s=>Object.is(s,i))};case"annotated":{Array.isArray(n.metadata)||T(e,"annotated metadata must be an array"),n.metadata.some(o=>!["regex","range","value"].includes(o?.kind))&&T(e,"unsupported annotation metadata kind");let i=Wt(n.base,`${e}.base`,!0,r),s=n.metadata.map((o,a)=>Wt(o,`${e}.metadata[${a}]`,!0,r));return{...n,base:i,metadata:s,inputConstraint:i.inputConstraint,test:o=>i.test(o)&&s.every(a=>!a.test||a.test(o))}}case"range":{for(let i of["ge","le","gt","lt"])Object.hasOwn(n,i)||T(e,`range missing '${i}'`);for(let i of["ge","le","gt","lt"])n[i]!==null&&(typeof n[i]!="number"||!Number.isFinite(n[i]))&&T(e,`${i} must be finite number or null`);return{...n,test:i=>typeof i=="number"&&(n.ge===null||i>=n.ge)&&(n.le===null||i<=n.le)&&(n.gt===null||i>n.gt)&&(n.lt===null||i<n.lt)}}case"regex":{(typeof n.pattern!="string"||!Number.isInteger(n.flags)||n.flags<0)&&T(e,"regex requires pattern and non-negative integer flags");let i=n.flags&-59;i&&T(e,`unsupported Python regex flags ${i}`),n.flags&2&&T(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(n.pattern.replaceAll(String.raw`[\s\S]`,"."))&&T(e,"regex uses a non-portable construct or character class");let s="uy";n.flags&16&&(s+="s");let o;try{o=new RegExp(`(?:${wm(n.pattern,n.flags)})(?![\\s\\S])`,s)}catch(a){T(e,`invalid portable regex: ${a.message}`)}return{...n,test:a=>typeof a!="string"?!1:(o.lastIndex=0,o.test(a))}}case"value":return Xt(n.value,`${e}.value`),{...n};case"generic":{let i=Wt(n.origin,`${e}.origin`,!0,r);(n.origin?.kind!=="type"||n.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(n.origin.name))&&T(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(n.arguments)||T(e,"generic arguments must be an array");let s=n.arguments.map((o,a)=>Wt(o,`${e}.arguments[${a}]`,!0,r));return{...n,origin:i,arguments:s,inputConstraint:s.some(o=>o.inputConstraint),test:o=>i.test(o)&&ym(n.origin,s,o)}}case"arguments":T(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||T(e,"ellipsis is only valid as a nested descriptor"),{...n};default:T(e,`unknown annotation kind '${n.kind}'`)}}function ym(n,e,t){let r=`${n.module}.${n.name}`;return r==="builtins.tuple"&&e.length&&e[1]?.kind!=="ellipsis"?t.length===e.length&&t.every((i,s)=>e[s].test(i)):r==="builtins.list"||r==="builtins.set"||r==="builtins.tuple"?[...t].every(i=>!e[0]?.test||e[0].test(i)):r==="builtins.dict"?Object.entries(t).every(([i,s])=>(!e[0]?.test||e[0].test(i))&&(!e[1]?.test||e[1].test(s))):!1}function $u(n,e){if(n===null)return null;if(typeof n!="string"&&T(e,"must be string or null"),n==="")return new Map;let t=new Map;for(let r of n.split(",")){let i=r.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(i)&&T(e,`invalid cardinality item '${r}'`);let s=i.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);s||T(e,`invalid cardinality item '${r}'`);let[,o,a,l,u]=s;t.has(o)&&T(e,`duplicate tag '${o}'`);let c=0,d=1/0;i.includes("[")&&(i.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(a)),d<c&&T(e,`maximum ${d} is below minimum ${c}`),t.set(o,{min:c,max:d})}return t.has("*")&&t.size>1&&T(e,"wildcard '*' cannot be combined with named tags"),t}function Mu(n,e){if(n===null)return null;typeof n!="string"&&T(e,"must be string or null");let t=new Set;for(let r of n.split(",")){let i=r.trim();i&&((!Ru.test(i)||t.has(i))&&T(e,`invalid or duplicate parent '${r}'`),t.add(i))}return t}function vm(n,e,t){if(n===null)return null;Ke(n,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let r=n.parameters??[];Array.isArray(r)||T(e,"parameters must be an array"),n={parameters:r,accepts_var_keyword:r.some(l=>l.kind==="var_keyword"),accepts_var_positional:r.some(l=>l.kind==="var_positional"),...n},(!Array.isArray(n.parameters)||typeof n.accepts_var_keyword!="boolean"||typeof n.accepts_var_positional!="boolean")&&T(e,"invalid signature descriptor");let i=new Set,s=!1,o=!1,a=n.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return Ke(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!Ru.test(l.name)||i.has(l.name))&&T(c,"invalid or duplicate parameter name"),i.add(l.name),(!gm.has(l.kind)||!bm.has(l.role)||typeof l.has_default!="boolean")&&T(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&T(c,"default presence must equal has_default"),l.has_default&&Xt(l.default,`${c}.default`),s||=l.kind==="var_keyword",o||=l.kind==="var_positional",{...l,annotation:Wt(l.annotation,`${c}.annotation`,!1,t)}});return(s!==n.accepts_var_keyword||o!==n.accepts_var_positional)&&T(e,"variadic summary flags do not match parameters"),{...n,parameters:a}}function Bu(n,e,t,r){let i=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];Ke(n,i,[],e),n={...Object.fromEntries(i.map(s=>[s,null])),...n};for(let s of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])n[s]!==null&&typeof n[s]!="string"&&T(e,`${s} must be string or null`);return n._meta!==null&&(Gt(n._meta)||T(e,"_meta must be object or null"),Xt(n._meta,`${e}._meta`)),$u(n.sub_tags,`${e}.sub_tags`),Mu(n.parent_tags,`${e}.parent_tags`),{...n,attributes:vm(n.attributes,`${e}.attributes`,r)}}function Lu(n){return n?n.split(",").map(e=>e.trim()).filter(Boolean):[]}function Pu(n,e){let t={...e};for(let[r,i]of Object.entries(n))r==="inherits_from"||r.startsWith("_")||t[r]||(t[r]=i);return t._meta={...n._meta||{},...e._meta||{}},t}function ju(n){let e={...n};return e._subSpec=Object.hasOwn(e,"sub_tags")?$u(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?Mu(e.parent_tags,"resolved.parent_tags"):null,e}function Fu(n,e,t,r){if(t.get(n)===1&&T(r,`inheritance cycle at '${n}'`),t.get(n)===2)return e[n];let i=e[n];i||T(r,`unknown abstract '${n}'`),t.set(n,1);let s={...i};for(let o of Lu(i.inherits_from))s=Pu(Fu(o,e,t,r),s);return s=ju(s),t.set(n,2),e[n]=s,s}function qo({abstracts:n={},elements:e={}}){let t={...n},r=new Map;for(let s of Object.keys(t))Fu(s,t,r,`abstracts.${s}.inherits_from`);let i={};for(let[s,o]of Object.entries(e)){let a={...o};for(let l of Lu(o.inherits_from)){let u=t[l];u||T(`elements.${s}.inherits_from`,`unknown abstract '${l}'`),a=Pu(u,a)}i[s]=ju(a)}return{abstracts:t,elements:i}}function Vo(n){Ke(n,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),Ke(n.document_format,["name","version"],["name","version"],"document_format"),(n.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(n.document_format.version))&&T("document_format","expected builder_grammar version 1.1 or 1.2"),Ke(n.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof n.grammar.name!="string"||!n.grammar.name)&&T("grammar.name","must be non-empty string");for(let i of["version","title","description"])n.grammar[i]!==null&&typeof n.grammar[i]!="string"&&T(`grammar.${i}`,"must be string or null");(!Gt(n.abstracts)||!Gt(n.elements))&&T("grammar document","abstracts/elements must be objects"),Object.hasOwn(n,"custom_types")&&n.document_format.version!=="1.2"&&T("custom_types","requires version 1.2");let e=Mr.fromJSON(n.custom_types??{}),t={};for(let[i,s]of Object.entries(n.abstracts))(!i||i.startsWith("_"))&&T("abstracts",`invalid public name '${i}'`),t[i]=Bu(s,`abstracts.${i}`,!1,e);let r={};for(let[i,s]of Object.entries(n.elements))(!i||i.startsWith("_"))&&T("elements",`invalid public name '${i}'`),r[i]=Bu(s,`elements.${i}`,!0,e);return{grammar:structuredClone(n.grammar),abstracts:t,elements:r}}function Uu(n,e,t,r){let i=e.attributes;if(!i)return;let s={...r};t!=null&&(s.node_value=t);let o=new Set(i.parameters.filter(u=>u.role==="attribute").map(u=>u.name)),a=new Set(["node_label","node_position","nodeId","target_id","datapath","iterate","store","_tag","_meta","ns"]);if(!i.accepts_var_keyword)for(let u of Object.keys(r))!o.has(u)&&!a.has(u)&&T(n,`unknown attribute '${u}'`);let l=e._meta?.component?i.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of i.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(s,u.name);!c&&!u.has_default&&T(n,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(s[u.name]))&&T(n,`invalid value for ${u.role} '${u.name}'`)}}var Mr=class n{#e=new Map;#t=new Map;register(e,t,r){let i=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),s=i.has(t)?{kind:"type",module:"builtins",name:i.get(t)}:t;return this.#r(e,{kind:"annotated",base:s,metadata:[r]})}#r(e,t){(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/.test(e)||e in this||["to_dict","from_dict"].includes(e)||Em.has(e))&&T("custom_types",`invalid, reserved or duplicate name '${e}'`),Ke(t,["kind","base","metadata"],["kind","base","metadata"],`custom_types.${e}`),(t.kind!=="annotated"||!Array.isArray(t.metadata)||t.metadata.length!==1||!["regex","range"].includes(t.metadata[0]?.kind))&&T(`custom_types.${e}`,"requires an annotated base with one Regex or Range validator");let r=t.metadata[0].kind==="regex"?["str"]:["int","float"];(t.base?.kind!=="type"||t.base.module!=="builtins"||!r.includes(t.base.name))&&T(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Xt(t,`custom_types.${e}`);let i=structuredClone(t),s=Wt(i,`custom_types.${e}`),o=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:o,enumerable:!0}),this.#e.set(e,i),this.#t.set(e,{...o,inputConstraint:!0,test:s.test}),o}resolve(e,t="custom_types"){return this.#t.has(e)||T(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||T(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){Gt(e)||T("custom_types","must be an object");let t=new n;for(let[r,i]of Object.entries(e))t.#r(r,i);return t}},Em=new Set("False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield".split(" "));function qu(n,e,t,r){let i=e?.attributes;if(i)for(let s of i.parameters){if(!s.annotation?.inputConstraint||s.role==="framework"||["var_keyword","var_positional"].includes(s.kind))continue;let o=s.role==="value"?t:r[s.name];o!==void 0&&(s.annotation.test(o)||T(n,`invalid input for '${s.name}' (custom type)`))}}function Vu(n,e,t=[]){if(e===null)return structuredClone(n);if(t.length===2&&t[0]==="custom_types"&&n!==void 0){if(!zo(n,e))throw new TypeError(`conflicting custom type '${t[1]}'`);return structuredClone(n)}if(t.length===2&&["abstracts","elements"].includes(t[0]))return structuredClone(e);if(st(n)&&st(e)){let r=structuredClone(n);for(let[i,s]of Object.entries(e))s!==null&&Object.defineProperty(r,i,{value:Vu(r[i],s,[...t,i]),enumerable:!0,writable:!0,configurable:!0});return r}return structuredClone(e)}function zo(n,e){return Object.is(n,e)?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>zo(t,e[r])):st(n)&&st(e)?Object.keys(n).length===Object.keys(e).length&&Object.keys(n).every(t=>Object.hasOwn(e,t)&&zo(n[t],e[t])):!1}function st(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function Ho(n){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n)){n.forEach(Ho);return}if(st(n)){Object.values(n).forEach(Ho);return}throw new TypeError("collection must contain only finite JSON values")}}var ot=class n{#e;constructor(e){Ho(e);let t=["document_format","grammar","abstracts","elements"];if(!st(e)||Object.keys(e).some(i=>![...t,"custom_types"].includes(i))||t.some(i=>!Object.hasOwn(e,i)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let r=e.document_format;if(!st(r)||Object.keys(r).length!==2||r.name!=="builder_grammar"||!["1.1","1.2"].includes(r.version))throw new TypeError("expected builder_grammar version 1.1 or 1.2");for(let i of["grammar","abstracts","elements"])if(!st(e[i]))throw new TypeError(`${i} must be an object`);if(Object.hasOwn(e,"custom_types")&&(r.version!=="1.2"||!st(e.custom_types)))throw new TypeError("custom_types requires an object catalog and version 1.2");this.#e=structuredClone(e)}update(e){let t=new n(e),r=Vu(this.#e,t.#e);return(this.#e.document_format.version==="1.2"||t.#e.document_format.version==="1.2")&&(r.document_format.version="1.2"),this.#e=r,this}toDocument(){return structuredClone(this.#e)}};var Yt=class{static renderType="string";static mode=null;constructor(e){this._builder=e,this.renders=new Map([[e,this]])}get builder(){return this._builder}get renderType(){return this.constructor.renderType}get mode(){return this.constructor.mode}addRender(e,t){this.renders.set(e,t)}getRender(e){let t=this.renders.get(e);if(t!==void 0)return t;let r=e.getRenderer();return this.renders.set(e,r),r}render(e,t={}){let r=e.builder,[i,s]=r.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,s,t);let o=this.getRender(r),a;return[a,s]=o._handleMeta(e,s),e._getMeta("subbuilder")||(s=o.adaptAttrs(s)),e.value instanceof A&&(i=this.renderChildren(e.value,t)),o.renderedItem(e,i,s,{tag:a,...t})}renderChildren(e,t={}){let r=[];for(let i of e.getNodes()){let s=this.render(i,t);s!==null&&(Array.isArray(s)?r.push(...s):r.push(s))}return r}_renderComponent(e,t,r){let[i,s,o,a]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,i,o,a,r);if(s==null)return[];if(!(s instanceof D))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${s?.constructor?.name||typeof s}`);return s.getNodes().map(l=>this._expandBlock(e,i,o,{node_label:l.label},r))}_expansionInputs(e,t){let r=e.builder,i=r.componentMethod(e.nodeTag),s=i&&r[i];if(typeof s!="function")throw new Error(`component '${e.nodeTag}' has no implementation`);let o=t.iterate;delete t.iterate,delete t.store;let a=e.getAttr("iterate")||e.getAttr("store");a!=null?(e.pointerType(a)&&(a=a.slice(1)),a.startsWith(".")&&(a=e._composeRelativeDatapath(a,a))):a=null;for(let l of Object.keys(t)){let u=e.getAttr(l);e.pointerType(u)==="^"&&(t[l]=`^${e.absDatapath(u)}`)}return[s,o,a,t]}_expandBlock(e,t,r,i,s){let o=e.builder._expansionRoot(r);t.call(e.builder,In(o),i);let a=o.getNodes();if(a.length!==1)throw new Error(`component '${e.nodeTag}' must build a tree, not a forest: ${a.length} root nodes`);let l={...s,depthOffset:this._nodeDepth(e,s.depthOffset||0)};return this.render(a[0],l)}preprocess(e){return e}renderedItem(e,t,r,i){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[r,i]=e._getMeta("render_tag,render_attributes"),s=Nn(e.nodeTag,{renderTag:r,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!s)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return i&&(t={...t,...i}),[s,t]}adaptAttrs(e){return e}adapt(e){let t=`${this.builder.constructor._name}_`;return e.startsWith(t)?e.slice(t.length):e}finalize(e,t=null,r={}){let i=this._composeStringFragments(e);if(t==null)return i;if(typeof t=="string")throw new TypeError("string render targets require filesystem support, which is unavailable in the portable renderer; pass a callable or writable target instead");if(typeof t.full=="function"&&typeof t.write!="function")return t.full(i),null;if(typeof t.write=="function")return t.write(i),null;if(typeof t=="function")return t(i),null;throw new TypeError("render target must be writable (.write), callable, or expose .full")}_composeStringFragments(e){if(!Array.isArray(e))return e;if(e.some(t=>typeof t!="string"))throw new TypeError("String composition requires string fragments; object renderers must define their own composition");return e.join("")}_escapeText(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',"&quot;")}_nodeDepth(e,t=0){let i=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(i-1,0)+t}};var Zt=class extends Yt{static mode="xml";renderedItem(e,t,r,{tag:i,pretty:s=!1,depthOffset:o=0}={}){let a=this._formatAttrs(r),l=s?" ".repeat(this._nodeDepth(e,o)):"",u=s?`
23
- `:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${i}${a}>${u}${c}${l}</${i}>${u}`}return t==null?`${l}<${i}${a}></${i}>${u}`:`${l}<${i}${a}>${this._escapeText(t)}</${i}>${u}`}finalize(e,t=null,{docHeader:r=null}={}){let i=this._composeStringFragments(e);return r===!0?i=`<?xml version='1.0' encoding='UTF-8'?>${i}`:typeof r=="string"&&(i=r+i),super.finalize(i,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,r])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(r)}"`).join("")}};var zu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"base",version:null,title:null,description:null},abstracts:{},elements:{dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};function Hu(n){let e=[];for(;n&&n!==Function.prototype;)e.push(n),n=Object.getPrototypeOf(n);return e.reverse()}function xm(n){let e=Object.create(null),t=(r,i)=>{let s=r.toLowerCase(),o=e[s];if(o!==void 0&&o!==i)throw new Error(`container '${r}' is already tied to implementation method '${o}' (cannot rebind to '${i}')`);e[s]=i};for(let r of Hu(n))if(Object.hasOwn(r,"containers"))for(let i of r.containers||[])t(i,i);return e}function On(n){let e=Object.create(null);for(let t of Object.keys(n)){let r=t.toLowerCase();if(Object.hasOwn(e,r))throw new Error(`element declaration '${t}' has a case-insensitive collision with '${e[r]}'`);e[r]=t}return e}var Bn="_root_",Rn="_root_",Wu=new Set(["destination","func","value","_on_start"]),ye=class n{static _sourceClass=A;static registerBuilder(e){if(typeof e!="function"||!(e.prototype instanceof n))throw new TypeError("registerBuilder requires a BuilderBase subclass");let t=e._name;if(typeof t!="string"||!t)throw new TypeError("registered builders require a non-empty static _name");let r=n._registry.get(t);if(r&&r!==e)throw new Error(`Builder name '${t}' is already registered to ${r.name}; cannot register ${e.name}`);return n._registry.set(t,e),e}static getBuilderClass(e){let t=n._registry.get(e);if(!t)throw new Error(`No builder registered with name '${e}'`);return t}constructor(e=null){this.name=e||this.constructor._name,this._dataroot=new D,this._dataroot.setBackref(),this._dataroot.setItem(Rn,new D),this.data=this._dataroot.getItem(Rn),this._defaultTargets=new Map,this.materialized=Object.create(null),this._collection=null,this._schemaOverride=null,this._tagNamesOverride=null,this._componentMap=null,this._targetSerial=0,this._subbuilders=new Map,this._sourceHandles=new WeakMap;let t=this.constructor._sourceClass;this._sourceroot=new t(null,this),this._sourceroot.setBackref(),this._sourceroot.setItem(Bn,new t(null,this)),this.source=this._sourceroot.getItem(Bn)}wrapSource(e){if(e=Y(e),!(e instanceof A)&&!(e instanceof we))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=Ou(this,e),this._sourceHandles.set(e,t)),t}get root(){return this.wrapSource(this.source)}getSubbuilder(e){if(typeof e!="string"||!e||e.includes(":"))throw new Error(`unsupported subbuilder reference '${e}'`);let t=this._subbuilders.get(e);if(!t){let r=n.getBuilderClass(e);t=new r,this._subbuilders.set(e,t)}return t._dataroot=this._dataroot,t.data=this.data,t}_resolveSubbuilderReference(e,t,r){if(typeof e!="string"||!e)throw new Error(`'${r}': subbuilder declaration must be a non-empty string`);if(e.includes(":"))throw new Error(`'${r}': runtime subbuilder reference '${e}' is unsupported`);return this.getSubbuilder(e)}static defineGrammar(e){let t=this._classCollection,r=t?new ot(t.toDocument()).update(e):new ot(e),i=Vo(r.toDocument()),s=qo(i),o=On(s.elements);this._classCollection=r,this._classSchema=s.elements,this._abstracts=s.abstracts,this._tagNames=o}static{this.defineGrammar(zu)}get _containers(){return xm(this.constructor)}containerMethod(e){return this._containers[e.toLowerCase()]||null}componentMethod(e){return this._componentMap?.[e.toLowerCase()]||null}get schema(){return this._schemaOverride||this.constructor._classSchema||{}}get schemaTagNames(){return this._schemaOverride?this._tagNamesOverride??=On(this.schema):this.constructor._tagNames??=On(this.schema)}schemaTag(e){let t=e.toLowerCase(),r=this.schemaTagNames[t];if(r)return r;let i=`${this.constructor._name}_`;return t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)]||null}loadGrammar(e,{replace:t=!1}={}){let r=this._collection||this.constructor._classCollection,i=t?new ot(e):new ot(r.toDocument()).update(e),s=Vo(i.toDocument()),o=qo(s),a=On(o.elements);return this._collection=i,this._schemaOverride=o.elements,this._tagNamesOverride=a,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,r=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;qu(e.nodeTag,r.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,r={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);return Uu(i,this.schema[i],t,r),!0}validateNode(e,{value:t,attrs:r,childTags:i}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let s=t!==void 0?t:e.value instanceof A?null:e.value;this.validateNodeValues(e.nodeTag,s,r||e.getAttr?.()||{});let o=this.schema[this.schemaTag(e.nodeTag)],a=i||(e.value instanceof A?e.value.getNodes().map(l=>l.nodeTag):null);return a&&this._validateChildren(e.nodeTag,o,a,!1),!0}validateChildren(e,t,{includeMinimum:r=!1}={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(s=>typeof s!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(i,this.schema[i],t,r)}validateParent(e,t=null){let r=this.schemaTag(e);if(!r)throw new Error(`unknown element '${e}'`);let i=this.schema[r];if(!this._countsForGrammar(i))return!0;let s=i._parentSpec;if(s==null||s.has("*"))return!0;if(t===null)throw new Error(`'${r}' requires a declared parent`);let o=this.schemaTag(t);if(!o)throw new Error(`unknown parent element '${t}'`);return this._validateParent(r,i,o),!0}bagCall(e,t,r,i){return this.setChild(e,t,r,i)}commandOnNode(e,t,r,i){if(e=Y(e),e.value instanceof A)return this.setChild(e.value,t,r,i);let s=e.value,o=new e.parentBag.constructor(null,e.builder||this),a=this.setChild(o,t,r,i,e);return this.promoteNodeValue(e,s,o),a}promoteNodeValue(e,t,r){e.setValue(r)}setChild(e,t,r,i,s=null){let o={...i},a=this.schema[t];if(!a)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,r,o);let l=a._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,o,t))||this,d=r instanceof A?r._builderBindingPlan(c):null,f=s?.rootBuilder||e.root._builder||this;if(o.nodeId!=null&&f.source.getNodeByAttr("nodeId",o.nodeId))throw new Error(`Duplicate nodeId '${o.nodeId}'`);r instanceof A&&this._validateChildren(t,a,r.getNodes().map(w=>w.nodeTag),!1);let h=s||e.parentNode,p=h?.nodeTag?this.schema[h.nodeTag]:null;if(p&&!h._getMeta("subbuilder")&&this._countsForGrammar(a))this._validateParent(t,a,h.nodeTag),this._validateChildren(h.nodeTag,p,[...e.getNodes().map(w=>w.nodeTag),t],!1);else if(!p&&!h?._getMeta("subbuilder")&&a._parentSpec!=null&&this._countsForGrammar(a))throw new Error(`'${t}' requires a declared parent`);a._meta&&!("_meta"in o)&&(o._meta=a._meta),a.ns&&!("ns"in o)&&(o.ns=a.ns);let m=o.node_position;delete o.node_position;let b=o.node_label;delete o.node_label;let g;if(p?.collection_key){if(b!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);g=this._collectionLabel(p.collection_key,t,o)}else{let w=p?._subSpec?.get(t);if(w&&w.max===1){if(b!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);g=t}else g=b||a.node_label||this._autoLabel(e,t)}if(e.node(g)!=null)throw new Error(`duplicate node label '${g}'`);return e._setBuilderItem(c,d,g,r,o,m||">",!1,!0,null,!1,!0,null,t)}_countsForGrammar(e){let t=e?._meta||{};return!(t.data_element||t.subbuilder||t.component)}_validateParent(e,t,r){let i=t._parentSpec;if(!(i==null||i.has("*")||!this._countsForGrammar(t))&&!i.has(r))throw new Error(`'${e}' not allowed as child of '${r}'`)}_validateChildren(e,t,r,i){let s=t._subSpec;if(s==null||s.has("*")||t._meta?.subbuilder)return[];let o=new Map;for(let a of r){let l=this.schema[a];if(l&&!this._countsForGrammar(l))continue;let u=s.get(a);if(!u)throw new Error(`'${a}' not allowed as child of '${e}'`);let c=(o.get(a)||0)+1;if(o.set(a,c),c>u.max)throw new Error(`too many '${a}' in '${e}'`)}return i?[...s].filter(([a,l])=>(o.get(a)||0)<l.min).map(([a])=>a):[]}_collectionLabel(e,t,r){let i=s=>{if(r[s]===null||r[s]===void 0)throw new Error(`'${t}': collection key needs attribute '${s}'`);return String(r[s])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(s,o)=>i(o)):i(e)}validateSource(){let e=[],t=(r,i="")=>{for(let s of r.getNodes()){let o=i?`${i}.${s.label}`:s.label,a=s.builder;a.validateCustomTypes(s);let l=a.schema[s.nodeTag];if(l&&!s._getMeta("data_element,subbuilder,component").some(Boolean)){let u=s.value instanceof A?s.value.getNodes().map(d=>d.nodeTag):[],c=a._validateChildren(s.nodeTag,l,u,!0);c.length&&e.push([o,c])}s.value instanceof A&&t(s.value,o)}};return t(this.source),e}_autoLabel(e,t){let r=0;for(;e.node(`${t}_${r}`)!==null&&e.node(`${t}_${r}`)!==void 0;)r+=1;return`${t}_${r}`}nodeById(e){let t=this.source.getNodeByAttr("nodeId",e);if(t==null)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}runtimeValues(e){e.builder.validateCustomTypes(e);let t=new Map,r={},i=e.runtimeToEvaluate(),s=new Set(i.keys()),o=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...i])if(!(typeof c!="string"||!z(d)))for(let f of ze(e,d))i.has(f)||i.set(f,o.get(f));let a=e._getMeta("data_element");for(let[c,d]of i){if(d instanceof J){t.set(c,d.resolve());continue}let f=typeof c=="string"?z(d)?.pointer??d:d;if(!e.pointerType(f)){t.set(c,typeof c=="string"&&typeof d=="string"&&d.startsWith("==")?null:d);continue}let h=e.absDatapath(f);if(t.set(c,this.data.getItem(h)),!a&&!h.includes("?")&&c===$r){let p=this.data.getNode(h);p&&Object.assign(r,p.getAttr("_wdg"))}}let l=Ea(i,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get($r);l.delete($r);for(let c of l.keys())s.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...r}]}evaluatePointerExpression(e,t,r,i,s){return null}targetId(e){if(e._targetId)return e._targetId;let t=e.rootBuilder;return e.parentBag.root!==t.source.root?null:(t._targetSerial+=1,e._targetId=`n${t._targetSerial}`,e._targetId)}get dataLogic(){if(!this._dataLogic){let e=this._buildDataLogic();this._dataLogic=Array.isArray(e)?e:[e]}return this._dataLogic}_buildDataLogic(){return this}_resolveLogicFunc(e){if(typeof e=="function")return e;if(typeof e!="string")throw new Error("data-element func must be a name or a function");for(let t of this.dataLogic){let i=(typeof t=="function"?t:t.constructor)[e];if(typeof i=="function")return i}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),r={};for(let[i,s]of Object.entries(t))Wu.has(i)||(r[i]=s);return r}computeLogic(e){for(let t of e)this._computeNode(t)}_computeNode(e){let t=e.getAttr()||{};if(e.nodeTag==="dataSetter"){let r={};for(let[i,s]of Object.entries(t))i!=="destination"&&i!=="value"&&!i.startsWith("_")&&(r[i]=s);e.setRelativeData(t.destination,t.value,{attributes:Object.keys(r).length?r:null})}else if(e.nodeTag==="dataFormula"){let r=this._resolveLogicFunc(t.func);e.setRelativeData(t.destination,r(this._bindings(e)))}else e.nodeTag==="dataController"&&this._resolveLogicFunc(t.func)(e,this._bindings(e))}_dataElementNodes(){let e=[],t=r=>{for(let i of r.getNodes())i._getMeta("data_element")&&e.push(i),i.value instanceof A&&t(i.value)};return t(this.source),e}setup(e){}main(e){throw new Error(`${this.constructor.name}.main() not implemented: a bare builder is grammar, not a renderable page`)}_resolveComponents(){let e={};for(let a of Hu(this.constructor))if(Object.hasOwn(a,"components"))for(let l of a.components||[])e[l]=l;if(!Object.keys(e).length)return;let t={...this.schema},r={};for(let[a,l]of Object.entries(e))t[a]={sub_tags:"",_meta:{component:!0}},r[a.toLowerCase()]=l;let i=On(t),s=this._collection||this.constructor._classCollection,o=s.toDocument();o.abstracts={},o.elements=Object.fromEntries(Object.keys(e).map(a=>[a,t[a]])),this._collection=new ot(s.toDocument()).update(o),this._schemaOverride=t,this._componentMap=r,this._tagNamesOverride=i}_expansionRoot(e=null){let t=this.constructor._sourceClass,r=new t(null,this);return r.setBackref(),r.setItem(Bn,new t(null,this),e?{datapath:e}:null),r.getItem(Bn)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Zt(this)}getRenderer(e=null){e??=this.constructor._defaultRenderMode;let t=this[`renderer_${e}`];if(!t)throw new Error(`${this.constructor.name} does not expose renderer_${e}`);return t}materialize(e=null,t={}){e??=this.constructor._defaultRenderMode;let r=this.getRenderer(e),i=r.renderChildren(r.preprocess(this.source),t);return this.materialized[e]=i,i}setRenderTarget(e,t=null){t??=this.constructor._defaultRenderMode,this._defaultTargets.set(t,e)}render({mode:e=null,target:t=null,...r}={}){e??=this.constructor._defaultRenderMode;let i=this.getRenderer(e);if(t===!1&&i.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let s=t===!1?null:t||this._defaultTargets.get(i.mode)||null,o={...s?.renderOpts,...r};return i.finalize(this.materialize(e,o),s,o)}};ye._registry=new Map;var Am=new Set(["short","medium","long","full"]),Tm=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Dm(n,e){if(!(n instanceof Date))throw new TypeError("Temporal formats require a typed Date value");if(!Number.isFinite(n.getTime()))throw new RangeError("Invalid date");let t=e||U(n).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function Sm(n,e,t,r){let i=e.match(Tm)||[];if(i.join("")!==e)throw new RangeError("Unclosed format literal");let s=(c,d=2)=>String(c).padStart(d,"0"),o=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(n),u={...r==="H"?{}:{y:()=>String(n.getUTCFullYear()),yy:()=>s(n.getUTCFullYear()%100),yyyy:()=>s(n.getUTCFullYear(),4),M:()=>String(n.getUTCMonth()+1),MM:()=>s(n.getUTCMonth()+1),MMM:()=>o({month:"short"}),MMMM:()=>o({month:"long"}),d:()=>String(n.getUTCDate()),dd:()=>s(n.getUTCDate()),EEE:()=>o({weekday:"short"}),EEEE:()=>o({weekday:"long"})},...r==="D"?{}:{H:()=>String(n.getUTCHours()),HH:()=>s(n.getUTCHours()),h:()=>String(n.getUTCHours()%12||12),hh:()=>s(n.getUTCHours()%12||12),m:()=>String(n.getUTCMinutes()),mm:()=>s(n.getUTCMinutes()),s:()=>String(n.getUTCSeconds()),ss:()=>s(n.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(n).find(c=>c.type==="dayPeriod").value}};return i.map(c=>{if(c.startsWith("'"))return c==="''"?"'":c.slice(1,-1).replaceAll("''","'");if(!/^[a-zA-Z]/.test(c))return c;if(!u[c])throw new RangeError(`Unsupported date format token: ${c}`);return u[c]()}).join("")}function Gu(n,{format:e,mask:t,locale:r,dtype:i,places:s}={}){let o=n==null?"":String(n);if(n!=null&&n!==""&&(e!=null&&e!==""||s!=null))if(typeof n=="number"||fe(n))o=Nm(n,{format:e,locale:r,places:s});else{let a=Dm(n,i);if(Am.has(e)){let l={timeZone:"UTC"};a!=="H"&&(l.dateStyle=e),a!=="D"&&(l.timeStyle=e),o=new Intl.DateTimeFormat(r||void 0,l).format(n)}else o=Sm(n,String(e),r||void 0,a)}return t==null?o:String(t).replaceAll("%s",()=>o)}function Cm({format:n="decimal",places:e}={}){let t={maximumFractionDigits:20};if(!n||n==="decimal")t.style="decimal";else if(n==="percent")t.style="percent";else if(n==="scientific")t.notation="scientific";else{let r=/^(0|#,##0)(?:\.(0*)(#*))?$/.exec(n);if(!r||n.includes(".")&&!r[2]&&!r[3])throw new RangeError(`Unsupported number format: ${n}`);t.useGrouping=r[1].includes(","),t.minimumFractionDigits=(r[2]||"").length,t.maximumFractionDigits=(r[2]||"").length+(r[3]||"").length}if(e!=null&&e!==""){let r=Number(e);if(!Number.isInteger(r)||r<0||r>20)throw new RangeError("places must be an integer from 0 to 20");t.minimumFractionDigits=r,t.maximumFractionDigits=r}return t}function Nm(n,e={}){if(typeof n!="number"&&!fe(n))throw new TypeError("Number formatting requires a Number or Decimal");if(!Number.isFinite(Number(n)))throw new RangeError("Number must be finite");let t=new Intl.NumberFormat(e.locale||void 0,Cm(e));if(fe(n)&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal values without precision loss");return t.format(fe(n)?n.toString():n)}var Im=new Set(["style","script"]),Om=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),Xu=new Set(["width","height","top","left","right","bottom","padding","margin","border","position","display","overflow","float","clear","resize","z_index","min_width","min_height","max_width","max_height","color","background","font","text","line_height","white_space","vertical_align","flex","gap","row_gap","column_gap","grid","align_content","justify_content","align_items","justify_items","visibility","opacity","cursor"]),$n=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),Yu=n=>n===!0?"true":n===!1?"false":String(n),es=n=>typeof n=="number"&&Number.isFinite(n)?`${n}px`:String(n);function Bm(n){if(Xu.has(n))return!0;for(let e of Xu)if(n.startsWith(`${e}_`))return!0;return!1}function Rm(n){let e=new Map;if(!n)return e;let t=[],r=0,i=null,s=!1,o=!1,a=0,l=String(n);for(let u=0;u<l.length;u+=1){let c=l[u],d=l[u+1];if(o){c==="*"&&d==="/"&&(o=!1,u+=1);continue}if(s){s=!1;continue}if(c==="\\"){s=!0;continue}if(i){c===i&&(i=null);continue}c==='"'||c==="'"?i=c:c==="/"&&d==="*"?(o=!0,u+=1):"([{".includes(c)?a+=1:")]}".includes(c)&&a>0?a-=1:c===";"&&a===0&&(t.push(l.slice(r,u)),r=u+1)}t.push(l.slice(r));for(let u of t){let c=u.trim();if(!c)continue;let d=c.indexOf(":");if(d<0)throw new TypeError(`malformed style declaration '${c}'`);e.set(c.slice(0,d).trim(),c.slice(d+1).trim())}return e}var Jt=class extends Yt{static mode="html";renderedItem(e,t,r,{tag:i,xml:s=!0,pretty:o=!1,depthOffset:a=0,includeDatapath:l=!1}={}){e.parentNode?._getMeta("subbuilder")==="html"&&(r={xmlns:"http://www.w3.org/1999/xhtml",...r});let{format:c,mask:d,locale:f,places:h,dtype:p,...m}=r;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=Gu(t,{format:c,mask:d,places:h,dtype:p,locale:this._displayLocale(e,f)}));let b=this._formatAttrs(m);if(l){if(!Object.hasOwn(r,"id")){let v=this.builder.targetId(e);v!==null&&(b+=` id="${this._htmlAttrValue(v)}"`)}for(let[v,k]of Object.entries(e.getAttr()))e.pointerType(k)&&(b+=` data-${this.adapt(v)}-pointer="${this._htmlAttrValue(e.absDatapath(k))}"`)}let g=o?" ".repeat(this._nodeDepth(e,a)):"",_=o?`
24
- `:"";if(e._getMeta("void"))return`${g}<${i}${b}${s?"/":""}>${_}`;if(Array.isArray(t)){let v=this._composeStringFragments(t);return`${g}<${i}${b}>${_}${v}${g}</${i}>${_}`}if(t==null)return`${g}<${i}${b}></${i}>${_}`;let w=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):Im.has(i)?String(t):this._escapeText(t);return`${g}<${i}${b}>${w}</${i}>${_}`}_displayLocale(e,t){if(t)return t;for(let r=e.parentNode;r;r=r.parentNode){let i=r.getAttr("locale");if(i==null)continue;let s=r.pointerType(i)?r.data.getItem(r.absDatapath(i)):i;if(s)return s}}adaptAttrs(e){let t={},r={};for(let[s,o]of Object.entries(e||{}))if(s.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(s)]=o;else if(s==="dtype")t.dtype=o;else{if(this.builder.constructor.retainedAttrPrefixes.some(a=>s.startsWith(a)))continue;this._isStyleContribution(s)?r[s]=o:t[s]=o}let i=this._adaptStyle(r);return i&&(t.style=i),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||$n.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&$n.has(t)||Bm(e)}_adaptStyle(e){let t=Rm(e.style),r=new Map,i=new Map;for(let[s,o]of Object.entries(e))if(s!=="style")if(s.startsWith("style_"))t.set(s.slice(6).replaceAll("_","-"),Yu(o));else if($n.has(s))r.set(s,o);else{let a=s.indexOf("_"),l=a<0?s:s.slice(0,a);a>=0&&$n.has(l)?(i.has(l)||i.set(l,{}),i.get(l)[s.slice(a+1)]=o):t.set(s.replaceAll("_","-"),Yu(o))}for(let s of $n)(r.has(s)||i.has(s))&&this[`_macro_${s}`](r.get(s),i.get(s)||{},t);return[...t].map(([s,o])=>`${s}: ${o}`).join("; ")}_formatAttrs(e){let t=[];for(let[r,i]of Object.entries(e||{}))Om.has(r)?i&&t.push(` ${r}`):t.push(` ${r}="${this._htmlAttrValue(i)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}_macro_rounded(e,t,r){let i=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[s,o]of Object.entries(t))if(s==="top"||s==="bottom")i[`${s}_left`]=o,i[`${s}_right`]=o;else if(s==="left"||s==="right")i[`top_${s}`]=o,i[`bottom_${s}`]=o;else if(["top_left","top_right","bottom_left","bottom_right"].includes(s))i[s]=o;else throw new TypeError(`rounded: unknown sub-kwarg '${s}'`);for(let[s,o]of Object.entries(i))r.set(`border-${s.replaceAll("_","-")}-radius`,es(o))}_macro_transform(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`rotate(${o}deg)`):s==="scale"||s==="translate"?i.push(`${s}(${o})`):s==="translate_x"?i.push(`translateX(${es(o)})`):s==="translate_y"?i.push(`translateY(${es(o)})`):s==="skew_x"?i.push(`skewX(${o}deg)`):s==="skew_y"?i.push(`skewY(${o}deg)`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("transform",i.join(" "))}_macro_filter(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`hue-rotate(${o}deg)`):s==="blur"?i.push(`blur(${es(o)})`):s==="drop_shadow"?i.push(`drop-shadow(${o})`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("filter",i.join(" "))}_macro_transition(e,t,r){e!==void 0&&r.set("transition",String(e));for(let[i,s]of Object.entries(t))r.set(`transition-${i.replaceAll("_","-")}`,String(s))}_macro_zoom(e,t,r){e!==void 0&&r.set("zoom",String(e))}_macro_shadow(e,t,r){e!==void 0&&r.set("box-shadow",String(e));for(let[i,s]of Object.entries(t))r.set(`box-shadow-${i.replaceAll("_","-")}`,String(s))}_macro_gradient(e,t,r){e!==void 0&&r.set("background-image",String(e))}};var $m=new Set(["alignment_baseline","baseline_shift","clip_path","clip_rule","color_interpolation","color_interpolation_filters","dominant_baseline","fill_opacity","fill_rule","flood_color","flood_opacity","font_family","font_size","font_size_adjust","font_stretch","font_style","font_variant","font_weight","glyph_orientation_horizontal","glyph_orientation_vertical","image_rendering","letter_spacing","lighting_color","marker_end","marker_mid","marker_start","overline_position","overline_thickness","paint_order","pointer_events","shape_rendering","stop_color","stop_opacity","strikethrough_position","strikethrough_thickness","stroke_dasharray","stroke_dashoffset","stroke_linecap","stroke_linejoin","stroke_miterlimit","stroke_opacity","stroke_width","text_anchor","text_decoration","text_rendering","underline_position","underline_thickness","unicode_bidi","word_spacing","writing_mode"]);function ts(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[$m.has(e)?e.replaceAll("_","-"):e,t]))}var Kt=class extends Zt{static mode="svg";adaptAttrs(e){return ts(e)}};var Zu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"html",version:null,title:null,description:null},abstracts:{},elements:{svg:{doc:"Switch to the SVG dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to SVG from this node down. No ``render_tag``: ``<svg>`` is\n emitted verbatim (HTML5 has a native ``<svg>`` tag).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"svg"}},a:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},abbr:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},address:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},area:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},article:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},aside:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},audio:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},b:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},base:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},bdi:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},bdo:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},blockquote:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},body:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},br:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},button:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},canvas:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},caption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},cite:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},code:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},col:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},colgroup:{doc:null,sub_tags:"col,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},data:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},datalist:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,option,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dd:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},del_:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},details:{doc:null,sub_tags:"summary[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dfn:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dialog:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},div:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dl:{doc:null,sub_tags:"dd,div,dt,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dt:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},em:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},embed:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},fieldset:{doc:null,sub_tags:"legend[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figcaption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figure:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figcaption[0:1],figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},footer:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},form:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h1:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h2:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h3:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h4:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h5:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h6:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},head:{doc:null,sub_tags:"base[0:1],link,meta,noscript,script,style,template,title[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},header:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hgroup:{doc:null,sub_tags:"h1,h2,h3,h4,h5,h6,p,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},html:{doc:null,sub_tags:"head[0:1],body[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},i:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},iframe:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},img:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},input:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},ins:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},kbd:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},label:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},legend:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},li:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},link:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},main:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},map:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mark:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},menu:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},meta:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},meter:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},nav:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},noscript:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},object:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ol:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},optgroup:{doc:null,sub_tags:"div,legend,noscript,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},option:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,div,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},output:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},p:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},picture:{doc:null,sub_tags:"img[0:1],script,source,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pre:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},progress:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},q:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rp:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rt:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ruby:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},s:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},samp:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},script:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},search:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},section:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},select:{doc:null,sub_tags:"button,div,hr,noscript,optgroup,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},slot:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},small:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},source:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},span:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},strong:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},style:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sub:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},summary:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sup:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},table:{doc:null,sub_tags:"caption[0:1],colgroup,script,tbody,template,tfoot[0:1],thead[0:1],tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tbody:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},td:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},template:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,del_,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,tr,track,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textarea:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tfoot:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},th:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},thead:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},time:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tr:{doc:null,sub_tags:"script,td,template,th",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},track:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},u:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ul:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},var:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},video:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},wbr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},selectedcontent:{doc:"Mirror of the selected option for Customizable Select (HTML 2024).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var Tt=class extends ye{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar(Zu)}get renderer_html(){return new Jt(this)}};ye.registerBuilder(Tt);var Ju={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"svg",version:null,title:null,description:null},abstracts:{graphics:{doc:"SVG graphics content: any graphical element.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null},containerElement:{doc:"SVG container content: elements that can hold children.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null}},elements:{html:{doc:"Switch to the HTML dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to HTML from this node down. The source tag ``html`` is\n rendered as ``_meta['render_tag']`` (``<foreignObject>``) carrying\n ``_meta['render_attributes']`` (the SVG namespace). The immediate\n HTML child declares XHTML so both sides of the XML boundary retain\n their native namespace.\n ",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"html",render_tag:"foreignObject",render_attributes:{xmlns:"http://www.w3.org/2000/svg"}}},svg:{doc:"Root SVG container or nested SVG viewport.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},g:{doc:"Group container for applying transforms and styles.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},defs:{doc:"Container for referenced elements (gradients, patterns, etc.).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},symbol:{doc:"Reusable graphical template, rendered only when referenced by <use>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},use:{doc:"Reference and render a <symbol> or other element.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rect:{doc:"Rectangle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},circle:{doc:"Circle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ellipse:{doc:"Ellipse.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},line:{doc:"Line segment between two points.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polyline:{doc:"Open shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polygon:{doc:"Closed shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},path:{doc:"Arbitrary shape defined by path commands (d attribute).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},image:{doc:"Embedded raster image.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},text:{doc:"Text block. Contains text content and optional <tspan>/<textPath>.",sub_tags:"tspan,textPath",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tspan:{doc:"Inline text span within <text>.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textPath:{doc:"Text rendered along a path shape.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},linearGradient:{doc:"Linear gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},radialGradient:{doc:"Radial gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},stop:{doc:"Gradient stop (color and offset).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pattern:{doc:"Tile pattern definition. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},clipPath:{doc:"Clipping path definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mask:{doc:"Alpha mask definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},marker:{doc:"Marker symbol for line endpoints or vertices.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},filter:{doc:"Filter effect container. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feGaussianBlur:{doc:"Gaussian blur filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feOffset:{doc:"Offset filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feBlend:{doc:"Blend filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feColorMatrix:{doc:"Color matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feComposite:{doc:"Composite filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feFlood:{doc:"Flood fill filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMerge:{doc:"Merge filter primitive (container for feMergeNode).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMergeNode:{doc:"Single input for feMerge.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDropShadow:{doc:"Drop shadow filter primitive (SVG 2).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDiffuseLighting:{doc:"Diffuse lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpecularLighting:{doc:"Specular lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},fePointLight:{doc:"Point light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDistantLight:{doc:"Distant light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpotLight:{doc:"Spot light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMorphology:{doc:"Morphology filter primitive (erode/dilate).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTurbulence:{doc:"Turbulence noise filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDisplacementMap:{doc:"Displacement map filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feConvolveMatrix:{doc:"Convolution matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feImage:{doc:"Image filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTile:{doc:"Tile filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animate:{doc:"Animate an attribute over time.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateTransform:{doc:"Animate a transform attribute.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateMotion:{doc:"Animate motion along a path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},set:{doc:"Set an attribute to a value for a duration.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:"Accessible title (tooltip in browsers).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},desc:{doc:"Accessible description.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},metadata:{doc:"Metadata container (RDF, Dublin Core, etc.).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},a:{doc:"Hyperlink wrapper.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},foreignObject:{doc:"Container for non-SVG content (HTML, MathML).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},switch:{doc:"Conditional processing (renders first matching child).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var Dt=class extends ye{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(Ju)}get renderer_svg(){return new Kt(this)}};ye.registerBuilder(Dt);var Qt=class n{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=Mr.fromJSON({nameSyntax:{kind:"annotated",base:{kind:"type",module:"builtins",name:"str"},metadata:[this.toJSON()]}}).resolve("nameSyntax").test,Object.freeze(this)}static fromJSON(e){if((e!==null&&typeof e=="object"?Object.keys(e).sort():[]).join()!=="flags,kind,pattern"||e.kind!=="regex")throw new TypeError(`A name syntax is {kind: 'regex', pattern, flags}, not ${JSON.stringify(e)}`);return new n(e.pattern,e.flags)}toJSON(){return{kind:"regex",pattern:this.pattern,flags:this.flags}}matches(e){return this.#e(e)}},Mn=new Qt(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var Se=class{constructor(e){this.gramlot=e}};var Pm=/^[a-z][.0-9_a-z\-\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*$/u,jm=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function at(n){let e=n.code;if(typeof e!="string"||Pm.exec(e)?.[0]!==e||!e.includes("-")||jm.has(e))throw new TypeError("webcomponent: code must be a literal custom-element name");return e}function Wo(n){for(let e of Object.values(n))e&&typeof e=="object"&&Wo(e);return Object.freeze(n)}function Ku(n){if(!n.annotation&&typeof n.dtype!="string"&&!Array.isArray(n.dtype))throw new TypeError("Component parameter requires dtype");let e=n.annotation?[structuredClone(n.annotation)]:(Array.isArray(n.dtype)?n.dtype:[n.dtype]).map(t=>({kind:"dtype",dtype:t}));return n.nullable&&e.push({kind:"dtype",dtype:"NN"}),n.binding&&n.dtype!=="T"&&e.push({kind:"annotated",base:{kind:"dtype",dtype:"T"},metadata:[{kind:"regex",pattern:"^[\\^=].+",flags:0}]}),e.length===1?e[0]:{kind:"union",items:e}}function Ct({name:n,tag:e,base:t,mixins:r=[],parameters:i={},subTags:s="",presentationDefaults:o=[],dataScope:a=!1,command:l=!1,childParameters:u={},sourceContext:c=!1,bagStore:d=!1,dragSource:f=!1,implementation:h}){if(at({code:e}),!/^[a-zA-Z][a-zA-Z0-9]*$/.test(n))throw new TypeError("Invalid component authoring name");let p={...t.parameters};for(let m of r)for(let[b,g]of Object.entries(m.parameters)){if(Object.hasOwn(p,b))throw new Error(`Duplicate mixin parameter: ${b}`);p[b]=g}Object.assign(p,i);for(let m of Object.values(p))Ku(m);return Object.freeze({name:n,tag:e,base:t,subTags:s,presentationDefaults:Object.freeze([...o]),dataScope:a,command:l,bagStore:d,mixins:Object.freeze([...r]),parameters:Wo(structuredClone(p)),childParameters:Wo(structuredClone(u)),sourceContext:c,dragSource:f,implementation:h})}var St=class n{#e=new WeakMap;constructor({name:e,components:t,dependencies:r=[],css:i=[],assets:s={},registerCommands:o=()=>{}}){if(typeof e!="string"||!e)throw new TypeError("Collection name must be nonempty");if(!Array.isArray(r)||r.some(u=>!(u instanceof n)))throw new TypeError("Collection dependencies must be collection objects");if(!Array.isArray(i)||i.some(u=>!(u instanceof URL))||!s||typeof s!="object"||Array.isArray(s)||Object.values(s).some(u=>!(u instanceof URL)))throw new TypeError("Collection css/assets require URL objects");if(typeof o!="function")throw new TypeError("registerCommands must be a function");this.dependencies=Object.freeze([...r]),this.css=Object.freeze([...i]),this.assets=Object.freeze({...s}),this.registerCommands=o,this.name=e,this.components=Object.freeze([...t]);let a=new Set,l=new Set;for(let u of t){if(a.has(u.name.toLowerCase())||l.has(u.tag))throw new Error(`Duplicate component: ${u.name}`);a.add(u.name.toLowerCase()),l.add(u.tag)}}toDocument(){return{document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:this.name,version:null,title:this.name,description:null},abstracts:{},elements:Object.fromEntries(this.components.map(e=>[e.name,{doc:null,sub_tags:e.subTags,parent_tags:null,inherits_from:null,ns:null,node_label:null,collection_key:null,attributes:{parameters:[...Object.entries(e.parameters).map(([t,r])=>({name:t,kind:"keyword_only",role:"attribute",annotation:Ku(r),has_default:!0,default:r.default??null})),{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:{render_tag:e.tag,gramlot_component:{parameters:structuredClone(e.parameters),presentationDefaults:[...e.presentationDefaults],dataScope:e.dataScope,command:e.command,...Object.keys(e.childParameters).length?{childParameters:structuredClone(e.childParameters)}:{},...e.sourceContext?{sourceContext:!0}:{},...e.dragSource?{dragSource:!0}:{},...e.bagStore?{bagStore:!0}:{}}}}]))}}register(e){if(this.#e.has(e))return;let t=[];for(let r of this.components){if(e.customElements.get(r.tag))throw new Error(`Custom element already registered: ${r.tag}`);let i=r.base(e.HTMLElement);for(let o of r.mixins)i=o(i);let s=r.implementation(i);Object.defineProperty(s,"gramlotComponent",{value:r}),t.push([r.tag,s])}for(let[r,i]of t)e.customElements.define(r,i);this.#e.set(e,t)}};function Go(n){return new St(n)}function Lr(n,e){return n.parameters=Object.fromEntries(Object.entries(n.constructor.gramlotComponent.parameters).map(([t,r])=>[t,Object.hasOwn(e,t)?e[t]:r.default])),Object.fromEntries(Object.entries(e).filter(([t])=>!Object.hasOwn(n.parameters,t)))}function Qu(n,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(n==="")return[];let t=new Set;return n.split(e).map(r=>{let i=r.indexOf(":"),s=i<0?r:r.slice(0,i),o=i<0?r:r.slice(i+1);if(!s||t.has(s))throw new Error("Invalid or duplicate choice code");return t.add(s),{id:s,caption:o}})}function rs(n){return class extends n{constructor(){super();let e=this.attachShadow({mode:"open"}),t=this.ownerDocument.createElement("style");t.textContent=`:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
36
+ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`}if(u==null||u==="")return t===null||t.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?Cm(u):String(u),d=this._escapeXml(c);return`<${o}${l}>${d}</${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,t={}){let{tagAttribute:r=null}=t,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 Pu.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(i.documentElement,r)}static _xmlElementToBag(e,t=null){let r=new this,i=Array.from(e.childNodes).filter(s=>s.nodeType===1);for(let s of i){let o=s.tagName,a={};for(let p=0;p<s.attributes.length;p++){let b=s.attributes[p];a[b.name]=b.value}let l=os(a._resolver);l&&delete a._resolver;let u=String(a._T||"").toUpperCase()==="BAG";Object.assign(a,Go(a));let c=o;"_tag"in a&&(c=a._tag,delete a._tag),t&&t in a&&(c=a[t],delete a[t]);let d=c,f=1;for(;r.getNode(c);)c=`${d}_${f++}`;let h=Array.from(s.childNodes).filter(p=>p.nodeType===1),m;if(h.length>0||u){let p=this._xmlElementToBag(s,t);m=r.setItem(c,p,Object.keys(a).length>0?a:null)}else{let p=s.textContent||"";m=r.setItem(c,p,Object.keys(a).length>0?a:null)}l&&(m.resolver=l),m.xmlTag=o}return r}static async fromUrl(e,t={}){let{timeout:r=30}=t,i={};r&&(i.signal=AbortSignal.timeout(r*1e3));let s=await fetch(e,i),o=s.headers.get("content-type")||"",a=await s.text();if(o.includes("json"))return n.fromTytx(a);if(o.includes("xml"))return n.fromXml(a);let l=a.trim();if(l.startsWith("<"))return n.fromXml(a);if(l.startsWith("{")||l.startsWith("["))return n.fromTytx(a);throw new $n(`Unsupported content-type: ${o}`)}toJson(e=!0){let t=[];for(let r of this._nodes)t.push(this._nodeToJsonDict(r,e));return e?U(t):JSON.stringify(t)}_nodeToJsonDict(e,t){let r=e.resolver?null:e.getValue(!0);if(r&&typeof r._nodeToJsonDict=="function"){let s=[];for(let o of r._nodes)s.push(r._nodeToJsonDict(o,t));r=s}let i={label:e.label,value:r,attr:as(e.attr)};return e.nodeTag!==null&&(i.tag=e.nodeTag),e.resolver&&(i.resolver=Rn(e.resolver)),i}static fromJson(e,t={}){return Lu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),Lu=!0),this.fromTytx(e,"json",t)}toStringTree(e=!0,t=null,r="",i=!0){t===null&&(t=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),d=l.getAttr(),f="",h=Object.keys(d);h.length>0&&(f=" ["+h.map(g=>`${g}=${JSON.stringify(d[g])}`).join(", ")+"]");let m=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",p=r+(u?" ":"\u2502 ");if(c instanceof n){let b=l,g=c.backref?"(*)":"";if(t.has(b))s.push(`${r}${m}${l.label}${g}${f} \u2192 (circular ref)`);else{t.set(b,l.label),s.push(`${r}${m}${l.label}${g}${f}`);let _=c.toStringTree(e,t,p,u);_&&s.push(_)}}else{let b;if(c===null)b="null";else if(c===void 0)b="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let g=new TextDecoder("utf-8",{fatal:!1}),_=c instanceof ArrayBuffer?new Uint8Array(c):c;b=g.decode(_)}else typeof c=="string"?c.length>50?b=JSON.stringify(c.slice(0,47)+"..."):b=JSON.stringify(c):b=String(c);s.push(`${r}${m}${l.label}: ${b}${f}`)}}return s.join(`
37
+ `)}toString(e=!0,t=null,r=""){t||(t=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="",d=a.attr;d&&Object.keys(d).length>0&&(c=` [${Object.entries(d).map(([p,b])=>`${p}=${JSON.stringify(b)}`).join(", ")}]`);let f=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",h=r+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let m=a;if(t.has(m))i.push(`${r}${f}${a.label}${c} \u2192 (circular ref)`);else{t.add(m),i.push(`${r}${f}${a.label}${c}`);let p=u.toString(e,t,h);p&&i.push(p)}}else{let m;u==null?m="null":typeof u=="string"&&u.length>50?m=JSON.stringify(u.slice(0,47)+"..."):typeof u=="string"?m=JSON.stringify(u):m=String(u),i.push(`${r}${f}${a.label}: ${m}${c}`)}}return i.join(`
38
+ `)}},$n=class extends Error{constructor(e){super(e),this.name="BagException"}};K.registerBagClass(x);Ho(x,"X",n=>n._toTytxPayload(),n=>x._fromTytxPayload(n));Gt(x.tytxSuffix,{...je(x.tytxSuffix),Bag:x});var Fu=new Set(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]);function qu(n){return n.endsWith("_")&&Fu.has(n.slice(0,-1))?n.slice(0,-1):n}function Uu(n){let e=qu(n);return e!==n?e:n.startsWith("_")&&Fu.has(n.slice(1))?n.slice(1):n}function Mn(n,{renderTag:e=null,ns:t=null,dialectName:r=null}={}){let i=e||n;if(!i)return i;if(i=qu(i),t&&!e){let s=`${r}_`;i.startsWith(s)&&(i=i.slice(s.length)),i=`${t}:${i}`}return i}var Pr=Symbol("value"),Xt=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function _e(n){return Object.entries(n||{}).filter(([e])=>!Xt.has(e)).map(([e,t])=>[Uu(e),t])}var Ae=class extends ze{constructor(e,t,r=null,i=null,s=null,o=null,a=null){super(e,t,r,i,s,o,a),this._builder=e?._insertingBuilder??e?._builder??null,this._targetId=null}get builder(){if(this._builder)return this._builder;let e=this.parentBag;return e?e._builder:null}get data(){return this.builder.data}get rootBuilder(){return this.parentBag.root._builder}_getMeta(e){let t=this.getAttr("_meta")||{},r=e.split(",").map(i=>i.trim());return r.length===1?t[r[0]]!==void 0?t[r[0]]:null:r.map(i=>t[i]!==void 0?t[i]:null)}pointerType(e){return typeof e=="string"&&(e[0]==="^"||e[0]==="=")&&!e.startsWith("==")?e[0]:null}pointers(){this.builder.validateCustomTypes(this);let e=[];for(let[t,r]of Object.entries(this.getAttr()||{}))this.pointerType(r)==="^"&&e.push([t,r.split(":",1)[0]]);return this.pointerType(this.value)==="^"&&e.push(["",this.value.split(":",1)[0]]),e}fixedAttrItems(){return _e(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set(Pr,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(H(e)?.pointer??e).slice(1));let r=null;return e.includes("?")&&([e,r]=e.split("?",2)),e.startsWith("#")?this._finalizeAbsPath(this._resolveSymbolicDatapath(e,t),r):(e.startsWith(".")&&(e=this._composeRelativeDatapath(e,t)),this._finalizeAbsPath(e,r))}_finalizeAbsPath(e,t){return e=this._collapseParentDatapath(e,e),t?`${e}?${t}`:e}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");i!=null&&(e=e==="."?i:i+e),r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let r=[];for(let i of e.split("."))if(i==="#parent"){if(r.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);r.pop()}else r.push(i);return r.join(".")}_resolveSymbolicDatapath(e,t){let r=e.slice(1),i=r.indexOf("."),s=i===-1?r:r.slice(0,i),o=i===-1?"":r.slice(i+1),a;if(s==="FORM")a=this._findMarkedDatapathAncestor(!0,!1,t);else if(s==="ANCHOR")a=this._findMarkedDatapathAncestor(!1,!0,t);else{let l=this.rootBuilder;if(!l)throw new Error(`#<id>: cannot resolve ${t} on a node without builder`);if(a=l.source.getNodeByAttr("nodeId",s),a==null)throw new Error(`#<id>: cannot resolve ${t}`)}return a.absDatapath(o?`.${o}`:".")}_findMarkedDatapathAncestor(e,t,r){let i=this;for(;i!=null;){let o=i.getAttr()||{};if(e&&(o.formId!=null||o.form===!0)||t&&"_anchor"in o)return i;i=i.parentNode}let s=e?"FORM":"ANCHOR";throw new Error(`#${s}: no marked ancestor found for ${r}`)}getRelativeData(e,t=null,{autocreate:r=!1}={}){let i=this.data,s=this.absDatapath(e);return r&&i.getItem(s)==null&&i.setItem(s,t),i.getItem(s,t)}setRelativeData(e,t,{attributes:r=null,fired:i=!1,reason:s=null}={}){let o=this.data,a=this.absDatapath(e);o.setItem(a,t,r,">",!1,!0,s===null?!0:s,i)}fireEvent(e,t=!0,{attributes:r=null,reason:i=null}={}){this.setRelativeData(e,t,{attributes:r,fired:!0,reason:i})}SET(e,t){this.setRelativeData(e,t)}GET(e){return this.getRelativeData(e)}PUT(e,t){this.setRelativeData(e,t,{reason:!1})}FIRE(e,t=!0){this.setRelativeData(e,t,{fired:!0})}},A=class n extends x{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return Ae}_setBuilderItem(e,t,r,...i){let s=t?.map(([a])=>[a,a._builder])||null;if(t)for(let[a,l]of t)a._builder=l;let o=this._insertingBuilder;this._insertingBuilder=e;try{return this.setItem(r,...i)}catch(a){if(this.node(r)==null&&s)for(let[l,u]of s)l._builder=u;throw a}finally{this._insertingBuilder=o}}bindBuilder(e){if(!e)throw new Error("SourceBag.bindBuilder requires a builder");let t=this._builderBindingPlan(e);for(let[r,i]of t)r._builder=i;return this.setBackref(),this}_builderBindingPlan(e){let t=[],r=new WeakSet,i=(s,o)=>{if(r.has(s))throw new Error("source contains a cyclic or shared SourceBag branch");r.add(s),t.push([s,o]);for(let a of s.getNodes()){let l=o,u=a._getMeta("subbuilder");u!=null&&(l=o._resolveSubbuilderReference(u,a.getAttr()||{},a.nodeTag)),t.push([a,l]);let c=a.getValue(!0);c instanceof n&&i(c,l)}};return i(this,e),t}};if((je(A.tytxSuffix).SourceBag??A)!==A)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Gt(A.tytxSuffix,{...je(A.tytxSuffix),SourceBag:A});function Om(n){if(n.length===0)return{value:null,attrs:{}};let e=n[0];if(e!==null&&typeof e=="object"){let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null)return{value:null,attrs:e}}return{value:e,attrs:n[1]||{}}}var Bm=new Set(["then","toJSON"]),zu=new WeakMap;function J(n){return zu.get(n)||n}function Ln(n){if(n==null)return n;n=J(n);let e=n._builder||n.parentBag&&n.parentBag._builder;return e?e.wrapSource(n):n}function Hu(n,e){let t=e instanceof x,r=new Proxy(e,{get(i,s){if(typeof s=="symbol"||s.startsWith("_")||Bm.has(s))return Reflect.get(i,s,i);let o=n.schemaTag(s);if(t&&o)return Vu(n,i,o,t);if(s in i){let l=Reflect.get(i,s,i);return typeof l=="function"?l.bind(i):l}if(o)return Vu(n,i,o,t);let a=n.containerMethod(s);if(a)return(...l)=>n[a](n.wrapSource(i),...l)}});return zu.set(r,e),r}function Vu(n,e,t,r){return(...i)=>{let{value:s,attrs:o}=Om(i),a=r?n.bagCall(e,t,s,o):n.commandOnNode(e,t,s,o);return a.builder.wrapSource(a)}}function Jo(n,e,{transport:t="json"}={}){let r=j(n,t==="json"?null:t);if(!(r instanceof A))throw new TypeError("TYTX payload did not decode to SourceBag");return r.bindBuilder(e)}var Gu=/^[A-Za-z_][A-Za-z0-9_]*$/,Rm=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),$m=new Set(["framework","value","attribute"]),Mm=new Map([["builtins.str",n=>typeof n=="string"],["builtins.int",n=>Number.isInteger(n)],["builtins.float",n=>typeof n=="number"&&Number.isFinite(n)],["builtins.bool",n=>typeof n=="boolean"],["builtins.list",n=>Array.isArray(n)],["builtins.dict",n=>n!==null&&typeof n=="object"&&!Array.isArray(n)],["builtins.tuple",n=>Array.isArray(n)],["builtins.set",n=>Array.isArray(n)||n instanceof Set],["builtins.NoneType",n=>n===null],["builtins.object",n=>!0]]);function Zt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function C(n,e){throw new TypeError(`${n}: ${e}`)}function tt(n,e,t,r){Zt(n)||C(r,"must be an object");for(let i of Object.keys(n))e.includes(i)||C(r,`unknown field '${i}'`);for(let i of t)Object.hasOwn(n,i)||C(r,`missing field '${i}'`)}function Jt(n,e){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n))return n.forEach((t,r)=>Jt(t,`${e}[${r}]`));if(Zt(n))return Object.entries(n).forEach(([t,r])=>Jt(r,`${e}.${t}`));C(e,"must be lossless JSON data")}}function Lm(n,e){let t="",r=!1;for(let i=0;i<n.length;i++){let s=n[i];if(s==="\\"){t+=s+(n[++i]??"");continue}s==="["&&(r=!0),!r&&s==="."&&!(e&16)?t+="[^\\n]":!r&&s==="^"&&e&8?t+="(?:^|(?<=\\n))":!r&&s==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=s,s==="]"&&(r=!1)}return t}function Yt(n,e,t=!1,r=null){if(n===null)return null;switch(tt(n,["kind","dtype","module","name","origin","arguments","items","values","base","metadata","pattern","flags","ge","le","gt","lt","value"],["kind"],e),n.kind){case"custom":return tt(n,["kind","name"],["kind","name"],e),r||C(e,"custom references require a catalog; nested catalog references are unsupported"),r.resolve(n.name,e);case"dtype":{tt(n,["kind","dtype"],["kind","dtype"],e);let i=n.dtype;typeof i!="string"&&C(e,"dtype must be a string");let s=In(i);return!s&&i!=="NN"&&C(e,`unknown dtype '${i}'`),{...n,test:a=>i==="NN"?a===null:i==="N"?be(a)&&!["NaN","Infinity","-Infinity"].includes(a.toString()):s===Number?typeof a=="number"&&Number.isFinite(a)&&(i!=="L"||Number.isInteger(a)):s===String?typeof a=="string":s===Boolean?typeof a=="boolean":s===Date?a instanceof Date&&Number.isFinite(a.getTime()):s===Object?Zt(a)&&[Object.prototype,null].includes(Object.getPrototypeOf(a)):a instanceof s}}case"any":return{...n,test:i=>!0};case"type":{(typeof n.module!="string"||typeof n.name!="string")&&C(e,"type requires string module/name");let i=`${n.module}.${n.name}`;if(i==="collections.abc.Callable")return{...n,test:o=>typeof o=="function",portable:!1};let s=Mm.get(i);return s||C(e,`unsupported type '${i}'`),{...n,test:s}}case"union":{(!Array.isArray(n.items)||!n.items.length)&&C(e,"union items must be non-empty");let i=n.items.map((s,o)=>Yt(s,`${e}.items[${o}]`,!0,r));return{...n,items:i,inputConstraint:i.some(s=>s.inputConstraint),test:s=>i.some(o=>o.test&&o.test(s))}}case"literal":return Array.isArray(n.values)||C(e,"literal values must be an array"),n.values.forEach((i,s)=>Jt(i,`${e}.values[${s}]`)),{...n,test:i=>n.values.some(s=>Object.is(s,i))};case"annotated":{Array.isArray(n.metadata)||C(e,"annotated metadata must be an array"),n.metadata.some(o=>!["regex","range","value"].includes(o?.kind))&&C(e,"unsupported annotation metadata kind");let i=Yt(n.base,`${e}.base`,!0,r),s=n.metadata.map((o,a)=>Yt(o,`${e}.metadata[${a}]`,!0,r));return{...n,base:i,metadata:s,inputConstraint:i.inputConstraint,test:o=>i.test(o)&&s.every(a=>!a.test||a.test(o))}}case"range":{for(let i of["ge","le","gt","lt"])Object.hasOwn(n,i)||C(e,`range missing '${i}'`);for(let i of["ge","le","gt","lt"])n[i]!==null&&(typeof n[i]!="number"||!Number.isFinite(n[i]))&&C(e,`${i} must be finite number or null`);return{...n,test:i=>typeof i=="number"&&(n.ge===null||i>=n.ge)&&(n.le===null||i<=n.le)&&(n.gt===null||i>n.gt)&&(n.lt===null||i<n.lt)}}case"regex":{(typeof n.pattern!="string"||!Number.isInteger(n.flags)||n.flags<0)&&C(e,"regex requires pattern and non-negative integer flags");let i=n.flags&-59;i&&C(e,`unsupported Python regex flags ${i}`),n.flags&2&&C(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(n.pattern.replaceAll(String.raw`[\s\S]`,"."))&&C(e,"regex uses a non-portable construct or character class");let s="uy";n.flags&16&&(s+="s");let o;try{o=new RegExp(`(?:${Lm(n.pattern,n.flags)})(?![\\s\\S])`,s)}catch(a){C(e,`invalid portable regex: ${a.message}`)}return{...n,test:a=>typeof a!="string"?!1:(o.lastIndex=0,o.test(a))}}case"value":return Jt(n.value,`${e}.value`),{...n};case"generic":{let i=Yt(n.origin,`${e}.origin`,!0,r);(n.origin?.kind!=="type"||n.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(n.origin.name))&&C(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(n.arguments)||C(e,"generic arguments must be an array");let s=n.arguments.map((o,a)=>Yt(o,`${e}.arguments[${a}]`,!0,r));return{...n,origin:i,arguments:s,inputConstraint:s.some(o=>o.inputConstraint),test:o=>i.test(o)&&Pm(n.origin,s,o)}}case"arguments":C(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||C(e,"ellipsis is only valid as a nested descriptor"),{...n};default:C(e,`unknown annotation kind '${n.kind}'`)}}function Pm(n,e,t){let r=`${n.module}.${n.name}`;return r==="builtins.tuple"&&e.length&&e[1]?.kind!=="ellipsis"?t.length===e.length&&t.every((i,s)=>e[s].test(i)):r==="builtins.list"||r==="builtins.set"||r==="builtins.tuple"?[...t].every(i=>!e[0]?.test||e[0].test(i)):r==="builtins.dict"?Object.entries(t).every(([i,s])=>(!e[0]?.test||e[0].test(i))&&(!e[1]?.test||e[1].test(s))):!1}function Xu(n,e){if(n===null)return null;if(typeof n!="string"&&C(e,"must be string or null"),n==="")return new Map;let t=new Map;for(let r of n.split(",")){let i=r.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(i)&&C(e,`invalid cardinality item '${r}'`);let s=i.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);s||C(e,`invalid cardinality item '${r}'`);let[,o,a,l,u]=s;t.has(o)&&C(e,`duplicate tag '${o}'`);let c=0,d=1/0;i.includes("[")&&(i.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(a)),d<c&&C(e,`maximum ${d} is below minimum ${c}`),t.set(o,{min:c,max:d})}return t.has("*")&&t.size>1&&C(e,"wildcard '*' cannot be combined with named tags"),t}function Yu(n,e){if(n===null)return null;typeof n!="string"&&C(e,"must be string or null");let t=new Set;for(let r of n.split(",")){let i=r.trim();i&&((!Gu.test(i)||t.has(i))&&C(e,`invalid or duplicate parent '${r}'`),t.add(i))}return t}function jm(n,e,t){if(n===null)return null;tt(n,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let r=n.parameters??[];Array.isArray(r)||C(e,"parameters must be an array"),n={parameters:r,accepts_var_keyword:r.some(l=>l.kind==="var_keyword"),accepts_var_positional:r.some(l=>l.kind==="var_positional"),...n},(!Array.isArray(n.parameters)||typeof n.accepts_var_keyword!="boolean"||typeof n.accepts_var_positional!="boolean")&&C(e,"invalid signature descriptor");let i=new Set,s=!1,o=!1,a=n.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return tt(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!Gu.test(l.name)||i.has(l.name))&&C(c,"invalid or duplicate parameter name"),i.add(l.name),(!Rm.has(l.kind)||!$m.has(l.role)||typeof l.has_default!="boolean")&&C(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&C(c,"default presence must equal has_default"),l.has_default&&Jt(l.default,`${c}.default`),s||=l.kind==="var_keyword",o||=l.kind==="var_positional",{...l,annotation:Yt(l.annotation,`${c}.annotation`,!1,t)}});return(s!==n.accepts_var_keyword||o!==n.accepts_var_positional)&&C(e,"variadic summary flags do not match parameters"),{...n,parameters:a}}function Wu(n,e,t,r){let i=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];tt(n,i,[],e),n={...Object.fromEntries(i.map(s=>[s,null])),...n};for(let s of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])n[s]!==null&&typeof n[s]!="string"&&C(e,`${s} must be string or null`);return n._meta!==null&&(Zt(n._meta)||C(e,"_meta must be object or null"),Jt(n._meta,`${e}._meta`)),Xu(n.sub_tags,`${e}.sub_tags`),Yu(n.parent_tags,`${e}.parent_tags`),{...n,attributes:jm(n.attributes,`${e}.attributes`,r)}}function Zu(n){return n?n.split(",").map(e=>e.trim()).filter(Boolean):[]}function Ju(n,e){let t={...e};for(let[r,i]of Object.entries(n))r==="inherits_from"||r.startsWith("_")||t[r]||(t[r]=i);return t._meta={...n._meta||{},...e._meta||{}},t}function Ku(n){let e={...n};return e._subSpec=Object.hasOwn(e,"sub_tags")?Xu(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?Yu(e.parent_tags,"resolved.parent_tags"):null,e}function Qu(n,e,t,r){if(t.get(n)===1&&C(r,`inheritance cycle at '${n}'`),t.get(n)===2)return e[n];let i=e[n];i||C(r,`unknown abstract '${n}'`),t.set(n,1);let s={...i};for(let o of Zu(i.inherits_from))s=Ju(Qu(o,e,t,r),s);return s=Ku(s),t.set(n,2),e[n]=s,s}function Ko({abstracts:n={},elements:e={}}){let t={...n},r=new Map;for(let s of Object.keys(t))Qu(s,t,r,`abstracts.${s}.inherits_from`);let i={};for(let[s,o]of Object.entries(e)){let a={...o};for(let l of Zu(o.inherits_from)){let u=t[l];u||C(`elements.${s}.inherits_from`,`unknown abstract '${l}'`),a=Ju(u,a)}i[s]=Ku(a)}return{abstracts:t,elements:i}}function Qo(n){tt(n,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),tt(n.document_format,["name","version"],["name","version"],"document_format"),(n.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(n.document_format.version))&&C("document_format","expected builder_grammar version 1.1 or 1.2"),tt(n.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof n.grammar.name!="string"||!n.grammar.name)&&C("grammar.name","must be non-empty string");for(let i of["version","title","description"])n.grammar[i]!==null&&typeof n.grammar[i]!="string"&&C(`grammar.${i}`,"must be string or null");(!Zt(n.abstracts)||!Zt(n.elements))&&C("grammar document","abstracts/elements must be objects"),Object.hasOwn(n,"custom_types")&&n.document_format.version!=="1.2"&&C("custom_types","requires version 1.2");let e=jr.fromJSON(n.custom_types??{}),t={};for(let[i,s]of Object.entries(n.abstracts))(!i||i.startsWith("_"))&&C("abstracts",`invalid public name '${i}'`),t[i]=Wu(s,`abstracts.${i}`,!1,e);let r={};for(let[i,s]of Object.entries(n.elements))(!i||i.startsWith("_"))&&C("elements",`invalid public name '${i}'`),r[i]=Wu(s,`elements.${i}`,!0,e);return{grammar:structuredClone(n.grammar),abstracts:t,elements:r}}function ec(n,e,t,r){let i=e.attributes;if(!i)return;let s={...r};t!=null&&(s.node_value=t);let o=new Set(i.parameters.filter(u=>u.role==="attribute").map(u=>u.name)),a=new Set(["node_label","node_position","nodeId","target_id","datapath","iterate","store","_tag","_meta","ns"]);if(!i.accepts_var_keyword)for(let u of Object.keys(r))!o.has(u)&&!a.has(u)&&C(n,`unknown attribute '${u}'`);let l=e._meta?.component?i.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of i.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(s,u.name);!c&&!u.has_default&&C(n,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(s[u.name]))&&C(n,`invalid value for ${u.role} '${u.name}'`)}}var jr=class n{#e=new Map;#t=new Map;register(e,t,r){let i=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),s=i.has(t)?{kind:"type",module:"builtins",name:i.get(t)}:t;return this.#r(e,{kind:"annotated",base:s,metadata:[r]})}#r(e,t){(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/.test(e)||e in this||["to_dict","from_dict"].includes(e)||Fm.has(e))&&C("custom_types",`invalid, reserved or duplicate name '${e}'`),tt(t,["kind","base","metadata"],["kind","base","metadata"],`custom_types.${e}`),(t.kind!=="annotated"||!Array.isArray(t.metadata)||t.metadata.length!==1||!["regex","range"].includes(t.metadata[0]?.kind))&&C(`custom_types.${e}`,"requires an annotated base with one Regex or Range validator");let r=t.metadata[0].kind==="regex"?["str"]:["int","float"];(t.base?.kind!=="type"||t.base.module!=="builtins"||!r.includes(t.base.name))&&C(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Jt(t,`custom_types.${e}`);let i=structuredClone(t),s=Yt(i,`custom_types.${e}`),o=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:o,enumerable:!0}),this.#e.set(e,i),this.#t.set(e,{...o,inputConstraint:!0,test:s.test}),o}resolve(e,t="custom_types"){return this.#t.has(e)||C(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||C(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){Zt(e)||C("custom_types","must be an object");let t=new n;for(let[r,i]of Object.entries(e))t.#r(r,i);return t}},Fm=new Set("False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield".split(" "));function tc(n,e,t,r){let i=e?.attributes;if(i)for(let s of i.parameters){if(!s.annotation?.inputConstraint||s.role==="framework"||["var_keyword","var_positional"].includes(s.kind))continue;let o=s.role==="value"?t:r[s.name];o!==void 0&&(s.annotation.test(o)||C(n,`invalid input for '${s.name}' (custom type)`))}}function rc(n,e,t=[]){if(e===null)return structuredClone(n);if(t.length===2&&t[0]==="custom_types"&&n!==void 0){if(!ea(n,e))throw new TypeError(`conflicting custom type '${t[1]}'`);return structuredClone(n)}if(t.length===2&&["abstracts","elements"].includes(t[0]))return structuredClone(e);if(lt(n)&&lt(e)){let r=structuredClone(n);for(let[i,s]of Object.entries(e))s!==null&&Object.defineProperty(r,i,{value:rc(r[i],s,[...t,i]),enumerable:!0,writable:!0,configurable:!0});return r}return structuredClone(e)}function ea(n,e){return Object.is(n,e)?!0:Array.isArray(n)&&Array.isArray(e)?n.length===e.length&&n.every((t,r)=>ea(t,e[r])):lt(n)&&lt(e)?Object.keys(n).length===Object.keys(e).length&&Object.keys(n).every(t=>Object.hasOwn(e,t)&&ea(n[t],e[t])):!1}function lt(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function ta(n){if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(Array.isArray(n)){n.forEach(ta);return}if(lt(n)){Object.values(n).forEach(ta);return}throw new TypeError("collection must contain only finite JSON values")}}var ut=class n{#e;constructor(e){ta(e);let t=["document_format","grammar","abstracts","elements"];if(!lt(e)||Object.keys(e).some(i=>![...t,"custom_types"].includes(i))||t.some(i=>!Object.hasOwn(e,i)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let r=e.document_format;if(!lt(r)||Object.keys(r).length!==2||r.name!=="builder_grammar"||!["1.1","1.2"].includes(r.version))throw new TypeError("expected builder_grammar version 1.1 or 1.2");for(let i of["grammar","abstracts","elements"])if(!lt(e[i]))throw new TypeError(`${i} must be an object`);if(Object.hasOwn(e,"custom_types")&&(r.version!=="1.2"||!lt(e.custom_types)))throw new TypeError("custom_types requires an object catalog and version 1.2");this.#e=structuredClone(e)}update(e){let t=new n(e),r=rc(this.#e,t.#e);return(this.#e.document_format.version==="1.2"||t.#e.document_format.version==="1.2")&&(r.document_format.version="1.2"),this.#e=r,this}toDocument(){return structuredClone(this.#e)}};var Kt=class{static renderType="string";static mode=null;constructor(e){this._builder=e,this.renders=new Map([[e,this]])}get builder(){return this._builder}get renderType(){return this.constructor.renderType}get mode(){return this.constructor.mode}addRender(e,t){this.renders.set(e,t)}getRender(e){let t=this.renders.get(e);if(t!==void 0)return t;let r=e.getRenderer();return this.renders.set(e,r),r}render(e,t={}){let r=e.builder,[i,s]=r.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,s,t);let o=this.getRender(r),a;return[a,s]=o._handleMeta(e,s),e._getMeta("subbuilder")||(s=o.adaptAttrs(s)),e.value instanceof A&&(i=this.renderChildren(e.value,t)),o.renderedItem(e,i,s,{tag:a,...t})}renderChildren(e,t={}){let r=[];for(let i of e.getNodes()){let s=this.render(i,t);s!==null&&(Array.isArray(s)?r.push(...s):r.push(s))}return r}_renderComponent(e,t,r){let[i,s,o,a]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,i,o,a,r);if(s==null)return[];if(!(s instanceof x))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${s?.constructor?.name||typeof s}`);return s.getNodes().map(l=>this._expandBlock(e,i,o,{node_label:l.label},r))}_expansionInputs(e,t){let r=e.builder,i=r.componentMethod(e.nodeTag),s=i&&r[i];if(typeof s!="function")throw new Error(`component '${e.nodeTag}' has no implementation`);let o=t.iterate;delete t.iterate,delete t.store;let a=e.getAttr("iterate")||e.getAttr("store");a!=null?(e.pointerType(a)&&(a=a.slice(1)),a.startsWith(".")&&(a=e._composeRelativeDatapath(a,a))):a=null;for(let l of Object.keys(t)){let u=e.getAttr(l);e.pointerType(u)==="^"&&(t[l]=`^${e.absDatapath(u)}`)}return[s,o,a,t]}_expandBlock(e,t,r,i,s){let o=e.builder._expansionRoot(r);t.call(e.builder,Ln(o),i);let a=o.getNodes();if(a.length!==1)throw new Error(`component '${e.nodeTag}' must build a tree, not a forest: ${a.length} root nodes`);let l={...s,depthOffset:this._nodeDepth(e,s.depthOffset||0)};return this.render(a[0],l)}preprocess(e){return e}renderedItem(e,t,r,i){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[r,i]=e._getMeta("render_tag,render_attributes"),s=Mn(e.nodeTag,{renderTag:r,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!s)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return i&&(t={...t,...i}),[s,t]}adaptAttrs(e){return e}adapt(e){let t=`${this.builder.constructor._name}_`;return e.startsWith(t)?e.slice(t.length):e}finalize(e,t=null,r={}){let i=this._composeStringFragments(e);if(t==null)return i;if(typeof t=="string")throw new TypeError("string render targets require filesystem support, which is unavailable in the portable renderer; pass a callable or writable target instead");if(typeof t.full=="function"&&typeof t.write!="function")return t.full(i),null;if(typeof t.write=="function")return t.write(i),null;if(typeof t=="function")return t(i),null;throw new TypeError("render target must be writable (.write), callable, or expose .full")}_composeStringFragments(e){if(!Array.isArray(e))return e;if(e.some(t=>typeof t!="string"))throw new TypeError("String composition requires string fragments; object renderers must define their own composition");return e.join("")}_escapeText(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',"&quot;")}_nodeDepth(e,t=0){let i=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(i-1,0)+t}};var Qt=class extends Kt{static mode="xml";renderedItem(e,t,r,{tag:i,pretty:s=!1,depthOffset:o=0}={}){let a=this._formatAttrs(r),l=s?" ".repeat(this._nodeDepth(e,o)):"",u=s?`
39
+ `:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${i}${a}>${u}${c}${l}</${i}>${u}`}return t==null?`${l}<${i}${a}></${i}>${u}`:`${l}<${i}${a}>${this._escapeText(t)}</${i}>${u}`}finalize(e,t=null,{docHeader:r=null}={}){let i=this._composeStringFragments(e);return r===!0?i=`<?xml version='1.0' encoding='UTF-8'?>${i}`:typeof r=="string"&&(i=r+i),super.finalize(i,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,r])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(r)}"`).join("")}};var nc={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"base",version:null,title:null,description:null},abstracts:{},elements:{dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};function ic(n){let e=[];for(;n&&n!==Function.prototype;)e.push(n),n=Object.getPrototypeOf(n);return e.reverse()}function Um(n){let e=Object.create(null),t=(r,i)=>{let s=r.toLowerCase(),o=e[s];if(o!==void 0&&o!==i)throw new Error(`container '${r}' is already tied to implementation method '${o}' (cannot rebind to '${i}')`);e[s]=i};for(let r of ic(n))if(Object.hasOwn(r,"containers"))for(let i of r.containers||[])t(i,i);return e}function Pn(n){let e=Object.create(null);for(let t of Object.keys(n)){let r=t.toLowerCase();if(Object.hasOwn(e,r))throw new Error(`element declaration '${t}' has a case-insensitive collision with '${e[r]}'`);e[r]=t}return e}var jn="_root_",Fn="_root_",sc=new Set(["destination","func","value","_on_start"]),Te=class n{static _sourceClass=A;static registerBuilder(e){if(typeof e!="function"||!(e.prototype instanceof n))throw new TypeError("registerBuilder requires a BuilderBase subclass");let t=e._name;if(typeof t!="string"||!t)throw new TypeError("registered builders require a non-empty static _name");let r=n._registry.get(t);if(r&&r!==e)throw new Error(`Builder name '${t}' is already registered to ${r.name}; cannot register ${e.name}`);return n._registry.set(t,e),e}static getBuilderClass(e){let t=n._registry.get(e);if(!t)throw new Error(`No builder registered with name '${e}'`);return t}constructor(e=null){this.name=e||this.constructor._name,this._dataroot=new x,this._dataroot.setBackref(),this._dataroot.setItem(Fn,new x),this.data=this._dataroot.getItem(Fn),this._defaultTargets=new Map,this.materialized=Object.create(null),this._collection=null,this._schemaOverride=null,this._tagNamesOverride=null,this._componentMap=null,this._targetSerial=0,this._subbuilders=new Map,this._sourceHandles=new WeakMap;let t=this.constructor._sourceClass;this._sourceroot=new t(null,this),this._sourceroot.setBackref(),this._sourceroot.setItem(jn,new t(null,this)),this.source=this._sourceroot.getItem(jn)}wrapSource(e){if(e=J(e),!(e instanceof A)&&!(e instanceof Ae))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=Hu(this,e),this._sourceHandles.set(e,t)),t}get root(){return this.wrapSource(this.source)}getSubbuilder(e){if(typeof e!="string"||!e||e.includes(":"))throw new Error(`unsupported subbuilder reference '${e}'`);let t=this._subbuilders.get(e);if(!t){let r=n.getBuilderClass(e);t=new r,this._subbuilders.set(e,t)}return t._dataroot=this._dataroot,t.data=this.data,t}_resolveSubbuilderReference(e,t,r){if(typeof e!="string"||!e)throw new Error(`'${r}': subbuilder declaration must be a non-empty string`);if(e.includes(":"))throw new Error(`'${r}': runtime subbuilder reference '${e}' is unsupported`);return this.getSubbuilder(e)}static defineGrammar(e){let t=this._classCollection,r=t?new ut(t.toDocument()).update(e):new ut(e),i=Qo(r.toDocument()),s=Ko(i),o=Pn(s.elements);this._classCollection=r,this._classSchema=s.elements,this._abstracts=s.abstracts,this._tagNames=o}static{this.defineGrammar(nc)}get _containers(){return Um(this.constructor)}containerMethod(e){return this._containers[e.toLowerCase()]||null}componentMethod(e){return this._componentMap?.[e.toLowerCase()]||null}get schema(){return this._schemaOverride||this.constructor._classSchema||{}}get schemaTagNames(){return this._schemaOverride?this._tagNamesOverride??=Pn(this.schema):this.constructor._tagNames??=Pn(this.schema)}schemaTag(e){let t=e.toLowerCase(),r=this.schemaTagNames[t];if(r)return r;let i=`${this.constructor._name}_`;return t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)]||null}loadGrammar(e,{replace:t=!1}={}){let r=this._collection||this.constructor._classCollection,i=t?new ut(e):new ut(r.toDocument()).update(e),s=Qo(i.toDocument()),o=Ko(s),a=Pn(o.elements);return this._collection=i,this._schemaOverride=o.elements,this._tagNamesOverride=a,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,r=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;tc(e.nodeTag,r.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,r={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);return ec(i,this.schema[i],t,r),!0}validateNode(e,{value:t,attrs:r,childTags:i}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let s=t!==void 0?t:e.value instanceof A?null:e.value;this.validateNodeValues(e.nodeTag,s,r||e.getAttr?.()||{});let o=this.schema[this.schemaTag(e.nodeTag)],a=i||(e.value instanceof A?e.value.getNodes().map(l=>l.nodeTag):null);return a&&this._validateChildren(e.nodeTag,o,a,!1),!0}validateChildren(e,t,{includeMinimum:r=!1}={}){let i=this.schemaTag(e);if(!i)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(s=>typeof s!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(i,this.schema[i],t,r)}validateParent(e,t=null){let r=this.schemaTag(e);if(!r)throw new Error(`unknown element '${e}'`);let i=this.schema[r];if(!this._countsForGrammar(i))return!0;let s=i._parentSpec;if(s==null||s.has("*"))return!0;if(t===null)throw new Error(`'${r}' requires a declared parent`);let o=this.schemaTag(t);if(!o)throw new Error(`unknown parent element '${t}'`);return this._validateParent(r,i,o),!0}bagCall(e,t,r,i){return this.setChild(e,t,r,i)}commandOnNode(e,t,r,i){if(e=J(e),e.value instanceof A)return this.setChild(e.value,t,r,i);let s=e.value,o=new e.parentBag.constructor(null,e.builder||this),a=this.setChild(o,t,r,i,e);return this.promoteNodeValue(e,s,o),a}promoteNodeValue(e,t,r){e.setValue(r)}setChild(e,t,r,i,s=null){let o={...i},a=this.schema[t];if(!a)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,r,o);let l=a._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,o,t))||this,d=r instanceof A?r._builderBindingPlan(c):null,f=s?.rootBuilder||e.root._builder||this;if(o.nodeId!=null&&f.source.getNodeByAttr("nodeId",o.nodeId))throw new Error(`Duplicate nodeId '${o.nodeId}'`);r instanceof A&&this._validateChildren(t,a,r.getNodes().map(w=>w.nodeTag),!1);let h=s||e.parentNode,m=h?.nodeTag?this.schema[h.nodeTag]:null;if(m&&!h._getMeta("subbuilder")&&this._countsForGrammar(a))this._validateParent(t,a,h.nodeTag),this._validateChildren(h.nodeTag,m,[...e.getNodes().map(w=>w.nodeTag),t],!1);else if(!m&&!h?._getMeta("subbuilder")&&a._parentSpec!=null&&this._countsForGrammar(a))throw new Error(`'${t}' requires a declared parent`);a._meta&&!("_meta"in o)&&(o._meta=a._meta),a.ns&&!("ns"in o)&&(o.ns=a.ns);let p=o.node_position;delete o.node_position;let b=o.node_label;delete o.node_label;let g;if(m?.collection_key){if(b!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);g=this._collectionLabel(m.collection_key,t,o)}else{let w=m?._subSpec?.get(t);if(w&&w.max===1){if(b!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);g=t}else g=b||a.node_label||this._autoLabel(e,t)}if(e.node(g)!=null)throw new Error(`duplicate node label '${g}'`);return e._setBuilderItem(c,d,g,r,o,p||">",!1,!0,null,!1,!0,null,t)}_countsForGrammar(e){let t=e?._meta||{};return!(t.data_element||t.subbuilder||t.component)}_validateParent(e,t,r){let i=t._parentSpec;if(!(i==null||i.has("*")||!this._countsForGrammar(t))&&!i.has(r))throw new Error(`'${e}' not allowed as child of '${r}'`)}_validateChildren(e,t,r,i){let s=t._subSpec;if(s==null||s.has("*")||t._meta?.subbuilder)return[];let o=new Map;for(let a of r){let l=this.schema[a];if(l&&!this._countsForGrammar(l))continue;let u=s.get(a);if(!u)throw new Error(`'${a}' not allowed as child of '${e}'`);let c=(o.get(a)||0)+1;if(o.set(a,c),c>u.max)throw new Error(`too many '${a}' in '${e}'`)}return i?[...s].filter(([a,l])=>(o.get(a)||0)<l.min).map(([a])=>a):[]}_collectionLabel(e,t,r){let i=s=>{if(r[s]===null||r[s]===void 0)throw new Error(`'${t}': collection key needs attribute '${s}'`);return String(r[s])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(s,o)=>i(o)):i(e)}validateSource(){let e=[],t=(r,i="")=>{for(let s of r.getNodes()){let o=i?`${i}.${s.label}`:s.label,a=s.builder;a.validateCustomTypes(s);let l=a.schema[s.nodeTag];if(l&&!s._getMeta("data_element,subbuilder,component").some(Boolean)){let u=s.value instanceof A?s.value.getNodes().map(d=>d.nodeTag):[],c=a._validateChildren(s.nodeTag,l,u,!0);c.length&&e.push([o,c])}s.value instanceof A&&t(s.value,o)}};return t(this.source),e}_autoLabel(e,t){let r=0;for(;e.node(`${t}_${r}`)!==null&&e.node(`${t}_${r}`)!==void 0;)r+=1;return`${t}_${r}`}nodeById(e){let t=this.source.getNodeByAttr("nodeId",e);if(t==null)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}runtimeValues(e){e.builder.validateCustomTypes(e);let t=new Map,r={},i=e.runtimeToEvaluate(),s=new Set(i.keys()),o=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...i])if(!(typeof c!="string"||!H(d)))for(let f of Ge(e,d))i.has(f)||i.set(f,o.get(f));let a=e._getMeta("data_element");for(let[c,d]of i){if(d instanceof K){t.set(c,d.resolve());continue}let f=typeof c=="string"?H(d)?.pointer??d:d;if(!e.pointerType(f)){t.set(c,typeof c=="string"&&typeof d=="string"&&d.startsWith("==")?null:d);continue}let h=e.absDatapath(f);if(t.set(c,this.data.getItem(h)),!a&&!h.includes("?")&&c===Pr){let m=this.data.getNode(h);m&&Object.assign(r,m.getAttr("_wdg"))}}let l=$a(i,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(Pr);l.delete(Pr);for(let c of l.keys())s.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...r}]}evaluatePointerExpression(e,t,r,i,s){return null}targetId(e){if(e._targetId)return e._targetId;let t=e.rootBuilder;return e.parentBag.root!==t.source.root?null:(t._targetSerial+=1,e._targetId=`n${t._targetSerial}`,e._targetId)}get dataLogic(){if(!this._dataLogic){let e=this._buildDataLogic();this._dataLogic=Array.isArray(e)?e:[e]}return this._dataLogic}_buildDataLogic(){return this}_resolveLogicFunc(e){if(typeof e=="function")return e;if(typeof e!="string")throw new Error("data-element func must be a name or a function");for(let t of this.dataLogic){let i=(typeof t=="function"?t:t.constructor)[e];if(typeof i=="function")return i}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),r={};for(let[i,s]of Object.entries(t))sc.has(i)||(r[i]=s);return r}computeLogic(e){for(let t of e)this._computeNode(t)}_computeNode(e){let t=e.getAttr()||{};if(e.nodeTag==="dataSetter"){let r={};for(let[i,s]of Object.entries(t))i!=="destination"&&i!=="value"&&!i.startsWith("_")&&(r[i]=s);e.setRelativeData(t.destination,t.value,{attributes:Object.keys(r).length?r:null})}else if(e.nodeTag==="dataFormula"){let r=this._resolveLogicFunc(t.func);e.setRelativeData(t.destination,r(this._bindings(e)))}else e.nodeTag==="dataController"&&this._resolveLogicFunc(t.func)(e,this._bindings(e))}_dataElementNodes(){let e=[],t=r=>{for(let i of r.getNodes())i._getMeta("data_element")&&e.push(i),i.value instanceof A&&t(i.value)};return t(this.source),e}setup(e){}main(e){throw new Error(`${this.constructor.name}.main() not implemented: a bare builder is grammar, not a renderable page`)}_resolveComponents(){let e={};for(let a of ic(this.constructor))if(Object.hasOwn(a,"components"))for(let l of a.components||[])e[l]=l;if(!Object.keys(e).length)return;let t={...this.schema},r={};for(let[a,l]of Object.entries(e))t[a]={sub_tags:"",_meta:{component:!0}},r[a.toLowerCase()]=l;let i=Pn(t),s=this._collection||this.constructor._classCollection,o=s.toDocument();o.abstracts={},o.elements=Object.fromEntries(Object.keys(e).map(a=>[a,t[a]])),this._collection=new ut(s.toDocument()).update(o),this._schemaOverride=t,this._componentMap=r,this._tagNamesOverride=i}_expansionRoot(e=null){let t=this.constructor._sourceClass,r=new t(null,this);return r.setBackref(),r.setItem(jn,new t(null,this),e?{datapath:e}:null),r.getItem(jn)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Qt(this)}getRenderer(e=null){e??=this.constructor._defaultRenderMode;let t=this[`renderer_${e}`];if(!t)throw new Error(`${this.constructor.name} does not expose renderer_${e}`);return t}materialize(e=null,t={}){e??=this.constructor._defaultRenderMode;let r=this.getRenderer(e),i=r.renderChildren(r.preprocess(this.source),t);return this.materialized[e]=i,i}setRenderTarget(e,t=null){t??=this.constructor._defaultRenderMode,this._defaultTargets.set(t,e)}render({mode:e=null,target:t=null,...r}={}){e??=this.constructor._defaultRenderMode;let i=this.getRenderer(e);if(t===!1&&i.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let s=t===!1?null:t||this._defaultTargets.get(i.mode)||null,o={...s?.renderOpts,...r};return i.finalize(this.materialize(e,o),s,o)}};Te._registry=new Map;var Vm=new Set(["short","medium","long","full"]),zm=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Hm(n,e){if(!(n instanceof Date))throw new TypeError("Temporal formats require a typed Date value");if(!Number.isFinite(n.getTime()))throw new RangeError("Invalid date");let t=e||U(n).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function Wm(n,e,t,r){let i=e.match(zm)||[];if(i.join("")!==e)throw new RangeError("Unclosed format literal");let s=(c,d=2)=>String(c).padStart(d,"0"),o=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(n),u={...r==="H"?{}:{y:()=>String(n.getUTCFullYear()),yy:()=>s(n.getUTCFullYear()%100),yyyy:()=>s(n.getUTCFullYear(),4),M:()=>String(n.getUTCMonth()+1),MM:()=>s(n.getUTCMonth()+1),MMM:()=>o({month:"short"}),MMMM:()=>o({month:"long"}),d:()=>String(n.getUTCDate()),dd:()=>s(n.getUTCDate()),EEE:()=>o({weekday:"short"}),EEEE:()=>o({weekday:"long"})},...r==="D"?{}:{H:()=>String(n.getUTCHours()),HH:()=>s(n.getUTCHours()),h:()=>String(n.getUTCHours()%12||12),hh:()=>s(n.getUTCHours()%12||12),m:()=>String(n.getUTCMinutes()),mm:()=>s(n.getUTCMinutes()),s:()=>String(n.getUTCSeconds()),ss:()=>s(n.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(n).find(c=>c.type==="dayPeriod").value}};return i.map(c=>{if(c.startsWith("'"))return c==="''"?"'":c.slice(1,-1).replaceAll("''","'");if(!/^[a-zA-Z]/.test(c))return c;if(!u[c])throw new RangeError(`Unsupported date format token: ${c}`);return u[c]()}).join("")}function oc(n,{format:e,mask:t,locale:r,dtype:i,places:s}={}){let o=n==null?"":String(n);if(n!=null&&n!==""&&(e!=null&&e!==""||s!=null))if(typeof n=="number"||be(n))o=Xm(n,{format:e,locale:r,places:s});else{let a=Hm(n,i);if(Vm.has(e)){let l={timeZone:"UTC"};a!=="H"&&(l.dateStyle=e),a!=="D"&&(l.timeStyle=e),o=new Intl.DateTimeFormat(r||void 0,l).format(n)}else o=Wm(n,String(e),r||void 0,a)}return t==null?o:String(t).replaceAll("%s",()=>o)}function Gm({format:n="decimal",places:e}={}){let t={maximumFractionDigits:20};if(!n||n==="decimal")t.style="decimal";else if(n==="percent")t.style="percent";else if(n==="scientific")t.notation="scientific";else{let r=/^(0|#,##0)(?:\.(0*)(#*))?$/.exec(n);if(!r||n.includes(".")&&!r[2]&&!r[3])throw new RangeError(`Unsupported number format: ${n}`);t.useGrouping=r[1].includes(","),t.minimumFractionDigits=(r[2]||"").length,t.maximumFractionDigits=(r[2]||"").length+(r[3]||"").length}if(e!=null&&e!==""){let r=Number(e);if(!Number.isInteger(r)||r<0||r>20)throw new RangeError("places must be an integer from 0 to 20");t.minimumFractionDigits=r,t.maximumFractionDigits=r}return t}function Xm(n,e={}){if(typeof n!="number"&&!be(n))throw new TypeError("Number formatting requires a Number or Decimal");if(!Number.isFinite(Number(n)))throw new RangeError("Number must be finite");let t=new Intl.NumberFormat(e.locale||void 0,Gm(e));if(be(n)&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal values without precision loss");return t.format(be(n)?n.toString():n)}var Ym=new Set(["style","script"]),Zm=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),ac=new Set(["width","height","top","left","right","bottom","padding","margin","border","position","display","overflow","float","clear","resize","z_index","min_width","min_height","max_width","max_height","color","background","font","text","line_height","white_space","vertical_align","flex","gap","row_gap","column_gap","grid","align_content","justify_content","align_items","justify_items","visibility","opacity","cursor"]),qn=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),lc=n=>n===!0?"true":n===!1?"false":String(n),ls=n=>typeof n=="number"&&Number.isFinite(n)?`${n}px`:String(n);function Jm(n){if(ac.has(n))return!0;for(let e of ac)if(n.startsWith(`${e}_`))return!0;return!1}function Km(n){let e=new Map;if(!n)return e;let t=[],r=0,i=null,s=!1,o=!1,a=0,l=String(n);for(let u=0;u<l.length;u+=1){let c=l[u],d=l[u+1];if(o){c==="*"&&d==="/"&&(o=!1,u+=1);continue}if(s){s=!1;continue}if(c==="\\"){s=!0;continue}if(i){c===i&&(i=null);continue}c==='"'||c==="'"?i=c:c==="/"&&d==="*"?(o=!0,u+=1):"([{".includes(c)?a+=1:")]}".includes(c)&&a>0?a-=1:c===";"&&a===0&&(t.push(l.slice(r,u)),r=u+1)}t.push(l.slice(r));for(let u of t){let c=u.trim();if(!c)continue;let d=c.indexOf(":");if(d<0)throw new TypeError(`malformed style declaration '${c}'`);e.set(c.slice(0,d).trim(),c.slice(d+1).trim())}return e}var er=class extends Kt{static mode="html";renderedItem(e,t,r,{tag:i,xml:s=!0,pretty:o=!1,depthOffset:a=0,includeDatapath:l=!1}={}){e.parentNode?._getMeta("subbuilder")==="html"&&(r={xmlns:"http://www.w3.org/1999/xhtml",...r});let{format:c,mask:d,locale:f,places:h,dtype:m,...p}=r;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=oc(t,{format:c,mask:d,places:h,dtype:m,locale:this._displayLocale(e,f)}));let b=this._formatAttrs(p);if(l){if(!Object.hasOwn(r,"id")){let E=this.builder.targetId(e);E!==null&&(b+=` id="${this._htmlAttrValue(E)}"`)}for(let[E,D]of Object.entries(e.getAttr()))e.pointerType(D)&&(b+=` data-${this.adapt(E)}-pointer="${this._htmlAttrValue(e.absDatapath(D))}"`)}let g=o?" ".repeat(this._nodeDepth(e,a)):"",_=o?`
40
+ `:"";if(e._getMeta("void"))return`${g}<${i}${b}${s?"/":""}>${_}`;if(Array.isArray(t)){let E=this._composeStringFragments(t);return`${g}<${i}${b}>${_}${E}${g}</${i}>${_}`}if(t==null)return`${g}<${i}${b}></${i}>${_}`;let w=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):Ym.has(i)?String(t):this._escapeText(t);return`${g}<${i}${b}>${w}</${i}>${_}`}_displayLocale(e,t){if(t)return t;for(let r=e.parentNode;r;r=r.parentNode){let i=r.getAttr("locale");if(i==null)continue;let s=r.pointerType(i)?r.data.getItem(r.absDatapath(i)):i;if(s)return s}}adaptAttrs(e){let t={},r={};for(let[s,o]of Object.entries(e||{}))if(s.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(s)]=o;else if(s==="dtype")t.dtype=o;else{if(this.builder.constructor.retainedAttrPrefixes.some(a=>s.startsWith(a)))continue;this._isStyleContribution(s)?r[s]=o:t[s]=o}let i=this._adaptStyle(r);return i&&(t.style=i),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||qn.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&qn.has(t)||Jm(e)}_adaptStyle(e){let t=Km(e.style),r=new Map,i=new Map;for(let[s,o]of Object.entries(e))if(s!=="style")if(s.startsWith("style_"))t.set(s.slice(6).replaceAll("_","-"),lc(o));else if(qn.has(s))r.set(s,o);else{let a=s.indexOf("_"),l=a<0?s:s.slice(0,a);a>=0&&qn.has(l)?(i.has(l)||i.set(l,{}),i.get(l)[s.slice(a+1)]=o):t.set(s.replaceAll("_","-"),lc(o))}for(let s of qn)(r.has(s)||i.has(s))&&this[`_macro_${s}`](r.get(s),i.get(s)||{},t);return[...t].map(([s,o])=>`${s}: ${o}`).join("; ")}_formatAttrs(e){let t=[];for(let[r,i]of Object.entries(e||{}))Zm.has(r)?i&&t.push(` ${r}`):t.push(` ${r}="${this._htmlAttrValue(i)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}_macro_rounded(e,t,r){let i=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[s,o]of Object.entries(t))if(s==="top"||s==="bottom")i[`${s}_left`]=o,i[`${s}_right`]=o;else if(s==="left"||s==="right")i[`top_${s}`]=o,i[`bottom_${s}`]=o;else if(["top_left","top_right","bottom_left","bottom_right"].includes(s))i[s]=o;else throw new TypeError(`rounded: unknown sub-kwarg '${s}'`);for(let[s,o]of Object.entries(i))r.set(`border-${s.replaceAll("_","-")}-radius`,ls(o))}_macro_transform(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`rotate(${o}deg)`):s==="scale"||s==="translate"?i.push(`${s}(${o})`):s==="translate_x"?i.push(`translateX(${ls(o)})`):s==="translate_y"?i.push(`translateY(${ls(o)})`):s==="skew_x"?i.push(`skewX(${o}deg)`):s==="skew_y"?i.push(`skewY(${o}deg)`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("transform",i.join(" "))}_macro_filter(e,t,r){let i=e===void 0?[]:[String(e)];for(let[s,o]of Object.entries(t))s==="rotate"?i.push(`hue-rotate(${o}deg)`):s==="blur"?i.push(`blur(${ls(o)})`):s==="drop_shadow"?i.push(`drop-shadow(${o})`):i.push(`${s.replaceAll("_","-")}(${o})`);i.length&&r.set("filter",i.join(" "))}_macro_transition(e,t,r){e!==void 0&&r.set("transition",String(e));for(let[i,s]of Object.entries(t))r.set(`transition-${i.replaceAll("_","-")}`,String(s))}_macro_zoom(e,t,r){e!==void 0&&r.set("zoom",String(e))}_macro_shadow(e,t,r){e!==void 0&&r.set("box-shadow",String(e));for(let[i,s]of Object.entries(t))r.set(`box-shadow-${i.replaceAll("_","-")}`,String(s))}_macro_gradient(e,t,r){e!==void 0&&r.set("background-image",String(e))}};var Qm=new Set(["alignment_baseline","baseline_shift","clip_path","clip_rule","color_interpolation","color_interpolation_filters","dominant_baseline","fill_opacity","fill_rule","flood_color","flood_opacity","font_family","font_size","font_size_adjust","font_stretch","font_style","font_variant","font_weight","glyph_orientation_horizontal","glyph_orientation_vertical","image_rendering","letter_spacing","lighting_color","marker_end","marker_mid","marker_start","overline_position","overline_thickness","paint_order","pointer_events","shape_rendering","stop_color","stop_opacity","strikethrough_position","strikethrough_thickness","stroke_dasharray","stroke_dashoffset","stroke_linecap","stroke_linejoin","stroke_miterlimit","stroke_opacity","stroke_width","text_anchor","text_decoration","text_rendering","underline_position","underline_thickness","unicode_bidi","word_spacing","writing_mode"]);function us(n){return Object.fromEntries(Object.entries(n||{}).map(([e,t])=>[Qm.has(e)?e.replaceAll("_","-"):e,t]))}var tr=class extends Qt{static mode="svg";adaptAttrs(e){return us(e)}};var uc={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"html",version:null,title:null,description:null},abstracts:{},elements:{svg:{doc:"Switch to the SVG dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to SVG from this node down. No ``render_tag``: ``<svg>`` is\n emitted verbatim (HTML5 has a native ``<svg>`` tag).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"svg"}},a:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},abbr:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},address:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},area:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},article:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},aside:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},audio:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},b:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},base:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},bdi:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},bdo:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},blockquote:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},body:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},br:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},button:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},canvas:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},caption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},cite:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},code:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},col:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},colgroup:{doc:null,sub_tags:"col,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},data:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},datalist:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,option,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dd:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},del_:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},details:{doc:null,sub_tags:"summary[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dfn:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dialog:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},div:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dl:{doc:null,sub_tags:"dd,div,dt,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dt:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},em:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},embed:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},fieldset:{doc:null,sub_tags:"legend[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figcaption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figure:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figcaption[0:1],figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},footer:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},form:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h1:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h2:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h3:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h4:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h5:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h6:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},head:{doc:null,sub_tags:"base[0:1],link,meta,noscript,script,style,template,title[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},header:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hgroup:{doc:null,sub_tags:"h1,h2,h3,h4,h5,h6,p,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},html:{doc:null,sub_tags:"head[0:1],body[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},i:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},iframe:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},img:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},input:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},ins:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},kbd:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},label:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},legend:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},li:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},link:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},main:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},map:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mark:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},menu:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},meta:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},meter:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},nav:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},noscript:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},object:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ol:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},optgroup:{doc:null,sub_tags:"div,legend,noscript,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},option:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,div,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},output:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},p:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},picture:{doc:null,sub_tags:"img[0:1],script,source,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pre:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},progress:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},q:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rp:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rt:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ruby:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},s:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},samp:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},script:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},search:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},section:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},select:{doc:null,sub_tags:"button,div,hr,noscript,optgroup,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},slot:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},small:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},source:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},span:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},strong:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},style:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sub:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},summary:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sup:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},table:{doc:null,sub_tags:"caption[0:1],colgroup,script,tbody,template,tfoot[0:1],thead[0:1],tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tbody:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},td:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},template:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,del_,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,tr,track,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textarea:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tfoot:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},th:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},thead:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},time:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tr:{doc:null,sub_tags:"script,td,template,th",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},track:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},u:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ul:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},var:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},video:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},wbr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},selectedcontent:{doc:"Mirror of the selected option for Customizable Select (HTML 2024).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var St=class extends Te{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar(uc)}get renderer_html(){return new er(this)}};Te.registerBuilder(St);var cc={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"svg",version:null,title:null,description:null},abstracts:{graphics:{doc:"SVG graphics content: any graphical element.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null},containerElement:{doc:"SVG container content: elements that can hold children.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null}},elements:{html:{doc:"Switch to the HTML dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to HTML from this node down. The source tag ``html`` is\n rendered as ``_meta['render_tag']`` (``<foreignObject>``) carrying\n ``_meta['render_attributes']`` (the SVG namespace). The immediate\n HTML child declares XHTML so both sides of the XML boundary retain\n their native namespace.\n ",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"html",render_tag:"foreignObject",render_attributes:{xmlns:"http://www.w3.org/2000/svg"}}},svg:{doc:"Root SVG container or nested SVG viewport.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},g:{doc:"Group container for applying transforms and styles.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},defs:{doc:"Container for referenced elements (gradients, patterns, etc.).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},symbol:{doc:"Reusable graphical template, rendered only when referenced by <use>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},use:{doc:"Reference and render a <symbol> or other element.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rect:{doc:"Rectangle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},circle:{doc:"Circle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ellipse:{doc:"Ellipse.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},line:{doc:"Line segment between two points.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polyline:{doc:"Open shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polygon:{doc:"Closed shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},path:{doc:"Arbitrary shape defined by path commands (d attribute).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},image:{doc:"Embedded raster image.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},text:{doc:"Text block. Contains text content and optional <tspan>/<textPath>.",sub_tags:"tspan,textPath",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tspan:{doc:"Inline text span within <text>.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textPath:{doc:"Text rendered along a path shape.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},linearGradient:{doc:"Linear gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},radialGradient:{doc:"Radial gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},stop:{doc:"Gradient stop (color and offset).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pattern:{doc:"Tile pattern definition. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},clipPath:{doc:"Clipping path definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mask:{doc:"Alpha mask definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},marker:{doc:"Marker symbol for line endpoints or vertices.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},filter:{doc:"Filter effect container. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feGaussianBlur:{doc:"Gaussian blur filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feOffset:{doc:"Offset filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feBlend:{doc:"Blend filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feColorMatrix:{doc:"Color matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feComposite:{doc:"Composite filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feFlood:{doc:"Flood fill filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMerge:{doc:"Merge filter primitive (container for feMergeNode).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMergeNode:{doc:"Single input for feMerge.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDropShadow:{doc:"Drop shadow filter primitive (SVG 2).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDiffuseLighting:{doc:"Diffuse lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpecularLighting:{doc:"Specular lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},fePointLight:{doc:"Point light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDistantLight:{doc:"Distant light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpotLight:{doc:"Spot light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMorphology:{doc:"Morphology filter primitive (erode/dilate).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTurbulence:{doc:"Turbulence noise filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDisplacementMap:{doc:"Displacement map filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feConvolveMatrix:{doc:"Convolution matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feImage:{doc:"Image filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTile:{doc:"Tile filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animate:{doc:"Animate an attribute over time.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateTransform:{doc:"Animate a transform attribute.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateMotion:{doc:"Animate motion along a path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},set:{doc:"Set an attribute to a value for a duration.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:"Accessible title (tooltip in browsers).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},desc:{doc:"Accessible description.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},metadata:{doc:"Metadata container (RDF, Dublin Core, etc.).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},a:{doc:"Hyperlink wrapper.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},foreignObject:{doc:"Container for non-SVG content (HTML, MathML).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},switch:{doc:"Conditional processing (renders first matching child).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var Nt=class extends Te{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(cc)}get renderer_svg(){return new tr(this)}};Te.registerBuilder(Nt);var rr=class n{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=jr.fromJSON({nameSyntax:{kind:"annotated",base:{kind:"type",module:"builtins",name:"str"},metadata:[this.toJSON()]}}).resolve("nameSyntax").test,Object.freeze(this)}static fromJSON(e){if((e!==null&&typeof e=="object"?Object.keys(e).sort():[]).join()!=="flags,kind,pattern"||e.kind!=="regex")throw new TypeError(`A name syntax is {kind: 'regex', pattern, flags}, not ${JSON.stringify(e)}`);return new n(e.pattern,e.flags)}toJSON(){return{kind:"regex",pattern:this.pattern,flags:this.flags}}matches(e){return this.#e(e)}},Un=new rr(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var De=class{constructor(e){this.gramlot=e}};var ra=["TL","TC","TR","L","R","BL","BC","BR"],dc=`.gramlot-labelbox[hidden]{display:none!important}
41
+ .gramlot-labelbox{box-sizing:border-box;min-width:0;min-height:0;--gramlot-label-width:initial;--gramlot-formlet-label-width:initial;display:grid;gap:var(--gramlot-label-gap,.25em);grid-template-areas:'label' 'control';grid-template-columns:minmax(0,1fr);grid-template-rows:max-content minmax(0,1fr)}
42
+ .gramlot-labelbox>.label-box{grid-area:label;color:var(--gramlot-label-color,var(--gramlot-text-secondary,inherit));font-size:var(--gramlot-label-size,1em)} .gramlot-labelbox>.control-box{box-sizing:border-box;grid-area:control;min-width:0;min-height:0;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
43
+ .gramlot-labelbox>.control-box>*{max-width:100%;box-sizing:border-box}
44
+ .gramlot-labelbox[data-position='L']{grid-template-areas:'label control';grid-template-rows:minmax(0,1fr)}
45
+ .gramlot-labelbox[data-position='R']{grid-template-areas:'control label';grid-template-columns:minmax(0,1fr) max-content;grid-template-rows:minmax(0,1fr)}
46
+ .gramlot-labelbox[data-position='L']>.label-box,.gramlot-labelbox[data-position='R']>.label-box{align-self:center}
47
+ .gramlot-labelbox[data-position^='B']{grid-template-areas:'control' 'label';grid-template-rows:minmax(0,1fr) max-content}
48
+ .gramlot-labelbox[data-position$='C']>.label-box{text-align:center}
49
+ .gramlot-labelbox[data-position$='R']>.label-box{text-align:right}
50
+ .gramlot-labelbox>.label-box[hidden]{display:none} .gramlot-labelbox>.label-box label{display:block}
51
+ .gramlot-labelbox[data-position='L']>.label-box{text-align:right;padding-right:2px}
52
+ .gramlot-labelbox[data-formlet-aligned]>.label-box>label{width:max-content;margin-left:auto}
53
+ .gramlot-labelbox[data-position='L']{grid-template-columns:var(--gramlot-label-width,var(--gramlot-formlet-label-width,max-content)) minmax(0,1fr)}
54
+ .gramlot-labelbox:has(>.label-box[hidden]){gap:0;grid-template-areas:'control';grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
55
+ .gramlot-labelbox[data-variant='card']{gap:0;border:1px solid var(--gramlot-border-control,#b9c2ce);border-radius:var(--gramlot-window-radius,9px);background:var(--gramlot-surface,#fff);box-shadow:0 3px 10px #0002}
56
+ .gramlot-labelbox[data-variant='card']>.label-box{background:var(--gramlot-card-header-background,#303946);color:var(--gramlot-card-header-color,#fff);padding:7px 12px;border-radius:calc(var(--gramlot-window-radius,9px) - 1px) calc(var(--gramlot-window-radius,9px) - 1px) 0 0;font-weight:600}
57
+ .gramlot-labelbox[data-variant='card']>.control-box{padding:12px}
58
+ .gramlot-labelbox[data-movable]>.label-box{cursor:grab;touch-action:none;user-select:none}
59
+ .gramlot-labelbox[data-selected]{outline:2px solid var(--gramlot-focus-ring,var(--gramlot-brand-blue,#3766b5));outline-offset:-2px}
60
+ .gramlot-labelbox[data-tray-block]>.label-box{position:relative;padding-inline:32px 60px}
61
+ .gramlot-labelbox>.label-box>.tray-settings-button{position:absolute;right:3px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:26px;height:26px;padding:4px;border:0;border-radius:4px;background:transparent;color:inherit;cursor:pointer}
62
+ .gramlot-labelbox>.label-box>button[hidden]{display:none}
63
+ .gramlot-labelbox>.label-box>.tray-settings-button[data-kind=layer]{right:31px}
64
+ .tray-settings-button{opacity:.65}
65
+ .tray-settings-button:hover,.tray-settings-button:focus-visible{opacity:1}
66
+ .tray-settings-button svg{width:18px;height:18px;pointer-events:none}
67
+ .gramlot-labelbox>.label-box>.tray-settings-button:hover{background:color-mix(in srgb,currentColor 12%,transparent)}
68
+ .tray-settings-button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
69
+
70
+ .gramlot-labelbox>.label-box>.tray-rotate{position:absolute;left:3px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:26px;height:26px;padding:4px;border:0;border-radius:4px;background:transparent;color:inherit;cursor:grab;touch-action:none;opacity:.7}
71
+ .tray-rotate svg{width:18px;height:18px;pointer-events:none}
72
+ .gramlot-labelbox>.label-box>.tray-rotate:hover{opacity:1;background:color-mix(in srgb,currentColor 12%,transparent)}
73
+ .tray-rotate:focus-visible{opacity:1;outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
74
+ .gramlot-labelbox[data-rotating]>.label-box>.tray-rotate{cursor:grabbing}
75
+ .gramlot-labelbox[data-moving]>.label-box{cursor:grabbing}
76
+ .gramlot-labelbox[data-resizable]>.control-box{overflow:auto}
77
+ .gramlot-labelbox>.tray-resize{position:absolute;right:1px;bottom:1px;width:22px;height:22px;padding:2px;display:grid;place-items:end;border:0;background:transparent;color:inherit;cursor:nwse-resize;touch-action:none;border-radius:3px;opacity:.65}
78
+ .gramlot-labelbox>.tray-resize[hidden]{display:none}
79
+ .gramlot-labelbox>.tray-resize svg{width:16px;height:16px;pointer-events:none}
80
+ .gramlot-labelbox>.tray-resize:hover,.gramlot-labelbox>.tray-resize:focus-visible{opacity:1}
81
+ .gramlot-labelbox>.tray-resize:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}`;function fc(n,e){let t=n.createElement("div"),r=n.createElement("div"),i=n.createElement("label");r.append(i),t.append(r,e);let s={box:t,labelBox:r,fieldLabel:i,controlBox:e,previous:{box:{},label:{},labelBox:{},controlBox:{}}};return t.labelbox=s,s}function hc(n,e,t){let{lbl:r,lbl_variant:i,lbl_position:s=i==="card"?"TC":"TL",...o}=e;if(!ra.includes(s))throw new TypeError(`Invalid lbl_position: ${s}`);let a={box:{},label:{},labelBox:{},controlBox:{}},l=[["box_l_","labelBox"],["box_c_","controlBox"],["lbl_","label"],["box_","box"]];for(let[c,d]of Object.entries(o)){let f=l.find(([h])=>c.startsWith(h));f&&(a[f[1]][c.slice(f[0].length)]=d,delete o[c])}let u={box:n.box,label:n.fieldLabel,labelBox:n.labelBox,controlBox:n.controlBox};for(let[c,d]of Object.entries(u)){let f=t(a[c]),h=n.previous[c];for(let m of new Set([...Object.keys(h),...Object.keys(f)]))f[m]==null?d.removeAttribute(m):d.setAttribute(m,String(f[m]));n.previous[c]=f}return e.lbl_width==null?n.box.style.removeProperty("--gramlot-label-width"):n.box.style.setProperty("--gramlot-label-width",e.lbl_width),n.box.classList.add("labelbox","gramlot-labelbox"),n.labelBox.classList.add("label-box"),n.controlBox.classList.add("control-box"),n.box.dataset.position=s,i==null?delete n.box.dataset.variant:n.box.dataset.variant=i,n.fieldLabel.textContent=r??"",n.labelBox.hidden=r==null||r==="",n.box.dispatchEvent(new n.box.ownerDocument.defaultView.Event("gramlot-label-layout",{bubbles:!0})),o}function fe(n){return n?.labelbox?n.labelbox.controlBox.firstElementChild:n}function Fr(n){let e=n?.parentElement?.parentElement;return e?.labelbox&&fe(e)===n?e:n}var rg=/^[a-z][.0-9_a-z\-\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*$/u,ng=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function ct(n){let e=n.code;if(typeof e!="string"||rg.exec(e)?.[0]!==e||!e.includes("-")||ng.has(e))throw new TypeError("webcomponent: code must be a literal custom-element name");return e}function na(n){for(let e of Object.values(n))e&&typeof e=="object"&&na(e);return Object.freeze(n)}function pc(n){if(!n.annotation&&typeof n.dtype!="string"&&!Array.isArray(n.dtype))throw new TypeError("Component parameter requires dtype");let e=n.annotation?[structuredClone(n.annotation)]:(Array.isArray(n.dtype)?n.dtype:[n.dtype]).map(t=>({kind:"dtype",dtype:t}));return n.nullable&&e.push({kind:"dtype",dtype:"NN"}),n.binding&&n.dtype!=="T"&&e.push({kind:"annotated",base:{kind:"dtype",dtype:"T"},metadata:[{kind:"regex",pattern:"^[\\^=].+",flags:0}]}),e.length===1?e[0]:{kind:"union",items:e}}function Ot({name:n,tag:e,base:t,mixins:r=[],parameters:i={},subTags:s="",presentationDefaults:o=[],dataScope:a=!1,command:l=!1,childParameters:u={},sourceContext:c=!1,bagStore:d=!1,dragSource:f=!1,implementation:h}){if(ct({code:e}),!/^[a-zA-Z][a-zA-Z0-9]*$/.test(n))throw new TypeError("Invalid component authoring name");let m={...t.parameters};for(let p of r)for(let[b,g]of Object.entries(p.parameters)){if(Object.hasOwn(m,b))throw new Error(`Duplicate mixin parameter: ${b}`);m[b]=g}Object.assign(m,i);for(let p of Object.values(m))pc(p);return Object.freeze({name:n,tag:e,base:t,subTags:s,presentationDefaults:Object.freeze([...o]),dataScope:a,command:l,bagStore:d,mixins:Object.freeze([...r]),labelbox:r.some(p=>p.labelbox===!0),parameters:na(structuredClone(m)),childParameters:na(structuredClone(u)),sourceContext:c,dragSource:f,implementation:h})}var It=class n{#e=new WeakMap;constructor({name:e,components:t,dependencies:r=[],css:i=[],assets:s={},registerCommands:o=()=>{}}){if(typeof e!="string"||!e)throw new TypeError("Collection name must be nonempty");if(!Array.isArray(r)||r.some(u=>!(u instanceof n)))throw new TypeError("Collection dependencies must be collection objects");if(!Array.isArray(i)||i.some(u=>!(u instanceof URL))||!s||typeof s!="object"||Array.isArray(s)||Object.values(s).some(u=>!(u instanceof URL)))throw new TypeError("Collection css/assets require URL objects");if(typeof o!="function")throw new TypeError("registerCommands must be a function");this.dependencies=Object.freeze([...r]),this.css=Object.freeze([...i]),this.assets=Object.freeze({...s}),this.registerCommands=o,this.name=e,this.components=Object.freeze([...t]);let a=new Set,l=new Set;for(let u of t){if(a.has(u.name.toLowerCase())||l.has(u.tag))throw new Error(`Duplicate component: ${u.name}`);a.add(u.name.toLowerCase()),l.add(u.tag)}}toDocument(){return{document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:this.name,version:null,title:this.name,description:null},abstracts:{},elements:Object.fromEntries(this.components.map(e=>[e.name,{doc:null,sub_tags:e.subTags,parent_tags:null,inherits_from:null,ns:null,node_label:null,collection_key:null,attributes:{parameters:[...Object.entries(e.parameters).map(([t,r])=>({name:t,kind:"keyword_only",role:"attribute",annotation:pc(r),has_default:!0,default:r.default??null})),{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:{render_tag:e.tag,gramlot_component:{parameters:structuredClone(e.parameters),presentationDefaults:[...e.presentationDefaults],dataScope:e.dataScope,command:e.command,...Object.keys(e.childParameters).length?{childParameters:structuredClone(e.childParameters)}:{},...e.sourceContext?{sourceContext:!0}:{},...e.labelbox?{labelbox:!0}:{},...e.dragSource?{dragSource:!0}:{},...e.bagStore?{bagStore:!0}:{}}}}]))}}register(e){if(this.#e.has(e))return;let t=[];for(let r of this.components){if(e.customElements.get(r.tag))throw new Error(`Custom element already registered: ${r.tag}`);let i=r.base(e.HTMLElement);for(let o of r.mixins)i=o(i);let s=r.implementation(i);Object.defineProperty(s,"gramlotComponent",{value:r}),t.push([r.tag,s])}for(let[r,i]of t)e.customElements.define(r,i);this.#e.set(e,t)}};function ia(n){return new It(n)}function qr(n,e){return n.parameters=Object.fromEntries(Object.entries(n.constructor.gramlotComponent.parameters).map(([t,r])=>[t,Object.hasOwn(e,t)?e[t]:r.default])),Object.fromEntries(Object.entries(e).filter(([t])=>!Object.hasOwn(n.parameters,t)))}function mc(n,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(n==="")return[];let t=new Set;return n.split(e).map(r=>{let i=r.indexOf(":"),s=i<0?r:r.slice(0,i),o=i<0?r:r.slice(i+1);if(!s||t.has(s))throw new Error("Invalid or duplicate choice code");return t.add(s),{id:s,caption:o}})}function cs(n){return class extends n{constructor(){super();let e=this.attachShadow({mode:"open"}),t=this.ownerDocument.createElement("style");t.textContent=`:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
25
82
  input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
26
83
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
27
84
  appearance:none;box-sizing:border-box;width:100%;border:1px solid var(--gramlot-border-control,#7a8798);
@@ -36,7 +93,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
36
93
  input[type=range],input[type=color],button{min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
37
94
  input[type=checkbox],input[type=radio]{min-width:calc(var(--gramlot-touch-target,0px) / 2);min-height:calc(var(--gramlot-touch-target,0px) / 2)}
38
95
  .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)}
39
- .caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return Lr(this,e)}setPageContext(e){this.pageContext=e}releaseControl(){}get liveWrites(){return this.control.localName==="textarea"||["text","password","range","color"].includes(this.control.type)}validateCandidate(e,t){return t(e),{ok:!0,value:e,isCurrent:()=>this.pageContext.isActive()}}finishValidation(){}validateSelection(){throw new TypeError("validate_select requires a constrained choice editor.")}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>{if(t==null&&!this.constructor.gramlotComponent.parameters.value.nullable)throw new TypeError("This component requires a non-null value.");if(t!=null&&e!=null&&typeof t!=typeof e)throw new TypeError("Validation must preserve the component value type.");this.sameControlValue(e,t)||this.writeControlValue(t)})}sameControlValue(e,t){return Object.is(e,t)}focus(e){this.control.focus(e)}}}function ec(n){return class extends rs(n){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,t){let r=super.projectAttributes(e,t),{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 r}}}ec.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function tc(n){return class extends rs(n){#e=new Map;#t;#r=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 t=[...this.control.querySelectorAll("input:not(:disabled)")],r=t.indexOf(e.target);if(r<0)return;e.preventDefault();let i=e.key==="Home"?0:e.key==="End"?t.length-1:Math.max(0,Math.min(t.length-1,r+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));t[i].focus()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=this.parameters.values??"";if(i!==this.#t){let o=Qu(i),a=new Set,l=null;for(let{id:u,caption:c}of o){let d=this.#e.get(u);if(!d){let h=this.ownerDocument.createElement("label");h.className="option";let p=this.ownerDocument.createElement("input");p.type=this.choiceType,p.name="choice",p.value=u;let m=this.ownerDocument.createElement("span");h.append(p,m),d={label:h,input:p,text:m},this.#e.set(u,d)}d.text.textContent=c;let f=l?l.nextSibling:this.control.firstChild;f!==d.label&&this.control.insertBefore(d.label,f),l=d.label,a.add(u)}for(let[u,c]of this.#e)a.has(u)||(c.label.remove(),this.#e.delete(u));this.#t=i}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:o}of this.#e.values())o.disabled=this.control.disabled||this.control.readOnly;return r}readControlValue(){if(this.multiple){let t=(this.#r?this.#r.split(","):[]).filter(r=>!this.#e.has(r)||this.#e.get(r).input.checked);for(let[r,{input:i}]of this.#e)i.checked&&!t.includes(r)&&t.push(r);return t.join(",")||null}for(let[e,{input:t}]of this.#e)if(t.checked)return e;return null}writeControlValue(e){this.#r=e;let t=this.multiple?new Set(e?e.split(","):[]):null;for(let[r,{input:i}]of this.#e)i.checked=this.multiple?t.has(r):r===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>this.writeControlValue(t))}focus(e){let t=[...this.#e.values()];(t.find(({input:r})=>r.checked&&!r.disabled)??t.find(({input:r})=>!r.disabled))?.input.focus(e)}}}tc.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Pr(n,e,{align:t="start",matchWidth:r=!1,inset:i=0,placement:s="bottom",point:o=null}={}){let a=e.ownerDocument.defaultView,l=o?{left:o.x,right:o.x,top:o.y,bottom:o.y,width:0}:e.getBoundingClientRect(),u=Math.max(0,a.innerWidth-16);n.style.setProperty("--gramlot-popup-available-width",`${u}px`),r&&(n.style.width=`${Math.min(Math.max(0,l.width-2*i),u)}px`),n.style.removeProperty("--gramlot-popup-available-height");let c=n.getBoundingClientRect();if(s==="side"){let g=Math.max(0,a.innerWidth-8-l.right-3),_=Math.max(0,l.left-8-3),w=c.width>g&&_>g;n.style.setProperty("--gramlot-popup-available-width",`${w?_:g}px`),n.style.setProperty("--gramlot-popup-available-height",`${Math.max(0,a.innerHeight-16)}px`);let v=n.getBoundingClientRect(),k=w?l.left-v.width-3:l.right+3;n.style.left=`${Math.max(8,Math.min(k,a.innerWidth-v.width-8))}px`,n.style.top=`${Math.max(8,Math.min(l.top,a.innerHeight-v.height-8))}px`;return}let d=Math.max(0,a.innerHeight-8-l.bottom-3),f=Math.max(0,l.top-8-3),h=c.height>d&&f>d;n.style.setProperty("--gramlot-popup-available-height",`${h?f:d}px`);let p=n.getBoundingClientRect(),m=t==="end"?l.right-p.width-i:l.left+i,b=h?l.top-p.height-3:l.bottom+3;n.style.left=`${Math.max(8,Math.min(m,a.innerWidth-p.width-8))}px`,n.style.top=`${Math.max(8,Math.min(b,a.innerHeight-p.height-8))}px`}function rc(n){if(n!=null&&(typeof n!="string"||/[{}]/.test(n.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function is(n,e){return rc(e),e==null?n:e.replaceAll("{}",()=>n)}function Fm(n){if(n instanceof Date)return vt(n);if(fe(n))return"N";if(typeof n=="number")return Number.isInteger(n)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function Um(n,e,{pattern:t="short",locale:r,timeZone:i}){if(!["short","medium","long","full"].includes(t))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=t),e!=="D"&&(s.timeStyle=t),new Intl.DateTimeFormat(r,s).format(n)}function ns(n){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(n);if(!e||e[1]==="("!=(e[4]===")")||n.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${n}`);let t=e[3]??"";return{prefix:e[1]??"",suffix:e[4]??"",intl:{useGrouping:e[2].startsWith("#,##")?"always":!1,minimumIntegerDigits:e[2].replace("#,##","").length,minimumFractionDigits:t.replaceAll("#","").length,maximumFractionDigits:t.length}}}function qm(n){let e=n.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=ns(e[0]);if(t.prefix||t.suffix)throw new RangeError("Positive-section affixes are not implemented");let r=e.length===3?e[1]:null;r!==null&&r!==""&&r!=="-"&&ns(r);let i=e.length>1?ns(e.at(-1)):null;return{positive:t,zero:r,negative:i}}function nc(n,e={},t={}){if(n===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 b of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(b))throw new RangeError(`Unsupported format option: ${b}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let r=e.dtype===void 0?Fm(n):e.dtype,i=["D","H","DHZ"].includes(r);if(!i&&!["L","R","N"].includes(r))throw new RangeError(`Unsupported format dtype: ${r}`);if(i){if(!(n instanceof Date)||!Number.isFinite(n.getTime()))throw new TypeError(`${r} requires a valid Date object`)}else if(!(typeof n=="number"&&Number.isFinite(n))&&!(fe(n)&&!["NaN","Infinity","-Infinity"].includes(n.toString())))throw new TypeError(`${r} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(r==="L"&&!Number.isInteger(n))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(!(i?Intl.DateTimeFormat:Intl.NumberFormat).supportedLocalesOf([o]).length)throw new RangeError(`Unsupported format locale: ${o}`);if(rc(a),i){let b=Um(n,r,e);return is(b,a)}let{positive:u,zero:c,negative:d}=qm(s),f=fe(n),h=f?n.eq(0):n===0,p=f?n.lt(0):n<0;if(f&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let m;if(h&&c!==null){if(c==="")return"";if(c==="-")m="-";else{let b=ns(c);m=b.prefix+new Intl.NumberFormat(o,b.intl).format(0)+b.suffix}}else{let b=p&&d?d:u,g=f?(p&&d?n.abs():n).toString():p&&d?-n:n===0?0:n;m=b.prefix+new Intl.NumberFormat(o,u.intl).format(g)+b.suffix}return is(m,a)}var Ue="http://www.w3.org/1999/xhtml",Nt="http://www.w3.org/2000/svg",Vm=new Set(["default","default_value","live","group","visible","action","fire","ask","_ask","_ask_if","_ask_title","_ask_onCancel","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","remote","_cachedRemote","_onRemote","_onCalling","onClose","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),zm=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],Hm={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},Wm=["format","mask","locale","timeZone","places","dtype"],Gm=new Set(["href","src","action","formaction","xlink:href","xlink_href"]);function It(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!Vm.has(e)&&!zm.some(r=>e.startsWith(r))))}function Fr(n,e,t=[]){for(let[r,i]of Object.entries(e)){let s=t.find(a=>r.startsWith(a))??"",o=r.slice(s.length);if(["style","class","_class"].includes(o)&&i!=null&&typeof i!="string")throw new TypeError(`${n.nodeTag} '${n.label}': '${r}' must be a string or null`)}}function Ur(n,e,t=[]){if(n.nodeTag==="script"){let r=[["",n.staticValue],...he(n.getAttr()).filter(([i])=>["src","href","xlink:href","xlink_href","_text"].includes(i.slice((t.find(s=>i.startsWith(s))??"").length).toLowerCase()))];for(let[i,s]of r)if(n.pointerType(s)||$e(s))throw new Error(`script '${n.label}': '${i}' must be literal Source; script code and URLs cannot come from Data`)}if(e.onClose!=null&&!n.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose)throw new Error("onClose is only supported on a tab/stack panel");for(let[r,i]of Object.entries(qr(It(e)))){let s=t.find(a=>r.startsWith(a)),o=s?r.slice(s.length):r;if(/^on./i.test(o))throw new Error(`${n.nodeTag} '${n.label}': '${r}' has the form of a native event handler, run by the browser outside Gramlot; write connect_${o} for an event, or rename the attribute`);if(Gm.has(o.toLowerCase())&&Xm(i))throw new Error(`${n.nodeTag} '${n.label}': '${r}' holds a javascript: URL, run by the browser as code; write connect_onclick or the action of a button instead`)}}function Xm(n){return typeof n=="string"&&/^javascript:/i.test(n.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function ic(n,e,t=[]){if(n.nodeTag!=="iframe")return e;let r=a=>{let l=t.find(u=>a.startsWith(u))??"";return[l,a.slice(l.length).toLowerCase()]},i=Object.fromEntries(he(n.getAttr())),s=[...Object.keys(i),...Object.keys(e)].find(a=>r(a)[1]==="srcdoc");if(s===void 0||Object.keys(i).some(a=>r(a)[1]==="sandbox")||n.pointerType(n.value)===null&&!(Object.hasOwn(i,s)&&(n.pointerType(i[s])!==null||$e(i[s]))))return e;let o=Object.fromEntries(Object.entries(e).filter(([a])=>r(a)[1]!=="sandbox"));return{[`${r(s)[0]}sandbox`]:"",...o}}function qr(n){return Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null))}function Ln(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>e.startsWith("xmlns_")?[`xmlns:${e.slice(6)}`,t]:e.startsWith("data_")||e.startsWith("aria_")?[e.replaceAll("_","-"),t]:[e,t]))}function ss(n){let{_meta:e,...t}=n;return Ln(qr(It(t)))}function sc(n,e){let t=Hm[String(n).toLowerCase()]??[],r={},i={};for(let[s,o]of Object.entries(e))t.includes(s)?i[s]=o:r[s]=o;return[r,i]}function jr(n){return String(n)}function Pn(n,e,t=null){let r={...e},{mask:i,format:s,locale:o,timeZone:a,dtype:l,places:u}=r;for(let d of Wm)delete r[d];let c=d=>{if(t&&s!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:s,mask:i,...o==null?{}:{locale:o},...a==null?{}:{timeZone:a},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=jr(d)),i==null)return d;let f=d==null?"":jr(d);return f===""?f:is(f,i)};return Array.isArray(n)?(Object.hasOwn(r,"_text")&&(r._text=c(r._text)),[n,r]):[c(n),r]}function $e(n){return typeof n=="string"&&n.startsWith("==")}var os=class{#e;#t;#r;#n;#i;#s;#o;#a=null;#l=!1;#u=[];#c=new Set;constructor(e,t){this.#e=e;let r=e.ownerDocument;this.#t=r.createElement("div"),this.#t.className="toolbar-viewport",this.#t.append(t),this.#n=r.createElement("button"),this.#n.type="button",this.#n.className="toolbar-more",this.#n.hidden=!0,this.#n.title="More commands";let i=r.createElementNS(Nt,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");let s=r.createElementNS(Nt,"path");s.setAttribute("d","m5 6 6 6-6 6m8-12 6 6-6 6"),s.setAttribute("fill","none"),s.setAttribute("stroke","currentColor"),s.setAttribute("stroke-width","1.8"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.append(s),this.#n.append(i),this.#n.setAttribute("aria-label","More commands"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.#r=r.createElement("div"),this.#r.className="toolbar-overflow",this.#r.setAttribute("popover","manual"),this.#r.setAttribute("role","menu"),this.#r.tabIndex=-1;let o=r.createElement("slot");o.name="overflow",this.#r.append(o),this.#n.addEventListener("click",()=>this.#l?this.close():this.open()),this.#n.addEventListener("keydown",l=>{["ArrowDown","ArrowRight"].includes(l.key)&&(l.preventDefault(),l.stopPropagation(),this.open())}),this.#r.addEventListener("keydown",l=>{l.key==="Escape"&&!l.composedPath().some(u=>u.localName==="gramlot-menu"&&u!==e)&&(l.preventDefault(),l.stopPropagation(),this.close())});let a=r.createElement("style");a.textContent=`
96
+ .caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return qr(this,e)}setPageContext(e){this.pageContext=e}releaseControl(){}get liveWrites(){return this.control.localName==="textarea"||["text","password","range","color"].includes(this.control.type)}validateCandidate(e,t){return t(e),{ok:!0,value:e,isCurrent:()=>this.pageContext.isActive()}}finishValidation(){}validateSelection(){throw new TypeError("validate_select requires a constrained choice editor.")}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>{if(t==null&&!this.constructor.gramlotComponent.parameters.value.nullable)throw new TypeError("This component requires a non-null value.");if(t!=null&&e!=null&&typeof t!=typeof e)throw new TypeError("Validation must preserve the component value type.");this.sameControlValue(e,t)||this.writeControlValue(t)})}sameControlValue(e,t){return Object.is(e,t)}focus(e){this.control.focus(e)}}}function gc(n){return class extends cs(n){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,t){let r=super.projectAttributes(e,t),{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 r}}}gc.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function bc(n){return class extends cs(n){#e=new Map;#t;#r=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 t=[...this.control.querySelectorAll("input:not(:disabled)")],r=t.indexOf(e.target);if(r<0)return;e.preventDefault();let i=e.key==="Home"?0:e.key==="End"?t.length-1:Math.max(0,Math.min(t.length-1,r+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));t[i].focus()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=this.parameters.values??"";if(i!==this.#t){let o=mc(i),a=new Set,l=null;for(let{id:u,caption:c}of o){let d=this.#e.get(u);if(!d){let h=this.ownerDocument.createElement("label");h.className="option";let m=this.ownerDocument.createElement("input");m.type=this.choiceType,m.name="choice",m.value=u;let p=this.ownerDocument.createElement("span");h.append(m,p),d={label:h,input:m,text:p},this.#e.set(u,d)}d.text.textContent=c;let f=l?l.nextSibling:this.control.firstChild;f!==d.label&&this.control.insertBefore(d.label,f),l=d.label,a.add(u)}for(let[u,c]of this.#e)a.has(u)||(c.label.remove(),this.#e.delete(u));this.#t=i}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:o}of this.#e.values())o.disabled=this.control.disabled||this.control.readOnly;return r}readControlValue(){if(this.multiple){let t=(this.#r?this.#r.split(","):[]).filter(r=>!this.#e.has(r)||this.#e.get(r).input.checked);for(let[r,{input:i}]of this.#e)i.checked&&!t.includes(r)&&t.push(r);return t.join(",")||null}for(let[e,{input:t}]of this.#e)if(t.checked)return e;return null}writeControlValue(e){this.#r=e;let t=this.multiple?new Set(e?e.split(","):[]):null;for(let[r,{input:i}]of this.#e)i.checked=this.multiple?t.has(r):r===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>this.writeControlValue(t))}focus(e){let t=[...this.#e.values()];(t.find(({input:r})=>r.checked&&!r.disabled)??t.find(({input:r})=>!r.disabled))?.input.focus(e)}}}bc.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Ur(n,e,{align:t="start",matchWidth:r=!1,inset:i=0,placement:s="bottom",point:o=null}={}){let a=e.ownerDocument.defaultView,l=o?{left:o.x,right:o.x,top:o.y,bottom:o.y,width:0}:e.getBoundingClientRect(),u=Math.max(0,a.innerWidth-16);n.style.setProperty("--gramlot-popup-available-width",`${u}px`),r&&(n.style.width=`${Math.min(Math.max(0,l.width-2*i),u)}px`),n.style.removeProperty("--gramlot-popup-available-height");let c=n.getBoundingClientRect();if(s==="side"){let g=Math.max(0,a.innerWidth-8-l.right-3),_=Math.max(0,l.left-8-3),w=c.width>g&&_>g;n.style.setProperty("--gramlot-popup-available-width",`${w?_:g}px`),n.style.setProperty("--gramlot-popup-available-height",`${Math.max(0,a.innerHeight-16)}px`);let E=n.getBoundingClientRect(),D=w?l.left-E.width-3:l.right+3;n.style.left=`${Math.max(8,Math.min(D,a.innerWidth-E.width-8))}px`,n.style.top=`${Math.max(8,Math.min(l.top,a.innerHeight-E.height-8))}px`;return}let d=Math.max(0,a.innerHeight-8-l.bottom-3),f=Math.max(0,l.top-8-3),h=c.height>d&&f>d;n.style.setProperty("--gramlot-popup-available-height",`${h?f:d}px`);let m=n.getBoundingClientRect(),p=t==="end"?l.right-m.width-i:l.left+i,b=h?l.top-m.height-3:l.bottom+3;n.style.left=`${Math.max(8,Math.min(p,a.innerWidth-m.width-8))}px`,n.style.top=`${Math.max(8,Math.min(b,a.innerHeight-m.height-8))}px`}function _c(n){if(n!=null&&(typeof n!="string"||/[{}]/.test(n.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function fs(n,e){return _c(e),e==null?n:e.replaceAll("{}",()=>n)}function ig(n){if(n instanceof Date)return kt(n);if(be(n))return"N";if(typeof n=="number")return Number.isInteger(n)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function sg(n,e,{pattern:t="short",locale:r,timeZone:i}){if(!["short","medium","long","full"].includes(t))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=t),e!=="D"&&(s.timeStyle=t),new Intl.DateTimeFormat(r,s).format(n)}function ds(n){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(n);if(!e||e[1]==="("!=(e[4]===")")||n.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${n}`);let t=e[3]??"";return{prefix:e[1]??"",suffix:e[4]??"",intl:{useGrouping:e[2].startsWith("#,##")?"always":!1,minimumIntegerDigits:e[2].replace("#,##","").length,minimumFractionDigits:t.replaceAll("#","").length,maximumFractionDigits:t.length}}}function og(n){let e=n.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=ds(e[0]);if(t.prefix||t.suffix)throw new RangeError("Positive-section affixes are not implemented");let r=e.length===3?e[1]:null;r!==null&&r!==""&&r!=="-"&&ds(r);let i=e.length>1?ds(e.at(-1)):null;return{positive:t,zero:r,negative:i}}function wc(n,e={},t={}){if(n===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 b of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(b))throw new RangeError(`Unsupported format option: ${b}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let r=e.dtype===void 0?ig(n):e.dtype,i=["D","H","DHZ"].includes(r);if(!i&&!["L","R","N"].includes(r))throw new RangeError(`Unsupported format dtype: ${r}`);if(i){if(!(n instanceof Date)||!Number.isFinite(n.getTime()))throw new TypeError(`${r} requires a valid Date object`)}else if(!(typeof n=="number"&&Number.isFinite(n))&&!(be(n)&&!["NaN","Infinity","-Infinity"].includes(n.toString())))throw new TypeError(`${r} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(r==="L"&&!Number.isInteger(n))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(!(i?Intl.DateTimeFormat:Intl.NumberFormat).supportedLocalesOf([o]).length)throw new RangeError(`Unsupported format locale: ${o}`);if(_c(a),i){let b=sg(n,r,e);return fs(b,a)}let{positive:u,zero:c,negative:d}=og(s),f=be(n),h=f?n.eq(0):n===0,m=f?n.lt(0):n<0;if(f&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let p;if(h&&c!==null){if(c==="")return"";if(c==="-")p="-";else{let b=ds(c);p=b.prefix+new Intl.NumberFormat(o,b.intl).format(0)+b.suffix}}else{let b=m&&d?d:u,g=f?(m&&d?n.abs():n).toString():m&&d?-n:n===0?0:n;p=b.prefix+new Intl.NumberFormat(o,u.intl).format(g)+b.suffix}return fs(p,a)}var we="http://www.w3.org/1999/xhtml",Bt="http://www.w3.org/2000/svg",ag=new Set(["default","default_value","live","group","visible","action","fire","ask","_ask","_ask_if","_ask_title","_ask_onCancel","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","remote","_cachedRemote","_onRemote","_onCalling","onClose","onEnd","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),lg=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],ug={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},cg=["format","mask","locale","timeZone","places","dtype"],dg=new Set(["href","src","data","action","formaction","xlink:href","xlink_href"]);function Rt(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!ag.has(e)&&!lg.some(r=>e.startsWith(r))))}function zr(n,e,t=[]){for(let[r,i]of Object.entries(e)){let s=t.find(a=>r.startsWith(a))??"",o=r.slice(s.length);if(["style","class","_class"].includes(o)&&i!=null&&typeof i!="string")throw new TypeError(`${n.nodeTag} '${n.label}': '${r}' must be a string or null`)}}function Hr(n,e,t=[]){if(n.nodeTag==="script"){let r=[["",n.staticValue],..._e(n.getAttr()).filter(([i])=>["src","href","xlink:href","xlink_href","_text"].includes(i.slice((t.find(s=>i.startsWith(s))??"").length).toLowerCase()))];for(let[i,s]of r)if(n.pointerType(s)||Fe(s))throw new Error(`script '${n.label}': '${i}' must be literal Source; script code and URLs cannot come from Data`)}if(e.onEnd!=null&&(n.nodeTag.toLowerCase()!=="transformpane"||!n._getMeta("gramlot_component")?.parameters?.onEnd))throw new Error("onEnd is only supported on transformPane");if(e.onClose!=null&&!n.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose)throw new Error("onClose is only supported on a tab/stack panel");for(let[r,i]of Object.entries(Wr(Rt(e)))){let s=t.find(a=>r.startsWith(a)),o=s?r.slice(s.length):r;if(/^on./i.test(o))throw new Error(`${n.nodeTag} '${n.label}': '${r}' has the form of a native event handler, run by the browser outside Gramlot; write connect_${o} for an event, or rename the attribute`);if(dg.has(o.toLowerCase())&&fg(i))throw new Error(`${n.nodeTag} '${n.label}': '${r}' holds a javascript: URL, run by the browser as code; write connect_onclick or the action of a button instead`)}}function fg(n){return typeof n=="string"&&/^javascript:/i.test(n.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function yc(n,e,t=[]){if(n.nodeTag!=="iframe")return e;let r=a=>{let l=t.find(u=>a.startsWith(u))??"";return[l,a.slice(l.length).toLowerCase()]},i=Object.fromEntries(_e(n.getAttr())),s=[...Object.keys(i),...Object.keys(e)].find(a=>r(a)[1]==="srcdoc");if(s===void 0||Object.keys(i).some(a=>r(a)[1]==="sandbox")||n.pointerType(n.value)===null&&!(Object.hasOwn(i,s)&&(n.pointerType(i[s])!==null||Fe(i[s]))))return e;let o=Object.fromEntries(Object.entries(e).filter(([a])=>r(a)[1]!=="sandbox"));return{[`${r(s)[0]}sandbox`]:"",...o}}function Wr(n){return Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null))}function Vn(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>e.startsWith("xmlns_")?[`xmlns:${e.slice(6)}`,t]:e.startsWith("data_")||e.startsWith("aria_")?[e.replaceAll("_","-"),t]:[e,t]))}function hs(n){let{_meta:e,...t}=n;return Vn(Wr(Rt(t)))}function vc(n,e){let t=ug[String(n).toLowerCase()]??[],r={},i={};for(let[s,o]of Object.entries(e))t.includes(s)?i[s]=o:r[s]=o;return[r,i]}function Vr(n){return String(n)}function zn(n,e,t=null){let r={...e},{mask:i,format:s,locale:o,timeZone:a,dtype:l,places:u}=r;for(let d of cg)delete r[d];let c=d=>{if(t&&s!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:s,mask:i,...o==null?{}:{locale:o},...a==null?{}:{timeZone:a},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=Vr(d)),i==null)return d;let f=d==null?"":Vr(d);return f===""?f:fs(f,i)};return Array.isArray(n)?(Object.hasOwn(r,"_text")&&(r._text=c(r._text)),[n,r]):[c(n),r]}function Fe(n){return typeof n=="string"&&n.startsWith("==")}var ps=class{#e;#t;#r;#n;#i;#s;#o;#a=null;#l=!1;#c=[];#u=new Set;constructor(e,t){this.#e=e;let r=e.ownerDocument;this.#t=r.createElement("div"),this.#t.className="toolbar-viewport",this.#t.append(t),this.#n=r.createElement("button"),this.#n.type="button",this.#n.className="toolbar-more",this.#n.hidden=!0,this.#n.title="More commands";let i=r.createElementNS(Bt,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");let s=r.createElementNS(Bt,"path");s.setAttribute("d","m5 6 6 6-6 6m8-12 6 6-6 6"),s.setAttribute("fill","none"),s.setAttribute("stroke","currentColor"),s.setAttribute("stroke-width","1.8"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.append(s),this.#n.append(i),this.#n.setAttribute("aria-label","More commands"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.#r=r.createElement("div"),this.#r.className="toolbar-overflow",this.#r.setAttribute("popover","manual"),this.#r.setAttribute("role","menu"),this.#r.tabIndex=-1;let o=r.createElement("slot");o.name="overflow",this.#r.append(o),this.#n.addEventListener("click",()=>this.#l?this.close():this.open()),this.#n.addEventListener("keydown",l=>{["ArrowDown","ArrowRight"].includes(l.key)&&(l.preventDefault(),l.stopPropagation(),this.open())}),this.#r.addEventListener("keydown",l=>{l.key==="Escape"&&!l.composedPath().some(u=>u.localName==="gramlot-menu"&&u!==e)&&(l.preventDefault(),l.stopPropagation(),this.close())});let a=r.createElement("style");a.textContent=`
40
97
  :host([role=toolbar]){min-width:0;min-height:0;max-width:100%;width:100%;flex-shrink:1;gap:0}
41
98
  :host([role=toolbar][aria-orientation=vertical]){width:auto;height:100%;max-height:100%}
42
99
  .toolbar-viewport{display:contents}
@@ -52,7 +109,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
52
109
  max-width:var(--gramlot-popup-available-width);max-height:var(--gramlot-popup-available-height);overflow:auto;
53
110
  background:var(--gramlot-field-background,Canvas);color:var(--gramlot-ink,CanvasText);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-lg,9px);box-shadow:0 8px 28px #0004}
54
111
  .toolbar-overflow ::slotted([role=separator]){margin:5px 7px;border-top:1px solid var(--gramlot-border-control,#888)}
55
- `,e.shadowRoot.append(a,this.#t,this.#n,this.#r)}get opened(){return this.#l}get button(){return this.#n}get panel(){return this.#r}contains(e){let t=e;for(;t&&t.parentElement!==this.#e;)t=t.parentElement;return this.#c.has(t)}connect(){if(!this.#e.permanent||this.#i)return;let e=this.#e.ownerDocument.defaultView;this.#s=new e.AbortController,this.#i=new e.ResizeObserver(()=>this.schedule()),this.#i.observe(this.#e),this.#e.ownerDocument.fonts.addEventListener("loadingdone",()=>this.schedule(),{signal:this.#s.signal}),this.schedule()}disconnect(){this.close(!1),this.#i?.disconnect(),this.#i=null,this.#s?.abort(),this.#a!==null&&this.#e.ownerDocument.defaultView.cancelAnimationFrame(this.#a),this.#a=null,this.#u=[]}schedule(){if(this.#e.isConnected){if(!this.#e.permanent){this.disconnect();for(let e of this.#e.children)e.removeAttribute("slot"),e.removeAttribute("data-menu-overflow");this.#c.clear(),this.#n.hidden=!0;return}this.#i||this.connect(),this.#a===null&&(this.#a=this.#e.ownerDocument.defaultView.requestAnimationFrame(()=>{this.#a=null,this.layout()}))}}layout(){let e=this.#e,t=e.ownerDocument.defaultView;if(!e.permanent||!e.isConnected)return;let r=e.parameters.orientation==="vertical",i=r?"height":"width",s=t.getComputedStyle(e),o=(r?e.clientHeight:e.clientWidth)-parseFloat(s[r?"paddingTop":"paddingLeft"]||0)-parseFloat(s[r?"paddingBottom":"paddingRight"]||0);if(o<=0)return;let a=e.ownerDocument.activeElement;for(;a?.shadowRoot?.activeElement;)a=a.shadowRoot.activeElement;let l=[...e.children].filter(g=>!g.hidden&&(g.localName!=="gramlot-menu"||g.permanent));for(let g of this.#u)l.includes(g)||(this.#i.unobserve(g),g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow"));for(let g of l)this.#u.includes(g)||this.#i.observe(g);this.#u=l;for(let g of l)g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow");this.#c.clear(),e.refreshItems();for(let g of e.items)g.refreshAvailability();let u=parseFloat(t.getComputedStyle(this.#t).gap)||0,c=new Map(l.map(g=>{let _=t.getComputedStyle(g),w=g.localName==="gramlot-spacer"?g.parameters.size??0:g.getBoundingClientRect()[i];return[g,w+(parseFloat(_[r?"marginTop":"marginLeft"])||0)+(parseFloat(_[r?"marginBottom":"marginRight"])||0)]})),d=g=>g.getAttribute("role")==="separator",f=g=>g.filter((_,w)=>!d(_)||g.slice(0,w).some(v=>v.localName!=="gramlot-spacer"&&!d(v))&&g.slice(w+1).find(v=>v.localName!=="gramlot-spacer")&&!d(g.slice(w+1).find(v=>v.localName!=="gramlot-spacer"))),h=g=>g.reduce((_,w)=>_+c.get(w),0)+Math.max(0,g.length-1)*u,p=f(l);if(h(p)>o){let g=l.map((_,w)=>({unit:_,index:w})).filter(({unit:_})=>_.localName==="gramlot-menu-line"&&!d(_)&&_.parameters.overflowable).sort((_,w)=>_.unit.parameters.priority-w.unit.parameters.priority||w.index-_.index);for(let{unit:_}of g){if(h(p)<=o-32)break;this.#c.add(_),p=f(p.filter(w=>w!==_))}}let m=f(l.filter(g=>this.#c.has(g)||d(g)&&!p.includes(g)));for(let g of m)this.#c.add(g);for(let g of l)d(g)&&!p.includes(g)&&!this.#c.has(g)&&(g.slot="suppressed");for(let g of this.#c)g.slot="overflow",g.setAttribute("data-menu-overflow","");this.#n.hidden=this.#c.size===0;for(let g of e.items)g.refreshAvailability();e.refreshItems();let b=l.find(g=>{let _=a;for(;_;){if(_===g)return!0;_=_.parentNode??_.host}return!1});this.#c.size===0?this.close(!1):b&&this.#c.has(b)?this.open(!1):this.#l&&this.#d(),b&&a?.isConnected&&a.focus({preventScroll:!0}),e.refreshItems()}#d(){Pr(this.#r,this.#n,{placement:this.#e.parameters.orientation==="vertical"?"side":"bottom"})}open(e=!0){if(this.#c.size){if(!this.#l){this.#r.showPopover(),this.#l=!0,this.#n.setAttribute("aria-expanded","true"),this.#o=new this.#e.ownerDocument.defaultView.AbortController;let t={signal:this.#o.signal};this.#e.ownerDocument.addEventListener("pointerdown",r=>{!r.composedPath().includes(this.#r)&&!r.composedPath().includes(this.#n)&&this.close(!1)},t),this.#e.ownerDocument.addEventListener("scroll",()=>this.#d(),{...t,capture:!0})}if(this.#e.refreshItems(),this.#d(),e){let t=i=>{if(i.hidden||i.disabled)return null;if(i.localName==="gramlot-menu-line"&&!i.parameters.group)return i.getAttribute("role")==="separator"?null:i;if(i.matches('input:not([type=hidden]),textarea,select,button,[tabindex="0"]'))return i;for(let s of i.children){let o=t(s);if(o)return o}return null};([...this.#e.children].filter(i=>this.#c.has(i)).map(t).find(Boolean)??this.#r).focus()}}}close(e=!0){if(this.#l){for(let t of this.#c)for(let r of t.querySelectorAll("gramlot-menu"))r.permanent||r.close(!1);this.#r.hidePopover(),this.#l=!1,this.#o?.abort(),this.#n.setAttribute("aria-expanded","false"),e&&!this.#n.hidden&&this.#n.focus()}}};function oc(n){return class extends n{#e;#t;#r=null;#n=[];#i=null;#s;#o;#a;#l;#u=!1;#c;#d;constructor(){super();let e=this.ownerDocument,t=this.attachShadow({mode:"open"}),r=e.createElement("style");r.textContent=`:host{box-sizing:border-box;color:var(--gramlot-ink,CanvasText)}
112
+ `,e.shadowRoot.append(a,this.#t,this.#n,this.#r)}get opened(){return this.#l}get button(){return this.#n}get panel(){return this.#r}contains(e){let t=e;for(;t&&t.parentElement!==this.#e;)t=t.parentElement;return this.#u.has(t)}connect(){if(!this.#e.permanent||this.#i)return;let e=this.#e.ownerDocument.defaultView;this.#s=new e.AbortController,this.#i=new e.ResizeObserver(()=>this.schedule()),this.#i.observe(this.#e),this.#e.ownerDocument.fonts.addEventListener("loadingdone",()=>this.schedule(),{signal:this.#s.signal}),this.schedule()}disconnect(){this.close(!1),this.#i?.disconnect(),this.#i=null,this.#s?.abort(),this.#a!==null&&this.#e.ownerDocument.defaultView.cancelAnimationFrame(this.#a),this.#a=null,this.#c=[]}schedule(){if(this.#e.isConnected){if(!this.#e.permanent){this.disconnect();for(let e of this.#e.children)e.removeAttribute("slot"),e.removeAttribute("data-menu-overflow");this.#u.clear(),this.#n.hidden=!0;return}this.#i||this.connect(),this.#a===null&&(this.#a=this.#e.ownerDocument.defaultView.requestAnimationFrame(()=>{this.#a=null,this.layout()}))}}layout(){let e=this.#e,t=e.ownerDocument.defaultView;if(!e.permanent||!e.isConnected)return;let r=e.parameters.orientation==="vertical",i=r?"height":"width",s=t.getComputedStyle(e),o=(r?e.clientHeight:e.clientWidth)-parseFloat(s[r?"paddingTop":"paddingLeft"]||0)-parseFloat(s[r?"paddingBottom":"paddingRight"]||0);if(o<=0)return;let a=e.ownerDocument.activeElement;for(;a?.shadowRoot?.activeElement;)a=a.shadowRoot.activeElement;let l=[...e.children].filter(g=>!g.hidden&&(fe(g).localName!=="gramlot-menu"||fe(g).permanent));for(let g of this.#c)l.includes(g)||(this.#i.unobserve(g),g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow"));for(let g of l)this.#c.includes(g)||this.#i.observe(g);this.#c=l;for(let g of l)g.removeAttribute("slot"),g.removeAttribute("data-menu-overflow");this.#u.clear(),e.refreshItems();for(let g of e.items)g.refreshAvailability();let u=parseFloat(t.getComputedStyle(this.#t).gap)||0,c=new Map(l.map(g=>{let _=t.getComputedStyle(g),w=fe(g).localName==="gramlot-spacer"?fe(g).parameters.size??0:g.getBoundingClientRect()[i];return[g,w+(parseFloat(_[r?"marginTop":"marginLeft"])||0)+(parseFloat(_[r?"marginBottom":"marginRight"])||0)]})),d=g=>fe(g).getAttribute("role")==="separator",f=g=>g.filter((_,w)=>!d(_)||g.slice(0,w).some(E=>fe(E).localName!=="gramlot-spacer"&&!d(E))&&g.slice(w+1).find(E=>fe(E).localName!=="gramlot-spacer")&&!d(g.slice(w+1).find(E=>fe(E).localName!=="gramlot-spacer"))),h=g=>g.reduce((_,w)=>_+c.get(w),0)+Math.max(0,g.length-1)*u,m=f(l);if(h(m)>o){let g=l.map((_,w)=>({unit:_,index:w})).filter(({unit:_})=>fe(_).localName==="gramlot-menu-line"&&!d(_)&&fe(_).parameters.overflowable).sort((_,w)=>fe(_.unit).parameters.priority-fe(w.unit).parameters.priority||w.index-_.index);for(let{unit:_}of g){if(h(m)<=o-32)break;this.#u.add(_),m=f(m.filter(w=>w!==_))}}let p=f(l.filter(g=>this.#u.has(g)||d(g)&&!m.includes(g)));for(let g of p)this.#u.add(g);for(let g of l)d(g)&&!m.includes(g)&&!this.#u.has(g)&&(g.slot="suppressed");for(let g of this.#u)g.slot="overflow",g.setAttribute("data-menu-overflow","");this.#n.hidden=this.#u.size===0;for(let g of e.items)g.refreshAvailability();e.refreshItems();let b=l.find(g=>{let _=a;for(;_;){if(_===g)return!0;_=_.parentNode??_.host}return!1});this.#u.size===0?this.close(!1):b&&this.#u.has(b)?this.open(!1):this.#l&&this.#d(),b&&a?.isConnected&&a.focus({preventScroll:!0}),e.refreshItems()}#d(){Ur(this.#r,this.#n,{placement:this.#e.parameters.orientation==="vertical"?"side":"bottom"})}open(e=!0){if(this.#u.size){if(!this.#l){this.#r.showPopover(),this.#l=!0,this.#n.setAttribute("aria-expanded","true"),this.#o=new this.#e.ownerDocument.defaultView.AbortController;let t={signal:this.#o.signal};this.#e.ownerDocument.addEventListener("pointerdown",r=>{!r.composedPath().includes(this.#r)&&!r.composedPath().includes(this.#n)&&this.close(!1)},t),this.#e.ownerDocument.addEventListener("scroll",()=>this.#d(),{...t,capture:!0})}if(this.#e.refreshItems(),this.#d(),e){let t=i=>{if(i.hidden||i.disabled)return null;if(i.localName==="gramlot-menu-line"&&!i.parameters.group)return i.getAttribute("role")==="separator"?null:i;if(i.matches('input:not([type=hidden]),textarea,select,button,[tabindex="0"]'))return i;for(let s of i.children){let o=t(s);if(o)return o}return null};([...this.#e.children].filter(i=>this.#u.has(i)).map(t).find(Boolean)??this.#r).focus()}}}close(e=!0){if(this.#l){for(let t of this.#u)for(let r of t.querySelectorAll("gramlot-menu"))r.permanent||r.close(!1);this.#r.hidePopover(),this.#l=!1,this.#o?.abort(),this.#n.setAttribute("aria-expanded","false"),e&&!this.#n.hidden&&this.#n.focus()}}};function Ec(n){return class extends n{#e;#t;#r=null;#n=[];#i=null;#s;#o;#a;#l;#c=!1;#u;#d;constructor(){super();let e=this.ownerDocument,t=this.attachShadow({mode:"open"}),r=e.createElement("style");r.textContent=`:host{box-sizing:border-box;color:var(--gramlot-ink,CanvasText)}
56
113
  :host([role=menu]){position:fixed;inset:auto;margin:0;padding:5px;min-width:min(16rem,var(--gramlot-popup-available-width));width:max-content;font:inherit;
57
114
  max-width:min(28rem,var(--gramlot-popup-available-width));max-height:var(--gramlot-popup-available-height);overflow:auto;
58
115
  background:var(--gramlot-field-background,Canvas);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-lg,9px);box-shadow:0 8px 28px #0004}
@@ -61,7 +118,7 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
61
118
  :host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
62
119
  :host([role=toolbar][aria-orientation=horizontal]) ::slotted([role=separator]){border-top:0;border-left:1px solid var(--gramlot-border-control,#888);align-self:stretch;margin:4px}
63
120
  :host([hidden]){display:none!important} slot{display:contents} .status{padding:.4em;opacity:.75}
64
- .status:empty{display:none} button{font:inherit}`,this.#l=e.createElement("slot"),this.#o=e.createElement("span"),this.#o.className="status",this.#o.setAttribute("role","status"),this.#a=e.createElement("button"),this.#a.textContent="Riprova",this.#a.hidden=!0,this.#a.addEventListener("click",i=>{i.stopPropagation(),this.menuBinding.load(!0)}),t.append(r,this.#l,this.#o,this.#a),this.#s=new os(this,this.#l),this.addEventListener("keydown",i=>this.#f(i)),this.addEventListener("focusin",i=>{let s=i.composedPath().find(o=>this.items.includes(o));s&&(this.#r=s,this.refreshItems())})}get permanent(){return this.parameters.presentation==="bar"}get opened(){return this.permanent||this.#u}get items(){return[...this.querySelectorAll("gramlot-menu-line")].filter(e=>e.menuOwner===this&&!e.parameters.group)}get overflow(){return this.#s}isOverflowed(e){return this.#s.contains(e)}get usableItems(){return this.items.filter(e=>e.slot!=="suppressed"&&!e.disabled&&!e.hidden&&!e.closest("[hidden]")&&e.getAttribute("role")!=="separator")}get parentMenu(){return this.parentElement?.closest("gramlot-menu")??null}connectedCallback(){this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>{this.refreshItems(),this.#s.schedule()}),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["hidden","disabled"]}),this.refreshItems(),this.#m(),this.#s.connect(),this.permanent&&this.menuBinding?.load()}disconnectedCallback(){this.#s.disconnect(),this.#t?.disconnect(),this.#e?.abort(),this.#d?.abort(),this.#c=null,this.#u=!1}projectAttributes(e){let t=Lr(this,e);if(this.#h(),!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0)throw new TypeError("menu iconSize must be positive");return this.setAttribute("role",this.permanent?"toolbar":"menu"),this.setAttribute("aria-orientation",this.permanent?this.parameters.orientation:"vertical"),this.tabIndex=-1,this.permanent?this.removeAttribute("popover"):this.setAttribute("popover","manual"),this.refreshItems(),this.#s.schedule(),t}#h(){let e=this.parameters.modifiers;if(e==null)return null;if(e==="*")return[];let t=e.trim().toLowerCase().split(/[,\s]+/);if(!t.length||t.some(r=>!["shift","ctrl","alt","meta"].includes(r))||new Set(t).size!==t.length)throw new TypeError("Menu modifiers require *, or a combination of Shift, Ctrl, Alt and Meta");return t}#m(){let e=this.parentElement;if(this.permanent||!e)return;if(["gramlot-menu-line","gramlot-drop-down-button"].includes(e.localName)){this.slot="menu";return}if(this.removeAttribute("slot"),e.localName==="gramlot-menu")return;this.#c=e,this.#d=new this.ownerDocument.defaultView.AbortController;let t={signal:this.#d.signal},r=s=>!s.composedPath().some(o=>o.localName==="gramlot-menu"),i=s=>{if(this.hidden||this.permanent||!r(s)||s.composedPath().some(u=>u instanceof this.ownerDocument.defaultView.Element&&(u.disabled===!0||u.getAttribute("aria-disabled")==="true")))return;let o=this.#h();if(s.type==="click"){if(o===null||s.button!==0||["shift","ctrl","alt","meta"].some(u=>!!s[u+"Key"]!==o.includes(u)))return}else if(o!==null)return;s.preventDefault(),s.stopPropagation();let a=s.type==="keydown",l=a?e.getBoundingClientRect():null;this.open(e,!1,a?{x:l.left+8,y:l.top+8}:{x:s.clientX,y:s.clientY})};e.addEventListener("click",i,t),e.addEventListener("contextmenu",i,t),e.addEventListener("keydown",s=>{(s.key==="ContextMenu"||s.key==="F10"&&s.shiftKey&&!s.ctrlKey&&!s.altKey&&!s.metaKey)&&i(s)},t)}setStatus(e){this.status=e,this.#o.textContent={loading:"Caricamento\u2026",empty:"Nessuna voce",error:"Impossibile caricare"}[e]??"",this.#a.hidden=e!=="error",this.setAttribute("aria-busy",String(e==="loading"));for(let t of this.items)t.refreshAvailability();this.refreshItems()}refreshItems(){for(let r of this.querySelectorAll("gramlot-menu-line"))r.menuOwner===this&&r.parameters.group&&r.refreshAvailability();for(let r of this.items)r.refreshAvailability();let e=this.usableItems;if(this.#r&&!e.includes(this.#r)){let r=this.#n.indexOf(this.#r),i=this.#n.slice(r+1).find(s=>e.includes(s))??this.#n.slice(0,r).reverse().find(s=>e.includes(s));this.#r=i??null,this.opened&&this.status!=="loading"&&(i?i.focus():this.permanent?this.focus():this.close())}let t=e.filter(r=>!this.isOverflowed(r));for(let r of this.items)r.control.tabIndex=this.permanent&&r===(t.includes(this.#r)?this.#r:t[0])?0:-1;this.#n=this.items}open(e,t=!1,r=null){if(this.permanent)return;this.#i=e,this.#u||(this.showPopover(),this.#u=!0),e.setAttribute("aria-expanded","true"),this.#e?.abort(),this.#e=new this.ownerDocument.defaultView.AbortController;let i={signal:this.#e.signal},s=()=>Pr(this,e,{point:r,placement:this.parentMenu&&(!this.parentMenu.permanent||this.parentMenu.parameters.orientation==="vertical"||this.parentMenu.isOverflowed(this.parentElement))?"side":"bottom"});s(),this.ownerDocument.defaultView.addEventListener("resize",s,i),this.ownerDocument.addEventListener("scroll",s,{...i,capture:!0}),this.ownerDocument.addEventListener("pointerdown",o=>{!o.composedPath().includes(this)&&(e===this.#c||!o.composedPath().includes(e))&&this.closeChain(!1)},i),this.menuBinding?.load().then(()=>{this.#u&&(this.ownerDocument.activeElement===this||!this.contains(this.ownerDocument.activeElement))&&this.focusEntry(t),this.#u&&s()}),this.focusEntry(t)}focusEntry(e=!1){let t=this.usableItems,r=t[e?t.length-1:0];r?(this.#r=r,r.focus()):this.focus()}close(e=!0){for(let t of this.querySelectorAll("gramlot-menu"))t.permanent||t.close(!1);if(this.permanent){this.#s.close(e);return}this.#u&&(this.hidePopover(),this.#u=!1,this.#e?.abort(),this.#i?.setAttribute("aria-expanded","false"),e&&this.#i?.isConnected&&this.#i.focus())}closeChain(e=!0){let t=this.parentMenu;this.close(e&&!t),t&&!t.permanent?t.closeChain(e):t?.isOverflowed(this.parentElement)?t.overflow.close(e):e&&this.#i?.isConnected&&this.#i.focus()}#f(e){if(e.defaultPrevented||e.composedPath().find(u=>u.localName==="gramlot-menu")!==this)return;let t=e.composedPath().find(u=>this.items.includes(u));if(!t&&e.target!==this)return;let r=t&&this.isOverflowed(t),i=this.usableItems.filter(u=>this.isOverflowed(u)===!!r),s=i.indexOf(t),o=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowRight":"ArrowDown",a=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowLeft":"ArrowUp",l;if(e.key===o&&(l=Math.min(i.length-1,s+1)),e.key===a&&(l=Math.max(0,s-1)),e.key==="Home"&&(l=0),e.key==="End"&&(l=i.length-1),l!==void 0){e.preventDefault(),e.stopPropagation(),i[l]?.focus();return}(!this.permanent||r)&&e.key==="ArrowRight"&&t?.submenu?(e.preventDefault(),e.stopPropagation(),t.openSubmenu()):e.key==="Escape"&&(!this.permanent||this.overflow.opened||this.items.some(u=>u.submenu?.opened))||!this.permanent&&e.key==="ArrowLeft"&&this.parentMenu?(e.preventDefault(),e.stopPropagation(),this.close()):e.key==="Tab"&&this.closeChain(!1)}}}function ac(n){return class extends n{#e;#t;#r;#n;#i;#s;#o=null;#a=!1;constructor(){super();let e=this.ownerDocument;this.#r=e.createElement("span"),this.#n=e.createElement("span"),this.#r.className="menu-caption",this.#n.className="menu-check",this.#i=e.createElement("span"),this.#i.className="menu-arrow",this.#i.setAttribute("aria-hidden","true"),this.#n.setAttribute("aria-hidden","true"),this.control.prepend(this.#n),this.control.append(this.#r,this.#i);let t=e.createElement("style");t.textContent=`:host{color:var(--gramlot-ink,CanvasText)} .control-box{color:inherit;height:100%} :host button{color:inherit}
121
+ .status:empty{display:none} button{font:inherit}`,this.#l=e.createElement("slot"),this.#o=e.createElement("span"),this.#o.className="status",this.#o.setAttribute("role","status"),this.#a=e.createElement("button"),this.#a.textContent="Riprova",this.#a.hidden=!0,this.#a.addEventListener("click",i=>{i.stopPropagation(),this.menuBinding.load(!0)}),t.append(r,this.#l,this.#o,this.#a),this.#s=new ps(this,this.#l),this.addEventListener("keydown",i=>this.#h(i)),this.addEventListener("focusin",i=>{let s=i.composedPath().find(o=>this.items.includes(o));s&&(this.#r=s,this.refreshItems())})}get permanent(){return this.parameters.presentation==="bar"}get opened(){return this.permanent||this.#c}get items(){return[...this.querySelectorAll("gramlot-menu-line")].filter(e=>e.menuOwner===this&&!e.parameters.group)}get overflow(){return this.#s}isOverflowed(e){return this.#s.contains(e)}get usableItems(){return this.items.filter(e=>Fr(e).slot!=="suppressed"&&!e.disabled&&!e.hidden&&!e.closest("[hidden]")&&e.getAttribute("role")!=="separator")}get parentMenu(){return this.parentElement?.closest("gramlot-menu")??null}connectedCallback(){this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>{this.refreshItems(),this.#s.schedule()}),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["hidden","disabled"]}),this.refreshItems(),this.#p(),this.#s.connect(),this.permanent&&this.menuBinding?.load()}disconnectedCallback(){this.#s.disconnect(),this.#t?.disconnect(),this.#e?.abort(),this.#d?.abort(),this.#u=null,this.#c=!1}projectAttributes(e){let t=qr(this,e);if(this.#f(),!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0)throw new TypeError("menu iconSize must be positive");return this.setAttribute("role",this.permanent?"toolbar":"menu"),this.setAttribute("aria-orientation",this.permanent?this.parameters.orientation:"vertical"),this.tabIndex=-1,this.permanent?this.removeAttribute("popover"):this.setAttribute("popover","manual"),this.refreshItems(),this.#s.schedule(),t}#f(){let e=this.parameters.modifiers;if(e==null)return null;if(e==="*")return[];let t=e.trim().toLowerCase().split(/[,\s]+/);if(!t.length||t.some(r=>!["shift","ctrl","alt","meta"].includes(r))||new Set(t).size!==t.length)throw new TypeError("Menu modifiers require *, or a combination of Shift, Ctrl, Alt and Meta");return t}#p(){let e=Fr(this).parentElement;if(this.permanent||!e)return;if(["gramlot-menu-line","gramlot-drop-down-button"].includes(e.localName)){Fr(this).slot="menu";return}if(Fr(this).removeAttribute("slot"),e.localName==="gramlot-menu")return;this.#u=e,this.#d=new this.ownerDocument.defaultView.AbortController;let t={signal:this.#d.signal},r=s=>!s.composedPath().some(o=>o.localName==="gramlot-menu"),i=s=>{if(this.hidden||this.permanent||!r(s)||s.composedPath().some(u=>u instanceof this.ownerDocument.defaultView.Element&&(u.disabled===!0||u.getAttribute("aria-disabled")==="true")))return;let o=this.#f();if(s.type==="click"){if(o===null||s.button!==0||["shift","ctrl","alt","meta"].some(u=>!!s[u+"Key"]!==o.includes(u)))return}else if(o!==null)return;s.preventDefault(),s.stopPropagation();let a=s.type==="keydown",l=a?e.getBoundingClientRect():null;this.open(e,!1,a?{x:l.left+8,y:l.top+8}:{x:s.clientX,y:s.clientY})};e.addEventListener("click",i,t),e.addEventListener("contextmenu",i,t),e.addEventListener("keydown",s=>{(s.key==="ContextMenu"||s.key==="F10"&&s.shiftKey&&!s.ctrlKey&&!s.altKey&&!s.metaKey)&&i(s)},t)}setStatus(e){this.status=e,this.#o.textContent={loading:"Caricamento\u2026",empty:"Nessuna voce",error:"Impossibile caricare"}[e]??"",this.#a.hidden=e!=="error",this.setAttribute("aria-busy",String(e==="loading"));for(let t of this.items)t.refreshAvailability();this.refreshItems()}refreshItems(){for(let r of this.querySelectorAll("gramlot-menu-line"))r.menuOwner===this&&r.parameters.group&&r.refreshAvailability();for(let r of this.items)r.refreshAvailability();let e=this.usableItems;if(this.#r&&!e.includes(this.#r)){let r=this.#n.indexOf(this.#r),i=this.#n.slice(r+1).find(s=>e.includes(s))??this.#n.slice(0,r).reverse().find(s=>e.includes(s));this.#r=i??null,this.opened&&this.status!=="loading"&&(i?i.focus():this.permanent?this.focus():this.close())}let t=e.filter(r=>!this.isOverflowed(r));for(let r of this.items)r.control.tabIndex=this.permanent&&r===(t.includes(this.#r)?this.#r:t[0])?0:-1;this.#n=this.items}open(e,t=!1,r=null){if(this.permanent)return;this.#i=e,this.#c||(this.showPopover(),this.#c=!0),e.setAttribute("aria-expanded","true"),this.#e?.abort(),this.#e=new this.ownerDocument.defaultView.AbortController;let i={signal:this.#e.signal},s=()=>Ur(this,e,{point:r,placement:this.parentMenu&&(!this.parentMenu.permanent||this.parentMenu.parameters.orientation==="vertical"||this.parentMenu.isOverflowed(this.parentElement))?"side":"bottom"});s(),this.ownerDocument.defaultView.addEventListener("resize",s,i),this.ownerDocument.addEventListener("scroll",s,{...i,capture:!0}),this.ownerDocument.addEventListener("pointerdown",o=>{!o.composedPath().includes(this)&&(e===this.#u||!o.composedPath().includes(e))&&this.closeChain(!1)},i),this.menuBinding?.load().then(()=>{this.#c&&(this.ownerDocument.activeElement===this||!this.contains(this.ownerDocument.activeElement))&&this.focusEntry(t),this.#c&&s()}),this.focusEntry(t)}focusEntry(e=!1){let t=this.usableItems,r=t[e?t.length-1:0];r?(this.#r=r,r.focus()):this.focus()}close(e=!0){for(let t of this.querySelectorAll("gramlot-menu"))t.permanent||t.close(!1);if(this.permanent){this.#s.close(e);return}this.#c&&(this.hidePopover(),this.#c=!1,this.#e?.abort(),this.#i?.setAttribute("aria-expanded","false"),e&&this.#i?.isConnected&&this.#i.focus())}closeChain(e=!0){let t=this.parentMenu;this.close(e&&!t),t&&!t.permanent?t.closeChain(e):t?.isOverflowed(this.parentElement)?t.overflow.close(e):e&&this.#i?.isConnected&&this.#i.focus()}#h(e){if(e.defaultPrevented||e.composedPath().find(u=>u.localName==="gramlot-menu")!==this)return;let t=e.composedPath().find(u=>this.items.includes(u));if(!t&&e.target!==this)return;let r=t&&this.isOverflowed(t),i=this.usableItems.filter(u=>this.isOverflowed(u)===!!r),s=i.indexOf(t),o=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowRight":"ArrowDown",a=this.permanent&&!r&&this.parameters.orientation==="horizontal"?"ArrowLeft":"ArrowUp",l;if(e.key===o&&(l=Math.min(i.length-1,s+1)),e.key===a&&(l=Math.max(0,s-1)),e.key==="Home"&&(l=0),e.key==="End"&&(l=i.length-1),l!==void 0){e.preventDefault(),e.stopPropagation(),i[l]?.focus();return}(!this.permanent||r)&&e.key==="ArrowRight"&&t?.submenu?(e.preventDefault(),e.stopPropagation(),t.openSubmenu()):e.key==="Escape"&&(!this.permanent||this.overflow.opened||this.items.some(u=>u.submenu?.opened))||!this.permanent&&e.key==="ArrowLeft"&&this.parentMenu?(e.preventDefault(),e.stopPropagation(),this.close()):e.key==="Tab"&&this.closeChain(!1)}}}function xc(n){return class extends n{#e;#t;#r;#n;#i;#s;#o=null;#a=!1;constructor(){super();let e=this.ownerDocument;this.#r=e.createElement("span"),this.#n=e.createElement("span"),this.#r.className="menu-caption",this.#n.className="menu-check",this.#i=e.createElement("span"),this.#i.className="menu-arrow",this.#i.setAttribute("aria-hidden","true"),this.#n.setAttribute("aria-hidden","true"),this.control.prepend(this.#n),this.control.append(this.#r,this.#i);let t=e.createElement("style");t.textContent=`:host{color:var(--gramlot-ink,CanvasText)} .control-box{color:inherit;height:100%} :host button{color:inherit}
65
122
  .menu-check:empty,.menu-arrow:empty{display:none}
66
123
  button.menu-row{display:grid;grid-template-columns:1em 1.15em minmax(0,1fr) .7em;column-gap:.5em;
67
124
  align-items:center;width:100%;min-height:max(min(var(--gramlot-field-height,28px),28px),var(--gramlot-touch-target,0px));padding:var(--gramlot-button-padding,3px 8px);
@@ -97,13 +154,17 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
97
154
  :host([data-menu-overflow]) .menu-group,:host([data-menu-group-rows]) .menu-group{flex-direction:column;align-items:stretch;padding:3px 0}
98
155
  :host([data-menu-overflow][role=group]){border-block-end:1px solid var(--gramlot-border-control,#888);margin-block-end:4px}
99
156
  :host([role=group][aria-disabled=true]) .menu-group{opacity:.45;pointer-events:none}
100
- :host([hidden]){display:none!important}`,this.caption.name="command-caption",this.#t=e.createElement("div"),this.#t.className="menu-group",this.#t.append(e.createElement("slot")),this.#t.hidden=!0,this.shadowRoot.append(t,this.#t);let r=e.createElement("slot");r.name="menu",this.shadowRoot.append(r),this.addEventListener("pointerenter",()=>{this.menuOwner&&(!this.menuOwner.permanent||this.menuOwner.isOverflowed(this))&&!this.disabled&&(clearTimeout(this.#s),this.#s=setTimeout(()=>{if(!(!this.isConnected||this.disabled||!this.menuOwner.opened))if(this.control.focus({preventScroll:!0}),this.submenu)this.openSubmenu();else for(let i of this.menuOwner.items)i.submenu?.close(!1)},180))}),this.addEventListener("pointerleave",()=>clearTimeout(this.#s))}get menuOwner(){return this.parentElement?.closest("gramlot-menu")??null}get submenu(){return[...this.children].find(e=>e.localName==="gramlot-menu")??null}get entryCaption(){return this.parameters.caption??this.#o?.label??""}get entryIcon(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.icon:this.#o?.icon}get entryIconSrc(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.iconSrc:this.#o?.iconSrc}get occurrence(){return this.parameters.code??this.sourceLabel}setCommandDefinition(e,t){this.#o=e,this.sourceLabel=t,this.#l()}projectAttributes(e,t){let r=super.projectAttributes(e,t);if(this.#e=e["aria-label"],this.parameters.iconSize!=null&&(!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0))throw new TypeError("menuline iconSize must be positive");if(!Number.isFinite(this.parameters.priority))throw new TypeError("menuline priority must be finite");return this.#a=!!this.parameters.disabled,this.#l(),this.menuOwner?.overflow.schedule(),r}#l(){let e=[...this.childNodes].filter(r=>r.nodeType===3).map(r=>r.textContent).join("").trim()==="-"&&!this.parameters.command;this.setAttribute("role",this.parameters.group?"group":e?"separator":this.parameters.checked==null?"menuitem":"menuitemcheckbox"),this.#t.hidden=!this.parameters.group,this.setAttribute("aria-disabled",String(this.#a)),this.parameters.checked!=null?(this.setAttribute("aria-checked",String(this.parameters.checked)),this.control.setAttribute("aria-checked",String(this.parameters.checked))):(this.removeAttribute("aria-checked"),this.control.removeAttribute("aria-checked")),this.#n.textContent=this.parameters.checked?"\u2713":"",this.#r.textContent=this.parameters.command&&!this.#o?"???":this.entryCaption,this.caption.hidden=!0,this.renderIcon(this.entryIcon,this.entryIconSrc);let t=this.parameters.tooltip??this.#o?.tooltip??this.entryCaption;this.control.title=t,this.control.setAttribute("aria-label",this.#e??(this.entryCaption||t)),this.submenu?this.control.setAttribute("aria-haspopup","menu"):this.control.removeAttribute("aria-haspopup"),this.refreshAvailability()}refreshAvailability(){let e=this.menuOwner,t=e&&(!e.permanent||e.isOverflowed(this)),r=a=>{for(let l=this;l&&l!==e;l=l.parentElement)if(l.localName==="gramlot-menu-line"&&l.parameters[a]!=null)return l.parameters[a];return e?.parameters[a]},i=!!(e?.permanent&&!t),s=r("labelPosition");this.control.classList.toggle("toolbar-button",i),this.control.classList.toggle("toolbar-below",i&&s==="below"),this.control.classList.toggle("toolbar-tooltip",i&&s==="tooltip"),i?this.control.style.setProperty("--gramlot-toolbar-icon-size",`${r("iconSize")}px`):this.control.style.removeProperty("--gramlot-toolbar-icon-size"),this.toggleAttribute("data-menu-group-rows",!!(t||e?.parameters.orientation==="vertical")),this.control.classList.toggle("menu-row",t),this.#i.textContent=this.submenu?t||e?.parameters.orientation==="vertical"?"\u203A":"\u25BE":"";let o=this.#a||this.getAttribute("role")==="separator"||!!(this.parameters.command&&!this.#o)||["loading","error"].includes(e?.status)||!!this.closest("gramlot-drop-down-button")?.parameters.disabled;this.control.disabled!==o&&(this.control.disabled=o)}get disabled(){for(let e=this.parentElement;e&&e!==this.menuOwner;e=e.parentElement)if(e.localName==="gramlot-menu-line"&&e.parameters.disabled)return!0;return this.control.disabled||!!this.closest("gramlot-drop-down-button")?.parameters.disabled}set disabled(e){this.control.disabled=!!e}attachCommand(){this.#l()}releaseCommand(){clearTimeout(this.#s),this.submenu?.close(!1)}openSubmenu(){if(!(this.disabled||!this.submenu)){for(let e of this.menuOwner.items)e!==this&&e.submenu?.close(!1);this.submenu.open(this.control)}}prepareCommand(e){if(this.parameters.group||this.disabled||this.hidden)return!1;if(this.submenu)return e.stopPropagation(),this.submenu.opened?this.submenu.close():this.openSubmenu(),!1;let t=this.menuOwner?.parentElement;return t?.localName==="gramlot-drop-down-button"?t.selectCommand(this,e.shiftKey):this.menuOwner.closeChain(),!0}}}function jn(n){return class extends rs(n){constructor(){super();let e=this.ownerDocument;this.control=e.createElement("button"),this.control.type="button",this.control.id="control",this.icon=e.createElement("span"),this.icon.className="icon",this.icon.setAttribute("aria-hidden","true"),this.caption=e.createElement("slot"),this.control.append(this.icon,this.caption),this.controlBox.append(this.control);let t=e.createElement("style");t.textContent=`:host{vertical-align:middle} .control-box{display:flex;align-items:stretch}
157
+ :host([hidden]){display:none!important}`,this.caption.name="command-caption",this.#t=e.createElement("div"),this.#t.className="menu-group",this.#t.append(e.createElement("slot")),this.#t.hidden=!0,this.shadowRoot.append(t,this.#t);let r=e.createElement("slot");r.name="menu",this.shadowRoot.append(r),this.addEventListener("pointerenter",()=>{this.menuOwner&&(!this.menuOwner.permanent||this.menuOwner.isOverflowed(this))&&!this.disabled&&(clearTimeout(this.#s),this.#s=setTimeout(()=>{if(!(!this.isConnected||this.disabled||!this.menuOwner.opened))if(this.control.focus({preventScroll:!0}),this.submenu)this.openSubmenu();else for(let i of this.menuOwner.items)i.submenu?.close(!1)},180))}),this.addEventListener("pointerleave",()=>clearTimeout(this.#s))}get menuOwner(){return this.parentElement?.closest("gramlot-menu")??null}get submenu(){return[...this.children].map(fe).find(e=>e.localName==="gramlot-menu")??null}get entryCaption(){return this.parameters.caption??this.#o?.label??""}get entryIcon(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.icon:this.#o?.icon}get entryIconSrc(){return this.parameters.icon||this.parameters.iconSrc?this.parameters.iconSrc:this.#o?.iconSrc}get occurrence(){return this.parameters.code??this.sourceLabel}setCommandDefinition(e,t){this.#o=e,this.sourceLabel=t,this.#l()}projectAttributes(e,t){let r=super.projectAttributes(e,t);if(this.#e=e["aria-label"],this.parameters.iconSize!=null&&(!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0))throw new TypeError("menuline iconSize must be positive");if(!Number.isFinite(this.parameters.priority))throw new TypeError("menuline priority must be finite");return this.#a=!!this.parameters.disabled,this.#l(),this.menuOwner?.overflow.schedule(),r}#l(){let e=[...this.childNodes].filter(r=>r.nodeType===3).map(r=>r.textContent).join("").trim()==="-"&&!this.parameters.command;this.setAttribute("role",this.parameters.group?"group":e?"separator":this.parameters.checked==null?"menuitem":"menuitemcheckbox"),this.#t.hidden=!this.parameters.group,this.setAttribute("aria-disabled",String(this.#a)),this.parameters.checked!=null?(this.setAttribute("aria-checked",String(this.parameters.checked)),this.control.setAttribute("aria-checked",String(this.parameters.checked))):(this.removeAttribute("aria-checked"),this.control.removeAttribute("aria-checked")),this.#n.textContent=this.parameters.checked?"\u2713":"",this.#r.textContent=this.parameters.command&&!this.#o?"???":this.entryCaption,this.caption.hidden=!0,this.renderIcon(this.entryIcon,this.entryIconSrc);let t=this.parameters.tooltip??this.#o?.tooltip??this.entryCaption;this.control.title=t,this.control.setAttribute("aria-label",this.#e??(this.entryCaption||t)),this.submenu?this.control.setAttribute("aria-haspopup","menu"):this.control.removeAttribute("aria-haspopup"),this.refreshAvailability()}refreshAvailability(){let e=this.menuOwner,t=e&&(!e.permanent||e.isOverflowed(this)),r=a=>{for(let l=this;l&&l!==e;l=l.parentElement)if(l.localName==="gramlot-menu-line"&&l.parameters[a]!=null)return l.parameters[a];return e?.parameters[a]},i=!!(e?.permanent&&!t),s=r("labelPosition");this.control.classList.toggle("toolbar-button",i),this.control.classList.toggle("toolbar-below",i&&s==="below"),this.control.classList.toggle("toolbar-tooltip",i&&s==="tooltip"),i?this.control.style.setProperty("--gramlot-toolbar-icon-size",`${r("iconSize")}px`):this.control.style.removeProperty("--gramlot-toolbar-icon-size"),this.toggleAttribute("data-menu-group-rows",!!(t||e?.parameters.orientation==="vertical")),this.control.classList.toggle("menu-row",t),this.#i.textContent=this.submenu?t||e?.parameters.orientation==="vertical"?"\u203A":"\u25BE":"";let o=this.#a||this.getAttribute("role")==="separator"||!!(this.parameters.command&&!this.#o)||["loading","error"].includes(e?.status)||!!this.closest("gramlot-drop-down-button")?.parameters.disabled;this.control.disabled!==o&&(this.control.disabled=o)}get disabled(){for(let e=this.parentElement;e&&e!==this.menuOwner;e=e.parentElement)if(e.localName==="gramlot-menu-line"&&e.parameters.disabled)return!0;return this.control.disabled||!!this.closest("gramlot-drop-down-button")?.parameters.disabled}set disabled(e){this.control.disabled=!!e}attachCommand(){this.#l()}releaseCommand(){clearTimeout(this.#s),this.submenu?.close(!1)}openSubmenu(){if(!(this.disabled||!this.submenu)){for(let e of this.menuOwner.items)e!==this&&e.submenu?.close(!1);this.submenu.open(this.control)}}prepareCommand(e){if(this.parameters.group||this.disabled||this.hidden)return!1;if(this.submenu)return e.stopPropagation(),this.submenu.opened?this.submenu.close():this.openSubmenu(),!1;let t=Fr(this.menuOwner)?.parentElement;return t?.localName==="gramlot-drop-down-button"?t.selectCommand(this,e.shiftKey):this.menuOwner.closeChain(),!0}}}function Hn(n){return class extends cs(n){constructor(){super();let e=this.ownerDocument;this.control=e.createElement("button"),this.control.type="button",this.control.id="control",this.icon=e.createElement("span"),this.icon.className="icon",this.icon.setAttribute("aria-hidden","true"),this.caption=e.createElement("slot"),this.control.append(this.icon,this.caption),this.controlBox.append(this.control);let t=e.createElement("style");t.textContent=`:host{vertical-align:middle} .control-box{display:flex;align-items:stretch}
101
158
  button{display:inline-flex;align-items:center;justify-content:center;gap:var(--gramlot-button-gap,.35em);font:inherit;
102
- color:var(--gramlot-ink,CanvasText);background:var(--gramlot-button-background,var(--gramlot-field-background,Canvas));
159
+ color:var(--gramlot-button-color,var(--gramlot-ink,CanvasText));background:var(--gramlot-button-background,var(--gramlot-field-background,Canvas));
103
160
  border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,4px);
104
161
  min-height:max(var(--gramlot-field-height,28px),var(--gramlot-touch-target,0px));
105
162
  padding:var(--gramlot-button-padding,.25em .65em);cursor:pointer}
106
163
  button:hover:not(:disabled){background:var(--gramlot-button-hover,var(--gramlot-field-readonly-background,#eee))}
164
+ :host(.button--secondary) button{background:var(--gramlot-selected,Highlight);color:var(--gramlot-action,CanvasText);border-color:transparent}
165
+ :host(.button--secondary) button:hover:not(:disabled){background:var(--gramlot-selected,Highlight);color:var(--gramlot-action-hover,CanvasText);border-color:var(--gramlot-action,CanvasText)}
166
+ button:active:not(:disabled){filter:brightness(.9)}
167
+ @media(prefers-contrast:more){button{border:2px solid currentColor}}
107
168
  :host(.button--quiet) button{background:transparent;color:var(--gramlot-action,CanvasText);border-color:transparent}
108
169
  :host(.button--quiet) button:hover:not(:disabled){background:var(--gramlot-selected,Highlight);color:var(--gramlot-action-hover,CanvasText);border-color:transparent}
109
170
  button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:2px}
@@ -118,36 +179,30 @@ ${" ".repeat(i)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
118
179
  color:var(--gramlot-ink,CanvasText);background:var(--gramlot-field-background,Canvas);box-shadow:0 3px 12px #0003}
119
180
  :host(:is([role=menuitem],[role=menuitemcheckbox])){display:block} :host(:is([role=menuitem],[role=menuitemcheckbox])) button{width:100%;justify-content:start;border:0;background:transparent}
120
181
  :host([role=separator]){display:block;border-top:1px solid var(--gramlot-border-control,#888);margin:.25em}
121
- :host([role=separator]) button{display:none}`,this.shadowRoot.append(t)}get disabled(){return this.control.disabled}set disabled(e){this.control.disabled=!!e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly,this.renderIcon(this.parameters.icon,this.parameters.iconSrc),e["aria-label"]!=null?this.control.setAttribute("aria-label",e["aria-label"]):this.control.removeAttribute("aria-label"),r}renderIcon(e,t){if(!t){this.icon.textContent=e??"";return}let r=this.icon.firstElementChild;r||(r=this.ownerDocument.createElement("img"),r.alt="",r.draggable=!1,this.icon.replaceChildren(r)),r.getAttribute("src")!==t&&r.setAttribute("src",t)}get entryIcon(){return this.parameters.icon}get entryIconSrc(){return this.parameters.iconSrc}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}jn.parameters={disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"},iconSrc:{dtype:"T",default:"",binding:"read"}};var Ym=Ct({name:"button",tag:"gramlot-button",base:jn,command:!0,subTags:"*",implementation:n=>class extends n{}}),Zm=Ct({name:"toggleButton",tag:"gramlot-toggle-button",base:jn,command:!0,subTags:"*",parameters:{value:{dtype:"B",default:!1,binding:"twoWay"},readonly:{dtype:"B",default:!1,binding:"read"}},implementation:n=>class extends n{#e=!1;constructor(){super();let e=this.ownerDocument.createElement("span");e.className="led",e.setAttribute("aria-hidden","true"),this.control.prepend(e),this.writeControlValue(!1)}get commitOnChange(){return!0}readControlValue(){return this.#e}writeControlValue(e){this.#e=e,this.control.setAttribute("aria-pressed",String(e))}prepareCommand(e){return!super.prepareCommand(e)||this.control.readOnly?!1:(this.writeControlValue(!this.#e),this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change")),!0)}}}),Jm=Ct({name:"menu",tag:"gramlot-menu",base:oc,subTags:"menuline,spacer,contentPane",parameters:{presentation:{dtype:"T",default:"popup",enum:["popup","bar"]},orientation:{dtype:"T",default:"horizontal",enum:["horizontal","vertical"]},modifiers:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",default:"beside",enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",default:24},resolver:{dtype:"T",nullable:!0},cacheTime:{dtype:"R",default:-1},sync:{dtype:"B",default:!1}},implementation:n=>class extends n{}}),Km=Ct({name:"menuline",tag:"gramlot-menu-line",base:jn,command:!0,subTags:"*",parameters:{command:{dtype:"T",nullable:!0},caption:{dtype:"T",nullable:!0},code:{dtype:"T",nullable:!0},checked:{dtype:"B",nullable:!0,binding:"read"},tooltip:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",nullable:!0,enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",nullable:!0},group:{dtype:"B",default:!1},priority:{dtype:"R",default:0},overflowable:{dtype:"B",default:!0},parameters:{annotation:{kind:"type",module:"builtins",name:"dict"},nullable:!0},favorite:{dtype:"B",default:!1}},implementation:ac}),Qm=Ct({name:"spacer",tag:"gramlot-spacer",base:n=>class extends n{projectAttributes(e){let t=Lr(this,e),{size:r,flex:i}=this.parameters;if(r!=null&&i!=null)throw new TypeError("spacer accepts size or flex, not both");if(r!=null&&(!Number.isFinite(r)||r<0)||i!=null&&(!Number.isFinite(i)||i<=0))throw new TypeError("Invalid spacer size/flex");return this.style.flex=i!=null?`${i} 1 0px`:`0 0 ${r??0}px`,this.setAttribute("aria-hidden","true"),t}},parameters:{size:{dtype:"R",nullable:!0},flex:{dtype:"R",nullable:!0}},implementation:n=>class extends n{}}),eg=Ct({name:"dropDownButton",tag:"gramlot-drop-down-button",base:jn,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:n=>class extends n{#e=null;#t;#r=null;#n;#i;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#i=e.createElement("span"),this.#i.hidden=!0,this.control.append(this.#i),this.#n=e.createElement("button"),this.#n.type="button",this.#n.className="arrow",this.#n.textContent="\u25BE",this.#n.setAttribute("aria-label","Open menu"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.controlBox.append(this.#n);let t=e.createElement("slot");t.name="menu",this.shadowRoot.append(t),this.#n.addEventListener("click",r=>{r.stopPropagation(),this.menu.opened?this.closeMenu():this.openMenu()}),this.#n.addEventListener("keydown",r=>{["ArrowDown","ArrowUp"].includes(r.key)&&(r.preventDefault(),this.openMenu(r.key==="ArrowUp"))})}get menu(){return[...this.children].find(e=>e.localName==="gramlot-menu")}get menuItems(){return this.menu?.items??[]}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#n.disabled=this.disabled,this.disabled&&this.menu?.close(!1),this.#s(),r}attachCommand(){if(this.parameters.persist){if(!this.id)throw new TypeError("dropDownButton persist requires an explicit id");this.#r=`gramlot:command:${this.ownerDocument.location.pathname}${this.ownerDocument.location.search}:${this.id}`;try{this.#e=this.ownerDocument.defaultView.localStorage.getItem(this.#r)}catch{}}this.#s(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#s()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.menu?.close(!1)}commandTarget(e){return e?.composedPath().includes(this.menu)?null:this.menuItems.find(t=>t.occurrence===this.#e)??this}selectCommand(e,t){if(t){if(this.#e=e.occurrence,this.#r)try{this.ownerDocument.defaultView.localStorage.setItem(this.#r,this.#e)}catch{}this.#s()}this.closeMenu()}#s(){let e=this.menuItems.map(i=>i.occurrence).filter(Boolean);if(new Set(e).size!==e.length)throw new TypeError("Dropdown menu codes must be unique");let t=this.commandTarget(),r=t!==this;this.caption.hidden=r,this.#i.hidden=!r,this.#i.textContent=r?t.entryCaption:"",this.renderIcon(t.entryIcon,t.entryIconSrc)}openMenu(e=!1){this.disabled||this.menu?.open(this.#n,e)}closeMenu(){this.menu?.close()}}}),as=Go({name:"buttons",components:[Ym,Zm,eg,Jm,Km,Qm]});function tg(n,e,t=n){let r=new Map,i=new Set,s=new Map;for(let[a,l]of e){if(typeof a!="string")continue;let u=z(l)?.pointer??l;s.set(a,u instanceof J?u.resolve():n.pointerType(u)?t.getRelativeData(u):$e(u)?null:u)}let o=a=>{if(r.has(a))return r.get(a);if(!e.has(a))throw new Error(`Source attribute '${a}' does not exist`);if(i.has(a))throw new Error(`cyclic attribute dependency: ${[...i,a].join(" -> ")}`);i.add(a);let l=e.get(a),u=z(l),c=u?s.get(a):null,d,f=h=>h?o(h):c;try{if(u)if(u.expression){let h=Jr(u.body),p=h.slots.map(f);d=n.rootBuilder.evaluatePointerExpression(n,a,l,h,p)}else d=$t(u.body,f),c==null&&(d=null);else d=s.get(a);return r.set(a,d),d}finally{i.delete(a)}};return{resolve:o}}function Ot(n,e,t=n){let r=new Map([...Object.entries(n.getAttr()),...he(n.getAttr())]);return tg(n,r,t).resolve(e)}var rg={dataFormula:["formula","_if","_else","_ask_if","_ask_onCancel"],dataController:["script","_if","_else","_ask_if","_ask_onCancel"],dataRpc:["_ask_if","_ask_onCancel","_if","_else","_onCalling","_onResult","_onError"],dataRemote:["_if","_else","_onCalling"]},Xo=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],ng=["_if","_else","_onRemote","_onCalling"],Yo=class{#e;#t=null;#r=null;#n=!1;constructor(e){this.#e=e}get inflight(){return this.#t?.view??null}get pending(){let e=this.#r;return e?Object.freeze({method:e.method,get params(){return P(e.text)}}):null}calling(e){if(!e)return!0;let t=!1,r=this.#n;this.#n=!0;try{t=e()!==!1}finally{this.#n=r,!t&&!this.#t&&this.#i()}return t}submit(e,t,r){try{let i=U(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((s,o)=>{this.#r={method:e,text:i,perform:r,resolve:s,reject:o}}):(this.#r?.resolve(void 0),this.#r=null,this.#s(e,t,i,r))}catch(i){return Promise.reject(i)}}submitSync(e,t){if(this.#t)throw new Error("A synchronous call cannot start while a request of the node is in flight");if(!this.#e.matches(e))throw new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`);return t()}#i(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#s(e.method,P(e.text),e.text,e.perform)}catch(r){t=Promise.reject(r)}t.then(e.resolve,e.reject)}#s(e,t,r,i){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let s=new AbortController,o={method:e,params:t,text:r,controller:s,ignored:!1};o.view=Object.freeze({method:e,get params(){return P(r)},sentAt:Date.now(),cancel:()=>this.#a(o)}),this.#t=o,s.signal.addEventListener("abort",()=>this.#o(o),{once:!0});let a;try{a=Promise.resolve(i(o))}catch(l){a=Promise.reject(l)}return a.then(()=>this.#o(o),()=>this.#o(o)),a}#o(e){this.#t===e&&(this.#t=null,this.#i())}#a(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#n||this.#i())}};function lc(n){return typeof n=="string"&&n.startsWith("==")}var er=class extends we{get frame(){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("frame accessor requires a window");let e=this.value instanceof A?this.value.getNodes():[];if(e.length){if(e.length!==1||e[0].nodeTag!=="framePane")throw new TypeError("A window requires exactly one framePane");return this.builder.wrapSource(e[0])}return this.builder.wrapSource(this.builder.commandOnNode(this,"framePane",null,{node_label:"frame"}))}requestClose(e="application"){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("requestClose requires a window");return this.rootBuilder.binding.gramlot.dom.getDomNode(this).requestClose(e)}get top(){return this.frameRegion("top")}get bottom(){return this.frameRegion("bottom")}get left(){return this.frameRegion("left")}get right(){return this.frameRegion("right")}get center(){return this.frameRegion("center")}frameRegion(e){if(this.nodeTag!=="framePane")throw new TypeError("Region accessors require framePane");let t=this.value instanceof A?this.value.getNodes().find(i=>i.getAttr("region")===e):null;if(t)return this.builder.wrapSource(t);let r={region:e,node_label:e};return e!=="center"&&Object.assign(r,{display:"flex",flex_direction:["top","bottom"].includes(e)?"column":"row"}),this.builder.wrapSource(this.builder.commandOnNode(this,"contentPane",null,r))}#e=new Set;#t=null;#r=null;get requests(){return this.#r??=new Yo(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...rg[this.nodeTag]??[],...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters??{}).filter(([,r])=>r.inline).map(([r])=>r),...this._getMeta("gramlot_component")?.command?["action","_ask_if"]:[],...typeof this.getAttr("remote")=="string"?ng:[]],t=[];for(let[r,i]of Object.entries(this.getAttr()??{}))typeof i=="string"&&(e.includes(r)||r==="validate_call"||r==="validate__onResult"||r==="validate_onAccept"||r==="validate_onReject"||/^validate_\w+_if$/.test(r)||r.startsWith("connect_on")||r.startsWith("subscribe_")||r.startsWith("selfsubscribe_"))&&t.push([r,i]);for(let r of["ask","_ask"]){let i=this.getAttr(r);if(i&&typeof i=="object")for(let s of["_if","askIf"])typeof i[s]=="string"&&t.push([`${r}.${s}`,i[s]])}for(let[r,i]of he(this.getAttr()))if(lc(i)&&t.push([r,i]),this.nodeTag==="script"&&typeof i=="string"){let s=this.builder.constructor.dialectPrefixes.find(o=>r.startsWith(o))??"";["src","href","xlink:href","xlink_href","_text"].includes(r.slice(s.length).toLowerCase())&&t.push([r,i])}return(lc(this.staticValue)||this.nodeTag==="script"&&typeof this.staticValue=="string")&&t.push(["",this.staticValue]),t}activateCode(){let e=new Map;for(let[t,r]of this.codeAttributes()){if(this.pointerType(r))throw new Error(`${this.nodeTag} '${this.label}': '${t}' is inline code and cannot be the pointer '${r}'; inline code is never read from Data`);e.set(t,r)}for(let[t,r]of[...he(this.getAttr()),["datapath",this.getAttr("datapath")]])z(r)?.expression&&e.set(t,r);this.#t=e}activatedCode(e){return this.#t?.get(e)??null}remote(e,t={}){let r=this.rootBuilder.nameSyntax;if(typeof e!="string"||!(this.pointerType(e)||r.matches(e)))throw new TypeError(`${this.nodeTag} '${this.label}': remote name must be a pointer or match ${r.pattern}, not ${JSON.stringify(e)}`);let i=Object.keys(t).find(o=>o.startsWith("_")&&!Xo.includes(o));if(i)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${i}' is not accepted; the control attributes are ${Xo.join(", ")}`);let s={remote:e};for(let[o,a]of Object.entries(t))s[Xo.includes(o)?o:`remote_${o}`]=a;return this.setAttr(s),In(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=z(e)?ze(this,e):new Set,r=super.pointers().filter(([i,s])=>!(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(i))&&!t.has(i)&&!this.#s(i,s)).map(([i,s])=>[i,z(s)?.pointer??s]);for(let i of t){let s=this.getAttr(i);this.pointerType(s)==="^"&&r.push(["datapath",z(s)?.pointer??s])}return r}runtimeToEvaluate(){let e=super.runtimeToEvaluate();for(let[t,r]of e){if(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(t)){e.set(t,new xt(()=>r));continue}if(this.pointerType(r)){if(z(r)){if(typeof t!="string")throw new Error(`${this.nodeTag} '${this.label}': pointer suffixes belong to attributes; use format/mask for node text`);this.absDatapath(r)===null&&e.set(t,new xt(()=>Ot(this,t)));continue}this.#s(t,r)?e.set(t,r.slice(1)):this.absDatapath(r)===null&&e.set(t,null)}}return e}pathAttribute(e){let t=this.getAttr(e);return z(t)?Ot(this,e):this.pointerType(t)&&this.#s(e,t)?t.slice(1):t}getRelativeData(e,t=null,r={}){return this.absDatapath(e)===null?null:super.getRelativeData(e,t,r)}setRelativeData(e,t,r={}){this.#o(e),super.setRelativeData(e,t,r)}PUT(e,t){this.#o(e),this.data.setItem(this.absDatapath(e),t,null,">",!1,!0,this,!1,!1)}FIRE(e,t=!0,r=null){t===null&&(t=!0),this.#o(e);let i=this.absDatapath(e);if(i.includes("?")){this.#n(i,t);return}this.data.getNode(i)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:r})}finally{this.data.getNode(i)?.setValue(null,!1)}}#n(e,t){let[r,i]=e.split("?",2),s=this.data;s.getNode(r)?.setAttr({[i]:null},!1);try{let o=s.getNode(r);o?o.setValue(o.staticValue,!0,{[i]:t},!0,!0,!0,!0):s.setItem(r,null,{[i]:t},">",!0,!0,!0,!0)}finally{s.getNode(r)?.setAttr({[i]:null},!1)}}FIRE_AFTER(e,t=!0,r=10){this.#o(e);let i=this.rootBuilder?.binding?.bindingFor(this)??null,s=null,o=setTimeout(()=>{s?.(),this.FIRE(e,t)},r);return s=i?.track(()=>clearTimeout(o))??null,()=>{clearTimeout(o),s?.()}}absDatapath(e){e=z(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[r,i]=t.split("?",2),s=super.absDatapath(r);return s===null?null:`${s}?${i}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");if(this.pointerType(i)&&(i=this.#i(r,i),i===null))return null;if(i!=null&&(e=e==="."?i:i+e),e.startsWith("#"))return r.parentNode._resolveSymbolicDatapath(e,t);r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_finalizeAbsPath(e,t){return e===null?null:super._finalizeAbsPath(e,t)}_resolveSymbolicDatapath(e,t){let r=e.slice(1).split(".",1)[0];if(r==="FORM"||r==="ANCHOR")return super._resolveSymbolicDatapath(e,t);let i=this.rootBuilder?.binding;if(!i)return super._resolveSymbolicDatapath(e,t);let s=i.nodeIds.get(r);if(!s)throw new Error(`#<id>: cannot resolve ${t}`);let o=e.slice(r.length+2);return s.absDatapath(o?`.${o}`:".")}#i(e,t){if(z(t)){let s=Ot(e,"datapath",e.parentNode);return s==null||s===""?null:s}let r=e.parentNode.absDatapath(t);if(r===null)return null;let i=this.data.getItem(r);return i==null||i===""?null:i}#s(e,t){return z(t)||typeof e!="string"||!e.endsWith("_path")?!1:(this.#e.has(e)||(this.#e.add(e),console.warn(`${this.nodeTag} '${this.label}': '${e}' holds a bare Data path; the pointer symbol of '${t}' is removed`)),!0)}#o(e){if(this.absDatapath(e)===null)throw new Error(`${this.nodeTag} '${this.label}': write on a null path: '${e}'`)}},le=class n extends A{get nodeClass(){return er}authorizedCopy(e){let t=new this.constructor;for(let r of this.getNodes()){let i=r.getAttr("auth")??null;if(i!==null){if(typeof i!="string")throw new TypeError(`${r.nodeTag} '${r.label}': 'auth' must be a string rule, not ${typeof i}`);if(e(i)!==null)continue}let s=r.staticValue;s instanceof n&&(s=s.authorizedCopy(e));let{auth:o,...a}=r.getAttr(),l=t.setItem(r.label,s,a,">",!1,!1,null,!1,!0,null,r.nodeTag);l.xmlTag=r.xmlTag}return t}activateCode(){for(let e of this.getNodes())e.activateCode(),e.staticValue instanceof n&&e.staticValue.activateCode();return this}};if((Re(le.tytxSuffix).GramlotBuilderBag??le)!==le)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");zt(le.tytxSuffix,{...Re(le.tytxSuffix),GramlotBuilderBag:le});var ig=new Set(["animate","animateMotion","animateTransform","circle","ellipse","feBlend","feColorMatrix","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feGaussianBlur","feImage","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","image","line","metadata","path","polygon","polyline","rect","set","stop","use"]),Fn=class extends Kt{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let r=this.owner.evaluateExpressions(e,t);Ur(e,r);let[i,s]=super._handleMeta(e,r);return Fr(e,s),e._getMeta("subbuilder")?[i,ts(ss(s))]:[i,s]}adaptAttrs(e){let{_meta:t,...r}=e;return Ln(super.adaptAttrs(qr(It(r))))}renderedItem(e,t,r,i={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,r,i);let{_text:s,...o}=r;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&s!=null&&(t=[this._escapeText(jr(s)),...t]),ig.has(i.tag)?`${i.pretty?" ".repeat(this._nodeDepth(e,i.depthOffset??0)):""}<${i.tag}${this._formatAttrs(o)} />${i.pretty?`
122
- `:""}`:super.renderedItem(e,t,o,i)}};var tr=class extends Jt{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof Tt?this.addRender(e,this):e instanceof Dt&&this.addRender(e,new Fn(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[r,i]=e.rootBuilder.runtimeValues(e),s=this.getRender(e.builder),[o,a]=s._handleMeta(e,i);return e._getMeta("subbuilder")||(a=s.adaptAttrs(a)),s.renderedItem(e,e.value instanceof A?this.renderChildren(e.value,t):r,a,{tag:o,...t})}_handleMeta(e,t){let r=this.builder.constructor.dialectPrefixes,i=this.evaluateExpressions(e,t);Ur(e,i,r);let[s,o]=super._handleMeta(e,ic(e,i,r));if(Fr(e,o,r),e.nodeTag==="webcomponent"){s=at(e.getAttr());let{code:u,...c}=o;o=c}if(e._getMeta("subbuilder")){let u=ss(o);return e._getMeta("subbuilder")==="html"&&(u.xmlns=Nt),[s,u]}let[a,l]=sc(s,o);return Object.keys(l).length&&this.#e.set(e,l),[s,a]}evaluateExpressions(e,t){let r=this.inlineCompiler,i=(o,a)=>r?r.compileExpression(e,o,a)(t):null,s={...t};for(let[o,a]of he(e.getAttr()))e.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(o)||$e(a)&&Object.hasOwn(s,o)&&(s[o]=i(o,a));return $e(e.value)&&this.#t.set(e,i("",e.value)),s}expressionValue(e,t){return $e(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let r=this.#e.get(e);return r?(this.#e.delete(e),{...t,...qr(r)}):t}adaptAttrs(e){let{_meta:t,...r}=e,i=`${this.builder.constructor._name}_`,s=this.builder.constructor.dialectPrefixes,o={},a={};for(let[l,u]of Object.entries(It(r))){if(u==null)continue;if(l.startsWith(i))throw new Error(`${l}: the attribute prefix '${i}' is not accepted; use the prefix '${s[0]}'`);let c=s.find(d=>l.startsWith(d));c?o[l.slice(c.length)]=u:a[l]=u}return Ln({...super.adaptAttrs(a),...o})}renderedItem(e,t,r,i={}){let s;[t,s]=Pn(this.expressionValue(e,t),this.restoreNativeAttributes(e,r));let{_text:o,...a}=s;Array.isArray(t)&&o!=null&&(t=[this._escapeText(jr(o)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:Ue,...a}:a;return super.renderedItem(e,t,l,i)}finalize(e,t=null,r={}){if(!r.doctype)return super.finalize(e,t,r);let i=this._composeStringFragments(e),s=this.builder.source.getNodes().filter(o=>!o._getMeta("data_element"));return s.length===1&&s[0].nodeTag==="html"||(i=`<html>${i}</html>`),super.finalize(`<!doctype html>${i}`,t,r)}};var uc={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"binding",version:null,title:"Gramlot binding",description:"Gramlot Data declarations and the plain HTML button; loaded after the HTML grammar."},abstracts:{},elements:{dataSetter:{doc:"Initial Data value, written literally at destination_path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!0,default:null},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:"Computed Data value written at result_path; formula is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"formula",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:"Side effects on Data; script is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"script",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRpc:{doc:"Server endpoint called through gramlot.rpc; the value is written at result_path when given.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"timeout",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRemote:{doc:"Data node resolved by a server endpoint through gramlot.rpc, on first read and again when cacheTime expires; with sync (default) the read waits for the answer when the transport supports it.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"cacheTime",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"sync",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"bool"},has_default:!0,default:!0},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},html_button:{doc:"Plain native HTML button without Gramlot click mechanisms.",sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{render_tag:"button"}},html_dialog:{doc:"Native HTML dialog, distinct from the layout window component.",sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{render_tag:"dialog"}}}};var cc={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"webcomponent",version:null,title:"Gramlot webcomponent",description:"An explicitly loaded autonomous custom element."},abstracts:{},elements:{webcomponent:{doc:"Create the custom-element tag named by literal code.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"code",kind:"keyword_only",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null}}};function Te(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("")}var ag="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",lg=new Set,ug=new Set(["serverpath","dbenv","shared_id"]),cg=["formsubscribe_"],dg={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},fg={dataFormula:"formula",dataController:"script"};function dc(n,e){if(["input","textarea","select","webcomponent"].includes(n)&&z(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(n==="html_button"&&Object.keys(e).some(i=>["action","ask","_delay","fire"].includes(i)||i.startsWith("fire_")))return"plain HTML button: use button for action, ask, fire or _delay";if(Object.hasOwn(e,"ask")&&!["button","toggleButton","dropDownButton","menuline"].includes(n))return"'ask' is supported on buttons";if(Object.hasOwn(e,"_ask")&&!["dataController","dataFormula","dataRpc"].includes(n))return"'_ask' requires a controller, formula or RPC";if(["dataSetter","dataRemote"].includes(n)&&Object.keys(e).some(i=>i.startsWith("subscribe_")||i.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=dg[n];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let r=fg[n];return r&&e[r]!=null&&e.func!=null?`'func' and '${r}' cannot be declared on the same node`:r&&e._if!=null&&e.func!=null?"'_if' is inline and cannot be declared with 'func': write the condition in the method":null}function fc(n){return Object.keys(n).find(e=>ug.has(e)||cg.some(t=>e.startsWith(t)))}var qe=class n extends Tt{static _name="gramlot";static _sourceClass=le;static{this.defineGrammar(uc)}static{this.defineGrammar(cc)}static{this.defineGrammar(as.toDocument())}static get dialectPrefixes(){let e=[];for(let t=Object.getPrototypeOf(n);t&&t!==Function.prototype;t=Object.getPrototypeOf(t))Object.hasOwn(t,"_name")&&t._name&&e.push(`${t._name}_`);return e}constructor(e=null,{collections:t=[],auth:r=null,nameSyntax:i=Mn}={}){if(!(i instanceof Qt))throw new TypeError(`nameSyntax must be a NameSyntax, not ${i}`);super(e),this._binding=null,this._auth=r,this._nameSyntax=i;for(let s of t)this.loadCollection(s)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,r,i,s){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,r,i.text)(s):null}nodeById(e){if(!this.binding)return super.nodeById(e);let t=this.binding.nodeIds.get(e);if(!t)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}loadCollection(e){return this.loadGrammar(e instanceof St?e.toDocument():e),this}schemaTag(e){let t=e.toLowerCase(),r=n.dialectPrefixes;if(t.startsWith(`${n._name}_`))throw new Error(`${e}: the tag prefix '${n._name}_' is not accepted; use the prefix '${r[0]}'`);if(lg.has(t))throw new Error(`${e}: excluded from Gramlot`);let i=this.schemaTagNames[t];if(i)return i;for(let s of r)if(t.startsWith(s)&&this.schemaTagNames[t.slice(s.length)])return t;return null}bagCall(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.bagCall(e,t,r,i)}commandOnNode(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.commandOnNode(e,t,r,i)}menuArguments(e,t,r={}){if(e==="menu"&&t==null)return[new le(null,this),r];if(e==="menuline"&&t!=null&&t!=="-"){if(Object.hasOwn(r,"command"))throw new TypeError("menuline command must be declared once");return[null,{...r,command:t}]}return[t,r]}validateNodeValues(e,t,r={}){if(this.schema[e]?._meta?.gramlot_component&&z(r.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&at(r);let i=fc(r);if(i)throw new Error(`${e}: attribute '${i}' is excluded from Gramlot`);let s=dc(e,r);if(s)throw new Error(`${e}: ${s}`);return super.validateNodeValues(e,t,r)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&z((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&at(t.attrs??e.getAttr());let r=fc(t.attrs??e.getAttr());if(r)throw new Error(`${e.nodeTag} '${e.label}': attribute '${r}' is excluded from Gramlot`);let i=dc(e.nodeTag,t.attrs??e.getAttr());if(i)throw new Error(`${e.nodeTag} '${e.label}': ${i}`);return super.validateNode(e,t)}_validateChildren(e,t,r,i){return super._validateChildren(e,t,r.map(s=>s==="html_button"?"button":s==="html_dialog"?"dialog":s),i)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,r,i,s=null){i=Object.fromEntries(Object.entries(i??{}).map(([l,u])=>[l,Y(u)instanceof we?this.reference(u):u]));let a=t==="dataSetter"&&i?.value!==null&&typeof i?.value=="object"&&Object.getPrototypeOf(i.value)===Object.prototype?{...i,value:new D(i.value)}:i;return super.setChild(e,t,r,a,s)}#e(e){if(e==="data")throw new Error(ag);if(this.schemaTagNames[e.toLowerCase()]===e)return e;let t=n.dialectPrefixes.find(r=>e.startsWith(r));return this.schemaTagNames[e.slice(t.length)]}get renderer_html(){return new tr(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,r){let i=t!=null?{_text:t}:null;e.setValue(r,!0,i,!0)}reference(e,t="node"){if(e=Y(e),!(e instanceof we)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let r=e.getAttr("__ref");return r==null&&(r=Te(),e.setAttr({__ref:r})),{$gramlotRef:r,kind:t}}toTytx(){return U(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function Un(n){return typeof n=="string"&&!["null","true","false"].includes(n)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(n)}function rr(n,e,t,r){let{group:i,method:s}=n.logicRegistry.resolve(t,e);return s.call(i,e,r)}function Qe(n,e,t,r,i,s=Object.keys(i)){return Un(r)?rr(n,e,r,i):n.inlineCompiler.compile(e,t,r,s)(i)}var hg=new Set(["input","select","textarea"]),pg=["type","multiple","group"];function hc(n,e){let t=n.getAttr(e);return n.pointerType(t)?n.getRelativeData(t):t}var be=class n{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#n;#i=!1;#s=!1;#o=!1;static for(e,t){let r=n.classFor(t.element,t.attrs);return r?new r(e,t):null}static classFor(e,t){if(e.namespaceURI!==Ue)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?ea:Zo;if(e.localName==="textarea")return et;if(e.localName==="select")return qn;if(e.localName!=="input")return null;let r=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(pc,r)?pc[r]:et}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([t.group??null]):e?.namespaceURI!==Ue||!hg.has(e.localName)?null:JSON.stringify(pg.map(r=>t[r]??null))}constructor(e,t){this.#r=e,this.#n=t}get binding(){return this.#r}get element(){return this.#n.element}get node(){return this.binding.node}get eventElement(){return this.element}get resolved(){return this.#n.resolved}get live(){return!!this.resolved.live}get writeEvent(){return this.constructor.liveWrites&&this.live?"input":"change"}project(e,t){if(this.#s){this.#o=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)||(this.#e=e,this.#t=!0,!(this.#i&&this.same(this.read(),e))&&(this.constructor.writesDefault&&!this.node.pointerType(this.node.getAttr("value"))&&this.writeDefault(e),this.write(e)))}read(){return this.element.value}write(e){let t=e==null?"":String(e);this.element.value!==t&&(this.element.value=t)}writeDefault(e){let t=e==null?"":String(e);this.element.localName==="textarea"?this.#n.text.data!==t&&(this.#n.text.data=t):this.element.defaultValue!==t&&(this.element.defaultValue=t)}same(e,t){return Object.is(e,t)}commit(e,t=this.read()){if(!this.binding.closed){this.#i=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#i=!1}}}attach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.addEventListener(e,this)}detach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.removeEventListener(e,this);this.#o=!1}refresh(){}handleEvent(e){if(!this.binding.closed){if(e.type==="compositionstart"){this.#s=!0;return}if(e.type==="compositionend"){this.#s=!1,this.writeEvent==="input"&&this.commit(e),this.#o&&(this.#o=!1,this.binding.runtime.renderer.project(this.node));return}this.#s||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},Zo=class extends be{static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.element.setPageContext(mc(this)),super.attach()}project(e,t){this.element.shouldProjectControlValue(e)&&super.project(e,t)}same(e,t){return this.element.sameControlValue(e,t)}detach(){this.element.releaseControl(),super.detach()}commit(e){this.binding.closed||this.element.control.disabled||this.element.control.readOnly||gc(this.element,this.element.acceptControlValue(),t=>super.commit(e,t.value))}get writeEvent(){return this.element.commitOnChange?"change":(this.resolved.live??this.element.parameters.live)&&this.element.liveWrites?"input":"change"}read(){return this.element.readControlValue()}write(e){this.element.writeControlValue(e)}handleEvent(e){if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.element.ownerDocument.defaultView.Event;this.element.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}},et=class extends be{static liveWrites=!0},Jo=class extends be{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},Ko=class extends be{static liveWrites=!0;read(){return Number(this.element.value)}},qn=class extends be{static writesDefault=!1;read(){return this.element.multiple?[...this.element.selectedOptions].map(e=>e.value):this.element.selectedIndex===-1?null:this.element.value}write(e){let t=this.element;if(t.multiple){if(e!=null&&!Array.isArray(e))throw new TypeError(`${this.node.nodeTag} '${this.node.label}': a multiple select requires an array`);let r=new Set((e??[]).map(String));for(let i of t.options){let s=r.has(i.value);i.selected!==s&&(i.selected=s)}}else e==null?t.selectedIndex!==-1&&(t.selectedIndex=-1):(t.selectedIndex===-1||t.value!==String(e))&&(t.value=String(e))}same(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&t.every((r,i)=>Object.is(r,e[i])):super.same(e,t)}},nr=class extends be{read(){return this.element.value===""?null:this.element.value}},Qo=class extends be{},ls=class extends be{static writesDefault=!1;read(){return this.element.checked}write(e){let t=!!e;this.element.checked!==t&&(this.element.checked=t)}same(e,t){return e===!!t}attach(){let e=this.node;if(e.getAttr("checked")!=null&&e.pointerType(e.getAttr("value"))==="^")throw new TypeError(`${e.nodeTag} '${e.label}': checked and a ^ value are two sources`);super.attach()}},us=class extends ls{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,r=ta(e);if(t!=null){if(e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);this.#r(t,r)}super.attach(),t!=null&&(this.#e=this.groups.join(this,t,r),this.element.setAttribute("name",this.#e))}detach(){this.#e!==null&&(this.groups.leave(this),this.element.removeAttribute("name"),this.#e=null),super.detach()}refresh(){if(this.#e===null)return;let e=this.resolved.group,t=ta(this.node);this.groups.nameOf(e,t)!==this.#e&&(this.#r(e,t),this.groups.leave(this),this.#e=this.groups.join(this,e,t),this.element.setAttribute("name",this.#e))}#r(e,t){let r=this.node;if(hc(r,"value")&&this.groups.peersOf(e,t).some(i=>!i.binding.closed&&i.read()))throw new Error(`${r.nodeTag} '${r.label}': several true values in radio group '${e}'`)}project(e,t){let r=!this.#t;this.#t=!0;let i=this.read();super.project(e,t),!r&&!i&&this.read()&&this.turnOffPeers()}commit(e){let t=this.read();super.commit(e),t&&!this.binding.closed&&this.turnOffPeers()}turnOffPeers(){if(this.#e!==null)for(let e of this.groups.peers(this)){if(this.binding.closed)return;e.binding.closed||(e.element.checked&&(e.element.checked=!1),hc(e.node,"value")&&e.commit(null))}}},ea=class extends us{static writesDefault=!1;get host(){return super.element}get element(){return this.host.control}project(e,t){this.host.shouldProjectControlValue(e)&&super.project(e,t)}commit(e){this.binding.closed||this.element.disabled||this.element.readOnly||gc(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(mc(this)),super.attach(),this.element.addEventListener("keydown",this)}detach(){this.host.releaseControl(),this.element.removeEventListener("keydown",this),super.detach()}handleEvent(e){if(!this.binding.closed){if(e.type==="keydown"){if(this.resolved.group==null||!["ArrowLeft","ArrowUp","ArrowRight","ArrowDown"].includes(e.key))return;let t=this.groups.peersOf(this.resolved.group,ta(this.node)).filter(o=>!o.binding.closed&&!o.element.disabled),r=t.indexOf(this);if(r<0)return;e.preventDefault();let i=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,s=t[(r+i+t.length)%t.length];s.element.focus(),s.element.click();return}if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.host.ownerDocument.defaultView.Event;this.host.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}}},cs=class{#e;#t=new Map;#r=new Map;#n=new WeakMap;#i=0;constructor(e){this.#e=e}join(e,t,r){let i=this.nameOf(t,r);return this.#t.has(i)||this.#t.set(i,new Set),this.#t.get(i).add(e),this.#r.set(e,i),i}leave(e){let t=this.#r.get(e);this.#r.delete(e);let r=this.#t.get(t);r?.delete(e),r?.size===0&&this.#t.delete(t)}peers(e){let t=this.#r.get(e);return[...this.#t.get(t)??[]].filter(r=>r!==e)}peersOf(e,t){return[...this.#t.get(this.nameOf(e,t))??[]]}nameOf(e,t){t!==null&&!this.#n.has(t)&&this.#n.set(t,this.#i++);let r=t===null?"page":`form${this.#n.get(t)}`;return`gramlot-${this.#e.instanceId}-${r}-${e}`}};function ta(n){for(let e=n;e;e=e.parentNode){let t=e.getAttr()??{};if(t.formId!=null||t.form===!0)return e}return null}var pc={text:et,password:et,email:et,url:et,tel:et,search:et,number:Jo,range:Ko,color:Qo,date:nr,time:nr,month:nr,week:nr,"datetime-local":nr,checkbox:ls,radio:us,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function mc(n){let{binding:e,node:t}=n,r=e.runtime.gramlot,i=(s,o,a,l=!1)=>l?e.runtime.inlineCompiler.compile(t,s,o,Object.keys(a),`return (${o});`)(a):Qe(e.runtime,t,s,o,a);return{locale:r.locale,timeZone:r.timeZone,createDecimal:Et,isDecimal:fe,getDecimalLibrary:Ro,publish:(s,o)=>t.publish(s,o),isActive:()=>!e.closed,callLogic:(s,o)=>rr(e.runtime,t,s,o),format:(s,o)=>r.format(s,o),invoke:i,remote:(s,o,a)=>r.rpc.call("data",s,o,{signal:a}),selectionOutputs:({selectedCaption:s,selectedRecord:o,fields:a},l)=>{if(!e.closed){s&&t.setRelativeData(s,l?.caption??null),o&&t.setRelativeData(o,l?new D(l.record):null);for(let[u,c]of Object.entries(a))t.setRelativeData(c,l?.record[u.slice(9)]??null)}},validationCurrent:()=>{let s=t.getAttr("value"),o=t.pointerType(s)?t.absDatapath(s):null;return()=>!e.closed&&t.getAttr("value")===s&&(o===null||t.absDatapath(s)===o)},finishValidation:({ok:s,result:o,rules:a})=>{if(e.closed)return;if(s)for(let u of o.datachanges)t.getRelativeData(".").update(u);let l=s?"validate_onAccept":"validate_onReject";if(a[l]){let u=c=>console.error("Validation notification failed:",c);try{let c=Object.fromEntries(Object.entries(a).map(([f,h])=>[f.slice(9),h])),d=i(l,a[l],{value:o.value,result:o,validations:c,userChange:!0});d instanceof Promise&&d.catch(u)}catch(c){u(c)}}},checkDataPatch:s=>{if(!(s instanceof D))throw new TypeError("Validation data changes must be a Bag.");if(!(t.getRelativeData(".")instanceof D))throw new TypeError("Validation data changes require a Bag datapath.")}}}function gc(n,e,t){let r=i=>{i.ok&&i.isCurrent()&&(t(i),n.finishValidation(i))};e instanceof Promise?e.then(r).catch(i=>console.error("Validation notification failed:",i)):r(e)}var ra=Symbol("source text"),bc={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},mg=new Set(["allowFullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formNoValidate","hidden","inert","isMap","itemscope","loop","multiple","muted","noModule","noValidate","open","playsInline","readOnly","required","reversed","selected"]),gg=new Set(["checked","muted","selected","value"]),bg=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function _g(n){let e=n.replace(/-([a-z])/g,(t,r)=>r.toUpperCase());return bg.get(e.toLowerCase())??e}var ds=class{constructor({metadataAttributes:e=[],invokeScript:t=null,callLogic:r=null}={}){this.invokeScript=t,this.callLogic=r,this.metadataAttributes=new Set([...Ht,"_text",...e])}definition(e){let t=e.builder,i={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},s=e.nodeTag==="webcomponent"?at(e.getAttr()):Nn(e.nodeTag,{renderTag:i.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),o=s==="foreignObject"?Nt:i.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof Dt?Nt:Ue);return{meta:i,namespace:o,tag:s}}validate(e,t=e.builder){let r=e.value instanceof A,i=r?e.getAttr("_text"):e.value;if(i!=null&&!["string","number","boolean"].includes(typeof i))throw new TypeError("HTML text must be scalar");for(let[a,l]of Object.entries(e.attr))if(!(a==="value"&&this.definition(e).meta.gramlot_component)&&!(e.nodeTag==="menuline"&&a==="parameters")&&!(this.metadataAttributes.has(a)||["ask","_ask"].includes(a)||l&&typeof l=="object"&&Object.hasOwn(l,"$gramlotRef"))&&l!=null&&!["string","number","boolean"].includes(typeof l))throw new TypeError(`HTML attribute ${a} must be scalar`);let s=Object.fromEntries(Object.entries(e.attr).filter(([a])=>!this.metadataAttributes.has(a))),o=r?e.value.getNodes().map(a=>a.nodeTag).filter(Boolean):[];t.validateNode(e,{value:i,attrs:s,childTags:o})}create(e,t,r=null,i=e.attr,s=null){let{tag:o,namespace:a,meta:l}=this.definition(e);r??=o;let u=a===Ue?t.createElement(r):t.createElementNS(a,r);if(l.gramlot_component&&u.constructor.gramlotComponent?.tag!==r)throw new Error(`Component collection must be activated before rendering ${r}`);l.gramlot_component?.dataScope&&(u.readDataScope=()=>{if(!e.getAttr("datapath"))throw new Error("Data scope requires an explicit datapath");return e.getRelativeData(".")}),l.gramlot_component?.sourceContext&&u.setSourceContext({publish:(f,h)=>e.publish(f,h),writeParameter:(f,h)=>this.writeParameter(e,f,h),callLogic:(f,h)=>this.callLogic(e,f,h)});let c=t.createTextNode(this.text(e));(a!==Ue||!l.void)&&u.append(c);let d={element:u,text:c,tag:r};return this.update(d,e,i,ra,s),d}matches(e,t){let{tag:r,namespace:i}=this.definition(t);return(i===Ue?e.tag.toLowerCase()===r.toLowerCase():e.tag===r)&&e.element.namespaceURI===i}writeParameter(e,t,r){let i=e.getAttr(t);e.pointerType(i)==="^"&&!z(i)&&!Object.is(e.getRelativeData(i.slice(1)),r)&&e.setRelativeData(i.slice(1),r)}compose(e,t,r){e.text.data=t??"";for(let i of r)e.element.append(i)}update(e,t,r=t.attr,i=ra,s=null){if(t.nodeTag==="script"){for(let[b,g]of t.codeAttributes())if(t.activatedCode(b)!==g)throw new Error(`script '${t.label}': '${b}' runs only as received with the Source`)}let{element:o,text:a}=e,l=o.namespaceURI===Ue,u=this.definition(t).meta.render_attributes??{},c=e.attrs??{},d=b=>(Ur(t,b,t.builder.constructor.dialectPrefixes),Fr(t,b,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(b)),f=t.parentNode;f?._getMeta("gramlot_component")?.childParameters&&(r=o.ownerDocument.defaultView.customElements.get(f._getMeta("render_tag")).projectChild(o,r,{adapt:d,invoke:(g,_,w)=>this.invokeScript(t,g,_,w),publish:(g,_)=>t.publish(g,_),publishParent:(g,_)=>f.publish(g,_),writeParameter:(g,_)=>this.writeParameter(t,g,_),remove:()=>t.parentBag.popNode(t.label)})),this.definition(t).meta.gramlot_component&&(this.definition(t).meta.gramlot_component.bagStore&&o.setStoreBag(t.getRelativeData(t.getAttr("storepath"))),r=o.projectAttributes(r,d)),r=Object.fromEntries(he({...r,...u}));let h=be.classFor(o,r)!==null;i===ra&&(i=this.text(t));let p=i==null?"":String(i);a.data!==p&&(a.data=p);let m=[...new Set([...Object.keys(c),...Object.keys(r)])];m.sort((b,g)=>(g==="sandbox")-(b==="sandbox"));for(let b of m){if(this.metadataAttributes.has(b)||["ask","_ask"].includes(b)||h&&b==="value")continue;let g=r[b],_=b,w=_g(_),v=l&&mg.has(w)&&typeof o[w]=="boolean",k=_==="xmlns"?"xmlns":_.includes(":")?_.split(":")[0]:"",E=Object.hasOwn(bc,k)?bc[k]:null;if(Object.is(c[b],g)||(g==null||v&&!g?E?o.removeAttributeNS(E,_.split(":").at(-1)):o.removeAttribute(_):E?o.setAttributeNS(E,_,String(g)):o.setAttribute(_,v?"":String(g))),l&&(v||gg.has(w))&&w in o){let C=w==="value"?g==null?"":String(g):!!g;o[w]!==C&&(o[w]=C)}}s===!1?o.style.visibility!=="hidden"&&(o.style.visibility="hidden"):e.visible===!1&&(r.style==null?o.removeAttribute("style"):o.setAttribute("style",String(r.style))),e.visible=s,e.attrs=r}text(e){return e.value instanceof A?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};function wg(n){for(let e=n.parentNode;e;e=e.parentNode)if(e.nodeTag==="framePane")return e;return null}function _c(n){if(!n||!(n.value instanceof A))return null;let e=n.value.getNodes().find(i=>i.getAttr("region")==="center"),t=[];function r(i){if(i.nodeTag!=="framePane"&&(i.getAttr("frameTarget")===!0&&t.push(i),i.value instanceof A))for(let s of i.value.getNodes())r(s)}return e&&r(e),t.length===1?t[0]:null}function yg(n){if(n.closed||!n.runtime.renderer.attached(n.node))return!1;for(let e=n.node;e;e=e.parentNode){let[,t]=e.rootBuilder.runtimeValues(e);if(t.hidden===!0||t.disabled===!0)return!1}return!0}function wc(n){if(n&&typeof n=="object"){for(let e of Object.values(n))wc(e);Object.freeze(n)}return n}function yc(n,e){let t=n.node,r=t.getAttr("command"),i=n.runtime.gramlot.commands.get(r),s=wg(t),o=_c(s);if(!i||!o)return console.warn(`Cannot dispatch command '${r}' at '${t.label}': missing or duplicate frame recipient`),null;let a=t.getAttr("parameters")??{};if(typeof a!="object"||Array.isArray(a))throw new TypeError("Command parameters require a mapping");let l=Object.fromEntries(Object.entries(a).map(([m,b])=>[m,t.pointerType(b)?t.getRelativeData(b):b])),u=wc(P(U(l))),c=Object.freeze(Object.fromEntries(["shift","ctrl","alt","meta"].map(m=>[m,!!e[`${m}Key`]]))),d=Object.freeze({sender:t,target:o,command:r,parameters:u,modifiers:c}),f=!1,h=n.runtime.bindingFor(o).track(()=>{f=!0}),p=()=>!f&&yg(n)&&_c(s)===o&&n.runtime.renderer.attached(o)&&t.getAttr("command")===r;return{message:d,current:p,release:h,cancel(){f=!0},deliver(){p()&&o.publish(i.publish,d)}}}var fs=class n{#e;#t;#r=null;#n=0;#i=new Set;#s=null;static for(e,t){return t.element?.constructor.gramlotComponent?.command?new n(e,t):null}constructor(e,t){this.#e=e,this.#t=t}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get controllers(){let e=this.node.value;return e?.getNodes?e.getNodes().filter(t=>t.nodeTag==="dataController"||t.nodeTag==="dataRpc"):[]}get mechanism(){let e=this.node,t=this.controllers;if(t.length>1)throw new Error(`${e.nodeTag} '${e.label}': several dataController or dataRpc children; a button has one click mechanism`);let r=e.getAttr()??{},i=[];if(t.length&&i.push("controller"),r.action!=null&&i.push("action"),e.nodeTag==="menuline"&&r.command!=null&&i.push("registered"),vc(r).length&&i.push("fire"),e.nodeTag==="menuline"&&e.value instanceof A&&e.value.getNodes().some(s=>s.nodeTag==="menu")&&i.length)throw new Error(`menuline '${e.label}': a submenu cannot also execute a command`);if(e.nodeTag==="menuline"&&r.group&&i.length)throw new Error(`menuline '${e.label}': a group cannot execute a command`);if(i.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${i.join(" and ")} together; a button has one click mechanism`);return i[0]??null}attach(){this.refresh(),this.element.activateCommand=e=>this.onClick(e),this.element.attachCommand(),this.element.addEventListener("click",this)}refresh(){if(this.node.nodeTag==="menuline"){let t=this.node.getAttr("command"),r=t?this.binding.runtime.gramlot.commands.get(t):null;this.element.setCommandDefinition(r,this.node.label),t&&!r&&this.#s!==t&&(console.warn(`Unknown command '${t}' in menu '${this.node.parentNode?.label}', entry '${this.node.label}'`),this.#s=t)}for(let t of this.#i)t.current()||t.cancel();this.mechanism&&this.node.getAttr("type")==null&&this.element.getAttribute("type")!=="button"&&this.element.setAttribute("type","button")}detach(){this.element.removeEventListener("click",this),this.element.releaseCommand(),delete this.element.activateCommand,this.#r?.();for(let e of this.#i)e.cancel(),e.release();this.#i.clear()}handleEvent(e){this.onClick(e)}onClick(e){if(this.binding.closed||this.element.disabled)return;let t=this.element.commandTarget(e);if(t===null)return;if(t!==this.element)return e.stopPropagation(),t.activateCommand(e);if(!this.element.prepareCommand(e))return;let r=this.mechanism;if(!r||(e.stopPropagation(),this.element.disabled))return;let i=r==="registered"?yc(this.binding,e):null;if(r==="registered"&&!i)return;i&&this.#i.add(i);let s=this.binding.countClick(),o=this.node;for(;o&&o.getAttr("_delay")==null;)o=o.parentNode;let a=o?o.rootBuilder.runtimeValues(o)[1]._delay:0;if(a>0){let l=this.#n+1;this.#r?.(),this.#n=l;let u=setTimeout(()=>{c(),this.#r=null,this.#n=0,this.#a(e,l,i)},a),c=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(u),i&&(i.cancel(),i.release(),this.#i.delete(i)),c(),this.#r=null,this.#n=0};return}return this.#r?.(),this.#a(e,s,i)}async#o(e){try{if(!e.current())return;let t=this.node.getAttr("ask"),r=this.binding.runtime.askDialog,i={...e.message.parameters};if(t&&r.required(this.binding,t,i,"ask")&&await r.show(this.binding,t,i)===null)return;e.deliver()}finally{e.release(),this.#i.delete(e)}}#a(e,t,r=null){if(r)return this.#o(r);if(this.binding.closed||this.element.disabled)return;let i=this.mechanism;if(!i)return;let s=this.node,o=vg(e);if(i==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t});else if(i==="action"){let a=()=>{let[,d]=s.rootBuilder.runtimeValues(s),f=Object.fromEntries(Object.entries(d).filter(([h])=>h!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(f),event:e,_counter:t,modifiers:o}},l=d=>{if(this.binding.closed||this.element.disabled||d===null)return;let f={...a(),...d};d&&(f._askResult=d),Qe(this.binding.runtime,s,"action",s.getAttr("action"),f)},u=s.getAttr("ask"),c=this.binding.runtime.askDialog;if(u&&c.required(this.binding,u,a(),"ask"))return c.show(this.binding,u,a()).then(l);l(void 0)}else{let a={modifier:o,_counter:t},l=s.getAttr("fire");if(l!=null){s.FIRE(l,o||!0,a);return}for(let[u,c]of vc(s.getAttr())){if(this.binding.closed)return;s.FIRE(c,u.slice(5),a)}}}};function vc(n){return Object.entries(n??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function vg(n){return["shift","ctrl","alt","meta"].filter(e=>n[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var Ve=class extends J{static classKwargs={...J.classKwargs,asBag:!1};constructor({cacheTime:e,onError:t}){super({cacheTime:e??-1}),this.onError=t,this.loading=null,this.loaded=!1,this.writing=!1}resolve({static:e=!1}={}){return!e&&!this.closed&&!this.loading&&!this.writing&&this.expired&&this.refresh(),this.cachedValue}refresh(){if(this.closed)return null;let e=this.startLoad(r=>this.#t(r));if(e===null)return null;let t=()=>{this.loading===e&&(this.loading=null)};return e.then(t,t),this.loading=e,e.catch(r=>{r?.name!=="AbortError"&&this.onError(r)}),e}resolveSync(e){return super.resolve(e)}prepareValue(e){return e}#e(){let e={...this._kw};for(let[t,r]of Object.entries(this.node?.attr??{}))this.constructor.internalParams.has(t)||(e[t]=r);return this._computeEffectiveFingerprint(e)}async#t(e){if(this.closed)return;let t=this.#e(),r=await this.loadAsync(e);if(this.closed||e.ignored)return;let i=this.prepareValue(r);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(i,this.cacheTime!==0):this.cachedValue=i}finally{this.writing=!1}return i}};var Vr=class extends Ve{static internalParams=new Set([...Ve.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:r,cacheTime:i,onCalling:s=null,onError:o,sync:a=!1}){super({cacheTime:i,onError:o}),this.binding=e,this.sync=a,this.method=t,this.params=r,this.onCalling=s}get closed(){return this.binding.closed}resolve(e={}){return this.sync?e.static||this.loading||this.writing?this.cachedValue:this.expired&&!this.binding.node.requests.calling(this.onCalling)?this.cachedValue:super.resolveSync(e):super.resolve(e)}load(){let e;try{e=this.binding.callSync("data",this.method,this.params)}catch(t){this.onError(t)}return this.loaded=!0,e}startLoad(e){let t=this.binding.node.requests;return t.calling(this.onCalling)?t.submit(this.method,this.params,e):null}loadAsync(e){return this.binding.call("data",e)}};var Ec=new Set(["kind","command","caption","icon","iconSrc","tooltip","disabled","hidden","checked","favorite","parameters","resolver","cacheTime","sync"]);function kc(n,e=new Set){if(!(n instanceof D)||e.has(n))throw new TypeError("Menu resolver must return an acyclic Bag");let t=new Set([...e,n]);return n.getNodes().map(r=>{let i=r.attr,s=i.kind,o=r.staticValue;if(Object.keys(i).some(l=>!Ec.has(l)&&!l.startsWith("resolver_")))throw new TypeError(`Unsupported menu record field: ${r.label}`);if(!["command","separator","submenu"].includes(s))throw new TypeError(`Invalid menu kind: ${r.label}`);for(let l of["disabled","hidden","checked"])if(i[l]!=null&&typeof i[l]!="boolean"&&!(typeof i[l]=="string"&&i[l].startsWith("^")))throw new TypeError(`Invalid menu ${l}`);if(i.favorite!=null&&typeof i.favorite!="boolean")throw new TypeError("favorite must be boolean");if(i.caption!=null&&typeof i.caption!="string")throw new TypeError("Menu caption must be text");if(i.parameters!=null&&(typeof i.parameters!="object"||Array.isArray(i.parameters)))throw new TypeError("Menu parameters must be a mapping");if(s==="command"&&(typeof i.command!="string"||!i.command||o!=null||i.resolver!=null))throw new TypeError("Command record requires a command and no children/resolver");if(s==="separator"&&(o!=null||Object.keys(i).length!==1))throw new TypeError("Separator record accepts kind only");if(s==="submenu"&&(typeof i.caption!="string"||i.command!=null||o instanceof D==(i.resolver!=null)||!(o instanceof D)&&o!=null))throw new TypeError("Submenu requires caption and exactly one content source");let a=o instanceof D?kc(o,t):null;return{label:r.label,attrs:{...i},children:a}})}function xc(n,e){let t=n.builder.wrapSource(n),r=n.value instanceof A?n.value.getNodes():[],i=new Set(e.map(s=>s.label));for(let s of r)i.has(s.label)||n.value.popNode(s.label);for(let[s,o]of e.entries()){let{kind:a,...l}=o.attrs,u=Object.fromEntries(Object.entries(l).filter(([p])=>p==="resolver"||p==="cacheTime"||p==="sync"||p.startsWith("resolver_")));for(let p of Object.keys(u))delete l[p];let c=a==="separator"?"-":null,d=n.value instanceof A?n.value.getNodes().find(p=>p.label===o.label):null,f=d?.value instanceof A;if(d&&(f!==(a==="submenu")||d.value==="-"!=(a==="separator"))&&(n.value.popNode(d.label),d=null),!d)d=Y(t.menuline(c,{...l,node_label:o.label}));else{let p=Object.keys(d.attr).filter(m=>Ec.has(m)&&!Object.hasOwn(l,m));d.setAttr({...Object.fromEntries(p.map(m=>[m,null])),...l})}if(a==="submenu"){let p=d.value instanceof A?d.value.getNodes().find(m=>m.nodeTag==="menu"):null;p?p.setAttr({...Object.fromEntries(Object.keys(p.attr).filter(m=>m==="resolver"||m==="cacheTime"||m==="sync"||m.startsWith("resolver_")).map(m=>[m,null])),...u}):p=Y(d.builder.wrapSource(d).menu({...u,node_label:"menu"})),o.children&&xc(p,o.children)}let h=n.value.getNodes().indexOf(d);h!==s&&n.value.move(h,s)}}var hs=class{#e=null;#t=null;#r=0;#n=!1;#i=null;constructor(e,t){this.binding=e,this.element=t}get node(){return this.binding.node}attach(){this.element.menuBinding=this,this.refresh()}detach(){this.#n=!0,this.#r++,this.node.requests.inflight?.cancel(),delete this.element.menuBinding,this.element.close(!1)}refresh(){let[,e]=this.node.rootBuilder.runtimeValues(this.node),t=Object.fromEntries(Object.entries(e).filter(([i])=>i.startsWith("resolver_")).map(([i,s])=>[i.slice(9),s])),r=U([e.resolver,t,e.cacheTime,e.sync]);r!==this.#e&&(this.#e=r,this.#r++,this.#i=null,this.#t=e.resolver?new Vr({binding:this.binding,method:e.resolver,params:t,cacheTime:e.cacheTime??-1,sync:e.sync??!1,onError:()=>{}}):null,this.#t?(this.element.setStatus("loading"),this.element.opened&&this.element.isConnected&&this.load()):this.element.setStatus(null))}async load(e=!1){if(this.#n||!this.#t)return;let t=this.#t,r=this.#r;try{if(e?t.refresh():t.resolve(),t.loading&&(this.element.setStatus("loading"),await t.loading),this.#n||r!==this.#r)return;let i=t.cachedValue,s=kc(i),o=U(i);this.#i!==o&&(xc(this.node,s),this.#i=o),this.element.setStatus(s.length?null:"empty")}catch(i){if(this.#n||r!==this.#r)return;this.element.setStatus("error"),console.warn(`Menu '${this.node.label}' failed to load`,i)}}};var ps="connect_on",Vn=class{#e;#t;#r;#n;#i;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,r])=>t.startsWith(ps)&&t.length>ps.length&&r!=null).map(([t,r])=>[t,t.slice(ps.length).toLowerCase(),r])}constructor(e,t,r,i,s=`${ps}${r}`){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get eventName(){return this.#r}get handler(){return this.#n}get attribute(){return this.#i}attach(){this.element.addEventListener(this.eventName,this)}detach(){this.element.removeEventListener(this.eventName,this)}handleEvent(e){if(this.binding.closed)return;let t=this.node,r=this.binding.runtime;if(Un(this.handler))return rr(r,t,this.handler,e);r.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function Bt(n,e=new Set){if(!n||typeof n!="object")return;let t=n.ownerDocument?.defaultView?.Node??n.defaultView?.Node;if(Y(n)instanceof we||t&&n instanceof t)throw new TypeError("Live Source/DOM references cannot cross a transport boundary");if(e.has(n))throw new TypeError("Transport data cannot contain circular references");e.add(n);let r=n instanceof D?n.getNodes().flatMap(i=>[i.staticValue,i.getAttr()]):Object.values(n);for(let i of r)Bt(i,e);e.delete(n)}var zn=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let r=new Map,i=s=>{for(let o of s.getNodes()){let a=o.getAttr("__ref");if(a){if(r.has(a))throw new Error("Duplicate Source reference");let l=this.entries.get(a);if(e!==this.sourceRoot&&l&&l.node!==o&&!t.has(l.node))throw new Error("Duplicate Source reference");r.set(a,o)}o.value instanceof A&&i(o.value)}};i(e)}register(e,t){let r=e.getAttr("__ref");if(r){if(this.entries.has(r))throw new Error(`Duplicate Source reference: ${r}`);this.entries.set(r,{node:e,dom:t})}}remove(e){for(let[t,r]of this.entries)r.node===e&&this.entries.delete(t)}resolveArguments(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r&&typeof r=="object"&&Object.hasOwn(r,"$gramlotRef")?this.resolve(r):r]))}resolve(e){if(!e||!["node","dom"].includes(e.kind))throw new TypeError("Expected a node or DOM reference");let t=this.entries.get(e.$gramlotRef);if(!t)throw new Error("Source reference is not mounted");return t[e.kind]}};var ms=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},na=class{#e;#t;#r;#n;#i;#s=!0;#o;constructor(e,{path:t,attr:r,recipient:i,order:s,subtree:o=!1}){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s,this.#o=o}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#n}get subtree(){return this.#o}get active(){return this.#s}get order(){return this.#i}close(){this.active&&(this.#s=!1,this.router.unregister(this))}},ia=class{constructor({evt:e,node:t,path:r,oldvalue:i,attrsDiff:s,reason:o,fired:a,level:l,registration:u}){this.evt=e,this.node=t,this.path=r,this.oldvalue=i,this.attrsDiff=s,this.reason=o,this.fired=a,this.level=l,this.registration=u}},gs=class{#e;#t=new ms;#r=new Map;#n=0;#i=0;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return this.#n}register({path:e,attr:t=null,recipient:r,subtree:i=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let s=this.#t;for(let a of e.split(".")){let l=s.children.get(a);l||(l=new ms(s,a),s.children.set(a,l)),s=l}this.#i+=1;let o=new na(this,{path:e,attr:t,recipient:r,order:this.#i,subtree:i});return s.registrations.add(o),this.#r.set(o,s),this.#n+=1,o}unregister(e){let t=this.#r.get(e);if(t)for(this.#r.delete(e),t.registrations.delete(e),this.#n-=1;t.parent&&!t.children.size&&!t.registrations.size;)t.parent.children.delete(t.segment),t=t.parent}deliver(e){let{pathlist:t}=e;if(!t?.length||t[0]!==Rn||e.reason==="autocreate")return;let r=t.slice(1),i=e.evt==="ins"||e.evt==="del";for(let s of Array.isArray(e.node)?e.node:[e.node]){let o=i?[...r,s.label]:r,a=o.join(".");for(let[l,u]of this.#s(o,e))l.active&&l.recipient.receive(new ia({evt:e.evt,node:s,path:a,oldvalue:e.oldvalue??null,attrsDiff:e.attrs_diff??null,reason:e.reason??null,fired:e.fired??!1,level:u,registration:l}))}}#s(e,t){let r=[],i=this.#t;for(let o of e){for(let a of i.registrations)i!==this.#t&&this.#o(a,"child",t)&&r.push([a,"child"]);if(i=i.children.get(o),!i)return r.sort(([a],[l])=>a.order-l.order)}for(let o of i.registrations)this.#o(o,"node",t)&&r.push([o,"node"]);let s=[...i.children.values()];for(;s.length;){let o=s.pop();for(let a of o.registrations)this.#o(a,"container",t)&&r.push([a,"container"]);s.push(...o.children.values())}return r.sort(([o],[a])=>o.order-a.order)}#o(e,t,r){let{evt:i}=r;return e.subtree?t!=="container"||i!=="upd_attrs":e.attr===null?i==="upd_attrs"?!1:!(t==="child"&&r.fired):t==="child"?!1:t==="container"?i!=="upd_attrs":i==="ins"||i==="del"?!0:Object.hasOwn(r.attrs_diff??{},e.attr)}};var bs=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=Hn(e),r=this.setterNodes(e);oa(e);for(let i of r)this.applySetter(i),this.runtime.closeBranch(i),i.parentBag&&i.parentBag.popNode(i.label);this.applyDefaults(t.filter(i=>i.nodeTag&&!i._getMeta("data_element")))}setterNodes(e){return Hn(e).filter(t=>t.nodeTag==="dataSetter")}applySetter(e){let t=e.absDatapath(e.pathAttribute("destination_path"));if(t===null)return;let r=e.getAttr("value")??null,i=kg(e.getAttr()),s=this.runtime.data;if(r!==null)s.setItem(t,r,i,">",!1,!0,e),r instanceof D&&e.setAttr({value:null},!1);else{let o=s.getNode(t);o?i&&o.setAttr(i,!0):s.setItem(t,null,i,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let r=t.getAttr();for(let[i,s]of Object.entries(r)){if(!Eg(t,i,s))continue;let o=i==="value"?r.default_value??r.default:r[`default_${i}`];o!=null&&this.#t(t,s,o)}this.#r(t,r)}}#t(e,t,r){let i=e.absDatapath(t);if(i===null)return;let[s,o=null]=i.split("?",2),a=this.runtime.data,l=a.getNode(s);if(o===null){if(l&&l.value!==null&&l.value!==void 0)return;a.setItem(s,r,null,">",!1,!0,e)}else if(l){let u=l.getAttr(o);u==null&&l.setAttr({[o]:r},!0)}else a.setItem(s,null,{[o]:r},">",!1,!0,e)}#r(e,t){let r={};for(let[o,a]of Object.entries(t))o.startsWith("attr_")&&(r[o.slice(5)]=z(a)?Ot(e,o):e.pointerType(a)?e.getRelativeData(a):a);if(!Object.keys(r).length)return;let i=[t.value,t.src].find(o=>e.pointerType(o));if(!i)return;let s=e.absDatapath(i);s!==null&&this.runtime.data.getNode(s.split("?",1)[0])?.setAttr(r,!0,!0,!1)}};function Eg(n,e,t){return e==="_meta"||Ht.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:n.pointerType(t)!==null}function kg(n){let e={};for(let[t,r]of Object.entries(It(n??{})))Ht.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||r!=null&&(e[t]=r);return Object.keys(e).length?e:null}function xg(n){let e=n.builder;if(!(e instanceof qe))throw new Error(`dataSetter '${n.label}': dataSetter is not supported inside ${e.constructor._name}`)}function oa(n){for(let e of Hn(n))e.nodeTag==="dataSetter"&&xg(e),Cg(e)}var Ag=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],Tg=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),Dg=["_onCalling","_onResult","_onError"],Sg=["_delay","_timing","_userChanges"],sa=["_init","_onBuilt","_onStart"];function Cg(n){let e=s=>n.getAttr(s)!==null&&n.getAttr(s)!==void 0,t=!n._getMeta("data_element")&&typeof n.getAttr("remote")=="string";if(n.nodeTag!=="dataRpc"){let s=Dg.find(o=>e(o)&&!(o==="_onCalling"&&(n.nodeTag==="dataRemote"||t)));if(s){let o=s==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${s}' is allowed only on ${o}`)}}if(Tg.has(n.nodeTag)){let s=Object.entries(n.getAttr()).find(([,a])=>$e(a));if(s)throw new Error(`${n.nodeTag} '${n.label}': '${s[0]}' is a == expression, not accepted on ${n.nodeTag}`);let o=n.nodeTag==="dataRemote"?sa.find(e):null;if(o)throw new Error(`dataRemote '${n.label}': '${o}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let a of sa){let l=n.getAttr(a);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${n.nodeTag} '${n.label}': '${a}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let r=Ag.find(s=>e(s)&&!(s==="_delay"&&!n._getMeta("data_element")&&n.nodeTag!=="html_button")&&!(t&&Sg.includes(s)));if(!r)return;let i=sa.includes(r)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${r}' is allowed only on ${i}`)}function Hn(n){if(n instanceof A)return n.getNodes().flatMap(t=>Hn(t));let e=[n];return n.value instanceof A&&e.push(...Hn(n.value)),e}var Ng=new Set(["destination_path","result_path","func","formula","script","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","_ask","_ask_if","_ask_title","_ask_onCancel","method","timeout","_onCalling","_onResult","_onError","cacheTime","sync"]),Wn=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let r=null,i=setTimeout(()=>{r(),this.#r=null,t()},e);r=this.binding.track(()=>clearTimeout(i)),this.#r=()=>{clearTimeout(i),r(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let r=setInterval(t,e*1e3),i=this.binding.track(()=>clearInterval(r));this.#t=()=>{clearInterval(r),i(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},zr=class{#e;#t=[];#r=new Set;#n;#i=null;#s=!1;constructor(e){this.#e=e,this.#n=new Wn(e),e.track(()=>{this.cancel(),this.#m(),this.#h()})}get binding(){return this.#e}get node(){return this.binding.node}get kind(){throw new Error("Provider.kind is defined by FormulaProvider, ControllerProvider, RpcProvider and RemoteProvider")}register(){let e=this.node,t=e.getAttr("_onStart");if(typeof t=="number"&&!(Number.isFinite(t)&&t>=0))throw new Error(`${e.nodeTag} '${e.label}': _onStart must be true or a delay in ms not below 0: ${t}`);this.#m();let r=this.binding.runtime.router,i=ze(e,e.getAttr("_timing"));for(let[s,o]of e.pointers()){if(s==="datapath")continue;let a=e.absDatapath(o);if(a===null)continue;let[l,u=null]=a.split("?",2),c=r.register({path:l,attr:u,recipient:this});this.#t.push(c),(s==="_timing"||i.has(s))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(s,o,a)=>l=>{let u={kind:"subscription",topic:a,payload:l};if(this.#a("_userChanges")&&a!=="node")return;let c=this.#a("_delay");c>0?this.#n.debounce(c,()=>this.invoke(u)):this.invoke(u)})),this.#o(),this.kind==="remote"&&this.invoke({kind:"install",change:null})}receive(e){if(this.#r.has(e.registration)){this.#o();return}if(this.#a("_userChanges")&&e.level!=="node")return;let t={kind:"data",change:e},r=this.#a("_delay");r>0?this.#n.debounce(r,()=>this.invoke(t)):this.invoke(t)}invoke(e){if(this.binding.closed)return;let t=this.node,r=this.kind==="formula",i=this.kind==="rpc",s=this.kind==="remote",o=this.readArguments(e);e.askResult&&(Object.assign(o,e.askResult),o._askResult=e.askResult);let a=t.getAttr("_ask"),l=this.binding.runtime.askDialog;if(a&&!e.askDone&&l.required(this.binding,a,o,"_ask"))return l.show(this.binding,a,o,t.getAttr("_ask_title")??"Warning").then(p=>{if(!this.binding.closed){if(p===null){let m=t.getAttr("_ask_onCancel");m&&this.#l("_ask_onCancel",m,m,o,!0);return}return this.invoke({...e,askDone:!0,askResult:p})}});let[u,c]=[r?"formula":"script",t.getAttr(r?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,o,!1)){if(s&&this.#h(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(i||s){this.#l(u,c,c,o,!0);return}}if(i)return this.#u(o);if(s)return this.#d(o);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,r?`return ${c}`:c,o,!0);else if(f==null){if(!r)return;h=new D(_s(o))}else{let{group:p,method:m}=this.binding.runtime.logicRegistry.resolve(f,t);h=r?m.call(p,o):m.call(p,t,o)}r&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,r]=t.rootBuilder.runtimeValues(t),i=Object.fromEntries(Object.entries(r).filter(([l])=>!Ng.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),s={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(i)};e.kind==="subscription"&&(s._subscription_kwargs=e.payload);let o=e.change??null,a=o?o.level:e.kind==="subscription"?e.topic:e.kind;return s._node=o?o.node:null,s._triggerpars={kw:o,trigger_reason:a},s._reason=a,e.kind==="click"&&Object.assign(s,Ig(e)),s}cancel(){this.#n.cancel()}#o(){this.#n.startTiming(this.#a("_timing"),()=>this.invoke({kind:"timing",change:null}))}#a(e){let t=this.node,r=t.getAttr(e);return z(r)?Ot(t,e):t.pointerType(r)?t.getRelativeData(r):r??null}#l(e,t,r,i,s){let o=[...s?["_kwargs"]:[],...Ac,...Tc,...Object.keys(_s(i))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?Qe(this.binding.runtime,this.node,e,t,{...i,_kwargs:i},o):this.binding.runtime.inlineCompiler.compile(this.node,e,t,o,r)({...i,_kwargs:i})}async#u(e){let t=this.node,[r,i,s]=["_onCalling","_onResult","_onError"].map(a=>t.getAttr(a)),o=t.requests;if(o.calling(r?()=>this.#l("_onCalling",r,r,e,!0):null))return o.submit(this.#a("method"),_s(e),a=>this.#c(a,e,i,s))}async#c(e,t,r,i){if(this.binding.closed)return;let s=this.node,o=this.#a("timeout"),a=o>0?setTimeout(()=>{let c=new Error(`${s.nodeTag} '${s.label}': no answer within ${o} ms`);c.name="TimeoutError",e.controller.abort(c)},o):null,l;try{l={result:await this.binding.call("data",e)}}catch(c){l={error:c}}if(clearTimeout(a),this.binding.closed||e.ignored)return;if("error"in l){if(!i)throw l.error;this.#l("_onError",i,i,{...t,error:l.error},!0);return}let{result:u}=l;s.getAttr("result_path")!=null&&s.setRelativeData(s.pathAttribute("result_path"),u),r&&this.#l("_onResult",r,r,{...t,result:u},!0)}#d(e){this.#h();let t=this.#s;this.#s=!1;let r=this.node,i=r.absDatapath(r.pathAttribute("destination_path"));if(i===null)return;let s=r.getAttr("_onCalling"),o=new Vr({binding:this.binding,method:this.#a("method"),params:_s(e),cacheTime:this.#a("cacheTime"),sync:this.#a("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:s?()=>this.#l("_onCalling",s,s,e,!0):null,onError:a=>{throw new Error(`${r.nodeTag} '${r.label}': dataRemote '${o.method}' failed: ${a.message}`,{cause:a})}});this.binding.runtime.data.setResolver(i,o),this.#i={path:i,resolver:o},t&&o.refresh()}#h(){if(!this.#i)return;let{path:e,resolver:t}=this.#i;this.#i=null,this.#s=t.loaded||t.loading!==null;let r=this.binding.runtime.data.getNode(e);r?.resolver===t&&(r.resolver=null)}#m(){for(let e of this.#t.splice(0))e.close();this.#r.clear()}},ws=class extends zr{get kind(){return"formula"}},ys=class extends zr{get kind(){return"controller"}},vs=class extends zr{get kind(){return"rpc"}},Es=class extends zr{get kind(){return"remote"}},Ac=["_node","_triggerpars","_reason","_subscription_kwargs","_askResult"],Tc=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function _s(n){let e={...n};for(let t of[...Ac,...Tc])delete e[t];return e}function Ig({event:n,counter:e}){return{_evt:n,button_counter:e,button_shift:!!n.shiftKey,button_ctrl:!!n.ctrlKey,button_alt:!!n.altKey,button_meta:!!n.metaKey}}var Og=[[null,/(\W|^)GET (?:\s*)(\^?[\w.#@$?-]+)/g,"$1this.GET('$2')"],[/;SET/g,/(\W|^)SET (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.SET('$2', $3)$4 "],[/;PUT/g,/(\W|^)PUT (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.PUT('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE_AFTER('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE_AFTER('$2')$3 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE('$2', $3)$4 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE('$2')$3 "]],Bg=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,Rg=new Set(["arguments","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","eval","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),ks=class{#e;#t=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return[...this.#t.values()].reduce((e,t)=>e+t.size,0)}preprocess(e,t,r){let i=r.trim();if(Bg.test(i))throw new Error(`${Gn(e,t)}: the PUBLISH macro is excluded from Gramlot`);let s=i.replace(/\$(\d+)/g,(o,a)=>`arguments[${parseInt(a,10)-1}]`);for(let[o,a,l]of Og)o&&(s=s.replace(o,`; ${o.source.slice(1)}`)),s=s.replace(a,l);return s!==i&&console.warn(`${Gn(e,t)}: legacy macros are deprecated; write this.GET(path), this.SET(path, value), this.PUT(path, value), this.FIRE(path, value), this.FIRE_AFTER(path, value) and arguments[n] in place of GET, SET, PUT, FIRE, FIRE_AFTER and $n`),s}compile(e,t,r,i,s=r){if(e.activatedCode(t)!==r)throw new Error(`${Gn(e,t)}: inline code runs only as received with the Source (main or a remote Source); a text written later is not run: use named logic`);let o=this.#t.get(e);o||(o=new Map,this.#t.set(e,o),this.runtime.bindingFor(e).track(()=>this.release(e)));let a=o.get(t);a?.source!==s&&(a={source:s,text:this.preprocess(e,t,s),key:null,run:null},o.set(t,a));let l=i.filter($g),u=l.join(",");if(a.key!==u){let c=Mg(e,t,a.text,l);a.key=u,a.run=d=>c.apply(e,l.map(f=>d[f]))}return a.run}compileExpression(e,t,r){let i=r.slice(2).trim(),s=he(e.getAttr()).filter(([,a])=>!$e(a)),o=this.compile(e,t,r,[...s.map(([a])=>a).filter(a=>a!=="_F"),"_F"],`return ${i}`);return a=>{let l={};for(let[u,c]of s)Object.hasOwn(a,u)?l[u]=a[u]:l[u]=e.pointerType(c)?e.getRelativeData(c):c;return o({...l,_F:(u,c)=>this.runtime.gramlot.format(u,c)})}}compilePointerExpression(e,t,r,i){let s=this.compile(e,t,r,["_pointerValues","_F"],`return (${i}
123
- )`);return o=>s({_pointerValues:o,_F:(a,l)=>this.runtime.gramlot.format(a,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let r=this.#t.get(e);if(r)for(let i of t){r.delete(i);for(let[s]of he({[i]:null}))r.delete(s)}}};function $g(n){return/^[A-Za-z_$][\w$]*$/.test(n)&&!Rg.has(n)}function Gn(n,e){return`${n.nodeTag} '${n.label}' ${e?`'${e}'`:"node value"}`}function Mg(n,e,t,r){try{return t.startsWith("function")?new Function(`return (${t}
182
+ :host([role=separator]) button{display:none}
183
+ @media(forced-colors:active){button,:host(.button--secondary) button,:host(.button--quiet) button{background:ButtonFace;color:ButtonText;border-color:ButtonText;filter:none}}
184
+ `,this.shadowRoot.append(t)}get disabled(){return this.control.disabled}set disabled(e){this.control.disabled=!!e}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly,this.renderIcon(this.parameters.icon,this.parameters.iconSrc),e["aria-label"]!=null?this.control.setAttribute("aria-label",e["aria-label"]):this.control.removeAttribute("aria-label"),r}renderIcon(e,t){if(!t){this.icon.textContent=e??"";return}let r=this.icon.firstElementChild;r||(r=this.ownerDocument.createElement("img"),r.alt="",r.draggable=!1,this.icon.replaceChildren(r)),r.getAttribute("src")!==t&&r.setAttribute("src",t)}get entryIcon(){return this.parameters.icon}get entryIconSrc(){return this.parameters.iconSrc}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}Hn.parameters={disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"},iconSrc:{dtype:"T",default:"",binding:"read"}};var hg=Ot({name:"button",tag:"gramlot-button",base:Hn,command:!0,subTags:"*",implementation:n=>class extends n{}}),pg=Ot({name:"toggleButton",tag:"gramlot-toggle-button",base:Hn,command:!0,subTags:"*",parameters:{value:{dtype:"B",default:!1,binding:"twoWay"},readonly:{dtype:"B",default:!1,binding:"read"}},implementation:n=>class extends n{#e=!1;constructor(){super();let e=this.ownerDocument.createElement("span");e.className="led",e.setAttribute("aria-hidden","true"),this.control.prepend(e),this.writeControlValue(!1)}get commitOnChange(){return!0}readControlValue(){return this.#e}writeControlValue(e){this.#e=e,this.control.setAttribute("aria-pressed",String(e))}prepareCommand(e){return!super.prepareCommand(e)||this.control.readOnly?!1:(this.writeControlValue(!this.#e),this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change")),!0)}}}),mg=Ot({name:"menu",tag:"gramlot-menu",base:Ec,subTags:"menuline,spacer,contentPane",parameters:{presentation:{dtype:"T",default:"popup",enum:["popup","bar"]},orientation:{dtype:"T",default:"horizontal",enum:["horizontal","vertical"]},modifiers:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",default:"beside",enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",default:24},resolver:{dtype:"T",nullable:!0},cacheTime:{dtype:"R",default:-1},sync:{dtype:"B",default:!1}},implementation:n=>class extends n{}}),gg=Ot({name:"menuline",tag:"gramlot-menu-line",base:Hn,command:!0,subTags:"*",parameters:{command:{dtype:"T",nullable:!0},caption:{dtype:"T",nullable:!0},code:{dtype:"T",nullable:!0},checked:{dtype:"B",nullable:!0,binding:"read"},tooltip:{dtype:"T",nullable:!0},labelPosition:{dtype:"T",binding:"read",nullable:!0,enum:["beside","below","tooltip"]},iconSize:{dtype:"R",binding:"read",nullable:!0},group:{dtype:"B",default:!1},priority:{dtype:"R",default:0},overflowable:{dtype:"B",default:!0},parameters:{annotation:{kind:"type",module:"builtins",name:"dict"},nullable:!0},favorite:{dtype:"B",default:!1}},implementation:xc}),bg=Ot({name:"spacer",tag:"gramlot-spacer",base:n=>class extends n{projectAttributes(e){let t=qr(this,e),{size:r,flex:i}=this.parameters;if(r!=null&&i!=null)throw new TypeError("spacer accepts size or flex, not both");if(r!=null&&(!Number.isFinite(r)||r<0)||i!=null&&(!Number.isFinite(i)||i<=0))throw new TypeError("Invalid spacer size/flex");return this.style.flex=i!=null?`${i} 1 0px`:`0 0 ${r??0}px`,this.setAttribute("aria-hidden","true"),t}},parameters:{size:{dtype:"R",nullable:!0},flex:{dtype:"R",nullable:!0}},implementation:n=>class extends n{}}),_g=Ot({name:"dropDownButton",tag:"gramlot-drop-down-button",base:Hn,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:n=>class extends n{#e=null;#t;#r=null;#n;#i;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#i=e.createElement("span"),this.#i.hidden=!0,this.control.append(this.#i),this.#n=e.createElement("button"),this.#n.type="button",this.#n.className="arrow",this.#n.textContent="\u25BE",this.#n.setAttribute("aria-label","Open menu"),this.#n.setAttribute("aria-haspopup","menu"),this.#n.setAttribute("aria-expanded","false"),this.controlBox.append(this.#n);let t=e.createElement("slot");t.name="menu",this.shadowRoot.append(t),this.#n.addEventListener("click",r=>{r.stopPropagation(),this.menu.opened?this.closeMenu():this.openMenu()}),this.#n.addEventListener("keydown",r=>{["ArrowDown","ArrowUp"].includes(r.key)&&(r.preventDefault(),this.openMenu(r.key==="ArrowUp"))})}get menu(){return[...this.children].map(fe).find(e=>e.localName==="gramlot-menu")}get menuItems(){return this.menu?.items??[]}projectAttributes(e,t){let r=super.projectAttributes(e,t);return this.#n.disabled=this.disabled,this.disabled&&this.menu?.close(!1),this.#s(),r}attachCommand(){if(this.parameters.persist){if(!this.id)throw new TypeError("dropDownButton persist requires an explicit id");this.#r=`gramlot:command:${this.ownerDocument.location.pathname}${this.ownerDocument.location.search}:${this.id}`;try{this.#e=this.ownerDocument.defaultView.localStorage.getItem(this.#r)}catch{}}this.#s(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#s()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.menu?.close(!1)}commandTarget(e){return e?.composedPath().includes(this.menu)?null:this.menuItems.find(t=>t.occurrence===this.#e)??this}selectCommand(e,t){if(t){if(this.#e=e.occurrence,this.#r)try{this.ownerDocument.defaultView.localStorage.setItem(this.#r,this.#e)}catch{}this.#s()}this.closeMenu()}#s(){let e=this.menuItems.map(i=>i.occurrence).filter(Boolean);if(new Set(e).size!==e.length)throw new TypeError("Dropdown menu codes must be unique");let t=this.commandTarget(),r=t!==this;this.caption.hidden=r,this.#i.hidden=!r,this.#i.textContent=r?t.entryCaption:"",this.renderIcon(t.entryIcon,t.entryIconSrc)}openMenu(e=!1){this.disabled||this.menu?.open(this.#n,e)}closeMenu(){this.menu?.close()}}}),ms=ia({name:"buttons",components:[hg,pg,_g,mg,gg,bg]});function wg(n,e,t=n){let r=new Map,i=new Set,s=new Map;for(let[a,l]of e){if(typeof a!="string")continue;let u=H(l)?.pointer??l;s.set(a,u instanceof K?u.resolve():n.pointerType(u)?t.getRelativeData(u):Fe(u)?null:u)}let o=a=>{if(r.has(a))return r.get(a);if(!e.has(a))throw new Error(`Source attribute '${a}' does not exist`);if(i.has(a))throw new Error(`cyclic attribute dependency: ${[...i,a].join(" -> ")}`);i.add(a);let l=e.get(a),u=H(l),c=u?s.get(a):null,d,f=h=>h?o(h):c;try{if(u)if(u.expression){let h=nn(u.body),m=h.slots.map(f);d=n.rootBuilder.evaluatePointerExpression(n,a,l,h,m)}else d=Pt(u.body,f),c==null&&(d=null);else d=s.get(a);return r.set(a,d),d}finally{i.delete(a)}};return{resolve:o}}function $t(n,e,t=n){let r=new Map([...Object.entries(n.getAttr()),..._e(n.getAttr())]);return wg(n,r,t).resolve(e)}var yg={dataFormula:["formula","_if","_else","_ask_if","_ask_onCancel"],dataController:["script","_if","_else","_ask_if","_ask_onCancel"],dataRpc:["_ask_if","_ask_onCancel","_if","_else","_onCalling","_onResult","_onError"],dataRemote:["_if","_else","_onCalling"]},sa=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],vg=["_if","_else","_onRemote","_onCalling"],oa=class{#e;#t=null;#r=null;#n=!1;constructor(e){this.#e=e}get inflight(){return this.#t?.view??null}get pending(){let e=this.#r;return e?Object.freeze({method:e.method,get params(){return j(e.text)}}):null}calling(e){if(!e)return!0;let t=!1,r=this.#n;this.#n=!0;try{t=e()!==!1}finally{this.#n=r,!t&&!this.#t&&this.#i()}return t}submit(e,t,r){try{let i=U(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((s,o)=>{this.#r={method:e,text:i,perform:r,resolve:s,reject:o}}):(this.#r?.resolve(void 0),this.#r=null,this.#s(e,t,i,r))}catch(i){return Promise.reject(i)}}submitSync(e,t){if(this.#t)throw new Error("A synchronous call cannot start while a request of the node is in flight");if(!this.#e.matches(e))throw new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`);return t()}#i(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#s(e.method,j(e.text),e.text,e.perform)}catch(r){t=Promise.reject(r)}t.then(e.resolve,e.reject)}#s(e,t,r,i){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let s=new AbortController,o={method:e,params:t,text:r,controller:s,ignored:!1};o.view=Object.freeze({method:e,get params(){return j(r)},sentAt:Date.now(),cancel:()=>this.#a(o)}),this.#t=o,s.signal.addEventListener("abort",()=>this.#o(o),{once:!0});let a;try{a=Promise.resolve(i(o))}catch(l){a=Promise.reject(l)}return a.then(()=>this.#o(o),()=>this.#o(o)),a}#o(e){this.#t===e&&(this.#t=null,this.#i())}#a(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#n||this.#i())}};function kc(n){return typeof n=="string"&&n.startsWith("==")}var nr=class extends Ae{get frame(){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("frame accessor requires a window");let e=this.value instanceof A?this.value.getNodes():[];if(e.length){if(e.length!==1||e[0].nodeTag!=="framePane")throw new TypeError("A window requires exactly one framePane");return this.builder.wrapSource(e[0])}return this.builder.wrapSource(this.builder.commandOnNode(this,"framePane",null,{node_label:"frame"}))}requestClose(e="application"){if(!["dialog","floatingPane"].includes(this.nodeTag))throw new TypeError("requestClose requires a window");return this.rootBuilder.binding.gramlot.dom.getDomNode(this).requestClose(e)}get top(){return this.frameRegion("top")}get bottom(){return this.frameRegion("bottom")}get left(){return this.frameRegion("left")}get right(){return this.frameRegion("right")}get center(){return this.frameRegion("center")}frameRegion(e){if(this.nodeTag!=="framePane")throw new TypeError("Region accessors require framePane");let t=this.value instanceof A?this.value.getNodes().find(i=>i.getAttr("region")===e):null;if(t)return this.builder.wrapSource(t);let r={region:e,node_label:e};return e!=="center"&&Object.assign(r,{display:"flex",flex_direction:["top","bottom"].includes(e)?"column":"row"}),this.builder.wrapSource(this.builder.commandOnNode(this,"contentPane",null,r))}#e=new Set;#t=null;#r=null;get requests(){return this.#r??=new oa(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...yg[this.nodeTag]??[],...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters??{}).filter(([,r])=>r.inline).map(([r])=>r),...this._getMeta("gramlot_component")?.command?["action","_ask_if"]:[],...typeof this.getAttr("remote")=="string"?vg:[]],t=[];for(let[r,i]of Object.entries(this.getAttr()??{}))typeof i=="string"&&(e.includes(r)||r==="validate_call"||r==="validate__onResult"||r==="validate_onAccept"||r==="validate_onReject"||/^validate_\w+_if$/.test(r)||r.startsWith("connect_on")||r.startsWith("subscribe_")||r.startsWith("selfsubscribe_"))&&t.push([r,i]);for(let r of["ask","_ask"]){let i=this.getAttr(r);if(i&&typeof i=="object")for(let s of["_if","askIf"])typeof i[s]=="string"&&t.push([`${r}.${s}`,i[s]])}for(let[r,i]of _e(this.getAttr()))if(kc(i)&&t.push([r,i]),this.nodeTag==="script"&&typeof i=="string"){let s=this.builder.constructor.dialectPrefixes.find(o=>r.startsWith(o))??"";["src","href","xlink:href","xlink_href","_text"].includes(r.slice(s.length).toLowerCase())&&t.push([r,i])}return(kc(this.staticValue)||this.nodeTag==="script"&&typeof this.staticValue=="string")&&t.push(["",this.staticValue]),t}activateCode(){let e=new Map;for(let[t,r]of this.codeAttributes()){if(this.pointerType(r))throw new Error(`${this.nodeTag} '${this.label}': '${t}' is inline code and cannot be the pointer '${r}'; inline code is never read from Data`);e.set(t,r)}for(let[t,r]of[..._e(this.getAttr()),["datapath",this.getAttr("datapath")]])H(r)?.expression&&e.set(t,r);this.#t=e}activatedCode(e){return this.#t?.get(e)??null}remote(e,t={}){let r=this.rootBuilder.nameSyntax;if(typeof e!="string"||!(this.pointerType(e)||r.matches(e)))throw new TypeError(`${this.nodeTag} '${this.label}': remote name must be a pointer or match ${r.pattern}, not ${JSON.stringify(e)}`);let i=Object.keys(t).find(o=>o.startsWith("_")&&!sa.includes(o));if(i)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${i}' is not accepted; the control attributes are ${sa.join(", ")}`);let s={remote:e};for(let[o,a]of Object.entries(t))s[sa.includes(o)?o:`remote_${o}`]=a;return this.setAttr(s),Ln(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=H(e)?Ge(this,e):new Set,r=super.pointers().filter(([i,s])=>!(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(i))&&!t.has(i)&&!this.#s(i,s)).map(([i,s])=>[i,H(s)?.pointer??s]);for(let i of t){let s=this.getAttr(i);this.pointerType(s)==="^"&&r.push(["datapath",H(s)?.pointer??s])}return r}runtimeToEvaluate(){let e=super.runtimeToEvaluate();for(let[t,r]of e){if(this.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(t)){e.set(t,new Dt(()=>r));continue}if(this.pointerType(r)){if(H(r)){if(typeof t!="string")throw new Error(`${this.nodeTag} '${this.label}': pointer suffixes belong to attributes; use format/mask for node text`);this.absDatapath(r)===null&&e.set(t,new Dt(()=>$t(this,t)));continue}this.#s(t,r)?e.set(t,r.slice(1)):this.absDatapath(r)===null&&e.set(t,null)}}return e}pathAttribute(e){let t=this.getAttr(e);return H(t)?$t(this,e):this.pointerType(t)&&this.#s(e,t)?t.slice(1):t}getRelativeData(e,t=null,r={}){return this.absDatapath(e)===null?null:super.getRelativeData(e,t,r)}setRelativeData(e,t,r={}){this.#o(e),super.setRelativeData(e,t,r)}PUT(e,t){this.#o(e),this.data.setItem(this.absDatapath(e),t,null,">",!1,!0,this,!1,!1)}FIRE(e,t=!0,r=null){t===null&&(t=!0),this.#o(e);let i=this.absDatapath(e);if(i.includes("?")){this.#n(i,t);return}this.data.getNode(i)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:r})}finally{this.data.getNode(i)?.setValue(null,!1)}}#n(e,t){let[r,i]=e.split("?",2),s=this.data;s.getNode(r)?.setAttr({[i]:null},!1);try{let o=s.getNode(r);o?o.setValue(o.staticValue,!0,{[i]:t},!0,!0,!0,!0):s.setItem(r,null,{[i]:t},">",!0,!0,!0,!0)}finally{s.getNode(r)?.setAttr({[i]:null},!1)}}FIRE_AFTER(e,t=!0,r=10){this.#o(e);let i=this.rootBuilder?.binding?.bindingFor(this)??null,s=null,o=setTimeout(()=>{s?.(),this.FIRE(e,t)},r);return s=i?.track(()=>clearTimeout(o))??null,()=>{clearTimeout(o),s?.()}}absDatapath(e){e=H(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[r,i]=t.split("?",2),s=super.absDatapath(r);return s===null?null:`${s}?${i}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let r=this;for(;r!==null&&e.startsWith(".");){let i=r.getAttr("datapath");if(this.pointerType(i)&&(i=this.#i(r,i),i===null))return null;if(i!=null&&(e=e==="."?i:i+e),e.startsWith("#"))return r.parentNode._resolveSymbolicDatapath(e,t);r=r.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_finalizeAbsPath(e,t){return e===null?null:super._finalizeAbsPath(e,t)}_resolveSymbolicDatapath(e,t){let r=e.slice(1).split(".",1)[0];if(r==="FORM"||r==="ANCHOR")return super._resolveSymbolicDatapath(e,t);let i=this.rootBuilder?.binding;if(!i)return super._resolveSymbolicDatapath(e,t);let s=i.nodeIds.get(r);if(!s)throw new Error(`#<id>: cannot resolve ${t}`);let o=e.slice(r.length+2);return s.absDatapath(o?`.${o}`:".")}#i(e,t){if(H(t)){let s=$t(e,"datapath",e.parentNode);return s==null||s===""?null:s}let r=e.parentNode.absDatapath(t);if(r===null)return null;let i=this.data.getItem(r);return i==null||i===""?null:i}#s(e,t){return H(t)||typeof e!="string"||!e.endsWith("_path")?!1:(this.#e.has(e)||(this.#e.add(e),console.warn(`${this.nodeTag} '${this.label}': '${e}' holds a bare Data path; the pointer symbol of '${t}' is removed`)),!0)}#o(e){if(this.absDatapath(e)===null)throw new Error(`${this.nodeTag} '${this.label}': write on a null path: '${e}'`)}},de=class n extends A{get nodeClass(){return nr}authorizedCopy(e){let t=new this.constructor;for(let r of this.getNodes()){let i=r.getAttr("auth")??null;if(i!==null){if(typeof i!="string")throw new TypeError(`${r.nodeTag} '${r.label}': 'auth' must be a string rule, not ${typeof i}`);if(e(i)!==null)continue}let s=r.staticValue;s instanceof n&&(s=s.authorizedCopy(e));let{auth:o,...a}=r.getAttr(),l=t.setItem(r.label,s,a,">",!1,!1,null,!1,!0,null,r.nodeTag);l.xmlTag=r.xmlTag}return t}activateCode(){for(let e of this.getNodes())e.activateCode(),e.staticValue instanceof n&&e.staticValue.activateCode();return this}};if((je(de.tytxSuffix).GramlotBuilderBag??de)!==de)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");Gt(de.tytxSuffix,{...je(de.tytxSuffix),GramlotBuilderBag:de});var Eg=new Set(["animate","animateMotion","animateTransform","circle","ellipse","feBlend","feColorMatrix","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feGaussianBlur","feImage","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","image","line","metadata","path","polygon","polyline","rect","set","stop","use"]),Wn=class extends tr{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let r=this.owner.evaluateExpressions(e,t);Hr(e,r);let[i,s]=super._handleMeta(e,r);return zr(e,s),e._getMeta("subbuilder")?[i,us(hs(s))]:[i,s]}adaptAttrs(e){let{_meta:t,...r}=e;return Vn(super.adaptAttrs(Wr(Rt(r))))}renderedItem(e,t,r,i={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,r,i);let{_text:s,...o}=r;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&s!=null&&(t=[this._escapeText(Vr(s)),...t]),Eg.has(i.tag)?`${i.pretty?" ".repeat(this._nodeDepth(e,i.depthOffset??0)):""}<${i.tag}${this._formatAttrs(o)} />${i.pretty?`
185
+ `:""}`:super.renderedItem(e,t,o,i)}};var ir=class extends er{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof St?this.addRender(e,this):e instanceof Nt&&this.addRender(e,new Wn(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[r,i]=e.rootBuilder.runtimeValues(e),s=this.getRender(e.builder),[o,a]=s._handleMeta(e,i);return e._getMeta("subbuilder")||(a=s.adaptAttrs(a)),s.renderedItem(e,e.value instanceof A?this.renderChildren(e.value,t):r,a,{tag:o,...t})}_handleMeta(e,t){let r=this.builder.constructor.dialectPrefixes,i=this.evaluateExpressions(e,t);Hr(e,i,r);let[s,o]=super._handleMeta(e,yc(e,i,r));if(zr(e,o,r),e.nodeTag==="webcomponent"){s=ct(e.getAttr());let{code:u,...c}=o;o=c}if(e._getMeta("subbuilder")){let u=hs(o);return e._getMeta("subbuilder")==="html"&&(u.xmlns=Bt),[s,u]}let[a,l]=vc(s,o);return Object.keys(l).length&&this.#e.set(e,l),[s,a]}evaluateExpressions(e,t){let r=this.inlineCompiler,i=(o,a)=>r?r.compileExpression(e,o,a)(t):null,s={...t};for(let[o,a]of _e(e.getAttr()))e.nodeTag==="menuline"&&["caption","icon","tooltip","command"].includes(o)||Fe(a)&&Object.hasOwn(s,o)&&(s[o]=i(o,a));return Fe(e.value)&&this.#t.set(e,i("",e.value)),s}expressionValue(e,t){return Fe(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let r=this.#e.get(e);return r?(this.#e.delete(e),{...t,...Wr(r)}):t}adaptAttrs(e){let{_meta:t,...r}=e,i=`${this.builder.constructor._name}_`,s=this.builder.constructor.dialectPrefixes,o={},a={};for(let[l,u]of Object.entries(Rt(r))){if(u==null)continue;if(l.startsWith(i))throw new Error(`${l}: the attribute prefix '${i}' is not accepted; use the prefix '${s[0]}'`);let c=s.find(d=>l.startsWith(d));c?o[l.slice(c.length)]=u:a[l]=u}return Vn({...super.adaptAttrs(a),...o})}renderedItem(e,t,r,i={}){let s;[t,s]=zn(this.expressionValue(e,t),this.restoreNativeAttributes(e,r));let{_text:o,...a}=s;Array.isArray(t)&&o!=null&&(t=[this._escapeText(Vr(o)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:we,...a}:a;return super.renderedItem(e,t,l,i)}finalize(e,t=null,r={}){if(!r.doctype)return super.finalize(e,t,r);let i=this._composeStringFragments(e),s=this.builder.source.getNodes().filter(o=>!o._getMeta("data_element"));return s.length===1&&s[0].nodeTag==="html"||(i=`<html>${i}</html>`),super.finalize(`<!doctype html>${i}`,t,r)}};var Ac={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"binding",version:null,title:"Gramlot binding",description:"Gramlot Data declarations and the plain HTML button; loaded after the HTML grammar."},abstracts:{},elements:{dataSetter:{doc:"Initial Data value, written literally at destination_path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!0,default:null},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:"Computed Data value written at result_path; formula is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"formula",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:"Side effects on Data; script is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"script",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRpc:{doc:"Server endpoint called through gramlot.rpc; the value is written at result_path when given.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"timeout",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRemote:{doc:"Data node resolved by a server endpoint through gramlot.rpc, on first read and again when cacheTime expires; with sync (default) the read waits for the answer when the transport supports it.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"cacheTime",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"sync",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"bool"},has_default:!0,default:!0},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},html_button:{doc:"Plain native HTML button without Gramlot click mechanisms.",sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{render_tag:"button"}},html_dialog:{doc:"Native HTML dialog, distinct from the layout window component.",sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{render_tag:"dialog"}}}};var Tc={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"webcomponent",version:null,title:"Gramlot webcomponent",description:"An explicitly loaded autonomous custom element."},abstracts:{},elements:{webcomponent:{doc:"Create the custom-element tag named by literal code.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"code",kind:"keyword_only",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null}}};function Q(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("")}var Ag="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",Tg=new Set,Dg=new Set(["serverpath","dbenv","shared_id"]),Cg=["formsubscribe_"],Sg={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},Ng={dataFormula:"formula",dataController:"script"};function Dc(n,e){if(["input","textarea","select","webcomponent"].includes(n)&&H(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(n==="html_button"&&Object.keys(e).some(i=>["action","ask","_delay","fire"].includes(i)||i.startsWith("fire_")))return"plain HTML button: use button for action, ask, fire or _delay";if(Object.hasOwn(e,"ask")&&!["button","toggleButton","dropDownButton","menuline"].includes(n))return"'ask' is supported on buttons";if(Object.hasOwn(e,"_ask")&&!["dataController","dataFormula","dataRpc"].includes(n))return"'_ask' requires a controller, formula or RPC";if(["dataSetter","dataRemote"].includes(n)&&Object.keys(e).some(i=>i.startsWith("subscribe_")||i.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=Sg[n];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let r=Ng[n];return r&&e[r]!=null&&e.func!=null?`'func' and '${r}' cannot be declared on the same node`:r&&e._if!=null&&e.func!=null?"'_if' is inline and cannot be declared with 'func': write the condition in the method":null}function Cc(n){return Object.keys(n).find(e=>Dg.has(e)||Cg.some(t=>e.startsWith(t)))}var Oe=class n extends St{static _name="gramlot";static _sourceClass=de;static{this.defineGrammar(Ac)}static{this.defineGrammar(Tc)}static{this.defineGrammar(ms.toDocument())}static get dialectPrefixes(){let e=[];for(let t=Object.getPrototypeOf(n);t&&t!==Function.prototype;t=Object.getPrototypeOf(t))Object.hasOwn(t,"_name")&&t._name&&e.push(`${t._name}_`);return e}constructor(e=null,{collections:t=[],auth:r=null,nameSyntax:i=Un}={}){if(!(i instanceof rr))throw new TypeError(`nameSyntax must be a NameSyntax, not ${i}`);super(e),this._binding=null,this._auth=r,this._nameSyntax=i;for(let s of t)this.loadCollection(s)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,r,i,s){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,r,i.text)(s):null}nodeById(e){if(!this.binding)return super.nodeById(e);let t=this.binding.nodeIds.get(e);if(!t)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}loadCollection(e){return this.loadGrammar(e instanceof It?e.toDocument():e),this}schemaTag(e){let t=e.toLowerCase(),r=n.dialectPrefixes;if(t.startsWith(`${n._name}_`))throw new Error(`${e}: the tag prefix '${n._name}_' is not accepted; use the prefix '${r[0]}'`);if(Tg.has(t))throw new Error(`${e}: excluded from Gramlot`);let i=this.schemaTagNames[t];if(i)return i;for(let s of r)if(t.startsWith(s)&&this.schemaTagNames[t.slice(s.length)])return t;return null}bagCall(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.bagCall(e,t,r,i)}commandOnNode(e,t,r,i){return t=this.#e(t),[r,i]=this.menuArguments(t,r,i),super.commandOnNode(e,t,r,i)}menuArguments(e,t,r={}){if(e==="menu"&&t==null)return[new de(null,this),r];if(e==="menuline"&&t!=null&&t!=="-"){if(Object.hasOwn(r,"command"))throw new TypeError("menuline command must be declared once");return[null,{...r,command:t}]}return[t,r]}validateNodeValues(e,t,r={}){if(this.schema[e]?._meta?.gramlot_component&&H(r.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&ct(r);let i=Cc(r);if(i)throw new Error(`${e}: attribute '${i}' is excluded from Gramlot`);let s=Dc(e,r);if(s)throw new Error(`${e}: ${s}`);return super.validateNodeValues(e,t,r)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&H((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&ct(t.attrs??e.getAttr());let r=Cc(t.attrs??e.getAttr());if(r)throw new Error(`${e.nodeTag} '${e.label}': attribute '${r}' is excluded from Gramlot`);let i=Dc(e.nodeTag,t.attrs??e.getAttr());if(i)throw new Error(`${e.nodeTag} '${e.label}': ${i}`);return super.validateNode(e,t)}_validateChildren(e,t,r,i){return super._validateChildren(e,t,r.map(s=>s==="html_button"?"button":s==="html_dialog"?"dialog":s),i)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,r,i,s=null){i=Object.fromEntries(Object.entries(i??{}).map(([l,u])=>[l,J(u)instanceof Ae?this.reference(u):u]));let a=t==="dataSetter"&&i?.value!==null&&typeof i?.value=="object"&&Object.getPrototypeOf(i.value)===Object.prototype?{...i,value:new x(i.value)}:i;return super.setChild(e,t,r,a,s)}#e(e){if(e==="data")throw new Error(Ag);if(this.schemaTagNames[e.toLowerCase()]===e)return e;let t=n.dialectPrefixes.find(r=>e.startsWith(r));return this.schemaTagNames[e.slice(t.length)]}get renderer_html(){return new ir(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,r){let i=t!=null?{_text:t}:null;e.setValue(r,!0,i,!0)}reference(e,t="node"){if(e=J(e),!(e instanceof Ae)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let r=e.getAttr("__ref");return r==null&&(r=Q(),e.setAttr({__ref:r})),{$gramlotRef:r,kind:t}}toTytx(){return U(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function Gn(n){return typeof n=="string"&&!["null","true","false"].includes(n)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(n)}function sr(n,e,t,r){let{group:i,method:s}=n.logicRegistry.resolve(t,e);return s.call(i,e,r)}function rt(n,e,t,r,i,s=Object.keys(i)){return Gn(r)?sr(n,e,r,i):n.inlineCompiler.compile(e,t,r,s)(i)}var Ig=new Set(["input","select","textarea"]),Og=["type","multiple"];function Sc(n,e){let t=n.node,r=t.getAttr(e);return t.pointerType(r)?t.getRelativeData(r):n.resolved[e]}var ye=class n{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#n;#i=!1;#s=!1;#o=!1;static for(e,t){let r=n.classFor(t.element,t.attrs);return r?new r(e,t):null}static classFor(e,t){if(e.namespaceURI!==we)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?da:aa;if(e.localName==="textarea")return nt;if(e.localName==="select")return Xn;if(e.localName!=="input")return null;let r=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(Nc,r)?Nc[r]:nt}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([]):e?.namespaceURI!==we||!Ig.has(e.localName)?null:JSON.stringify(Og.filter(r=>(r!=="type"||e.localName!=="input")&&(r!=="multiple"||!["input","select"].includes(e.localName))).map(r=>t[r]??null))}constructor(e,t){this.#r=e,this.#n=t}get binding(){return this.#r}get element(){return this.#n.element}get node(){return this.binding.node}get eventElement(){return this.element}get resolved(){return this.#n.resolved}get live(){return!!this.resolved.live}get writeEvent(){return this.constructor.liveWrites&&this.live?"input":"change"}project(e,t){if(this.#s){this.#o=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)&&(!this.#i||this.same(this.read(),e))||(this.#e=e,this.#t=!0,!(this.#i&&this.same(this.read(),e))&&(this.constructor.writesDefault&&!this.node.pointerType(this.node.getAttr("value"))&&this.writeDefault(e),this.write(e)))}read(){return this.element.value}write(e){let t=e==null?"":String(e);this.element.value!==t&&(this.element.value=t)}writeDefault(e){let t=e==null?"":String(e);this.element.localName==="textarea"?this.#n.text.data!==t&&(this.#n.text.data=t):this.element.defaultValue!==t&&(this.element.defaultValue=t)}same(e,t){return Object.is(e,t)}commit(e,t=this.read()){if(!this.binding.closed){this.#i=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#i=!1}}}attach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.addEventListener(e,this)}detach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.removeEventListener(e,this);this.#o=!1}refresh(){}handleEvent(e){if(!this.binding.closed){if(e.type==="compositionstart"){this.#s=!0;return}if(e.type==="compositionend"){this.#s=!1,this.writeEvent==="input"&&this.commit(e),this.#o&&(this.#o=!1,this.binding.runtime.renderer.project(this.node));return}this.#s||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},aa=class extends ye{static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.element.setPageContext(Ic(this)),super.attach()}project(e,t){this.element.shouldProjectControlValue(e)&&super.project(e,t)}same(e,t){return this.element.sameControlValue(e,t)}detach(){this.element.releaseControl(),super.detach()}commit(e){this.binding.closed||this.element.control.disabled||this.element.control.readOnly||Oc(this.element,this.element.acceptControlValue(),t=>super.commit(e,t.value))}get writeEvent(){return this.element.commitOnChange?"change":(this.resolved.live??this.element.parameters.live)&&this.element.liveWrites?"input":"change"}read(){return this.element.readControlValue()}write(e){this.element.writeControlValue(e)}handleEvent(e){if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.element.ownerDocument.defaultView.Event;this.element.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}},nt=class extends ye{static liveWrites=!0},la=class extends ye{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},ua=class extends ye{static liveWrites=!0;read(){return Number(this.element.value)}},Xn=class extends ye{static writesDefault=!1;read(){return this.element.multiple?[...this.element.selectedOptions].map(e=>e.value):this.element.selectedIndex===-1?null:this.element.value}write(e){let t=this.element;if(t.multiple){if(e!=null&&!Array.isArray(e))throw new TypeError(`${this.node.nodeTag} '${this.node.label}': a multiple select requires an array`);let r=new Set((e??[]).map(String));for(let i of t.options){let s=r.has(i.value);i.selected!==s&&(i.selected=s)}}else e==null?t.selectedIndex!==-1&&(t.selectedIndex=-1):(t.selectedIndex===-1||t.value!==String(e))&&(t.value=String(e))}same(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&t.every((r,i)=>Object.is(r,e[i])):super.same(e,t)}},or=class extends ye{read(){return this.element.value===""?null:this.element.value}},ca=class extends ye{},gs=class extends ye{static writesDefault=!1;read(){return this.element.checked}write(e){let t=!!e;this.element.checked!==t&&(this.element.checked=t)}same(e,t){return e===!!t}attach(){let e=this.node;if(e.getAttr("checked")!=null&&e.pointerType(e.getAttr("value"))==="^")throw new TypeError(`${e.nodeTag} '${e.label}': checked and a ^ value are two sources`);super.attach()}},Gr=class extends gs{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,r=fa(e);if(t!=null){if(e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);this.#r(t,r)}super.attach(),t!=null&&(this.#e=this.groups.join(this,t,r),this.element.setAttribute("name",this.#e))}detach(){this.#e!==null&&(this.groups.leave(this),this.element.removeAttribute("name"),this.#e=null),super.detach()}refresh(e=this.resolved.group){let t=this.resolved.group??null,r=fa(this.node);if(!Object.is(e??null,t)){let i=new Set([this,...this.groups.peers(this),...t===null?[]:this.groups.peersOf(t,r)]);this.groups.leave(this),this.#e=t===null?null:this.groups.join(this,t,r),this.#e===null?this.element.removeAttribute("name"):this.element.setAttribute("name",this.#e);for(let s of i){if(this.binding.closed||!this.binding.runtime.renderer.attached(this.node))return;s.binding.closed||!s.binding.runtime.renderer.attached(s.node)||s.binding.runtime.renderer.html.writeParameter(s.node,"value",!1)}return}this.#e!==null&&this.groups.nameOf(t,r)!==this.#e&&(this.#r(t,r),this.groups.leave(this),this.#e=this.groups.join(this,t,r),this.element.setAttribute("name",this.#e))}#r(e,t){let r=this.node;if(Sc(this,"value")&&this.groups.peersOf(e,t).some(i=>!i.binding.closed&&i.read()))throw new Error(`${r.nodeTag} '${r.label}': several true values in radio group '${e}'`)}project(e,t){let r=!this.#t;this.#t=!0;let i=this.read();super.project(e,t),!r&&!i&&this.read()&&this.turnOffPeers()}commit(e){let t=this.read();super.commit(e),t&&!this.binding.closed&&this.turnOffPeers()}turnOffPeers(){if(this.#e!==null)for(let e of this.groups.peers(this)){if(this.binding.closed)return;e.binding.closed||(e.element.checked&&(e.element.checked=!1),Sc(e,"value")&&e.commit(null))}}},da=class extends Gr{static writesDefault=!1;get host(){return super.element}get element(){return this.host.control}project(e,t){this.host.shouldProjectControlValue(e)&&super.project(e,t)}commit(e){this.binding.closed||this.element.disabled||this.element.readOnly||Oc(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(Ic(this)),super.attach(),this.element.addEventListener("keydown",this)}detach(){this.host.releaseControl(),this.element.removeEventListener("keydown",this),super.detach()}handleEvent(e){if(!this.binding.closed){if(e.type==="keydown"){if(this.resolved.group==null||!["ArrowLeft","ArrowUp","ArrowRight","ArrowDown"].includes(e.key))return;let t=this.groups.peersOf(this.resolved.group,fa(this.node)).filter(o=>!o.binding.closed&&!o.element.disabled),r=t.indexOf(this);if(r<0)return;e.preventDefault();let i=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,s=t[(r+i+t.length)%t.length];s.element.focus(),s.element.click();return}if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.host.ownerDocument.defaultView.Event;this.host.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}}},bs=class{#e;#t=new Map;#r=new Map;#n=new WeakMap;#i=0;constructor(e){this.#e=e}join(e,t,r){let i=this.nameOf(t,r);return this.#t.has(i)||this.#t.set(i,new Set),this.#t.get(i).add(e),this.#r.set(e,i),i}leave(e){let t=this.#r.get(e);this.#r.delete(e);let r=this.#t.get(t);r?.delete(e),r?.size===0&&this.#t.delete(t)}peers(e){let t=this.#r.get(e);return[...this.#t.get(t)??[]].filter(r=>r!==e)}peersOf(e,t){return[...this.#t.get(this.nameOf(e,t))??[]]}nameOf(e,t){t!==null&&!this.#n.has(t)&&this.#n.set(t,this.#i++);let r=t===null?"page":`form${this.#n.get(t)}`;return`gramlot-${this.#e.instanceId}-${r}-${e}`}};function fa(n){for(let e=n;e;e=e.parentNode){let t=e.getAttr()??{};if(t.formId!=null||t.form===!0)return e}return null}var Nc={text:nt,password:nt,email:nt,url:nt,tel:nt,search:nt,number:la,range:ua,color:ca,date:or,time:or,month:or,week:or,"datetime-local":or,checkbox:gs,radio:Gr,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function Ic(n){let{binding:e,node:t}=n,r=e.runtime.gramlot,i=(s,o,a,l=!1)=>l?e.runtime.inlineCompiler.compile(t,s,o,Object.keys(a),`return (${o});`)(a):rt(e.runtime,t,s,o,a);return{locale:r.locale,timeZone:r.timeZone,createDecimal:At,isDecimal:be,getDecimalLibrary:zo,publish:(s,o)=>t.publish(s,o),isActive:()=>!e.closed,reportError:(s,o)=>{e.closed||e.runtime.reportError(s,o)},callLogic:(s,o)=>sr(e.runtime,t,s,o),format:(s,o)=>r.format(s,o),invoke:i,remote:(s,o,a)=>r.rpc.call("data",s,o,{signal:a}),selectionOutputs:({selectedCaption:s,selectedRecord:o,fields:a},l)=>{if(!e.closed){s&&t.setRelativeData(s,l?.caption??null),o&&t.setRelativeData(o,l?new x(l.record):null);for(let[u,c]of Object.entries(a))t.setRelativeData(c,l?.record[u.slice(9)]??null)}},validationCurrent:()=>{let s=t.getAttr("value"),o=t.pointerType(s)?t.absDatapath(s):null;return()=>!e.closed&&t.getAttr("value")===s&&(o===null||t.absDatapath(s)===o)},finishValidation:({ok:s,result:o,rules:a})=>{if(e.closed)return;if(s)for(let u of o.datachanges)t.getRelativeData(".").update(u);let l=s?"validate_onAccept":"validate_onReject";if(a[l]){let u=c=>{e.closed||e.runtime.reportError(c,"Validation callback failed")};try{let c=Object.fromEntries(Object.entries(a).map(([f,h])=>[f.slice(9),h])),d=i(l,a[l],{value:o.value,result:o,validations:c,userChange:!0});d instanceof Promise&&d.catch(u)}catch(c){u(c)}}},checkDataPatch:s=>{if(!(s instanceof x))throw new TypeError("Validation data changes must be a Bag.");if(!(t.getRelativeData(".")instanceof x))throw new TypeError("Validation data changes require a Bag datapath.")}}}function Oc(n,e,t){let r=n.pageContext,i=s=>{s.ok&&s.isCurrent()&&(t(s),n.finishValidation(s))};if(e instanceof Promise)e.then(i).catch(s=>r.reportError(s,"Field update failed"));else try{i(e)}catch(s){r.reportError(s,"Field update failed")}}var ha=Symbol("source text"),Bc={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Bg=new Set(["allowFullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formNoValidate","hidden","inert","isMap","itemscope","loop","multiple","muted","noModule","noValidate","open","playsInline","readOnly","required","reversed","selected"]),Rg=new Set(["checked","muted","selected","value"]),$g=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function Mg(n){let e=n.replace(/-([a-z])/g,(t,r)=>r.toUpperCase());return $g.get(e.toLowerCase())??e}var _s=class{constructor({metadataAttributes:e=[],invokeScript:t=null,callLogic:r=null,reportError:i=null}={}){this.invokeScript=t,this.callLogic=r,this.reportError=i,this.metadataAttributes=new Set([...Xt,"_text",...e])}definition(e){let t=e.builder,i={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},s=e.nodeTag==="webcomponent"?ct(e.getAttr()):Mn(e.nodeTag,{renderTag:i.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),o=s==="foreignObject"?Bt:i.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof Nt?Bt:we);return{meta:i,namespace:o,tag:s}}validate(e,t=e.builder){this.validateLabelbox(e);let r=e.value instanceof A,i=r?e.getAttr("_text"):e.value;if(i!=null&&!["string","number","boolean"].includes(typeof i))throw new TypeError("HTML text must be scalar");for(let[a,l]of Object.entries(e.attr))if(!(a==="value"&&this.definition(e).meta.gramlot_component)&&!(e.nodeTag==="menuline"&&a==="parameters")&&!(this.metadataAttributes.has(a)||["ask","_ask"].includes(a)||l&&typeof l=="object"&&Object.hasOwn(l,"$gramlotRef"))&&l!=null&&!["string","number","boolean"].includes(typeof l))throw new TypeError(`HTML attribute ${a} must be scalar`);let s=Object.fromEntries(Object.entries(e.attr).filter(([a])=>!this.metadataAttributes.has(a))),o=r?e.value.getNodes().map(a=>a.nodeTag).filter(Boolean):[];t.validateNode(e,{value:i,attrs:s,childTags:o})}hasLabelbox(e){let t=this.definition(e).meta.gramlot_component;return t?.labelbox?!0:t?.presentationDefaults.length?Object.hasOwn(e.attr,"lbl"):Object.keys(e.attr).some(r=>r==="lbl"||r.startsWith("lbl_")||r.startsWith("box_"))}validateLabelbox(e){if(!this.hasLabelbox(e))return;let{tag:t,namespace:r}=this.definition(e);if(r!==we&&t!=="svg"||["html","head","body","style","script","link","meta","title","base","tr","td","th","thead","tbody","tfoot","col","colgroup","caption","option","optgroup","li","dt","dd","source","track","param","area"].includes(t))throw new TypeError("Labelbox requires content that can be placed in an HTML flow container");let i=e.parentNode;if(i?.nodeTag){let s=this.definition(i);if(s.namespace!==we&&s.tag!=="foreignObject"||["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","ul","ol","dl","p","button","label"].includes(s.tag))throw new TypeError("Labelbox requires an HTML flow container")}}create(e,t,r=null,i=e.attr,s=null){let{tag:o,namespace:a,meta:l}=this.definition(e);r??=o;let u=a===we?t.createElement(r):t.createElementNS(a,r);if(l.gramlot_component&&u.constructor.gramlotComponent?.tag!==r)throw new Error(`Component collection must be activated before rendering ${r}`);l.gramlot_component?.dataScope&&(u.readDataScope=()=>{if(!e.getAttr("datapath"))throw new Error("Data scope requires an explicit datapath");return e.getRelativeData(".")}),l.gramlot_component?.sourceContext&&u.setSourceContext({reportError:(f,h)=>this.reportError(e,f,h),publish:(f,h)=>e.publish(f,h),writeParameter:(f,h)=>this.writeParameter(e,f,h),callLogic:(f,h)=>this.callLogic(e,f,h)});let c=t.createTextNode(this.text(e));(a!==we||!l.void)&&u.append(c);let d={element:u,text:c,tag:r,presentation:u};if(this.hasLabelbox(e)){this.validateLabelbox(e);let f=t.createElement("div");f.append(u),d.labelbox=fc(t,f),d.presentation=d.labelbox.box,d.labelId=`gramlot-label-${Q()}`,d.controlId=`gramlot-control-${Q()}`;let h=t.createElement("style");h.textContent=dc,d.presentation.prepend(h),l.gramlot_component?.labelbox&&u.setLabelbox(d.labelbox)}return this.update(d,e,i,ha,s),d}matches(e,t){let{tag:r,namespace:i}=this.definition(t);return(i===we?e.tag.toLowerCase()===r.toLowerCase():e.tag===r)&&e.element.namespaceURI===i}writeParameter(e,t,r){let i=e.getAttr(t);e.pointerType(i)==="^"&&!H(i)&&!Object.is(e.getRelativeData(i.slice(1)),r)&&e.setRelativeData(i.slice(1),r)}compose(e,t,r){e.text.data=t??"";for(let i of r)e.element.append(i)}update(e,t,r=t.attr,i=ha,s=null){if(t.nodeTag==="script"){for(let[b,g]of t.codeAttributes())if(t.activatedCode(b)!==g)throw new Error(`script '${t.label}': '${b}' runs only as received with the Source`)}let{element:o,text:a}=e;if(this.hasLabelbox(t)&&!e.labelbox)throw new TypeError("Declare lbl or box_* when creating an experimental HTML labelbox");let l=o.namespaceURI===we,u=this.definition(t).meta.render_attributes??{},c=e.attrs??{},d=b=>(Hr(t,b,t.builder.constructor.dialectPrefixes),zr(t,b,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(b)),f=t.parentNode;f?._getMeta("gramlot_component")?.childParameters&&(r=o.ownerDocument.defaultView.customElements.get(f._getMeta("render_tag")).projectChild(e.presentation,r,{label:t.label,adapt:d,invoke:(g,_,w)=>this.invokeScript(t,g,_,w),reportError:(g,_)=>this.reportError(t,g,_),publish:(g,_)=>t.publish(g,_),publishParent:(g,_)=>f.publish(g,_),writeParameter:(g,_)=>this.writeParameter(t,g,_),remove:()=>t.parentBag.popNode(t.label)})),e.labelbox&&(e.labelbox.box.style.visibility="",hc(e.labelbox,r,d)),this.definition(t).meta.gramlot_component&&(this.definition(t).meta.gramlot_component.bagStore&&o.setStoreBag(t.getRelativeData(t.getAttr("storepath"))),r=o.projectAttributes(r,d)),e.labelbox&&(r=Object.fromEntries(Object.entries(r).filter(([b])=>b!=="lbl"&&!b.startsWith("lbl_")&&!b.startsWith("box_"))),r.slot!=null?e.presentation.setAttribute("slot",r.slot):e.presentationSlot!=null&&e.presentation.removeAttribute("slot"),e.presentationSlot=r.slot,delete r.slot),r=Object.fromEntries(_e({...r,...u}));let h=ye.classFor(o,r)!==null;i===ha&&(i=this.text(t));let m=i==null?"":String(i);a.data!==m&&(a.data=m);let p=[...new Set([...Object.keys(c),...Object.keys(r)])];p.sort((b,g)=>(g==="sandbox")-(b==="sandbox")||(l&&o.localName==="input"?(g==="type")-(b==="type"):0));for(let b of p){if(this.metadataAttributes.has(b)||["ask","_ask"].includes(b)||h&&b==="value")continue;let g=r[b];if(l&&b==="multiple"&&["input","select"].includes(o.localName)){o.multiple!==!!g&&(o.multiple=!!g);continue}if(l&&o.localName==="input"&&b==="type"){Object.is(c.type,g)||(g==null?o.removeAttribute("type"):o.type=String(g));continue}let _=b,w=Mg(_),E=l&&Bg.has(w)&&typeof o[w]=="boolean",D=_==="xmlns"?"xmlns":_.includes(":")?_.split(":")[0]:"",y=Object.hasOwn(Bc,D)?Bc[D]:null;if(Object.is(c[b],g)||(g==null||E&&!g?y?o.removeAttributeNS(y,_.split(":").at(-1)):o.removeAttribute(_):y?o.setAttributeNS(y,_,String(g)):o.setAttribute(_,E?"":String(g))),l&&(E||Rg.has(w))&&w in o){let T=w==="value"?g==null?"":String(g):!!g;o[w]!==T&&(o[w]=T)}}if(s===!1?o.style.visibility!=="hidden"&&(o.style.visibility="hidden"):e.visible===!1&&(r.style==null?o.removeAttribute("style"):o.setAttribute("style",String(r.style))),e.visible=s,e.labelbox){let{fieldLabel:b,labelBox:g,box:_}=e.labelbox;["input","textarea","select","button","output","meter","progress"].includes(e.tag)?(o.id||(o.id=e.controlId),b.htmlFor=o.id):(b.id=e.labelId,this.definition(t).meta.gramlot_component?.labelbox||(_.setAttribute("role","group"),g.hidden?_.removeAttribute("aria-labelledby"):_.setAttribute("aria-labelledby",b.id))),_.hidden=!!r.hidden,s===!1&&(_.style.visibility="hidden")}e.attrs=r}text(e){return e.value instanceof A?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};function Lg(n){for(let e=n.parentNode;e;e=e.parentNode)if(e.nodeTag==="framePane")return e;return null}function Rc(n){if(!n||!(n.value instanceof A))return null;let e=n.value.getNodes().find(i=>i.getAttr("region")==="center"),t=[];function r(i){if(i.nodeTag!=="framePane"&&(i.getAttr("frameTarget")===!0&&t.push(i),i.value instanceof A))for(let s of i.value.getNodes())r(s)}return e&&r(e),t.length===1?t[0]:null}function Pg(n){if(n.closed||!n.runtime.renderer.attached(n.node))return!1;for(let e=n.node;e;e=e.parentNode){let[,t]=e.rootBuilder.runtimeValues(e);if(t.hidden===!0||t.disabled===!0)return!1}return!0}function $c(n){if(n&&typeof n=="object"){for(let e of Object.values(n))$c(e);Object.freeze(n)}return n}function Mc(n,e){let t=n.node,r=t.getAttr("command"),i=n.runtime.gramlot.commands.get(r),s=Lg(t),o=Rc(s);if(!i||!o)return console.warn(`Cannot dispatch command '${r}' at '${t.label}': missing or duplicate frame recipient`),null;let a=t.getAttr("parameters")??{};if(typeof a!="object"||Array.isArray(a))throw new TypeError("Command parameters require a mapping");let l=Object.fromEntries(Object.entries(a).map(([p,b])=>[p,t.pointerType(b)?t.getRelativeData(b):b])),u=$c(j(U(l))),c=Object.freeze(Object.fromEntries(["shift","ctrl","alt","meta"].map(p=>[p,!!e[`${p}Key`]]))),d=Object.freeze({sender:t,target:o,command:r,parameters:u,modifiers:c}),f=!1,h=n.runtime.bindingFor(o).track(()=>{f=!0}),m=()=>!f&&Pg(n)&&Rc(s)===o&&n.runtime.renderer.attached(o)&&t.getAttr("command")===r;return{message:d,current:m,release:h,cancel(){f=!0},deliver(){m()&&o.publish(i.publish,d)}}}var ws=class n{#e;#t;#r=null;#n=0;#i=new Set;#s=null;static for(e,t){return t.element?.constructor.gramlotComponent?.command?new n(e,t):null}constructor(e,t){this.#e=e,this.#t=t}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get controllers(){let e=this.node.value;return e?.getNodes?e.getNodes().filter(t=>t.nodeTag==="dataController"||t.nodeTag==="dataRpc"):[]}get mechanism(){let e=this.node,t=this.controllers;if(t.length>1)throw new Error(`${e.nodeTag} '${e.label}': several dataController or dataRpc children; a button has one click mechanism`);let r=e.getAttr()??{},i=[];if(t.length&&i.push("controller"),r.action!=null&&i.push("action"),e.nodeTag==="menuline"&&r.command!=null&&i.push("registered"),Lc(r).length&&i.push("fire"),e.nodeTag==="menuline"&&e.value instanceof A&&e.value.getNodes().some(s=>s.nodeTag==="menu")&&i.length)throw new Error(`menuline '${e.label}': a submenu cannot also execute a command`);if(e.nodeTag==="menuline"&&r.group&&i.length)throw new Error(`menuline '${e.label}': a group cannot execute a command`);if(i.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${i.join(" and ")} together; a button has one click mechanism`);return i[0]??null}attach(){this.refresh(),this.element.activateCommand=e=>this.onClick(e),this.element.attachCommand(),this.element.addEventListener("click",this)}refresh(){if(this.node.nodeTag==="menuline"){let t=this.node.getAttr("command"),r=t?this.binding.runtime.gramlot.commands.get(t):null;this.element.setCommandDefinition(r,this.node.label),t&&!r&&this.#s!==t&&(console.warn(`Unknown command '${t}' in menu '${this.node.parentNode?.label}', entry '${this.node.label}'`),this.#s=t)}for(let t of this.#i)t.current()||t.cancel();this.mechanism&&this.node.getAttr("type")==null&&this.element.getAttribute("type")!=="button"&&this.element.setAttribute("type","button")}detach(){this.element.removeEventListener("click",this),this.element.releaseCommand(),delete this.element.activateCommand,this.#r?.();for(let e of this.#i)e.cancel(),e.release();this.#i.clear()}handleEvent(e){this.onClick(e)}onClick(e){if(this.binding.closed||this.element.disabled)return;let t=this.element.commandTarget(e);if(t===null)return;if(t!==this.element)return e.stopPropagation(),t.activateCommand(e);if(!this.element.prepareCommand(e))return;let r=this.mechanism;if(!r||(e.stopPropagation(),this.element.disabled))return;let i=r==="registered"?Mc(this.binding,e):null;if(r==="registered"&&!i)return;i&&this.#i.add(i);let s=this.binding.countClick(),o=this.node;for(;o&&o.getAttr("_delay")==null;)o=o.parentNode;let a=o?o.rootBuilder.runtimeValues(o)[1]._delay:0;if(a>0){let l=this.#n+1;this.#r?.(),this.#n=l;let u=setTimeout(()=>{c(),this.#r=null,this.#n=0,this.#a(e,l,i)},a),c=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(u),i&&(i.cancel(),i.release(),this.#i.delete(i)),c(),this.#r=null,this.#n=0};return}return this.#r?.(),this.#a(e,s,i)}async#o(e){try{if(!e.current())return;let t=this.node.getAttr("ask"),r=this.binding.runtime.askDialog,i={...e.message.parameters};if(t&&r.required(this.binding,t,i,"ask")&&await r.show(this.binding,t,i)===null)return;e.deliver()}finally{e.release(),this.#i.delete(e)}}#a(e,t,r=null){if(r)return this.#o(r);if(this.binding.closed||this.element.disabled)return;let i=this.mechanism;if(!i)return;let s=this.node,o=jg(e);if(i==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t});else if(i==="action"){let a=()=>{let[,d]=s.rootBuilder.runtimeValues(s),f=Object.fromEntries(Object.entries(d).filter(([h])=>h!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(f),event:e,_counter:t,modifiers:o}},l=d=>{if(this.binding.closed||this.element.disabled||d===null)return;let f={...a(),...d};d&&(f._askResult=d),rt(this.binding.runtime,s,"action",s.getAttr("action"),f)},u=s.getAttr("ask"),c=this.binding.runtime.askDialog;if(u&&c.required(this.binding,u,a(),"ask"))return c.show(this.binding,u,a()).then(l);l(void 0)}else{let a={modifier:o,_counter:t},l=s.getAttr("fire");if(l!=null){s.FIRE(l,o||!0,a);return}for(let[u,c]of Lc(s.getAttr())){if(this.binding.closed)return;s.FIRE(c,u.slice(5),a)}}}};function Lc(n){return Object.entries(n??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function jg(n){return["shift","ctrl","alt","meta"].filter(e=>n[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var We=class extends K{static classKwargs={...K.classKwargs,asBag:!1};constructor({cacheTime:e,onError:t}){super({cacheTime:e??-1}),this.onError=t,this.loading=null,this.loaded=!1,this.writing=!1}resolve({static:e=!1}={}){return!e&&!this.closed&&!this.loading&&!this.writing&&this.expired&&this.refresh(),this.cachedValue}refresh(){if(this.closed)return null;let e=this.startLoad(r=>this.#t(r));if(e===null)return null;let t=()=>{this.loading===e&&(this.loading=null)};return e.then(t,t),this.loading=e,e.catch(r=>{r?.name!=="AbortError"&&this.onError(r)}),e}resolveSync(e){return super.resolve(e)}prepareValue(e){return e}#e(){let e={...this._kw};for(let[t,r]of Object.entries(this.node?.attr??{}))this.constructor.internalParams.has(t)||(e[t]=r);return this._computeEffectiveFingerprint(e)}async#t(e){if(this.closed)return;let t=this.#e(),r=await this.loadAsync(e);if(this.closed||e.ignored)return;let i=this.prepareValue(r);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(i,this.cacheTime!==0):this.cachedValue=i}finally{this.writing=!1}return i}};var Xr=class extends We{static internalParams=new Set([...We.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:r,cacheTime:i,onCalling:s=null,onError:o,sync:a=!1}){super({cacheTime:i,onError:o}),this.binding=e,this.sync=a,this.method=t,this.params=r,this.onCalling=s}get closed(){return this.binding.closed}resolve(e={}){return this.sync?e.static||this.loading||this.writing?this.cachedValue:this.expired&&!this.binding.node.requests.calling(this.onCalling)?this.cachedValue:super.resolveSync(e):super.resolve(e)}load(){let e;try{e=this.binding.callSync("data",this.method,this.params)}catch(t){this.onError(t)}return this.loaded=!0,e}startLoad(e){let t=this.binding.node.requests;return t.calling(this.onCalling)?t.submit(this.method,this.params,e):null}loadAsync(e){return this.binding.call("data",e)}};var Pc=new Set(["kind","command","caption","icon","iconSrc","tooltip","disabled","hidden","checked","favorite","parameters","resolver","cacheTime","sync"]);function jc(n,e=new Set){if(!(n instanceof x)||e.has(n))throw new TypeError("Menu resolver must return an acyclic Bag");let t=new Set([...e,n]);return n.getNodes().map(r=>{let i=r.attr,s=i.kind,o=r.staticValue;if(Object.keys(i).some(l=>!Pc.has(l)&&!l.startsWith("resolver_")))throw new TypeError(`Unsupported menu record field: ${r.label}`);if(!["command","separator","submenu"].includes(s))throw new TypeError(`Invalid menu kind: ${r.label}`);for(let l of["disabled","hidden","checked"])if(i[l]!=null&&typeof i[l]!="boolean"&&!(typeof i[l]=="string"&&i[l].startsWith("^")))throw new TypeError(`Invalid menu ${l}`);if(i.favorite!=null&&typeof i.favorite!="boolean")throw new TypeError("favorite must be boolean");if(i.caption!=null&&typeof i.caption!="string")throw new TypeError("Menu caption must be text");if(i.parameters!=null&&(typeof i.parameters!="object"||Array.isArray(i.parameters)))throw new TypeError("Menu parameters must be a mapping");if(s==="command"&&(typeof i.command!="string"||!i.command||o!=null||i.resolver!=null))throw new TypeError("Command record requires a command and no children/resolver");if(s==="separator"&&(o!=null||Object.keys(i).length!==1))throw new TypeError("Separator record accepts kind only");if(s==="submenu"&&(typeof i.caption!="string"||i.command!=null||o instanceof x==(i.resolver!=null)||!(o instanceof x)&&o!=null))throw new TypeError("Submenu requires caption and exactly one content source");let a=o instanceof x?jc(o,t):null;return{label:r.label,attrs:{...i},children:a}})}function Fc(n,e){let t=n.builder.wrapSource(n),r=n.value instanceof A?n.value.getNodes():[],i=new Set(e.map(s=>s.label));for(let s of r)i.has(s.label)||n.value.popNode(s.label);for(let[s,o]of e.entries()){let{kind:a,...l}=o.attrs,u=Object.fromEntries(Object.entries(l).filter(([m])=>m==="resolver"||m==="cacheTime"||m==="sync"||m.startsWith("resolver_")));for(let m of Object.keys(u))delete l[m];let c=a==="separator"?"-":null,d=n.value instanceof A?n.value.getNodes().find(m=>m.label===o.label):null,f=d?.value instanceof A;if(d&&(f!==(a==="submenu")||d.value==="-"!=(a==="separator"))&&(n.value.popNode(d.label),d=null),!d)d=J(t.menuline(c,{...l,node_label:o.label}));else{let m=Object.keys(d.attr).filter(p=>Pc.has(p)&&!Object.hasOwn(l,p));d.setAttr({...Object.fromEntries(m.map(p=>[p,null])),...l})}if(a==="submenu"){let m=d.value instanceof A?d.value.getNodes().find(p=>p.nodeTag==="menu"):null;m?m.setAttr({...Object.fromEntries(Object.keys(m.attr).filter(p=>p==="resolver"||p==="cacheTime"||p==="sync"||p.startsWith("resolver_")).map(p=>[p,null])),...u}):m=J(d.builder.wrapSource(d).menu({...u,node_label:"menu"})),o.children&&Fc(m,o.children)}let h=n.value.getNodes().indexOf(d);h!==s&&n.value.move(h,s)}}var ys=class{#e=null;#t=null;#r=0;#n=!1;#i=null;constructor(e,t){this.binding=e,this.element=t}get node(){return this.binding.node}attach(){this.element.menuBinding=this,this.refresh()}detach(){this.#n=!0,this.#r++,this.node.requests.inflight?.cancel(),delete this.element.menuBinding,this.element.close(!1)}refresh(){let[,e]=this.node.rootBuilder.runtimeValues(this.node),t=Object.fromEntries(Object.entries(e).filter(([i])=>i.startsWith("resolver_")).map(([i,s])=>[i.slice(9),s])),r=U([e.resolver,t,e.cacheTime,e.sync]);r!==this.#e&&(this.#e=r,this.#r++,this.#i=null,this.#t=e.resolver?new Xr({binding:this.binding,method:e.resolver,params:t,cacheTime:e.cacheTime??-1,sync:e.sync??!1,onError:()=>{}}):null,this.#t?(this.element.setStatus("loading"),this.element.opened&&this.element.isConnected&&this.load()):this.element.setStatus(null))}async load(e=!1){if(this.#n||!this.#t)return;let t=this.#t,r=this.#r;try{if(e?t.refresh():t.resolve(),t.loading&&(this.element.setStatus("loading"),await t.loading),this.#n||r!==this.#r)return;let i=t.cachedValue,s=jc(i),o=U(i);this.#i!==o&&(Fc(this.node,s),this.#i=o),this.element.setStatus(s.length?null:"empty")}catch(i){if(this.#n||r!==this.#r)return;this.element.setStatus("error"),console.warn(`Menu '${this.node.label}' failed to load`,i)}}};var vs="connect_on",Yn=class{#e;#t;#r;#n;#i;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,r])=>t.startsWith(vs)&&t.length>vs.length&&r!=null).map(([t,r])=>[t,t.slice(vs.length).toLowerCase(),r])}constructor(e,t,r,i,s=`${vs}${r}`){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get eventName(){return this.#r}get handler(){return this.#n}get attribute(){return this.#i}attach(){this.element.addEventListener(this.eventName,this)}detach(){this.element.removeEventListener(this.eventName,this)}handleEvent(e){if(this.binding.closed)return;let t=this.node,r=this.binding.runtime;if(Gn(this.handler))return sr(r,t,this.handler,e);r.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function Mt(n,e=new Set){if(!n||typeof n!="object")return;let t=n.ownerDocument?.defaultView?.Node??n.defaultView?.Node;if(J(n)instanceof Ae||t&&n instanceof t)throw new TypeError("Live Source/DOM references cannot cross a transport boundary");if(e.has(n))throw new TypeError("Transport data cannot contain circular references");e.add(n);let r=n instanceof x?n.getNodes().flatMap(i=>[i.staticValue,i.getAttr()]):Object.values(n);for(let i of r)Mt(i,e);e.delete(n)}var Zn=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let r=new Map,i=s=>{for(let o of s.getNodes()){let a=o.getAttr("__ref");if(a){if(r.has(a))throw new Error("Duplicate Source reference");let l=this.entries.get(a);if(e!==this.sourceRoot&&l&&l.node!==o&&!t.has(l.node))throw new Error("Duplicate Source reference");r.set(a,o)}o.value instanceof A&&i(o.value)}};i(e)}register(e,t){let r=e.getAttr("__ref");if(r){if(this.entries.has(r))throw new Error(`Duplicate Source reference: ${r}`);this.entries.set(r,{node:e,dom:t})}}remove(e){for(let[t,r]of this.entries)r.node===e&&this.entries.delete(t)}resolveArguments(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r&&typeof r=="object"&&Object.hasOwn(r,"$gramlotRef")?this.resolve(r):r]))}resolve(e){if(!e||!["node","dom"].includes(e.kind))throw new TypeError("Expected a node or DOM reference");let t=this.entries.get(e.$gramlotRef);if(!t)throw new Error("Source reference is not mounted");return t[e.kind]}};var Es=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},pa=class{#e;#t;#r;#n;#i;#s=!0;#o;constructor(e,{path:t,attr:r,recipient:i,order:s,subtree:o=!1}){this.#e=e,this.#t=t,this.#r=r,this.#n=i,this.#i=s,this.#o=o}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#n}get subtree(){return this.#o}get active(){return this.#s}get order(){return this.#i}close(){this.active&&(this.#s=!1,this.router.unregister(this))}},ma=class{constructor({evt:e,node:t,path:r,oldvalue:i,attrsDiff:s,reason:o,fired:a,level:l,registration:u}){this.evt=e,this.node=t,this.path=r,this.oldvalue=i,this.attrsDiff=s,this.reason=o,this.fired=a,this.level=l,this.registration=u}},xs=class{#e;#t=new Es;#r=new Map;#n=0;#i=0;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return this.#n}register({path:e,attr:t=null,recipient:r,subtree:i=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let s=this.#t;for(let a of e.split(".")){let l=s.children.get(a);l||(l=new Es(s,a),s.children.set(a,l)),s=l}this.#i+=1;let o=new pa(this,{path:e,attr:t,recipient:r,order:this.#i,subtree:i});return s.registrations.add(o),this.#r.set(o,s),this.#n+=1,o}unregister(e){let t=this.#r.get(e);if(t)for(this.#r.delete(e),t.registrations.delete(e),this.#n-=1;t.parent&&!t.children.size&&!t.registrations.size;)t.parent.children.delete(t.segment),t=t.parent}deliver(e){let{pathlist:t}=e;if(!t?.length||t[0]!==Fn||e.reason==="autocreate")return;let r=t.slice(1),i=e.evt==="ins"||e.evt==="del";for(let s of Array.isArray(e.node)?e.node:[e.node]){let o=i?[...r,s.label]:r,a=o.join(".");for(let[l,u]of this.#s(o,e))l.active&&l.recipient.receive(new ma({evt:e.evt,node:s,path:a,oldvalue:e.oldvalue??null,attrsDiff:e.attrs_diff??null,reason:e.reason??null,fired:e.fired??!1,level:u,registration:l}))}}#s(e,t){let r=[],i=this.#t;for(let o of e){for(let a of i.registrations)i!==this.#t&&this.#o(a,"child",t)&&r.push([a,"child"]);if(i=i.children.get(o),!i)return r.sort(([a],[l])=>a.order-l.order)}for(let o of i.registrations)this.#o(o,"node",t)&&r.push([o,"node"]);let s=[...i.children.values()];for(;s.length;){let o=s.pop();for(let a of o.registrations)this.#o(a,"container",t)&&r.push([a,"container"]);s.push(...o.children.values())}return r.sort(([o],[a])=>o.order-a.order)}#o(e,t,r){let{evt:i}=r;return e.subtree?t!=="container"||i!=="upd_attrs":e.attr===null?i==="upd_attrs"?!1:!(t==="child"&&r.fired):t==="child"?!1:t==="container"?i!=="upd_attrs":i==="ins"||i==="del"?!0:Object.hasOwn(r.attrs_diff??{},e.attr)}};var ks=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=Jn(e),r=this.setterNodes(e);ba(e);for(let i of r)this.applySetter(i),this.runtime.closeBranch(i),i.parentBag&&i.parentBag.popNode(i.label);this.applyDefaults(t.filter(i=>i.nodeTag&&!i._getMeta("data_element")))}setterNodes(e){return Jn(e).filter(t=>t.nodeTag==="dataSetter")}applySetter(e){let t=e.absDatapath(e.pathAttribute("destination_path"));if(t===null)return;let r=e.getAttr("value")??null,i=qg(e.getAttr()),s=this.runtime.data;if(r!==null)s.setItem(t,r,i,">",!1,!0,e),r instanceof x&&e.setAttr({value:null},!1);else{let o=s.getNode(t);o?i&&o.setAttr(i,!0):s.setItem(t,null,i,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let r=t.getAttr();for(let[i,s]of Object.entries(r)){if(!Fg(t,i,s))continue;let o=i==="value"?r.default_value??r.default:r[`default_${i}`];o!=null&&this.#t(t,s,o)}this.#r(t,r)}}#t(e,t,r){let i=e.absDatapath(t);if(i===null)return;let[s,o=null]=i.split("?",2),a=this.runtime.data,l=a.getNode(s);if(o===null){if(l&&l.value!==null&&l.value!==void 0)return;a.setItem(s,r,null,">",!1,!0,e)}else if(l){let u=l.getAttr(o);u==null&&l.setAttr({[o]:r},!0)}else a.setItem(s,null,{[o]:r},">",!1,!0,e)}#r(e,t){let r={};for(let[o,a]of Object.entries(t))o.startsWith("attr_")&&(r[o.slice(5)]=H(a)?$t(e,o):e.pointerType(a)?e.getRelativeData(a):a);if(!Object.keys(r).length)return;let i=[t.value,t.src].find(o=>e.pointerType(o));if(!i)return;let s=e.absDatapath(i);s!==null&&this.runtime.data.getNode(s.split("?",1)[0])?.setAttr(r,!0,!0,!1)}};function Fg(n,e,t){return e==="_meta"||Xt.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:n.pointerType(t)!==null}function qg(n){let e={};for(let[t,r]of Object.entries(Rt(n??{})))Xt.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||r!=null&&(e[t]=r);return Object.keys(e).length?e:null}function Ug(n){let e=n.builder;if(!(e instanceof Oe))throw new Error(`dataSetter '${n.label}': dataSetter is not supported inside ${e.constructor._name}`)}function ba(n){for(let e of Jn(n))e.nodeTag==="dataSetter"&&Ug(e),Gg(e)}var Vg=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],zg=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),Hg=["_onCalling","_onResult","_onError"],Wg=["_delay","_timing","_userChanges"],ga=["_init","_onBuilt","_onStart"];function Gg(n){let e=s=>n.getAttr(s)!==null&&n.getAttr(s)!==void 0,t=!n._getMeta("data_element")&&typeof n.getAttr("remote")=="string";if(n.nodeTag!=="dataRpc"){let s=Hg.find(o=>e(o)&&!(o==="_onCalling"&&(n.nodeTag==="dataRemote"||t)));if(s){let o=s==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${s}' is allowed only on ${o}`)}}if(zg.has(n.nodeTag)){let s=Object.entries(n.getAttr()).find(([,a])=>Fe(a));if(s)throw new Error(`${n.nodeTag} '${n.label}': '${s[0]}' is a == expression, not accepted on ${n.nodeTag}`);let o=n.nodeTag==="dataRemote"?ga.find(e):null;if(o)throw new Error(`dataRemote '${n.label}': '${o}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let a of ga){let l=n.getAttr(a);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${n.nodeTag} '${n.label}': '${a}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let r=Vg.find(s=>e(s)&&!(s==="_delay"&&!n._getMeta("data_element")&&n.nodeTag!=="html_button")&&!(t&&Wg.includes(s)));if(!r)return;let i=ga.includes(r)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${n.nodeTag??"fragment"} '${n.label}': '${r}' is allowed only on ${i}`)}function Jn(n){if(n instanceof A)return n.getNodes().flatMap(t=>Jn(t));let e=[n];return n.value instanceof A&&e.push(...Jn(n.value)),e}var Xg=new Set(["destination_path","result_path","func","formula","script","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","_ask","_ask_if","_ask_title","_ask_onCancel","method","timeout","_onCalling","_onResult","_onError","cacheTime","sync"]),Kn=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let r=null,i=setTimeout(()=>{r(),this.#r=null,t()},e);r=this.binding.track(()=>clearTimeout(i)),this.#r=()=>{clearTimeout(i),r(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let r=setInterval(t,e*1e3),i=this.binding.track(()=>clearInterval(r));this.#t=()=>{clearInterval(r),i(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},Yr=class{#e;#t=[];#r=new Set;#n;#i=null;#s=!1;constructor(e){this.#e=e,this.#n=new Kn(e),e.track(()=>{this.cancel(),this.#p(),this.#f()})}get binding(){return this.#e}get node(){return this.binding.node}get kind(){throw new Error("Provider.kind is defined by FormulaProvider, ControllerProvider, RpcProvider and RemoteProvider")}register(){let e=this.node,t=e.getAttr("_onStart");if(typeof t=="number"&&!(Number.isFinite(t)&&t>=0))throw new Error(`${e.nodeTag} '${e.label}': _onStart must be true or a delay in ms not below 0: ${t}`);this.#p();let r=this.binding.runtime.router,i=Ge(e,e.getAttr("_timing"));for(let[s,o]of e.pointers()){if(s==="datapath")continue;let a=e.absDatapath(o);if(a===null)continue;let[l,u=null]=a.split("?",2),c=r.register({path:l,attr:u,recipient:this});this.#t.push(c),(s==="_timing"||i.has(s))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(s,o,a)=>l=>{let u={kind:"subscription",topic:a,payload:l};if(this.#a("_userChanges")&&a!=="node")return;let c=this.#a("_delay");c>0?this.#n.debounce(c,()=>this.invoke(u)):this.invoke(u)})),this.#o(),this.kind==="remote"&&this.invoke({kind:"install",change:null})}receive(e){if(this.#r.has(e.registration)){this.#o();return}if(this.#a("_userChanges")&&e.level!=="node")return;let t={kind:"data",change:e},r=this.#a("_delay");r>0?this.#n.debounce(r,()=>this.invoke(t)):this.invoke(t)}invoke(e){if(this.binding.closed)return;let t=this.node,r=this.kind==="formula",i=this.kind==="rpc",s=this.kind==="remote",o=this.readArguments(e);e.askResult&&(Object.assign(o,e.askResult),o._askResult=e.askResult);let a=t.getAttr("_ask"),l=this.binding.runtime.askDialog;if(a&&!e.askDone&&l.required(this.binding,a,o,"_ask"))return l.show(this.binding,a,o,t.getAttr("_ask_title")??"Warning").then(m=>{if(!this.binding.closed){if(m===null){let p=t.getAttr("_ask_onCancel");p&&this.#l("_ask_onCancel",p,p,o,!0);return}return this.invoke({...e,askDone:!0,askResult:m})}});let[u,c]=[r?"formula":"script",t.getAttr(r?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,o,!1)){if(s&&this.#f(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(i||s){this.#l(u,c,c,o,!0);return}}if(i)return this.#c(o);if(s)return this.#d(o);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,r?`return ${c}`:c,o,!0);else if(f==null){if(!r)return;h=new x(As(o))}else{let{group:m,method:p}=this.binding.runtime.logicRegistry.resolve(f,t);h=r?p.call(m,o):p.call(m,t,o)}r&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,r]=t.rootBuilder.runtimeValues(t),i=Object.fromEntries(Object.entries(r).filter(([l])=>!Xg.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),s={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(i)};e.kind==="subscription"&&(s._subscription_kwargs=e.payload);let o=e.change??null,a=o?o.level:e.kind==="subscription"?e.topic:e.kind;return s._node=o?o.node:null,s._triggerpars={kw:o,trigger_reason:a},s._reason=a,e.kind==="click"&&Object.assign(s,Yg(e)),s}cancel(){this.#n.cancel()}#o(){this.#n.startTiming(this.#a("_timing"),()=>this.invoke({kind:"timing",change:null}))}#a(e){let t=this.node,r=t.getAttr(e);return H(r)?$t(t,e):t.pointerType(r)?t.getRelativeData(r):r??null}#l(e,t,r,i,s){let o=[...s?["_kwargs"]:[],...qc,...Uc,...Object.keys(As(i))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?rt(this.binding.runtime,this.node,e,t,{...i,_kwargs:i},o):this.binding.runtime.inlineCompiler.compile(this.node,e,t,o,r)({...i,_kwargs:i})}async#c(e){let t=this.node,[r,i,s]=["_onCalling","_onResult","_onError"].map(a=>t.getAttr(a)),o=t.requests;if(o.calling(r?()=>this.#l("_onCalling",r,r,e,!0):null))return o.submit(this.#a("method"),As(e),a=>this.#u(a,e,i,s))}async#u(e,t,r,i){if(this.binding.closed)return;let s=this.node,o=this.#a("timeout"),a=o>0?setTimeout(()=>{let c=new Error(`${s.nodeTag} '${s.label}': no answer within ${o} ms`);c.name="TimeoutError",e.controller.abort(c)},o):null,l;try{l={result:await this.binding.call("data",e)}}catch(c){l={error:c}}if(clearTimeout(a),this.binding.closed||e.ignored)return;if("error"in l){if(!i)throw l.error;this.#l("_onError",i,i,{...t,error:l.error},!0);return}let{result:u}=l;s.getAttr("result_path")!=null&&s.setRelativeData(s.pathAttribute("result_path"),u),r&&this.#l("_onResult",r,r,{...t,result:u},!0)}#d(e){this.#f();let t=this.#s;this.#s=!1;let r=this.node,i=r.absDatapath(r.pathAttribute("destination_path"));if(i===null)return;let s=r.getAttr("_onCalling"),o=new Xr({binding:this.binding,method:this.#a("method"),params:As(e),cacheTime:this.#a("cacheTime"),sync:this.#a("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:s?()=>this.#l("_onCalling",s,s,e,!0):null,onError:a=>{throw new Error(`${r.nodeTag} '${r.label}': dataRemote '${o.method}' failed: ${a.message}`,{cause:a})}});this.binding.runtime.data.setResolver(i,o),this.#i={path:i,resolver:o},t&&o.refresh()}#f(){if(!this.#i)return;let{path:e,resolver:t}=this.#i;this.#i=null,this.#s=t.loaded||t.loading!==null;let r=this.binding.runtime.data.getNode(e);r?.resolver===t&&(r.resolver=null)}#p(){for(let e of this.#t.splice(0))e.close();this.#r.clear()}},Ts=class extends Yr{get kind(){return"formula"}},Ds=class extends Yr{get kind(){return"controller"}},Cs=class extends Yr{get kind(){return"rpc"}},Ss=class extends Yr{get kind(){return"remote"}},qc=["_node","_triggerpars","_reason","_subscription_kwargs","_askResult"],Uc=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function As(n){let e={...n};for(let t of[...qc,...Uc])delete e[t];return e}function Yg({event:n,counter:e}){return{_evt:n,button_counter:e,button_shift:!!n.shiftKey,button_ctrl:!!n.ctrlKey,button_alt:!!n.altKey,button_meta:!!n.metaKey}}var Zg=[[null,/(\W|^)GET (?:\s*)(\^?[\w.#@$?-]+)/g,"$1this.GET('$2')"],[/;SET/g,/(\W|^)SET (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.SET('$2', $3)$4 "],[/;PUT/g,/(\W|^)PUT (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.PUT('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE_AFTER('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE_AFTER('$2')$3 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE('$2', $3)$4 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE('$2')$3 "]],Jg=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,Kg=new Set(["arguments","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","eval","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),Ns=class{#e;#t=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return[...this.#t.values()].reduce((e,t)=>e+t.size,0)}preprocess(e,t,r){let i=r.trim();if(Jg.test(i))throw new Error(`${Qn(e,t)}: the PUBLISH macro is excluded from Gramlot`);let s=i.replace(/\$(\d+)/g,(o,a)=>`arguments[${parseInt(a,10)-1}]`);for(let[o,a,l]of Zg)o&&(s=s.replace(o,`; ${o.source.slice(1)}`)),s=s.replace(a,l);return s!==i&&console.warn(`${Qn(e,t)}: legacy macros are deprecated; write this.GET(path), this.SET(path, value), this.PUT(path, value), this.FIRE(path, value), this.FIRE_AFTER(path, value) and arguments[n] in place of GET, SET, PUT, FIRE, FIRE_AFTER and $n`),s}compile(e,t,r,i,s=r){if(e.activatedCode(t)!==r)throw new Error(`${Qn(e,t)}: inline code runs only as received with the Source (main or a remote Source); a text written later is not run: use named logic`);let o=this.#t.get(e);o||(o=new Map,this.#t.set(e,o),this.runtime.bindingFor(e).track(()=>this.release(e)));let a=o.get(t);a?.source!==s&&(a={source:s,text:this.preprocess(e,t,s),key:null,run:null},o.set(t,a));let l=i.filter(Qg),u=l.join(",");if(a.key!==u){let c=eb(e,t,a.text,l);a.key=u,a.run=d=>c.apply(e,l.map(f=>d[f]))}return a.run}compileExpression(e,t,r){let i=r.slice(2).trim(),s=_e(e.getAttr()).filter(([,a])=>!Fe(a)),o=this.compile(e,t,r,[...s.map(([a])=>a).filter(a=>a!=="_F"),"_F"],`return ${i}`);return a=>{let l={};for(let[u,c]of s)Object.hasOwn(a,u)?l[u]=a[u]:l[u]=e.pointerType(c)?e.getRelativeData(c):c;return o({...l,_F:(u,c)=>this.runtime.gramlot.format(u,c)})}}compilePointerExpression(e,t,r,i){let s=this.compile(e,t,r,["_pointerValues","_F"],`return (${i}
186
+ )`);return o=>s({_pointerValues:o,_F:(a,l)=>this.runtime.gramlot.format(a,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let r=this.#t.get(e);if(r)for(let i of t){r.delete(i);for(let[s]of _e({[i]:null}))r.delete(s)}}};function Qg(n){return/^[A-Za-z_$][\w$]*$/.test(n)&&!Kg.has(n)}function Qn(n,e){return`${n.nodeTag} '${n.label}' ${e?`'${e}'`:"node value"}`}function eb(n,e,t,r){try{return t.startsWith("function")?new Function(`return (${t}
124
187
  )`)():new Function(...r,`${t}
125
- `)}catch(i){throw i instanceof EvalError?new EvalError(`${Gn(n,e)}: inline code blocked by the Content Security Policy of the page (no 'unsafe-eval'); move the code to named logic (a method of the page's class Logic) or serve the page with the permissive CSP profile, which allows 'unsafe-eval'`,{cause:i}):new SyntaxError(`${Gn(n,e)}: ${i.message} in the inline code:
126
- ${t}`,{cause:i})}}var xs=class{#e;#t;#r=!1;#n=null;#i=null;constructor(e){this.#e=e,this.#t=new Wn(e)}get binding(){return this.#e}get node(){return this.binding.node}get closed(){return this.#r||this.binding.closed}close(){this.#r=!0,this.#t.cancel()}register(){this.#t.startTiming(this.#o("_timing"),()=>this.update())}receive(e){if(this.#o("_userChanges")&&e.level!=="node")return;let t=this.#o("_delay");t>0?this.#t.debounce(t,()=>this.update()):this.update()}async update(){if(this.closed||!this.binding.hasStamp("start"))return;let e=this.node,[,t]=e.rootBuilder.runtimeValues(e),r=t.remote,i={};for(let[l,u]of Object.entries(t))l.startsWith("remote_")&&(i[l.slice(7)]=u);let s=e.getAttr("_if");if(s&&!this.#a("_if",s,`return (${s})`,i)){let l=e.getAttr("_else");l&&this.#a("_else",l,l,i);return}let o;try{let l=U(i);if(t._cachedRemote&&this.#s(r,l))return;let u=e.getAttr("_onCalling");if(!e.requests.calling(u?()=>this.#a("_onCalling",u,u,i):null))return;o=await this.binding.runtime.gramlot.src.remoteSource(e,r,i)}catch(l){throw new Error(`${e.nodeTag} '${e.label}': remote '${r}' failed: ${l.message}`,{cause:l})}let a=e.getAttr("_onRemote");!this.closed&&o&&a&&this.#a("_onRemote",a,a,i)}fragmentMounted(e,t){this.#n=e,this.#i=t}#s(e,t){let r=this.node.requests.inflight;return r?r.method===e&&U(r.params)===t:e===this.#n&&t===this.#i}#o(e){let[,t]=this.node.rootBuilder.runtimeValues(this.node);return t[e]??null}#a(e,t,r,i){return e==="_onRemote"?Qe(this.binding.runtime,this.node,e,t,i):this.binding.runtime.inlineCompiler.compile(this.node,e,t,Object.keys(i),r)(i)}};var Lg=new Set(["title","msg","fields","_if","askIf"]),Pg=new Set(["name","lbl","tag","type","default_value","required","min","max","step","placeholder"]),As=class{#e;#t=null;#r=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}required(e,t,r,i){let s=(o,a)=>typeof a=="boolean"?a:e.runtime.inlineCompiler.compile(e.node,o,a,Object.keys(r),`return (${a});`)(r);if(typeof t=="string"){let o=e.node.getAttr("_ask_if");return!o||!!s("_ask_if",o)}return t?.askIf&&s(`${i}.askIf`,t.askIf),!t?._if||!!s(`${i}._if`,t._if)}show(e,t,r,i="Parameters"){let s=typeof t=="string"?{msg:t,title:i}:t;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ask requires text or a parameter description");for(let d of Object.keys(s))if(!Lg.has(d))throw new Error(`Unsupported ask option: ${d}`);let o=s.fields??[];if(!Array.isArray(o))throw new TypeError("ask fields must be an array");let a=new Set;for(let d of o){if(!d||!/^[A-Za-z_]\w*$/.test(d.name)||a.has(d.name))throw new Error("ask fields require distinct simple names");a.add(d.name);for(let f of Object.keys(d))if(!Pg.has(f))throw new Error(`Unsupported ask field option: ${f}`);if(d.tag&&!["input","textarea"].includes(d.tag))throw new Error(`Unsupported ask widget: ${d.tag}`);if(d.type&&!["text","number","date","checkbox","email","password","url","tel"].includes(d.type))throw new Error(`Unsupported ask input type: ${d.type}`)}let l=this.runtime.gramlot,u=this.#n(),c=this.#r;return new Promise((d,f)=>{let h=`ask_${Te()}`,p=!1,m=()=>{},b=(g,_=null)=>{if(p)return;p=!0;let w=g?Object.fromEntries(o.map(v=>[v.name,l.data.getItem(`${h}.${v.name}`)])):null;c.delete(h),m();try{l.src.source.popNode(h),l.data.getNode(h)&&l.data.popNode(h),_?f(_):d(w)}catch(v){f(v)}};c.set(h,{finish:b}),m=e.track(()=>b(!1));try{let g=new qe,_=g.root.html_dialog({nodeId:h,datapath:h,request:h,connect_oncancel:`${u}.cancel`,connect_onclose:`${u}.cancel`,class:"gramlot-ask","aria-labelledby":`${h}_title`,style:"border:1px solid #aab4c2;border-radius:8px;padding:16px;max-width:32rem;width:calc(100% - 48px);font:inherit;"});_.h2(s.title??i,{id:`${h}_title`,style:"font-size:1.1em;margin:0 0 12px;"}),s.msg&&_.p(s.msg);let w=_.form({request:h,connect_onsubmit:`${u}.confirm`});for(let E of o){w.dataSetter({destination_path:`.${E.name}`,value:Object.hasOwn(r,E.name)?r[E.name]:E.default_value??(E.type==="checkbox"?!1:"")});let C=w.div({style:"margin:8px 0;"});C.html_label(E.lbl??E.name,{for:`${h}_${E.name}`,style:"display:block;margin-bottom:4px;"});let L={id:`${h}_${E.name}`,value:`^.${E.name}`,live:!0};for(let q of["required","min","max","step","placeholder"])E[q]!==void 0&&(L[q]=E[q]);E.tag==="textarea"?C.textarea(L):C.input({...L,type:E.type??"text"})}let v=w.div({style:"display:flex;justify-content:flex-end;gap:8px;margin-top:16px;"});v.html_button("Cancel",{type:"button",request:h,connect_onclick:`${u}.cancel`}),v.html_button("Confirm",{type:"submit",autofocus:o.length===0}),l.src.source.setItem(h,l.src.prepareSource(g.source));let k=l.src.binding.nodeIds.get(h);l.dom.getDomNode(k).showModal()}catch(g){b(!1,g)}})}#n(){if(this.#t===null){let e=`ask_${Te()}`,t=this.#r;class r{confirm(s,o){o.preventDefault(),t.get(s.getAttr("request"))?.finish(!0)}cancel(s,o){o.preventDefault(),t.get(s.getAttr("request"))?.finish(!1)}}this.runtime.logicRegistry.register(r,{group:e,resource:"gramlot:ask"}),this.#t=e}return this.#t}};var Dc={dataFormula:ws,dataController:ys,dataRpc:vs,dataRemote:Es},jg=["datapath","_anchor","nodeId","form","formId"],Hr=class{#e;#t=new Map;#r=new Map;#n;#i;#s;#o;#a;#l=`gramlot-data-${Te()}`;#u=!1;constructor(e,{subscriptions:t}){this.#e=e,this.#a=t,this.#n=new gs(this),this.#i=new bs(this),this.#s=new ks(this),this.#o=new As(this)}get gramlot(){return this.#e}get subscriptions(){return this.#a}get builder(){return this.gramlot.src.builder}get renderer(){return this.gramlot.src.renderer}get logicRegistry(){return this.gramlot.src.logicRegistry}get data(){return this.builder.data}get root(){return this.data.parent}get size(){return this.#t.size}get disposed(){return this.#u}get router(){return this.#n}get installer(){return this.#i}get inlineCompiler(){return this.#s}get askDialog(){return this.#o}get nodeIds(){return this.#r}attach(){this.root.subscribe(this.#l,{any:e=>this.receiveData(e)})}receiveData(e){this.router.deliver(e)}bindingFor(e){return this.#t.get(e)??null}openBinding(e){if(this.disposed)throw new Error("BindingRuntime is disposed");let t=this.bindingFor(e);return t||(t=new aa(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof A)for(let i of e.value.getNodes())try{this.closeBranch(i)}catch(s){t.push(s)}let r=this.bindingFor(e);if(r){this.#t.delete(e);let i=e.getAttr("nodeId");this.nodeIds.get(i)===e&&this.nodeIds.delete(i);try{r.close()}catch(s){t.push(s)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#p(e);for(let r of t)this.bindingFor(r)?.rebind();for(let r of t)this.renderer.project(r);for(let r of t)this.bindingFor(r)?.remote?.update()}handleSourceEvent(e){let{evt:t,node:r}=e,i=[],s=o=>{try{this.closeBranch(o)}catch(a){i.push(a)}};try{if(t==="ins")this.#c(r);else if(t==="del")for(let o of Array.isArray(r)?r:[r])s(o);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof A)for(let o of e.oldvalue.getNodes())s(o);this.inlineCompiler.release(r,[""]),t==="upd_value_attr"?this.#m(r,e.attrs_diff):this.#f(r).rebind(),r.value instanceof A&&this.#c(r.value)}else if(t==="upd_attrs")this.#m(r,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(o){throw i.length?new AggregateError([...i,o],"Source event failed"):o}return i}branchBuilt(e){let t=[];for(let r of this.#p(e)){let i=this.bindingFor(r);!i||i.hasStamp("built")||!this.renderer.attached(r)||(i.stamp("built"),t.push(i))}for(let r of t)this.renderer.attached(r.node)&&this.#h(r,"built","_onBuilt");if(this.gramlot.state==="started")for(let r of t)this.renderer.attached(r.node)&&this.#d(r)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#d(e)}dispose(){if(this.disposed)return;this.#u=!0,this.root.unsubscribe(this.#l,{any:!0}),this.nodeIds.clear();let e=[];for(let[t,r]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{r.close()}catch(i){e.push(i)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#c(e){if(!(e instanceof A)&&this.bindingFor(e))return;let t=e instanceof A?e.getNodes().flatMap(s=>this.#p(s)):this.#p(e),r=new Set(t.filter(s=>this.bindingFor(s))),i=new Map;for(let s of t){let o=s.getAttr("nodeId");if(o!=null){if(i.has(o)||this.nodeIds.has(o)&&this.nodeIds.get(o)!==s)throw new Error(`Duplicate nodeId '${o}'`);i.set(o,s)}}for(let[s,o]of i)this.nodeIds.set(s,o);try{for(let s of t)this.openBinding(s);this.installer.install(e);for(let s of t)this.renderer.attached(s)&&this.bindingFor(s).registerPointers()}catch(s){let o=[s];for(let a of t.filter(l=>!r.has(l)).reverse()){let l=a.getAttr("nodeId");i.get(l)===a&&this.nodeIds.get(l)===a&&this.nodeIds.delete(l);let u=this.bindingFor(a);if(u){this.#t.delete(a);try{u.close()}catch(c){o.push(c)}}}throw o.length>1?new AggregateError(o,"Source branch installation failed"):s}for(let s of t){let o=this.bindingFor(s);if(!(!o||o.hasStamp("init")||!this.renderer.attached(s))&&(o.stamp("init"),Sc(s.getAttr("_init"))))for(let a of o.providers)a.invoke({kind:"init",change:null})}}#d(e){e.hasStamp("start")||(e.stamp("start"),this.#h(e,"start","_onStart"),e.remote?.update())}#h(e,t,r){let i=e.node.getAttr(r);if(Sc(i))for(let s of e.providers){if(typeof i!="number"||i<=0){s.invoke({kind:t,change:null});continue}let o=null,a=setTimeout(()=>{o(),s.invoke({kind:t,change:null})},i);o=e.track(()=>clearTimeout(a))}}#m(e,t){let r=this.#f(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:i,new:s}=t.nodeId;if(s!=null&&this.nodeIds.has(s)&&this.nodeIds.get(s)!==e)throw new Error(`Duplicate nodeId '${s}'`);this.nodeIds.get(i)===e&&this.nodeIds.delete(i),s!=null&&this.nodeIds.set(s,e)}jg.some(i=>Object.hasOwn(t,i))?this.rebindBranch(e):r.rebind()}#f(e){let t=this.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': the node has no NodeBinding (its installation failed); remove it from the Source and insert it again`);return t}#p(e){let t=[e];if(e.value instanceof A)for(let r of e.value.getNodes())t.push(...this.#p(r));return t}};function Sc(n){return n===!0||typeof n=="number"}var aa=class{#e;#t;#r=!1;#n=[];#i=[];#s=new Set;#o=null;#a=null;#l=new Set;#u=new Set;#c=0;#d=new Set;constructor(e,t){this.#e=e,this.#t=t}get runtime(){return this.#e}get node(){return this.#t}get closed(){return this.#r}get registrations(){return[...this.#i]}get providers(){return this.#o?[this.#o]:[]}get remote(){return this.#a}get clickCount(){return this.#c}countClick(){return++this.#c}hasStamp(e){return this.#s.has(e)}stamp(e){this.#s.add(e)}registerPointers(){this.node._getMeta("data_element")&&(this.runtime.renderer.references.remove(this.node),this.runtime.renderer.references.register(this.node,null));let e=this.node,t=e._getMeta("data_element");if(t&&!Dc[e.nodeTag])return;!t&&typeof e.getAttr("remote")=="string"?this.#a??=new xs(this):this.#a&&(this.#a.close(),this.#a=null);let r=new Set;if(e._getMeta("gramlot_component")?.bagStore){let s=e.getAttr("storepath");if(typeof s!="string"||!s||/^[\^=]/.test(s)||s.includes("?"))throw new TypeError("storepath requires a plain Bag data path");let o=e.absDatapath(s);this.#i.push(this.runtime.router.register({path:o,recipient:this,subtree:!0}))}let i=this.remote?ze(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[s,o]of Object.entries(e.getAttr()))if(s.startsWith("remote_"))for(let a of ze(e,o))r.add(a)}for(let[s,o]of e.pointers()){if(t&&s!=="datapath")continue;let l=(s==="datapath"?e.parentNode:e).absDatapath(o);if(l===null)continue;let[u,c=null]=l.split("?",2),d=this.runtime.router.register({path:u,attr:c,recipient:this});this.#i.push(d),s==="datapath"&&this.#d.add(d),this.remote&&(s==="remote"||s.startsWith("remote_")||r.has(s))&&this.#l.add(d),this.remote&&(s==="_timing"||i.has(s))&&this.#u.add(d)}if(!t){this.#h(),this.remote?.register();return}this.#o??=new Dc[e.nodeTag](this),this.#o.register()}#h(){let e=this.node;this.#i.push(...this.runtime.subscriptions.subscribeNode(e,(t,r)=>{if(typeof r!="string"||!r)throw new TypeError(`${t} requires a handler`);return i=>{if(this.closed)return;if(Un(r))return rr(this.runtime,e,r,i);let[,s]=e.rootBuilder.runtimeValues(e),o=Object.fromEntries(Object.entries(s).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),a={...this.runtime.renderer.references.resolveArguments(o),p_0:i};return this.runtime.inlineCompiler.compile(e,t,r,Object.keys(a))(a)}}))}rebind(){this.#m(),this.registerPointers()}receive(e){if(this.#d.has(e.registration)){this.runtime.rebindBranch(this.node);return}this.#l.has(e.registration)&&this.remote.receive(e),this.#u.has(e.registration)&&this.remote.register(),this.runtime.renderer.project(this.node,e)}track(e){if(this.closed)throw new Error(`NodeBinding of '${this.node.label}' is closed`);return this.#n.push(e),()=>{let t=this.#n.indexOf(e);t!==-1&&this.#n.splice(t,1)}}async call(e,t){let{controller:r}=t,i=this.track(()=>r.abort());try{let s=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:r.signal});if(r.signal.aborted)throw r.signal.reason;return s}finally{i()}}callSync(e,t,r){return this.node.requests.submitSync(t,()=>this.runtime.gramlot.rpc.callSync(e,t,r))}close(){if(this.closed)return;this.#r=!0,this.#a?.close(),this.node._getMeta("data_element")&&this.runtime.renderer.references.remove(this.node),this.#m();let e=[];for(let t of this.#n.splice(0).reverse())try{t()}catch(r){e.push(r)}if(e.length)throw new AggregateError(e,`NodeBinding of '${this.node.label}' cleanup failed`)}#m(){for(let e of this.#i.splice(0))e.close();this.#d.clear(),this.#l.clear(),this.#u.clear()}};var Ts=class{constructor(e){this.renderer=e}prepare(e,t){let r=this.renderer.records.get(e);if(!r||r.resolved.draggable!==!0)return null;let i=e._getMeta("gramlot_component")?.dragSource?r.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(i===null)return null;let{dragValues:s,item:o,path:a}=i;if(r.resolved.onDrag){let u=this.renderer.html.callLogic(e,r.resolved.onDrag,{dragValues:s,item:o,path:a});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return Bt(s),{dragValues:Object.fromEntries(Object.entries(s).map(([u,c])=>{if(u.startsWith("text/")||u==="dragTags"){if(typeof c!="string")throw new TypeError(`${u} drag data must be text`);return[u,c]}return[u,P(U(c))]})),item:o,path:a}}};var Rt=class{static isTarget(e){return e.dropTarget===!0||!!e.dropTargetCb||Object.entries(e).some(([t,r])=>t.startsWith("dropTargetCb_")&&!!r)}static acceptedTypes(e,t="",r=[]){let i=t.split(",").map(s=>s.trim()).filter(Boolean).map(s=>{let o=s.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${o.join(".*")}$`)});return e.filter(s=>s!=="dragTags"&&(r.includes(s)||i.some(o=>o.test(s))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let r=new Set(e.split(",").map(i=>i.trim()).filter(Boolean));return r.size?t.split(",").some(i=>i.split(" AND ").every(s=>(s=s.trim(),!s||s==="!"?!1:s.startsWith("!")?!r.has(s.slice(1)):r.has(s)))):!1}static acceptsEffect(e="all",t="move"){let r={all:["copy","move","link"],none:[],copy:["copy"],move:["move"],link:["link"],copyMove:["copy","move"],copyLink:["copy","link"],linkMove:["link","move"]};if(!Object.hasOwn(r,e))throw new TypeError(`Invalid effectAllowed: ${e}`);if(!["copy","move","link"].includes(t))throw new TypeError(`Invalid dropEffect: ${t}`);return r[e].includes(t)}static evaluate(e,t,r,i,s=[]){let o=this.acceptedTypes(e,i.dropTypes,s),a=i.dropEffect??"move",l=this.isTarget(i)&&o.length>0&&this.acceptsTags(t,i.dropTags)&&this.acceptsEffect(r,a);return{accepted:l,types:o,dropEffect:l?a:"none"}}};var Cc=["dragstart","dragover","dragleave","drop","dragend"],Ds=class{#e;#t;#r=null;#n=null;#i=null;#s;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of Cc)this.#t.addEventListener(t,this);this.#s=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#s)}handleEvent(e){e.type==="dragstart"?this.#l(e):e.type==="dragend"?this.#b(e.dataTransfer.dropEffect):e.type==="dragleave"?this.#f():e.type==="dragover"?this.#d(e):e.type==="drop"&&this.#h(e)}#o(e,t){for(let r of e.composedPath()){let i=this.#e.elements.get(r);if(i&&t(i.resolved))return i}return null}#a(e,t){return e.node._getMeta("gramlot_component")?.dragSource?e.element.getDragContext(t):{element:e.element,item:void 0,path:void 0}}#l(e){let t=this.#o(e,r=>r.draggable===!0);if(t){this.#b("none");try{let r=this.#e.prepareDrag(t.node,e);if(!r||!t.element.isConnected||this.#e.records.get(t.node)!==t){e.preventDefault();return}let i=this.#a(t,e);if(!i){e.preventDefault();return}let s=new Map(Object.entries(r.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:U(c)]));if(!s.size){e.preventDefault();return}let o=t.resolved.effectAllowed??"all";Rt.acceptsEffect(o,"move");let a="";for(let u=t;u;u=u.parent)if(u.resolved?.dragTags!=null){a=u.resolved.dragTags;break}let l=this.#r={record:t,wires:s,effectAllowed:o,phase:"active",tags:[a,r.dragValues.dragTags].filter(Boolean).join(","),endTopic:this.#e.binding.gramlot._subscriptions.topicFor(t.node,"endDrag"),source:{pageId:this.#e.binding.gramlot.pageId??null,sourcePath:t.node.fullpath,itemPath:r.path??null},preview:null,release:null};e.dataTransfer.clearData();for(let[u,c]of s)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=o,this.#i=this.#t.createElement("style"),this.#i.textContent=".canBeDropped{outline:2px solid var(--gramlot-brand-blue,#3766b5);outline-offset:-2px}.cannotBeDropped{outline:2px dashed currentColor;outline-offset:-2px}.draggedItem{opacity:.75}",this.#t.head.append(this.#i),this.#u(l,i.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(r){e.preventDefault(),this.#g(),this.#_(r)}}}#u(e,t,r){let i=t.cloneNode(!0);i.removeAttribute("id");for(let s of i.querySelectorAll("[id]"))s.removeAttribute("id");i.setAttribute("aria-hidden","true"),i.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(i.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(i),e.preview=i,r.setDragImage(i,0,0)}#c(e){let t=this.#r,r=this.#o(e,u=>Rt.isTarget(u));if(!r)return null;let i=this.#a(r,e);if(!i)return{record:r,element:r.element,accepted:!1};let s=Rt.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,r.resolved),a={dropValues:Object.fromEntries(s.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):P(t.wires.get(u))])),item:i.item,path:i.path,source:{...t.source},selfdrop:r===t.record,dropEffect:s.dropEffect,dataAvailable:!0},l=s.accepted&&this.#e.checkDropTarget(r.node,a)&&this.#e.records.get(r.node)===r&&i.element.isConnected;return{record:r,element:i.element,accepted:l,context:a}}#d(e){if(!this.#r){this.#o(e,t=>Rt.isTarget(t))&&(e.preventDefault(),e.dataTransfer.dropEffect="none");return}if(e.preventDefault(),this.#r.phase!=="active"){e.dataTransfer.dropEffect="none";return}try{let t=this.#r,r=this.#c(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r?.accepted?r.context.dropEffect:"none",this.#f(),r&&this.#m(r.element,r.accepted)}catch(t){e.dataTransfer.dropEffect="none",this.#r&&(this.#r.phase="rejected"),this.#p(),this.#_(t)}}async#h(e){if(!this.#r){this.#o(e,r=>Rt.isTarget(r))&&e.preventDefault();return}if(e.preventDefault(),this.#r.phase!=="active")return;let t=this.#r;try{let r=this.#c(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}if(t.phase="dropped",this.#p(),!r?.accepted){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r.context.dropEffect,r.record.node.publish("onDrop",r.context),await this.#e.invokeDrop(r.record.node,r.context)}catch(r){this.#r===t&&(t.phase="rejected",this.#p()),this.#_(r)}}#m(e,t){let r=t?"canBeDropped":"cannotBeDropped",i=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#n={element:e,name:r,hadClass:e.classList.contains(r),hadPart:i.includes(r)},e.classList.add(r),i.includes(r)||e.setAttribute("part",[...i,r].join(" "))}#f(){if(!this.#n)return;let{element:e,name:t,hadClass:r,hadPart:i}=this.#n;r||e.classList.remove(t),i||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(s=>s!==t).join(" ")),this.#n=null}#p(){this.#f(),this.#r&&(this.#r.preview?.remove(),this.#r.preview=null,this.#r.wires.clear())}#g(){let e=this.#r;return this.#p(),this.#r=null,e?.release?.(),this.#i?.remove(),this.#i=null,e}#b(e){let t=this.#g();!t||this.#e.disposed||this.#e.endDrag(t.record.node,{source:{...t.source},dropEffect:e},t.endTopic).catch(r=>this.#_(r))}#_(e){console.error("Gramlot drag/drop failed:",e)}dispose(){this.#g();for(let e of Cc)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#s)}};var Xn=class extends tr{static renderType="object";#e=new Set;#t=new WeakMap;#r=new WeakMap;#n=new WeakMap;constructor(e,t,r,{binding:i}={}){if(super(e),!(e instanceof ye)||!(t instanceof le)||r?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(i instanceof Hr))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");this._binding=i,this.source=t,this.destination=r,this.html=new ds({metadataAttributes:["__ref"],callLogic:(s,o,a)=>{let{group:l,method:u}=i.gramlot.src.logicRegistry.resolve(o,s);return u.call(l,s,a)},invokeScript:(s,o,a,l)=>Qe(i,s,o,a,l,s.parentNode._getMeta("gramlot_component").childParameters[o].inline)}),this.records=new Map,this.references=new zn(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new Ts(this),this.instanceId=Te(),this.radioGroups=new cs(this),this.dragDrop=new Ds(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:s=>this.receive(s)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l}){let u=this.records.get(e);if(!u)return!1;if(!u.resolved.dropTargetCb)return!0;let c=this.html.callLogic(e,u.resolved.dropTargetCb,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l});if(typeof c!="boolean")throw new TypeError("dropTargetCb must return a boolean synchronously");return c}async invokeDrop(e,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l}){let u=this.records.get(e);!u||!u.resolved.onDrop||Object.keys(t).length===0||await this.html.callLogic(e,u.resolved.onDrop,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:r},i){let s={source:t,dropEffect:r},o=[],a=this.records.get(e);try{a&&!a.binding.closed&&a.resolved.onDragEnd&&await this.html.callLogic(e,a.resolved.onDragEnd,s)}catch(l){o.push(l)}try{this.binding.gramlot.publish(i,s)}catch(l){o.push(l)}if(o.length)throw new AggregateError(o,"Drag completion notification failed")}get inlineCompiler(){return this.binding.inlineCompiler}evaluateExpressions(e,t){let r=this.#r.get(e)??super.evaluateExpressions(e,t),i=e._getMeta("gramlot_component");if(i?.presentationDefaults.length){let s=e.getAttr();this.#n.set(e,Object.fromEntries(Object.entries(r).filter(([o])=>Object.hasOwn(s,o)&&i.presentationDefaults.some(a=>o.startsWith(a)))))}if(i&&(i.parameters.value?.binding==="twoWay"||i.presentationDefaults.length)){let s=[];for(let o=e.parentNode;o;o=o.parentNode)this.#n.has(o)&&s.unshift(this.#n.get(o));r=Object.assign({},...s,r)}return this.#r.delete(e),this.#t.set(e,r),r}render(e,t={}){if(!(e instanceof er))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(e._getMeta("data_element")||!this.binding.bindingFor(e)&&this.#a(e))return null;if(e.nodeTag)this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder);else if(!(e.value instanceof A))throw new TypeError("Source fragments must contain child SourceBags");return e.nodeTag?super.render(e,t):this.renderFragment(e,t)}renderFragment(e,{document:t=this.destination.ownerDocument,...r}={}){let i=t.createDocumentFragment(),s={node:e,binding:this.#f(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,s),this.elements.set(i,s),i.append(s.start);for(let o of e.value.getNodes()){let a=this.render(o,{document:t,...r});if(a===null)continue;i.append(a);let l=this.elements.get(a);l&&(l.parent=s,s.children.add(o))}return i.append(s.end),i}renderedItem(e,t,r,{tag:i,document:s=this.destination.ownerDocument}={}){let o=r;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(o=this.restoreNativeAttributes(e,r),e._getMeta("gramlot_component")||([t,o]=Pn(t,o,(h,p)=>this._binding.gramlot.format(h,p)))),o=this.componentAttributes(e,o);let a=Array.isArray(t)?t:[],l=Array.isArray(t)?o._text:t,u=this.#t.get(e),c={node:e,binding:this.#f(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,s,i,o,u.visible??null)};this.html.compose(c,l,a),c.shape=be.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c);let d=be.for(c.binding,c);d&&(c.control=d,d.attach(),c.cleanup.push(()=>d.detach()),this.#d(c,e,o,null));let f=fs.for(c.binding,c);f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),e.nodeTag==="menu"&&(c.menu=new hs(c.binding,c.element),c.menu.attach(),c.cleanup.push(()=>c.menu.detach())),this.#h(c),this.references?.register(e,c.element);for(let h of a){let p=this.elements.get(h);p&&(p.parent=c,p.container=c.element,c.children.add(p.node))}return c.element}validateCandidate(e,{replacingNode:t=null}={}){if(!(e instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");let r=new Set,i=s=>{if(!r.has(s)){r.add(s);for(let o of this.records.get(s)?.children??[])i(o);if(s.value instanceof A)for(let o of s.value.getNodes())i(o)}};for(let s of this.records.get(t)?.children??[])i(s);if(t?.value instanceof A)for(let s of t.value.getNodes())i(s);return this.#i(e,t?t.nodeTag:null),oa(e),this.references?.validate(e,r),e}#i(e,t=null){let r=new Set,i=(s,o=null)=>{if(!(s instanceof le)||r.has(s))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(s._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");r.add(s);for(let a of s.getNodes()){if(!(a instanceof er))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(a.builder instanceof ye))throw new TypeError("SourceBagNode requires builder ownership");if(a.resolver)throw new TypeError("Source resolvers are outside this port");if(a._getMeta("data_element"))a.builder.validateNode(a);else if(a.nodeTag){let l=a._getMeta("subbuilder")?s._builder:a.builder;this.html.validate(a,l),a._getMeta("subbuilder")||a.builder.validateParent(a.nodeTag,o)}else{if(!(a.value instanceof A))throw new TypeError("Source fragments must contain child SourceBags");if(Object.keys(a.attr).some(l=>l!=="_meta"))throw new TypeError("Fragment attributes are unsupported")}a.value instanceof A&&i(a.value,a._getMeta("subbuilder")?null:a.nodeTag??o)}};i(e,t)}freeze(e){e=Y(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Freeze requires a mounted Source node");t.frozen=!0}unfreeze(e){e=Y(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let r=i=>{delete i.frozen;for(let s of i.children)r(this.records.get(s))};r(t),!this.#s(e)&&(this.attached(e)?this.#p(e):this.remove(e))}#s(e){for(;e;){let t=this.records.get(e);if(t?.frozen)return!0;e=e.parentBag?.parentNode??t?.parent?.node}return!1}receive(e){if(this.disposed)return;let t=r=>this.#e.has(r)||e.evt==="del"&&r.nodeTag==="dataSetter";if(Array.isArray(e.node)){let r=e.node.filter(i=>!t(i));if(!r.length)return;e={...e,node:r}}else if(t(e.node))return;if(this.pending.push(e),!this.building){this.building=!0;try{for(;this.pending.length;){let r=this.pending.shift();if(r.evt!=="del"&&!this.attached(r.node))continue;r.evt!=="del"&&r.evt!=="upd_attrs"&&this.#l(r);let i=this.binding.handleSourceEvent(r);try{this.#o(r,i)}catch(s){if(!i.length)throw s;i.push(s)}if(i.length)throw i.length===1?i[0]:new AggregateError(i,"Source cleanup failed")}}catch(r){throw this.pending.length=0,r}finally{this.building=!1}}}#o(e,t){if(e.evt==="del"){for(let r of Array.isArray(e.node)?e.node:[e.node]){if(this.#s(r))continue;let i=this.records.get(r)?.parent??null;try{this.remove(r)}catch(s){t.push(s)}this.#m(i)}return}if(!this.#s(e.node))if(e.evt==="ins")this.insert(e.node);else if(e.evt.startsWith("upd_"))this.update(e.node,e.evt);else throw new Error(`Unsupported Source event: ${e.evt}`)}attached(e){let t=e.parentBag;for(;t&&t!==this.source;)t=t.parentNode?.parentBag;return t===this.source}#a(e){let t=new Set(this.pending.flatMap(r=>Array.isArray(r.node)?r.node:[r.node]));for(let r=e;r;r=r.parentBag?.parentNode)if(t.has(r))return!0;return!1}#l(e){let t=r=>{if(!(r instanceof er))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(r.value instanceof A){if(!(r.value instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");for(let i of r.value.getNodes())t(i)}};t(e.node)}insert(e){if(!this.attached(e)||this.records.has(e))return;if(e._getMeta("data_element")){this.records.get(e.parentBag?.parentNode)?.button?.refresh(),this.binding.branchBuilt(e);return}let t=this.records.get(e.parentBag?.parentNode),r=t?.element??t?.container??this.destination,i=e.parentBag.getNodes(),s=t?.end??null;for(let o=i.indexOf(e)+1;o<i.length;o++){let a=this.records.get(i[o]);if(a){s=a.element??a.start;break}}this.buildNode(e,r,s,t)}buildNode(e,t,r=null,i=null){this.#e.add(e);let s;try{s=this.render(e,{document:t.ownerDocument})}catch(a){this.#u(e,a)}finally{this.#e.delete(e)}let o=this.records.get(e);return t.insertBefore(s,r),o.parent=i,this.assignContainer(o,t),i?.children.add(e),this.#m(i),this.binding.branchBuilt(e),o}#u(e,t){let r=[t],i=[],s=o=>{if(i.push(o),o.value instanceof A)for(let a of o.value.getNodes())s(a)};s(e);for(let o of i.reverse())try{this.remove(o)}catch(a){r.push(a)}throw r.length===1?t:new AggregateError(r,"Source build and cleanup failed")}assignContainer(e,t){e.container=t;let r=e.element??t;for(let i of e.children){let s=this.records.get(i);s&&this.assignContainer(s,r)}}update(e,t){let r=this.records.get(e);if(!r){this.insert(e);return}let i=e.value==null||["string","number","boolean"].includes(typeof e.value),s=t==="upd_value"&&i&&r.element&&r.children.size===0&&this.html.matches(r,e);(t==="upd_attrs"||s)&&r.element&&this.html.matches(r,e)?(e.nodeTag&&this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder),this.project(e),t==="upd_attrs"&&this.records.get(e)===r&&(this.references?.remove(e),this.references?.register(e,r.element))):this.#p(e)}project(e,t=null){let r=this.records.get(e);if(!r?.element)return;let i=this.getRender(e.builder),s=this.#n.get(e),[o,a]=e.rootBuilder.runtimeValues(e),[,l]=i._handleMeta(e,a),u=this.#t.get(e);if(r.shape!==be.shape(r.element,u)){if(this.#s(e))return;this.#r.set(e,u);try{this.#p(e)}finally{this.#r.delete(e)}return}r.resolved=u;let c=e._getMeta("subbuilder")?l:i.adaptAttrs(l),d=e.value instanceof A,f=d?[]:this.expressionValue(e,o);i===this&&(c=this.restoreNativeAttributes(e,c),e._getMeta("gramlot_component")||([f,c]=Pn(f,c,(p,m)=>this._binding.gramlot.format(p,m)))),c=this.componentAttributes(e,c),this.html.update(r,e,c,d?c._text:f,u.visible??null),this.#d(r,e,c,t),r.control?.refresh(),r.button?.refresh(),r.menu?.refresh(),this.#h(r);let h=this.#n.get(e);if(h){let p=new Set([...Object.keys(s??{}),...Object.keys(h)].filter(m=>!Object.is(s?.[m],h[m])));p.size&&this.#c(e,p)}(r.element.localName==="option"||r.element.localName==="optgroup")&&this.#m(r.parent)}#c(e,t){if(e.value instanceof A)for(let r of e.value.getNodes()){let i=r._getMeta("gramlot_component"),s=r.getAttr(),o=t;i?.presentationDefaults.length?o=new Set([...t].filter(a=>!Object.hasOwn(s,a))):i?.parameters.value?.binding==="twoWay"&&[...t].some(a=>!Object.hasOwn(s,a))&&this.project(r),o.size&&this.#c(r,o)}}componentAttributes(e,t){let r=e._getMeta("gramlot_component"),i=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!r&&!i)return t;let s=this.#t.get(e),o=Object.fromEntries([...new Set([...Object.keys(r?.parameters??{}),...Object.keys(i??{}),...Object.keys(s).filter(a=>a.startsWith("validate_"))])].filter(a=>Object.hasOwn(s,a)).map(a=>[a,s[a]]));return{...t,...o}}#d(e,t,r,i){if(!e.control)return;let s=t.getAttr("value")!=null;(s||e.valueDeclared)&&e.control.project(r.value??null,i),e.valueDeclared=s}#h(e){let t=new Map(Vn.declared(e.node).map(r=>[r[0],r]));if(!e.events){if(!t.size)return;e.events=new Map,e.cleanup.push(()=>{for(let r of e.events.values())r.detach();e.events.clear()})}for(let[r,i]of[...e.events])t.get(r)?.[2]!==i.handler&&(i.detach(),e.events.delete(r));for(let[r,[,i,s]]of t){if(e.events.has(r))continue;let o=new Vn(e.binding,e,i,s,r);o.attach(),e.events.set(r,o)}}#m(e){for(let t=e;t;t=t.parent){if(t.control instanceof qn){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=Y(e),r=this.records.get(t);return r&&this.attached(t)?r.element??null:null}getBaseSourceNode(e){for(let t=e;t;t=t.parentNode){let r=t.nodeType===1?this.elements.get(t):null;if(r)return this.attached(r.node)?r.node:null}return null}#f(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#p(e){let t=this.records.get(e),r=t.element?.nextSibling??t.end?.nextSibling??null,i=t.container,s=t.parent,o=null;try{this.remove(e)}catch(a){o=a}try{this.buildNode(e,i,r,s)}catch(a){throw o?new AggregateError([o,a],"Source replacement cleanup and commit failed"):a}if(o)throw o}onDispose(e,t){let r=this.records.get(e);if(!r)throw new Error("Source node is not mounted");return r.cleanup.push(t),()=>{let i=r.cleanup.indexOf(t);i!==-1&&r.cleanup.splice(i,1)}}remove(e){let t=this.records.get(e);if(!t)return;let r=[];for(let i of[...t.children])try{this.remove(i)}catch(s){r.push(s)}for(let i of t.cleanup.splice(0).reverse())try{i()}catch(s){r.push(s)}if(this.references?.remove(e),t.element&&this.elements.delete(t.element),t.element?.remove(),t.start?.remove(),t.end?.remove(),t.parent?.children.delete(e),this.records.delete(e),this.#t.delete(e),this.#n.delete(e),r.length)throw new AggregateError(r,"Source cleanup failed")}dispose(){if(this.disposed)return;this.disposed=!0,this.dragDrop.dispose(),this.source.unsubscribe(this.subscription,{any:!0}),this.pending.length=0;let e=[],t=[...this.records.entries()].filter(([,r])=>!r.parent).map(([r])=>r);for(let r of t)try{this.remove(r)}catch(i){e.push(i)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var Fg=new Set(["page","constructor"]);function Nc(n,e){if(n===null)return[];let t=n.split("/");for(let r of t)if(Fg.has(r))throw new Error(`${e}: a logic group cannot be named '${r}' (group '${n}')`);return t}var Ug=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function qg(n){return/^[\w$]/.test(n)?Ug.has(n):n!==")"&&n!=="]"}function Vg(n,e){let t=!1;for(let r=e+1;r<n.length;r++){let i=n[r];if(i===`
127
- `)return-1;if(i==="\\"){r++;continue}if(i==="[")t=!0;else if(i==="]")t=!1;else if(i==="/"&&!t)return r}return-1}function zg(n){let e=0,t="",r="";for(let i=n.indexOf("{");i<n.length;i++){let s=n[i];if(s==="/"&&n[i+1]==="/"){if(i=n.indexOf(`
128
- `,i),i<0)break;continue}if(s==="/"&&n[i+1]==="*"){let o=n.indexOf("*/",i+2);if(o>=0){i=o+1;continue}}if(s==="/"&&qg(r)){let o=Vg(n,i);if(o>=0){i=o,r=")";continue}}if(s==='"'||s==="'"||s==="`"){let o=i+1;for(;o<n.length&&n[o]!==s;)o+=n[o]==="\\"?2:1;e===1&&(t+=n.slice(i+1,o)==="constructor"?" constructor":' ""'),i=o,r=")";continue}if(/[\w$]/.test(s)){let o=i+1;for(;o<n.length&&/[\w$]/.test(n[o]);)o++;e===1&&(t+=n.slice(i,o)),r=n.slice(i,o),i=o-1;continue}if(/\s/.test(s)||(r=s),s==="{"){++e===2&&(t+=" {}");continue}if(s==="}"){e--;continue}e===1&&(t+=s)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function Ic(n,e){if(n===void 0)return[];if(typeof n!="function"||!/^class\b/.test(Function.prototype.toString.call(n)))throw new Error(`${e}: the module exports no class Logic`);if(Object.getPrototypeOf(n)!==Function.prototype||Object.getPrototypeOf(n.prototype)!==Object.prototype)throw new Error(`${e}: class Logic cannot extend another class`);if(zg(Function.prototype.toString.call(n)))throw new Error(`${e}: class Logic cannot declare a constructor; state lives on the group or the page`);let t=[];for(let r of Reflect.ownKeys(n.prototype)){if(r==="constructor")continue;if(typeof r=="symbol")throw new Error(`${e}: class Logic cannot declare symbol keys (${String(r)})`);let i=Object.getOwnPropertyDescriptor(n.prototype,r);if(i.get||i.set)throw new Error(`${e}: class Logic cannot declare the accessor '${r}'`);if(typeof i.value!="function")throw new Error(`${e}: Logic.prototype.${r} is not a method`);if(r==="page")throw new Error(`${e}: a logic method cannot be named 'page'`);t.push([r,i.value])}return t}function Oc(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var ir=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},Wr=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new ir(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:r,resource:i}of e){let s=Nc(r,i);for(let o=0;o<s.length;o++){let a=s.slice(0,o).join("/");t.has(a)||t.set(a,new Set),t.get(a).add(s[o])}}for(let{logicClass:r,group:i,resource:s}of e){let o=t.get(i??"")??new Set;for(let[a]of Ic(r,s))if(o.has(a))throw new Error(`${s}: the logic method '${a}' has the name of a child group`)}}register(e,{group:t=null,resource:r}){let i=Nc(t,r),s=Ic(e,r),o=this.#e.logic;for(let a of i){let l=Object.getOwnPropertyDescriptor(o,a)?.value;if(l===void 0){let u=new ir(this,this.#e);Oc(o,a,u),o=u}else if(l instanceof ir)o=l;else throw new Error(`${r}: the group '${a}' has the name of a logic method`)}for(let[a,l]of s){if(Object.getOwnPropertyDescriptor(o,a)?.value instanceof ir)throw new Error(`${r}: the logic method '${a}' has the name of a child group`);Oc(o,a,l)}this.#t.has(o)||this.#t.set(o,[]),this.#t.get(o).push(r)}resolve(e,t){let r=e.split("."),i=r.pop(),s=this.#e.logic;for(let a=0;a<r.length;a++)if(s=Object.getOwnPropertyDescriptor(s,r[a])?.value,!(s instanceof ir))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${r.slice(0,a+1).join("/")}'`);let o=Object.getOwnPropertyDescriptor(s,i)?.value;if(typeof o!="function"){let a=this.#t.get(s)??[],l=r.length?`the group '${r.join("/")}'`:"the page logic";throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: ${l} has no method '${i}' (resources: ${a.join(", ")||"none"})`)}return{group:s,method:o}}};var Yn=class extends Se{constructor(e,{collections:t,destination:r,subscriptions:i,nameSyntax:s}){super(e),e.src=this,this.logicRegistry=new Wr(e),this.builder=new qe(null,{collections:t,nameSyntax:s}),this.binding=new Hr(e,{subscriptions:i}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new Xn(this.builder,this.source,r,{binding:this.binding})}startSource(e){if(!["ready","failed"].includes(this.gramlot.state))throw new Error(`Cannot start embedded Source while Gramlot is ${this.gramlot.state}`);try{return this.mountMainSource(e)}catch(t){throw this.gramlot.state="failed",t}}mountMainSource(e,t=null){let r=this.prepareSource(e);if(this.renderer.validateCandidate(r),t!==null){if(!(t instanceof D)||t instanceof A)throw new TypeError("Initial page data must be a Data Bag");for(let i of t.getNodes())this.builder.data.setItem([i.label],i.getValue(),i.attr,">",!1,!1)}try{this.source.setItem("main",r)}catch(i){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),i}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof A){if(!(e instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");return e.bindBuilder(t).activateCode()}if(typeof e!="string")throw new TypeError("Source value did not decode to SourceBag");let r=Uo(e,t);if(!(r instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");return r.activateCode()}async remoteSource(e,t,r={}){if(!this.gramlot.rpc.transport?.call)throw new Error("Remote Source is unavailable without a server transport");let s=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!s)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,r,o=>this.#e(e,s,o))??!1}async#e(e,t,r){if(t.closed||this.gramlot.state==="disposed")return!1;let i=!1,s=()=>this.gramlot.state!=="disposed"&&!r.ignored&&!t.closed;try{let o=await t.call("source",r);if(!s())return!1;let a=this.prepareSource(o,e.builder);return s()?(this.renderer.validateCandidate(a,{replacingNode:e}),i=!0,e.setValue(a,!0,{_text:null},!0),t.remote?.fragmentMounted(r.method,r.text),!0):!1}catch(o){if(!i&&!s())return!1;throw o}}};var Zn=class extends Error{name="RpcError";constructor({code:e,name:t,message:r,details:i}){super(r),this.code=e,this.remoteName=t,i!==void 0&&(this.details=i)}},Jn=class extends Se{constructor(e,{rpcUrl:t,closeUrl:r,document:i,transport:s}){super(e),this.transport=s===!1?null:s??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:r,document:i}),this.remoteRequests=new Map}get supportsCallSync(){return this.transport?.supportsCallSync===!0}callSync(e,t,r={}){if(!this.supportsCallSync)throw new Error(`rpc '${t}': the transport of this page has no synchronous call`);if(Bt(r),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let i=Te(),s=P(this.transport.callSync(U({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:r})));if(s.id!==i)throw new Error("rpc response id mismatch");if(s.error)throw new Zn(s.error);return s.value}async call(e,t,r={},i={}){return(await this.callEnvelope(e,t,r,i)).value}async callEnvelope(e,t,r={},{signal:i=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);Bt(r);let s=Te(),o=U({id:s,pageId:this.gramlot.pageId,contentType:e,name:t,params:r}),a=i?[this.gramlot.abort.signal,i]:[this.gramlot.abort.signal],l=a.find(f=>f.aborted);if(l)throw l.reason;let u=new AbortController,c=f=>u.abort(f.target.reason);for(let f of a)f.addEventListener("abort",c,{once:!0});let d=new Promise((f,h)=>{u.signal.addEventListener("abort",()=>{this.remoteRequests.delete(s),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(s,u);try{let f=P(await Promise.race([this.transport.call(o,u.signal),d]));if(f.id!==s)throw new Error("rpc response id mismatch");if(f.error)throw new Zn(f.error);return f}finally{this.remoteRequests.delete(s);for(let f of a)f.removeEventListener("abort",c)}}};var Kn=class extends Se{setTouchMode(e="auto"){if(!["auto","on","off"].includes(e))throw new TypeError(`Invalid touch mode: ${e}`);let t=this.gramlot.src.renderer.destination.ownerDocument.documentElement;e==="auto"?t.removeAttribute("data-gramlot-touch"):t.setAttribute("data-gramlot-touch",e)}reference(e){return this.gramlot.src.renderer.references.resolve(e)}getBaseSourceNode(e){return this.gramlot.src.renderer.getBaseSourceNode(e)}getDomNode(e){return this.gramlot.src.renderer.getDomNode(e)}};var Bc="gramlot:publish",Ss=class{#e;#t;#r;#n=Te();#i=new Map;#s=!1;#o;#a;#l;#u;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#o=i=>this.#m(i),this.#a=i=>{if(i.target?.localName!=="iframe")return;let s=this.#g(i.target);s&&(this.#d(s.window),this.#f(s,{kind:"hello"}))},this.#t.addEventListener("message",this.#o),this.#l=()=>this.#c(),this.#u=()=>this.ready(),this.#t.addEventListener("pagehide",this.#l),this.#t.addEventListener("pageshow",this.#u),t.addEventListener("load",this.#a,!0);let r=this.#p();r&&this.#f(r,{kind:"hello"})}ready(){if(this.#s||this.#e.state!=="started")return;let e=this.#p();e&&this.#f(e,{kind:"ready"});for(let t of this.#r.getElementsByTagName("iframe")){let r=this.#g(t);r&&this.#f(r,{kind:"hello"})}}prepare(e,t){let r=[];if(e.parent){let o=this.#p();if(!o)throw new Error("This page has no parent frame");r.push(o)}if(e.iframe!==void 0){let o=e.iframe,a=Y(o),l=typeof o=="string"?this.#r.getElementById(o):a instanceof we?this.#e.dom.getDomNode(a):null,u=this.#g(l);if(!u)throw new Error("iframe destination must be an active Gramlot iframe ID or Source reference");r.push(u)}let i=r.map(o=>{let a=this.#i.get(o.window);if(!a||a.origin!==o.origin)throw new Error("Destination page is not ready");return{...o,session:a.session}});Bt(t);let s=U(t);return()=>{if(!this.#s)for(let o of i){let a=this.#_(o.window);if(!a||a.origin!==o.origin||this.#i.get(o.window)?.session!==o.session)throw new Error("Destination page disconnected before publication");this.#f(o,{kind:"publish",recipient:o.session,topic:e.topic,wire:s})}}}dispose(){this.#s||(this.#c(),this.#s=!0,this.#t.removeEventListener("message",this.#o),this.#t.removeEventListener("pagehide",this.#l),this.#t.removeEventListener("pageshow",this.#u),this.#r.removeEventListener("load",this.#a,!0))}#c(){for(let[e,t]of this.#i)this.#f({window:e,origin:t.origin},{kind:"close"});for(let e of this.#i.keys())this.#d(e)}#d(e){this.#i.get(e)?.release?.(),this.#i.delete(e)}#h(e,t){this.#d(e.window);let r={session:t,origin:e.origin};e.node&&(r.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#f(e,{kind:"close"}),this.#d(e.window)})),this.#i.set(e.window,r)}#m(e){if(this.#s||e.data?.type!==Bc)return;let t=this.#_(e.source);if(!t||e.origin!==t.origin)return;let r=e.data;if(!(typeof r.session!="string"||!r.session)){if(r.kind==="hello")this.#d(t.window),r.ready===!0&&this.#h(t,r.session),this.#e.state==="started"&&this.#f(t,{kind:"ready"});else if(r.kind==="ready"){let i=this.#i.get(t.window)?.session!==r.session;this.#h(t,r.session),i&&this.#e.state==="started"&&this.#f(t,{kind:"ready"})}else if(r.kind==="close")this.#i.get(t.window)?.session===r.session&&this.#d(t.window);else if(r.kind==="publish"){if(this.#e.state!=="started"||r.recipient!==this.#n||this.#i.get(t.window)?.session!==r.session||typeof r.topic!="string"||!r.topic||typeof r.wire!="string")return;this.#e.publish(r.topic,P(r.wire))}}}#f(e,t){e.window.postMessage({type:Bc,session:this.#n,ready:this.#e.state==="started",...t},e.origin==="null"?"*":e.origin)}#p(){let e=this.#t.parent;return e===this.#t?null:{window:e,origin:this.#b(this.#r.referrer||this.#r.baseURI)}}#g(e){if(e?.localName!=="iframe"||!e.isConnected||!e.contentWindow)return null;let t=this.#e.dom.getBaseSourceNode(e);if(!t||!this.#e.src.binding.bindingFor(t)||this.#e.dom.getDomNode(t)!==e)return null;let r=e.getAttribute("sandbox"),s=r!==null&&!r.split(/\s+/).includes("allow-same-origin")?"null":this.#b(e.hasAttribute("srcdoc")?this.#r.baseURI:e.getAttribute("src")||this.#r.baseURI);return{window:e.contentWindow,origin:s,node:t}}#b(e){let t=new URL(e,this.#r.baseURI);return t.protocol==="file:"?"null":t.origin}#_(e){let t=this.#p();if(t?.window===e)return t;for(let r of this.#r.getElementsByTagName("iframe")){let i=this.#g(r);if(i?.window===e)return i}return null}};var Cs=class extends Se{#e=new Map;#t=new WeakSet;#r=new WeakMap;#n=0;#i=!1;#s;attach(e){this.#s=new Ss(this.gramlot,e)}ready(){this.#s.ready()}subscribe(e,t){if(this.#l(),this.#a(e),typeof t!="function")throw new TypeError("subscribe requires a callback");let r=Object.freeze({});return this.#t.add(r),this.#e.has(e)||this.#e.set(e,new Map),this.#e.get(e).set(r,t),r}unsubscribe(e){if(!this.#t.has(e))throw new TypeError("Unknown subscription registration");for(let[t,r]of this.#e)r.delete(e)&&!r.size&&this.#e.delete(t)}publish(e,t={}){if(this.#l(),!t||typeof t!="object"||Array.isArray(t))throw new TypeError("publish requires one object of named data");if(typeof e=="string")return this.#o(e,t);if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("publish requires a topic string or descriptor");if(Object.keys(e).some(s=>!["topic","nodeId","parent","iframe"].includes(s)))throw new Error("This publication route is not implemented yet");if(this.#a(e.topic),e.parent!==void 0&&typeof e.parent!="boolean")throw new TypeError("parent must be boolean");if(e.iframe==="*")throw new Error("Recursive iframe broadcast is not implemented yet");if((e.parent||e.iframe!==void 0)&&Object.hasOwn(e,"nodeId"))throw new Error("Interframe node addressing is not implemented yet");let i=e.parent||e.iframe!==void 0?this.#s.prepare(e,t):null;if(Object.hasOwn(e,"nodeId")){let s=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!s)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(s,e.topic,t)}this.#o(e.topic,t),i?.()}topicFor(e,t){this.#a(t),e=Y(e);let r=this.gramlot.src.binding.bindingFor(e);if(!r||r.closed)throw new Error("Topic target is not an active Source node of this page");let i=e.getAttr("nodeId");return i==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#n}`),i=this.#r.get(e)),`${i}_${t}`}publishNode(e,t,r={}){return this.publish(this.topicFor(e,t),r)}subscribeNode(e,t){let r=[];for(let[i,s]of Object.entries(e.getAttr())){let o=i.startsWith("selfsubscribe_")?"selfsubscribe_":i.startsWith("subscribe_")?"subscribe_":null;if(!o)continue;let a=o==="selfsubscribe_"?this.topicFor(e,i.slice(o.length)):i.slice(o.length);this.#a(a),r.push([a,t(i,s,a)])}return this.#l(),r.map(([i,s])=>{let o=this.subscribe(i,s);return{close:()=>this.unsubscribe(o)}})}dispose(){this.#i=!0,this.#s.dispose(),this.#e.clear()}#o(e,t){this.#a(e);let r=this.#e.get(e);if(r)for(let[i,s]of[...r]){if(this.#i)break;r.has(i)&&s(t)}}#a(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#l(){if(this.#i)throw new Error("Gramlot subscriptions are disposed")}};var Rc=2e3;function Hg(n){if(!(n instanceof Date))return String(n??"");let e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}var Qn=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof D))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],r=(i,s)=>{for(let o of i.getNodes()){let a=s+o.label;o.value instanceof D?r(o.value,`${a}.`):t.push(`${a}: ${Hg(o.value)}`)}};return r(this.branch(e),""),t.join(`
129
- `)}mailtoUrl(e,t){let r=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(r.length>Rc)throw new Error(`gramlot.utl.inout.sendMail: the email of '${e}' is ${r.length} characters long, over the mailto: limit of ${Rc}; send it with sendHttp or save it as a file`);return r}sendMail(e,t){this.open(this.mailtoUrl(e,t))}async sendHttp(e,t){let r=JSON.stringify(this.branch(e).asDict(!1,!1,!0)),i=await this.document.defaultView.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:r});if(!i.ok)throw new Error(`gramlot.utl.inout.sendHttp: ${t} answered ${i.status}`);return i}save(e,t){this.saveText(this.branch(e).toTytx(),t,"application/json")}restore(e){let t=this.document.createElement("input");return t.type="file",t.accept=".json,application/json",new Promise((r,i)=>{t.addEventListener("change",async()=>{try{let s=P(await t.files[0].text());if(!(s instanceof D))throw new TypeError("the file must contain a typed Bag");this.gramlot.data.setItem(e,s),r(s)}catch(s){i(new Error(`gramlot.utl.inout.restore: the file is not a saved Gramlot branch: ${s.message}`,{cause:s}))}},{once:!0}),t.click()})}download(e,t,r){if(!["json","xml"].includes(r))throw new Error(`gramlot.utl.inout.download: format '${r}' is not 'json' or 'xml'`);let i=this.branch(e);if(r==="json")this.saveText(i.toJson(!1),t,"application/json");else{let s=e.split(".").at(-1);this.saveText(`<?xml version='1.0' encoding='UTF-8'?>
130
- <${s}>${i.toXml()}</${s}>`,t,"application/xml")}}saveText(e,t,r){let i=this.document.defaultView,s=i.URL.createObjectURL(new i.Blob([e],{type:r}));this.open(s,t),i.setTimeout(()=>i.URL.revokeObjectURL(s),1e3)}open(e,t=null){let r=this.document.createElement("a");r.href=e,t!==null&&(r.download=t),r.click()}};var ei=class extends Se{constructor(e,t){super(e),this.inout=new Qn(e,t)}};var ti=class{constructor({pageId:e,rpcUrl:t="/gramlot/rpc",closeUrl:r="/gramlot/close",rootId:i="gramlot-root",capabilities:s=[],element:o=null,document:a=o?.ownerDocument??globalThis.document,transport:l=null,collections:u=[],locale:c=null,timeZone:d=null,devices:f=[],serverAdapter:h=new ut,nameSyntax:p=null}={}){as.register(a.defaultView);for(let b of u)b instanceof St&&b.register(a.defaultView);this.commands=new Yr,this.pageId=e;let m=c==null||d==null?a.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...f]),this.locale=c??m.locale,this.timeZone=d??m.timeZone,Object.defineProperty(this,"_subscriptions",{value:new Cs(this)}),this.capabilities=Object.freeze([...s]),this.serverAdapter=h,this.src=new Yn(this,{collections:u,destination:o??a.getElementById(i),subscriptions:this._subscriptions,nameSyntax:p===null?Mn:Qt.fromJSON(p)}),this.data=this.src.builder.data,this.rpc=new Jn(this,{rpcUrl:t,closeUrl:r,document:a,transport:l}),this.dom=new Kn(this),this.utl=new ei(this,a),this.state="ready",this._subscriptions.attach(a),this.abort=new AbortController,this.rpc.transport&&(this.pagehide=b=>{b.persisted||this.dispose({beacon:!0})},a.defaultView.addEventListener("pagehide",this.pagehide),this.window=a.defaultView)}publish(e,t={}){return this._subscriptions.publish(e,t)}subscribe(e,t){return this._subscriptions.subscribe(e,t)}unsubscribe(e){this._subscriptions.unsubscribe(e)}format(e,t){return nc(e,t,{locale:this.locale,timeZone:this.timeZone})}start(){return this.state==="disposed"?Promise.reject(new Error("Gramlot is disposed")):this.rpc.transport?this.loading?this.loading:this.state==="started"?Promise.resolve(this):(this.state="loading",this.loading=this.loadMain().finally(()=>{this.loading=null}),this.loading):Promise.reject(new Error("This Gramlot instance has no server transport"))}async loadMain(){let e;try{e=await this.rpc.callEnvelope("source","main")}catch(t){throw this.state==="disposed"?new Error("Gramlot was disposed during main",{cause:t}):(this.state="failed",t)}if(this.state==="disposed")throw new Error("Gramlot was disposed during main");try{return this.src.mountMainSource(e.value,e.data)}catch(t){throw this.state!=="disposed"&&(this.state="failed"),t}}dispose({beacon:e=!1}={}){if(this.state!=="disposed"){this.state="disposed",this._subscriptions.dispose(),this.pagehide&&this.window.removeEventListener("pagehide",this.pagehide),this.abort.abort();try{try{this.src.binding.dispose()}finally{this.src.renderer.dispose()}}finally{this.rpc.transport&&(this.rpc.transport.close(this.pageId,{beacon:e}),this.rpc.transport.dispose())}}}};var la=class{constructor({config:e,resources:t,document:r=globalThis.document}){this.config=e,this.resources=t,this.document=r,this.serverAdapter=new ut}async run(){let{config:e,resources:t,document:r}=this,i=r.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));let s=!1,o,a,l=[],u=new Promise(d=>{o=d}),c=d=>{d.persisted||s||(s=!0,this.closePage(),o(null))};i.addEventListener("pagehide",c);try{let d=t.css.map(_=>new Promise((w,v)=>{let k=r.createElement("link");k.rel="stylesheet",k.href=_;let E=()=>{k.removeEventListener("load",C),k.removeEventListener("error",L)};l.push(E);let C=()=>{E(),w()},L=()=>{E(),v(new Error(`${_}: stylesheet load failed`))};k.addEventListener("load",C),k.addEventListener("error",L),r.head.append(k)})),f=t.js.map(async({url:_,group:w})=>{try{return{logicClass:(await import(new URL(_,r.baseURI).href)).Logic,group:w,resource:_}}catch(v){throw new Error(`${_}: import failed: ${v.message}`,{cause:v})}}),h=new Set,p=(t.collections??[]).map(async _=>{if(!_||typeof _!="object"||Object.keys(_).sort().join(",")!=="buildId,name,url"||typeof _.name!="string"||typeof _.url!="string"||typeof _.buildId!="string"||!/^sha256:[0-9a-f]{64}$/.test(_.buildId)||h.has(_.name))throw new TypeError("Invalid or duplicate collection bootstrap record");h.add(_.name);let{name:w,url:v,buildId:k}=_,E;try{E=await import(new URL(v,r.baseURI).href)}catch(C){throw new Error(`${w}: collection import failed: ${C.message}`,{cause:C})}if(E.default?.name!==w||E.buildId!==k)throw new Error(`${w}: collection identity mismatch; expected ${k}, received ${E.buildId}`);return E.default}),m=await Promise.race([Promise.all([Promise.all(d),Promise.all(f),Promise.all(p)]),u]);if(s)return null;let[,b,g]=m;Wr.check(b);for(let _ of g)_.register(i);a=new ti({...e,document:r,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...g.map(_=>_.toDocument())]}),i.removeEventListener("pagehide",c);for(let _ of g)_.registerCommands(a);for(let{logicClass:_,group:w,resource:v}of b)a.src.logicRegistry.register(_,{group:w,resource:v});return i.gramlot=a,await a.start(),a}catch(d){throw a?a.dispose():s||this.closePage(),d}finally{for(let d of l)d();i.removeEventListener("pagehide",c)}}async loadServerAdapter(e){let t;try{t=await import(new URL(e,this.document.baseURI).href)}catch(r){throw new Error(`${e}: server adapter import failed: ${r.message}`,{cause:r})}return new t.default}closePage(){let e=this.serverAdapter.createTransport({...this.config,document:this.document});e.close(this.config.pageId,{beacon:!0}),e.dispose()}};var Ns=Symbol("gramlot.source"),ua=Symbol("gramlot.endpoint"),Wg=new Map([[Ns,"registerSource"],[ua,"registerEndpoint"]]);function $c(n,e,t,r){let i=Wg.get(t);if(e==="main")throw new TypeError(`${i} cannot declare main`);let s=Object.getOwnPropertyDescriptor(n.prototype,e)?.value;if(typeof s!="function")throw new TypeError(`${i} requires an own method of ${n.name}: ${String(e)}`);if(s[t])throw new TypeError(`${t===Ns?"Source method":"Endpoint"} already registered: ${e}`);if(s[Ns]||s[ua])throw new TypeError(`${e} is declared both as Source method and endpoint`);s[t]={auth:r}}var Is=class{static registerSource(e,{auth:t=null}={}){$c(this,e,Ns,t)}static registerEndpoint(e,{auth:t=null}={}){$c(this,e,ua,t)}},ri=class extends Is{static gramlots=[];static title="Gramlot";static devices=[];static locale=null;static timeZone=null;static installable=!1;static appIcon=null;manifest({baseUrl:e="./"}={}){let{title:t,appIcon:r}=this.constructor;if(typeof r!="string"||!r)throw new TypeError("An installable Page needs appIcon");return{id:e,name:t,short_name:t,start_url:e,scope:e,display:"standalone",icons:[{src:e+r.replace(/^\/+/,""),sizes:"512x512",type:"image/png"}]}}static css=[];static css_theme=null;static css_requires="";static js_requires="";static sourceBuilder=qe;main(e){throw new Error("Page.main(root) must be implemented")}};var Gr=class extends ri{static shellId="frame";static datapath=null;main(e){let t=e.div({id:this.constructor.shellId,datapath:this.constructor.datapath,class:"frame-page",height:"100vh",display:"flex",flex_direction:"column",min_height:0}),r=t.borderContainer({node_label:"frame",height:"100%",flex:"1",min_height:0});for(let i of["top","bottom","left","right","center"])if(this[i]!==void 0){let s=r.contentPane({region:i,node_label:i});this[i](s)}this.behavior(t)}center(e){}behavior(e){}};var ni=class extends Gr{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:r}=this.constructor;if(!(t instanceof D))throw new TypeError("IndexPage.navigation must be a Bag");e.dataSetter({destination_path:`${r}.navigation`,value:t}),e.dataSetter({destination_path:`${r}.navigationSelection`,value:null}),e.dataSetter({destination_path:`${r}.active`,value:null}),e.dataSetter({destination_path:`${r}.opened`,value:new D}),super.main(e)}left(e){e.setAttr({width:"240px",splitter:!0,drawer:!0,drawer_label:"Navigation"}),e.tree({node_label:"tree",storepath:`${this.constructor.datapath}.navigation`,labelAttribute:"title",hideValues:!0,selectedPath:`^${this.constructor.datapath}.navigationSelection`})}center(e){e.tabContainer({node_label:"tabs",height:"100%",selectedPage:`^${this.constructor.datapath}.active`})}behavior(e){e.dataController({func:"indexMount",_onStart:!0,shell_id:this.constructor.shellId})}index_panel(e,{selection:t}){this.panel(e,t.getNode("#0"))}panel(e,t){e.iframe({src:t.attr.url,title:t.attr.title??t.label,width:"100%",height:"100%",border:0})}};ni.registerSource("index_panel");function ca(n,e,t=()=>{},r=()=>{},{state:i=e.builder.data.getItem(e.getAttr("datapath")),createEntry:s=null,onLoad:o=()=>{}}={}){let a=i.getItem("navigation");if(!(a instanceof D))throw new TypeError("IndexPage navigation must be a Bag");let l=e.value.getNode("frame.center.tabs"),u=e.builder,c=new Map,d=!1,f=!1,h=0,p=null,m=i.getItem("opened");for(let k of m.getNodes()){let{url:E,path:C,title:L}=k.attr,q=l.value.getNode(k.label),ve={url:E,path:C,title:L,pane:q,node:a.getNode(C),loading:!1};r(ve),c.set(E,ve),h++}let b=k=>{if(!d){f=!0;try{i.setItem("active",k.url),i.setItem("navigationSelection",k.path),t(c,k.url)}finally{f=!1}}};async function g(k){let E=a.getNode(k);if(!E)throw new Error(`Unknown index navigation path: ${k}`);let C=E.attr.url;if(C==null)return;if(typeof C!="string"||!C)throw new TypeError("IndexPage URL must be nonempty text");p=C;let L=c.get(C);if(L){L.path=k,b(L);return}for(;l.value!==null&&l.value.getNode(`page${h}`);)h++;let q=Y(u.wrapSource(l).contentPane({node_label:`page${h++}`,title:E.attr.title??E.label,pageName:C,height:"100%"})),ve=i.getItem("active");L={url:C,path:k,node:E,pane:q,title:E.attr.title??E.label,loading:!0},c.set(C,L);try{if(b(L),o(C,"loading"),s)await s(L);else{let Z=new D;if(Z.setItem(E.label,null,{...E.attr}),!await n.binding.gramlot.src.remoteSource(q,"index_panel",{selection:Z}))throw new Error("Panel loading was cancelled")}if(d)return;L.loading=!1,m.setItem(q.label,null,{url:C,path:L.path,title:L.title}),r(L),p===C&&(o(C,"ready"),b(L))}catch(Z){if(c.delete(C),m.getNode(q.label)&&m.popNode(q.label),q.parentBag&&q.parentBag.popNode(q.label),!d&&p===C){o(C,"error",Z);let ne=c.get(ve);if(p=ne?.url??null,ne)b(ne);else{f=!0;try{i.setItem("active",null),i.setItem("navigationSelection",null),t(c,null)}finally{f=!1}}}}}let _=`${e.getAttr("id")}-selection`;i.subscribe(_,{any:k=>{if(!(f||d)){if(k.node===i.getNode("navigationSelection")){let E=i.getItem("navigationSelection");E!==null&&g(E)}else if(k.node===i.getNode("active")){let E=c.get(i.getItem("active"));E&&(p=E.url,b(E))}}}});let w=()=>{if(!d){d=!0,i.unsubscribe(_,{any:!0});for(let k of c.values())k.loading&&k.pane.parentBag&&k.pane.parentBag.popNode(k.pane.label)}};n.onDispose(e,w);let v=c.get(i.getItem("active"));return v?b(v):i.getItem("navigationSelection")!==null&&g(i.getItem("navigationSelection")),{entries:c,dispose:w}}var Os=class{indexMount(e,{shell_id:t}){let r=this.page.src.renderer,i=r.destination.ownerDocument.getElementById(t);this.index=ca(r,r.elements.get(i).node)}};function Bs(n,{datapath:e,value:t,language:r="text",height:i="420px",...s}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let o=n.borderContainer({datapath:e,height:i,class:"gramlot-editor-options"}),a={language:r,indentUnit:4,fontSize:14,fontFamily:"monospace",lineNumbers:!0,lineWrapping:!0,folding:!0,bracketMatching:!0,autoCloseBrackets:!0,autoIndent:!0,autocompletion:!0,highlightActiveLine:!0,highlightSelectionMatches:!0};for(let[d,f]of Object.entries(a))o.dataSetter({destination_path:`.settings.${d}`,value:f});let l=o.contentPane({region:"right",width:"250px",drawer:"close",drawer_label:"Options",drawer_icon:"\u2699",drawer_minimize:!1,padding:"12px",overflow:"auto",class:"gramlot-editor-settings"});l.h3("Editor options"),l.filteringSelect({value:"^.settings.language",lbl:"Language",values:"text:Plain text,python:Python,javascript:JavaScript,typescript:TypeScript,json:JSON,html:HTML,css:CSS,xml:XML,markdown:Markdown,sql:SQL,typst:Typst"}),l.numberTextBox({value:"^.settings.indentUnit",lbl:"Indent spaces",min:1,max:16,dtype:"L",validate_notnull:!0}),l.numberTextBox({value:"^.settings.fontSize",lbl:"Font size",min:8,max:48,dtype:"L",validate_notnull:!0}),l.textbox({value:"^.settings.fontFamily",lbl:"Font family"});let u={lineNumbers:"Line numbers",lineWrapping:"Wrap lines",folding:"Code folding",bracketMatching:"Match brackets",autoCloseBrackets:"Close brackets and quotes",autoIndent:"Automatic indentation",autocompletion:"Local completion",highlightActiveLine:"Highlight current line",highlightSelectionMatches:"Highlight matching selections"};for(let[d,f]of Object.entries(u))l.checkbox({value:`^.settings.${d}`,label:f,display:"block",margin_top:"8px"});return o.contentPane({region:"center",min_height:0}).codeMirror({...s,value:t,height:"100%",...Object.fromEntries(Object.keys(a).map(d=>[d,`^.settings.${d}`]))}),o}var ii=class n extends Ve{static internalParams=new Set([...Ve.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:r="",onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method="directory_tree",this.params={root:t,path:r},this.children=new Set}get closed(){return this.#e}startLoad(e){if(this.loading)return this.loading;let t=new AbortController;return this.#t=t,e({controller:t,method:this.method,params:this.params,ignored:!1})}async loadAsync({controller:e,method:t,params:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof D))throw new TypeError("directory_tree must return a Bag");for(let t of this.children)t.abort();this.children.clear();for(let t of e.getNodes())if(t.attr.is_directory){let r=new n({gramlot:this.gramlot,root:this.params.root,path:t.attr.path,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}},si=class{constructor(e,t){this.gramlot=e,this.state=t,this.request=null,this.resolver=null,this.disposed=!1}async open(e){this.request?.abort();let t=this.request=new AbortController;this.state.setItem("status","Opening directory\u2026");try{let r=await this.gramlot.rpc.call("data","workspace_open",{root:e},{signal:t.signal});if(this.disposed||t.signal.aborted)return null;let i=new ii({gramlot:this.gramlot,root:r.root,onError:o=>this.state.setItem("status",o.message)}),s=i.prepareValue(r.entries);return this.resolver?.abort(),this.resolver=i,this.state.setItem("selectedPath",null),this.state.setItem("store",s),this.state.setItem("root",r.root),this.state.setItem("status",""),r.root}catch(r){return!this.disposed&&!t.signal.aborted&&this.state.setItem("status",r.message),null}finally{this.request===t&&(this.request=null)}}dispose(){this.disposed=!0,this.request?.abort(),this.resolver?.abort()}},sr=class{fileSystemMount(e){this.fileSystems??=new WeakMap;let t=e.parentNode,r=t.getRelativeData("."),i=new si(this.page,r);this.fileSystems.set(r,i),this.page.src.renderer.onDispose(t,()=>i.dispose())}fileSystemOpen(e,{root:t}){if(t)return this.fileSystems.get(e.getRelativeData(".")).open(t)}};function Mc(n,{datapath:e,...t}){let r=n.div({datapath:e,class:"gramlot-filesystem",...t});return r.dataSetter({destination_path:".store",value:new D}),r.dataSetter({destination_path:".root",value:null}),r.dataSetter({destination_path:".requestedRoot",value:null}),r.dataSetter({destination_path:".selectedPath",value:null}),r.dataSetter({destination_path:".status",value:""}),r.dataController({func:"fileSystemMount",_onBuilt:!0}),r.dataController({func:"fileSystemOpen",root:"^.requestedRoot"}),r.tree({storepath:".store",selectedPath:"^.selectedPath",labelAttribute:"caption",hideValues:!0,class:"gramlot-filesystem-tree"}),r.div("^.status",{role:"status",class:"gramlot-filesystem-status"}),r}var Gg=(n,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([n,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Rs=class{constructor(e,t){this.gramlot=e,this.state=t,this.pending=new Map,this.disposed=!1}get documents(){return this.state.getItem("documents")}async open(e,t){let r=Gg(e,t),i=this.documents.getNodes().find(a=>!a.value.getItem("isNew")&&a.value.getItem("root")===e&&a.value.getItem("path")===t);if(i)return i.label;if(this.pending.has(r))return this.pending.get(r).promise;let s=new AbortController,o=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:s.signal}).then(a=>{if(this.disposed||s.signal.aborted)return null;let l=new D;for(let[u,c]of Object.entries({...a,root:e,saved:a.content,busy:!1}))l.setItem(u,c);return this.documents.setItem(r,l),r}).finally(()=>this.pending.delete(r));return this.pending.set(r,{request:s,promise:o}),o}newDocument(e,t,r=""){let i=`new_${crypto.randomUUID().replaceAll("-","")}`,s=new D;for(let[o,a]of Object.entries({language:e,root:r,path:`Untitled${t}`,content:"",saved:"",writable:!0,busy:!1,isNew:!0,createHidden:!0,saveRoot:r,savePath:`Untitled${t}`}))s.setItem(o,a);return this.documents.setItem(i,s),i}async create(e){let t=this.documents.getItem(e);if(!t||!t.getItem("isNew")||this.pending.has(e))return!1;let r=t.getItem("saveRoot"),i=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==i.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let s=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let a=this.gramlot.rpc.call("data","document_create",{root:r,path:i,content:s},{signal:o.signal}).then(l=>this.disposed||o.signal.aborted?!1:(t.setItem("root",l.root),t.setItem("path",l.path),t.setItem("revision",l.revision),t.setItem("saved",s),t.setItem("isNew",!1),t.setItem("createHidden",!0),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:o,promise:a}),a}invalidateRecipe(e){let t=this.documents.getItem(e);t.getItem("path").endsWith(".typ.py")&&(t.getItem("rendering")&&this.pending.get(e)?.request.abort(),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generate preview to render the current Python recipe."))}async renderRecipe(e){let t=this.documents.getItem(e);if(!t||!t.getItem("path").endsWith(".typ.py")||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("content"),i=new AbortController;t.setItem("busy",!0),t.setItem("rendering",!0),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generating Typst on the server\u2026");let s=this.gramlot.rpc.call("data","document_render_typst",{content:r},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted||t.getItem("content")!==r?!1:(t.setItem("typstSource",o.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(o=>(!this.disposed&&!i.signal.aborted&&t.setItem("renderStatus",o.message),!1)).finally(()=>{this.pending.delete(e),this.disposed||(t.setItem("rendering",!1),t.setItem("busy",!1))});return this.pending.set(e,{request:i,promise:s}),s}dirty(e){let t=this.documents.getItem(e);return t&&t.getItem("content")!==t.getItem("saved")}async save(e){let t=this.documents.getItem(e);if(!t||t.getItem("isNew")||!this.dirty(e)||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("content"),i=new AbortController;t.setItem("busy",!0);let s=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:r,revision:t.getItem("revision")},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted?!1:(t.setItem("revision",o.revision),t.setItem("saved",r),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:i,promise:s}),s}revert(e){let t=this.documents.getItem(e);return!t||!this.dirty(e)||this.pending.has(e)?!1:(t.setItem("content",t.getItem("saved")),!0)}canClose(e,t=!1){return!this.pending.has(e)&&(t||!this.dirty(e))}close(e,t=!1){return this.canClose(e,t)?(this.documents.popNode(e),this.state.getItem("active")===e&&this.state.setItem("active",this.documents.getNodes()[0]?.label??null),!0):!1}dispose(){this.disposed=!0;for(let{request:e}of this.pending.values())e.abort()}},$s=class{constructor(e){this.storage=e,this.key="gramlot.ide.recentWorkspaces"}read(){let e=this.storage.getItem(this.key),t=e===null?[]:JSON.parse(e);if(!Array.isArray(t)||t.some(r=>typeof r!="string"||!r))throw new TypeError("Invalid recent workspace preference");return t.slice(0,6)}remember(e){let t=[e,...this.read().filter(r=>r!==e)].slice(0,6);return this.storage.setItem(this.key,JSON.stringify(t)),t}choices(e=this.read()){let t=new D;return e.forEach((r,i)=>t.setItem(`r${i}`,r,{caption:r})),t}};var Ms=class{fileSystemMount(e){return sr.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return sr.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){this.ideRoot=e.parentNode,this.ideState=e.getRelativeData("."),this.ideDocuments=new Rs(this.page,this.ideState),this.idePanels=new Map,this.ideDisposed=!1,this.ideRequested=0,this.ideRecent=new $s(this.page.src.renderer.destination.ownerDocument.defaultView.sessionStorage);let t=this.ideRecent.read();this.ideState.setItem("recent",this.ideRecent.choices(t)),this.ideState.setItem("workspace",t[0]??"");let r=this.ideState.getItem("browser");r.subscribe("ide-browser",{any:i=>{if(i.node===r.getNode("root")){let s=r.getItem("root");this.ideState.setItem("workspace",s),this.ideState.setItem("recent",this.ideRecent.choices(this.ideRecent.remember(s))),this.ideState.setItem("status",`Workspace: ${s}`)}else if(i.node===r.getNode("selectedPath")){let s=r.getItem("selectedPath"),o=s===null?null:r.getItem("store").getNode(s);o&&!o.attr.is_directory&&this.ideOpenDocument(r.getItem("root"),o.attr.path)}}}),this.ideDocuments.documents.subscribe("ide-documents",{any:i=>{if(["content","saved","busy","writable","view","isNew","path","root"].includes(i.node.label))for(let[s,o]of this.idePanels){let a=this.ideDocuments.documents.getItem(s);a&&(i.node===a.getNode("content")&&this.ideDocuments.invalidateRecipe(s),this.ideDocumentState(s),o.setAttr({title:`${this.ideDocuments.dirty(s)?"\u25CF ":""}${a.getItem("path")}`}))}}}),this.page.src.renderer.onDispose(this.ideRoot,()=>{this.ideDisposed=!0,r.unsubscribe("ide-browser",{any:!0}),this.ideDocuments.documents.unsubscribe("ide-documents",{any:!0}),this.ideDocuments.dispose()})}ideOpenWorkspace(){let e=this.ideState.getItem("workspace");e&&e!==this.ideState.getItem("browser.root")&&this.ideState.setItem("browser.requestedRoot",e)}ideDocumentState(e){let t=this.ideDocuments.documents.getItem(e),r=!this.ideDocuments.dirty(e)&&!t.getItem("isNew")||t.getItem("busy");t.setItem("saveDisabled",!!(r||!t.getItem("writable"))),t.setItem("revertDisabled",!!(!this.ideDocuments.dirty(e)||t.getItem("busy"))),t.setItem("displayPath",t.getItem("isNew")?t.getItem("path"):`${t.getItem("root")}/${t.getItem("path")}`),t.setItem("pdfFilename",t.getItem("path").split("/").at(-1).replace(/\.typ(?:\.py)?$/i,".pdf")),t.setItem("renderDisabled",!!(t.getItem("busy")||!t.getItem("writable"))),this.ideHistoryState(t)}async ideOpenDocument(e,t){let r=++this.ideRequested;try{let i=await this.ideDocuments.open(e,t);if(i===null||this.ideDisposed)return;this.ideShowDocument(i),r===this.ideRequested&&(this.ideState.setItem("active",i),this.ideState.setItem("status",`${t}${this.ideDocuments.documents.getItem(i).getItem("writable")?"":" (read only)"}`))}catch(i){this.ideDisposed||this.ideState.setItem("status",i.message)}}ideNew(){let e=this.ideState.getItem("newType"),t=e==="typstRecipe"?"python":e,r={typstRecipe:".typ.py",typst:".typ",markdown:".md",html:".html",python:".py",javascript:".js",typescript:".ts",json:".json",css:".css",sql:".sql",xml:".xml",text:".txt"},i=this.ideDocuments.newDocument(t,r[e],this.ideState.getItem("workspace"));++this.ideRequested,this.ideShowDocument(i),this.ideState.setItem("active",i),this.ideState.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e){let r=this.ideDocuments.documents.getItem(e).getItem("path");if(!this.idePanels.has(e)){let i=this.ideDocuments.documents.getItem(e),s=r.endsWith(".typ.py");s&&this.ideDocuments.invalidateRecipe(e),i.setItem("readonly",!i.getItem("writable")),this.ideDocumentState(e),i.setItem("view","code"),i.setItem("createHidden",!0),i.setItem("undoDisabled",!0),i.setItem("redoDisabled",!0);let o=this.ideRoot.value.getNode("frame.center.tabs"),a=Y(o.builder.wrapSource(o).contentPane({node_label:e,title:r,pageName:e,documentKey:e,closable:!0,onClose:"ideClose",height:"100%"}));this.idePanels.set(e,a);let l=a.builder.wrapSource(a).div({display:"flex",flex_direction:"column",height:"100%"}),u=l.div({datapath:`.documents.${e}`,display:"flex",align_items:"center",gap:"6px",padding:"4px 12px",height:"40px",flex_shrink:0,box_sizing:"border-box",class:"gramlot-ide-document-toolbar",role:"toolbar","aria-label":`Commands for ${r}`});for(let[w,v,k,E]of[["save","M5 3h12l4 4v14H3V3h2 M7 3v6h10V3 M7 21v-8h10v8","Save","ideSave"],["revert","M3 10a9 9 0 1 1 2 8 M3 4v6h6 M12 7v5l3 2","Revert to saved","ideRevert"],["undo","M9 5 3 11l6 6 M3 11h12a6 6 0 0 1 6 6v2","Undo","ideUndo"],["redo","m15 5 6 6-6 6 M21 11H9a6 6 0 0 0-6 6v2","Redo","ideRedo"]]){let C=u.button({title:k,"aria-label":k,disabled:`^.${w}Disabled`,class:`button--quiet gramlot-ide-${w}`});C.svg({viewBox:"0 0 24 24",width:18,height:18,fill:"none",stroke:"currentColor",stroke_width:1.7,stroke_linecap:"round",stroke_linejoin:"round","aria-hidden":"true"}).path({d:v}),C.dataController({func:E,documentKey:e})}s&&u.button("Generate preview",{disabled:"^.renderDisabled",class:"button--quiet"}).dataController({func:"ideRenderRecipe",documentKey:e}),u.div("^.displayPath",{class:"gramlot-ide-document-path",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap",min_width:0,flex:"1"});let c=l.div({datapath:`.documents.${e}`,hidden:"^.createHidden",padding:"8px 12px",display:"flex",gap:"8px",align_items:"end",flex_shrink:0});c.textbox({value:"^.saveRoot",lbl:"Directory",flex:"1",disabled:"^.busy"}),c.textbox({value:"^.savePath",lbl:"File name",flex:"1",disabled:"^.busy"}),c.button("Create file",{disabled:"^.busy"}).dataController({func:"ideCreate",documentKey:e}),c.button("Cancel",{disabled:"^.busy",class:"button--quiet"}).dataController({func:"ideCancelCreate",documentKey:e});let d=l.div({flex:"1",min_height:0}),f=i.getItem("language")==="html",h=i.getItem("language")==="markdown",p=f||h,m=i.getItem("language")==="typst",b=p||m||s,g=b?d.tabContainer({height:"100%",selectedPage:`^.documents.${e}.view`}):null,_=b?g.contentPane({title:"Code",pageName:"code",height:"100%"}):d;if(Bs(_,{datapath:`.documents.${e}`,value:"^.content",language:i.getItem("language"),height:"100%",readonly:"^.readonly",nodeId:`editor_${e}`,editorView:"code",selfsubscribe_historyChanged:"ideHistoryChanged"}),l.dataController({func:"ideSave",documentKey:e,[`subscribe_editor_${e}_save`]:!0}),m&&g.contentPane({title:"Preview",pageName:"preview",height:"100%"}).typstPreview({value:`^.documents.${e}.content`,filename:`^.documents.${e}.pdfFilename`,height:"100%"}),s){let w=g.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});w.div(`^.documents.${e}.renderStatus`,{role:"status",padding:"8px 12px",white_space:"pre-wrap",overflow:"auto",max_height:"30%"}),w.typstPreview({value:`^.documents.${e}.typstSource`,filename:`^.documents.${e}.pdfFilename`,hidden:`^.documents.${e}.previewHidden`,flex:"1",min_height:0}),g.contentPane({title:"Generated Typst",pageName:"generated",height:"100%"}).codeMirror({value:`^.documents.${e}.typstSource`,language:"typst",readonly:!0,height:"100%"})}if(p){let w=g.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});h&&(i.setItem("allowHtml",!1),w.checkbox({value:`^.documents.${e}.allowHtml`,label:"Allow embedded HTML",class:"gramlot-ide-allow-html",padding:"8px 12px",flex_shrink:0})),w[f?"htmlPreview":"markdownPreview"]({value:`^.documents.${e}.content`,flex:"1",min_height:0,...h?{allowHtml:`^.documents.${e}.allowHtml`}:{}}),g.contentPane({title:"Rich text",pageName:"rich",height:"100%"})[f?"htmlEditor":"markdownEditor"]({datapath:`.documents.${e}`,value:"^.content",readonly:"^.readonly",height:"100%",nodeId:`rich_editor_${e}`,editorView:"rich",selfsubscribe_historyChanged:"ideHistoryChanged"}),l.dataController({func:"ideSave",documentKey:e,[`subscribe_rich_editor_${e}_save`]:!0})}}}async ideRenderRecipe(e,{documentKey:t}){this.ideDocuments.documents.getItem(t).setItem("view","preview"),await this.ideDocuments.renderRecipe(t)}ideCancelCreate(e,{documentKey:t}){this.ideDocuments.documents.getItem(t).setItem("createHidden",!0)}async ideCreate(e,{documentKey:t}){this.ideState.setItem("status","Creating file\u2026");try{let r=await this.ideDocuments.create(t);if(!this.ideDisposed&&r){this.ideState.setItem("status","File created.");let i=this.ideState.getItem("browser");i.getItem("root")&&await this.fileSystems.get(i).open(i.getItem("root"))}}catch(r){this.ideDisposed||this.ideState.setItem("status",r.message)}}async ideSave(e,{documentKey:t=null}={}){let r=t??this.ideState.getItem("active");if(!r||this.ideDocuments.documents.getItem(r).getItem("saveDisabled"))return;let i=this.ideDocuments.documents.getItem(r);if(i.getItem("isNew")){i.setItem("createHidden",!1);return}this.ideState.setItem("status","Saving\u2026");try{let s=await this.ideDocuments.save(r);this.ideDisposed||this.ideState.setItem("status",s?"Saved.":"Document is read only or a request is pending.")}catch(s){this.ideDisposed||this.ideState.setItem("status",s.message)}}ideRevert(e,{documentKey:t}){this.ideDocuments.revert(t)&&this.ideState.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:r}){let i=e.getRelativeData("."),s=e.getAttr("editorView");i.setItem(`${s}CanUndo`,t),i.setItem(`${s}CanRedo`,r),this.ideHistoryState(i)}ideHistoryState(e){let t=e.getItem("view");e.setItem("undoDisabled",!e.getItem(`${t}CanUndo`)),e.setItem("redoDisabled",!e.getItem(`${t}CanRedo`))}ideEditor(e){let t=this.ideDocuments.documents.getItem(e).getItem("view")==="rich",r=this.page.src.binding.nodeIds.get(`${t?"rich_":""}editor_${e}`);return this.page.src.renderer.records.get(r).element}ideUndo(e,{documentKey:t}){this.ideEditor(t).undo()}ideRedo(e,{documentKey:t}){this.ideEditor(t).redo()}ideClose(e){let t=e.getAttr("documentKey");return this.ideDocuments.canClose(t)?!0:(this.ideState.setItem("status","Save or revert your changes before closing. Pending operations must finish first."),!1)}ideClosed(e,{pageName:t}){this.ideForgetDocument(t)}ideForgetDocument(e,t=!1){let r=this.ideDocuments.documents.getItem(e),i=this.ideState.getItem("browser"),s=i.getItem("selectedPath"),o=s===null?null:i.getItem("store").getNode(s);r&&i.getItem("root")===r.getItem("root")&&o?.attr.path===r.getItem("path")&&i.setItem("selectedPath",null),this.idePanels.delete(e),this.ideDocuments.close(e,t)}};var da=class n extends Ve{static internalParams=new Set([...Ve.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:r,onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method=t,this.params={directory:r},this.children=new Set}get closed(){return this.#e}startLoad(e){if(this.loading)return this.loading;let t=new AbortController;return this.#t=t,e({controller:t,method:this.method,params:this.params,ignored:!1})}async loadAsync({controller:e,method:t,params:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof D))throw new TypeError("Directory navigation must return a Bag");for(let t of this.children)t.abort();this.children.clear();for(let t of e.getNodes())if(t.attr.directory!==void 0){let r=new n({gramlot:this.gramlot,method:this.method,directory:t.attr.directory,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}};function or(n,e){return e===2?n%4===0&&(n%100!==0||n%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function Ce(n,e,t){if(![n,e,t].every(Number.isInteger)||n<1||n>9999||e<1||e>12||t<1||t>or(n,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(n).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function ar(n){if(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(n))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=n.split("-").map(Number);return Ce(...e),e}function oi(n,e,t){let r=n-1,i=365*r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400)+t-1;for(let s=1;s<e;s++)i+=or(n,s);return i}function ai(n,e){let t=oi(...ar(n))+e;if(!Number.isSafeInteger(t)||t<0||t>oi(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let r=1,i=1e4;for(;i-r>1;){let o=Math.floor((r+i)/2);oi(o,1,1)<=t?r=o:i=o}t-=oi(r,1,1);let s=1;for(;t>=or(r,s);)t-=or(r,s++);return Ce(r,s,t+1)}function fa(n){return ai(n,-(oi(...ar(n))%7))}function Lc(n,e,t=0,r=1){let i=n*12+e-1+t,s=Math.floor(i/12),o=(i%12+12)%12+1,a=i+r-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:Ce(s,o,1),end:Ce(l,u,or(l,u))}}var ha={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"}},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"}}};function Pc(n){if(typeof n!="string")throw new RangeError("A supported locale is required.");let e=n.replaceAll("-","_"),t=e.indexOf("_"),r=(t<0?e:e.slice(0,t)).toLowerCase(),i=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(ha,r))throw new RangeError(`Unsupported locale: ${n}`);let s=ha[r];return{dictionary:s,phrases:a=>[...new Set([...s.keywords[a],...ha.en.keywords[a]])],order:s.date_order[i]??s.date_order.default}}var lr=/^(?:\d{4}|\d{2})$/,jc=/^\d{1,2}$/,li=(n,e)=>({ok:!1,error:{code:n,message:e}}),cr=(n="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:n})},qc=(n,e)=>Object.hasOwn(n,e);function ur(n,e){if(n.length===4)return Number(n);let t=e.year+e.twoDigitYearAhead-100;return t+((Number(n)-t)%100+100)%100}function Xg(n,e){if(n.includes(";")){let i=n.split(";").map(s=>s.trim());return i.length!==2?cr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:i,range:!0}}if(e.phrases("no_period").includes(n))return{bounds:["",""],range:!0};let t=e.phrases("to"),r=e.phrases("from");for(let i of t)if(n.startsWith(`${i} `))return{bounds:["",n.slice(i.length+1).trim()],range:!0};for(let i of t){let s=` ${i} `;if(!n.includes(s))continue;for(let a of r)if(n.startsWith(`${a} `)){n=n.slice(a.length+1);break}let o=n.split(s).map(a=>a.trim());return o.length!==2?cr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let i of r)if(n.startsWith(`${i} `))return{bounds:[n.slice(i.length+1).trim(),""],range:!0};return{bounds:[n,n],range:!1}}function Yg(n,e,t){let r=[[n,0]],i=/^(.+?)\s*([+-])\s*(\d+)$/.exec(n);i&&r.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 r)for(let[l,u]of Object.entries(s))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return ai(fa(e.workdate),(u+a)*7+(t?6:0));if(l.endsWith("_month")){let c=Lc(e.year,e.month,u+a);return t?c.end:c.start}return ai(e.workdate,u+a)}return null}function Zg(n,e,t){let r=Object.entries(e.dictionary.quarters).sort((i,s)=>s[0].length-i[0].length);for(let[i,s]of r){let o;if(n===i)o=null;else if(n.startsWith(i)&&lr.test(n.slice(i.length).trim()))o=ur(n.slice(i.length).trim(),e);else if(n.endsWith(i)&&lr.test(n.slice(0,-i.length).trim()))o=ur(n.slice(0,-i.length).trim(),e);else continue;return{year:o,month:t?s*3:s*3-2}}return null}function Fc(n,e){if(qc(e.months,n))return e.months[n];let t=/^m(\d{1,2})$/.exec(n);return t&&Number(t[1])>=1&&Number(t[1])<=12?Number(t[1]):null}function Jg(n,e){let t=n.split(/\s+/),r=t.map((u,c)=>Fc(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!r.length)return null;if(r.length!==1)return cr();let i=r[0],s=Fc(t[i],e.dictionary),o=t.slice(0,i),a=t.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&&lr.test(a[0]))return{year:ur(a[0],e),month:s};if(o.length===1&&jc.test(o[0])){if(!a.length)return Ce(e.year,s,Number(o[0]));if(a.length===1&&lr.test(a[0]))return Ce(ur(a[0],e),s,Number(o[0]))}return!o.length&&a.length===2&&jc.test(a[0])&&lr.test(a[1])?Ce(ur(a[1],e),s,Number(a[0])):cr()}function Kg(n,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(t)return Ce(...t.slice(1).map(Number));let r=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(n),i={};if(r)e.order.split("").forEach((a,l)=>{i[a]=r[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(n)){let a=n.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;i[l]=n.slice(0,u),n=n.slice(u)}}else return null;if(!lr.test(i.Y)||i.D.length>2||i.M.length>2)return cr();let s=Number(i.D),o=Number(i.M);return r&&o>12&&s<=12&&([s,o]=[o,s]),Ce(ur(i.Y,e),o,s)}function Uc(n,e,t){if(!n)return null;let r=e.phrases("articles");if(n=n.split(/\s+/).filter(s=>!r.includes(s)).join(" "),!n)return cr();if(lr.test(n))return Ce(ur(n,e),t?12:1,t?31:1);let i=Yg(n,e,t)??Zg(n,e,t)??Jg(n,e);return i!==null?i:qc(e.dictionary.weekdays,n)?ai(fa(e.workdate),e.dictionary.weekdays[n]):Kg(n,e)??cr()}function Qg(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year,i=typeof e=="string"?ar(e)[0]:e?.year,s=typeof e=="string"?ar(e)[1]:e?.month;return i&&(r>i&&(r=i),r===i&&n.month>s&&r--),Ce(r,n.month,1)}function eb(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year;if(e!==null){let[i,s]=ar(e);r<i&&(r=i),r===i&&s>n.month&&r++}return Ce(r,n.month,or(r,n.month))}function tb(n,e={}){if(!e||typeof e!="object"||Array.isArray(e))return li("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:r="it-IT",workdate:i,twoDigitYearAhead:s=20}=e,[o,a]=ar(i);if(!Number.isInteger(s)||s<0||s>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...Pc(r),workdate:i,year:o,month:a,twoDigitYearAhead:s}}catch(r){return li("INVALID_CONTEXT",r.message)}if(typeof n!="string")return li("INVALID_INPUT","Expression must be a string.");try{let r=n.toLowerCase().trim().replaceAll(",",""),{bounds:i,range:s}=Xg(r,t),o=Uc(i[1],t,!0),a=Uc(i[0],t,!1),l=Qg(a,o,t),u=eb(o,l,t);return!s&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(r){if(r instanceof RangeError)return li("INVALID_DATE",r.message);if(r instanceof SyntaxError)return li(r.code,r.message);throw r}}var Vc=["TL","TC","TR","L","R","BL","BC","BR"];function rb(n,e,t,r){let i=t(e);for(let s of new Set([...Object.keys(r),...Object.keys(i)]))i[s]==null?n.removeAttribute(s):n.setAttribute(s,String(i[s]));return i}function zc(n){return class extends n{#e={box:{},label:{},labelBox:{},controlBox:{}};constructor(){super(),this.box=this.ownerDocument.createElement("div"),this.box.className="labelbox",this.labelBox=this.ownerDocument.createElement("div"),this.labelBox.className="label-box",this.fieldLabel=this.ownerDocument.createElement("label"),this.fieldLabel.id="field-label",this.fieldLabel.htmlFor="control",this.labelBox.append(this.fieldLabel),this.box.append(this.labelBox,this.controlBox);let e=this.ownerDocument.createElement("style");e.textContent=`.labelbox{--gramlot-label-width:initial;--gramlot-formlet-label-width:initial;display:grid;gap:var(--gramlot-label-gap,.25em);grid-template-areas:'label' 'control'}
131
- .label-box{grid-area:label;color:var(--gramlot-label-color,var(--gramlot-text-secondary,inherit));font-size:var(--gramlot-label-size,1em)} .control-box{grid-area:control}
132
- .labelbox[data-position='L']{grid-template-areas:'label control';align-items:center}
133
- .labelbox[data-position='R']{grid-template-areas:'control label';align-items:center}
134
- .labelbox[data-position^='B']{grid-template-areas:'control' 'label'}
135
- .labelbox[data-position$='C']>.label-box{text-align:center}
136
- .labelbox[data-position$='R']>.label-box{text-align:right}
137
- .label-box[hidden]{display:none} .label-box label{display:block}
138
- .labelbox[data-position='L']>.label-box{text-align:right;padding-right:2px}
139
- .labelbox[data-formlet-aligned]>.label-box>label{width:max-content;margin-left:auto}
140
- .labelbox[data-position='L']{grid-template-columns:var(--gramlot-label-width,var(--gramlot-formlet-label-width,max-content)) minmax(0,1fr)}`,this.shadowRoot.append(e,this.box)}projectAttributes(e,t){let r=super.projectAttributes(e,t),{lbl:i,lbl_position:s="TL"}=this.parameters;if(!Vc.includes(s))throw new TypeError(`Invalid lbl_position: ${s}`);let o={box:{},label:{},labelBox:{},controlBox:{}},a=[["box_l_","labelBox"],["box_c_","controlBox"],["lbl_","label"],["box_","box"]];for(let[u,c]of Object.entries(r)){let d=a.find(([f])=>u.startsWith(f));d&&(o[d[1]][u.slice(d[0].length)]=c,delete r[u])}let l={box:this.box,label:this.fieldLabel,labelBox:this.labelBox,controlBox:this.controlBox};for(let[u,c]of Object.entries(l))this.#e[u]=rb(c,o[u],t,this.#e[u]);return e.lbl_width==null?this.box.style.removeProperty("--gramlot-label-width"):this.box.style.setProperty("--gramlot-label-width",e.lbl_width),this.box.classList.add("labelbox"),this.labelBox.classList.add("label-box"),this.controlBox.classList.add("control-box"),this.box.dataset.position=s,this.fieldLabel.textContent=i??"",this.labelBox.hidden=i==null||i==="",this.control.localName!=="input"&&(this.labelBox.hidden?this.control.removeAttribute("aria-labelledby"):this.control.setAttribute("aria-labelledby","field-label")),this.dispatchEvent(new this.ownerDocument.defaultView.Event("gramlot-label-layout",{bubbles:!0})),r}}}zc.parameters={lbl:{dtype:"T",qualification:"intl_str",nullable:!0,binding:"read"},lbl_position:{dtype:"T",default:"TL",binding:"read",enum:Vc}};var ga=["select","notnull","empty","case","len","min","max","email","regex","call","remote"],nb=["nodup","exist","gridnodup"],Ls=n=>n==null||n==="",pa=(n,e)=>n instanceof Promise?n.then(e):e(n);function Hc(n,e,t={}){let r={value:n,modified:!1,error:null,warnings:[],issues:[],datachanges:[]},i=Object.fromEntries(Object.entries(e).map(([u,c])=>[u.slice(9),c])),s=u=>Object.hasOwn(e,`validate_${u}`)&&e[`validate_${u}`]!=null;for(let u of nb)if(s(u))throw new Error(`validate_${u} requires the DB/grid integration.`);let o=(u,c,d=!1)=>t.invoke(u,e[u],{...i,value:c,result:r,validations:i,userChange:!0,signal:t.signal},d),a=(u,c)=>{if(c==null||c===!0)return;if(typeof c!="boolean"&&typeof c!="string"&&(typeof c!="object"||Array.isArray(c)))throw new TypeError("A validator returns true, false, null, an error code, or a result object/Bag.");let d=`validate_${u}`,f=c instanceof D?Object.fromEntries(c.getNodes().map(g=>[g.label,g.value])):typeof c=="object"?c:{errorcode:c===!1?"error":c};if(Object.hasOwn(f,"value")&&(r.modified||=!Object.is(r.value,f.value),r.value=f.value),f.data!=null&&(t.checkDataPatch(f.data),r.datachanges.push(f.data)),!f.errorcode)return;let h=e[`${d}_iswarning`]??f.iswarning??!!(e[`${d}_warning`]&&!e[`${d}_error`]),p=e[`${d}_${f.errorcode}`]||e[`${d}_${h?"warning":"error"}`]||f.message||e[`${d}_${h?"error":"warning"}`]||String(f.errorcode),m=$t(p,g=>g?{...i,...f,value:r.value}[g]:r.value);if(m==null)throw new Error("A validation message references a missing value.");let b={rule:u,code:f.errorcode,severity:h?"warning":"error",message:m};r.issues.push(b),h?r.warnings.push(m):(r.error=m,r.required=!!f.required)},l=u=>{if(t.signal?.aborted)throw t.signal.reason;if(r.error||u===ga.length)return r;let c=ga[u],d=`validate_${c}`,f=e[d];if(!s(c)||f===!1&&c!=="empty")return l(u+1);let h=m=>{if(!m)return l(u+1);let b;return c==="remote"&&r.value==null?l(u+1):(c==="call"?b=o(d,r.value):c==="remote"?b=t.remote(f,{...ib(e),value:r.value},t.signal):b=sb(c,f,r.value,t),pa(b,g=>{if(t.signal?.aborted)throw t.signal.reason;let _=()=>(a(c,g),l(u+1));return c==="remote"&&e.validate__onResult?pa(t.invoke("validate__onResult",e.validate__onResult,{result:g,value:r.value,validations:i,signal:t.signal}),_):_()}))},p=e[`${d}_if`];return pa(p==null?!0:typeof p=="boolean"?p:o(`${d}_if`,r.value,!0),h)};return l(0)}function ib(n){let e=new Set(["if","error","warning","iswarning"]);return Object.fromEntries(Object.entries(n).filter(([t])=>t.startsWith("validate_remote_")&&!e.has(t.slice(16))).map(([t,r])=>[t.slice(16),r]))}function ui(n,e,t={}){return{errorcode:n,message:e,...t}}function sb(n,e,t,r){if(n==="select")return r.selection(t);if(n==="notnull")return Ls(t)&&e?ui("notnull","A value is required.",{required:!0}):null;if(n==="empty")return Ls(t)?{value:e}:null;if(n==="len"){if(typeof e!="string"||!/^(?:\d+|\d+:\d*|:\d+)$/.test(e))throw new Error("Invalid validate_len: use a length or min:max.");let[i,s]=e.split(":"),o=Number(i||0),a=s===void 0?o:s===""?1/0:Number(s);if(o>a)throw new Error("Invalid validate_len: minimum exceeds maximum.");if(Ls(t))return;if(typeof t!="string")throw new TypeError("validate_len requires a text value.");return t.length<o||t.length>a?ui(o===a?"wrong length":t.length<o?"too short":"too long",o===a?`Enter exactly ${o} characters.`:a===1/0?`Enter at least ${o} characters.`:o===0?`Enter no more than ${a} characters.`:`Enter between ${o} and ${a} characters.`):void 0}if(!Ls(t)){if(n==="case"){if(typeof t!="string")throw new TypeError("validate_case requires a text value.");switch(e){case"upper":case"u":return{value:t.toUpperCase()};case"lower":case"l":return{value:t.toLowerCase()};case"title":case"t":return{value:t.replace(/\p{L}[\p{L}\p{M}]*/gu,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())};case"capitalize":case"c":return{value:t[0].toUpperCase()+t.slice(1).toLowerCase()};default:throw new Error("Invalid validate_case: use upper, lower, title or capitalize.")}}if(n==="min"||n==="max"){let i;if(r.isDecimal?.(t))i=t.comparedTo(e);else if(t instanceof Date&&e instanceof Date)i=t.getTime()-e.getTime();else if(typeof t=="number"&&Number.isFinite(t)&&typeof e=="number"&&Number.isFinite(e))i=t-e;else throw new TypeError(`validate_${n} requires matching numeric or date/time values.`);return(n==="min"?i<0:i>0)?ui(n,`Value must be ${n==="min"?"at least":"at most"} ${e}.`):void 0}if(n==="email"){if(typeof t!="string")throw new TypeError("validate_email requires a text value.");return/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(t)?null:ui("email","Check email format.",{iswarning:!0})}if(n==="regex"){if(typeof t!="string"||typeof e!="string")throw new TypeError("validate_regex requires text.");let i=e.trim(),s=i.startsWith("!");return new RegExp(s?i.slice(1):i,"u").test(t)!==s?null:ui("regex","The value does not match the required pattern.")}}}var ci={dtype:"T",nullable:!0,binding:"read"},Ps={dtype:"B",nullable:!0,binding:"read"},ma={dtype:["T","L","N","R","B","D","H","DH","DHZ"],nullable:!0,binding:"read"},Wc={validate_select:Ps,validate_notnull:{...Ps,default:!1},validate_empty:ma,validate_case:{...ci,enum:["upper","lower","title","capitalize","u","l","t","c"]},validate_len:ci,validate_min:ma,validate_max:ma,validate_email:Ps,validate_regex:ci,validate_call:{dtype:"T",nullable:!0},validate_remote:ci,validate_onAccept:{dtype:"T",nullable:!0},validate_onReject:{dtype:"T",nullable:!0},validate__onResult:{dtype:"T",nullable:!0},validate_timeout:{dtype:"L",nullable:!0,binding:"read"},...Object.fromEntries(ga.flatMap(n=>[[`validate_${n}_if`,{dtype:["T","B"],nullable:!0}],[`validate_${n}_iswarning`,Ps],...["error","warning"].map(e=>[`validate_${n}_${e}`,{...ci,qualification:"intl_str"}])]))};var ob=1800,Gc=200;function Xc(n){return class extends n{#e=!1;#t;#r;#n;#i;#s=0;#o;#a={};validationResult=null;constructor(){super(),this.message=this.ownerDocument.createElement("small"),this.message.id="field-message",this.message.hidden=!0,this.message.setAttribute("aria-live","polite"),this.message.setAttribute("popover","manual"),this.message.setAttribute("role","tooltip");let e=this.ownerDocument.createElement("style");e.textContent=`#control[aria-invalid="true"]{background:var(--gramlot-error-background,#fff1f0)}
188
+ `)}catch(i){throw i instanceof EvalError?new EvalError(`${Qn(n,e)}: inline code blocked by the Content Security Policy of the page (no 'unsafe-eval'); move the code to named logic (a method of the page's class Logic) or serve the page with the permissive CSP profile, which allows 'unsafe-eval'`,{cause:i}):new SyntaxError(`${Qn(n,e)}: ${i.message} in the inline code:
189
+ ${t}`,{cause:i})}}var Is=class{#e;#t;#r=!1;#n=null;#i=null;constructor(e){this.#e=e,this.#t=new Kn(e)}get binding(){return this.#e}get node(){return this.binding.node}get closed(){return this.#r||this.binding.closed}close(){this.#r=!0,this.#t.cancel()}register(){this.#t.startTiming(this.#o("_timing"),()=>this.trigger())}receive(e){if(this.#o("_userChanges")&&e.level!=="node")return;let t=this.#o("_delay");t>0?this.#t.debounce(t,()=>this.trigger()):this.trigger()}trigger(){this.update().catch(e=>{this.closed||this.binding.runtime.reportError(e,"Content could not be loaded")})}async update(){if(this.closed||!this.binding.hasStamp("start"))return;let e=this.node,[,t]=e.rootBuilder.runtimeValues(e),r=t.remote,i={};for(let[l,u]of Object.entries(t))l.startsWith("remote_")&&(i[l.slice(7)]=u);let s=e.getAttr("_if");if(s&&!this.#a("_if",s,`return (${s})`,i)){let l=e.getAttr("_else");l&&this.#a("_else",l,l,i);return}let o;try{let l=U(i);if(t._cachedRemote&&this.#s(r,l))return;let u=e.getAttr("_onCalling");if(!e.requests.calling(u?()=>this.#a("_onCalling",u,u,i):null))return;o=await this.binding.runtime.gramlot.src.remoteSource(e,r,i)}catch(l){throw new Error(`${e.nodeTag} '${e.label}': remote '${r}' failed: ${l.message}`,{cause:l})}let a=e.getAttr("_onRemote");!this.closed&&o&&a&&await this.#a("_onRemote",a,a,i)}fragmentMounted(e,t){this.#n=e,this.#i=t}#s(e,t){let r=this.node.requests.inflight;return r?r.method===e&&U(r.params)===t:e===this.#n&&t===this.#i}#o(e){let[,t]=this.node.rootBuilder.runtimeValues(this.node);return t[e]??null}#a(e,t,r,i){return e==="_onRemote"?rt(this.binding.runtime,this.node,e,t,i):this.binding.runtime.inlineCompiler.compile(this.node,e,t,Object.keys(i),r)(i)}};var tb=new Set(["title","msg","fields","_if","askIf"]),rb=new Set(["name","lbl","tag","type","default_value","required","min","max","step","placeholder"]),Os=class{#e;#t=null;#r=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}required(e,t,r,i){let s=(o,a)=>typeof a=="boolean"?a:e.runtime.inlineCompiler.compile(e.node,o,a,Object.keys(r),`return (${a});`)(r);if(typeof t=="string"){let o=e.node.getAttr("_ask_if");return!o||!!s("_ask_if",o)}return t?.askIf&&s(`${i}.askIf`,t.askIf),!t?._if||!!s(`${i}._if`,t._if)}show(e,t,r,i="Parameters"){let s=typeof t=="string"?{msg:t,title:i}:t;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ask requires text or a parameter description");for(let d of Object.keys(s))if(!tb.has(d))throw new Error(`Unsupported ask option: ${d}`);let o=s.fields??[];if(!Array.isArray(o))throw new TypeError("ask fields must be an array");let a=new Set;for(let d of o){if(!d||!/^[A-Za-z_]\w*$/.test(d.name)||a.has(d.name))throw new Error("ask fields require distinct simple names");a.add(d.name);for(let f of Object.keys(d))if(!rb.has(f))throw new Error(`Unsupported ask field option: ${f}`);if(d.tag&&!["input","textarea"].includes(d.tag))throw new Error(`Unsupported ask widget: ${d.tag}`);if(d.type&&!["text","number","date","checkbox","email","password","url","tel"].includes(d.type))throw new Error(`Unsupported ask input type: ${d.type}`)}let l=this.runtime.gramlot,u=this.#n(),c=this.#r;return new Promise((d,f)=>{let h=`ask_${Q()}`,m=!1,p=()=>{},b=(g,_=null)=>{if(m)return;m=!0;let w=g?Object.fromEntries(o.map(E=>[E.name,l.data.getItem(`${h}.${E.name}`)])):null;c.delete(h),p();try{l.src.source.popNode(h),l.data.getNode(h)&&l.data.popNode(h),_?f(_):d(w)}catch(E){f(E)}};c.set(h,{finish:b}),p=e.track(()=>b(!1));try{let g=new Oe,_=g.root.html_dialog({nodeId:h,datapath:h,request:h,connect_oncancel:`${u}.cancel`,connect_onclose:`${u}.cancel`,class:"gramlot-ask","aria-labelledby":`${h}_title`,style:"border:1px solid #aab4c2;border-radius:8px;padding:16px;max-width:32rem;width:calc(100% - 48px);font:inherit;"});_.h2(s.title??i,{id:`${h}_title`,style:"font-size:1.1em;margin:0 0 12px;"}),s.msg&&_.p(s.msg);let w=_.form({request:h,connect_onsubmit:`${u}.confirm`});for(let y of o){w.dataSetter({destination_path:`.${y.name}`,value:Object.hasOwn(r,y.name)?r[y.name]:y.default_value??(y.type==="checkbox"?!1:"")});let T=w.div({style:"margin:8px 0;"});T.html_label(y.lbl??y.name,{for:`${h}_${y.name}`,style:"display:block;margin-bottom:4px;"});let S={id:`${h}_${y.name}`,value:`^.${y.name}`,live:!0};for(let I of["required","min","max","step","placeholder"])y[I]!==void 0&&(S[I]=y[I]);y.tag==="textarea"?T.textarea(S):T.input({...S,type:y.type??"text"})}let E=w.div({style:"display:flex;justify-content:flex-end;gap:8px;margin-top:16px;"});E.html_button("Cancel",{type:"button",request:h,connect_onclick:`${u}.cancel`}),E.html_button("Confirm",{type:"submit",autofocus:o.length===0}),l.src.source.setItem(h,l.src.prepareSource(g.source));let D=l.src.binding.nodeIds.get(h);l.dom.getDomNode(D).showModal()}catch(g){b(!1,g)}})}#n(){if(this.#t===null){let e=`ask_${Q()}`,t=this.#r;class r{confirm(s,o){o.preventDefault(),t.get(s.getAttr("request"))?.finish(!0)}cancel(s,o){o.preventDefault(),t.get(s.getAttr("request"))?.finish(!1)}}this.runtime.logicRegistry.register(r,{group:e,resource:"gramlot:ask"}),this.#t=e}return this.#t}};var Bs=class{#e;#t=`errors_${Q()}`;#r=null;#n=new Map;#i=new Set;#s=0;constructor(e){this.#e=e}show(e,t){let r=new Set,i=[];for(let o=e;o!==null&&typeof o=="object"&&!r.has(o);o=o.cause){if(o.name==="AbortError")return;r.add(o),i.push(o.stack??o.message)}let s=typeof e?.message=="string"?e.message:String(e);queueMicrotask(()=>{this.#e.disposed||this.#o(s,t,i.join(`
190
+ Caused by:
191
+ `))})}#o(e,t,r){let i=this.#e.gramlot,s=JSON.stringify([t,e]);if(this.#i.has(s))return;let o=this.#e.nodeIds.get(this.#t);if(!o){if(this.#n.clear(),this.#s=0,this.#r===null){let m=this;class p{close(g){m.#a(g.getAttr("notice"))}}this.#r=`errors_${Q()}`,this.#e.logicRegistry.register(p,{group:this.#r,resource:"gramlot:error-notifications"})}let h=new Oe;h.root.aside({nodeId:this.#t,class:"gramlot-error-notifications",popover:"manual","aria-label":"Error notifications",style:"position:fixed;inset:auto max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) auto;margin:0;width:360px;max-width:calc(100vw - 24px);max-height:50vh;overflow:auto;box-sizing:border-box;padding:0;border:1px solid var(--gramlot-border-control,#aab4c2);border-radius:8px;background:var(--gramlot-surface,#fff);color:var(--gramlot-ink,#222);font:13px/1.4 system-ui;box-shadow:0 6px 24px #0003;"}),i.src.source.setItem(this.#t,i.src.prepareSource(h.source)),o=this.#e.nodeIds.get(this.#t)}if(this.#n.has(s))return;if(this.#n.size===5){let h=`${++this.#s} additional errors`,m=o.value.getNode("overflow");m?m.setValue(h):i.src.builder.wrapSource(o).p(h,{node_label:"overflow",role:"status",style:"margin:0;padding:12px;"});return}let a=`notice_${Q()}`,l=new Oe,u=l.root.article({role:"alert",style:"color:inherit;padding:12px;border-bottom:1px solid var(--gramlot-border,#ddd);"}),c=u.div({style:"display:flex;align-items:start;gap:12px;"});c.strong(`==${JSON.stringify(t)}`,{style:"flex:1;color:var(--gramlot-error,#b13d48);"}),c.html_button("\xD7",{type:"button",notice:a,connect_onclick:`${this.#r}.close`,"aria-label":"Dismiss notification",title:"Dismiss notification",style:"border:0;background:transparent;color:inherit;font:18px/1 system-ui;width:24px;height:24px;flex:0 0 24px;padding:0;cursor:pointer;"}),u.p(`==${JSON.stringify(e)}`,{style:"margin:6px 0;overflow-wrap:anywhere;"});let d=u.details({style:"border:0;padding:0;margin:8px 0 0;background:transparent;"});d.summary("Details",{style:"cursor:pointer;"}),d.pre(`==${JSON.stringify(r)}`,{style:"font:11px/1.4 monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:6px 0 0;padding:8px;border:0;border-radius:4px;background:var(--gramlot-surface-subtle,#f2f4f6);"});let f=i.src.builder.wrapSource(o).div({node_label:a});J(f).setValue(i.src.prepareSource(l.source)),this.#n.set(s,a),i.dom.getDomNode(o).showPopover()}#a(e){this.#e.nodeIds.get(this.#t).value.popNode(e);for(let[r,i]of this.#n)i===e&&(this.#n.delete(r),this.#i.add(r));this.#n.size||this.#e.gramlot.src.source.popNode(this.#t)}};var Vc={dataFormula:Ts,dataController:Ds,dataRpc:Cs,dataRemote:Ss},nb=["datapath","_anchor","nodeId","form","formId"],Zr=class{#e;#t=new Map;#r=new Map;#n;#i;#s;#o;#a;#l;#c=`gramlot-data-${Q()}`;#u=!1;constructor(e,{subscriptions:t}){this.#e=e,this.#l=t,this.#n=new xs(this),this.#i=new ks(this),this.#s=new Ns(this),this.#o=new Os(this),this.#a=new Bs(this)}get gramlot(){return this.#e}reportError(e,t){this.disposed||this.#a.show(e,t)}get subscriptions(){return this.#l}get builder(){return this.gramlot.src.builder}get renderer(){return this.gramlot.src.renderer}get logicRegistry(){return this.gramlot.src.logicRegistry}get data(){return this.builder.data}get root(){return this.data.parent}get size(){return this.#t.size}get disposed(){return this.#u}get router(){return this.#n}get installer(){return this.#i}get inlineCompiler(){return this.#s}get askDialog(){return this.#o}get nodeIds(){return this.#r}attach(){this.root.subscribe(this.#c,{any:e=>this.receiveData(e)})}receiveData(e){this.router.deliver(e)}bindingFor(e){return this.#t.get(e)??null}openBinding(e){if(this.disposed)throw new Error("BindingRuntime is disposed");let t=this.bindingFor(e);return t||(t=new _a(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof A)for(let i of e.value.getNodes())try{this.closeBranch(i)}catch(s){t.push(s)}let r=this.bindingFor(e);if(r){this.#t.delete(e);let i=e.getAttr("nodeId");this.nodeIds.get(i)===e&&this.nodeIds.delete(i);try{r.close()}catch(s){t.push(s)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#g(e);for(let r of t)this.bindingFor(r)?.rebind();for(let r of t)this.renderer.project(r);for(let r of t)this.bindingFor(r)?.remote?.trigger()}handleSourceEvent(e){let{evt:t,node:r}=e,i=[],s=o=>{try{this.closeBranch(o)}catch(a){i.push(a)}};try{if(t==="ins")this.#d(r);else if(t==="del")for(let o of Array.isArray(r)?r:[r])s(o);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof A)for(let o of e.oldvalue.getNodes())s(o);this.inlineCompiler.release(r,[""]),t==="upd_value_attr"?this.#h(r,e.attrs_diff):this.#m(r).rebind(),r.value instanceof A&&this.#d(r.value)}else if(t==="upd_attrs")this.#h(r,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(o){throw i.length?new AggregateError([...i,o],"Source event failed"):o}return i}branchBuilt(e){let t=[];for(let r of this.#g(e)){let i=this.bindingFor(r);!i||i.hasStamp("built")||!this.renderer.attached(r)||(i.stamp("built"),t.push(i))}for(let r of t)this.renderer.attached(r.node)&&this.#p(r,"built","_onBuilt");if(this.gramlot.state==="started")for(let r of t)this.renderer.attached(r.node)&&this.#f(r)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#f(e)}dispose(){if(this.disposed)return;this.#u=!0,this.root.unsubscribe(this.#c,{any:!0}),this.nodeIds.clear();let e=[];for(let[t,r]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{r.close()}catch(i){e.push(i)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#d(e){if(!(e instanceof A)&&this.bindingFor(e))return;let t=e instanceof A?e.getNodes().flatMap(s=>this.#g(s)):this.#g(e),r=new Set(t.filter(s=>this.bindingFor(s))),i=new Map;for(let s of t){let o=s.getAttr("nodeId");if(o!=null){if(i.has(o)||this.nodeIds.has(o)&&this.nodeIds.get(o)!==s)throw new Error(`Duplicate nodeId '${o}'`);i.set(o,s)}}for(let[s,o]of i)this.nodeIds.set(s,o);try{for(let s of t)this.openBinding(s);this.installer.install(e);for(let s of t)this.renderer.attached(s)&&this.bindingFor(s).registerPointers()}catch(s){let o=[s];for(let a of t.filter(l=>!r.has(l)).reverse()){let l=a.getAttr("nodeId");i.get(l)===a&&this.nodeIds.get(l)===a&&this.nodeIds.delete(l);let u=this.bindingFor(a);if(u){this.#t.delete(a);try{u.close()}catch(c){o.push(c)}}}throw o.length>1?new AggregateError(o,"Source branch installation failed"):s}for(let s of t){let o=this.bindingFor(s);if(!(!o||o.hasStamp("init")||!this.renderer.attached(s))&&(o.stamp("init"),zc(s.getAttr("_init"))))for(let a of o.providers)a.invoke({kind:"init",change:null})}}#f(e){e.hasStamp("start")||(e.stamp("start"),this.#p(e,"start","_onStart"),e.remote?.trigger())}#p(e,t,r){let i=e.node.getAttr(r);if(zc(i))for(let s of e.providers){if(typeof i!="number"||i<=0){s.invoke({kind:t,change:null});continue}let o=null,a=setTimeout(()=>{o(),s.invoke({kind:t,change:null})},i);o=e.track(()=>clearTimeout(a))}}#h(e,t){let r=this.#m(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:i,new:s}=t.nodeId;if(s!=null&&this.nodeIds.has(s)&&this.nodeIds.get(s)!==e)throw new Error(`Duplicate nodeId '${s}'`);this.nodeIds.get(i)===e&&this.nodeIds.delete(i),s!=null&&this.nodeIds.set(s,e)}nb.some(i=>Object.hasOwn(t,i))?this.rebindBranch(e):r.rebind()}#m(e){let t=this.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': the node has no NodeBinding (its installation failed); remove it from the Source and insert it again`);return t}#g(e){let t=[e];if(e.value instanceof A)for(let r of e.value.getNodes())t.push(...this.#g(r));return t}};function zc(n){return n===!0||typeof n=="number"}var _a=class{#e;#t;#r=!1;#n=[];#i=[];#s=new Set;#o=null;#a=null;#l=new Set;#c=new Set;#u=0;#d=new Set;constructor(e,t){this.#e=e,this.#t=t}get runtime(){return this.#e}get node(){return this.#t}get closed(){return this.#r}get registrations(){return[...this.#i]}get providers(){return this.#o?[this.#o]:[]}get remote(){return this.#a}get clickCount(){return this.#u}countClick(){return++this.#u}hasStamp(e){return this.#s.has(e)}stamp(e){this.#s.add(e)}registerPointers(){this.node._getMeta("data_element")&&(this.runtime.renderer.references.remove(this.node),this.runtime.renderer.references.register(this.node,null));let e=this.node,t=e._getMeta("data_element");if(t&&!Vc[e.nodeTag])return;!t&&typeof e.getAttr("remote")=="string"?this.#a??=new Is(this):this.#a&&(this.#a.close(),this.#a=null);let r=new Set;if(e._getMeta("gramlot_component")?.bagStore){let s=e.getAttr("storepath");if(typeof s!="string"||!s||/^[\^=]/.test(s)||s.includes("?"))throw new TypeError("storepath requires a plain Bag data path");let o=e.absDatapath(s);this.#i.push(this.runtime.router.register({path:o,recipient:this,subtree:!0}))}let i=this.remote?Ge(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[s,o]of Object.entries(e.getAttr()))if(s.startsWith("remote_"))for(let a of Ge(e,o))r.add(a)}for(let[s,o]of e.pointers()){if(t&&s!=="datapath")continue;let l=(s==="datapath"?e.parentNode:e).absDatapath(o);if(l===null)continue;let[u,c=null]=l.split("?",2),d=this.runtime.router.register({path:u,attr:c,recipient:this});this.#i.push(d),s==="datapath"&&this.#d.add(d),this.remote&&(s==="remote"||s.startsWith("remote_")||r.has(s))&&this.#l.add(d),this.remote&&(s==="_timing"||i.has(s))&&this.#c.add(d)}if(!t){this.#f(),this.remote?.register();return}this.#o??=new Vc[e.nodeTag](this),this.#o.register()}#f(){let e=this.node;this.#i.push(...this.runtime.subscriptions.subscribeNode(e,(t,r)=>{if(typeof r!="string"||!r)throw new TypeError(`${t} requires a handler`);return i=>{if(this.closed)return;if(Gn(r))return sr(this.runtime,e,r,i);let[,s]=e.rootBuilder.runtimeValues(e),o=Object.fromEntries(Object.entries(s).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),a={...this.runtime.renderer.references.resolveArguments(o),p_0:i};return this.runtime.inlineCompiler.compile(e,t,r,Object.keys(a))(a)}}))}rebind(){this.#p(),this.registerPointers()}receive(e){if(this.#d.has(e.registration)){this.runtime.rebindBranch(this.node);return}this.#l.has(e.registration)&&this.remote.receive(e),this.#c.has(e.registration)&&this.remote.register(),this.runtime.renderer.project(this.node,e)}track(e){if(this.closed)throw new Error(`NodeBinding of '${this.node.label}' is closed`);return this.#n.push(e),()=>{let t=this.#n.indexOf(e);t!==-1&&this.#n.splice(t,1)}}async call(e,t){let{controller:r}=t,i=this.track(()=>r.abort());try{let s=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:r.signal});if(r.signal.aborted)throw r.signal.reason;return s}finally{i()}}callSync(e,t,r){return this.node.requests.submitSync(t,()=>this.runtime.gramlot.rpc.callSync(e,t,r))}close(){if(this.closed)return;this.#r=!0,this.#a?.close(),this.node._getMeta("data_element")&&this.runtime.renderer.references.remove(this.node),this.#p();let e=[];for(let t of this.#n.splice(0).reverse())try{t()}catch(r){e.push(r)}if(e.length)throw new AggregateError(e,`NodeBinding of '${this.node.label}' cleanup failed`)}#p(){for(let e of this.#i.splice(0))e.close();this.#d.clear(),this.#l.clear(),this.#c.clear()}};var Rs=class{constructor(e){this.renderer=e}prepare(e,t){let r=this.renderer.records.get(e);if(!r||r.resolved.draggable!==!0)return null;let i=e._getMeta("gramlot_component")?.dragSource?r.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(i===null)return null;let{dragValues:s,item:o,path:a}=i;if(r.resolved.onDrag){let u=this.renderer.html.callLogic(e,r.resolved.onDrag,{dragValues:s,item:o,path:a});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return Mt(s),{dragValues:Object.fromEntries(Object.entries(s).map(([u,c])=>{if(u.startsWith("text/")||u==="dragTags"){if(typeof c!="string")throw new TypeError(`${u} drag data must be text`);return[u,c]}return[u,j(U(c))]})),item:o,path:a}}};var Lt=class{static isTarget(e){return e.dropTarget===!0||!!e.dropTargetCb||Object.entries(e).some(([t,r])=>t.startsWith("dropTargetCb_")&&!!r)}static acceptedTypes(e,t="",r=[]){let i=t.split(",").map(s=>s.trim()).filter(Boolean).map(s=>{let o=s.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${o.join(".*")}$`)});return e.filter(s=>s!=="dragTags"&&(r.includes(s)||i.some(o=>o.test(s))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let r=new Set(e.split(",").map(i=>i.trim()).filter(Boolean));return r.size?t.split(",").some(i=>i.split(" AND ").every(s=>(s=s.trim(),!s||s==="!"?!1:s.startsWith("!")?!r.has(s.slice(1)):r.has(s)))):!1}static acceptsEffect(e="all",t="move"){let r={all:["copy","move","link"],none:[],copy:["copy"],move:["move"],link:["link"],copyMove:["copy","move"],copyLink:["copy","link"],linkMove:["link","move"]};if(!Object.hasOwn(r,e))throw new TypeError(`Invalid effectAllowed: ${e}`);if(!["copy","move","link"].includes(t))throw new TypeError(`Invalid dropEffect: ${t}`);return r[e].includes(t)}static evaluate(e,t,r,i,s=[]){let o=this.acceptedTypes(e,i.dropTypes,s),a=i.dropEffect??"move",l=this.isTarget(i)&&o.length>0&&this.acceptsTags(t,i.dropTags)&&this.acceptsEffect(r,a);return{accepted:l,types:o,dropEffect:l?a:"none"}}};var Hc=["dragstart","dragover","dragleave","drop","dragend"],$s=class{#e;#t;#r=null;#n=null;#i=null;#s;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of Hc)this.#t.addEventListener(t,this);this.#s=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#s)}handleEvent(e){e.type==="dragstart"?this.#l(e):e.type==="dragend"?this.#b(e.dataTransfer.dropEffect):e.type==="dragleave"?this.#h():e.type==="dragover"?this.#d(e):e.type==="drop"&&this.#f(e)}#o(e,t){for(let r of e.composedPath()){let i=this.#e.elements.get(r);if(i&&t(i.resolved))return i}return null}#a(e,t){return e.node._getMeta("gramlot_component")?.dragSource?e.element.getDragContext(t):{element:e.element,item:void 0,path:void 0}}#l(e){let t=this.#o(e,r=>r.draggable===!0);if(t){this.#b("none");try{let r=this.#e.prepareDrag(t.node,e);if(!r||!t.element.isConnected||this.#e.records.get(t.node)!==t){e.preventDefault();return}let i=this.#a(t,e);if(!i){e.preventDefault();return}let s=new Map(Object.entries(r.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:U(c)]));if(!s.size){e.preventDefault();return}let o=t.resolved.effectAllowed??"all";Lt.acceptsEffect(o,"move");let a="";for(let u=t;u;u=u.parent)if(u.resolved?.dragTags!=null){a=u.resolved.dragTags;break}let l=this.#r={record:t,wires:s,effectAllowed:o,phase:"active",tags:[a,r.dragValues.dragTags].filter(Boolean).join(","),endTopic:this.#e.binding.subscriptions.topicFor(t.node,"endDrag"),source:{pageId:this.#e.binding.gramlot.pageId??null,sourcePath:t.node.fullpath,itemPath:r.path??null},preview:null,release:null};e.dataTransfer.clearData();for(let[u,c]of s)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=o,this.#i=this.#t.createElement("style"),this.#i.textContent=".canBeDropped{outline:2px solid var(--gramlot-brand-blue,#3766b5);outline-offset:-2px}.cannotBeDropped{outline:2px dashed currentColor;outline-offset:-2px}.draggedItem{opacity:.75}",this.#t.head.append(this.#i),this.#c(l,i.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(r){e.preventDefault(),this.#g(),this.#_(r)}}}#c(e,t,r){let i=t.cloneNode(!0);i.removeAttribute("id");for(let s of i.querySelectorAll("[id]"))s.removeAttribute("id");i.setAttribute("aria-hidden","true"),i.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(i.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(i),e.preview=i,r.setDragImage(i,0,0)}#u(e){let t=this.#r,r=this.#o(e,u=>Lt.isTarget(u));if(!r)return null;let i=this.#a(r,e);if(!i)return{record:r,element:r.element,accepted:!1};let s=Lt.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,r.resolved),a={dropValues:Object.fromEntries(s.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):j(t.wires.get(u))])),item:i.item,path:i.path,source:{...t.source},selfdrop:r===t.record,dropEffect:s.dropEffect,dataAvailable:!0},l=s.accepted&&this.#e.checkDropTarget(r.node,a)&&this.#e.records.get(r.node)===r&&i.element.isConnected;return{record:r,element:i.element,accepted:l,context:a}}#d(e){if(!this.#r){this.#o(e,t=>Lt.isTarget(t))&&(e.preventDefault(),e.dataTransfer.dropEffect="none");return}if(e.preventDefault(),this.#r.phase!=="active"){e.dataTransfer.dropEffect="none";return}try{let t=this.#r,r=this.#u(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r?.accepted?r.context.dropEffect:"none",this.#h(),r&&this.#p(r.element,r.accepted)}catch(t){e.dataTransfer.dropEffect="none",this.#r&&(this.#r.phase="rejected"),this.#m(),this.#_(t)}}async#f(e){if(!this.#r){this.#o(e,i=>Lt.isTarget(i))&&e.preventDefault();return}if(e.preventDefault(),this.#r.phase!=="active")return;let t=this.#r,r;try{if(r=this.#u(e),this.#r!==t){e.dataTransfer.dropEffect="none";return}if(t.phase="dropped",this.#m(),!r?.accepted){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=r.context.dropEffect,r.record.node.publish("onDrop",r.context),await this.#e.invokeDrop(r.record.node,r.context)}catch(i){this.#r===t&&(t.phase="rejected",this.#m()),(!r||this.#e.records.has(r.record.node))&&this.#_(i)}}#p(e,t){let r=t?"canBeDropped":"cannotBeDropped",i=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#n={element:e,name:r,hadClass:e.classList.contains(r),hadPart:i.includes(r)},e.classList.add(r),i.includes(r)||e.setAttribute("part",[...i,r].join(" "))}#h(){if(!this.#n)return;let{element:e,name:t,hadClass:r,hadPart:i}=this.#n;r||e.classList.remove(t),i||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(s=>s!==t).join(" ")),this.#n=null}#m(){this.#h(),this.#r&&(this.#r.preview?.remove(),this.#r.preview=null,this.#r.wires.clear())}#g(){let e=this.#r;return this.#m(),this.#r=null,e?.release?.(),this.#i?.remove(),this.#i=null,e}#b(e){let t=this.#g();!t||this.#e.disposed||this.#e.endDrag(t.record.node,{source:{...t.source},dropEffect:e},t.endTopic).catch(r=>this.#_(r))}#_(e){this.#e.binding.reportError(e,"Drag and drop failed")}dispose(){this.#g();for(let e of Hc)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#s)}};var ei=class extends ir{static renderType="object";#e=new Set;#t=new WeakMap;#r=new WeakMap;#n=new WeakMap;constructor(e,t,r,{binding:i}={}){if(super(e),!(e instanceof Te)||!(t instanceof de)||r?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(i instanceof Zr))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof Te))throw new TypeError("SourceBag requires builder ownership");this._binding=i,this.source=t,this.destination=r,this.html=new _s({metadataAttributes:["__ref"],reportError:(s,o,a)=>{this.records.has(s)&&i.reportError(o,a)},callLogic:(s,o,a)=>{let{group:l,method:u}=i.gramlot.src.logicRegistry.resolve(o,s);return u.call(l,s,a)},invokeScript:(s,o,a,l)=>rt(i,s,o,a,l,s.parentNode._getMeta("gramlot_component").childParameters[o].inline)}),this.records=new Map,this.references=new Zn(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new Rs(this),this.instanceId=Q(),this.radioGroups=new bs(this),this.dragDrop=new $s(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:s=>this.receive(s)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l}){let u=this.records.get(e);if(!u)return!1;if(!u.resolved.dropTargetCb)return!0;let c=this.html.callLogic(e,u.resolved.dropTargetCb,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l});if(typeof c!="boolean")throw new TypeError("dropTargetCb must return a boolean synchronously");return c}async invokeDrop(e,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l}){let u=this.records.get(e);!u||!u.resolved.onDrop||Object.keys(t).length===0||await this.html.callLogic(e,u.resolved.onDrop,{dropValues:t,item:r,path:i,source:s,selfdrop:o,dropEffect:a,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:r},i){let s={source:t,dropEffect:r},o=[],a=this.records.get(e);try{a&&!a.binding.closed&&a.resolved.onDragEnd&&await this.html.callLogic(e,a.resolved.onDragEnd,s)}catch(l){o.push(l)}try{this.binding.gramlot.publish(i,s)}catch(l){o.push(l)}if(o.length)throw new AggregateError(o,"Drag completion notification failed")}get inlineCompiler(){return this.binding.inlineCompiler}evaluateExpressions(e,t){let r=this.#r.get(e)??super.evaluateExpressions(e,t),i=e._getMeta("gramlot_component");if(i?.presentationDefaults.length){let s=e.getAttr();this.#n.set(e,Object.fromEntries(Object.entries(r).filter(([o])=>Object.hasOwn(s,o)&&i.presentationDefaults.some(a=>o.startsWith(a)))))}if(this.html.hasLabelbox(e)||i?.presentationDefaults.length){let s=[];for(let o=e.parentNode;o;o=o.parentNode)this.#n.has(o)&&s.unshift(this.#n.get(o));r=Object.assign({},...s,r)}return this.#r.delete(e),this.#t.set(e,r),r}render(e,t={}){if(!(e instanceof nr))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(e._getMeta("data_element")||!this.binding.bindingFor(e)&&this.#a(e))return null;if(e.nodeTag)this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder);else if(!(e.value instanceof A))throw new TypeError("Source fragments must contain child SourceBags");return e.nodeTag?super.render(e,t):this.renderFragment(e,t)}renderFragment(e,{document:t=this.destination.ownerDocument,...r}={}){let i=t.createDocumentFragment(),s={node:e,binding:this.#h(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,s),this.elements.set(i,s),i.append(s.start);for(let o of e.value.getNodes()){let a=this.render(o,{document:t,...r});if(a===null)continue;i.append(a);let l=this.elements.get(a);l&&(l.parent=s,s.children.add(o))}return i.append(s.end),i}renderedItem(e,t,r,{tag:i,document:s=this.destination.ownerDocument}={}){let o=r;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(o=this.restoreNativeAttributes(e,r),e._getMeta("gramlot_component")||([t,o]=zn(t,o,(h,m)=>this._binding.gramlot.format(h,m)))),o=this.componentAttributes(e,o);let a=Array.isArray(t)?t:[],l=Array.isArray(t)?o._text:t,u=this.#t.get(e),c={node:e,binding:this.#h(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,s,i,o,u.visible??null)};this.html.compose(c,l,a),c.shape=ye.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c),this.elements.set(c.presentation,c);let d=ye.for(c.binding,c);(d||c.element.namespaceURI===we&&c.element.localName==="input")&&c.cleanup.push(()=>c.control?.detach()),d&&(c.control=d,d.attach(),this.#d(c,e,o,null));let f=ws.for(c.binding,c);f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),e.nodeTag==="menu"&&(c.menu=new ys(c.binding,c.element),c.menu.attach(),c.cleanup.push(()=>c.menu.detach())),this.#f(c),this.references?.register(e,c.element);for(let h of a){let m=this.elements.get(h);m&&(m.parent=c,m.container=c.element,c.children.add(m.node))}return c.presentation}validateCandidate(e,{replacingNode:t=null}={}){if(!(e instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");let r=new Set,i=s=>{if(!r.has(s)){r.add(s);for(let o of this.records.get(s)?.children??[])i(o);if(s.value instanceof A)for(let o of s.value.getNodes())i(o)}};for(let s of this.records.get(t)?.children??[])i(s);if(t?.value instanceof A)for(let s of t.value.getNodes())i(s);return this.#i(e,t?t.nodeTag:null),ba(e),this.references?.validate(e,r),e}#i(e,t=null){let r=new Set,i=(s,o=null)=>{if(!(s instanceof de)||r.has(s))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(s._builder instanceof Te))throw new TypeError("SourceBag requires builder ownership");r.add(s);for(let a of s.getNodes()){if(!(a instanceof nr))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(a.builder instanceof Te))throw new TypeError("SourceBagNode requires builder ownership");if(a.resolver)throw new TypeError("Source resolvers are outside this port");if(a._getMeta("data_element"))a.builder.validateNode(a);else if(a.nodeTag){let l=a._getMeta("subbuilder")?s._builder:a.builder;this.html.validate(a,l),a._getMeta("subbuilder")||a.builder.validateParent(a.nodeTag,o)}else{if(!(a.value instanceof A))throw new TypeError("Source fragments must contain child SourceBags");if(Object.keys(a.attr).some(l=>l!=="_meta"))throw new TypeError("Fragment attributes are unsupported")}a.value instanceof A&&i(a.value,a._getMeta("subbuilder")?null:a.nodeTag??o)}};i(e,t)}freeze(e){e=J(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Freeze requires a mounted Source node");t.frozen=!0}unfreeze(e){e=J(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let r=i=>{delete i.frozen;for(let s of i.children)r(this.records.get(s))};r(t),!this.#s(e)&&(this.attached(e)?this.#m(e):this.remove(e))}#s(e){for(;e;){let t=this.records.get(e);if(t?.frozen)return!0;e=e.parentBag?.parentNode??t?.parent?.node}return!1}receive(e){if(this.disposed)return;let t=r=>this.#e.has(r)||e.evt==="del"&&r.nodeTag==="dataSetter";if(Array.isArray(e.node)){let r=e.node.filter(i=>!t(i));if(!r.length)return;e={...e,node:r}}else if(t(e.node))return;if(this.pending.push(e),!this.building){this.building=!0;try{for(;this.pending.length;){let r=this.pending.shift();if(r.evt!=="del"&&!this.attached(r.node))continue;r.evt!=="del"&&r.evt!=="upd_attrs"&&this.#l(r);let i=this.binding.handleSourceEvent(r);try{this.#o(r,i)}catch(s){if(!i.length)throw s;i.push(s)}if(i.length)throw i.length===1?i[0]:new AggregateError(i,"Source cleanup failed")}}catch(r){throw this.pending.length=0,r}finally{this.building=!1}}}#o(e,t){if(e.evt==="del"){for(let r of Array.isArray(e.node)?e.node:[e.node]){if(this.#s(r))continue;let i=this.records.get(r)?.parent??null;try{this.remove(r)}catch(s){t.push(s)}this.#p(i)}return}if(!this.#s(e.node))if(e.evt==="ins")this.insert(e.node);else if(e.evt.startsWith("upd_"))this.update(e.node,e.evt);else throw new Error(`Unsupported Source event: ${e.evt}`)}attached(e){let t=e.parentBag;for(;t&&t!==this.source;)t=t.parentNode?.parentBag;return t===this.source}#a(e){let t=new Set(this.pending.flatMap(r=>Array.isArray(r.node)?r.node:[r.node]));for(let r=e;r;r=r.parentBag?.parentNode)if(t.has(r))return!0;return!1}#l(e){let t=r=>{if(!(r instanceof nr))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(r.value instanceof A){if(!(r.value instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");for(let i of r.value.getNodes())t(i)}};t(e.node)}insert(e){if(!this.attached(e)||this.records.has(e))return;if(e._getMeta("data_element")){this.records.get(e.parentBag?.parentNode)?.button?.refresh(),this.binding.branchBuilt(e);return}let t=this.records.get(e.parentBag?.parentNode),r=t?.element??t?.container??this.destination,i=e.parentBag.getNodes(),s=t?.end??null;for(let o=i.indexOf(e)+1;o<i.length;o++){let a=this.records.get(i[o]);if(a){s=a.presentation??a.start;break}}this.buildNode(e,r,s,t)}buildNode(e,t,r=null,i=null){this.#e.add(e);let s;try{s=this.render(e,{document:t.ownerDocument})}catch(a){this.#c(e,a)}finally{this.#e.delete(e)}let o=this.records.get(e);return t.insertBefore(s,r),o.parent=i,this.assignContainer(o,t),i?.children.add(e),this.#p(i),this.binding.branchBuilt(e),o}#c(e,t){let r=[t],i=[],s=o=>{if(i.push(o),o.value instanceof A)for(let a of o.value.getNodes())s(a)};s(e);for(let o of i.reverse())try{this.remove(o)}catch(a){r.push(a)}throw r.length===1?t:new AggregateError(r,"Source build and cleanup failed")}assignContainer(e,t){e.container=t;let r=e.element??t;for(let i of e.children){let s=this.records.get(i);s&&this.assignContainer(s,r)}}update(e,t){let r=this.records.get(e);if(!r){this.insert(e);return}let i=e.value==null||["string","number","boolean"].includes(typeof e.value),s=t==="upd_value"&&i&&r.element&&r.children.size===0&&this.html.matches(r,e);(t==="upd_attrs"||s)&&r.element&&this.html.matches(r,e)?(e.nodeTag&&this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder),this.project(e),t==="upd_attrs"&&this.records.get(e)===r&&(this.references?.remove(e),this.references?.register(e,r.element))):this.#m(e)}project(e,t=null){let r=this.records.get(e);if(!r?.element||!this.attached(e))return;let i=this.getRender(e.builder),s=this.#n.get(e),[o,a]=e.rootBuilder.runtimeValues(e),[,l]=i._handleMeta(e,a),u=this.#t.get(e),c=r.element.namespaceURI===we&&r.element.localName==="input"&&!Object.is(r.resolved.type,u.type),d=r.element.namespaceURI===we&&["input","select"].includes(r.element.localName)&&!!r.resolved.multiple!=!!u.multiple,f=r.resolved.group,h=r.control instanceof Gr&&!Object.is(f??null,u.group??null);if((c||d||h)&&this.#s(e))return;if(r.shape!==ye.shape(r.element,u)){if(this.#s(e))return;this.#r.set(e,u);try{this.#m(e)}finally{this.#r.delete(e)}return}let m=c?ye.classFor(r.element,u):null,p=c&&(r.control?.constructor??null)!==m,b=(c||d&&r.element.localName==="input")&&!p&&r.control&&Object.is(r.resolved.value,u.value);if(p&&(r.control?.detach(),r.control=null),h&&!p&&u.group!=null&&e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);r.resolved=u;let g=e._getMeta("subbuilder")?l:i.adaptAttrs(l),_=e.value instanceof A,w=_?[]:this.expressionValue(e,o);if(i===this&&(g=this.restoreNativeAttributes(e,g),e._getMeta("gramlot_component")||([w,g]=zn(w,g,(D,y)=>this._binding.gramlot.format(D,y)))),g=this.componentAttributes(e,g),this.html.update(r,e,g,_?g._text:w,u.visible??null),p&&m&&(r.control=new m(r.binding,r),r.control.attach()),h&&!p){r.control.refresh(f??null),this.records.get(e)===r&&!r.binding.closed&&this.project(e);return}b||this.#d(r,e,g,t),r.control?.refresh(),r.button?.refresh(),r.menu?.refresh(),this.#f(r);let E=this.#n.get(e);if(E){let D=new Set([...Object.keys(s??{}),...Object.keys(E)].filter(y=>!Object.is(s?.[y],E[y])));D.size&&this.#u(e,D)}(r.element.localName==="option"||r.element.localName==="optgroup")&&this.#p(r.parent)}#u(e,t){if(e.value instanceof A)for(let r of e.value.getNodes()){let i=r._getMeta("gramlot_component"),s=r.getAttr(),o=t;i?.presentationDefaults.length?o=new Set([...t].filter(a=>!Object.hasOwn(s,a))):this.html.hasLabelbox(r)&&[...t].some(a=>!Object.hasOwn(s,a))&&this.project(r),o.size&&this.#u(r,o)}}componentAttributes(e,t){let r=e._getMeta("gramlot_component"),i=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!r&&!i)return t;let s=this.#t.get(e),o=Object.fromEntries([...new Set([...Object.keys(r?.parameters??{}),...Object.keys(i??{}),...Object.keys(s).filter(a=>a.startsWith("validate_"))])].filter(a=>Object.hasOwn(s,a)).map(a=>[a,s[a]]));return{...t,...o}}#d(e,t,r,i){if(!e.control)return;let s=t.getAttr("value")!=null;(s||e.valueDeclared)&&e.control.project(r.value??null,i),e.valueDeclared=s}#f(e){let t=new Map(Yn.declared(e.node).map(r=>[r[0],r]));if(!e.events){if(!t.size)return;e.events=new Map,e.cleanup.push(()=>{for(let r of e.events.values())r.detach();e.events.clear()})}for(let[r,i]of[...e.events])t.get(r)?.[2]!==i.handler&&(i.detach(),e.events.delete(r));for(let[r,[,i,s]]of t){if(e.events.has(r))continue;let o=new Yn(e.binding,e,i,s,r);o.attach(),e.events.set(r,o)}}#p(e){for(let t=e;t;t=t.parent){if(t.control instanceof Xn){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=J(e),r=this.records.get(t);return r&&this.attached(t)?r.element??null:null}getBaseSourceNode(e){for(let t=e;t;t=t.parentNode){let r=t.nodeType===1?this.elements.get(t):null;if(r)return this.attached(r.node)?r.node:null}return null}#h(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#m(e){let t=this.records.get(e),r=t.presentation?.nextSibling??t.end?.nextSibling??null,i=t.container,s=t.parent,o=null;try{this.remove(e)}catch(a){o=a}try{this.buildNode(e,i,r,s)}catch(a){throw o?new AggregateError([o,a],"Source replacement cleanup and commit failed"):a}if(o)throw o}onDispose(e,t){let r=this.records.get(e);if(!r)throw new Error("Source node is not mounted");return r.cleanup.push(t),()=>{let i=r.cleanup.indexOf(t);i!==-1&&r.cleanup.splice(i,1)}}remove(e){let t=this.records.get(e);if(!t)return;let r=[];for(let i of[...t.children])try{this.remove(i)}catch(s){r.push(s)}for(let i of t.cleanup.splice(0).reverse())try{i()}catch(s){r.push(s)}if(this.references?.remove(e),t.element&&this.elements.delete(t.element),t.presentation&&this.elements.delete(t.presentation),t.presentation?.remove(),t.start?.remove(),t.end?.remove(),t.parent?.children.delete(e),this.records.delete(e),this.#t.delete(e),this.#n.delete(e),r.length)throw new AggregateError(r,"Source cleanup failed")}dispose(){if(this.disposed)return;this.disposed=!0,this.dragDrop.dispose(),this.source.unsubscribe(this.subscription,{any:!0}),this.pending.length=0;let e=[],t=[...this.records.entries()].filter(([,r])=>!r.parent).map(([r])=>r);for(let r of t)try{this.remove(r)}catch(i){e.push(i)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var ib=new Set(["page","constructor"]);function Wc(n,e){if(n===null)return[];let t=n.split("/");for(let r of t)if(ib.has(r))throw new Error(`${e}: a logic group cannot be named '${r}' (group '${n}')`);return t}var sb=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function ob(n){return/^[\w$]/.test(n)?sb.has(n):n!==")"&&n!=="]"}function ab(n,e){let t=!1;for(let r=e+1;r<n.length;r++){let i=n[r];if(i===`
192
+ `)return-1;if(i==="\\"){r++;continue}if(i==="[")t=!0;else if(i==="]")t=!1;else if(i==="/"&&!t)return r}return-1}function lb(n){let e=0,t="",r="";for(let i=n.indexOf("{");i<n.length;i++){let s=n[i];if(s==="/"&&n[i+1]==="/"){if(i=n.indexOf(`
193
+ `,i),i<0)break;continue}if(s==="/"&&n[i+1]==="*"){let o=n.indexOf("*/",i+2);if(o>=0){i=o+1;continue}}if(s==="/"&&ob(r)){let o=ab(n,i);if(o>=0){i=o,r=")";continue}}if(s==='"'||s==="'"||s==="`"){let o=i+1;for(;o<n.length&&n[o]!==s;)o+=n[o]==="\\"?2:1;e===1&&(t+=n.slice(i+1,o)==="constructor"?" constructor":' ""'),i=o,r=")";continue}if(/[\w$]/.test(s)){let o=i+1;for(;o<n.length&&/[\w$]/.test(n[o]);)o++;e===1&&(t+=n.slice(i,o)),r=n.slice(i,o),i=o-1;continue}if(/\s/.test(s)||(r=s),s==="{"){++e===2&&(t+=" {}");continue}if(s==="}"){e--;continue}e===1&&(t+=s)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function Gc(n,e){if(n===void 0)return[];if(typeof n!="function"||!/^class\b/.test(Function.prototype.toString.call(n)))throw new Error(`${e}: the module exports no class Logic`);if(Object.getPrototypeOf(n)!==Function.prototype||Object.getPrototypeOf(n.prototype)!==Object.prototype)throw new Error(`${e}: class Logic cannot extend another class`);if(lb(Function.prototype.toString.call(n)))throw new Error(`${e}: class Logic cannot declare a constructor; state lives on the group or the page`);let t=[];for(let r of Reflect.ownKeys(n.prototype)){if(r==="constructor")continue;if(typeof r=="symbol")throw new Error(`${e}: class Logic cannot declare symbol keys (${String(r)})`);let i=Object.getOwnPropertyDescriptor(n.prototype,r);if(i.get||i.set)throw new Error(`${e}: class Logic cannot declare the accessor '${r}'`);if(typeof i.value!="function")throw new Error(`${e}: Logic.prototype.${r} is not a method`);if(r==="page")throw new Error(`${e}: a logic method cannot be named 'page'`);t.push([r,i.value])}return t}function Xc(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var ar=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},Jr=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new ar(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:r,resource:i}of e){let s=Wc(r,i);for(let o=0;o<s.length;o++){let a=s.slice(0,o).join("/");t.has(a)||t.set(a,new Set),t.get(a).add(s[o])}}for(let{logicClass:r,group:i,resource:s}of e){let o=t.get(i??"")??new Set;for(let[a]of Gc(r,s))if(o.has(a))throw new Error(`${s}: the logic method '${a}' has the name of a child group`)}}register(e,{group:t=null,resource:r}){let i=Wc(t,r),s=Gc(e,r),o=this.#e.logic;for(let a of i){let l=Object.getOwnPropertyDescriptor(o,a)?.value;if(l===void 0){let u=new ar(this,this.#e);Xc(o,a,u),o=u}else if(l instanceof ar)o=l;else throw new Error(`${r}: the group '${a}' has the name of a logic method`)}for(let[a,l]of s){if(Object.getOwnPropertyDescriptor(o,a)?.value instanceof ar)throw new Error(`${r}: the logic method '${a}' has the name of a child group`);Xc(o,a,l)}this.#t.has(o)||this.#t.set(o,[]),this.#t.get(o).push(r)}resolve(e,t){let r=e.split("."),i=r.pop(),s=this.#e.logic;for(let a=0;a<r.length;a++)if(s=Object.getOwnPropertyDescriptor(s,r[a])?.value,!(s instanceof ar))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${r.slice(0,a+1).join("/")}'`);let o=Object.getOwnPropertyDescriptor(s,i)?.value;if(typeof o!="function"){let a=this.#t.get(s)??[],l=r.length?`the group '${r.join("/")}'`:"the page logic";throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: ${l} has no method '${i}' (resources: ${a.join(", ")||"none"})`)}return{group:s,method:o}}};var ti=class extends De{constructor(e,{collections:t,destination:r,subscriptions:i,nameSyntax:s}){super(e),e.src=this,this.logicRegistry=new Jr(e),this.builder=new Oe(null,{collections:t,nameSyntax:s}),this.binding=new Zr(e,{subscriptions:i}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new ei(this.builder,this.source,r,{binding:this.binding})}startSource(e){if(!["ready","failed"].includes(this.gramlot.state))throw new Error(`Cannot start embedded Source while Gramlot is ${this.gramlot.state}`);try{return this.mountMainSource(e)}catch(t){throw this.gramlot.state="failed",t}}mountMainSource(e,t=null){let r=this.prepareSource(e);if(this.renderer.validateCandidate(r),t!==null){if(!(t instanceof x)||t instanceof A)throw new TypeError("Initial page data must be a Data Bag");for(let i of t.getNodes())this.builder.data.setItem([i.label],i.getValue(),i.attr,">",!1,!1)}try{this.source.setItem("main",r)}catch(i){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),i}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof A){if(!(e instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");return e.bindBuilder(t).activateCode()}if(typeof e!="string")throw new TypeError("Source value did not decode to SourceBag");let r=Jo(e,t);if(!(r instanceof de))throw new TypeError("Source values must be GramlotBuilderBags");return r.activateCode()}async remoteSource(e,t,r={}){if(!this.gramlot.rpc.transport?.call)throw new Error("Remote Source is unavailable without a server transport");let s=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!s)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,r,o=>this.#e(e,s,o))??!1}async#e(e,t,r){if(t.closed||this.gramlot.state==="disposed")return!1;let i=!1,s=()=>this.gramlot.state!=="disposed"&&!r.ignored&&!t.closed;try{let o=await t.call("source",r);if(!s())return!1;let a=this.prepareSource(o,e.builder);return s()?(this.renderer.validateCandidate(a,{replacingNode:e}),i=!0,e.setValue(a,!0,{_text:null},!0),t.remote?.fragmentMounted(r.method,r.text),!0):!1}catch(o){if(!i&&!s())return!1;throw o}}};var ri=class extends Error{name="RpcError";constructor({code:e,name:t,message:r,details:i}){super(r),this.code=e,this.remoteName=t,i!==void 0&&(this.details=i)}},ni=class extends De{constructor(e,{rpcUrl:t,closeUrl:r,document:i,transport:s}){super(e),this.transport=s===!1?null:s??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:r,document:i}),this.remoteRequests=new Map}get supportsCallSync(){return this.transport?.supportsCallSync===!0}callSync(e,t,r={}){if(!this.supportsCallSync)throw new Error(`rpc '${t}': the transport of this page has no synchronous call`);if(Mt(r),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let i=Q(),s=j(this.transport.callSync(U({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:r})));if(s.id!==i)throw new Error("rpc response id mismatch");if(s.error)throw new ri(s.error);return s.value}async call(e,t,r={},i={}){return(await this.callEnvelope(e,t,r,i)).value}async callEnvelope(e,t,r={},{signal:i=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);Mt(r);let s=Q(),o=U({id:s,pageId:this.gramlot.pageId,contentType:e,name:t,params:r}),a=i?[this.gramlot.abort.signal,i]:[this.gramlot.abort.signal],l=a.find(f=>f.aborted);if(l)throw l.reason;let u=new AbortController,c=f=>u.abort(f.target.reason);for(let f of a)f.addEventListener("abort",c,{once:!0});let d=new Promise((f,h)=>{u.signal.addEventListener("abort",()=>{this.remoteRequests.delete(s),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(s,u);try{let f=j(await Promise.race([this.transport.call(o,u.signal),d]));if(f.id!==s)throw new Error("rpc response id mismatch");if(f.error)throw new ri(f.error);return f}finally{this.remoteRequests.delete(s);for(let f of a)f.removeEventListener("abort",c)}}};var ii=class extends De{setTouchMode(e="auto"){if(!["auto","on","off"].includes(e))throw new TypeError(`Invalid touch mode: ${e}`);let t=this.gramlot.src.renderer.destination.ownerDocument.documentElement;e==="auto"?t.removeAttribute("data-gramlot-touch"):t.setAttribute("data-gramlot-touch",e)}navigate(e){if(typeof e!="string"||!e)throw new TypeError("Navigation requires an absolute HTTP(S) URL");let t=new URL(e);if(!["http:","https:"].includes(t.protocol)||t.username||t.password)throw new TypeError("Navigation requires an HTTP(S) URL without credentials");this.gramlot.src.renderer.destination.ownerDocument.defaultView.location.assign(t.href)}reference(e){return this.gramlot.src.renderer.references.resolve(e)}getBaseSourceNode(e){return this.gramlot.src.renderer.getBaseSourceNode(e)}getDomNode(e){return this.gramlot.src.renderer.getDomNode(e)}};var Yc="gramlot:publish",Ms=class{#e;#t;#r;#n=Q();#i=new Map;#s=!1;#o;#a;#l;#c;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#o=i=>this.#p(i),this.#a=i=>{if(i.target?.localName!=="iframe")return;let s=this.#g(i.target);s&&(this.#d(s.window),this.#h(s,{kind:"hello"}))},this.#t.addEventListener("message",this.#o),this.#l=()=>this.#u(),this.#c=()=>this.ready(),this.#t.addEventListener("pagehide",this.#l),this.#t.addEventListener("pageshow",this.#c),t.addEventListener("load",this.#a,!0);let r=this.#m();r&&this.#h(r,{kind:"hello"})}ready(){if(this.#s||this.#e.state!=="started")return;let e=this.#m();e&&this.#h(e,{kind:"ready"});for(let t of this.#r.getElementsByTagName("iframe")){let r=this.#g(t);r&&this.#h(r,{kind:"hello"})}}prepare(e,t){let r=[];if(e.parent){let o=this.#m();if(!o)throw new Error("This page has no parent frame");r.push(o)}if(e.iframe!==void 0){let o=e.iframe,a=J(o),l=typeof o=="string"?this.#r.getElementById(o):a instanceof Ae?this.#e.dom.getDomNode(a):null,u=this.#g(l);if(!u)throw new Error("iframe destination must be an active Gramlot iframe ID or Source reference");r.push(u)}let i=r.map(o=>{let a=this.#i.get(o.window);if(!a||a.origin!==o.origin)throw new Error("Destination page is not ready");return{...o,session:a.session}});Mt(t);let s=U(t);return()=>{if(!this.#s)for(let o of i){let a=this.#_(o.window);if(!a||a.origin!==o.origin||this.#i.get(o.window)?.session!==o.session)throw new Error("Destination page disconnected before publication");this.#h(o,{kind:"publish",recipient:o.session,topic:e.topic,wire:s})}}}dispose(){this.#s||(this.#u(),this.#s=!0,this.#t.removeEventListener("message",this.#o),this.#t.removeEventListener("pagehide",this.#l),this.#t.removeEventListener("pageshow",this.#c),this.#r.removeEventListener("load",this.#a,!0))}#u(){for(let[e,t]of this.#i)this.#h({window:e,origin:t.origin},{kind:"close"});for(let e of this.#i.keys())this.#d(e)}#d(e){this.#i.get(e)?.release?.(),this.#i.delete(e)}#f(e,t){this.#d(e.window);let r={session:t,origin:e.origin};e.node&&(r.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#h(e,{kind:"close"}),this.#d(e.window)})),this.#i.set(e.window,r)}#p(e){if(this.#s||e.data?.type!==Yc)return;let t=this.#_(e.source);if(!t||e.origin!==t.origin)return;let r=e.data;if(!(typeof r.session!="string"||!r.session)){if(r.kind==="hello")this.#d(t.window),r.ready===!0&&this.#f(t,r.session),this.#e.state==="started"&&this.#h(t,{kind:"ready"});else if(r.kind==="ready"){let i=this.#i.get(t.window)?.session!==r.session;this.#f(t,r.session),i&&this.#e.state==="started"&&this.#h(t,{kind:"ready"})}else if(r.kind==="close")this.#i.get(t.window)?.session===r.session&&this.#d(t.window);else if(r.kind==="publish"){if(this.#e.state!=="started"||r.recipient!==this.#n||this.#i.get(t.window)?.session!==r.session||typeof r.topic!="string"||!r.topic||typeof r.wire!="string")return;this.#e.publish(r.topic,j(r.wire))}}}#h(e,t){e.window.postMessage({type:Yc,session:this.#n,ready:this.#e.state==="started",...t},e.origin==="null"?"*":e.origin)}#m(){let e=this.#t.parent;return e===this.#t?null:{window:e,origin:this.#b(this.#r.referrer||this.#r.baseURI)}}#g(e){if(e?.localName!=="iframe"||!e.isConnected||!e.contentWindow)return null;let t=this.#e.dom.getBaseSourceNode(e);if(!t||!this.#e.src.binding.bindingFor(t)||this.#e.dom.getDomNode(t)!==e)return null;let r=e.getAttribute("sandbox"),s=r!==null&&!r.split(/\s+/).includes("allow-same-origin")?"null":this.#b(e.hasAttribute("srcdoc")?this.#r.baseURI:e.getAttribute("src")||this.#r.baseURI);return{window:e.contentWindow,origin:s,node:t}}#b(e){let t=new URL(e,this.#r.baseURI);return t.protocol==="file:"?"null":t.origin}#_(e){let t=this.#m();if(t?.window===e)return t;for(let r of this.#r.getElementsByTagName("iframe")){let i=this.#g(r);if(i?.window===e)return i}return null}};var Ls=class extends De{#e=new Map;#t=new WeakSet;#r=new WeakMap;#n=0;#i=!1;#s;attach(e){this.#s=new Ms(this.gramlot,e)}ready(){this.#s.ready()}subscribe(e,t){if(this.#l(),this.#a(e),typeof t!="function")throw new TypeError("subscribe requires a callback");let r=Object.freeze({});return this.#t.add(r),this.#e.has(e)||this.#e.set(e,new Map),this.#e.get(e).set(r,t),r}unsubscribe(e){if(!this.#t.has(e))throw new TypeError("Unknown subscription registration");for(let[t,r]of this.#e)r.delete(e)&&!r.size&&this.#e.delete(t)}publish(e,t={}){if(this.#l(),!t||typeof t!="object"||Array.isArray(t))throw new TypeError("publish requires one object of named data");if(typeof e=="string")return this.#o(e,t);if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("publish requires a topic string or descriptor");if(Object.keys(e).some(s=>!["topic","nodeId","parent","iframe"].includes(s)))throw new Error("This publication route is not implemented yet");if(this.#a(e.topic),e.parent!==void 0&&typeof e.parent!="boolean")throw new TypeError("parent must be boolean");if(e.iframe==="*")throw new Error("Recursive iframe broadcast is not implemented yet");if((e.parent||e.iframe!==void 0)&&Object.hasOwn(e,"nodeId"))throw new Error("Interframe node addressing is not implemented yet");let i=e.parent||e.iframe!==void 0?this.#s.prepare(e,t):null;if(Object.hasOwn(e,"nodeId")){let s=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!s)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(s,e.topic,t)}this.#o(e.topic,t),i?.()}topicFor(e,t){this.#a(t),e=J(e);let r=this.gramlot.src.binding.bindingFor(e);if(!r||r.closed)throw new Error("Topic target is not an active Source node of this page");let i=e.getAttr("nodeId");return i==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#n}`),i=this.#r.get(e)),`${i}_${t}`}publishNode(e,t,r={}){return this.publish(this.topicFor(e,t),r)}subscribeNode(e,t){let r=[];for(let[i,s]of Object.entries(e.getAttr())){let o=i.startsWith("selfsubscribe_")?"selfsubscribe_":i.startsWith("subscribe_")?"subscribe_":null;if(!o)continue;let a=o==="selfsubscribe_"?this.topicFor(e,i.slice(o.length)):i.slice(o.length);this.#a(a),r.push([a,t(i,s,a)])}return this.#l(),r.map(([i,s])=>{let o=this.subscribe(i,s);return{close:()=>this.unsubscribe(o)}})}dispose(){this.#i=!0,this.#s.dispose(),this.#e.clear()}#o(e,t){this.#a(e);let r=this.#e.get(e);if(r)for(let[i,s]of[...r]){if(this.#i)break;r.has(i)&&s(t)}}#a(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#l(){if(this.#i)throw new Error("Gramlot subscriptions are disposed")}};var Ps=class extends K{constructor(e,t,r){super({cacheTime:r}),this.handler=e,this.name=t,this.failed=!1,this.writing=!1,this.request=null,this.revision=0,this.received=0}resolve({static:e=!1}={}){return!e&&!this.handler.disposed&&!this.writing&&!this.request&&!this.failed&&!this._node.attr.watching&&this.expired&&this.handler.refresh(this.name),this.cachedValue}reset(){super.reset(),this.failed=!1,this.revision++}};var Zc=["appinfo","location"],Jc={UNAVAILABLE:"unavailable",PERMISSION_DENIED:"denied",TIMEOUT:"error",FAILED:"error",CANCELLED:"cancelled"};function V(n){let e=Object.hasOwn(Jc,n?.code)?n.code:"FAILED";return{status:Jc[e],error:e==="CANCELLED"?null:{code:e,message:String(n?.message??"Device operation failed")}}}var si=class extends De{#e=null;#t=null;#r=null;#n=null;#i=null;#s=null;#o=new Map;#a=new Map;#l=null;#c=null;#u=null;#d=null;#f=null;#p=null;#h=null;constructor(e){super(e),this.provider=null,this.disposed=!1,this.monitor=null,this.retiring=null,this.resolvers=new Map,this.cleanup=Promise.resolve()}installData(){let{gramlot:e}=this;e.data.setItem("gramlot.device.database",null,{status:"idle",error:null}),e.data.setItem("gramlot.device.orientation",null,{status:"idle",error:null,listening:!1});for(let p of["gyroscope","accelerometer"])e.data.setItem(`gramlot.device.${p}`,null,{enabled:!1,watching:!1,status:"idle",error:null}),e.data.getNode(`gramlot.device.${p}`).setAttr({error:null},!1,!0,!1),this.#a.set(p,{node:e.data.getNode(`gramlot.device.${p}`),stream:null,cleanup:Promise.resolve()});for(let p of Zc){let b=`gramlot.device.${p}`,g={status:"idle",error:null,cacheTime:p==="appinfo"?-1:5};p==="location"&&Object.assign(g,{enabled:!1,watching:!1}),e.data.setItem(b,null);let _=e.data.getNode(b);_.setAttr(g,!1,!0,!1);let w=new Ps(this,p,g.cacheTime);_.resolver=w,this.resolvers.set(p,w)}e.data.setItem("gramlot.device.clipboard",null,{status:"idle",error:null,text:"",copy:null,paste:null,operation:null});let t=e.data.getNode("gramlot.device.clipboard");e.data.setItem("gramlot.device.camera",null,{status:"idle",error:null,capture:null,choose:null});let r=e.data.getNode("gramlot.device.camera");e.data.setItem("gramlot.device.barcode",null,{status:"idle",error:null,scan:null});let i=e.data.getNode("gramlot.device.barcode");e.data.setItem("gramlot.device.biometrics",null,{status:"idle",error:null,verify:null});let s=e.data.getNode("gramlot.device.biometrics"),o=new x;o.setItem("request",new x);for(let p of["scheduled","received","action"])o.setItem(p,null);e.data.setItem("gramlot.device.notifications",o,{status:"idle",error:null,schedule:null,listening:!1,listenerError:null});let a=e.data.getNode("gramlot.device.notifications"),l=new x;for(let p of["registration","received","action"])l.setItem(p,null);e.data.setItem("gramlot.device.push",l,{status:"idle",error:null,register:null,listening:!1,listenerError:null});let u=e.data.getNode("gramlot.device.push"),c=new x;c.setItem("request",null),e.data.setItem("gramlot.device.links",c,{listening:!1,listenerError:null});let d=new x;d.setItem("request",null),e.data.setItem("gramlot.device.shortcuts",d,{listening:!1,listenerError:null}),e.data.setItem("gramlot.device.network",null,{status:"idle",error:null,listening:!1});let f=new x;f.setItem("active",null),f.setItem("event",null),f.setItem("sequence",0),e.data.setItem("gramlot.device.lifecycle",f,{status:"idle",error:null,listening:!1}),e.data.setItem("gramlot.device.haptics",null,{status:"idle",error:null,impact:null,style:"medium",vibrate:null,duration:600});let h=e.data.getNode("gramlot.device.haptics");e.data.setItem("gramlot.device.audio",null,{status:"idle",error:null,recording:!1,start:null,stop:null,cancel:null,share:null,shareStatus:"idle",shareError:null,shareActivity:null});let m=e.data.getNode("gramlot.device.audio");e.data.subscribe("gramlot.device",{update:p=>{if(!this.disposed){for(let[b,g]of this.#a)if(p.node===g.node&&p.attrs_diff?.enabled){if(typeof g.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.#g(b,g)}p.node===t&&p.fired&&(p.attrs_diff?.copy?.new===!0&&this.#v(t,"copy"),p.attrs_diff?.paste?.new===!0&&this.#v(t,"paste")),p.node===m&&p.fired&&(p.attrs_diff?.start?.new===!0&&this.#b(m),p.attrs_diff?.stop?.new===!0&&this.#_(m),p.attrs_diff?.cancel?.new===!0&&this.#y(m),p.attrs_diff?.share?.new===!0&&this.#A(m)),p.node===h&&p.fired&&p.attrs_diff?.impact?.new===!0&&this.#D(h),p.node===h&&p.fired&&p.attrs_diff?.vibrate?.new===!0&&this.#T(h),p.node===i&&p.fired&&p.attrs_diff?.scan?.new===!0&&this.#C(i),p.node===r&&p.fired&&p.attrs_diff?.choose?.new===!0&&this.#E(r,"choose"),p.node===r&&p.fired&&p.attrs_diff?.capture?.new===!0&&this.#E(r,"capture"),p.node===s&&p.fired&&p.attrs_diff?.verify?.new===!0&&this.#S(s),p.node===a&&p.fired&&p.attrs_diff?.schedule?.new===!0&&this.#N(a),p.node===u&&p.fired&&p.attrs_diff?.register?.new===!0&&this.#O(u);for(let b of this.resolvers.values()){if(p.node!==b._node)continue;let{cacheTime:g}=p.node.attr;if(typeof g!="number"||!Number.isFinite(g)||g<0&&g!==-1)throw new TypeError("Device cacheTime must be -1 or a nonnegative number of seconds");if(b.cacheTime=g,b.name==="location"){if(typeof p.node.attr.enabled!="boolean")throw new TypeError("Device enabled must be boolean");this.reconcile()}}}}})}attach(e,{dispose:t=null}={}){if(this.assertLive(),this.provider)throw new Error("A device provider is already attached");if(!Array.isArray(e.capabilities)||e.capabilities.some(r=>![...Zc,"camera","biometrics","notifications","push","shortcuts","barcode","network","lifecycle","haptics","audio","clipboard","links","orientation","gyroscope","accelerometer","database"].includes(r)))throw new TypeError("Unknown device provider capability");if(t!==null&&typeof t!="function")throw new TypeError("Device attachment dispose must be a function");this.releaseProvider=t,this.provider=e,this.installData(),this.reconcile(),this.#m("orientation",(r,i)=>e.startOrientationEvents(r,i),(r,i)=>{if(!["portrait","landscape"].includes(i?.type)||!["primary","secondary"].includes(i.direction)||!Number.isFinite(i.timestamp))throw new TypeError("Invalid screen orientation from device provider");let s=new x;for(let o of["type","direction","timestamp"])s.setItem(o,i[o]);r.setValue(s,!0,{status:"success",error:null},!0,!1)}),this.#m("network",(r,i)=>e.startNetworkEvents(r,i),(r,i)=>{if(typeof i?.connected!="boolean"||!["none","unknown","wifi","cellular"].includes(i.type))throw new TypeError("Invalid network state from device provider");let s=new x;s.setItem("connected",i.connected),s.setItem("type",i.type),r.setValue(s,!0,{status:"success",error:null},!0,!1)}),this.#m("lifecycle",(r,i)=>e.startLifecycleEvents(r,i),(r,i)=>{if(i?.kind==="state"&&typeof i.active=="boolean")r.staticValue.setItem("active",i.active);else if(i?.kind==="pause"||i?.kind==="resume")r.staticValue.setItem("event",i.kind),r.staticValue.setItem("sequence",r.staticValue.getItem("sequence")+1);else throw new TypeError("Invalid lifecycle event from device provider");r.setAttr({status:"success",error:null},!0,!0,!1)}),e.capabilities.includes("links")&&this.#R(this.gramlot.data.getNode("gramlot.device.links")),e.capabilities.includes("shortcuts")&&this.#B(this.gramlot.data.getNode("gramlot.device.shortcuts")),e.capabilities.includes("push")&&this.#k(this.gramlot.data.getNode("gramlot.device.push")),e.capabilities.includes("notifications")&&this.#x(this.gramlot.data.getNode("gramlot.device.notifications"))}assertLive(){if(this.disposed)throw new Error("DeviceHandler is disposed")}resolver(e){if(this.assertLive(),!this.resolvers.has(e))throw new TypeError(`Unknown device value: ${e}`);return this.resolvers.get(e)}invalidate(e){this.resolver(e).reset()}refresh(e){let t=this.resolver(e);if(t.request)return;let r={revision:t.revision,received:t.received};t.request=r,this.attributes(t,{status:"pending",error:null}),Promise.resolve().then(()=>{if(!(this.disposed||t.request!==r))return this.requireCapability(e),e==="appinfo"?this.provider.readAppInfo():this.provider.readLocation()}).then(i=>{this.disposed||t.request!==r||(this.accept(t,i),t.revision!==r.revision&&(t._lastUpdate=null))}).catch(i=>{!this.disposed&&t.request===r&&t.received===r.received&&this.failure(t,i)}).finally(()=>{t.request===r&&(t.request=null)})}#m(e,t,r){let i=this.gramlot.data.getNode(`gramlot.device.${e}`);if(!this.provider.capabilities.includes(e)){i.setAttr(V({code:"UNAVAILABLE",message:`${e} is unavailable`}),!0,!0,!1);return}let s={controller:new AbortController};this.#o.set(e,s),i.setAttr({status:"pending",error:null},!0,!0,!1),s.start=Promise.resolve().then(()=>s.controller.signal.aborted?async()=>{}:t(o=>{if(!s.controller.signal.aborted)try{r(i,o)}catch(a){i.setAttr(V(a),!0,!0,!1)}},s.controller.signal)).then(o=>(s.controller.signal.aborted||i.setAttr({listening:!0},!0,!0,!1),o)),s.start.catch(o=>{let a=s.controller.signal.aborted;s.controller.abort(),a||i.setAttr({...V(o),listening:!1},!0,!0,!1)})}#g(e,t){let{node:r}=t;if(!r.attr.enabled){let s=t.stream;if(!s)return;t.stream=null,s.controller.abort(),t.cleanup=s.start.then(o=>o(),()=>{}).then(()=>{!this.disposed&&!t.stream&&r.setAttr({watching:!1,status:"idle",error:null},!0,!0,!1)}),t.cleanup.catch(o=>{this.disposed||r.setAttr(V(o),!0,!0,!1)});return}if(t.stream)return;let i={controller:new AbortController};t.stream=i,i.start=t.cleanup.then(()=>{if(i.controller.signal.aborted)return async()=>{};this.requireCapability(e);let s=o=>{if(!(this.disposed||i.controller.signal.aborted))try{if(o?.kind==="state"&&typeof o.watching=="boolean")r.setAttr({watching:o.watching,status:o.watching?"pending":"idle",error:null},!0,!0,!1);else if(o?.kind==="sample"){for(let l of["x","y","z","timestamp"])if(!Number.isFinite(o[l]))throw new TypeError(`Invalid ${e}.${l}`);if(!r.attr.watching||r.staticValue&&o.timestamp<r.staticValue.getItem("timestamp"))return;let a=new x;for(let l of["x","y","z","timestamp"])a.setItem(l,o[l]);r.setValue(a,!0,{status:"success",error:null},!0,!1)}else if(o?.kind==="error"&&o.error instanceof Error)r.setAttr({...V(o.error),watching:!1},!0,!0,!1);else throw new TypeError(`Invalid ${e} event`)}catch(a){r.setAttr(V(a),!0,!0,!1)}};return e==="gyroscope"?this.provider.startGyroscopeUpdates(s,i.controller.signal):this.provider.startAccelerometerUpdates(s,i.controller.signal)}),i.start.catch(s=>{!this.disposed&&!i.controller.signal.aborted&&r.setAttr({...V(s),watching:!1},!0,!0,!1)}),r.setAttr({status:"pending",error:null},!0,!0,!1)}#b(e){let t=this.#n;if(t){if(t.phase!=="complete")return;t.phase="replacing",e.setValue(null,!0,{status:"pending",error:null,recording:!1,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),t.close=t.start.then(i=>i.dispose()).then(()=>{this.disposed||t.controller.signal.aborted||this.#n!==t||(this.#n=null,this.#b(e))}).catch(i=>{!this.disposed&&this.#n===t&&(t.phase="failed",e.setAttr(V(i),!0,!0,!1))});return}let r={controller:new AbortController,phase:"starting"};this.#n=r,e.setValue(null,!0,{status:"pending",error:null,recording:!1,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),r.start=Promise.resolve().then(async()=>r.controller.signal.aborted?null:(this.requireCapability("audio"),this.provider.startAudioRecording(i=>{this.#n===r&&!r.controller.signal.aborted&&this.#y(e,i)},r.controller.signal))),r.start.then(i=>{!i||r.controller.signal.aborted||this.disposed||(r.phase="recording",e.setAttr({status:"recording",error:null,recording:!0},!0,!0,!1))}).catch(i=>{r.controller.signal.aborted||this.disposed||(this.#n===r&&(this.#n=null),e.setAttr({...V(i),recording:!1},!0,!0,!1))})}#_(e){let t=this.#n;!t||t.phase!=="recording"||(t.phase="stopping",e.setAttr({status:"pending",error:null},!0,!0,!1),t.stop=t.start.then(r=>r.stop()).then(r=>{if(t.controller.signal.aborted||this.disposed)return;if(typeof r?.url!="string"||!r.url||typeof r.mimeType!="string"||!r.mimeType.startsWith("audio/")||!Number.isFinite(r.duration)||r.duration<0)throw new TypeError("Invalid audio result from device provider");let i=new x;for(let s of["url","mimeType","duration"])i.setItem(s,r[s]);t.phase="complete",e.setValue(i,!0,{status:"success",error:null,recording:!1},!0,!1)}).catch(r=>{!t.controller.signal.aborted&&!this.disposed&&this.#y(e,r)}))}#A(e){let t=this.#n;if(t?.phase!=="sharing"){if(!t||t.phase!=="complete"){let r=V(new Error("Record and stop audio before sharing"));e.setAttr({shareStatus:r.status,shareError:r.error,shareActivity:null},!0,!0,!1);return}t.phase="sharing",e.setAttr({shareStatus:"pending",shareError:null,shareActivity:null},!0,!0,!1),t.share=t.start.then(r=>r.share(t.controller.signal)).then(r=>{if(!(t.controller.signal.aborted||this.disposed)){if(typeof r?.activity!="string")throw new TypeError("Invalid audio share result from device provider");e.setAttr({shareStatus:"success",shareError:null,shareActivity:r.activity},!0,!0,!1)}}).catch(r=>{if(t.controller.signal.aborted||this.disposed)return;let i=V(r);e.setAttr({shareStatus:i.status,shareError:i.error,shareActivity:null},!0,!0,!1)}).finally(()=>{this.#n===t&&!t.controller.signal.aborted&&(t.phase="complete")})}}#y(e,t={code:"CANCELLED",message:"Audio recording cancelled"}){let r=this.#n;!r||r.phase==="closing"||r.phase==="sharing"||(r.phase="closing",r.controller.abort(),e.setValue(null,!0,{status:"pending",error:null,shareStatus:"idle",shareError:null,shareActivity:null},!0,!1),r.close=r.start.then(i=>i===null?void 0:i.dispose(),i=>{if(i?.code!=="CANCELLED")throw i}).then(()=>{this.disposed||this.#n!==r||(this.#n=null,e.setAttr({...V(t),recording:!1},!0,!0,!1))}).catch(i=>{!this.disposed&&this.#n===r&&(r.phase="failed",e.setAttr(V(i),!0,!0,!1))}))}#v(e,t){if(this.#t)return;let r=new AbortController;this.#t=r;let i=e.attr.text;e.setValue(null,!0,{status:"pending",error:null,operation:t},!0,!1),Promise.resolve().then(async()=>{if(r.signal.aborted)return;this.requireCapability("clipboard");let s;if(t==="copy"){if(typeof i!="string")throw new TypeError("Clipboard text must be a string");await this.provider.copyText(i,r.signal),s={text:i}}else s=await this.provider.pasteText(r.signal);if(r.signal.aborted)return;if(typeof s?.text!="string")throw new TypeError("Invalid clipboard text from device provider");let o=new x;o.setItem("text",s.text),e.setValue(o,!0,{status:"success",error:null},!0,!1)}).catch(s=>{r.signal.aborted||e.setAttr(V(s),!0,!0,!1)}).finally(()=>{this.#t===r&&(this.#t=null)})}#T(e){if(this.#s)return;let t=new AbortController;this.#s=t;let{duration:r}=e.attr;e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(async()=>{if(t.signal.aborted)return;if(this.requireCapability("haptics"),!Number.isInteger(r)||r<1||r>5e3)throw new TypeError("Vibration duration must be an integer from 1 to 5000 milliseconds");if(await this.provider.vibrate(r,t.signal),t.signal.aborted)return;let i=new x;i.setItem("duration",r),i.setItem("acknowledged",!0),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#s===t&&(this.#s=null)})}#D(e){if(this.#s)return;let t=new AbortController;this.#s=t;let{style:r}=e.attr;e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(async()=>{if(t.signal.aborted)return;if(this.requireCapability("haptics"),!["light","medium","heavy"].includes(r))throw new TypeError("Invalid haptic style");if(await this.provider.impact(r,t.signal),t.signal.aborted)return;let i=new x;i.setItem("style",r),i.setItem("acknowledged",!0),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(i=>{t.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#s===t&&(this.#s=null)})}#C(e){if(this.#i)return;let t=new AbortController;this.#i=t,e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(()=>{if(!t.signal.aborted)return this.requireCapability("barcode"),this.provider.scanBarcode(t.signal)}).then(r=>{if(t.signal.aborted)return;if(typeof r?.text!="string"||!r.text||typeof r.format!="string"||!r.format)throw new TypeError("Invalid barcode result from device provider");let i=new x;i.setItem("text",r.text),i.setItem("format",r.format),e.setValue(i,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setAttr(V(r),!0,!0,!1)}).finally(()=>{this.#i===t&&(this.#i=null)})}#E(e,t){if(this.#r)return;let r=new AbortController;this.#r=r,e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(()=>{if(!r.signal.aborted)return this.requireCapability("camera"),t==="choose"?this.provider.choosePhoto(r.signal):this.provider.takePhoto(r.signal)}).then(i=>{if(r.signal.aborted)return;if(typeof i?.url!="string"||!i.url||typeof i.format!="string"||!i.format)throw new TypeError("Invalid camera photo from device provider");let s=new x;s.setItem("url",i.url),s.setItem("format",i.format),e.setValue(s,!0,{status:"success",error:null},!0,!1)}).catch(i=>{r.signal.aborted||e.setAttr(V(i),!0,!0,!1)}).finally(()=>{this.#r===r&&(this.#r=null)})}#S(e){if(this.#l)return;let t=new AbortController;this.#l=t,e.setValue(null,!0,{status:"pending",error:null},!0,!1),Promise.resolve().then(()=>{if(!t.signal.aborted)return this.requireCapability("biometrics"),this.provider.verifyBiometrics(t.signal)}).then(()=>{if(t.signal.aborted)return;let r=new x;r.setItem("verified",!0),e.setValue(r,!0,{status:"success",error:null},!0,!1)}).catch(r=>{t.signal.aborted||e.setValue(null,!0,V(r),!0,!1)}).finally(()=>{this.#l===t&&(this.#l=null)})}#x(e){if(this.#u)return this.#u.start;let t={controller:new AbortController};return this.#u=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startNotificationEvents(r=>{if(!t.controller.signal.aborted)try{if(!["received","action"].includes(r.kind)||!Number.isInteger(r.id)||typeof r.title!="string"||typeof r.body!="string"||r.kind==="action"&&typeof r.actionId!="string")throw new TypeError("Invalid notification event from device provider");let i=new x;for(let s of["id","title","body"])i.setItem(s,r[s]);r.kind==="action"&&i.setItem("actionId",r.actionId),e.staticValue.setItem(r.kind,i)}catch(i){e.setAttr({listenerError:V(i).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),this.#u===t&&(this.#u=null),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)}),e.setAttr({listenerError:null},!0,!0,!1),t.start}#N(e){if(this.#c)return;let t=new AbortController;this.#c=t;let r=e.staticValue.getItem("request"),i=r instanceof x?Object.fromEntries(["id","title","body","delay"].map(s=>[s,r.getItem(s)])):null;e.staticValue.setItem("scheduled",null),e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(async()=>{if(!t.signal.aborted){if(this.requireCapability("notifications"),!i||!Number.isInteger(i.id)||i.id<1||i.id>2147483647||typeof i.title!="string"||!i.title.trim()||typeof i.body!="string"||!i.body.trim()||typeof i.delay!="number"||!Number.isFinite(i.delay)||i.delay<=0)throw new TypeError("Notification requires a positive 32-bit id, title, body and positive delay in seconds");if(await this.#x(e),!t.signal.aborted)return this.provider.scheduleNotification(i,t.signal)}}).then(s=>{if(t.signal.aborted)return;if(s?.id!==i.id||typeof s.at!="number"||!Number.isFinite(s.at))throw new TypeError("Invalid notification scheduling acknowledgement");let o=new x;o.setItem("id",s.id),o.setItem("at",s.at),e.staticValue.setItem("scheduled",o),e.setAttr({status:"success",error:null},!0,!0,!1)}).catch(s=>{t.signal.aborted||e.setAttr(V(s),!0,!0,!1)}).finally(()=>{this.#c===t&&(this.#c=null)})}#w(){let e=this.#d;return this.#d=null,e&&clearTimeout(e.timer),e}#I(e,t){if(t.kind==="registration"){if(typeof t.token!="string"||!t.token)throw new TypeError("Invalid push registration token");this.#w();let r=new x;r.setItem("token",t.token),e.staticValue.setItem("registration",r),e.setAttr({status:"success",error:null},!0,!0,!1)}else if(t.kind==="registrationError")this.#w(),e.staticValue.setItem("registration",null),e.setAttr(V(t.error),!0,!0,!1);else{if(!["received","action"].includes(t.kind))throw new TypeError("Invalid push event kind");let r=["id","title","body","messageId","destination"];t.kind==="action"&&r.push("actionId");let i=new x;for(let s of r){if(typeof t[s]!="string")throw new TypeError(`Invalid push event ${s}`);i.setItem(s,t[s])}e.staticValue.setItem(t.kind,i)}}#k(e){if(this.#f)return this.#f.start;let t={controller:new AbortController};return this.#f=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startPushEvents(r=>{if(!t.controller.signal.aborted)try{this.#I(e,r)}catch(i){e.setAttr({listenerError:V(i).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),this.#f===t&&(this.#f=null),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)}),e.setAttr({listenerError:null},!0,!0,!1),t.start}#O(e){if(this.#d)return;let t={controller:new AbortController,timer:null};this.#d=t,t.timer=setTimeout(()=>{this.disposed||this.#d!==t||(this.#w(),t.controller.abort(),e.setAttr(V({code:"TIMEOUT",message:"Push registration has not returned a token"}),!0,!0,!1))},3e4),e.staticValue.setItem("registration",null),e.setAttr({status:"pending",error:null},!0,!0,!1),Promise.resolve().then(async()=>{t.controller.signal.aborted||(this.requireCapability("push"),await this.#k(e),!(t.controller.signal.aborted||this.#d!==t)&&await this.provider.registerPush(t.controller.signal))}).catch(r=>{this.disposed||this.#d!==t||(this.#w(),t.controller.abort(),e.setAttr(V(r),!0,!0,!1))})}#B(e){let t={controller:new AbortController};this.#p=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startShortcutEvents((r,i=null)=>{if(!t.controller.signal.aborted)try{if(i)throw i;for(let o of["id","destination"])if(typeof r?.[o]!="string"||!r[o])throw new TypeError(`Invalid shortcut request ${o}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let s=new x;s.setItem("id",r.id),s.setItem("destination",r.destination),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",s)}catch(s){e.setAttr({listenerError:V(s).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)})}#R(e){let t={controller:new AbortController};this.#h=t,t.start=Promise.resolve().then(()=>t.controller.signal.aborted?async()=>{}:this.provider.startLinkEvents((r,i=null)=>{if(!t.controller.signal.aborted)try{if(i)throw i;for(let o of["id","url"])if(typeof r?.[o]!="string"||!r[o])throw new TypeError(`Invalid link request ${o}`);if(e.staticValue.getItem("request")?.getItem("id")===r.id)return;let s=new x;s.setItem("id",r.id),s.setItem("url",r.url),e.setAttr({listenerError:null},!0,!0,!1),e.staticValue.setItem("request",s)}catch(s){e.setAttr({listenerError:V(s).error},!0,!0,!1)}},t.controller.signal)).then(r=>(t.controller.signal.aborted||e.setAttr({listening:!0},!0,!0,!1),r)),t.start.catch(r=>{let i=t.controller.signal.aborted;t.controller.abort(),i||e.setAttr({listening:!1,listenerError:V(r).error},!0,!0,!1)})}requireCapability(e){if(!this.provider||!this.provider.capabilities.includes(e))throw Object.assign(new Error(`${e} is unavailable in this environment`),{code:"UNAVAILABLE"})}attributes(e,t){let r=e.writing;e.writing=!0;try{e._node.setAttr(t,!0,!0,!1)}finally{e.writing=r}}accept(e,t){let r=e.name==="appinfo"?["id","name","version","build"]:["latitude","longitude","accuracy","timestamp"],i=e.name==="appinfo"?"string":"number";for(let l of r)if(typeof t[l]!==i||i==="number"&&!Number.isFinite(t[l]))throw new TypeError(`Invalid ${e.name}.${l} from device provider`);let s=e.cachedValue;if(e.name==="location"&&s&&t.timestamp<s.getItem("timestamp")){this.attributes(e,{status:"success",error:null});return}let o=new x;for(let l of r)o.setItem(l,t[l]);e._lastUpdate=Date.now(),e.failed=!1,e.received++;let a=e.writing;e.writing=!0;try{e._node.setValue(o,!0,{status:"success",error:null},!0,!1)}finally{e.writing=a}}failure(e,t){e.failed=!0,this.attributes(e,V(t))}reconcile(){let e=this.resolvers.get("location");if(e._node.attr.enabled){if(this.monitor)return;let t={stop:null,controller:new AbortController};this.monitor=t,t.start=Promise.resolve(this.cleanup).then(()=>this.disposed||this.monitor!==t?null:(this.requireCapability("location"),this.provider.startLocationUpdates((r,i)=>{if(!(this.disposed||this.monitor!==t))if(i)this.failure(e,i);else try{this.accept(e,r)}catch(s){this.failure(e,s)}},t.controller.signal))),t.start.then(r=>{r===null||this.disposed||this.monitor!==t||(t.stop=r,this.attributes(e,{watching:!0}))}).catch(r=>{!this.disposed&&this.monitor===t&&(this.attributes(e,{watching:!1}),this.failure(e,r))}),this.attributes(e,{status:"pending",error:null})}else if(this.monitor){let t=this.monitor;this.monitor=null,t.controller.abort(),this.retiring=t,this.cleanup=t.start.then(r=>r===null?void 0:r(),()=>{}).then(()=>{if(this.retiring===t&&(this.retiring=null),!this.disposed){let r={watching:!1};!this.monitor&&!e.request&&e._node.attr.status==="pending"&&Object.assign(r,{status:"cancelled",error:null}),this.attributes(e,r)}}),this.cleanup.catch(r=>{this.disposed||this.failure(e,r)})}}async openDatabase(e){if(this.assertLive(),!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(e)||typeof e!="string")throw new TypeError("Invalid database name");if(this.#e)throw new Error("This page already owns a database connection");let t=this.gramlot.data.getNode("gramlot.device.database"),r=(s,o=null)=>{this.disposed||t.setAttr({status:s,error:o},!0,!0,!1)};if(!this.provider.capabilities.includes("database")){let s=Object.assign(new Error("Native database unavailable"),{code:"UNAVAILABLE"});throw r("unavailable",{code:s.code,message:s.message}),s}let i={controller:new AbortController,close:null,start:null};this.#e=i,r("pending"),i.start=this.provider.openDatabase(e,i.controller.signal);try{let s=await i.start,o=!1,a=null,l=()=>a||(o=!0,a=s.close().then(()=>{r("closed")},c=>{throw r("error",{code:"FAILED",message:c.message}),c}).finally(()=>{this.#e===i&&(this.#e=null)}),a);if(i.close=l,this.disposed||i.controller.signal.aborted)throw await l(),Object.assign(new Error("Page closed"),{code:"CANCELLED"});let u=async(c,d,f)=>{if(this.assertLive(),o)throw new Error("Database connection is closed");r("pending");try{let h=await s[c](d,f);return r("success"),h}catch(h){throw r("error",{code:"FAILED",message:h.message}),h}};return r("success"),{query:(c,d=[])=>u("query",c,d),execute:(c,d=[])=>u("execute",c,d),close:l}}catch(s){throw this.#e===i&&(this.#e=null),this.disposed||t.setAttr(V(s),!0,!0,!1),s}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.#e;e?.controller.abort(),e&&(this.cleanup=Promise.all([this.cleanup,e.start.then(()=>e.close?.(),()=>{})]).then(()=>{}));let t=[...this.#a.values()].map(c=>{let d=c.stream;return c.stream=null,d?.controller.abort(),d?d.start.then(f=>f(),()=>{}):c.cleanup});this.#t?.abort(),this.#t=null;let r=this.#n;this.#n=null,r?.controller.abort(),this.#s?.abort(),this.#s=null;let i=[...this.#o.values()];this.#o.clear();for(let c of i)c.controller.abort();let s=this.#h;this.#h=null,s?.controller.abort();let o=this.#p;this.#p=null,o?.controller.abort(),this.#w()?.controller.abort();let a=this.#f;this.#f=null,a?.controller.abort(),this.#i?.abort(),this.#i=null,this.#r?.abort(),this.#r=null,this.#l?.abort(),this.#l=null,this.#c?.abort(),this.#c=null;let l=this.#u;this.#u=null,l?.controller.abort(),this.gramlot.data.unsubscribe("gramlot.device",{any:!0});let u=this.monitor;if(this.monitor=null,u?.controller.abort(),u)this.cleanup=u.start.then(c=>c===null?void 0:c(),()=>{});else if(this.retiring?.stop){let c=this.retiring;this.cleanup=this.cleanup.catch(()=>c.stop())}l&&(this.cleanup=Promise.all([this.cleanup,l.start.then(c=>c(),()=>{})]).then(()=>{})),a&&(this.cleanup=Promise.all([this.cleanup,a.start.then(c=>c(),()=>{})]).then(()=>{})),s&&(this.cleanup=Promise.all([this.cleanup,s.start.then(c=>c(),()=>{})]).then(()=>{})),o&&(this.cleanup=Promise.all([this.cleanup,o.start.then(c=>c(),()=>{})]).then(()=>{})),this.cleanup=Promise.all([this.cleanup,...t,...i.map(c=>c.start.then(d=>d(),()=>{}))]).then(()=>{}),r&&(this.cleanup=Promise.all([this.cleanup,r.start.then(c=>c===null?void 0:c.dispose(),c=>{if(c?.code!=="CANCELLED")throw c})]).then(()=>{})),this.cleanup=this.cleanup.finally(()=>this.releaseProvider?.()),this.cleanup.catch(c=>{this.cleanupError=c});for(let c of this.resolvers.values())c.request=null}};var Kc=2e3;function ub(n){if(!(n instanceof Date))return String(n??"");let e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}var oi=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof x))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],r=(i,s)=>{for(let o of i.getNodes()){let a=s+o.label;o.value instanceof x?r(o.value,`${a}.`):t.push(`${a}: ${ub(o.value)}`)}};return r(this.branch(e),""),t.join(`
194
+ `)}mailtoUrl(e,t){let r=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(r.length>Kc)throw new Error(`gramlot.utl.inout.sendMail: the email of '${e}' is ${r.length} characters long, over the mailto: limit of ${Kc}; send it with sendHttp or save it as a file`);return r}sendMail(e,t){this.open(this.mailtoUrl(e,t))}async sendHttp(e,t){let r=JSON.stringify(this.branch(e).asDict(!1,!1,!0)),i=await this.document.defaultView.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:r});if(!i.ok)throw new Error(`gramlot.utl.inout.sendHttp: ${t} answered ${i.status}`);return i}save(e,t){this.saveText(this.branch(e).toTytx(),t,"application/json")}restore(e){let t=this.document.createElement("input");return t.type="file",t.accept=".json,application/json",new Promise((r,i)=>{let s=()=>i(new this.document.defaultView.DOMException("File selection cancelled","AbortError"));t.addEventListener("cancel",s,{once:!0}),t.addEventListener("change",async()=>{if(t.removeEventListener("cancel",s),!t.files.length){s();return}try{let o=j(await t.files[0].text());if(!(o instanceof x))throw new TypeError("the file must contain a typed Bag");this.gramlot.data.setItem(e,o),r(o)}catch(o){i(new Error(`gramlot.utl.inout.restore: the file is not a saved Gramlot branch: ${o.message}`,{cause:o}))}},{once:!0}),t.click()})}download(e,t,r){if(!["json","xml"].includes(r))throw new Error(`gramlot.utl.inout.download: format '${r}' is not 'json' or 'xml'`);let i=this.branch(e);if(r==="json")this.saveText(i.toJson(!1),t,"application/json");else{let s=e.split(".").at(-1);this.saveText(`<?xml version='1.0' encoding='UTF-8'?>
195
+ <${s}>${i.toXml()}</${s}>`,t,"application/xml")}}saveText(e,t,r){let i=this.document.defaultView,s=i.URL.createObjectURL(new i.Blob([e],{type:r}));this.open(s,t),i.setTimeout(()=>i.URL.revokeObjectURL(s),1e3)}open(e,t=null){let r=this.document.createElement("a");r.href=e,t!==null&&(r.download=t),r.click()}};var ai=class extends De{constructor(e,t){super(e),this.inout=new oi(e,t)}};var li=class{#e;constructor({pageId:e,rpcUrl:t="/gramlot/rpc",closeUrl:r="/gramlot/close",rootId:i="gramlot-root",capabilities:s=[],element:o=null,document:a=o?.ownerDocument??globalThis.document,transport:l=null,collections:u=[],locale:c=null,timeZone:d=null,devices:f=[],serverAdapter:h=new ft,nameSyntax:m=null}={}){ms.register(a.defaultView);for(let b of u)b instanceof It&&b.register(a.defaultView);this.commands=new tn,this.pageId=e;let p=c==null||d==null?a.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...f]),this.locale=c??p.locale,this.timeZone=d??p.timeZone,Object.defineProperty(this,"_subscriptions",{value:new Ls(this)}),this.capabilities=Object.freeze([...s]),this.serverAdapter=h,this.src=new ti(this,{collections:u,destination:o??a.getElementById(i),subscriptions:this._subscriptions,nameSyntax:m===null?Un:rr.fromJSON(m)}),this.#e=en.install({document:a,root:this.src.renderer.destination}),this.data=this.src.builder.data,this.dvc=new si(this),this.rpc=new ni(this,{rpcUrl:t,closeUrl:r,document:a,transport:l}),this.dom=new ii(this),this.utl=new ai(this,a),this.state="ready",this._subscriptions.attach(a),this.abort=new AbortController,this.rpc.transport&&(this.pagehide=b=>{b.persisted||this.dispose()},a.defaultView.addEventListener("pagehide",this.pagehide),this.window=a.defaultView)}publish(e,t={}){return this._subscriptions.publish(e,t)}subscribe(e,t){return this._subscriptions.subscribe(e,t)}unsubscribe(e){this._subscriptions.unsubscribe(e)}format(e,t){return wc(e,t,{locale:this.locale,timeZone:this.timeZone})}start(){return this.state==="disposed"?Promise.reject(new Error("Gramlot is disposed")):this.rpc.transport?this.loading?this.loading:this.state==="started"?Promise.resolve(this):(this.state="loading",this.loading=this.loadMain().finally(()=>{this.loading=null}),this.loading):Promise.reject(new Error("This Gramlot instance has no server transport"))}async loadMain(){let e;try{e=await this.rpc.callEnvelope("source","main")}catch(t){throw this.state==="disposed"?new Error("Gramlot was disposed during main",{cause:t}):(this.state="failed",t)}if(this.state==="disposed")throw new Error("Gramlot was disposed during main");try{return this.src.mountMainSource(e.value,e.data)}catch(t){throw this.state!=="disposed"&&(this.state="failed"),t}}dispose(){if(this.state!=="disposed"){this.state="disposed",this.dvc.dispose(),this.#e.dispose(),this._subscriptions.dispose(),this.pagehide&&this.window.removeEventListener("pagehide",this.pagehide),this.abort.abort();try{try{this.src.binding.dispose()}finally{this.src.renderer.dispose()}}finally{if(this.rpc.transport)try{this.rpc.transport.close(this.pageId)}finally{this.rpc.transport.dispose()}}}}};var wa=class{constructor({config:e,resources:t,document:r=globalThis.document}){this.config=e,this.resources=t,this.document=r,this.serverAdapter=new ft}async run(){let{config:e,resources:t,document:r}=this,i=r.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));let s=!1,o,a,l=[],u=new Promise(d=>{o=d}),c=d=>{if(!(d.persisted||s)){s=!0;try{this.closePage()}finally{o(null)}}};i.addEventListener("pagehide",c);try{let d=t.css.map(_=>new Promise((w,E)=>{let D=r.createElement("link");D.rel="stylesheet",D.href=_;let y=()=>{D.removeEventListener("load",T),D.removeEventListener("error",S)};l.push(y);let T=()=>{y(),w()},S=()=>{y(),E(new Error(`${_}: stylesheet load failed`))};D.addEventListener("load",T),D.addEventListener("error",S),r.head.append(D)})),f=t.js.map(async({url:_,group:w})=>{try{return{logicClass:(await import(new URL(_,r.baseURI).href)).Logic,group:w,resource:_}}catch(E){throw new Error(`${_}: import failed: ${E.message}`,{cause:E})}}),h=new Set,m=(t.collections??[]).map(async _=>{if(!_||typeof _!="object"||Object.keys(_).sort().join(",")!=="buildId,name,url"||typeof _.name!="string"||typeof _.url!="string"||typeof _.buildId!="string"||!/^sha256:[0-9a-f]{64}$/.test(_.buildId)||h.has(_.name))throw new TypeError("Invalid or duplicate collection bootstrap record");h.add(_.name);let{name:w,url:E,buildId:D}=_,y;try{y=await import(new URL(E,r.baseURI).href)}catch(T){throw new Error(`${w}: collection import failed: ${T.message}`,{cause:T})}if(y.default?.name!==w||y.buildId!==D)throw new Error(`${w}: collection identity mismatch; expected ${D}, received ${y.buildId}`);return y.default}),p=await Promise.race([Promise.all([Promise.all(d),Promise.all(f),Promise.all(m)]),u]);if(s)return null;let[,b,g]=p;Jr.check(b);for(let _ of g)_.register(i);a=new li({...e,document:r,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...g.map(_=>_.toDocument())]}),i.removeEventListener("pagehide",c);for(let _ of g)_.registerCommands(a);for(let{logicClass:_,group:w,resource:E}of b)a.src.logicRegistry.register(_,{group:w,resource:E});return i.gramlot=a,await a.start(),a}catch(d){throw a?a.dispose():s||this.closePage(),d}finally{for(let d of l)d();i.removeEventListener("pagehide",c)}}async loadServerAdapter(e){let t;try{t=await import(new URL(e,this.document.baseURI).href)}catch(r){throw new Error(`${e}: server adapter import failed: ${r.message}`,{cause:r})}return new t.default}closePage(){let e=this.serverAdapter.createTransport({...this.config,document:this.document});try{e.close(this.config.pageId)}finally{e.dispose()}}};var js=Symbol("gramlot.source"),ya=Symbol("gramlot.endpoint"),cb=new Map([[js,"registerSource"],[ya,"registerEndpoint"]]);function Qc(n,e,t,r){let i=cb.get(t);if(e==="main")throw new TypeError(`${i} cannot declare main`);let s=Object.getOwnPropertyDescriptor(n.prototype,e)?.value;if(typeof s!="function")throw new TypeError(`${i} requires an own method of ${n.name}: ${String(e)}`);if(s[t])throw new TypeError(`${t===js?"Source method":"Endpoint"} already registered: ${e}`);if(s[js]||s[ya])throw new TypeError(`${e} is declared both as Source method and endpoint`);s[t]={auth:r}}var Fs=class{static registerSource(e,{auth:t=null}={}){Qc(this,e,js,t)}static registerEndpoint(e,{auth:t=null}={}){Qc(this,e,ya,t)}},ui=class extends Fs{static gramlots=[];static title="Gramlot";static devices=[];static locale=null;static timeZone=null;static installable=!1;static appIcon=null;manifest({baseUrl:e="./"}={}){let{title:t,appIcon:r}=this.constructor;if(typeof r!="string"||!r)throw new TypeError("An installable Page needs appIcon");return{id:e,name:t,short_name:t,start_url:e,scope:e,display:"standalone",icons:[{src:e+r.replace(/^\/+/,""),sizes:"512x512",type:"image/png"}]}}static css=[];static css_theme=null;static css_requires="";static js_requires="";static sourceBuilder=Oe;main(e){throw new Error("Page.main(root) must be implemented")}};var Kr=class extends ui{static shellId="frame";static datapath=null;main(e){let t=e.div({id:this.constructor.shellId,datapath:this.constructor.datapath,class:"frame-page",height:"100vh",display:"flex",flex_direction:"column",min_height:0}),r=t.borderContainer({node_label:"frame",height:"100%",flex:"1",min_height:0});for(let i of["top","bottom","left","right","center"])if(this[i]!==void 0){let s=r.contentPane({region:i,node_label:i});this[i](s)}this.behavior(t)}center(e){}behavior(e){}};var ci=class extends Kr{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:r}=this.constructor;if(!(t instanceof x))throw new TypeError("IndexPage.navigation must be a Bag");e.dataSetter({destination_path:`${r}.navigation`,value:t}),e.dataSetter({destination_path:`${r}.navigationSelection`,value:null}),e.dataSetter({destination_path:`${r}.active`,value:null}),e.dataSetter({destination_path:`${r}.opened`,value:new x}),super.main(e)}left(e){e.setAttr({width:"240px",splitter:!0,drawer:!0,drawer_label:"Navigation"}),e.tree({node_label:"tree",storepath:".navigation",labelAttribute:"title",hideValues:!0,selectedPath:"^.navigationSelection"})}center(e){e.tabContainer({node_label:"tabs",height:"100%",selectedPage:"^.active"})}behavior(e){e.dataController({func:"indexMount",_onStart:!0})}index_panel(e,{selection:t}){this.panel(e,t.getNode("#0"))}panel(e,t){e.iframe({src:t.attr.url,title:t.attr.title??t.label,width:"100%",height:"100%",border:0})}};ci.registerSource("index_panel");function va(n,e,t=()=>{},r=()=>{},{state:i=e.getRelativeData("."),createEntry:s=null,onLoad:o=()=>{}}={}){let a=i.getItem("navigation");if(!(a instanceof x))throw new TypeError("IndexPage navigation must be a Bag");let l=e.value.getNode("frame.center.tabs"),u=e.builder,c=new Map,d={entries:c,disposed:!1,selecting:!1,sequence:0,requested:null};Object.defineProperty(e,"indexContext",{value:d,configurable:!0});let f=i.getItem("opened");for(let y of f.getNodes()){let{url:T,path:S,title:I}=y.attr,W=l.value.getNode(y.label),ee={url:T,path:S,title:I,pane:W,node:a.getNode(S),loading:!1};r(ee),c.set(T,ee),d.sequence++}let h=(y,T,S)=>{try{o(y.url,T,S)}catch(I){n.binding.reportError(I,"Page load callback failed")}},m=(y,T,S)=>{y.loading&&(y.loading=!1,h(y,T,S))},p=y=>{if(!d.disposed){d.selecting=!0;try{i.setItem("active",y.url),i.setItem("navigationSelection",y.path),t(c,y.url)}finally{d.selecting=!1}}};function b(y){g(y).catch(T=>{d.disposed||n.binding.reportError(T,"Page could not be opened")})}async function g(y){let T=a.getNode(y);if(!T)throw new Error(`Unknown index navigation path: ${y}`);let S=T.attr.url;if(S==null)return;if(typeof S!="string"||!S)throw new TypeError("IndexPage URL must be nonempty text");d.requested=S;let I=c.get(S);if(I){I.path=y,p(I);return}for(;l.value!==null&&l.value.getNode(`page${d.sequence}`);)d.sequence++;let W=J(u.wrapSource(l).contentPane({node_label:`page${d.sequence++}`,title:T.attr.title??T.label,pageName:S,height:"100%",closable:!0})),ee=i.getItem("active");I={url:S,path:y,node:T,pane:W,title:T.attr.title??T.label,loading:!0},c.set(S,I);try{if(h(I,"loading"),d.disposed||c.get(S)!==I||(p(I),d.disposed||c.get(S)!==I))return;if(s)await s(I);else{let se=new x;if(se.setItem(T.label,null,{...T.attr}),!await n.binding.gramlot.src.remoteSource(W,"index_panel",{selection:se}))throw new Error("Panel loading was cancelled")}if(d.disposed||c.get(S)!==I)return;f.setItem(W.label,null,{url:S,path:I.path,title:I.title}),r(I)}catch(se){if(d.disposed||c.get(S)!==I)return;try{if(n.binding.reportError(se,"Page could not be opened"),c.delete(S),f.getNode(W.label)&&f.popNode(W.label),W.parentBag&&W.parentBag.popNode(W.label),!d.disposed&&d.requested===S){let he=c.get(ee);if(d.requested=he?.url??null,he)p(he);else{d.selecting=!0;try{i.setItem("active",null),i.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}}finally{m(I,"error",se)}return}d.disposed||c.get(S)!==I||(m(I,"ready"),!d.disposed&&c.get(S)===I&&d.requested===S&&p(I))}let _=`${e.getAttr("id")}-page-close`;e.value.subscribe(_,{any:y=>{if(y.evt!=="del")return;let T=[...c.values()].find(W=>W.pane===y.node);if(!T)return;let{url:S,pane:I}=T;if(!(d.disposed||n.disposed||c.get(S)!==T)){c.delete(S),f.getNode(I.label)&&f.popNode(I.label);try{if(i.getItem("active")===S){let W=[...c.values()].at(-1);if(d.requested=W?.url??null,W)p(W);else{d.selecting=!0;try{i.setItem("active",null),i.setItem("navigationSelection",null),t(c,null)}finally{d.selecting=!1}}}else t(c,i.getItem("active"))}finally{m(T,"cancelled")}}}});let w=`${e.getAttr("id")}-selection`;i.subscribe(w,{any:y=>{if(!(d.selecting||d.disposed)){if(y.node===i.getNode("navigationSelection")){let T=i.getItem("navigationSelection");T!==null&&b(T)}else if(y.node===i.getNode("active")){let T=c.get(i.getItem("active"));T&&(d.requested=T.url,p(T))}}}});let E=()=>{if(!d.disposed){d.disposed=!0,i.unsubscribe(w,{any:!0}),e.value.unsubscribe(_,{any:!0});for(let y of c.values())y.loading&&(y.pane.parentBag&&y.pane.parentBag.popNode(y.pane.label),m(y,"cancelled"));c.clear(),e.indexContext===d&&delete e.indexContext}};d.dispose=E,n.onDispose(e,E);let D=c.get(i.getItem("active"));return D?p(D):i.getItem("navigationSelection")!==null&&b(i.getItem("navigationSelection")),d}var qs=class{indexMount(e){va(this.page.src.renderer,e.parentNode)}};function Us(n,{datapath:e,value:t,language:r="text",height:i="420px",...s}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let o=n.borderContainer({datapath:e,height:i,class:"gramlot-editor-options"}),a={language:r,indentUnit:4,fontSize:14,fontFamily:"monospace",lineNumbers:!0,lineWrapping:!0,folding:!0,bracketMatching:!0,autoCloseBrackets:!0,autoIndent:!0,autocompletion:!0,highlightActiveLine:!0,highlightSelectionMatches:!0};for(let[d,f]of Object.entries(a))o.dataSetter({destination_path:`.settings.${d}`,value:f});let l=o.contentPane({region:"right",width:"250px",drawer:"close",drawer_label:"Options",drawer_icon:"\u2699",drawer_minimize:!1,padding:"12px",overflow:"auto",class:"gramlot-editor-settings"});l.h3("Editor options"),l.filteringSelect({value:"^.settings.language",lbl:"Language",values:"text:Plain text,python:Python,javascript:JavaScript,typescript:TypeScript,json:JSON,html:HTML,css:CSS,xml:XML,markdown:Markdown,sql:SQL,typst:Typst"}),l.numberTextBox({value:"^.settings.indentUnit",lbl:"Indent spaces",min:1,max:16,dtype:"L",validate_notnull:!0}),l.numberTextBox({value:"^.settings.fontSize",lbl:"Font size",min:8,max:48,dtype:"L",validate_notnull:!0}),l.textbox({value:"^.settings.fontFamily",lbl:"Font family"});let u={lineNumbers:"Line numbers",lineWrapping:"Wrap lines",folding:"Code folding",bracketMatching:"Match brackets",autoCloseBrackets:"Close brackets and quotes",autoIndent:"Automatic indentation",autocompletion:"Local completion",highlightActiveLine:"Highlight current line",highlightSelectionMatches:"Highlight matching selections"};for(let[d,f]of Object.entries(u))l.checkbox({value:`^.settings.${d}`,label:f,display:"block",margin_top:"8px"});return o.contentPane({region:"center",min_height:0}).codeMirror({...s,value:t,height:"100%",...Object.fromEntries(Object.keys(a).map(d=>[d,`^.settings.${d}`]))}),o}var di=class n extends We{static internalParams=new Set([...We.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:r="",onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method="directory_tree",this.params={root:t,path:r},this.children=new Set}get closed(){return this.#e}startLoad(e){if(this.loading)return this.loading;let t=new AbortController;return this.#t=t,e({controller:t,method:this.method,params:this.params,ignored:!1})}async loadAsync({controller:e,method:t,params:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof x))throw new TypeError("directory_tree must return a Bag");for(let t of this.children)t.abort();this.children.clear();for(let t of e.getNodes())if(t.attr.is_directory){let r=new n({gramlot:this.gramlot,root:this.params.root,path:t.attr.path,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}},fi=class{constructor(e,t){this.gramlot=e,this.source=t,this.request=null,this.resolver=null,this.disposed=!1}get state(){return this.source.getRelativeData(".")}async open(e){this.request?.abort();let t=this.request=new AbortController;this.state.setItem("status","Opening directory\u2026");try{let r=await this.gramlot.rpc.call("data","workspace_open",{root:e},{signal:t.signal});if(this.disposed||t.signal.aborted)return null;let i=new di({gramlot:this.gramlot,root:r.root,onError:o=>this.state.setItem("status",o.message)}),s=i.prepareValue(r.entries);return this.resolver?.abort(),this.resolver=i,this.state.setItem("selectedPath",null),this.state.setItem("store",s),this.state.setItem("writable",r.writable),this.state.setItem("root",r.root),this.state.setItem("status",""),r.root}catch(r){return!this.disposed&&!t.signal.aborted&&this.state.setItem("status",r.message),null}finally{this.request===t&&(this.request=null)}}dispose(){this.disposed=!0,this.request?.abort(),this.resolver?.abort()}},lr=class{fileSystemMount(e){let t=e.parentNode,r=new fi(this.page,t);Object.defineProperty(t,"fileSystemController",{value:r,configurable:!0}),this.page.src.renderer.onDispose(t,()=>r.dispose())}fileSystemOpen(e,{root:t}){if(t)return e.parentNode.fileSystemController.open(t)}};function ed(n,{datapath:e,...t}){let r=n.div({datapath:e,class:"gramlot-filesystem",...t});return r.dataSetter({destination_path:".store",value:new x}),r.dataSetter({destination_path:".root",value:null}),r.dataSetter({destination_path:".requestedRoot",value:null}),r.dataSetter({destination_path:".selectedPath",value:null}),r.dataSetter({destination_path:".status",value:""}),r.dataController({func:"fileSystemMount",_onBuilt:!0}),r.dataController({func:"fileSystemOpen",root:"^.requestedRoot"}),r.tree({storepath:".store",selectedPath:"^.selectedPath",labelAttribute:"caption",hideValues:!0,class:"gramlot-filesystem-tree"}),r.div("^.status",{role:"status",class:"gramlot-filesystem-status"}),r}var db=(n,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([n,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Vs=class{constructor(e,t){this.gramlot=e,this.source=t,this.pending=new Map,this.disposed=!1}get state(){return this.source.getRelativeData(".")}get documents(){return this.state.getItem("documents")}async open(e,t){let r=db(e,t),i=this.documents.getNodes().find(a=>!a.value.getItem("isNew")&&a.value.getItem("root")===e&&a.value.getItem("path")===t);if(i)return i.label;if(this.pending.has(r))return this.pending.get(r).promise;let s=new AbortController,o=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:s.signal}).then(a=>{if(this.disposed||s.signal.aborted)return null;let l=new x;for(let[u,c]of Object.entries({...a,root:e,saved:a.content,busy:!1}))l.setItem(u,c);return this.documents.setItem(r,l),r}).finally(()=>this.pending.delete(r));return this.pending.set(r,{request:s,promise:o}),o}newDocument(e,t,r=""){let i=`new_${Q()}`,s=new x;for(let[o,a]of Object.entries({language:e,root:r,path:`Untitled${t}`,content:"",saved:"",writable:!0,busy:!1,isNew:!0,createHidden:!0,saveRoot:r,savePath:`Untitled${t}`}))s.setItem(o,a);return this.documents.setItem(i,s),i}async create(e){let t=this.documents.getItem(e);if(!t||!t.getItem("isNew")||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("saveRoot"),i=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==i.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let s=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let a=this.gramlot.rpc.call("data","document_create",{root:r,path:i,content:s},{signal:o.signal}).then(l=>this.disposed||o.signal.aborted?!1:(t.setItem("root",l.root),t.setItem("path",l.path),t.setItem("revision",l.revision),t.setItem("saved",s),t.setItem("isNew",!1),t.setItem("createHidden",!0),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:o,promise:a}),a}invalidateRecipe(e){let t=this.documents.getItem(e);t.getItem("path").endsWith(".typ.py")&&(t.getItem("rendering")&&this.pending.get(e)?.request.abort(),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generate preview to render the current Python recipe."))}async renderRecipe(e){let t=this.documents.getItem(e);if(!t||!t.getItem("path").endsWith(".typ.py")||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("content"),i=new AbortController;t.setItem("busy",!0),t.setItem("rendering",!0),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generating Typst on the server\u2026");let s=this.gramlot.rpc.call("data","document_render_typst",{content:r},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted||t.getItem("content")!==r?!1:(t.setItem("typstSource",o.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(o=>(!this.disposed&&!i.signal.aborted&&t.setItem("renderStatus",o.message),!1)).finally(()=>{this.pending.delete(e),this.disposed||(t.setItem("rendering",!1),t.setItem("busy",!1))});return this.pending.set(e,{request:i,promise:s}),s}dirty(e){let t=this.documents.getItem(e);return t&&t.getItem("content")!==t.getItem("saved")}async save(e){let t=this.documents.getItem(e);if(!t||t.getItem("isNew")||!this.dirty(e)||!t.getItem("writable")||this.pending.has(e))return!1;let r=t.getItem("content"),i=new AbortController;t.setItem("busy",!0);let s=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:r,revision:t.getItem("revision")},{signal:i.signal}).then(o=>this.disposed||i.signal.aborted?!1:(t.setItem("revision",o.revision),t.setItem("saved",r),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:i,promise:s}),s}revert(e){let t=this.documents.getItem(e);return!t||!this.dirty(e)||this.pending.has(e)?!1:(t.setItem("content",t.getItem("saved")),!0)}canClose(e,t=!1){return!this.pending.has(e)&&(t||!this.dirty(e))}close(e,t=!1){return this.canClose(e,t)?(this.documents.popNode(e),this.state.getItem("active")===e&&this.state.setItem("active",this.documents.getNodes()[0]?.label??null),!0):!1}dispose(){this.disposed=!0;for(let{request:e}of this.pending.values())e.abort()}},zs=class{constructor(e){this.storage=e,this.key="gramlot.ide.recentWorkspaces"}read(){let e=this.storage.getItem(this.key),t=e===null?[]:JSON.parse(e);if(!Array.isArray(t)||t.some(r=>typeof r!="string"||!r))throw new TypeError("Invalid recent workspace preference");return t.slice(0,6)}remember(e){let t=[e,...this.read().filter(r=>r!==e)].slice(0,6);return this.storage.setItem(this.key,JSON.stringify(t)),t}choices(e=this.read()){let t=new x;return e.forEach((r,i)=>t.setItem(`r${i}`,r,{caption:r})),t}};function Re(n){for(let e=n;e;e=e.parentNode){let t=e.ideContext;if(t)return t}throw new Error("IDE operation requires a node inside a mounted IDE")}var Hs=class{fileSystemMount(e){return lr.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return lr.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){let t=e.parentNode,r={scope:t,documents:new Vs(this.page,t),requested:0,editorPrefix:`ide_${Q()}`,recent:new zs(this.page.src.renderer.destination.ownerDocument.defaultView.sessionStorage)};Object.defineProperty(t,"ideContext",{value:r,configurable:!0});let{documents:i,recent:s}=r,o=t.getRelativeData("."),a=s.read();o.setItem("recent",s.choices(a)),o.setItem("workspace",a[0]??"");let l=o.getItem("browser");l.subscribe("ide-browser",{any:c=>{if(c.node===l.getNode("root")){let d=l.getItem("root");o.setItem("workspace",d),o.setItem("recent",s.choices(s.remember(d))),o.setItem("status",`Workspace: ${d}`)}else if(c.node===l.getNode("selectedPath")){let d=l.getItem("selectedPath"),f=d===null?null:l.getItem("store").getNode(d);f&&!f.attr.is_directory&&this.ideOpenDocument(t,l.getItem("root"),f.attr.path)}}});let u=i.documents;u.subscribe("ide-documents",{any:c=>{if(["content","saved","busy","writable","view","isNew","path","root"].includes(c.node.label))for(let d of t.value.getNode("frame.center.tabs").value?.getNodes()??[]){let f=d.getAttr("documentKey"),h=i.documents.getItem(f);h&&(c.node===h.getNode("content")&&i.invalidateRecipe(f),this.ideDocumentState(t,f),d.setAttr({title:`${i.dirty(f)?"\u25CF ":""}${h.getItem("path")}`}))}}}),this.page.src.renderer.onDispose(r.scope,()=>{l.unsubscribe("ide-browser",{any:!0}),u.unsubscribe("ide-documents",{any:!0}),i.dispose()})}ideOpenWorkspace(e){let r=Re(e).scope.getRelativeData("."),i=r.getItem("workspace");i&&i!==r.getItem("browser.root")&&r.setItem("browser.requestedRoot",i)}ideDocumentState(e,t){let r=Re(e),{documents:i}=r,s=i.documents.getItem(t),o=!i.dirty(t)&&!s.getItem("isNew")||s.getItem("busy");s.setItem("saveDisabled",!!(o||!s.getItem("writable"))),s.setItem("revertDisabled",!!(!i.dirty(t)||s.getItem("busy"))),s.setItem("displayPath",s.getItem("isNew")?s.getItem("path"):`${s.getItem("root")}/${s.getItem("path")}`),s.setItem("pdfFilename",s.getItem("path").split("/").at(-1).replace(/\.typ(?:\.py)?$/i,".pdf")),s.setItem("renderDisabled",!!(s.getItem("busy")||!s.getItem("writable"))),this.ideHistoryState(s)}async ideOpenDocument(e,t,r){let i=Re(e),{documents:s}=i,o=i.scope.getRelativeData("."),a=++i.requested;try{let l=await s.open(t,r);if(l===null||s.disposed)return;this.ideShowDocument(e,l),a===i.requested&&(o.setItem("active",l),o.setItem("status",`${r}${s.documents.getItem(l).getItem("writable")?"":" (draft only \u2014 Remote Edit is disabled)"}`))}catch(l){s.disposed||o.setItem("status",l.message)}}ideNew(e){let t=Re(e),{documents:r}=t,i=t.scope.getRelativeData("."),s=i.getItem("newType"),o=s==="typstRecipe"?"python":s,a={typstRecipe:".typ.py",typst:".typ",markdown:".md",html:".html",python:".py",javascript:".js",typescript:".ts",json:".json",css:".css",sql:".sql",xml:".xml",text:".txt"},l=r.newDocument(o,a[s],i.getItem("workspace"));r.documents.getItem(l).setItem("writable",i.getItem("browser.writable")===!0),++t.requested,this.ideShowDocument(e,l),i.setItem("active",l),i.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e,t){let r=Re(e),{documents:i}=r,o=i.documents.getItem(t).getItem("path"),a=r.scope.value.getNode("frame.center.tabs");if(!a.value?.getNode(t)){let l=i.documents.getItem(t),u=o.endsWith(".typ.py");u&&i.invalidateRecipe(t),l.setItem("readonly",!1),this.ideDocumentState(e,t),l.setItem("view","code"),l.setItem("createHidden",!0),l.setItem("undoDisabled",!0),l.setItem("redoDisabled",!0);let c=J(a.builder.wrapSource(a).contentPane({node_label:t,title:o,pageName:t,documentKey:t,closable:!0,onClose:"ideClose",height:"100%"})),d=c.builder.wrapSource(c).div({display:"flex",flex_direction:"column",height:"100%"}),f=d.div({datapath:`.documents.${t}`,display:"flex",align_items:"center",gap:"6px",padding:"4px 12px",height:"40px",flex_shrink:0,box_sizing:"border-box",class:"gramlot-ide-document-toolbar",role:"toolbar","aria-label":`Commands for ${o}`});for(let[y,T,S,I]of[["save","M5 3h12l4 4v14H3V3h2 M7 3v6h10V3 M7 21v-8h10v8","Save","ideSave"],["revert","M3 10a9 9 0 1 1 2 8 M3 4v6h6 M12 7v5l3 2","Revert to saved","ideRevert"],["undo","M9 5 3 11l6 6 M3 11h12a6 6 0 0 1 6 6v2","Undo","ideUndo"],["redo","m15 5 6 6-6 6 M21 11H9a6 6 0 0 0-6 6v2","Redo","ideRedo"]]){let W=f.button({title:S,"aria-label":S,disabled:`^.${y}Disabled`,class:`button--quiet gramlot-ide-${y}`});W.svg({viewBox:"0 0 24 24",width:18,height:18,fill:"none",stroke:"currentColor",stroke_width:1.7,stroke_linecap:"round",stroke_linejoin:"round","aria-hidden":"true"}).path({d:T}),W.dataController({func:I,documentKey:t})}u&&f.button("Generate preview",{disabled:"^.renderDisabled",class:"button--quiet"}).dataController({func:"ideRenderRecipe",documentKey:t}),f.div("^.displayPath",{class:"gramlot-ide-document-path",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap",min_width:0,flex:"1"});let h=d.div({datapath:`.documents.${t}`,hidden:"^.createHidden",padding:"8px 12px",display:"flex",gap:"8px",align_items:"end",flex_shrink:0});h.textbox({value:"^.saveRoot",lbl:"Directory",flex:"1",disabled:"^.busy"}),h.textbox({value:"^.savePath",lbl:"File name",flex:"1",disabled:"^.busy"}),h.button("Create file",{disabled:"^.busy"}).dataController({func:"ideCreate",documentKey:t}),h.button("Cancel",{disabled:"^.busy",class:"button--quiet"}).dataController({func:"ideCancelCreate",documentKey:t});let m=d.div({flex:"1",min_height:0}),p=l.getItem("language")==="html",b=l.getItem("language")==="markdown",g=p||b,_=l.getItem("language")==="typst",w=g||_||u,E=w?m.tabContainer({height:"100%",selectedPage:`^.documents.${t}.view`}):null,D=w?E.contentPane({title:"Code",pageName:"code",height:"100%"}):m;if(Us(D,{datapath:`.documents.${t}`,value:"^.content",language:l.getItem("language"),height:"100%",readonly:"^.readonly",nodeId:`${r.editorPrefix}_editor_${t}`,editorView:"code",selfsubscribe_historyChanged:"ideHistoryChanged"}),d.dataController({func:"ideSave",documentKey:t,[`subscribe_${r.editorPrefix}_editor_${t}_save`]:!0}),_&&E.contentPane({title:"Preview",pageName:"preview",height:"100%"}).typstPreview({value:`^.documents.${t}.content`,filename:`^.documents.${t}.pdfFilename`,height:"100%"}),u){let y=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});y.div(`^.documents.${t}.renderStatus`,{role:"status",padding:"8px 12px",white_space:"pre-wrap",overflow:"auto",max_height:"30%"}),y.typstPreview({value:`^.documents.${t}.typstSource`,filename:`^.documents.${t}.pdfFilename`,hidden:`^.documents.${t}.previewHidden`,flex:"1",min_height:0}),E.contentPane({title:"Generated Typst",pageName:"generated",height:"100%"}).codeMirror({value:`^.documents.${t}.typstSource`,language:"typst",readonly:!0,height:"100%"})}if(g){let y=E.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});b&&(l.setItem("allowHtml",!1),y.checkbox({value:`^.documents.${t}.allowHtml`,label:"Allow embedded HTML",class:"gramlot-ide-allow-html",padding:"8px 12px",flex_shrink:0})),y[p?"htmlPreview":"markdownPreview"]({value:`^.documents.${t}.content`,flex:"1",min_height:0,...b?{allowHtml:`^.documents.${t}.allowHtml`}:{}}),E.contentPane({title:"Rich text",pageName:"rich",height:"100%"})[p?"htmlEditor":"markdownEditor"]({datapath:`.documents.${t}`,value:"^.content",readonly:"^.readonly",height:"100%",nodeId:`${r.editorPrefix}_rich_editor_${t}`,editorView:"rich",selfsubscribe_historyChanged:"ideHistoryChanged"}),d.dataController({func:"ideSave",documentKey:t,[`subscribe_${r.editorPrefix}_rich_editor_${t}_save`]:!0})}}}async ideRenderRecipe(e,{documentKey:t}){let r=Re(e),{documents:i}=r;i.documents.getItem(t).setItem("view","preview"),await i.renderRecipe(t)}ideCancelCreate(e,{documentKey:t}){let r=Re(e),{documents:i}=r;i.documents.getItem(t).setItem("createHidden",!0)}async ideCreate(e,{documentKey:t}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData(".");s.setItem("status","Creating file\u2026");try{let o=await i.create(t);if(!i.disposed&&o){s.setItem("status","File created.");let a=s.getItem("browser");a.getItem("root")&&await r.scope.value.getNode("frame.left.browser").fileSystemController.open(a.getItem("root"))}}catch(o){i.disposed||s.setItem("status",o.message)}}async ideSave(e,{documentKey:t=null}={}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData("."),o=t??s.getItem("active");if(!o||i.documents.getItem(o).getItem("saveDisabled"))return;let a=i.documents.getItem(o);if(a.getItem("isNew")){a.setItem("createHidden",!1);return}s.setItem("status","Saving\u2026");try{let l=await i.save(o);i.disposed||s.setItem("status",l?"Saved.":"Document is read only or a request is pending.")}catch(l){i.disposed||s.setItem("status",l.message)}}ideRevert(e,{documentKey:t}){let r=Re(e),{documents:i}=r,s=r.scope.getRelativeData(".");i.revert(t)&&s.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:r}){let i=e.getRelativeData("."),s=e.getAttr("editorView");i.setItem(`${s}CanUndo`,t),i.setItem(`${s}CanRedo`,r),this.ideHistoryState(i)}ideHistoryState(e){let t=e.getItem("view");e.setItem("undoDisabled",!e.getItem(`${t}CanUndo`)),e.setItem("redoDisabled",!e.getItem(`${t}CanRedo`))}ideEditor(e,t){let r=Re(e),{documents:i}=r,s=i.documents.getItem(t).getItem("view")==="rich",o=this.page.src.binding.nodeIds.get(`${r.editorPrefix}_${s?"rich_":""}editor_${t}`);return this.page.src.renderer.records.get(o).element}ideUndo(e,{documentKey:t}){this.ideEditor(e,t).undo()}ideRedo(e,{documentKey:t}){this.ideEditor(e,t).redo()}ideClose(e){let t=Re(e),{documents:r}=t,i=t.scope.getRelativeData("."),s=e.getAttr("documentKey");return r.canClose(s)?!0:(i.setItem("status","Save or revert your changes before closing. Pending operations must finish first."),!1)}ideClosed(e,{pageName:t}){this.ideForgetDocument(e,t)}ideForgetDocument(e,t,r=!1){let i=Re(e),{documents:s}=i,o=i.scope.getRelativeData("."),a=s.documents.getItem(t),l=o.getItem("browser"),u=l.getItem("selectedPath"),c=u===null?null:l.getItem("store").getNode(u);a&&l.getItem("root")===a.getItem("root")&&c?.attr.path===a.getItem("path")&&l.setItem("selectedPath",null),s.close(t,r)}};var Ea=class n extends We{static internalParams=new Set([...We.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:r,onError:i}){super({cacheTime:-1,onError:i}),this.gramlot=e,this.method=t,this.params={directory:r},this.children=new Set}get closed(){return this.#e}startLoad(e){if(this.loading)return this.loading;let t=new AbortController;return this.#t=t,e({controller:t,method:this.method,params:this.params,ignored:!1})}async loadAsync({controller:e,method:t,params:r}){let{signal:i}=e,s,o=new Promise((a,l)=>{s=()=>l(i.reason),i.addEventListener("abort",s,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,r,{signal:i}),o]);if(i.aborted)throw i.reason;return a}finally{i.removeEventListener("abort",s),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof x))throw new TypeError("Directory navigation must return a Bag");for(let t of this.children)t.abort();this.children.clear();for(let t of e.getNodes())if(t.attr.directory!==void 0){let r=new n({gramlot:this.gramlot,method:this.method,directory:t.attr.directory,onError:this.onError});this.children.add(r),e.setResolver(t.label,r)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}};function ur(n,e){return e===2?n%4===0&&(n%100!==0||n%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function $e(n,e,t){if(![n,e,t].every(Number.isInteger)||n<1||n>9999||e<1||e>12||t<1||t>ur(n,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(n).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function cr(n){if(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(n))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=n.split("-").map(Number);return $e(...e),e}function hi(n,e,t){let r=n-1,i=365*r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400)+t-1;for(let s=1;s<e;s++)i+=ur(n,s);return i}function pi(n,e){let t=hi(...cr(n))+e;if(!Number.isSafeInteger(t)||t<0||t>hi(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let r=1,i=1e4;for(;i-r>1;){let o=Math.floor((r+i)/2);hi(o,1,1)<=t?r=o:i=o}t-=hi(r,1,1);let s=1;for(;t>=ur(r,s);)t-=ur(r,s++);return $e(r,s,t+1)}function xa(n){return pi(n,-(hi(...cr(n))%7))}function td(n,e,t=0,r=1){let i=n*12+e-1+t,s=Math.floor(i/12),o=(i%12+12)%12+1,a=i+r-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:$e(s,o,1),end:$e(l,u,ur(l,u))}}var Ws={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 rd(n){if(typeof n!="string")throw new RangeError("A supported locale is required.");let e=n.replaceAll("-","_"),t=e.indexOf("_"),r=(t<0?e:e.slice(0,t)).toLowerCase(),i=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(Ws,r))throw new RangeError(`Unsupported locale: ${n}`);let s=Ws[r];return{dictionary:s,phrases:a=>[...new Set([...s.keywords[a],...Ws.en.keywords[a]])],order:s.date_order[i]??s.date_order.default}}var dr=/^(?:\d{4}|\d{2})$/,nd=/^\d{1,2}$/,mi=(n,e)=>({ok:!1,error:{code:n,message:e}}),hr=(n="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:n})},od=(n,e)=>Object.hasOwn(n,e);function fr(n,e){if(n.length===4)return Number(n);let t=e.year+e.twoDigitYearAhead-100;return t+((Number(n)-t)%100+100)%100}function fb(n,e){if(n.includes(";")){let i=n.split(";").map(s=>s.trim());return i.length!==2?hr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:i,range:!0}}if(e.phrases("no_period").includes(n))return{bounds:["",""],range:!0};let t=e.phrases("to"),r=e.phrases("from");for(let i of t)if(n.startsWith(`${i} `))return{bounds:["",n.slice(i.length+1).trim()],range:!0};for(let i of t){let s=` ${i} `;if(!n.includes(s))continue;for(let a of r)if(n.startsWith(`${a} `)){n=n.slice(a.length+1);break}let o=n.split(s).map(a=>a.trim());return o.length!==2?hr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let i of r)if(n.startsWith(`${i} `))return{bounds:[n.slice(i.length+1).trim(),""],range:!0};return{bounds:[n,n],range:!1}}function hb(n,e,t){let r=[[n,0]],i=/^(.+?)\s*([+-])\s*(\d+)$/.exec(n);i&&r.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 r)for(let[l,u]of Object.entries(s))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return pi(xa(e.workdate),(u+a)*7+(t?6:0));if(l.endsWith("_month")){let c=td(e.year,e.month,u+a);return t?c.end:c.start}return pi(e.workdate,u+a)}return null}function pb(n,e,t){let r=Object.entries(e.dictionary.quarters).sort((i,s)=>s[0].length-i[0].length);for(let[i,s]of r){let o;if(n===i)o=null;else if(n.startsWith(i)&&dr.test(n.slice(i.length).trim()))o=fr(n.slice(i.length).trim(),e);else if(n.endsWith(i)&&dr.test(n.slice(0,-i.length).trim()))o=fr(n.slice(0,-i.length).trim(),e);else continue;return{year:o,month:t?s*3:s*3-2}}return null}function id(n,e){if(od(e.months,n))return e.months[n];let t=/^m(\d{1,2})$/.exec(n);return t&&Number(t[1])>=1&&Number(t[1])<=12?Number(t[1]):null}function mb(n,e){let t=n.split(/\s+/),r=t.map((u,c)=>id(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!r.length)return null;if(r.length!==1)return hr();let i=r[0],s=id(t[i],e.dictionary),o=t.slice(0,i),a=t.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&&dr.test(a[0]))return{year:fr(a[0],e),month:s};if(o.length===1&&nd.test(o[0])){if(!a.length)return $e(e.year,s,Number(o[0]));if(a.length===1&&dr.test(a[0]))return $e(fr(a[0],e),s,Number(o[0]))}return!o.length&&a.length===2&&nd.test(a[0])&&dr.test(a[1])?$e(fr(a[1],e),s,Number(a[0])):hr()}function gb(n,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(t)return $e(...t.slice(1).map(Number));let r=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(n),i={};if(r)e.order.split("").forEach((a,l)=>{i[a]=r[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(n)){let a=n.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;i[l]=n.slice(0,u),n=n.slice(u)}}else return null;if(!dr.test(i.Y)||i.D.length>2||i.M.length>2)return hr();let s=Number(i.D),o=Number(i.M);return r&&o>12&&s<=12&&([s,o]=[o,s]),$e(fr(i.Y,e),o,s)}function sd(n,e,t){if(!n)return null;let r=e.phrases("articles");if(n=n.split(/\s+/).filter(s=>!r.includes(s)).join(" "),!n)return hr();if(dr.test(n))return $e(fr(n,e),t?12:1,t?31:1);let i=hb(n,e,t)??pb(n,e,t)??mb(n,e);return i!==null?i:od(e.dictionary.weekdays,n)?pi(xa(e.workdate),e.dictionary.weekdays[n]):gb(n,e)??hr()}function bb(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year,i=typeof e=="string"?cr(e)[0]:e?.year,s=typeof e=="string"?cr(e)[1]:e?.month;return i&&(r>i&&(r=i),r===i&&n.month>s&&r--),$e(r,n.month,1)}function _b(n,e,t){if(n===null||typeof n=="string")return n;let r=n.year??t.year;if(e!==null){let[i,s]=cr(e);r<i&&(r=i),r===i&&s>n.month&&r++}return $e(r,n.month,ur(r,n.month))}function ad(n,e={}){if(!e||typeof e!="object"||Array.isArray(e))return mi("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:r="it-IT",workdate:i,twoDigitYearAhead:s=20}=e,[o,a]=cr(i);if(!Number.isInteger(s)||s<0||s>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...rd(r),workdate:i,year:o,month:a,twoDigitYearAhead:s}}catch(r){return mi("INVALID_CONTEXT",r.message)}if(typeof n!="string")return mi("INVALID_INPUT","Expression must be a string.");try{let r=n.toLowerCase().trim().replaceAll(",",""),{bounds:i,range:s}=fb(r,t),o=sd(i[1],t,!0),a=sd(i[0],t,!1),l=bb(a,o,t),u=_b(o,l,t);return!s&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(r){if(r instanceof RangeError)return mi("INVALID_DATE",r.message);if(r instanceof SyntaxError)return mi(r.code,r.message);throw r}}function ka(n){return class extends n{setLabelbox(e){let{box:t,labelBox:r,fieldLabel:i}=e;Object.assign(this,{box:t,labelBox:r,fieldLabel:i}),i.addEventListener("click",()=>{this.control.focus(),this.control.localName==="input"&&["checkbox","radio"].includes(this.control.type)&&this.control.click()})}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=this.parameters.lbl??"";return i?this.control.setAttribute("aria-label",i):this.control.removeAttribute("aria-label"),r}}}ka.labelbox=!0;ka.parameters={lbl:{dtype:"T",qualification:"intl_str",nullable:!0,binding:"read"},lbl_position:{dtype:"T",default:"TL",binding:"read",enum:ra}};var Da=["select","notnull","empty","case","len","min","max","email","regex","call","remote"],wb=["nodup","exist","gridnodup"],Gs=n=>n==null||n==="",Aa=(n,e)=>n instanceof Promise?n.then(e):e(n);function ld(n,e,t={}){let r={value:n,modified:!1,error:null,warnings:[],issues:[],datachanges:[]},i=Object.fromEntries(Object.entries(e).map(([u,c])=>[u.slice(9),c])),s=u=>Object.hasOwn(e,`validate_${u}`)&&e[`validate_${u}`]!=null;for(let u of wb)if(s(u))throw new Error(`validate_${u} requires the DB/grid integration.`);let o=(u,c,d=!1)=>t.invoke(u,e[u],{...i,value:c,result:r,validations:i,userChange:!0,signal:t.signal},d),a=(u,c)=>{if(c==null||c===!0)return;if(typeof c!="boolean"&&typeof c!="string"&&(typeof c!="object"||Array.isArray(c)))throw new TypeError("A validator returns true, false, null, an error code, or a result object/Bag.");let d=`validate_${u}`,f=c instanceof x?Object.fromEntries(c.getNodes().map(g=>[g.label,g.value])):typeof c=="object"?c:{errorcode:c===!1?"error":c};if(Object.hasOwn(f,"value")&&(r.modified||=!Object.is(r.value,f.value),r.value=f.value),f.data!=null&&(t.checkDataPatch(f.data),r.datachanges.push(f.data)),!f.errorcode)return;let h=e[`${d}_iswarning`]??f.iswarning??!!(e[`${d}_warning`]&&!e[`${d}_error`]),m=e[`${d}_${f.errorcode}`]||e[`${d}_${h?"warning":"error"}`]||f.message||e[`${d}_${h?"error":"warning"}`]||String(f.errorcode),p=Pt(m,g=>g?{...i,...f,value:r.value}[g]:r.value);if(p==null)throw new Error("A validation message references a missing value.");let b={rule:u,code:f.errorcode,severity:h?"warning":"error",message:p};r.issues.push(b),h?r.warnings.push(p):(r.error=p,r.required=!!f.required)},l=u=>{if(t.signal?.aborted)throw t.signal.reason;if(r.error||u===Da.length)return r;let c=Da[u],d=`validate_${c}`,f=e[d];if(!s(c)||f===!1&&c!=="empty")return l(u+1);let h=p=>{if(!p)return l(u+1);let b;return c==="remote"&&r.value==null?l(u+1):(c==="call"?b=o(d,r.value):c==="remote"?b=t.remote(f,{...yb(e),value:r.value},t.signal):b=vb(c,f,r.value,t),Aa(b,g=>{if(t.signal?.aborted)throw t.signal.reason;let _=()=>(a(c,g),l(u+1));return c==="remote"&&e.validate__onResult?Aa(t.invoke("validate__onResult",e.validate__onResult,{result:g,value:r.value,validations:i,signal:t.signal}),_):_()}))},m=e[`${d}_if`];return Aa(m==null?!0:typeof m=="boolean"?m:o(`${d}_if`,r.value,!0),h)};return l(0)}function yb(n){let e=new Set(["if","error","warning","iswarning"]);return Object.fromEntries(Object.entries(n).filter(([t])=>t.startsWith("validate_remote_")&&!e.has(t.slice(16))).map(([t,r])=>[t.slice(16),r]))}function gi(n,e,t={}){return{errorcode:n,message:e,...t}}function vb(n,e,t,r){if(n==="select")return r.selection(t);if(n==="notnull")return Gs(t)&&e?gi("notnull","A value is required.",{required:!0}):null;if(n==="empty")return Gs(t)?{value:e}:null;if(n==="len"){if(typeof e!="string"||!/^(?:\d+|\d+:\d*|:\d+)$/.test(e))throw new Error("Invalid validate_len: use a length or min:max.");let[i,s]=e.split(":"),o=Number(i||0),a=s===void 0?o:s===""?1/0:Number(s);if(o>a)throw new Error("Invalid validate_len: minimum exceeds maximum.");if(Gs(t))return;if(typeof t!="string")throw new TypeError("validate_len requires a text value.");return t.length<o||t.length>a?gi(o===a?"wrong length":t.length<o?"too short":"too long",o===a?`Enter exactly ${o} characters.`:a===1/0?`Enter at least ${o} characters.`:o===0?`Enter no more than ${a} characters.`:`Enter between ${o} and ${a} characters.`):void 0}if(!Gs(t)){if(n==="case"){if(typeof t!="string")throw new TypeError("validate_case requires a text value.");switch(e){case"upper":case"u":return{value:t.toUpperCase()};case"lower":case"l":return{value:t.toLowerCase()};case"title":case"t":return{value:t.replace(/\p{L}[\p{L}\p{M}]*/gu,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())};case"capitalize":case"c":return{value:t[0].toUpperCase()+t.slice(1).toLowerCase()};default:throw new Error("Invalid validate_case: use upper, lower, title or capitalize.")}}if(n==="min"||n==="max"){let i;if(r.isDecimal?.(t))i=t.comparedTo(e);else if(t instanceof Date&&e instanceof Date)i=t.getTime()-e.getTime();else if(typeof t=="number"&&Number.isFinite(t)&&typeof e=="number"&&Number.isFinite(e))i=t-e;else throw new TypeError(`validate_${n} requires matching numeric or date/time values.`);return(n==="min"?i<0:i>0)?gi(n,`Value must be ${n==="min"?"at least":"at most"} ${e}.`):void 0}if(n==="email"){if(typeof t!="string")throw new TypeError("validate_email requires a text value.");return/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(t)?null:gi("email","Check email format.",{iswarning:!0})}if(n==="regex"){if(typeof t!="string"||typeof e!="string")throw new TypeError("validate_regex requires text.");let i=e.trim(),s=i.startsWith("!");return new RegExp(s?i.slice(1):i,"u").test(t)!==s?null:gi("regex","The value does not match the required pattern.")}}}var bi={dtype:"T",nullable:!0,binding:"read"},Xs={dtype:"B",nullable:!0,binding:"read"},Ta={dtype:["T","L","N","R","B","D","H","DH","DHZ"],nullable:!0,binding:"read"},ud={validate_select:Xs,validate_notnull:{...Xs,default:!1},validate_empty:Ta,validate_case:{...bi,enum:["upper","lower","title","capitalize","u","l","t","c"]},validate_len:bi,validate_min:Ta,validate_max:Ta,validate_email:Xs,validate_regex:bi,validate_call:{dtype:"T",nullable:!0},validate_remote:bi,validate_onAccept:{dtype:"T",nullable:!0},validate_onReject:{dtype:"T",nullable:!0},validate__onResult:{dtype:"T",nullable:!0},validate_timeout:{dtype:"L",nullable:!0,binding:"read"},...Object.fromEntries(Da.flatMap(n=>[[`validate_${n}_if`,{dtype:["T","B"],nullable:!0}],[`validate_${n}_iswarning`,Xs],...["error","warning"].map(e=>[`validate_${n}_${e}`,{...bi,qualification:"intl_str"}])]))};var Eb=1800,cd=200;function dd(n){return class extends n{#e=!1;#t;#r;#n;#i;#s=0;#o;#a={};validationResult=null;constructor(){super(),this.message=this.ownerDocument.createElement("small"),this.message.id="field-message",this.message.hidden=!0,this.message.setAttribute("aria-live","polite"),this.message.setAttribute("popover","manual"),this.message.setAttribute("role","tooltip");let e=this.ownerDocument.createElement("style");e.textContent=`#control[aria-invalid="true"]{background:var(--gramlot-error-background,#fff1f0)}
141
196
  input#control[aria-invalid="true"],textarea#control[aria-invalid="true"]{color:var(--gramlot-error,#8c1d18)}
142
197
  #field-message{position:fixed;inset:auto;margin:0;padding:.4em .65em;border:1px solid var(--gramlot-error,#b3261e);border-radius:var(--gramlot-radius-sm,4px);
143
198
  color:var(--gramlot-error,#8c1d18);background:var(--gramlot-error-background,#fff1f0);font:inherit;font-size:.85em;box-shadow:var(--gramlot-shadow,0 2px 8px #0003);
144
- max-width:min(28em,var(--gramlot-popup-available-width,100vw));max-height:var(--gramlot-popup-available-height,100vh);overflow:auto;overflow-wrap:anywhere;opacity:1;transition:opacity ${Gc}ms ease-out}
199
+ max-width:min(28em,var(--gramlot-popup-available-width,100vw));max-height:var(--gramlot-popup-available-height,100vh);overflow:auto;overflow-wrap:anywhere;opacity:1;transition:opacity ${cd}ms ease-out}
145
200
  #field-message[data-severity="warning"]{color:var(--gramlot-warning,#805600);border-color:var(--gramlot-warning,#805600);background:var(--gramlot-warning-background,#fff8df)}
146
201
  #field-message[data-fading]{opacity:0}
147
- @media(prefers-reduced-motion:reduce){#field-message{transition:none}}`,this.shadowRoot.append(e),this.control.setAttribute("aria-describedby",this.message.id),this.controlBox.append(this.message),this.control.addEventListener("input",()=>this.cancelValidation()),this.control.addEventListener("compositionstart",()=>this.cancelValidation()),this.control.addEventListener("focusin",()=>this.#u()),this.control.addEventListener("mouseenter",()=>this.#u()),this.control.addEventListener("keydown",t=>{t.key==="Escape"&&(this.cancelValidation(),this.#l())})}#l(){this.ownerDocument.defaultView.clearTimeout(this.#r),this.#n?.abort(),this.#n=null,this.message.hidden||this.message.hidePopover(),this.message.hidden=!0,this.message.removeAttribute("data-fading")}#u(){if(!this.message.textContent||!this.isConnected)return;this.#l();let e=this.ownerDocument.defaultView;this.message.hidden=!1,this.message.showPopover(),Pr(this.message,this.control),this.#r=e.setTimeout(()=>{this.message.hidden||(this.message.setAttribute("data-fading",""),this.#r=e.setTimeout(()=>this.#l(),Gc))},ob),this.#n=new e.AbortController;let t={capture:!0,signal:this.#n.signal};e.addEventListener("scroll",()=>this.#l(),t),e.addEventListener("resize",()=>this.#l(),t)}releaseControl(){this.cancelValidation(),this.#l(),super.releaseControl()}disconnectedCallback(){this.releaseControl()}setFieldState({invalid:e=!1,pending:t=!1}={}){this.control.setAttribute("aria-invalid",String(e)),this.control.setAttribute("aria-busy",String(t))}error(e){this.#e=!1,["input","textarea"].includes(this.control.localName)&&this.control.setCustomValidity(e),this.control.setAttribute("aria-invalid",String(!!e)),this.message.textContent=e,e?this.#u():this.#l()}cancelValidation(){this.#s++,this.#i?.abort(),this.#i=null,this.#o=null,this.control.setAttribute("aria-busy","false")}validateCandidate(e,t){this.cancelValidation();let r=new AbortController;this.#i=r;let i=this.#s,s=this.#a,o=this.pageContext.validationCurrent();this.#o=o;let a=()=>this.#s===i&&!r.signal.aborted&&o(),l=d=>({value:e,modified:!1,error:d.message,warnings:[],issues:[],datachanges:[]}),u=d=>{if(!a())return this.#i===r&&this.cancelValidation(),{ok:!1};this.#i=null,this.#o=null,this.control.setAttribute("aria-busy","false");try{d.error||t(d.value)}catch(h){d=l(h)}this.validationResult=d,this.error(d.error||""),this.message.dataset.severity=d.error?"error":"warning",this.#e=!!d.error,!d.error&&d.warnings.length&&(this.message.textContent=d.warnings.join(`
148
- `),this.#u());let f={ok:!d.error,value:d.value,result:d,rules:s,isCurrent:a};return f.ok||this.finishValidation(f),f},c;try{if(s.validate_timeout!=null&&(!Number.isInteger(s.validate_timeout)||s.validate_timeout<=0))throw new TypeError("validate_timeout must be a positive integer in milliseconds.");c=Hc(e,s,{...this.pageContext,signal:r.signal,selection:d=>this.validateSelection(d)})}catch(d){return u(l(d))}return c instanceof Promise?(this.control.setAttribute("aria-busy","true"),new Promise(d=>{let f,h=()=>{clearTimeout(f),d({ok:!1})};r.signal.addEventListener("abort",h,{once:!0});let p=m=>{clearTimeout(f),r.signal.removeEventListener("abort",h),d(u(m))};s.validate_timeout!=null&&(f=setTimeout(()=>{p(l(new Error("Validation timed out."))),r.abort()},s.validate_timeout)),c.then(p,m=>p(l(m)))})):u(c)}finishValidation(e){e.result&&this.pageContext.finishValidation(e)}shouldProjectControlValue(e){this.#o&&!this.#o()&&this.cancelValidation();let t=this.sameControlValue(e,this.#t);return t&&this.#e?!1:(t||this.cancelValidation(),this.#t=e,!t&&this.#e&&this.error(""),!0)}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=Object.fromEntries(Object.entries(e).filter(([a])=>a.startsWith("validate_")));([...new Set([...Object.keys(i),...Object.keys(this.#a)])].some(a=>!Object.is(i[a],this.#a[a]))||e.disabled||e.readonly)&&this.cancelValidation(),this.#a=i;for(let a of Object.keys(i))delete r[a];let o=!!this.parameters.validate_notnull;return this.control.setAttribute("aria-required",String(o)),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.required=o),r}}}Xc.parameters=Wc;var Xr=new TextEncoder,Yc=n=>`export {default} from "./collection.js";
202
+ @media(prefers-reduced-motion:reduce){#field-message{transition:none}}`,this.shadowRoot.append(e),this.control.setAttribute("aria-describedby",this.message.id),this.controlBox.append(this.message),this.control.addEventListener("input",()=>this.cancelValidation()),this.control.addEventListener("compositionstart",()=>this.cancelValidation()),this.control.addEventListener("focusin",()=>this.#c()),this.control.addEventListener("mouseenter",()=>this.#c()),this.control.addEventListener("keydown",t=>{t.key==="Escape"&&(this.cancelValidation(),this.#l())})}#l(){this.ownerDocument.defaultView.clearTimeout(this.#r),this.#n?.abort(),this.#n=null,this.message.hidden||this.message.hidePopover(),this.message.hidden=!0,this.message.removeAttribute("data-fading")}#c(){if(!this.message.textContent||!this.isConnected)return;this.#l();let e=this.ownerDocument.defaultView;this.message.hidden=!1,this.message.showPopover(),Ur(this.message,this.control),this.#r=e.setTimeout(()=>{this.message.hidden||(this.message.setAttribute("data-fading",""),this.#r=e.setTimeout(()=>this.#l(),cd))},Eb),this.#n=new e.AbortController;let t={capture:!0,signal:this.#n.signal};e.addEventListener("scroll",()=>this.#l(),t),e.addEventListener("resize",()=>this.#l(),t)}releaseControl(){this.cancelValidation(),this.#l(),super.releaseControl()}disconnectedCallback(){this.releaseControl()}setFieldState({invalid:e=!1,pending:t=!1}={}){this.control.setAttribute("aria-invalid",String(e)),this.control.setAttribute("aria-busy",String(t))}error(e){this.#e=!1,["input","textarea"].includes(this.control.localName)&&this.control.setCustomValidity(e),this.control.setAttribute("aria-invalid",String(!!e)),this.message.textContent=e,e?this.#c():this.#l()}cancelValidation(){this.#s++,this.#i?.abort(),this.#i=null,this.#o=null,this.control.setAttribute("aria-busy","false")}validateCandidate(e,t){this.cancelValidation();let r=new AbortController;this.#i=r;let i=this.#s,s=this.#a,o=this.pageContext.validationCurrent();this.#o=o;let a=()=>this.#s===i&&!r.signal.aborted&&o(),l=d=>({value:e,modified:!1,error:d.message,warnings:[],issues:[],datachanges:[]}),u=d=>{if(!a())return this.#i===r&&this.cancelValidation(),{ok:!1};this.#i=null,this.#o=null,this.control.setAttribute("aria-busy","false");try{d.error||t(d.value)}catch(h){d=l(h)}this.validationResult=d,this.error(d.error||""),this.message.dataset.severity=d.error?"error":"warning",this.#e=!!d.error,!d.error&&d.warnings.length&&(this.message.textContent=d.warnings.join(`
203
+ `),this.#c());let f={ok:!d.error,value:d.value,result:d,rules:s,isCurrent:a};return f.ok||this.finishValidation(f),f},c;try{if(s.validate_timeout!=null&&(!Number.isInteger(s.validate_timeout)||s.validate_timeout<=0))throw new TypeError("validate_timeout must be a positive integer in milliseconds.");c=ld(e,s,{...this.pageContext,signal:r.signal,selection:d=>this.validateSelection(d)})}catch(d){return u(l(d))}return c instanceof Promise?(this.control.setAttribute("aria-busy","true"),new Promise(d=>{let f,h=()=>{clearTimeout(f),d({ok:!1})};r.signal.addEventListener("abort",h,{once:!0});let m=p=>{clearTimeout(f),r.signal.removeEventListener("abort",h),d(u(p))};s.validate_timeout!=null&&(f=setTimeout(()=>{m(l(new Error("Validation timed out."))),r.abort()},s.validate_timeout)),c.then(m,p=>m(l(p)))})):u(c)}finishValidation(e){e.result&&this.pageContext.finishValidation(e)}shouldProjectControlValue(e){this.#o&&!this.#o()&&this.cancelValidation();let t=this.sameControlValue(e,this.#t);return t&&this.#e?!1:(t||this.cancelValidation(),this.#t=e,!t&&this.#e&&this.error(""),!0)}projectAttributes(e,t){let r=super.projectAttributes(e,t),i=Object.fromEntries(Object.entries(e).filter(([a])=>a.startsWith("validate_")));([...new Set([...Object.keys(i),...Object.keys(this.#a)])].some(a=>!Object.is(i[a],this.#a[a]))||e.disabled||e.readonly)&&this.cancelValidation(),this.#a=i;for(let a of Object.keys(i))delete r[a];let o=!!this.parameters.validate_notnull;return this.control.setAttribute("aria-required",String(o)),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.required=o),r}}}dd.parameters=ud;var Qr=new TextEncoder,fd=n=>`export {default} from "./collection.js";
149
204
  export const buildId = "${n}";
150
- `,ba=n=>typeof n=="string"&&n.length>0&&!/[\\\x00-\x1f:?#%]/.test(n)&&!n.split("/").some(e=>!e||e==="."||e==="..");function Zc(n,e){if(!n||typeof n.name!="string"||!n.name||!["grammar","commands","module"].every(t=>ba(n[t]))||!Array.isArray(n.css)||!n.css.every(ba)||!Array.isArray(n.dependencies)||!n.dependencies.every(t=>typeof t=="string"&&t.length>0)||!Array.isArray(n.files)||!n.files.every(ba)||new Set(n.files).size!==n.files.length||!(e instanceof Map)||e.size!==n.files.length||n.files.some(t=>!(e.get(t)instanceof Uint8Array))||[n.grammar,n.commands,n.module,...n.css].some(t=>!e.has(t)))throw new TypeError("Invalid collection artifact metadata or file inventory")}async function Jc(n,e){Zc(n,e);let t=[Xr.encode("gramlot-build-v1\0")],r=(l,u)=>{let c=typeof u=="string"?Xr.encode(u):u;t.push(Xr.encode(`${l}\0${c.length}\0`),c)};for(let l of["name","grammar","commands","module"])r(l,n[l]);for(let l of n.css)r("css",l);for(let l of n.dependencies)r("dependency",l);let i=(l,u)=>{let c=Xr.encode(l),d=Xr.encode(u);for(let f=0;f<Math.min(c.length,d.length);f++)if(c[f]!==d[f])return c[f]-d[f];return c.length-d.length};for(let l of[...n.files].sort(i))r("path",l),r("content",l===n.module?Yc("__GRAMLOT_BUILD_ID__"):e.get(l));let s=new Uint8Array(t.reduce((l,u)=>l+u.length,0)),o=0;for(let l of t)s.set(l,o),o+=l.length;let a=await crypto.subtle.digest("SHA-256",s);return"sha256:"+[...new Uint8Array(a)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function ab(n,e){if(Zc(n,e),typeof n.buildId!="string"||!/^sha256:[a-f0-9]{64}$/.test(n.buildId))throw new TypeError("Invalid collection buildId");let t=Xr.encode(Yc(n.buildId)),r=e.get(n.module);if(r.length!==t.length||r.some((i,s)=>i!==t[s]))throw new Error("Invalid collection wrapper");if(await Jc(n,e)!==n.buildId)throw new Error(`Collection fingerprint mismatch: ${n.name}`)}export{D as Bag,je as BagNode,tc as ChoiceGroup,Yr as CommandRegistry,St as ComponentCollection,ii as DirectoryResolver,Kn as DomHandler,Is as Exposed,Xc as FieldState,si as FileSystemController,sr as FileSystemLogic,Gr as FramePage,ti as Gramlot,qe as GramlotBuilder,tr as GramlotHtmlRenderer,Xn as GramlotRenderer,Fn as GramlotSvgRenderer,Se as Handler,Zr as HttpTransport,Ms as IdeLogic,Qn as InOut,Os as IndexLogic,ni as IndexPage,zc as Labelbox,ec as NativeControl,da as NavigationResolver,ri as Page,la as PageBootstrap,zn as References,Zn as RpcError,Jn as RpcHandler,ut as ServerAdapter,Yn as SourceHandler,ei as UtilitiesHandler,Bs as codeMirrorWithOptions,Jc as collectionBuildId,Et as createDecimal,Go as defineCollection,Ct as defineComponent,Mc as fileSystemTree,ca as mountIndexPage,tb as parseDateExpression,ab as verifyCollectionArtifact};
205
+ `,Ca=n=>typeof n=="string"&&n.length>0&&!/[\\\x00-\x1f:?#%]/.test(n)&&!n.split("/").some(e=>!e||e==="."||e==="..");function hd(n,e){if(!n||typeof n.name!="string"||!n.name||!["grammar","commands","module"].every(t=>Ca(n[t]))||!Array.isArray(n.css)||!n.css.every(Ca)||!Array.isArray(n.dependencies)||!n.dependencies.every(t=>typeof t=="string"&&t.length>0)||!Array.isArray(n.files)||!n.files.every(Ca)||new Set(n.files).size!==n.files.length||!(e instanceof Map)||e.size!==n.files.length||n.files.some(t=>!(e.get(t)instanceof Uint8Array))||[n.grammar,n.commands,n.module,...n.css].some(t=>!e.has(t)))throw new TypeError("Invalid collection artifact metadata or file inventory")}async function pd(n,e){hd(n,e);let t=[Qr.encode("gramlot-build-v1\0")],r=(l,u)=>{let c=typeof u=="string"?Qr.encode(u):u;t.push(Qr.encode(`${l}\0${c.length}\0`),c)};for(let l of["name","grammar","commands","module"])r(l,n[l]);for(let l of n.css)r("css",l);for(let l of n.dependencies)r("dependency",l);let i=(l,u)=>{let c=Qr.encode(l),d=Qr.encode(u);for(let f=0;f<Math.min(c.length,d.length);f++)if(c[f]!==d[f])return c[f]-d[f];return c.length-d.length};for(let l of[...n.files].sort(i))r("path",l),r("content",l===n.module?fd("__GRAMLOT_BUILD_ID__"):e.get(l));let s=new Uint8Array(t.reduce((l,u)=>l+u.length,0)),o=0;for(let l of t)s.set(l,o),o+=l.length;let a=await crypto.subtle.digest("SHA-256",s);return"sha256:"+[...new Uint8Array(a)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function xb(n,e){if(hd(n,e),typeof n.buildId!="string"||!/^sha256:[a-f0-9]{64}$/.test(n.buildId))throw new TypeError("Invalid collection buildId");let t=Qr.encode(fd(n.buildId)),r=e.get(n.module);if(r.length!==t.length||r.some((i,s)=>i!==t[s]))throw new Error("Invalid collection wrapper");if(await pd(n,e)!==n.buildId)throw new Error(`Collection fingerprint mismatch: ${n.name}`)}export{x as Bag,ze as BagNode,bc as ChoiceGroup,tn as CommandRegistry,It as ComponentCollection,si as DeviceHandler,di as DirectoryResolver,ii as DomHandler,Fs as Exposed,dd as FieldState,fi as FileSystemController,lr as FileSystemLogic,Kr as FramePage,li as Gramlot,Oe as GramlotBuilder,ir as GramlotHtmlRenderer,ei as GramlotRenderer,Wn as GramlotSvgRenderer,De as Handler,rn as HttpTransport,Hs as IdeLogic,oi as InOut,qs as IndexLogic,ci as IndexPage,ka as Labelbox,en as MobileEnvironment,gc as NativeControl,Ea as NavigationResolver,ui as Page,wa as PageBootstrap,Zn as References,ri as RpcError,ni as RpcHandler,ft as ServerAdapter,ti as SourceHandler,ai as UtilitiesHandler,Us as codeMirrorWithOptions,pd as collectionBuildId,At as createDecimal,ia as defineCollection,Ot as defineComponent,ed as fileSystemTree,va as mountIndexPage,ad as parseDateExpression,xb as verifyCollectionArtifact};
151
206
  /*! Bundled license information:
152
207
 
153
208
  decimal.js/decimal.mjs: