@gramlot/gramlot 0.3.10 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/editors/__init__.py +13 -0
- package/dist/components/{editors.js → editors/assets/collection.js} +131 -246
- package/dist/components/editors/assets/index.js +2 -0
- package/dist/components/editors/commands.json +7 -0
- package/dist/components/editors/grammar.json +7045 -0
- package/dist/components/inputs/__init__.py +13 -0
- package/dist/components/{inputs.js → inputs/assets/collection.js} +287 -198
- package/dist/components/inputs/assets/index.js +2 -0
- package/dist/components/inputs/commands.json +7 -0
- package/dist/components/inputs/grammar.json +42881 -0
- package/dist/components/layout/__init__.py +13 -0
- package/dist/components/layout/assets/collection.js +25737 -0
- package/dist/components/layout/assets/index.js +2 -0
- package/dist/components/layout/commands.json +7 -0
- package/dist/components/layout/grammar.json +1798 -0
- package/dist/components/tree/__init__.py +13 -0
- package/dist/components/{tree.js → tree/assets/collection.js} +62 -175
- package/dist/components/tree/assets/index.js +2 -0
- package/dist/components/tree/commands.json +7 -0
- package/dist/components/tree/grammar.json +339 -0
- package/dist/components/typst/__init__.py +13 -0
- package/dist/components/typst/assets/collection.js +4 -0
- package/dist/components/typst/assets/index.js +2 -0
- package/dist/components/typst/commands.json +7 -0
- package/dist/components/typst/grammar.json +81 -0
- package/dist/gramlot.js +2496 -905
- package/dist/gramlot.min.js +109 -28
- package/dist/runtime-notices.json +0 -196
- package/package.json +1 -1
- package/src/binding/ask-dialog.js +1 -1
- package/src/binding/installation.js +5 -6
- package/src/binding/runtime.js +4 -2
- package/src/bootstrap.d.ts +1 -1
- package/src/bootstrap.js +52 -30
- package/src/builder/binding.json +25 -0
- package/src/builder/gramlot-builder.js +16 -3
- package/src/builder/source.js +33 -1
- package/src/collection-artifact.d.ts +11 -0
- package/src/collection-artifact.js +57 -0
- package/src/commands.d.ts +9 -0
- package/src/commands.js +36 -0
- package/src/components/bases.js +1 -1
- package/src/components/border-container.js +26 -1
- package/src/components/buttons.js +84 -161
- package/src/components/choice-editor.js +31 -10
- package/src/components/database-choices.js +110 -0
- package/src/components/inputs.js +15 -2
- package/src/components/layout.js +5 -3
- package/src/components/menus.js +346 -0
- package/src/components/popup.js +15 -2
- package/src/components/registry.js +18 -3
- package/src/components/toolbar-overflow.js +181 -0
- package/src/components/tree.js +14 -4
- package/src/components/windows.js +284 -0
- package/src/filesystem.js +1 -0
- package/src/gramlot.d.ts +2 -0
- package/src/gramlot.js +4 -2
- package/src/handlers/rpc-handler.d.ts +6 -1
- package/src/handlers/rpc-handler.js +7 -2
- package/src/handlers/source-handler.d.ts +2 -1
- package/src/handlers/source-handler.js +10 -1
- package/src/ide-documents.js +1 -1
- package/src/ide-runtime.js +3 -2
- package/src/index-page-styles.js +1 -1
- package/src/index-theme.js +1 -1
- package/src/index.d.ts +5 -0
- package/src/index.js +5 -0
- package/src/renderer/gramlot-html-renderer.js +1 -0
- package/src/renderer/gramlot-renderer.js +13 -3
- package/src/server/gramlot-file-server.d.ts +2 -0
- package/src/server/gramlot-file-server.js +45 -1
- package/src/server/gramlot-server.d.ts +20 -2
- package/src/server/gramlot-server.js +86 -6
- package/src/server/page-base.js +1 -0
- package/src/server/page.d.ts +3 -0
- package/src/view/button.js +47 -3
- package/src/view/controls.js +8 -0
- package/src/view/html.js +1 -0
- package/src/view/menu-command.js +45 -0
- package/src/view/menu.js +87 -0
- package/themes/gramlot-compact/README.md +19 -0
- package/themes/gramlot-compact/theme.css +138 -45
- package/themes/joanna/README.md +19 -0
- package/themes/joanna/theme.css +134 -78
- package/themes/mela/theme.css +184 -0
- package/themes/mimi/README.md +19 -0
- package/themes/mimi/theme.css +133 -77
- package/themes/palettes/README.md +3 -0
- package/themes/palettes/compact.css +86 -0
- package/themes/palettes/joanna.css +86 -0
- package/themes/palettes/mimi.css +86 -0
- package/tools/gramlot-tools-inspector.js +3 -3
- package/dist/components/layout.js +0 -3385
- package/dist/components/typst.js +0 -4
package/dist/gramlot.min.js
CHANGED
|
@@ -6,25 +6,25 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
var Ec=Object.create;var Ii=Object.defineProperty;var kc=Object.getOwnPropertyDescriptor;var Ac=Object.getOwnPropertyNames;var Tc=Object.getPrototypeOf,xc=Object.prototype.hasOwnProperty;var lt=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Dc=(r,e)=>{for(var t in e)Ii(r,t,{get:e[t],enumerable:!0})},Sc=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ac(e))!xc.call(r,s)&&s!==t&&Ii(r,s,{get:()=>e[s],enumerable:!(n=kc(e,s))||n.enumerable});return r};var oa=(r,e,t)=>(t=r!=null?Ec(Tc(r)):{},Sc(e||!r||!r.__esModule?Ii(t,"default",{value:r,enumerable:!0}):t,r));var $t=lt(ce=>{"use strict";function Jd(r,e,t){if(t===void 0&&(t=Array.prototype),r&&typeof t.find=="function")return t.find.call(r,e);for(var n=0;n<r.length;n++)if(Mt(r,n)){var s=r[n];if(e.call(void 0,s,n,r))return s}}function dr(r,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(r=e.create(null,e.getOwnPropertyDescriptors(r))),e&&typeof e.freeze=="function"?e.freeze(r):r}function Mt(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Kd(r,e){if(r===null||typeof r!="object")throw new TypeError("target is not an object");for(var t in e)Mt(e,t)&&(r[t]=e[t]);return r}var Ua=dr({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 Qd(r){return Mt(Ua,r.toLowerCase())}var qa=dr({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 ef(r){return Mt(qa,r.toLowerCase())}var Qr=dr({script:!1,style:!1,textarea:!0,title:!0});function tf(r){var e=r.toLowerCase();return Mt(Qr,e)&&!Qr[e]}function rf(r){var e=r.toLowerCase();return Mt(Qr,e)&&Qr[e]}function Va(r){return r===en.HTML}function nf(r){return Va(r)||r===en.XML_XHTML_APPLICATION}var en=dr({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),sf=Object.keys(en).map(function(r){return en[r]});function of(r){return sf.indexOf(r)>-1}var af=dr({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=Kd;ce.find=Jd;ce.freeze=dr;ce.HTML_BOOLEAN_ATTRIBUTES=Ua;ce.HTML_RAW_TEXT_ELEMENTS=Qr;ce.HTML_VOID_ELEMENTS=qa;ce.hasDefaultHTMLNamespace=nf;ce.hasOwn=Mt;ce.isHTMLBooleanAttribute=Qd;ce.isHTMLRawTextElement=tf;ce.isHTMLEscapableRawTextElement=rf;ce.isHTMLMimeType=Va;ce.isHTMLVoidElement=ef;ce.isValidMimeType=of;ce.MIME_TYPE=en;ce.NAMESPACE=af});var on=lt(sn=>{"use strict";var lf=$t();function za(r,e){r.prototype=Object.create(Error.prototype,{constructor:{value:r},name:{value:r.name,enumerable:!0,writable:e}})}var rn=lf.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"}),Wa=Object.keys(rn);function Ga(r){return typeof r=="number"&&r>=1&&r<=25}function uf(r){return typeof r=="string"&&r.substring(r.length-rn.Error.length)===rn.Error}function nn(r,e){Ga(r)?(this.name=Wa[r],this.message=e||""):(this.message=r,this.name=uf(e)?e:rn.Error),Error.captureStackTrace&&Error.captureStackTrace(this,nn)}za(nn,!0);Object.defineProperties(nn.prototype,{code:{enumerable:!0,get:function(){var r=Wa.indexOf(this.name);return Ga(r)?r:0}}});var Xa={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},Xi=Object.entries(Xa);for(tn=0;tn<Xi.length;tn++)Ha=Xi[tn][0],nn[Ha]=Xi[tn][1];var Ha,tn;function Yi(r,e,t){this.message=r,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,Yi)}za(Yi);sn.DOMException=nn;sn.DOMExceptionName=rn;sn.ExceptionCode=Xa;sn.ParseError=Yi});var ro=lt(B=>{"use strict";function el(r){try{typeof r!="function"&&(r=RegExp);var e=new r("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var pr=el();function mt(r){if(r.source[0]!=="[")throw new Error(r+" can not be used with chars");return r.source.slice(1,r.source.lastIndexOf("]"))}function fr(r,e){if(r.source[0]!=="[")throw new Error("/"+r.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(r.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+r.source+"/");if(e==="-"&&r.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+r.source+"/");return new RegExp(r.source.replace(e,""),pr?"u":"")}function $(r){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var n=typeof t=="string";if(n&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return n?t:t.source}).join(""),pr?"u":"")}function I(r){if(arguments.length===0)throw new Error("no parameters provided");return $.apply(I,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var cf="\uFFFD",gt=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;pr&&(gt=$("[",mt(gt),"\\u{10000}-\\u{10FFFF}","]"));var df=new RegExp("[^"+mt(gt)+"]",pr?"u":""),vs=/[\x20\x09\x0D\x0A]/,ff=mt(vs),z=$(vs,"+"),J=$(vs,"*"),an=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;pr&&(an=$("[",mt(an),"\\u{10000}-\\u{10FFFF}","]"));var hf=mt(an),Ki=$("[",hf,mt(/[-.0-9\xB7]/),mt(/[\u0300-\u036F\u203F-\u2040]/),"]"),De=$(an,Ki,"*"),pf=$("^",De,"$"),Ya=$(Ki,"+"),mf=$("&",De,";"),gf=I(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),ln=I(mf,"|",gf),un=$("%",De,";"),Qi=I($('"',I(/[^%&"]/,"|",un,"|",ln),"*",'"'),"|",$("'",I(/[^%&']/,"|",un,"|",ln),"*","'")),bf=I('"',I(/[^<&"]/,"|",ln),"*",'"',"|","'",I(/[^<&']/,"|",ln),"*","'"),_f=fr(an,":"),wf=fr(Ki,":"),Zi=$(_f,wf,"*"),yf=$("^",Zi,"$"),cn=$(Zi,I(":",Zi),"?"),vf=$("^",cn,"$"),Ef=$("(",cn,")"),hr=I(/"[^"]*"|'[^']*'/),kf=$(/^<\?/,"(",De,")",I(z,"(?!",vs,")(",gt,"*?)"),"?",/\?>/),Za=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,dn=I('"',Za,'*"',"|","'",fr(Za,"'"),"*'"),tl="<!--",rl="-->",Af=$(tl,I(fr(gt,"-"),"|",$("-",fr(gt,"-"))),"*",rl),Ja="#PCDATA",Tf=I($(/\(/,J,Ja,I(J,/\|/,J,cn),"*",J,/\)\*/),"|",$(/\(/,J,Ja,J,/\)/)),xf=/[?*+]?/,Df=$(/\([^>]+\)/,xf),Sf=I("EMPTY","|","ANY","|",Tf,"|",Df),Cf="<!ELEMENT",Nf=$(Cf,z,I(cn,"|",un),z,I(Sf,"|",un),J,">"),If=$("NOTATION",z,/\(/,J,De,I(J,/\|/,J,De),"*",J,/\)/),Of=$(/\(/,J,Ya,I(J,/\|/,J,Ya),"*",J,/\)/),Bf=I(If,"|",Of),Rf=I(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Bf),Mf=I(/#REQUIRED|#IMPLIED/,"|",I(I("#FIXED",z),"?",bf)),$f=I(z,De,z,Rf,z,Mf),Lf="<!ATTLIST",Pf=$(Lf,z,De,$f,"*",J,">"),Ji="about:legacy-compat",Ff=I('"'+Ji+'"',"|","'"+Ji+"'"),eo="SYSTEM",Es="PUBLIC",ks=I(I(eo,z,hr),"|",I(Es,z,dn,z,hr)),jf=$("^",I(I(eo,z,"(?<SystemLiteralOnly>",hr,")"),"|",I(Es,z,"(?<PubidLiteral>",dn,")",z,"(?<SystemLiteral>",hr,")"))),Uf=$("^",dn,"$"),qf=$("^",hr,"$"),Vf=I(z,"NDATA",z,De),Hf=I(Qi,"|",I(ks,Vf,"?")),nl="<!ENTITY",zf=$(nl,z,De,z,Hf,J,">"),Wf=I(Qi,"|",ks),Gf=$(nl,z,"%",z,De,z,Wf,J,">"),Xf=I(zf,"|",Gf),Yf=$(Es,z,dn),Zf=$("<!NOTATION",z,De,z,I(ks,"|",Yf),J,">"),to=$(J,"=",J),Ka=/1[.]\d+/,Jf=$(z,"version",to,I("'",Ka,"'","|",'"',Ka,'"')),Qa=/[A-Za-z][-A-Za-z0-9._]*/,Kf=I(z,"encoding",to,I('"',Qa,'"',"|","'",Qa,"'")),Qf=I(z,"standalone",to,I("'",I("yes","|","no"),"'","|",'"',I("yes","|","no"),'"')),eh=$(/^<\?xml/,Jf,Kf,"?",Qf,"?",J,/\?>/),th="<!DOCTYPE",rh="<![CDATA[",nh="]]>",sh=/<!\[CDATA\[/,ih=/\]\]>/,oh=$(gt,"*?",ih),ah=$(sh,oh);B.chars=mt;B.chars_without=fr;B.detectUnicodeSupport=el;B.reg=$;B.regg=I;B.ABOUT_LEGACY_COMPAT=Ji;B.ABOUT_LEGACY_COMPAT_SystemLiteral=Ff;B.AttlistDecl=Pf;B.CDATA_START=rh;B.CDATA_END=nh;B.CDSect=ah;B.Char=gt;B.Comment=Af;B.COMMENT_START=tl;B.COMMENT_END=rl;B.DOCTYPE_DECL_START=th;B.elementdecl=Nf;B.EntityDecl=Xf;B.EntityValue=Qi;B.ExternalID=ks;B.ExternalID_match=jf;B.Name=De;B.Name_exact=pf;B.NCName_exact=yf;B.NotationDecl=Zf;B.Reference=ln;B.PEReference=un;B.PI=kf;B.PUBLIC=Es;B.PubidLiteral=dn;B.PubidLiteral_match=Uf;B.QName=cn;B.QName_exact=vf;B.QName_group=Ef;B.S=z;B.SChar_s=ff;B.S_OPT=J;B.SYSTEM=eo;B.SystemLiteral=hr;B.SystemLiteral_match=qf;B.InvalidChar=df;B.UNICODE_REPLACEMENT_CHARACTER=cf;B.UNICODE_SUPPORT=pr;B.XMLDecl=eh});var ho=lt(ee=>{"use strict";var Be=$t(),Ye=Be.find,lh=Be.hasDefaultHTMLNamespace,gr=Be.hasOwn,uh=Be.isHTMLMimeType,ch=Be.isHTMLRawTextElement,dh=Be.isHTMLVoidElement,fn=Be.MIME_TYPE,Ze=Be.NAMESPACE,_e=Symbol(),cl=on(),E=cl.DOMException,ge=cl.DOMExceptionName,Q=ro();function ke(r){if(r!==_e)throw new TypeError("Illegal constructor")}function fh(r){return r!==""}function hh(r){return r?r.split(/[\t\n\f\r ]+/).filter(fh):[]}function ph(r,e){return gr(r,e)||(r[e]=!0),r}function sl(r){if(!r)return[];var e=hh(r);return Object.keys(e.reduce(ph,{}))}function mh(r){return function(e){return r&&r.indexOf(e)!==-1}}function dl(r){if(!Q.QName_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+r+'"')}function so(r,e){dl(e),r=r||null;var t=null,n=e;if(e.indexOf(":")>=0){var s=e.split(":");t=s[0],n=s[1]}if(t!==null&&r===null)throw new E(E.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&r!==Be.NAMESPACE.XML)throw new E(E.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&r!==Be.NAMESPACE.XMLNS)throw new E(E.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(r===Be.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new E(E.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[r,t,n]}function wr(r,e){for(var t in r)gr(r,t)&&(e[t]=r[t])}function Ae(r,e){var t=r.prototype;if(!(t instanceof e)){let n=function(){};n.prototype=e.prototype,n=new n,wr(t,n),r.prototype=t=n}t.constructor!=r&&(typeof r!="function"&&console.error("unknown Class:"+r),t.constructor=r)}var Te={},Oe=Te.ELEMENT_NODE=1,br=Te.ATTRIBUTE_NODE=2,hn=Te.TEXT_NODE=3,fl=Te.CDATA_SECTION_NODE=4,hl=Te.ENTITY_REFERENCE_NODE=5,gh=Te.ENTITY_NODE=6,io=Te.PROCESSING_INSTRUCTION_NODE=7,oo=Te.COMMENT_NODE=8,mr=Te.DOCUMENT_NODE=9,pl=Te.DOCUMENT_TYPE_NODE=10,bt=Te.DOCUMENT_FRAGMENT_NODE=11,bh=Te.NOTATION_NODE=12,K=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 ml(r,e){if(e.length<r.length)return ml(e,r);var t=null;for(var n in r){if(r[n]!==e[n])return t;t=r[n]}return t}function il(r){return r.guid||(r.guid=Math.random()),r.guid}function oe(){}oe.prototype={length:0,item:function(r){return r>=0&&r<this.length?this[r]:null},toString:function(r){var e;typeof r=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:r}:r?e={requireWellFormed:!!r.requireWellFormed,splitCDATASections:r.splitCDATASections!==!1,nodeFilter:r.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var t=[],n=0;n<this.length;n++)fo(this[n],t,null,e);return t.join("")},filter:function(r){return Array.prototype.filter.call(this,r)},indexOf:function(r){return Array.prototype.indexOf.call(this,r)}};oe.prototype[Symbol.iterator]=function(){var r=this,e=0;return{next:function(){return e<r.length?{value:r[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Xe(r,e){this._node=r,this._refresh=e,Ds(this)}function Ds(r){var e=r._node._inc||r._node.ownerDocument._inc;if(r._inc!==e){var t=r._refresh(r._node);if(xl(r,"length",t.length),!r.$$length||t.length<r.$$length)for(var n=t.length;n in r;n++)gr(r,n)&&delete r[n];wr(t,r),r._inc=e}}Xe.prototype.item=function(r){return Ds(this),this[r]||null};Ae(Xe,oe);function _r(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function gl(r,e){for(var t=0;t<r.length;){if(r[t]===e)return t;t++}}function ao(r,e,t){if(!e)return r._noNsIndex;var n=r._nsIndex[e];return!n&&t&&(n=r._nsIndex[e]=Object.create(null)),n}function _h(r,e,t){var n=ao(r,e,!1),s=n&&n[t];return s||null}function wh(r,e){ao(r,e.namespaceURI,!0)[e.localName]=e}function yh(r,e){var t=ao(r,e.namespaceURI,!1);t&&delete t[e.localName]}function vh(r,e,t,n){if(n?e[gl(e,n)]=t:(e[e.length]=t,e.length++),wh(e,t),r){t.ownerElement=r;var s=r.ownerDocument;s&&(n&&wl(s,r,n),Eh(s,r,t))}}function ol(r,e,t){var n=gl(e,t);if(n>=0){for(var s=e.length-1;n<=s;)e[n]=e[++n];if(e.length=s,yh(e,t),r){var i=r.ownerDocument;i&&wl(i,r,t),t.ownerElement=null}}}_r.prototype={length:0,item:oe.prototype.item,getNamedItem:function(r){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase());for(var e=0;e<this.length;){var t=this[e];if(t.nodeName===r)return t;e++}return null},setNamedItem:function(r){var e=r.ownerElement;if(e&&e!==this._ownerElement)throw new E(E.INUSE_ATTRIBUTE_ERR);var t=_h(this,r.namespaceURI,r.localName);return t===r?r:(vh(this._ownerElement,this,r,t),t)},setNamedItemNS:function(r){return this.setNamedItem(r)},removeNamedItem:function(r){var e=this.getNamedItem(r);if(!e)throw new E(E.NOT_FOUND_ERR,r);return ol(this._ownerElement,this,e),e},removeNamedItemNS:function(r,e){var t=this.getNamedItemNS(r,e);if(!t)throw new E(E.NOT_FOUND_ERR,r?r+" : "+e:e);return ol(this._ownerElement,this,t),t},getNamedItemNS:function(r,e){r||(r=null);for(var t=0;t<this.length;){var n=this[t];if(n.localName===e&&n.namespaceURI===r)return n;t++}return null}};_r.prototype[Symbol.iterator]=function(){var r=this,e=0;return{next:function(){return e<r.length?{value:r[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function bl(){}bl.prototype={hasFeature:function(r,e){return!0},createDocument:function(r,e,t){var n=fn.XML_APPLICATION;r===Ze.HTML?n=fn.XML_XHTML_APPLICATION:r===Ze.SVG&&(n=fn.XML_SVG_IMAGE);var s=new nt(_e,{contentType:n});if(s.implementation=this,s.childNodes=new oe,s.doctype=t||null,t&&s.appendChild(t),e){var i=s.createElementNS(r,e);s.appendChild(i)}return s},createDocumentType:function(r,e,t,n){dl(r);var s=new Ns(_e);return s.name=r,s.nodeName=r,s.publicId=e||"",s.systemId=t||"",s.internalSubset=n||"",s.childNodes=new oe,s},createHTMLDocument:function(r){var e=new nt(_e,{contentType:fn.HTML});if(e.implementation=this,e.childNodes=new oe,r!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var t=e.createElement("html");e.appendChild(t);var n=e.createElement("head");if(t.appendChild(n),typeof r=="string"){var s=e.createElement("title");s.appendChild(e.createTextNode(r)),n.appendChild(s)}t.appendChild(e.createElement("body"))}return e}};function F(r){ke(r)}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 r=this.getRootNode();return r&&r.nodeType===r.DOCUMENT_NODE},contains:function(r){if(!r)return!1;var e=r;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(r){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(r){if(!r)return!1;for(var e=[{node:this,other:r}];e.length>0;){var t=e.pop(),n=t.node,s=t.other;if(n.nodeType!==s.nodeType)return!1;switch(n.nodeType){case n.DOCUMENT_TYPE_NODE:if(n.name!==s.name||n.publicId!==s.publicId||n.systemId!==s.systemId)return!1;break;case n.ELEMENT_NODE:if(n.namespaceURI!==s.namespaceURI||n.prefix!==s.prefix||n.localName!==s.localName||n.attributes.length!==s.attributes.length)return!1;for(var i=0;i<n.attributes.length;i++){var o=n.attributes.item(i),a=s.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case n.ATTRIBUTE_NODE:if(n.namespaceURI!==s.namespaceURI||n.localName!==s.localName||n.value!==s.value)return!1;break;case n.PROCESSING_INSTRUCTION_NODE:if(n.target!==s.target||n.data!==s.data)return!1;break;case n.TEXT_NODE:case n.CDATA_SECTION_NODE:case n.COMMENT_NODE:if(n.data!==s.data)return!1;break}if(n.childNodes.length!==s.childNodes.length)return!1;for(var i=n.childNodes.length-1;i>=0;i--)e.push({node:n.childNodes[i],other:s.childNodes[i]})}return!0},isSameNode:function(r){return this===r},insertBefore:function(r,e){return xs(this,r,e)},replaceChild:function(r,e){xs(this,r,e,El),e&&this.removeChild(e)},removeChild:function(r){return yl(this,r)},appendChild:function(r){return this.insertBefore(r,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(r){return Tl(this.ownerDocument||this,this,r)},normalize:function(){de(this,null,{enter:function(r){for(var e=r.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===hn&&e.nodeType===hn){for(var n=[],s=t;s!==null&&s.nodeType===hn;)n.push(s.data),s=s.nextSibling;for(var i=e.nextSibling;i!==s;){var o=i.nextSibling;i.parentNode=null,i.previousSibling=null,i.nextSibling=null,i=o}e.nextSibling=s,s!==null?s.previousSibling=e:r.lastChild=e,e.appendData(n.join("")),lo(r.ownerDocument,r),e=s}else e=t}return!0}})},isSupported:function(r,e){return this.ownerDocument.implementation.hasFeature(r,e)},lookupPrefix:function(r){for(var e=this;e;){var t=e._nsMap;if(t){for(var n in t)if(gr(t,n)&&t[n]===r)return n}e=e.nodeType==br?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(r){for(var e=this;e;){var t=e._nsMap;if(t&&gr(t,r))return t[r];e=e.nodeType==br?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(r){var e=this.lookupPrefix(r);return e==null},compareDocumentPosition:function(r){if(this===r)return 0;var e=r,t=this,n=null,s=null;if(e instanceof Lt&&(n=e,e=n.ownerElement),t instanceof Lt&&(s=t,t=s.ownerElement,n&&e&&t===e))for(var i=0,o;o=t.attributes[i];i++){if(o===n)return K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+K.DOCUMENT_POSITION_PRECEDING;if(o===s)return K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+K.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return K.DOCUMENT_POSITION_DISCONNECTED+K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(il(t.ownerDocument)>il(e.ownerDocument)?K.DOCUMENT_POSITION_FOLLOWING:K.DOCUMENT_POSITION_PRECEDING);if(s&&e===t)return K.DOCUMENT_POSITION_CONTAINS+K.DOCUMENT_POSITION_PRECEDING;if(n&&e===t)return K.DOCUMENT_POSITION_CONTAINED_BY+K.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!s&&l===t)return K.DOCUMENT_POSITION_CONTAINED_BY+K.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=t.parentNode;c;){if(!n&&c===e)return K.DOCUMENT_POSITION_CONTAINS+K.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=ml(a,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return K.DOCUMENT_POSITION_FOLLOWING;if(h===e)return K.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return K.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(h)>=0)return K.DOCUMENT_POSITION_PRECEDING}return 0}};function _l(r){return r=="<"&&"<"||r==">"&&">"||r=="&"&&"&"||r=='"'&&"""||"&#"+r.charCodeAt()+";"}wr(Te,F);wr(Te,F.prototype);wr(K,F);wr(K,F.prototype);function Ts(r,e){de(r,null,{enter:function(t){return e(t)?de.STOP:!0}})}function de(r,e,t){for(var n=[{node:r,context:e,phase:de.ENTER}];n.length>0;){var s=n.pop();if(s.phase===de.ENTER){var i=t.enter(s.node,s.context);if(i===de.STOP)return de.STOP;if(n.push({node:s.node,context:i,phase:de.EXIT}),i==null)continue;for(var o=s.node.lastChild;o;)n.push({node:o,context:i,phase:de.ENTER}),o=o.previousSibling}else t.exit&&t.exit(s.node,s.context)}}de.STOP=Symbol("walkDOM.STOP");de.ENTER=0;de.EXIT=1;function nt(r,e){ke(r);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||fn.XML_APPLICATION,this.type=uh(this.contentType)?"html":"xml"}function Eh(r,e,t){r&&r._inc++;var n=t.namespaceURI;n===Ze.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function wl(r,e,t,n){r&&r._inc++;var s=t.namespaceURI;s===Ze.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function lo(r,e,t){if(r&&r._inc){r._inc++;var n=e.childNodes;if(t&&!t.nextSibling)n[n.length++]=t;else{for(var s=e.firstChild,i=0;s;)n[i++]=s,s=s.nextSibling;n.length=i,delete n[n.length]}}}function yl(r,e){if(r!==e.parentNode)throw new E(E.NOT_FOUND_ERR,"child's parent is not parent");var t=e.previousSibling,n=e.nextSibling;return t?t.nextSibling=n:r.firstChild=n,n?n.previousSibling=t:r.lastChild=t,lo(r.ownerDocument,r),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function kh(r){return r&&(r.nodeType===F.DOCUMENT_NODE||r.nodeType===F.DOCUMENT_FRAGMENT_NODE||r.nodeType===F.ELEMENT_NODE)}function Ah(r){return r&&(r.nodeType===F.CDATA_SECTION_NODE||r.nodeType===F.COMMENT_NODE||r.nodeType===F.DOCUMENT_FRAGMENT_NODE||r.nodeType===F.DOCUMENT_TYPE_NODE||r.nodeType===F.ELEMENT_NODE||r.nodeType===F.PROCESSING_INSTRUCTION_NODE||r.nodeType===F.TEXT_NODE)}function _t(r){return r&&r.nodeType===F.DOCUMENT_TYPE_NODE}function rt(r){return r&&r.nodeType===F.ELEMENT_NODE}function vl(r){return r&&r.nodeType===F.TEXT_NODE}function al(r,e){var t=r.childNodes||[];if(Ye(t,rt)||_t(e))return!1;var n=Ye(t,_t);return!(e&&n&&t.indexOf(n)>t.indexOf(e))}function ll(r,e){var t=r.childNodes||[];function n(i){return rt(i)&&i!==e}if(Ye(t,n))return!1;var s=Ye(t,_t);return!(e&&s&&t.indexOf(s)>t.indexOf(e))}function Th(r,e,t){if(!kh(r))throw new E(E.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+r.nodeType);if(t&&t.parentNode!==r)throw new E(E.NOT_FOUND_ERR,"child not in parent");if(!Ah(e)||_t(e)&&r.nodeType!==F.DOCUMENT_NODE)throw new E(E.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+r.nodeType)}function xh(r,e,t){var n=r.childNodes||[],s=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var i=s.filter(rt);if(i.length>1||Ye(s,vl))throw new E(E.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!al(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(rt(e)&&!al(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(_t(e)){if(Ye(n,_t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ye(n,rt);if(t&&n.indexOf(o)<n.indexOf(t))throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&o)throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function El(r,e,t){var n=r.childNodes||[],s=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var i=s.filter(rt);if(i.length>1||Ye(s,vl))throw new E(E.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!ll(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(rt(e)&&!ll(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(_t(e)){if(Ye(n,function(l){return _t(l)&&l!==t}))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ye(n,rt);if(t&&n.indexOf(o)<n.indexOf(t))throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function xs(r,e,t,n){Th(r,e,t),r.nodeType===F.DOCUMENT_NODE&&(n||xh)(r,e,t);var s=e.parentNode;if(s&&s.removeChild(e),e.nodeType===bt){var i=e.firstChild;if(i==null)return e;var o=e.lastChild}else i=o=e;var a=t?t.previousSibling:r.lastChild;i.previousSibling=a,o.nextSibling=t,a?a.nextSibling=i:r.firstChild=i,t==null?r.lastChild=o:t.previousSibling=o;do i.parentNode=r;while(i!==o&&(i=i.nextSibling));return lo(r.ownerDocument||r,r,e),e.nodeType==bt&&(e.firstChild=e.lastChild=null),e}nt.prototype={implementation:null,nodeName:"#document",nodeType:mr,doctype:null,documentElement:null,_inc:1,insertBefore:function(r,e){if(r.nodeType===bt){for(var t=r.firstChild;t;){var n=t.nextSibling;this.insertBefore(t,e),t=n}return r}return xs(this,r,e),r.ownerDocument=this,this.documentElement===null&&r.nodeType===Oe&&(this.documentElement=r),r},removeChild:function(r){var e=yl(this,r);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(r,e){xs(this,r,e,El),r.ownerDocument=this,e&&this.removeChild(e),rt(r)&&(this.documentElement=r)},importNode:function(r,e){return Dh(this,r,e)},getElementById:function(r){var e=null;return Ts(this.documentElement,function(t){if(t.nodeType==Oe&&t.getAttribute("id")==r)return e=t,!0}),e},createElement:function(r){var e=new st(_e);e.ownerDocument=this,this.type==="html"&&(r=r.toLowerCase()),lh(this.contentType)&&(e.namespaceURI=Ze.HTML),e.nodeName=r,e.tagName=r,e.localName=r,e.childNodes=new oe;var t=e.attributes=new _r;return t._ownerElement=e,e},createDocumentFragment:function(){var r=new yr(_e);return r.ownerDocument=this,r.childNodes=new oe,r},createTextNode:function(r){var e=new pn(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(r),e},createComment:function(r){var e=new Ss(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(r),e},createCDATASection:function(r){if(r.indexOf("]]>")!==-1)throw new E(E.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new Cs(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(r),e},createProcessingInstruction:function(r,e){var t=new Os(_e);return t.ownerDocument=this,t.childNodes=new oe,t.nodeName=t.target=r,t.nodeValue=t.data=e,t},createAttribute:function(r){if(!Q.QName_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'invalid character in name "'+r+'"');return this.type==="html"&&(r=r.toLowerCase()),this._createAttribute(r)},_createAttribute:function(r){var e=new Lt(_e);return e.ownerDocument=this,e.childNodes=new oe,e.name=r,e.nodeName=r,e.localName=r,e.specified=!0,e},createEntityReference:function(r){if(!Q.Name_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'not a valid xml name "'+r+'"');if(this.type==="html")throw new E("document is an html document",ge.NotSupportedError);var e=new Is(_e);return e.ownerDocument=this,e.childNodes=new oe,e.nodeName=r,e},createElementNS:function(r,e){var t=so(r,e),n=new st(_e),s=n.attributes=new _r;return n.childNodes=new oe,n.ownerDocument=this,n.nodeName=e,n.tagName=e,n.namespaceURI=t[0],n.prefix=t[1],n.localName=t[2],s._ownerElement=n,n},createAttributeNS:function(r,e){var t=so(r,e),n=new Lt(_e);return n.ownerDocument=this,n.childNodes=new oe,n.nodeName=e,n.name=e,n.specified=!0,n.namespaceURI=t[0],n.prefix=t[1],n.localName=t[2],n}};Ae(nt,F);function st(r){ke(r),this._nsMap=Object.create(null)}st.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(r){return!!this.getAttributeNode(r)},getAttribute:function(r){var e=this.getAttributeNode(r);return e?e.value:null},getAttributeNode:function(r){return this._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase()),this.attributes.getNamedItem(r)},setAttribute:function(r,e){this._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase());var t=this.getAttributeNode(r);t?t.value=t.nodeValue=""+e:(t=this.ownerDocument._createAttribute(r),t.value=t.nodeValue=""+e,this.setAttributeNode(t))},removeAttribute:function(r){var e=this.getAttributeNode(r);e&&this.removeAttributeNode(e)},setAttributeNode:function(r){return this.attributes.setNamedItem(r)},setAttributeNodeNS:function(r){return this.attributes.setNamedItemNS(r)},removeAttributeNode:function(r){return this.attributes.removeNamedItem(r.nodeName)},removeAttributeNS:function(r,e){var t=this.getAttributeNodeNS(r,e);t&&this.removeAttributeNode(t)},hasAttributeNS:function(r,e){return this.getAttributeNodeNS(r,e)!=null},getAttributeNS:function(r,e){var t=this.getAttributeNodeNS(r,e);return t?t.value:null},setAttributeNS:function(r,e,t){var n=so(r,e),s=n[2],i=this.getAttributeNodeNS(r,s);i?i.value=i.nodeValue=""+t:(i=this.ownerDocument.createAttributeNS(r,e),i.value=i.nodeValue=""+t,this.setAttributeNode(i))},getAttributeNodeNS:function(r,e){return this.attributes.getNamedItemNS(r,e)},getElementsByClassName:function(r){var e=sl(r);return new Xe(this,function(t){var n=[];return e.length>0&&Ts(t,function(s){if(s!==t&&s.nodeType===Oe){var i=s.getAttribute("class");if(i){var o=r===i;if(!o){var a=sl(i);o=e.every(mh(a))}o&&n.push(s)}}}),n})},getElementsByTagName:function(r){var e=(this.nodeType===mr?this:this.ownerDocument).type==="html",t=r.toLowerCase();return new Xe(this,function(n){var s=[];return Ts(n,function(i){if(!(i===n||i.nodeType!==Oe))if(r==="*")s.push(i);else{var o=i.getQualifiedName(),a=e&&i.namespaceURI===Ze.HTML?t:r;o===a&&s.push(i)}}),s})},getElementsByTagNameNS:function(r,e){return new Xe(this,function(t){var n=[];return Ts(t,function(s){s!==t&&s.nodeType===Oe&&(r==="*"||s.namespaceURI===r)&&(e==="*"||s.localName==e)&&n.push(s)}),n})}};nt.prototype.getElementsByClassName=st.prototype.getElementsByClassName;nt.prototype.getElementsByTagName=st.prototype.getElementsByTagName;nt.prototype.getElementsByTagNameNS=st.prototype.getElementsByTagNameNS;Ae(st,F);function Lt(r){ke(r),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}Lt.prototype.nodeType=br;Ae(Lt,F);function wt(r){ke(r)}wt.prototype={data:"",substringData:function(r,e){return this.data.substring(r,r+e)},appendData:function(r){r=this.data+r,this.nodeValue=this.data=r,this.length=r.length},insertData:function(r,e){this.replaceData(r,0,e)},deleteData:function(r,e){this.replaceData(r,e,"")},replaceData:function(r,e,t){var n=this.data.substring(0,r),s=this.data.substring(r+e);t=n+t+s,this.nodeValue=this.data=t,this.length=t.length}};Ae(wt,F);function pn(r){ke(r)}pn.prototype={nodeName:"#text",nodeType:hn,splitText:function(r){var e=this.data,t=e.substring(r);e=e.substring(0,r),this.data=this.nodeValue=e,this.length=e.length;var n=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}};Ae(pn,wt);function Ss(r){ke(r)}Ss.prototype={nodeName:"#comment",nodeType:oo};Ae(Ss,wt);function Cs(r){ke(r)}Cs.prototype={nodeName:"#cdata-section",nodeType:fl};Ae(Cs,pn);function Ns(r){ke(r)}Ns.prototype.nodeType=pl;Ae(Ns,F);function uo(r){ke(r)}uo.prototype.nodeType=bh;Ae(uo,F);function co(r){ke(r)}co.prototype.nodeType=gh;Ae(co,F);function Is(r){ke(r)}Is.prototype.nodeType=hl;Ae(Is,F);function yr(r){ke(r)}yr.prototype.nodeName="#document-fragment";yr.prototype.nodeType=bt;Ae(yr,F);function Os(r){ke(r)}Os.prototype.nodeType=io;Ae(Os,wt);function kl(){}kl.prototype.serializeToString=function(r,e){return Al.call(r,e)};F.prototype.toString=Al;function Al(r){var e;typeof r=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:r}:r!=null?e={requireWellFormed:!!r.requireWellFormed,splitCDATASections:r.splitCDATASections!==!1,nodeFilter:r.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var t=[],n=this.nodeType===mr&&this.documentElement||this,s=n.prefix,i=n.namespaceURI;if(i&&s==null){var s=n.lookupPrefix(i);if(s==null)var o=[{namespace:i,prefix:null}]}return fo(this,t,o,e),t.join("")}function ul(r,e,t){var n=r.prefix||"",s=r.namespaceURI;if(!s||n==="xml"&&s===Ze.XML||s===Ze.XMLNS)return!1;for(var i=t.length;i--;){var o=t[i];if(o.prefix===n)return o.namespace!==s}return!0}function As(r,e,t,n){if(n&&!Q.QName_exact.test(e))throw new E('The attribute name "'+e+'" is not a valid XML QName',ge.InvalidStateError);r.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,_l),'"')}function fo(r,e,t,n){t||(t=[]);var s=n.nodeFilter,i=n.requireWellFormed,o=n.splitCDATASections,a=r.nodeType===mr?r:r.ownerDocument,l=a.type==="html";de(r,{ns:t},{enter:function(u,c){var d=c.ns;if(s)if(u=s(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 g,b=0;b<f.length;b++)if(f.item(b).name==="xmlns"){g=f.item(b).value;break}if(!g)for(var y=d.length-1;y>=0;y--){var w=d[y];if(w.prefix===""&&w.namespace===u.namespaceURI){g=w.namespace;break}}if(g!==u.namespaceURI)for(var y=d.length-1;y>=0;y--){var w=d[y];if(w.namespace===u.namespaceURI){w.prefix&&(m=w.prefix+":"+p);break}}}if(i&&!Q.QName_exact.test(m))throw new E('The element name "'+m+'" is not a valid XML QName',ge.InvalidStateError);e.push("<",m);for(var k=d.slice(),A=0;A<h;A++){var v=f.item(A);v.prefix=="xmlns"?k.push({prefix:v.localName,namespace:v.value}):v.nodeName=="xmlns"&&k.push({prefix:"",namespace:v.value})}for(var A=0;A<h;A++){var v=f.item(A);if(ul(v,l,k)){var N=v.prefix||"",L=v.namespaceURI;As(e,N?"xmlns:"+N:"xmlns",L,i),k.push({prefix:N,namespace:L})}var U=s?s(v):v;U&&(typeof U=="string"?e.push(U):As(e,U.name,U.value,i))}if(p===m&&ul(u,l,k)){var ve=u.prefix||"",L=u.namespaceURI;As(e,ve?"xmlns:"+ve:"xmlns",L,i),k.push({prefix:ve,namespace:L})}var Y=!u.firstChild;if(Y&&(l||u.namespaceURI===Ze.HTML)&&(Y=dh(p)),Y)return e.push("/>"),null;if(e.push(">"),l&&ch(p)){for(var ne=u.firstChild;ne;)ne.data?e.push(ne.data):fo(ne,e,k.slice(),n),ne=ne.nextSibling;return e.push("</",m,">"),null}return{ns:k,tag:m};case mr:case bt:if(i&&u.nodeType===mr&&u.documentElement==null)throw new E("The Document has no documentElement",ge.InvalidStateError);return{ns:d};case br:return As(e,u.name,u.value,i),null;case hn:if(i&&Q.InvalidChar.test(u.data))throw new E("The Text node data contains characters outside the XML Char production",ge.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,_l)),null;case fl:if(i&&u.data.indexOf("]]>")!==-1)throw new E('The CDATASection data contains "]]>"',ge.InvalidStateError);return o?e.push(Q.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),Q.CDATA_END):e.push(Q.CDATA_START,u.data,Q.CDATA_END),null;case oo:if(i){if(Q.InvalidChar.test(u.data))throw new E("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 E('The comment node data contains "--" or ends with "-"',ge.InvalidStateError)}return e.push(Q.COMMENT_START,u.data,Q.COMMENT_END),null;case pl:var Ne=u.publicId,G=u.systemId;if(i){if(!Q.Name_exact.test(u.name))throw new E('The doctype name "'+u.name+'" is not a valid XML Name',ge.InvalidStateError);if(Ne&&!Q.PubidLiteral_match.test(Ne))throw new E("DocumentType publicId is not a valid PubidLiteral",ge.InvalidStateError);if(G&&G!=="."&&!Q.SystemLiteral_match.test(G))throw new E("DocumentType systemId is not a valid SystemLiteral",ge.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new E('DocumentType internalSubset contains "]>"',ge.InvalidStateError)}return e.push(Q.DOCTYPE_DECL_START," ",u.name),Ne?(e.push(" ",Q.PUBLIC," ",Ne),G&&G!=="."&&e.push(" ",G)):G&&G!=="."&&e.push(" ",Q.SYSTEM," ",G),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case io:if(i){if(!Q.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new E('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',ge.InvalidStateError);if(Q.InvalidChar.test(u.data))throw new E("The ProcessingInstruction data contains characters outside the XML Char production",ge.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new E('The ProcessingInstruction data contains "?>"',ge.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case hl:if(i&&!Q.Name_exact.test(u.nodeName))throw new E('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 Dh(r,e,t){var n;return de(e,null,{enter:function(s,i){var o=s.cloneNode(!1);o.ownerDocument=r,o.parentNode=null,i===null?n=o:i.appendChild(o);var a=s.nodeType===br||t;return a?o:null}}),n}function Tl(r,e,t){var n;return de(e,null,{enter:function(s,i){var o=new s.constructor(_e);for(var a in s)if(gr(s,a)){var l=s[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}s.childNodes&&(o.childNodes=new oe),o.ownerDocument=r;var u=t;switch(o.nodeType){case Oe:var c=s.attributes,d=o.attributes=new _r,f=c.length;d._ownerElement=o;for(var h=0;h<f;h++)o.setAttributeNode(Tl(r,c.item(h),!0));break;case br:u=!0}return i!==null?i.appendChild(o):n=o,u?o:null}}),n}function xl(r,e,t){r[e]=t}function no(r){for(var e=[],t=r.firstChild;t;)t.nodeType===Oe&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Xe.prototype,"length",{get:function(){return Ds(this),this.$$length}}),Object.defineProperty(F.prototype,"textContent",{get:function(){if(this.nodeType===Oe||this.nodeType===bt){var r=[];return de(this,null,{enter:function(e){if(e.nodeType===Oe||e.nodeType===bt)return!0;if(e.nodeType===io||e.nodeType===oo)return null;r.push(e.nodeValue)}}),r.join("")}return this.nodeValue},set:function(r){switch(this.nodeType){case Oe:case bt:for(;this.firstChild;)this.removeChild(this.firstChild);(r||String(r))&&this.appendChild(this.ownerDocument.createTextNode(r));break;default:this.data=r,this.value=r,this.nodeValue=r}}}),Object.defineProperty(wt.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(r){this._data=r,this.length=typeof r=="string"?r.length:0}}),Object.defineProperty(wt.prototype,"nodeValue",{get:function(){return this.data},set:function(r){this.data=r},enumerable:!0,configurable:!0}),Object.defineProperty(st.prototype,"children",{get:function(){return new Xe(this,no)}}),Object.defineProperty(nt.prototype,"children",{get:function(){return new Xe(this,no)}}),Object.defineProperty(yr.prototype,"children",{get:function(){return new Xe(this,no)}}),xl=function(r,e,t){r["$$"+e]=t})}catch{}ee._updateLiveList=Ds;ee.Attr=Lt;ee.CDATASection=Cs;ee.CharacterData=wt;ee.Comment=Ss;ee.Document=nt;ee.DocumentFragment=yr;ee.DocumentType=Ns;ee.DOMImplementation=bl;ee.Element=st;ee.Entity=co;ee.EntityReference=Is;ee.LiveNodeList=Xe;ee.NamedNodeMap=_r;ee.Node=F;ee.NodeList=oe;ee.Notation=uo;ee.Text=pn;ee.ProcessingInstruction=Os;ee.walkDOM=de;ee.XMLSerializer=kl});var Sl=lt(mn=>{"use strict";var Dl=$t().freeze;mn.XML_ENTITIES=Dl({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});mn.HTML_ENTITIES=Dl({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"});mn.entityMap=mn.HTML_ENTITIES});var Ll=lt(Rs=>{"use strict";var Tr=$t(),R=ro(),Ol=on(),Sh=Tr.isHTMLEscapableRawTextElement,Ch=Tr.isHTMLMimeType,Nh=Tr.isHTMLRawTextElement,_n=Tr.hasOwn,Cl=Tr.NAMESPACE,Ih=Ol.ParseError,Oh=Ol.DOMException,vr=0,yt=1,Er=2,gn=3,kr=4,Ar=5,bn=6,Bs=7;function Bl(){}Bl.prototype={parse:function(r,e,t){var n=this.domBuilder;n.startDocument(),$h(e,e=Object.create(null)),Bh(r,e,t,n,this.errorHandler),n.endDocument()}};var po=/&#?\w+;?/g;function Bh(r,e,t,n,s){var i=Ch(n.mimeType);r.indexOf(R.UNICODE_REPLACEMENT_CHARACTER)>=0&&s.warning("Unicode replacement character detected, source encoding issues?");function o(q){if(q>65535){q-=65536;var Ie=55296+(q>>10),ss=56320+(q&1023);return String.fromCharCode(Ie,ss)}else return String.fromCharCode(q)}function a(q){var Ie=q[q.length-1]===";"?q:q+";";if(!i&&Ie!==q)return s.error("EntityRef: expecting ;"),q;var ss=R.Reference.exec(Ie);if(!ss||ss[0].length!==Ie.length)return s.error("entity not matching Reference production: "+q),q;var is=Ie.slice(1,-1);return _n(t,is)?t[is]:is.charAt(0)==="#"?o(parseInt(is.substring(1).replace("x","0x"))):(s.error("entity not found:"+q),q)}function l(q){if(q>g){var Ie=r.substring(g,q).replace(po,a);f&&h(g),n.characters(Ie,0,q-g),g=q}}var u=0,c=0,d=/\r\n?|\n|$/g,f=n.locator;function h(q,Ie){for(;q>=c&&(Ie=d.exec(r));)u=c,c=Ie.index+Ie[0].length,f.lineNumber++;f.columnNumber=q-u+1}for(var p=[{currentNSMap:e}],m=[],g=0;;){try{var b=r.indexOf("<",g);if(b<0){if(!i&&m.length>0)return s.fatalError("unclosed xml tag(s): "+m.join(", "));if(!r.substring(g).match(/^\s*$/)){var y=n.doc,w=y.createTextNode(r.substring(g));if(y.documentElement)return s.error("Extra content at the end of the document");y.appendChild(w),n.currentElement=w}return}if(b>g){var k=r.substring(g,b);!i&&m.length===0&&(k=k.replace(new RegExp(R.S_OPT.source,"g"),""),k&&s.error("Unexpected content outside root element: '"+k+"'")),l(b)}switch(r.charAt(b+1)){case"/":var M=r.indexOf(">",b+2),A=r.substring(b+2,M>0?M:void 0);if(!A)return s.fatalError("end tag name missing");var v=R.reg("^",R.QName_group,R.S_OPT,"$"),N=M>0&&v.exec(A);if(!N){var L=M>0&&R.reg("^",R.QName_group).exec(A);if(i&&L)s.warning('end tag name contains invalid trailing characters: "'+A+'"'),N=L;else if(L&&new RegExp(v.source,v.flags+"m").test(A))s.error('end tag name is followed by a line break and trailing content: "'+A+'"'),N=L;else return s.fatalError('end tag name contains invalid characters: "'+A+'"')}if(!n.currentElement&&!n.doc.documentElement)return;var U=m[m.length-1]||n.currentElement.tagName||n.doc.documentElement.tagName||"";if(U!==N[1]){var ve=N[1].toLowerCase();if(!i||U.toLowerCase()!==ve)return s.fatalError('Opening and ending tag mismatch: "'+U+'" != "'+A+'"')}var Y=p.pop();m.pop();var ne=Y.localNSMap;if(n.endElement(Y.uri,Y.localName,U),ne)for(var Ne in ne)_n(ne,Ne)&&n.endPrefixMapping(Ne);M++;break;case"?":f&&h(b),M=Ph(r,b,n,s);break;case"!":f&&h(b),M=Ml(r,b,n,s,i);break;default:f&&h(b);var G=new $l,se=p[p.length-1].currentNSMap,M=Rh(r,b,G,se,a,s,i),sa=G.length;if(G.closed||(i&&Tr.isHTMLVoidElement(G.tagName)?G.closed=!0:m.push(G.tagName)),f&&sa){for(var vc=Nl(f,{}),Ni=0;Ni<sa;Ni++){var ia=G[Ni];h(ia.offset),ia.locator=Nl(f,{})}n.locator=vc,Il(G,n,se)&&p.push(G),n.locator=f}else Il(G,n,se)&&p.push(G);i&&!G.closed?M=Mh(r,M,G.tagName,a,n):M++}}catch(q){if(q instanceof Ih)throw q;if(q instanceof Oh)return s.fatalError("Error constructing the DOM: "+q.name+": "+q.message,q);s.error("element parse error: "+q),M=-1}M>g?g=M:l(Math.max(b,g)+1)}}function Nl(r,e){return e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber,e}function Rh(r,e,t,n,s,i,o){function a(h,p,m){if(_n(t.attributeNames,h))return i.fatalError("Attribute "+h+" redefined");if(!o&&p.indexOf("<")>=0)return i.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,p.replace(/[\t\n\r]/g," ").replace(po,s),m)}for(var l,u,c=++e,d=vr;;){var f=r.charAt(c);if(d===vr&&f==="<")throw new Error("unexpected < in tag name: "+r.slice(e,c));switch(f){case"=":if(d===yt)l=r.slice(e,c),d=gn;else if(d===Er)d=gn;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===gn||d===yt)if(d===yt&&(i.warning('attribute value must after "="'),l=r.slice(e,c)),e=c+1,c=r.indexOf(f,e),c>0)u=r.slice(e,c),a(l,u,e-1),d=Ar;else throw new Error("attribute value no end '"+f+"' match");else if(d==kr)u=r.slice(e,c),a(l,u,e),i.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Ar;else throw new Error('attribute value must after "="');break;case"/":switch(d){case vr:t.setTagName(r.slice(e,c));case Ar:case bn:case Bs:d=Bs,t.closed=!0;case kr:case yt:break;case Er:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),d==vr&&t.setTagName(r.slice(e,c)),c;case">":switch(d){case vr:t.setTagName(r.slice(e,c));case Ar:case bn:case Bs:break;case kr:case yt:u=r.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Er:d===Er&&(u=l),d==kr?(i.warning('attribute "'+u+'" missed quot(")!'),a(l,u,e)):(o||i.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case gn:if(!o)return i.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case vr:t.setTagName(r.slice(e,c)),d=bn;break;case yt:l=r.slice(e,c),d=Er;break;case kr:var u=r.slice(e,c);i.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Ar:d=bn;break}else switch(d){case Er:o||i.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,d=yt;break;case Ar:i.warning('attribute space is required"'+l+'"!!');case bn:d=yt,e=c;break;case gn:d=kr,e=c;break;case Bs:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function Il(r,e,t){for(var n=r.tagName,s=null,d=r.length;d--;){var i=r[d],o=i.qName,a=i.value,f=o.indexOf(":");if(f>0)var l=i.prefix=o.slice(0,f),u=o.slice(f+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";i.localName=u,c!==!1&&(s==null&&(s=Object.create(null),t=Object.create(t)),t[c]=s[c]=a,i.uri=Cl.XMLNS,e.startPrefixMapping(c,a))}for(var d=r.length;d--;)i=r[d],i.prefix&&(i.prefix==="xml"&&(i.uri=Cl.XML),i.prefix!=="xmlns"&&(i.uri=t[i.prefix]));var f=n.indexOf(":");f>0?(l=r.prefix=n.slice(0,f),u=r.localName=n.slice(f+1)):(l=null,u=r.localName=n);var h=r.uri=t[l||""];if(e.startElement(h,u,n,r),r.closed){if(e.endElement(h,u,n),s)for(l in s)_n(s,l)&&e.endPrefixMapping(l)}else return r.currentNSMap=t,r.localNSMap=s,!0}function Mh(r,e,t,n,s){var i=Sh(t);if(i||Nh(t)){var o=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(r),l=a?a.index:-1;if(l<0)return e+1;var u=r.substring(e+1,l);return i&&(u=u.replace(po,n)),s.characters(u,0,u.length),l}return e+1}function $h(r,e){for(var t in r)_n(r,t)&&(e[t]=r[t])}function Rl(r,e){var t=e;function n(c){return c=c||0,r.charAt(t+c)}function s(c){c=c||1,t+=c}function i(){for(var c=0;t<r.length;){var d=n();if(d!==" "&&d!==`
|
|
11
|
-
`&&d!==" "&&d!=="\r")return c;c++,
|
|
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=="<"&&"<"||n==">"&&">"||n=="&"&&"&"||n=='"'&&"""||"&#"+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,`
|
|
12
12
|
`).replace(/[\r\u0085\u2028\u2029]/g,`
|
|
13
|
-
`)}function
|
|
14
|
-
@#[line:`+
|
|
15
|
-
`,i),i<0&&(i=r.length),n+=r.slice(o,i);continue}if(r.startsWith("/*",i)){let c=r.indexOf("*/",i+2);i=c<0?r.length:c+2,n+=r.slice(o,i);continue}if(a==="/"&&s){let c=!1;for(i++;i<r.length;){let d=r[i++];if(d==="\\"){i++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(r[i]??"")&&i<r.length;)i++;n+=r.slice(o,i),s=!1;continue}let l=a==="{"?r.slice(i).match(aa):null;if(l){let c=l[1]??"";if(c.startsWith("?"))throw new SyntaxError("Optional slots are supported in pointer templates only");n+=`_pointerValues[${e.length}]`,e.push(c),i+=l[0].length,s=!1;continue}let u=r.slice(i).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),n+=u[0],i+=u[0].length,s=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}n+=a,i++,/\s/.test(a)||(s=/[([{,:;=!?&|+*%~<>\/-]/.test(a))}return{text:n,slots:e,identifiers:t}}function la(r,e,t=()=>null){let n=new Map,s=[],i=o=>{if(n.has(o))return n.get(o);if(!r.has(o))throw new Error(`Referenced Source attribute '${o}' does not exist`);if(s.includes(o))throw new Error(`Cyclic attribute dependency: ${[...s,o].join(" -> ")}`);s.push(o);try{let a=r.get(o),l=typeof o=="string"?V(a):null,u=e.get(o);if(l){let c=d=>d?i(d):e.get(o);if(l.expression){let d=zr(l.body);u=t(o,a,d,d.slots.map(c))}else u=Hr(l.body,c),e.get(o)==null&&(u=null)}return n.set(o,u),u}finally{s.pop()}};return new Map([...r.keys()].map(o=>[o,i(o)]))}function He(r,e){let t=new Map([...Object.entries(r.getAttr()),...r.fixedAttrItems()]),n=new Set,s=[],i=o=>{let a=V(o);if(!a)return;let l=[];a.expression?l.push(...zr(a.body).slots):Hr(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(s.includes(u))throw new Error(`Cyclic attribute dependency: ${[...s,u].join(" -> ")}`);n.has(u)||(s.push(u),i(t.get(u)),s.pop(),n.add(u))}};return i(e),n}var lr=9e15,ht=1e9,Oi="0123456789abcdef",ls="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",us="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Bi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-lr,maxE:lr,crypto:!1},fa,tt,O=!0,ds="[DecimalError] ",ft=ds+"Invalid argument: ",ha=ds+"Precision limit exceeded",pa=ds+"crypto unavailable",ma="[object Decimal]",pe=Math.floor,ie=Math.pow,Cc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Nc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ic=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ga=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$e=1e7,S=7,Oc=9007199254740991,Bc=ls.length-1,Ri=us.length-1,_={toStringTag:ma};_.absoluteValue=_.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),x(r)};_.ceil=function(){return x(new this.constructor(this),this.e+1,2)};_.clampedTo=_.clamp=function(r,e){var t,n=this,s=n.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(ft+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};_.comparedTo=_.cmp=function(r){var e,t,n,s,i=this,o=i.d,a=(r=new i.constructor(r)).d,l=i.s,u=r.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(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(n=o.length,s=a.length,e=0,t=n<s?n:s;e<t;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return n===s?0:n>s^l<0?1:-1};_.cosine=_.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+S,n.rounding=1,t=Rc(n,va(n,t)),n.precision=r,n.rounding=e,x(tt==2||tt==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};_.cubeRoot=_.cbrt=function(){var r,e,t,n,s,i,o,a,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(O=!1,i=c.s*ie(c.s*c,1/3),!i||Math.abs(i)==1/0?(t=ue(c.d),r=c.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=ie(t,1/3),r=pe((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new d(t),n.s=c.s):n=new d(i.toString()),o=(r=d.precision)+3;;)if(a=n,l=a.times(a).times(a),u=l.plus(c),n=X(u.plus(c).times(a),u.plus(l),o+2,1),ue(a.d).slice(0,o)===(t=ue(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!s&&t=="4999"){if(!s&&(x(a,r+1,0),a.times(a).times(a).eq(c))){n=a;break}o+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(x(n,r+1,1),e=!n.times(n).times(n).eq(c));break}return O=!0,x(n,r,d.rounding,e)};_.decimalPlaces=_.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-pe(this.e/S))*S,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};_.dividedBy=_.div=function(r){return X(this,new this.constructor(r))};_.dividedToIntegerBy=_.divToInt=function(r){var e=this,t=e.constructor;return x(X(e,new t(r),0,1,1),t.precision,t.rounding)};_.equals=_.eq=function(r){return this.cmp(r)===0};_.floor=function(){return x(new this.constructor(this),this.e+1,3)};_.greaterThan=_.gt=function(r){return this.cmp(r)>0};_.greaterThanOrEqualTo=_.gte=function(r){var e=this.cmp(r);return e==1||e===0};_.hyperbolicCosine=_.cosh=function(){var r,e,t,n,s,i=this,o=i.constructor,a=new o(1);if(!i.isFinite())return new o(i.s?1/0:NaN);if(i.isZero())return a;t=o.precision,n=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,s=i.d.length,s<32?(r=Math.ceil(s/3),e=(1/hs(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=ur(o,1,i.times(e),new o(1),!0);for(var l,u=r,c=new o(8);u--;)l=i.times(i),i=a.minus(l.times(c.minus(l.times(c))));return x(i,o.precision=t,o.rounding=n,!0)};_.hyperbolicSine=_.sinh=function(){var r,e,t,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(s.e,s.sd())+4,i.rounding=1,n=s.d.length,n<3)s=ur(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/hs(5,r)),s=ur(i,2,s,s,!0);for(var o,a=new i(5),l=new i(16),u=new i(20);r--;)o=s.times(s),s=s.times(a.plus(o.times(l.times(o).plus(u))))}return i.precision=e,i.rounding=t,x(s,e,t,!0)};_.hyperbolicTangent=_.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,X(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};_.inverseCosine=_.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,s=e.rounding;return t!==-1?t===0?r.isNeg()?ze(e,n,s):new e(0):new e(NaN):r.isZero()?ze(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=s,r.times(2))};_.inverseHyperbolicCosine=_.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,O=!1,t=t.times(t).minus(1).sqrt().plus(t),O=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};_.inverseHyperbolicSine=_.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,O=!1,t=t.times(t).plus(1).sqrt().plus(t),O=!0,n.precision=r,n.rounding=e,t.ln())};_.inverseHyperbolicTangent=_.atanh=function(){var r,e,t,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=i.precision,e=i.rounding,n=s.sd(),Math.max(n,r)<2*-s.e-1?x(new i(s),r,e,!0):(i.precision=t=n-s.e,s=X(s.plus(1),new i(1).minus(s),t+r,1),i.precision=r+4,i.rounding=1,s=s.ln(),i.precision=r,i.rounding=e,s.times(.5))):new i(NaN)};_.inverseSine=_.asin=function(){var r,e,t,n,s=this,i=s.constructor;return s.isZero()?new i(s):(e=s.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=ze(i,t+4,n).times(.5),r.s=s.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,s.times(2)))};_.inverseTangent=_.atan=function(){var r,e,t,n,s,i,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<=Ri)return o=ze(c,d+4,f).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(d+4<=Ri)return o=ze(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/S+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(O=!1,e=Math.ceil(a/S),n=1,l=u.times(u),o=new c(u),s=u;r!==-1;)if(s=s.times(l),i=o.minus(s.div(n+=2)),s=s.times(l),o=i.plus(s.div(n+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===i.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),O=!0,x(o,c.precision=d,c.rounding=f,!0)};_.isFinite=function(){return!!this.d};_.isInteger=_.isInt=function(){return!!this.d&&pe(this.e/S)>this.d.length-2};_.isNaN=function(){return!this.s};_.isNegative=_.isNeg=function(){return this.s<0};_.isPositive=_.isPos=function(){return this.s>0};_.isZero=function(){return!!this.d&&this.d[0]===0};_.lessThan=_.lt=function(r){return this.cmp(r)<0};_.lessThanOrEqualTo=_.lte=function(r){return this.cmp(r)<1};_.logarithm=_.log=function(r){var e,t,n,s,i,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding,h=5;if(r==null)r=new c(10),e=!0;else{if(r=new c(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new c(NaN);e=r.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)i=!0;else{for(s=t[0];s%10===0;)s/=10;i=s!==1}if(O=!1,a=d+h,o=dt(u,a),n=e?cs(c,a+10):dt(r,a),l=X(o,n,a,1),Wr(l.d,s=d,f))do if(a+=10,o=dt(u,a),n=e?cs(c,a+10):dt(r,a),l=X(o,n,a,1),!i){+ue(l.d).slice(s+1,s+15)+1==1e14&&(l=x(l,d+1,0));break}while(Wr(l.d,s+=10,f));return O=!0,x(l,d,f)};_.minus=_.sub=function(r){var e,t,n,s,i,o,a,l,u,c,d,f,h=this,p=h.constructor;if(r=new p(r),!h.d||!r.d)return!h.s||!r.s?r=new p(NaN):h.d?r.s=-r.s:r=new p(r.d||h.s!==r.s?h:NaN),r;if(h.s!=r.s)return r.s=-r.s,h.plus(r);if(u=h.d,f=r.d,a=p.precision,l=p.rounding,!u[0]||!f[0]){if(f[0])r.s=-r.s;else if(u[0])r=new p(h);else return new p(l===3?-0:0);return O?x(r,a,l):r}if(t=pe(r.e/S),c=pe(h.e/S),u=u.slice(),i=c-t,i){for(d=i<0,d?(e=u,i=-i,o=f.length):(e=f,t=c,o=u.length),n=Math.max(Math.ceil(a/S),o)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=u.length,o=f.length,d=n<o,d&&(o=n),n=0;n<o;n++)if(u[n]!=f[n]){d=u[n]<f[n];break}i=0}for(d&&(e=u,u=f,f=e,r.s=-r.s),o=u.length,n=f.length-o;n>0;--n)u[o++]=0;for(n=f.length;n>i;){if(u[--n]<f[n]){for(s=n;s&&u[--s]===0;)u[s]=$e-1;--u[s],u[n]+=$e}u[n]-=f[n]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=fs(u,t),O?x(r,a,l):r):new p(l===3?-0:0)};_.modulo=_.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?x(new n(t),n.precision,n.rounding):(O=!1,n.modulo==9?(e=X(t,r.abs(),0,3,1),e.s*=r.s):e=X(t,r,0,n.modulo,1),e=e.times(r),O=!0,t.minus(e))};_.naturalExponential=_.exp=function(){return Mi(this)};_.naturalLogarithm=_.ln=function(){return dt(this)};_.negated=_.neg=function(){var r=new this.constructor(this);return r.s=-r.s,x(r)};_.plus=_.add=function(r){var e,t,n,s,i,o,a,l,u,c,d=this,f=d.constructor;if(r=new f(r),!d.d||!r.d)return!d.s||!r.s?r=new f(NaN):d.d||(r=new f(r.d||d.s===r.s?d:NaN)),r;if(d.s!=r.s)return r.s=-r.s,d.minus(r);if(u=d.d,c=r.d,a=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(r=new f(d)),O?x(r,a,l):r;if(i=pe(d.e/S),n=pe(r.e/S),u=u.slice(),s=i-n,s){for(s<0?(t=u,s=-s,o=c.length):(t=c,n=i,o=u.length),i=Math.ceil(a/S),o=i>o?i+1:o+1,s>o&&(s=o,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(o=u.length,s=c.length,o-s<0&&(s=o,t=c,c=u,u=t),e=0;s;)e=(u[--s]=u[s]+c[s]+e)/$e|0,u[s]%=$e;for(e&&(u.unshift(e),++n),o=u.length;u[--o]==0;)u.pop();return r.d=u,r.e=fs(u,n),O?x(r,a,l):r};_.precision=_.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ft+r);return t.d?(e=ba(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};_.round=function(){var r=this,e=r.constructor;return x(new e(r),r.e+1,e.rounding)};_.sine=_.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+S,n.rounding=1,t=$c(n,va(n,t)),n.precision=r,n.rounding=e,x(tt>2?t.neg():t,r,e,!0)):new n(NaN)};_.squareRoot=_.sqrt=function(){var r,e,t,n,s,i,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),n=new c(e)):n=new c(u.toString()),t=(l=c.precision)+3;;)if(i=n,n=i.plus(X(o,i,t+2,1)).times(.5),ue(i.d).slice(0,t)===(e=ue(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(x(i,l+1,0),i.times(i).eq(o))){n=i;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(x(n,l+1,1),r=!n.times(n).eq(o));break}return O=!0,x(n,l,c.rounding,r)};_.tangent=_.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=X(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,x(tt==2||tt==4?t.neg():t,r,e,!0)):new n(NaN)};_.times=_.mul=function(r){var e,t,n,s,i,o,a,l,u,c=this,d=c.constructor,f=c.d,h=(r=new d(r)).d;if(r.s*=c.s,!f||!f[0]||!h||!h[0])return new d(!r.s||f&&!f[0]&&!h||h&&!h[0]&&!f?NaN:!f||!h?r.s/0:r.s*0);for(t=pe(c.e/S)+pe(r.e/S),l=f.length,u=h.length,l<u&&(i=f,f=h,h=i,o=l,l=u,u=o),i=[],o=l+u,n=o;n--;)i.push(0);for(n=u;--n>=0;){for(e=0,s=l+n;s>n;)a=i[s]+h[n]*f[s-n-1]+e,i[s--]=a%$e|0,e=a/$e|0;i[s]=(i[s]+e)%$e|0}for(;!i[--o];)i.pop();return e?++t:i.shift(),r.d=i,r.e=fs(i,t),O?x(r,d.precision,d.rounding):r};_.toBinary=function(r,e){return $i(this,2,r,e)};_.toDecimalPlaces=_.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(Ee(r,0,ht),e===void 0?e=n.rounding:Ee(e,0,8),x(t,r+t.e+1,e))};_.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=We(n,!0):(Ee(r,0,ht),e===void 0?e=s.rounding:Ee(e,0,8),n=x(new s(n),r+1,e),t=We(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=We(s):(Ee(r,0,ht),e===void 0?e=i.rounding:Ee(e,0,8),n=x(new i(s),r+s.e+1,e),t=We(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};_.toFraction=function(r){var e,t,n,s,i,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),n=l=new m(0),e=new m(n),i=e.e=ba(p)-h.e-1,o=i%S,e.d[0]=ie(10,o<0?S+o:o),r==null)r=i>0?e:u;else{if(a=new m(r),!a.isInt()||a.lt(u))throw Error(ft+a);r=a.gt(e)?i>0?e:u:a}for(O=!1,a=new m(ue(p)),c=m.precision,m.precision=i=p.length*S*2;d=X(a,e,0,1,1),s=t.plus(d.times(n)),s.cmp(r)!=1;)t=n,n=s,s=u,u=l.plus(d.times(s)),l=s,s=e,e=a.minus(d.times(s)),a=s;return s=X(r.minus(t),n,0,1,1),l=l.plus(s.times(u)),t=t.plus(s.times(n)),l.s=u.s=h.s,f=X(u,n,i,1).minus(h).abs().cmp(X(l,t,i,1).minus(h).abs())<1?[u,n]:[l,t],m.precision=c,O=!0,f};_.toHexadecimal=_.toHex=function(r,e){return $i(this,16,r,e)};_.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:Ee(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(O=!1,t=X(t,r,0,e,1).times(r),O=!0,x(t)):(r.s=t.s,t=r),t};_.toNumber=function(){return+this};_.toOctal=function(r,e){return $i(this,8,r,e)};_.toPower=_.pow=function(r){var e,t,n,s,i,o,a=this,l=a.constructor,u=+(r=new l(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new l(ie(+a,u));if(a=new l(a),a.eq(1))return a;if(n=l.precision,i=l.rounding,r.eq(1))return x(a,n,i);if(e=pe(r.e/S),e>=r.d.length-1&&(t=u<0?-u:u)<=Oc)return s=_a(l,a,t,n),r.s<0?new l(1).div(s):x(s,n,i);if(o=a.s,o<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=ie(+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),s=Mi(r.times(dt(a,n+t)),n),s.d&&(s=x(s,n+5,1),Wr(s.d,n,i)&&(e=n+10,s=x(Mi(r.times(dt(a,e+t)),e),e+5,1),+ue(s.d).slice(n+1,n+15)+1==1e14&&(s=x(s,n+1,0)))),s.s=o,O=!0,l.rounding=i,x(s,n,i))};_.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=We(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(Ee(r,1,ht),e===void 0?e=s.rounding:Ee(e,0,8),n=x(new s(n),r,e),t=We(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toSignificantDigits=_.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(Ee(r,1,ht),e===void 0?e=n.rounding:Ee(e,0,8)),x(new n(t),r,e)};_.toString=function(){var r=this,e=r.constructor,t=We(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};_.truncated=_.trunc=function(){return x(new this.constructor(this),this.e+1,1)};_.valueOf=_.toJSON=function(){var r=this,e=r.constructor,t=We(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function ue(r){var e,t,n,s=r.length-1,i="",o=r[0];if(s>0){for(i+=o,e=1;e<s;e++)n=r[e]+"",t=S-n.length,t&&(i+=ct(t)),i+=n;o=r[e],n=o+"",t=S-n.length,t&&(i+=ct(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}function Ee(r,e,t){if(r!==~~r||r<e||r>t)throw Error(ft+r)}function Wr(r,e,t,n){var s,i,o,a;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=S,s=0):(s=Math.ceil((e+1)/S),e%=S),i=ie(10,S-e),a=r[s]%i|0,n==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==i||t>3&&a+1==i/2)&&(r[s+1]/i/100|0)==ie(10,e-2)-1||(a==i/2||a==0)&&(r[s+1]/i/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),o=(n||t<4)&&a==9999||!n&&t>3&&a==4999):o=((n||t<4)&&a+1==i||!n&&t>3&&a+1==i/2)&&(r[s+1]/i/1e3|0)==ie(10,e-3)-1,o}function os(r,e,t){for(var n,s=[0],i,o=0,a=r.length;o<a;){for(i=s.length;i--;)s[i]*=e;for(s[0]+=Oi.indexOf(r.charAt(o++)),n=0;n<s.length;n++)s[n]>t-1&&(s[n+1]===void 0&&(s[n+1]=0),s[n+1]+=s[n]/t|0,s[n]%=t)}return s.reverse()}function Rc(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/hs(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=ur(r,1,e.times(s),new r(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,e}var X=(function(){function r(n,s,i){var o,a=0,l=n.length;for(n=n.slice();l--;)o=n[l]*s+a,n[l]=o%i|0,a=o/i|0;return a&&n.unshift(a),n}function e(n,s,i,o){var a,l;if(i!=o)l=i>o?1:-1;else for(a=l=0;a<i;a++)if(n[a]!=s[a]){l=n[a]>s[a]?1:-1;break}return l}function t(n,s,i,o){for(var a=0;i--;)n[i]-=a,a=n[i]<s[i]?1:0,n[i]=a*o+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,s,i,o,a,l){var u,c,d,f,h,p,m,g,b,y,w,k,A,v,N,L,U,ve,Y,ne,Ne=n.constructor,G=n.s==s.s?1:-1,se=n.d,M=s.d;if(!se||!se[0]||!M||!M[0])return new Ne(!n.s||!s.s||(se?M&&se[0]==M[0]:!M)?NaN:se&&se[0]==0||!M?G*0:G/0);for(l?(h=1,c=n.e-s.e):(l=$e,h=S,c=pe(n.e/h)-pe(s.e/h)),Y=M.length,U=se.length,b=new Ne(G),y=b.d=[],d=0;M[d]==(se[d]||0);d++);if(M[d]>(se[d]||0)&&c--,i==null?(v=i=Ne.precision,o=Ne.rounding):a?v=i+(n.e-s.e)+1:v=i,v<0)y.push(1),p=!0;else{if(v=v/h+2|0,d=0,Y==1){for(f=0,M=M[0],v++;(d<U||f)&&v--;d++)N=f*l+(se[d]||0),y[d]=N/M|0,f=N%M|0;p=f||d<U}else{for(f=l/(M[0]+1)|0,f>1&&(M=r(M,f,l),se=r(se,f,l),Y=M.length,U=se.length),L=Y,w=se.slice(0,Y),k=w.length;k<Y;)w[k++]=0;ne=M.slice(),ne.unshift(0),ve=M[0],M[1]>=l/2&&++ve;do f=0,u=e(M,w,Y,k),u<0?(A=w[0],Y!=k&&(A=A*l+(w[1]||0)),f=A/ve|0,f>1?(f>=l&&(f=l-1),m=r(M,f,l),g=m.length,k=w.length,u=e(m,w,g,k),u==1&&(f--,t(m,Y<g?ne:M,g,l))):(f==0&&(u=f=1),m=M.slice()),g=m.length,g<k&&m.unshift(0),t(w,m,k,l),u==-1&&(k=w.length,u=e(M,w,Y,k),u<1&&(f++,t(w,Y<k?ne:M,k,l))),k=w.length):u===0&&(f++,w=[0]),y[d++]=f,u&&w[0]?w[k++]=se[L]||0:(w=[se[L]],k=1);while((L++<U||w[0]!==void 0)&&v--);p=w[0]!==void 0}y[0]||y.shift()}if(h==1)b.e=c,fa=p;else{for(d=1,f=y[0];f>=10;f/=10)d++;b.e=d+c*h-1,x(b,a?i+b.e+1:i,o,p)}return b}})();function x(r,e,t,n){var s,i,o,a,l,u,c,d,f,h=r.constructor;e:if(e!=null){if(d=r.d,!d)return r;for(s=1,a=d[0];a>=10;a/=10)s++;if(i=e-s,i<0)i+=S,o=e,c=d[f=0],l=c/ie(10,s-o-1)%10|0;else if(f=Math.ceil((i+1)/S),a=d.length,f>=a)if(n){for(;a++<=f;)d.push(0);c=l=0,s=1,i%=S,o=i-S+1}else break e;else{for(c=a=d[f],s=1;a>=10;a/=10)s++;i%=S,o=i-S+s,l=o<0?0:c/ie(10,s-o-1)%10|0}if(n=n||e<0||d[f+1]!==void 0||(o<0?c:c%ie(10,s-o-1)),u=t<4?(l||n)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||n||t==6&&(i>0?o>0?c/ie(10,s-o):0:d[f-1])%10&1||t==(r.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=r.e+1,d[0]=ie(10,(S-e%S)%S),r.e=-e||0):d[0]=r.e=0,r;if(i==0?(d.length=f,a=1,f--):(d.length=f+1,a=ie(10,S-i),d[f]=o>0?(c/ie(10,s-o)%ie(10,o)|0)*a:0),u)for(;;)if(f==0){for(i=1,o=d[0];o>=10;o/=10)i++;for(o=d[0]+=a,a=1;o>=10;o/=10)a++;i!=a&&(r.e++,d[0]==$e&&(d[0]=1));break}else{if(d[f]+=a,d[f]!=$e)break;d[f--]=0,a=1}for(i=d.length;d[--i]===0;)d.pop()}return O&&(r.e>h.maxE?(r.d=null,r.e=NaN):r.e<h.minE&&(r.e=0,r.d=[0])),r}function We(r,e,t){if(!r.isFinite())return ya(r);var n,s=r.e,i=ue(r.d),o=i.length;return e?(t&&(n=t-o)>0?i=i.charAt(0)+"."+i.slice(1)+ct(n):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+ct(-s-1)+i,t&&(n=t-o)>0&&(i+=ct(n))):s>=o?(i+=ct(s+1-o),t&&(n=t-s-1)>0&&(i=i+"."+ct(n))):((n=s+1)<o&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-o)>0&&(s+1===o&&(i+="."),i+=ct(n))),i}function fs(r,e){var t=r[0];for(e*=S;t>=10;t/=10)e++;return e}function cs(r,e,t){if(e>Bc)throw O=!0,t&&(r.precision=t),Error(ha);return x(new r(ls),e,1,!0)}function ze(r,e,t){if(e>Ri)throw Error(ha);return x(new r(us),e,t,!0)}function ba(r){var e=r.length-1,t=e*S+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function ct(r){for(var e="";r--;)e+="0";return e}function _a(r,e,t,n){var s,i=new r(1),o=Math.ceil(n/S+4);for(O=!1;;){if(t%2&&(i=i.times(e),ca(i.d,o)&&(s=!0)),t=pe(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),ca(e.d,o)}return O=!0,i}function ua(r){return r.d[r.d.length-1]&1}function wa(r,e,t){for(var n,s,i=new r(e[0]),o=0;++o<e.length;){if(s=new r(e[o]),!s.s){i=s;break}n=i.cmp(s),(n===t||n===0&&i.s===t)&&(i=s)}return i}function Mi(r,e){var t,n,s,i,o,a,l,u=0,c=0,d=0,f=r.constructor,h=f.rounding,p=f.precision;if(!r.d||!r.d[0]||r.e>17)return new f(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(O=!1,l=p):l=e,a=new f(.03125);r.e>-2;)r=r.times(a),d+=5;for(n=Math.log(ie(2,d))/Math.LN10*2+5|0,l+=n,t=i=o=new f(1),f.precision=l;;){if(i=x(i.times(r),l,1),t=t.times(++c),a=o.plus(X(i,t,l,1)),ue(a.d).slice(0,l)===ue(o.d).slice(0,l)){for(s=d;s--;)o=x(o.times(o),l,1);if(e==null)if(u<3&&Wr(o.d,l-n,h,u))f.precision=l+=10,t=i=a=new f(1),c=0,u++;else return x(o,f.precision=p,h,O=!0);else return f.precision=p,o}o=a}}function dt(r,e){var t,n,s,i,o,a,l,u,c,d,f,h=1,p=10,m=r,g=m.d,b=m.constructor,y=b.rounding,w=b.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new b(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);if(e==null?(O=!1,c=w):c=e,b.precision=c+=p,t=ue(g),n=t.charAt(0),Math.abs(i=m.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)m=m.times(r),t=ue(m.d),n=t.charAt(0),h++;i=m.e,n>1?(m=new b("0."+t),i++):m=new b(n+"."+t.slice(1))}else return u=cs(b,c+2,w).times(i+""),m=dt(new b(n+"."+t.slice(1)),c-p).plus(u),b.precision=w,e==null?x(m,w,y,O=!0):m;for(d=m,l=o=m=X(m.minus(1),m.plus(1),c,1),f=x(m.times(m),c,1),s=3;;){if(o=x(o.times(f),c,1),u=l.plus(X(o,new b(s),c,1)),ue(u.d).slice(0,c)===ue(l.d).slice(0,c))if(l=l.times(2),i!==0&&(l=l.plus(cs(b,c+2,w).times(i+""))),l=X(l,new b(h),c,1),e==null)if(Wr(l.d,c-p,y,a))b.precision=c+=p,u=o=m=X(d.minus(1),d.plus(1),c,1),f=x(m.times(m),c,1),s=a=1;else return x(l,b.precision=w,y,O=!0);else return b.precision=w,l;l=u,s+=2}}function ya(r){return String(r.s*r.s/0)}function as(r,e){var t,n,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(n,s),e){if(s-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%S,t<0&&(n+=S),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=S;n<s;)r.d.push(+e.slice(n,n+=S));e=e.slice(n),n=S-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),O&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Mc(r,e){var t,n,s,i,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ga.test(e))return as(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(Nc.test(e))t=16,e=e.toLowerCase();else if(Cc.test(e))t=2;else if(Ic.test(e))t=8;else throw Error(ft+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),o=i>=0,n=r.constructor,o&&(e=e.replace(".",""),a=e.length,i=a-i,s=_a(n,new n(t),i,i*2)),u=os(e,t,$e),c=u.length-1,i=c;u[i]===0;--i)u.pop();return i<0?new n(r.s*0):(r.e=fs(u,c),r.d=u,O=!1,o&&(r=X(r,s,a*4)),l&&(r=r.times(Math.abs(l)<54?ie(2,l):Gr.pow(2,l))),O=!0,r)}function $c(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ur(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/hs(5,t)),e=ur(r,2,e,e);for(var s,i=new r(5),o=new r(16),a=new r(20);t--;)s=e.times(e),e=e.times(i.plus(s.times(o.times(s).minus(a))));return e}function ur(r,e,t,n,s){var i,o,a,l,u=1,c=r.precision,d=Math.ceil(c/S);for(O=!1,l=t.times(t),a=new r(n);;){if(o=X(a.times(l),new r(e++*e++),c,1),a=s?n.plus(o):n.minus(o),n=X(o.times(l),new r(e++*e++),c,1),o=a.plus(n),o.d[d]!==void 0){for(i=d;o.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=n,n=o,o=i,u++}return O=!0,o.d.length=d+1,o}function hs(r,e){for(var t=r;--e;)t*=r;return t}function va(r,e){var t,n=e.s<0,s=ze(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return tt=n?4:1,e;if(t=e.divToInt(s),t.isZero())tt=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return tt=ua(t)?n?2:3:n?4:1,e;tt=ua(t)?n?1:4:n?3:2}return e.minus(s).abs()}function $i(r,e,t,n){var s,i,o,a,l,u,c,d,f,h=r.constructor,p=t!==void 0;if(p?(Ee(t,1,ht),n===void 0?n=h.rounding:Ee(n,0,8)):(t=h.precision,n=h.rounding),!r.isFinite())c=ya(r);else{for(c=We(r),o=c.indexOf("."),p?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,o>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-o,f.d=os(We(f),10,s),f.e=f.d.length),d=os(c,10,s),i=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=p?"0p+0":"0";else{if(o<0?i--:(r=new h(r),r.d=d,r.e=i,r=X(r,f,t,n,0,s),d=r.d,i=r.e,u=fa),o=d[t],a=s/2,u=u||d[t+1]!==void 0,u=n<4?(o!==void 0||u)&&(n===0||n===(r.s<0?3:2)):o>a||o===a&&(n===4||u||n===6&&d[t-1]&1||n===(r.s<0?8:7)),d.length=t,u)for(;++d[--t]>s-1;)d[t]=0,t||(++i,d.unshift(1));for(l=d.length;!d[l-1];--l);for(o=0,c="";o<l;o++)c+=Oi.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=os(c,s,e),l=d.length;!d[l-1];--l);for(o=1,c="1.";o<l;o++)c+=Oi.charAt(d[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)c="0"+c;c="0."+c}else if(++i>l)for(i-=l;i--;)c+="0";else i<l&&(c=c.slice(0,i)+"."+c.slice(i))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return r.s<0?"-"+c:c}function ca(r,e){if(r.length>e)return r.length=e,!0}function Lc(r){return new this(r).abs()}function Pc(r){return new this(r).acos()}function Fc(r){return new this(r).acosh()}function jc(r,e){return new this(r).plus(e)}function Uc(r){return new this(r).asin()}function qc(r){return new this(r).asinh()}function Vc(r){return new this(r).atan()}function Hc(r){return new this(r).atanh()}function zc(r,e){r=new this(r),e=new this(e);var t,n=this.precision,s=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=ze(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?ze(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=ze(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(X(r,e,i,1)),e=ze(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(X(r,e,i,1)),t}function Wc(r){return new this(r).cbrt()}function Gc(r){return x(r=new this(r),r.e+1,2)}function Xc(r,e,t){return new this(r).clamp(e,t)}function Yc(r){if(!r||typeof r!="object")throw Error(ds+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,ht,"rounding",0,8,"toExpNeg",-lr,0,"toExpPos",0,lr,"maxE",0,lr,"minE",-lr,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=Bi[t]),(n=r[t])!==void 0)if(pe(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(ft+t+": "+n);if(t="crypto",s&&(this[t]=Bi[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(pa);else this[t]=!1;else throw Error(ft+t+": "+n);return this}function Zc(r){return new this(r).cos()}function Jc(r){return new this(r).cosh()}function Ea(r){var e,t,n;function s(i){var o,a,l,u=this;if(!(u instanceof s))return new s(i);if(u.constructor=s,da(i)){u.s=i.s,O?!i.d||i.e>s.maxE?(u.e=NaN,u.d=null):i.e<s.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(o=0,a=i;a>=10;a/=10)o++;O?o>s.maxE?(u.e=NaN,u.d=null):o<s.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[i]):(u.e=o,u.d=[i]);return}if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return as(u,i.toString())}if(l==="string")return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),ga.test(i)?as(u,i):Mc(u,i);if(l==="bigint")return i<0?(i=-i,u.s=-1):u.s=1,as(u,i.toString());throw Error(ft+i)}if(s.prototype=_,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=Yc,s.clone=Ea,s.isDecimal=da,s.abs=Lc,s.acos=Pc,s.acosh=Fc,s.add=jc,s.asin=Uc,s.asinh=qc,s.atan=Vc,s.atanh=Hc,s.atan2=zc,s.cbrt=Wc,s.ceil=Gc,s.clamp=Xc,s.cos=Zc,s.cosh=Jc,s.div=Kc,s.exp=Qc,s.floor=ed,s.hypot=td,s.ln=rd,s.log=nd,s.log10=id,s.log2=sd,s.max=od,s.min=ad,s.mod=ld,s.mul=ud,s.pow=cd,s.random=dd,s.round=fd,s.sign=hd,s.sin=pd,s.sinh=md,s.sqrt=gd,s.sub=bd,s.sum=_d,s.tan=wd,s.tanh=yd,s.trunc=vd,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return s.config(r),s}function Kc(r,e){return new this(r).div(e)}function Qc(r){return new this(r).exp()}function ed(r){return x(r=new this(r),r.e+1,3)}function td(){var r,e,t=new this(0);for(O=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),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 da(r){return r instanceof Gr||r&&r.toStringTag===ma||!1}function rd(r){return new this(r).ln()}function nd(r,e){return new this(r).log(e)}function sd(r){return new this(r).log(2)}function id(r){return new this(r).log(10)}function od(){return wa(this,arguments,-1)}function ad(){return wa(this,arguments,1)}function ld(r,e){return new this(r).mod(e)}function ud(r,e){return new this(r).mul(e)}function cd(r,e){return new this(r).pow(e)}function dd(r){var e,t,n,s,i=0,o=new this(1),a=[];if(r===void 0?r=this.precision:Ee(r,1,ht),n=Math.ceil(r/S),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)s=e[i],s>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)s=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,i):(a.push(s%1e7),i+=4);i=n/4}else throw Error(pa);else for(;i<n;)a[i++]=Math.random()*1e7|0;for(n=a[--i],r%=S,n&&r&&(s=ie(10,S-r),a[i]=(n/s|0)*s);a[i]===0;i--)a.pop();if(i<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=S)a.shift();for(n=1,s=a[0];s>=10;s/=10)n++;n<S&&(t-=S-n)}return o.e=t,o.d=a,o}function fd(r){return x(r=new this(r),r.e+1,this.rounding)}function hd(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function pd(r){return new this(r).sin()}function md(r){return new this(r).sinh()}function gd(r){return new this(r).sqrt()}function bd(r,e){return new this(r).sub(e)}function _d(){var r=0,e=arguments,t=new this(e[r]);for(O=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return O=!0,x(t,this.precision,this.rounding)}function wd(r){return new this(r).tan()}function yd(r){return new this(r).tanh()}function vd(r){return x(r=new this(r),r.e+1,1)}_[Symbol.for("nodejs.util.inspect.custom")]=_.toString;_[Symbol.toStringTag]="Decimal";var Gr=_.constructor=Ea(Bi);ls=new Gr(ls);us=new Gr(us);var ka=Gr;var Ed=20,kd=1,It=1e6,Aa=1e6,Ad=-7,Td=21,xd=!1,Xr="[big.js] ",Ot=Xr+"Invalid ",ps=Ot+"decimal places",Dd=Ot+"rounding mode",Ta=Xr+"Division by zero",H={},Ge=void 0,Sd=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function xa(){function r(e){var t=this;if(!(t instanceof r))return e===Ge?xa():new r(e);if(e instanceof r)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(r.strict===!0&&typeof e!="bigint")throw TypeError(Ot+"value");e=e===0&&1/e<0?"-0":String(e)}Cd(t,e)}t.constructor=r}return r.prototype=H,r.DP=Ed,r.RM=kd,r.NE=Ad,r.PE=Td,r.strict=xd,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}function Cd(r,e){var t,n,s;if(!Sd.test(e))throw Error(Ot+"number");for(r.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),s=e.length,n=0;n<s&&e.charAt(n)=="0";)++n;if(n==s)r.c=[r.e=0];else{for(;s>0&&e.charAt(--s)=="0";);for(r.e=t-n-1,r.c=[],t=0;n<=s;)r.c[t++]=+e.charAt(n++)}return r}function Bt(r,e,t,n){var s=r.c;if(t===Ge&&(t=r.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(Dd);if(e<1)n=t===3&&(n||!!s[0])||e===0&&(t===1&&s[0]>=5||t===2&&(s[0]>5||s[0]===5&&(n||s[1]!==Ge))),s.length=1,n?(r.e=r.e-e+1,s[0]=1):s[0]=r.e=0;else if(e<s.length){if(n=t===1&&s[e]>=5||t===2&&(s[e]>5||s[e]===5&&(n||s[e+1]!==Ge||s[e-1]&1))||t===3&&(n||!!s[0]),s.length=e,n){for(;++s[--e]>9;)if(s[e]=0,e===0){++r.e,s.unshift(1);break}}for(e=s.length;!s[--e];)s.pop()}return r}function Rt(r,e,t){var n=r.e,s=r.c.join(""),i=s.length;if(e)s=s.charAt(0)+(i>1?"."+s.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)s="0"+s;s="0."+s}else if(n>0)if(++n>i)for(n-=i;n--;)s+="0";else n<i&&(s=s.slice(0,n)+"."+s.slice(n));else i>1&&(s=s.charAt(0)+"."+s.slice(1));return r.s<0&&t?"-"+s:s}H.abs=function(){var r=new this.constructor(this);return r.s=1,r};H.cmp=function(r){var e,t=this,n=t.c,s=(r=new t.constructor(r)).c,i=t.s,o=r.s,a=t.e,l=r.e;if(!n[0]||!s[0])return n[0]?i:s[0]?-o:0;if(i!=o)return i;if(e=i<0,a!=l)return a>l^e?1:-1;for(o=(a=n.length)<(l=s.length)?a:l,i=-1;++i<o;)if(n[i]!=s[i])return n[i]>s[i]^e?1:-1;return a==l?0:a>l^e?1:-1};H.div=function(r){var e=this,t=e.constructor,n=e.c,s=(r=new t(r)).c,i=e.s==r.s?1:-1,o=t.DP;if(o!==~~o||o<0||o>It)throw Error(ps);if(!s[0])throw Error(Ta);if(!n[0])return r.s=i,r.c=[r.e=0],r;var a,l,u,c,d,f=s.slice(),h=a=s.length,p=n.length,m=n.slice(0,a),g=m.length,b=r,y=b.c=[],w=0,k=o+(b.e=e.e-r.e)+1;for(b.s=i,i=k<0?0:k,f.unshift(0);g++<a;)m.push(0);do{for(u=0;u<10;u++){if(a!=(g=m.length))c=a>g?1:-1;else for(d=-1,c=0;++d<a;)if(s[d]!=m[d]){c=s[d]>m[d]?1:-1;break}if(c<0){for(l=g==a?s:f;g;){if(m[--g]<l[g]){for(d=g;d&&!m[--d];)m[d]=9;--m[d],m[g]+=10}m[g]-=l[g]}for(;!m[0];)m.shift()}else break}y[w++]=c?u:++u,m[0]&&c?m[g]=n[h]||0:m=[n[h]]}while((h++<p||m[0]!==Ge)&&i--);return!y[0]&&w!=1&&(y.shift(),b.e--,k--),w>k&&Bt(b,k,t.RM,m[0]!==Ge),b};H.eq=function(r){return this.cmp(r)===0};H.gt=function(r){return this.cmp(r)>0};H.gte=function(r){return this.cmp(r)>-1};H.lt=function(r){return this.cmp(r)<0};H.lte=function(r){return this.cmp(r)<1};H.minus=H.sub=function(r){var e,t,n,s,i=this,o=i.constructor,a=i.s,l=(r=new o(r)).s;if(a!=l)return r.s=-l,i.plus(r);var u=i.c.slice(),c=i.e,d=r.c,f=r.e;if(!u[0]||!d[0])return d[0]?r.s=-l:u[0]?r=new o(i):r.s=1,r;if(a=c-f){for((s=a<0)?(a=-a,n=u):(f=c,n=d),n.reverse(),l=a;l--;)n.push(0);n.reverse()}else for(t=((s=u.length<d.length)?u:d).length,a=l=0;l<t;l++)if(u[l]!=d[l]){s=u[l]<d[l];break}if(s&&(n=u,u=d,d=n,r.s=-r.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]||(r.s=1,u=[f=0]),r.c=u,r.e=f,r};H.mod=function(r){var e,t=this,n=t.constructor,s=t.s,i=(r=new n(r)).s;if(!r.c[0])throw Error(Ta);return t.s=r.s=1,e=r.cmp(t)==1,t.s=s,r.s=i,e?new n(t):(s=n.DP,i=n.RM,n.DP=n.RM=0,t=t.div(r),n.DP=s,n.RM=i,this.minus(t.times(r)))};H.neg=function(){var r=new this.constructor(this);return r.s=-r.s,r};H.plus=H.add=function(r){var e,t,n,s=this,i=s.constructor;if(r=new i(r),s.s!=r.s)return r.s=-r.s,s.minus(r);var o=s.e,a=s.c,l=r.e,u=r.c;if(!a[0]||!u[0])return u[0]||(a[0]?r=new i(s):r.s=s.s),r;if(a=a.slice(),e=o-l){for(e>0?(l=o,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,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 r.c=a,r.e=l,r};H.pow=function(r){var e=this,t=new e.constructor("1"),n=t,s=r<0;if(r!==~~r||r<-Aa||r>Aa)throw Error(Ot+"exponent");for(s&&(r=-r);r&1&&(n=n.times(e)),r>>=1,!!r;)e=e.times(e);return s?t.div(n):n};H.prec=function(r,e){if(r!==~~r||r<1||r>It)throw Error(Ot+"precision");return Bt(new this.constructor(this),r,e)};H.round=function(r,e){if(r===Ge)r=0;else if(r!==~~r||r<-It||r>It)throw Error(ps);return Bt(new this.constructor(this),r+this.e+1,e)};H.sqrt=function(){var r,e,t,n=this,s=n.constructor,i=n.s,o=n.e,a=new s("0.5");if(!n.c[0])return new s(n);if(i<0)throw Error(Xr+"No square root");i=Math.sqrt(+Rt(n,!0,!0)),i===0||i===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),i=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),r=new s((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+o)):r=new s(i+""),o=r.e+(s.DP+=4);do t=r,r=a.times(t.plus(n.div(t)));while(t.c.slice(0,o).join("")!==r.c.slice(0,o).join(""));return Bt(r,(s.DP-=4)+r.e+1,s.RM)};H.times=H.mul=function(r){var e,t=this,n=t.constructor,s=t.c,i=(r=new n(r)).c,o=s.length,a=i.length,l=t.e,u=r.e;if(r.s=t.s==r.s?1:-1,!s[0]||!i[0])return r.c=[r.e=0],r;for(r.e=l+u,o<a&&(e=s,s=i,i=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]+i[l]*s[u-l-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++r.e:e.shift(),l=e.length;!e[--l];)e.pop();return r.c=e,r};H.toExponential=function(r,e){var t=this,n=t.c[0];if(r!==Ge){if(r!==~~r||r<0||r>It)throw Error(ps);for(t=Bt(new t.constructor(t),++r,e);t.c.length<r;)t.c.push(0)}return Rt(t,!0,!!n)};H.toFixed=function(r,e){var t=this,n=t.c[0];if(r!==Ge){if(r!==~~r||r<0||r>It)throw Error(ps);for(t=Bt(new t.constructor(t),r+t.e+1,e),r=r+t.e+1;t.c.length<r;)t.c.push(0)}return Rt(t,!1,!!n)};H[Symbol.for("nodejs.util.inspect.custom")]=H.toJSON=H.toString=function(){var r=this,e=r.constructor;return Rt(r,r.e<=e.NE||r.e>=e.PE,!!r.c[0])};H.toNumber=function(){var r=+Rt(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(r.toString()))throw Error(Xr+"Imprecise conversion");return r};H.toPrecision=function(r,e){var t=this,n=t.constructor,s=t.c[0];if(r!==Ge){if(r!==~~r||r<1||r>It)throw Error(Ot+"precision");for(t=Bt(new n(t),r,e);t.c.length<r;)t.c.push(0)}return Rt(t,r<=t.e||t.e<=n.NE||t.e>=n.PE,!!s)};H.valueOf=function(){var r=this,e=r.constructor;if(e.strict===!0)throw Error(Xr+"valueOf disallowed");return Rt(r,r.e<=e.NE||r.e>=e.PE,!0)};var Nd=xa(),Da=Nd;var Gi={};Dc(Gi,{DecodeError:()=>me,Decoder:()=>Pe,EXT_TIMESTAMP:()=>Pi,Encoder:()=>cr,ExtData:()=>Le,ExtensionCodec:()=>pt,decode:()=>$a,decodeArrayStream:()=>Fa,decodeAsync:()=>Pa,decodeMulti:()=>La,decodeMultiStream:()=>ja,decodeTimestampExtension:()=>Vi,decodeTimestampToTimeSpec:()=>qi,encode:()=>bs,encodeDateToTimeSpec:()=>ji,encodeTimeSpecToTimestamp:()=>Fi,encodeTimestampExtension:()=>Ui});function Sa(r){let e=r.length,t=0,n=0;for(;n<e;){let s=r.charCodeAt(n++);if((s&4294967168)===0){t++;continue}else if((s&4294965248)===0)t+=2;else{if(s>=55296&&s<=56319&&n<e){let i=r.charCodeAt(n);(i&64512)===56320&&(++n,s=((s&1023)<<10)+(i&1023)+65536)}(s&4294901760)===0?t+=3:t+=4}}return t}function Id(r,e,t){let n=r.length,s=t,i=0;for(;i<n;){let o=r.charCodeAt(i++);if((o&4294967168)===0){e[s++]=o;continue}else if((o&4294965248)===0)e[s++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&i<n){let a=r.charCodeAt(i);(a&64512)===56320&&(++i,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[s++]=o>>12&15|224,e[s++]=o>>6&63|128):(e[s++]=o>>18&7|240,e[s++]=o>>12&63|128,e[s++]=o>>6&63|128)}e[s++]=o&63|128}}var Od=new TextEncoder,Bd=50;function Rd(r,e,t){Od.encodeInto(r,e.subarray(t))}function Ca(r,e,t){r.length>Bd?Rd(r,e,t):Id(r,e,t)}var Md=4096;function Li(r,e,t){let n=e,s=n+t,i=[],o="";for(;n<s;){let a=r[n++];if((a&128)===0)i.push(a);else if((a&224)===192){let l=r[n++]&63;i.push((a&31)<<6|l)}else if((a&240)===224){let l=r[n++]&63,u=r[n++]&63;i.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=r[n++]&63,u=r[n++]&63,c=r[n++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d)}else i.push(a);i.length>=Md&&(o+=String.fromCharCode(...i),i.length=0)}return i.length>0&&(o+=String.fromCharCode(...i)),o}var $d=new TextDecoder,Ld=200;function Pd(r,e,t){let n=r.subarray(e,e+t);return $d.decode(n)}function Na(r,e,t){return t>Ld?Pd(r,e,t):Li(r,e,t)}var Le=class{type;data;constructor(e,t){this.type=e,this.data=t}};var me=class r extends Error{constructor(e){super(e);let t=Object.create(r.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:r.name})}};function Ia(r,e,t){let n=t/4294967296,s=t;r.setUint32(e,n),r.setUint32(e+4,s)}function ms(r,e,t){let n=Math.floor(t/4294967296),s=t;r.setUint32(e,n),r.setUint32(e+4,s)}function gs(r,e){let t=r.getInt32(e),n=r.getUint32(e+4);return t*4294967296+n}function Oa(r,e){let t=r.getUint32(e),n=r.getUint32(e+4);return t*4294967296+n}var Pi=-1,Fd=4294967296-1,jd=17179869184-1;function Fi({sec:r,nsec:e}){if(r>=0&&e>=0&&r<=jd)if(e===0&&r<=Fd){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,r),t}else{let t=r/4294967296,n=r&4294967295,s=new Uint8Array(8),i=new DataView(s.buffer);return i.setUint32(0,e<<2|t&3),i.setUint32(4,n),s}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),ms(n,4,r),t}}function ji(r){let e=r.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,s=Math.floor(n/1e9);return{sec:t+s,nsec:n-s*1e9}}function Ui(r){if(r instanceof Date){let e=ji(r);return Fi(e)}else return null}function qi(r){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(r.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),s=(t&3)*4294967296+n,i=t>>>2;return{sec:s,nsec:i}}case 12:{let t=gs(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new me(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${r.length}`)}}function Vi(r){let e=qi(r);return new Date(e.sec*1e3+e.nsec/1e6)}var Ba={type:Pi,encode:Ui,decode:Vi};var pt=class r{static defaultCodec=new r;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(Ba)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let s=-1-e;this.builtInEncoders[s]=t,this.builtInDecoders[s]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let s=this.builtInEncoders[n];if(s!=null){let i=s(e,t);if(i!=null){let o=-1-n;return new Le(o,i)}}}for(let n=0;n<this.encoders.length;n++){let s=this.encoders[n];if(s!=null){let i=s(e,t);if(i!=null){let o=n;return new Le(o,i)}}}return e instanceof Le?e:null}decode(e,t,n){let s=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return s?s(e,t,n):new Le(t,e)}};function Ud(r){return r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer}function Yr(r){return r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):Ud(r)?new Uint8Array(r):Uint8Array.from(r)}var qd=100,Vd=2048,cr=class r{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??qd,this.initialBufferSize=e?.initialBufferSize??Vd,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 r({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),n=new Uint8Array(t),s=new DataView(t);n.set(this.bytes),this.view=s,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Sa(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),Ca(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);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 n=Yr(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let s of e)this.doEncode(s,t+1)}countWithoutUndefined(e,t){let n=0;for(let s of t)e[s]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let s=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(s<16)this.writeU8(128+s);else if(s<65536)this.writeU8(222),this.writeU16(s);else if(s<4294967296)this.writeU8(223),this.writeU32(s);else throw new Error(`Too large map object: ${s}`);for(let i of n){let o=e[i];this.ignoreUndefined&&o===void 0||(this.encodeString(i),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),s=n.length;if(s>=4294967296)throw new Error(`Too large extension object: ${s}`);this.writeU8(201),this.writeU32(s),this.writeI8(e.type),this.writeU8a(n);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),Ia(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ms(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 bs(r,e){return new cr(e).encodeSharedRef(r)}function _s(r){return`${r<0?"-":""}0x${Math.abs(r).toString(16).padStart(2,"0")}`}var Hd=16,zd=16,ws=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Hd,t=zd){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let s=this.caches[n-1];e:for(let i of s){let o=i.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return i.str}return null}store(e,t){let n=this.caches[e.length-1],s={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=s:n.push(s)}decode(e,t,n){let s=this.find(e,t,n);if(s!=null)return this.hit++,s;this.miss++;let i=Li(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,i),i}};var Hi="array",Kr="map_key",Ma="map_value",Wd=r=>{if(typeof r=="string"||typeof r=="number")return r;throw new me("The type of key must be string or number but "+typeof r)},zi=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Hi,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=Kr,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===Hi){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===Kr||e.type===Ma){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Jr=-1,Wi=new DataView(new ArrayBuffer(0)),Gd=new Uint8Array(Wi.buffer);try{Wi.getInt8(0)}catch(r){if(!(r 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 Ra=new RangeError("Insufficient data"),Xd=new ws,Pe=class r{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Wi;bytes=Gd;headByte=Jr;stack=new zi;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:Xd,this.mapKeyConverter=e?.mapKeyConverter??Wd}clone(){return new r({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=Jr,this.stack.reset()}setBuffer(e){let t=Yr(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Jr&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=Yr(e),s=new Uint8Array(t.length+n.length);s.set(t),s.set(n,t.length),this.setBuffer(s)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} 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,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=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 n}let{headByte:s,pos:i,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${_s(s)} at ${o} (${i} 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 n=t,s=-1;for await(let i of e){if(t&&s===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(s=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--s!==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 s=e-128;if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e<160){let s=e-144;if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else{let s=e-160;t=this.decodeString(s,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 s=this.lookU8();t=this.decodeString(s,1)}else if(e===218){let s=this.lookU16();t=this.decodeString(s,2)}else if(e===219){let s=this.lookU32();t=this.decodeString(s,4)}else if(e===220){let s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===221){let s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===222){let s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===223){let s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===196){let s=this.lookU8();t=this.decodeBinary(s,1)}else if(e===197){let s=this.lookU16();t=this.decodeBinary(s,2)}else if(e===198){let s=this.lookU32();t=this.decodeBinary(s,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 s=this.lookU8();t=this.decodeExtension(s,1)}else if(e===200){let s=this.lookU16();t=this.decodeExtension(s,2)}else if(e===201){let s=this.lookU32();t=this.decodeExtension(s,4)}else throw new me(`Unrecognized type byte: ${_s(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let s=n.top();if(s.type===Hi)if(s.array[s.position]=t,s.position++,s.position===s.size)t=s.array,n.release(s);else continue e;else if(s.type===Kr){if(t==="__proto__")throw new me("The key __proto__ is not allowed");s.key=this.mapKeyConverter(t),s.type=Ma;continue e}else if(s.map[s.key]=t,s.readCount++,s.readCount===s.size)t=s.map,n.release(s);else{s.key=null,s.type=Kr;continue e}}return t}}readHeadByte(){return this.headByte===Jr&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Jr}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: ${_s(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 Ra;let n=this.pos+t,s;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?s=this.keyDecoder.decode(this.bytes,n,e):s=Na(this.bytes,n,e),this.pos+=t+e,s}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Kr:!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 Ra;let n=this.pos+t,s=this.bytes.subarray(n,n+e);return this.pos+=t+e,s}decodeExtension(e,t){if(e>this.maxExtLength)throw new me(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),s=this.decodeBinary(e,t+1);return this.extensionCodec.decode(s,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=Oa(this.view,this.pos);return this.pos+=8,e}readI64(){let e=gs(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 $a(r,e){return new Pe(e).decode(r)}function La(r,e){return new Pe(e).decodeMulti(r)}function Yd(r){return r[Symbol.asyncIterator]!=null}async function*Zd(r){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}function ys(r){return Yd(r)?r:Zd(r)}async function Pa(r,e){let t=ys(r);return new Pe(e).decodeAsync(t)}function Fa(r,e){let t=ys(r);return new Pe(e).decodeArrayStream(t)}function ja(r,e){let t=ys(r);return new Pe(e).decodeStream(t)}var Fs=oa(go(),1),bo=ka,_o=Da,Je=Gi,zl=Fs.DOMParser,Wl=Fs.XMLSerializer;var Gl=Je!==null;function Xl(){if(!Gl)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var Yl=Zh();function Zh(){if(!Gl)return null;let r=new TextEncoder,e=new TextDecoder,t=new Je.ExtensionCodec;return t.register({type:-1,encode:n=>{if(n instanceof Date){let s=vt(n);if(s==="D"||s==="H")return null}return Je.encodeTimestampExtension(n)},decode:n=>Je.decodeTimestampExtension(n)}),t.register({type:1,encode:n=>fe(n)?r.encode(n.toString()):null,decode:n=>Et(e.decode(n))}),t.register({type:2,encode:n=>{if(n instanceof Date&&vt(n)==="D"){let s=n.getUTCFullYear(),i=String(n.getUTCMonth()+1).padStart(2,"0"),o=String(n.getUTCDate()).padStart(2,"0");return r.encode(`${s}-${i}-${o}`)}return null},decode:n=>new Date(e.decode(n)+"T00:00:00.000Z")}),t.register({type:3,encode:n=>{if(n instanceof Date&&vt(n)==="H"){let s=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),o=String(n.getUTCSeconds()).padStart(2,"0"),a=String(n.getUTCMilliseconds()).padStart(3,"0");return r.encode(`${s}:${i}:${o}.${a}`)}return null},decode:n=>{let s=e.decode(n),i=s.indexOf("."),o=i>=0?s.substring(0,i):s,a=i>=0?s.substring(i+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:n=>{let s=wo(n);if(s!==null){let[i,o]=s;return r.encode(`${i}:${o(n)}`)}return null},decode:n=>{let s=e.decode(n),i=s.indexOf(":"),o=s.slice(0,i),a=s.slice(i+1),l=kt[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),t}function Zl(r){return Xl(),Je.encode(r,{extensionCodec:Yl})}function Jl(r){return Xl(),Je.decode(r,{extensionCodec:Yl})}function Us(r,e=!1){let t=qs(r);if(t===null)return[!1,String(r)];let[n,s,i]=t;return i&&!e?[!1,String(r)]:[!0,`${s(r)}::${n}`]}function yo(r){if(!r.includes("::"))return[!1,r];let e=r.lastIndexOf("::"),t=r.slice(0,e),n=r.slice(e+2),s=kt[n];if(s===void 0)return[!1,r];let[,i]=s;return[!0,i(t)]}function js(r,e,t){if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let n={};for(let[s,i]of Object.entries(r))n[s]=js(i,e,t);return n}return Array.isArray(r)?r.map(n=>js(n,e,t)):t(r)?e(r):r}function vo(r){let e=qs(r);if(e!==null){let[t,n,s]=e;return s?[r,!1]:[`${n(r)}::${t}`,!0]}if(Array.isArray(r)){let t=!1;return[r.map(s=>{let[i,o]=vo(s);return o&&(t=!0),i}),t]}if(r!==null&&typeof r=="object"){let t=!1,n={};for(let[s,i]of Object.entries(r)){let[o,a]=vo(i);a&&(t=!0),n[s]=o}return[n,t]}return[r,!1]}function Jh(r,e=!1){let[t,n]=Us(r,e);if(t)return n;let[s,i]=vo(r),o=JSON.stringify(s);return i?`${o}::JS`:o}function Kh(r){return JSON.stringify(r)}function Qh(r){if(!Je)throw new Error("@msgpack/msgpack is required for MessagePack support");return Je.encode(r)}function W(r,e=null,{raw:t=!1,qs:n=!1,_forceSuffix:s=!1}={}){if(n)return`${Ql(r)}::QS`;if(t){if(e===null||e==="json")return Kh(r);if(e==="msgpack")return Qh(r);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let i=Jh(r,s);return e==="json"?`"${i}"`:i}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${Kl(r)}</tytx_root>`;if(e==="msgpack")return Zl(r);throw new Error(`Unknown transport: ${e}`)}}var Cr,Eo;typeof window<"u"&&window.DOMParser?(Cr=window.DOMParser,Eo=window.XMLSerializer):(Cr=zl,Eo=Wl);function eu(r){if(r===null||typeof r!="object"||Array.isArray(r))return!1;let e=Object.keys(r);if(e.length!==1)return!1;let t=r[e[0]];return t!==null&&typeof t=="object"&&"value"in t}function tu(r,e,t){let n=r.createElement(e),s=t.attrs||{},i=t.value;for(let[o,a]of Object.entries(s))n.setAttribute(o,W(a,null,{_forceSuffix:!0}));if(Array.isArray(i))for(let o of i)if(eu(o)){let[a]=Object.keys(o),l=o[a],u=tu(r,a,l);n.appendChild(u)}else{n.textContent=W(i);break}else n.textContent=W(i);return n}function Kl(r){if(!Cr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(eu(r)){let[e]=Object.keys(r),t=r[e],n=new Cr().parseFromString("<root/>","text/xml"),s=tu(n,e,t);return new Eo().serializeToString(s)}else return W(r)}function ko(r){let e={};for(let n=0;n<r.attributes.length;n++){let s=r.attributes[n];e[s.name]=P(s.value)}let t=[];for(let n=0;n<r.childNodes.length;n++){let s=r.childNodes[n];s.nodeType===1&&t.push(s)}if(t.length>0)if(t.length===1){let n=t[0],s=ko(n);return{attrs:e,value:{[n.tagName]:s}}}else{let n=[];for(let s of t){let i=ko(s);n.push({[s.tagName]:i})}return{attrs:e,value:n}}return{attrs:e,value:P(r.textContent)}}function ru(r){if(!Cr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let n=new Cr().parseFromString(r,"text/xml").documentElement;if(n.tagName==="tytx_root"){let i=null;for(let o=0;o<n.childNodes.length;o++)if(n.childNodes[o].nodeType===1){i=n.childNodes[o];break}if(!i)return P(n.textContent);n=i}let s=ko(n);return{[n.tagName]:s}}function ep(r){return typeof r=="string"}function tp(r){let[e,t]=yo(r);if(e)return t;let n=r;n.endsWith("::JS")&&(n=n.slice(0,-4));let s;try{s=JSON.parse(n)}catch{return r}return js(s,rp,ep)}function rp(r){return r.includes("::")?yo(r)[1]:r}function np(r){let e=ru(r);return typeof e=="string"?P(e):e}function sp(r){return Jl(r)}function P(r,e=null){if(r===null)return null;if(e===null||e==="json"){let t=r;return e==="json"&&r.startsWith('"')&&r.endsWith('"')&&(t=r.slice(1,-1)),tp(t)}else{if(e==="xml")return np(r);if(e==="msgpack")return sp(r);throw new Error(`Unknown transport: ${e}`)}}function Ql(r){if(Array.isArray(r))return r.map(e=>String(e)).join("&");if(r!==null&&typeof r=="object"){let e=[];for(let[t,n]of Object.entries(r)){let[s,i]=Us(n,!0);s?e.push(`${t}=${i}`):e.push(`${t}=${n}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof r}`)}function nu(r){if(!r)return[];let e=r.split("&"),t=e.map(o=>o.includes("=")),n=t.every(Boolean),s=!t.some(Boolean);if(!n&&!s)throw new Error("QS format error: mixed items with and without '='");if(s)return e.map(o=>P(o));let i={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);i[l]=P(u)}return i}var iu=bo||_o||Number,ou=bo?"decimal.js":_o?"big.js":"number";function To(){return ou}function Et(r){return new iu(r)}function fe(r){return ou==="number"?!1:r instanceof iu}function vt(r){let e=r.getUTCFullYear()===1970&&r.getUTCMonth()===0&&r.getUTCDate()===1,t=r.getUTCHours()===0&&r.getUTCMinutes()===0&&r.getUTCSeconds()===0&&r.getUTCMilliseconds()===0;return e&&!t?"H":t&&!e?"D":"DHZ"}function ip(r){return r.toString()}function op(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0");return`${e}-${t}-${n}`}function ap(r){return r.toISOString()}function lp(r){let e=String(r.getUTCHours()).padStart(2,"0"),t=String(r.getUTCMinutes()).padStart(2,"0"),n=String(r.getUTCSeconds()).padStart(2,"0"),s=String(r.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${n}.${s}`}function up(r){return r?"true":"false"}function cp(r){return r.toString()}function dp(r){return r.toString()}function fp(r){let e="";for(let t=0;t<r.length;t+=32768)e+=String.fromCharCode.apply(null,r.subarray(t,t+32768));return btoa(e)}var Vs=[],Ao=new Map;function wo(r){if(r===null||typeof r!="object")return null;for(let e=Object.getPrototypeOf(r);e!==null;e=Object.getPrototypeOf(e))for(let[t,n,s,i]of Vs)if(t.prototype===e)return[n,s,i];return null}function qs(r){if(r===null)return["NN",()=>"",!0];if(fe(r))return["N",ip,!1];if(r instanceof Uint8Array)return["RAW",fp,!1];if(r instanceof Date){let e=vt(r);return e==="D"?["D",op,!1]:e==="H"?["H",lp,!1]:["DHZ",ap,!1]}return typeof r=="boolean"?["B",up,!0]:typeof r=="number"?Number.isInteger(r)?["L",cp,!0]:["R",dp,!0]:wo(r)}function hp(r){return Et(r)}function pp(r){let[e,t,n]=r.split("-").map(Number);return new Date(Date.UTC(e,t-1,n,0,0,0,0))}function su(r){return new Date(r)}function mp(r){let[e,t,n]=r.split(":"),[s,i]=n.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(s),Number(i||0)))}function gp(r){return r.toLowerCase()==="true"}function bp(r){return parseInt(r,10)}function _p(r){return parseFloat(r)}function wp(r){return r}function yp(r){return null}var vp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function Ep(r){if(!vp.test(r))throw new Error(`RAW payload is not standard padded base64: '${r}'`);let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function kp(r){return nu(r)}var Ap=/^[A-Z]+$/,kt={N:[Object,hp],D:[Date,pp],DH:[Date,su],DHZ:[Date,su],H:[Date,mp],L:[Number,bp],R:[Number,_p],T:[String,wp],B:[Boolean,gp],QS:[Object,kp],NN:[null,yp],RAW:[Uint8Array,Ep]};function wn(r){return Object.hasOwn(kt,r)?kt[r][0]:null}function xo(r,e,t,n,s=!1){if(typeof e!="string"||!Ap.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let i=kt[e];if(i!==void 0&&i[0]!==r){let o=i[0]===null?"null":i[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}Vs=Vs.filter(([o])=>o!==r),Vs.push([r,e,t,s]),kt[e]=[r,n]}function Ft(r,e){Ao.set(r,e)}function Re(r){return Ao.has(r)?Ao.get(r):{}}var au={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 xp(r){let e=r._retryPolicy;return e==null?null:typeof e=="string"?au[e]||null:e}function Dp(r,e){return e.some(t=>t==="Error"?!0:r.name===t||r.constructor.name===t)}function Sp(r){return new Promise(e=>setTimeout(e,r))}async function Cp(r,e){if(!e)return r();let t=e.maxAttempts||3,n=e.delay||1,s=e.backoff||2,i=e.jitter!==!1,o=e.on||["Error"],a=null,l=n*1e3;for(let u=0;u<t;u++)try{let c=r();return c instanceof Promise?await c:c}catch(c){if(a=c,u<t-1&&Dp(c,o)){let d=l;i&&(d*=1+Math.random()*.1),await Sp(d),l*=s}else throw c}throw a}var Z=class r{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let n={...this.constructor.classKwargs,...e};for(let i of["interval","reactive"])if(Object.hasOwn(n,i))throw new TypeError(`Removed resolver option: ${i}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=n.cacheTime,this._readOnly=n.readOnly,this._asBag=n.asBag,this._retryPolicy=n.retryPolicy,this._kw={};let s=this.constructor.internalParams;for(let[i,o]of Object.entries(n))s.has(i)||(this._kw[i]=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,...n}=e;if(t)return this._node?this._node._value:this.cachedValue;let s={...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)||(s[c]=d)}Object.assign(s,n);let i=this._computeEffectiveFingerprint(s);if(i===this._lastEffectiveFingerprint&&!this.expired)return this.cachedValue;this._lastEffectiveFingerprint=i;let o=xp(this),a=()=>this.load(s);if(o)return Cp(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=r._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){r._BagClass=e}load(e){return null}};Z._BagClass=null;var jt=class extends Z{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 Fe=class r{constructor(e,t,n=null,s=null,i=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,s&&this.setAttr(s,!1,!0,l),n!==null&&this.setValue(n,!1),i&&(this.resolver=i)}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,n={}){if(t!==null){let s=P(`${t}::QS`);if(Array.isArray(s)){let i=s.length?s:Object.keys(this._attr),o=i.map(l=>{let u=this.getAttr(l);return!e&&u instanceof Z?u.resolve():u}),a=l=>s.length===0?Object.fromEntries(i.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return o.some(l=>l&&typeof l.then=="function")?Promise.all(o).then(a):a(o)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");n={...n,...s}}}return this._resolver!==null?this._resolver.resolve({static:e,...n}):this._value}setValue(e,t=!0,n=null,s=null,i=!0,o=null,a=!1){e instanceof Z?(this.resolver=e,e=null):e instanceof r&&(n=n||{},Object.assign(n,e._attr),e.resolver&&(this.resolver=e.resolver),e=e._value);let l=this._value;l!==e&&l?.parentNode===this&&l.setBackref(),this._value=e;let u=l!==this._value,c=t??!0,d=null;if(n!==null){let h={...this._attr};this.setAttr(n,!1,s,i);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 r))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 n=null;e.resolver&&(n=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),n._node=null,n._kw={...e.resolver._kw});let s=this._value,i={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=n,this.setValue(t,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(i,this._attr),l=Object.keys(a).length?a:null,u=s!==t||o!==n;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:s,attrs_diff:l}:{oldvalue:s};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,s,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 n={},s=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of s){let o=i in e?e[i]:null,a=i in t?t[i]:null;o!==a&&(n[i]={old:o,new:a})}return n}setAttr(e=null,t=!0,n=!0,s=!0){let i=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=t&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(n?Object.assign(this._attr,i):this._attr={...i},s)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 n of t.split(","))delete this._attr[n.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 n=this;if(t===null)for(;n&&!(e in n._attr);)n=n.parentNode;else for(;n&&n._attr[e]!==t;)n=n.parentNode;return n}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof r)||this.label!==e.label)return!1;let t=Object.keys(this._attr),n=Object.keys(e._attr);if(t.length!==n.length)return!1;for(let s of t)if(this._attr[s]!==e._attr[s])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),n=Object.keys(e._attr);return t.length!==n.length||t.some(s=>this._attr[s]!==e._attr[s])?`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 yn=class r{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(n=>n.label===e);let t=e.match(/^#(\d+)$/);if(t){let n=parseInt(t[1],10);return n<this._list.length?n:-1}if(t=e.match(/^#(\w*)=(.*)$/),t){let[,n,s]=t,i=s.includes("::")?P(s):s;return n?this._list.findIndex(o=>o.getAttr(n)===i):this._list.findIndex(o=>o._value===i)}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 n=this._parseSharpIndex(e.slice(1),e);return Math.min(n,t)}if(e.startsWith("<")){let n=e.slice(1);if(n.startsWith("#")){let i=this._parseSharpIndex(n.slice(1),e);return Math.min(i,t)}let s=this.index(n);if(s<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return s}if(e.startsWith(">")){let n=e.slice(1);if(n.startsWith("#")){let i=this._parseSharpIndex(n.slice(1),e);return Math.min(i+1,t)}let s=this.index(n);if(s<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return s+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 n=parseInt(e,10);if(n<0)throw new Error(`Invalid node_position '${t}': negative index not allowed in '#n' syntax`);return n}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let t=this.index(e);return t>=0?this._list[t]:null}return this._dict[e]||null}set(e,t,n=">",s=null,i=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)s={[m[0]]:t};else{if(!Array.isArray(t)||t.length!==m.length)throw new Error("Wrong attributes assignment");s={};for(let g=0;g<m.length;g++)s[m[g]]=t[g]}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(s,c,!0,l):p.setValue(t,c,s,a,l,u,d);else{let m=i&&i.nodeClass?i.nodeClass:Fe;p=new m(i,e,h?null:t,s,o,f,null,l);let g=this._parsePosition(n);this._dict[e]=p,this._list.splice(g,0,p),c&&i&&i.backref&&i._onNodeInserted(p,g,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 n=this._list.indexOf(t);return n>=0&&this._list.splice(n,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,n=!0){if(t<0)return;let s=Array.isArray(e)?e:[e];if(s.length===0||t>=this._list.length)return;let i=this._list[t].label;if(s.length>1){let o=[...s].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),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(i);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=s[0];if(o===t||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(t,0,a),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,t)}}isEqual(e){if(!(e instanceof r)||this._list.length!==e._list.length)return!1;for(let t=0;t<this._list.length;t++){let n=this._list[t],s=e._list[t];if(!n.isEqual(s))return!1}return!0}};var du=oa(go(),1);var Do="::RSLV:",Np=new Map,Ip=new Map,Hs=new WeakMap,re=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},vn=class extends Z{constructor(e){super({asBag:!1}),Hs.set(this,e)}get payload(){return Hs.get(this)}load(){throw new re("This resolver is opaque; local execution is unavailable")}};function lu(r){if(!r||typeof r!="object"||Array.isArray(r)||typeof r.resolver_module!="string"||typeof r.resolver_class!="string"||!Array.isArray(r.args??[])||!r.kwargs||typeof r.kwargs!="object"||Array.isArray(r.kwargs))throw new re("Invalid resolver description")}function uu(r,e=new Set){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(typeof r!="object"||e.has(r)||!Array.isArray(r)&&Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)throw new re("Resolver parameters must be JSON data; callbacks cannot travel");e.add(r);for(let t of Object.values(r))uu(t,e);e.delete(r)}}function En(r){if(Hs.has(r))return Hs.get(r);let e=Ip.get(r.constructor);if(!e)throw new re(`Unregistered resolver: ${r.constructor.name}`);let t=e.encode(r),n={resolver_module:e.module,resolver_class:e.name,args:t.args??[],kwargs:t.kwargs??{}};return lu(n),uu(n),Do+JSON.stringify(n)}function zs(r){if(typeof r!="string"||!r.startsWith(Do))return null;let e=r.slice(Do.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new vn(r);let t;try{t=JSON.parse(e)}catch{throw new re("Invalid resolver JSON or signed token")}lu(t);let n=Np.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!n)return new vn(r);let s=n.decode({args:t.args??[],kwargs:t.kwargs});if(!(s instanceof n.cls))throw new re("Resolver decoder returned an incompatible instance");return s}function Ws(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[e,t instanceof Z?En(t):t]))}function So(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[e,zs(t)??t]))}var je="__cls";function Nr(r,e){return r!==null&&r.tytxSuffix===e?r:wn(e)}function Op(r){let e=r.tytxSuffix,t=Object.entries(Re(e)).filter(([,n])=>n===r).map(([n])=>n);if(t.length===0)throw new re(`${r.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new re(`${r.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function Co(r,e){let t=Re(r);if(!Object.hasOwn(t,e))throw new re(`Unknown Bag class '${e}' for TYTX type '${r}'`);return t[e]}function No(r,e){return r===e?null:Op(r)}function*fu(r,e=[]){for(let t of r){let n=[...e,t.label];yield[n,t];let s=t.getValue(!0);!t.resolver&&s instanceof C&&(yield*fu(s,n))}}function Bp(r){let e=r.toISOString(),t=r.getUTCFullYear()===1970&&r.getUTCMonth()===0&&r.getUTCDate()===1,n=r.getUTCHours()===0&&r.getUTCMinutes()===0&&r.getUTCSeconds()===0&&r.getUTCMilliseconds()===0;if(n&&!t)return e.slice(0,e.indexOf("T"));let s=e.replace(/\.000Z$/,"Z");return t&&!n?s.slice(s.indexOf("T")+1):s}function Ir(r){if(r===null||typeof r!="object")return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function At(r){return typeof r=="string"?r.includes("::")?`${r}::T`:r:Array.isArray(r)?r.map(At):Ir(r)?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,At(t)])):r}function Io(r){if(!Ir(r))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=r;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var cu=!1,C=class r{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new yn,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Io(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 Fe}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=[],n=e;for(;n!==null;){if(n.parentBag===this)return t.push(n.label),t.reverse(),t.join(".");t.push(n.label),n=n.parentNode}return null}get length(){return this._nodes.length}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}get attributes(){return this._parentNode!==null?this._parentNode.getAttr():{}}get rootAttributes(){return this._rootAttributes}set rootAttributes(e){this._rootAttributes=e!==null?{...e}:null}_htraverseBefore(e){let t=this,n;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),n=e.split(".").filter(s=>s)):n=[...e];n.length&&n[0]==="#parent"&&t!==null;)n.shift(),t=t.parent;return[t,n]}_htraverse(e,t=!1,n=!0){let[s,i]=this._htraverseBefore(e);if(s===null)return[null,null];if(i.length===0)return[s,""];for(;i.length>1&&s instanceof r;){let o=i[0];if(o==="#parent"){if(s.parent===null||s.parent===void 0)break;i.shift(),s=s.parent;continue}let a=s._nodes.get(o);if(!a)break;let l=a.getValue(n);if(l instanceof r)i.shift(),s=l;else if(t){let u=s.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),i.shift(),s=u}else break}if(!t)return i.length>1?[null,null]:[s,i[0]];for(;i.length>1;){let o=i.shift();if(o.startsWith("#"))throw new kn("Not existing index in #n syntax");let a=s.createChildBag();s._nodes.set(o,a,">",null,s,null,!1,!0,"autocreate"),s=a}return[s,i[0]]}get(e,t=null,n=!0,s={}){if(!e)return this;if(e==="#parent")return this.parent;let i=null;e.includes("?")&&([e,i]=e.split("?",2));let o=this._nodes.get(e);return o?o.getValue(n,i,s):t}getItem(e,t=null,n=!1,s={}){if(!e)return this;let[i,o]=this._htraverse(e,!1,n);return i instanceof r?i.get(o,t,n,s):t}setItem(e,t,n=null,s=">",i=!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,s,n,f,c,i,o,a,u,l,d)}_pop(e,t=null){let n=this._nodes.index(e);if(n>=0){let s=this._nodes.pop(n);return this.backref&&this._onNodeDeleted(s,n,t),s}return null}pop(e,t=null,n=null){let s=this.popNode(e,n);return s?s.value:t}delItem(e,t=null,n=null){return this.pop(e,t,n)}popNode(e,t=null){let[n,s]=this._htraverse(e,!1,!0);if(!n||!s)return null;let i=n._nodes.get(s);if(!i)return null;try{return n._pop(s,t)}finally{i.parentBag===n&&n._nodes._dict[i.label]!==i&&(i.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,n=!1,s=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[i,o]=this._htraverse(e,n,t);if(i instanceof r&&o){let a=i._nodes.get(o);if(a)return a;if(n)return i._nodes.set(o,s,">",null,i,null,!1,!0,"autocreate"),i._nodes.get(o)}return null}setBackref(e=null,t=null){let n=this._backref;if(this._backref=!0,this._parent=t,this._parentNode=e,!n){this._nodes._parentBag=this;for(let s of this)s.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 r&&t.clearBackref()}}}_onNodeChanged(e,t,n,s=null,i=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:s,attrs_diff:i,evt:n,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],n,s,i,o,a)}_onNodeInserted(e,t,n=null,s=null,i=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof r&&a.setBackref(e,o),n===null&&(n=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:n,ind:t,evt:"ins",reason:s,fired:i});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...n],s,i)}_onNodeDeleted(e,t,n=null,s=null){for(let i of Object.values(this._delSubscribers))i({node:e,pathlist:n,ind:t,evt:"del",reason:s});this._parent&&this._parentNode&&(n===null&&(n=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...n],s))}_subscribe(e,t,n){n!=null&&(t[e]=n)}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:n=null,insert:s=null,delete:i=null,any:o=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,n||o),this._subscribe(e,this._insSubscribers,s||o),this._subscribe(e,this._delSubscribers,i||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:n=!1,insert:s=!1,delete:i=!1,any:o=!1}=t;(n||o)&&delete this._updSubscribers[e],(s||o)&&delete this._insSubscribers[e],(i||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,n=!0){let s=r.prototype.getNode.call(this,e,!0,!0);s&&s.setAttr(t,!0,!0,n)}getAttr(e=null,t=null,n=null){let s=this.getNode(e);return s?s.getAttr(t,n):n}delAttr(e=null,...t){let n=this.getNode(e);n&&n.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 n of this._nodes){let s=n.value;if(s instanceof r){if(s.getItem(e)===t)return n}else if(s&&s.get&&s.get(e)===t)return n}return null}getNodeByAttr(e,t,n=!1,s=!1){let i=t===void 0,o=n&&typeof t=="string"?t.toLowerCase():t,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let d=n&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(i||d==o)return c}if(c._value instanceof r)if(s){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 n of this._nodes){if(n._resolver!==null)return!1;let s=n.getValue(!0);if(s!=null&&!(e&&s===0)&&!(t&&s===""))return!1}return!0}query(e=null,t=null,n=!1,s=!1,i=!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,g,b)=>{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 y=b();return g&&y instanceof r?null:y}else if(p.startsWith("#v.")){let y=p.split(".").slice(1).join("."),w=b();return w&&w.getItem?w.getItem(y):null}else{if(p==="#__v")return h.getValue(!0);if(p.startsWith("#a")){let y=p.includes(".")?p.split(".").slice(1).join("."):null;return h.getAttr(y)}else{let y=b();return y&&y.getItem?y.getItem(p):null}}};function*f(){let h=0;function*p(m,g){for(let b of m._nodes){let y=g?`${g}.${b.label}`:b.label,w=!1,k,A=()=>(w||(k=b.getValue(l),w=!0),k);if((i&&o||(A()instanceof r?o:i))&&(t===null||t(b))&&(yield c.length===1?d(b,c[0],y,s,A):c.map(N=>d(b,N,y,s,A)),h++,a!==null&&h>=a))return;if(s){let N=A();if(N instanceof r&&(yield*p(N,y),a!==null&&h>=a))return}}}yield*p(u,"")}return n?f():[...f()]}getLeaves(){let e=[],t=(n,s)=>{for(let i of n._nodes){let o=s?`${s}.${i.label}`:i.label,a=i.getValue(!1);a instanceof r?t(a,o):e.push([o,a])}};return t(this,""),e}digest(e=null,t=null,n=!1){typeof t=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),n=t,t=null);let s=this.query(e,t,!1,!1,!0,!0,null,!1);if(n){if(!s||s.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let i=[...s];if(i.length&&Array.isArray(i[0])){let o=i[0].length,a=[];for(let l=0;l<o;l++)a.push(i.map(u=>u[l]));return a}return[i]}return[...s]}columns(e,t=!1){typeof e=="string"&&(e=e.split(","));let n=t?"#a.":"",s=e.map(i=>`${n}${i}`).join(",");return this.digest(s,null,!0)}sum(e="#v",t=!1,n=null){if(t!=null&&typeof t!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(n!=null&&typeof n!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let s=i=>{let o=0,a=!1;for(let l of this.query(i,n)){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(i=>s(i.trim())):s(e)}sort(e="#k:a"){let t=(s,i)=>s==null?[-1,""]:i&&typeof s=="string"?[0,s.toLowerCase()]:[0,s],n=(s,i)=>s[0]!==i[0]?s[0]-i[0]:s[1]<i[1]?-1:s[1]>i[1]?1:0;if(typeof e=="function")this._nodes._list.sort((s,i)=>{let o=e(s),a=e(i);return o<a?-1:o>a?1:0});else{let s=e.split(",");s.reverse();for(let i of s){let o,a;i.includes(":")?[o,a]=i.split(":",2):(o=i,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 r?f.getItem(o):f?f[o]:null;return t(h,u)};this._nodes._list.sort((d,f)=>{let h=n(c(d),c(f));return l?-h:h})}}return this}equalTo(e){return e instanceof r?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let t=null;e.includes("?")&&([e,t]=e.split("?",2));let n=this.getNode(e);return n===null?!1:t===null?!0:t.split("&").every(s=>s in n.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 n=this.getNode(e);n||(this.setItem(e,null),n=this.getNode(e)),n.resolver=t}setCallbackItem(e,t,n={}){let s=new jt({callback:t,...n});this.setResolver(e,s)}move(e,t,n=!0){this._nodes.move(e,t,n)}asDict(e=!1,t=!1,n=!1,s=!1){let i={};for(let o of this._nodes){let a=o.value;if(s&&a==null)continue;let l=o.label;e&&(l=String(l)),t&&(l=l.toLowerCase()),n&&a instanceof r&&(a=r.prototype.asDict.call(a,e,t,n,s)),Object.defineProperty(i,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return i}setdefault(e,t=null){let n=this.getNode(e);return n?n.value:(this.setItem(e,t),t)}deepcopy(e=!1){let t=this.createChildBag();for(let n of this._nodes){let s=n.getValue(!e);s instanceof r&&(s=s.deepcopy(e));let i=new t.nodeClass(t,n.label,s);i.setAttr({...n.attr},!1,!1,!1),i.nodeTag=n.nodeTag,i.xmlTag=n.xmlTag,t._nodes._list.push(i),t._nodes._dict[i.label]=i}return t}update(e,t=null,n=null,s=!1){if(!(e instanceof r)){for(let i in e){let o=e[i];(!s||o!==null||!this._nodes.has(i))&&this.setItem(i,o,null,">",!1,!1,n,!1,n!==!1)}return}for(let i of[...e]){let o=i.label,a=t==="static"?i.resolver:null,l=a?null:i.getValue(),u=i.attr.__replace;delete i.attr.__replace;let c=this._nodes.get(o);if(c)if(c.setAttr(i.attr,n===null?!0:n,!0,!1),i.nodeTag!=null&&(c.nodeTag=i.nodeTag),i.xmlTag!=null&&(c.xmlTag=i.xmlTag),a)c.resolver=a,c.setValue(null,n===null?!0:n,null,null,!1,n);else{i.resolver&&(c.resolver=null);let d=c.getValue();l instanceof r&&d instanceof r&&!u?d.update(l,t,n,s):(!s||l!==null)&&c.setValue(l,n===null?!0:n,null,null,!1,n)}else{let d=this.setItem(o,a||l,i.attr,">",!1,!1,n,!1,n!==!1);d.nodeTag=i.nodeTag,d.xmlTag=i.xmlTag}}}_fillFromBag(e){this.clear();for(let t of e){let n=new this.nodeClass(this,t.label);n.replace(t),n.nodeTag=t.nodeTag,n.xmlTag=t.xmlTag,this._nodes._list.push(n),this._nodes._dict[n.label]=n}}_appendLiteral(e,t,n=null,s=null,i=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let o=new this.nodeClass(this,e,null,n,s,i,null,!1);return t instanceof Z?o.resolver=t:o._value=t,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,t={}){let n=Io(t);if(e!=null&&!Ir(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let s=this.createChildBag(),i=new Set,o=(a,l,u)=>{if(i.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);i.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;n&&(Ir(p)||Array.isArray(p))&&(p=this.createChildBag(),o(p,h,`${u}[${JSON.stringify(f)}]`)),a._appendLiteral(f,p)}}finally{i.delete(l)}};return e!=null&&o(s,e,"$"),this._replacePrepared(s)}_loadSource(e,t={}){return this.fillFrom(e,t)}replace(e){if(!(e instanceof r))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 n of this._nodes){n.parentBag=null;let s=n.getValue(!0);s instanceof r&&s.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 n of this._nodes)n.parentBag=this;for(let n of e._nodes)n._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:t=!0,deep:n=!1,kwargs:s={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let i=(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&&n){let f=u.getValue(t);if(f instanceof r){let h=i(f,c);if(h)return h}}}return null};return i(this,s)}*traverse(){for(let e of this._nodes){yield e;let t=e.getValue(!0);t instanceof r&&(yield*t.traverse())}}*_iterNodesWithPaths(e=!0,t=""){for(let n of this._nodes){let s=t?`${t}.${n.label}`:n.label;yield[s,n];let i=n.getValue(e);i instanceof r&&(yield*i._iterNodesWithPaths(e,s))}}*_nodeFlattener(e=null){let t=e!==null,n=t?Object.create(null):null,s=0,i=new Map([["[]",this.constructor]]);for(let[o,a]of fu(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=En(a.resolver);else if(d instanceof r){let g=d.constructor,b=g.tytxSuffix;i.set(u,g),h=No(g,Nr(i.get(c),b)),f=`::${b}`}else d===null?f="::NN":f=At(d);if(a.attr&&Object.hasOwn(a.attr,je))throw new re(`node '${o}': the attribute '${je}' is reserved for the Bag class name`);let p=Ws(At(a.attr));h!==null&&(p[je]=h);let m=a.nodeTag;t?(yield[l.length?n[c]:null,a.label,m,f,p],d instanceof r&&(n[u]=s,e[s]=o,s++)):yield[l,a.label,m,f,p]}}toTytx(e="json",t=!1){let n=this._toTytxPayload(t),s=this.constructor.tytxSuffix;if(e==="json")return`${n}::${s}`;if(e==="msgpack")return bs(new Le(4,new TextEncoder().encode(`${s}:${n}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let i={};t={rows:[...this._nodeFlattener(i)],paths:i}}else t={rows:[...this._nodeFlattener(null)]};let n=this.constructor,s=No(n,Nr(null,n.tytxSuffix));return s!==null&&(t[je]=s),t.rows=t.rows.map(([i,o,a,l,u])=>[At(i),At(o),At(a),l,u]),t.paths&&(t.paths=At(t.paths)),W(t)}static fromTytx(e,t="json",n={}){if(Ir(t)&&(n=t,t="json"),Io(n),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 s=P(e,t==="json"?null:t);if(s instanceof r)return s;if(!Ir(s)&&!Array.isArray(s))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(s,n)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Nr(null,t));let n=P(e);if(!n||!Array.isArray(n.rows))throw new re("Invalid TYTX Bag: expected rows");let s=n.paths,i=s!=null,o=Object.hasOwn(n,je)?Co(t,n[je]):Nr(null,t),a=new o,l=new Map([["[]",a]]);for(let u of n.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(i){if(c!==null&&!Object.hasOwn(s,c))throw new re(`Unknown TYTX parent reference: ${c}`);m=c===null?"":s[c]}if(typeof m=="string"&&(m=m?m.split("."):[]),!Array.isArray(m))throw new re("Invalid TYTX parent path");let g=JSON.stringify(m);if(!l.has(g))throw new re(`Missing or undecodable TYTX parent branch: ${m}`);let b=l.get(g),y=JSON.stringify([...m,d]),w=h,k=zs(w),A=So(p),v=Object.hasOwn(A,je)?A[je]:null;if(delete A[je],w instanceof r){let L=w.constructor.tytxSuffix,U=v!==null?Co(L,v):Nr(b.constructor,L);w=new U,l.set(y,w)}else if(v!==null)throw new re(`node '${y}': the attribute '${je}' is reserved for the Bag class name of a branch`);let N=b._appendLiteral(d,k?null:w,A,k);N.nodeTag=f??null}return a}toXml(e={}){let{pretty:t=!1,encoding:n="UTF-8",docHeader:s=null,selfClosedTags:i=null}=e,o=this._bagToXml(i,t);return s===!0?o=`<?xml version='1.0' encoding='${n}'?>
|
|
16
|
-
${o}`:typeof
|
|
17
|
-
${o}`),o}_bagToXml(e=null,t=!1,
|
|
18
|
-
`:"")}_nodeToXml(e,t=null,
|
|
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}'?>
|
|
16
|
+
${o}`:typeof i=="string"&&(o=`${i}
|
|
17
|
+
${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}>
|
|
19
19
|
${f}
|
|
20
|
-
${" ".repeat(
|
|
21
|
-
`)}toString(e=!0,t=null,
|
|
22
|
-
`)}},kn=class extends Error{constructor(e){super(e),this.name="BagException"}};Z.registerBagClass(C);xo(C,"X",r=>r._toTytxPayload(),r=>C._fromTytxPayload(r));Ft(C.tytxSuffix,{...Re(C.tytxSuffix),Bag:C});var hu=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 pu(r){return r.endsWith("_")&&hu.has(r.slice(0,-1))?r.slice(0,-1):r}function mu(r){let e=pu(r);return e!==r?e:r.startsWith("_")&&hu.has(r.slice(1))?r.slice(1):r}function An(r,{renderTag:e=null,ns:t=null,dialectName:n=null}={}){let s=e||r;if(!s)return s;if(s=pu(s),t&&!e){let i=`${n}_`;s.startsWith(i)&&(s=s.slice(i.length)),s=`${t}:${s}`}return s}var Or=Symbol("value"),Ut=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function he(r){return Object.entries(r||{}).filter(([e])=>!Ut.has(e)).map(([e,t])=>[mu(e),t])}var we=class extends Fe{constructor(e,t,n=null,s=null,i=null,o=null,a=null){super(e,t,n,s,i,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")||{},n=e.split(",").map(s=>s.trim());return n.length===1?t[n[0]]!==void 0?t[n[0]]:null:n.map(s=>t[s]!==void 0?t[s]: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,n]of Object.entries(this.getAttr()||{}))this.pointerType(n)==="^"&&e.push([t,n.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(Or,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(V(e)?.pointer??e).slice(1));let n=null;return e.includes("?")&&([e,n]=e.split("?",2)),e.startsWith("#")?this._finalizeAbsPath(this._resolveSymbolicDatapath(e,t),n):(e.startsWith(".")&&(e=this._composeRelativeDatapath(e,t)),this._finalizeAbsPath(e,n))}_finalizeAbsPath(e,t){return e=this._collapseParentDatapath(e,e),t?`${e}?${t}`:e}_composeRelativeDatapath(e,t){let n=this;for(;n!==null&&e.startsWith(".");){let s=n.getAttr("datapath");s!=null&&(e=e==="."?s:s+e),n=n.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let n=[];for(let s of e.split("."))if(s==="#parent"){if(n.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);n.pop()}else n.push(s);return n.join(".")}_resolveSymbolicDatapath(e,t){let n=e.slice(1),s=n.indexOf("."),i=s===-1?n:n.slice(0,s),o=s===-1?"":n.slice(s+1),a;if(i==="FORM")a=this._findMarkedDatapathAncestor(!0,!1,t);else if(i==="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",i),a==null)throw new Error(`#<id>: cannot resolve ${t}`)}return a.absDatapath(o?`.${o}`:".")}_findMarkedDatapathAncestor(e,t,n){let s=this;for(;s!=null;){let o=s.getAttr()||{};if(e&&(o.formId!=null||o.form===!0)||t&&"_anchor"in o)return s;s=s.parentNode}let i=e?"FORM":"ANCHOR";throw new Error(`#${i}: no marked ancestor found for ${n}`)}getRelativeData(e,t=null,{autocreate:n=!1}={}){let s=this.data,i=this.absDatapath(e);return n&&s.getItem(i)==null&&s.setItem(i,t),s.getItem(i,t)}setRelativeData(e,t,{attributes:n=null,fired:s=!1,reason:i=null}={}){let o=this.data,a=this.absDatapath(e);o.setItem(a,t,n,">",!1,!0,i===null?!0:i,s)}fireEvent(e,t=!0,{attributes:n=null,reason:s=null}={}){this.setRelativeData(e,t,{attributes:n,fired:!0,reason:s})}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})}},D=class r extends C{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return we}_setBuilderItem(e,t,n,...s){let i=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(n,...s)}catch(a){if(this.node(n)==null&&i)for(let[l,u]of i)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[n,s]of t)n._builder=s;return this.setBackref(),this}_builderBindingPlan(e){let t=[],n=new WeakSet,s=(i,o)=>{if(n.has(i))throw new Error("source contains a cyclic or shared SourceBag branch");n.add(i),t.push([i,o]);for(let a of i.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 r&&s(c,l)}};return s(this,e),t}};if((Re(D.tytxSuffix).SourceBag??D)!==D)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Ft(D.tytxSuffix,{...Re(D.tytxSuffix),SourceBag:D});function Lp(r){if(r.length===0)return{value:null,attrs:{}};let e=r[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:r[1]||{}}}var Pp=new Set(["then","toJSON"]),bu=new WeakMap;function te(r){return bu.get(r)||r}function Tn(r){if(r==null)return r;r=te(r);let e=r._builder||r.parentBag&&r.parentBag._builder;return e?e.wrapSource(r):r}function _u(r,e){let t=e instanceof C,n=new Proxy(e,{get(s,i){if(typeof i=="symbol"||i.startsWith("_")||Pp.has(i))return Reflect.get(s,i,s);let o=r.schemaTag(i);if(t&&o)return gu(r,s,o,t);if(i in s){let l=Reflect.get(s,i,s);return typeof l=="function"?l.bind(s):l}if(o)return gu(r,s,o,t);let a=r.containerMethod(i);if(a)return(...l)=>r[a](r.wrapSource(s),...l)}});return bu.set(n,e),n}function gu(r,e,t,n){return(...s)=>{let{value:i,attrs:o}=Lp(s),a=n?r.bagCall(e,t,i,o):r.commandOnNode(e,t,i,o);return a.builder.wrapSource(a)}}function Oo(r,e,{transport:t="json"}={}){let n=P(r,t==="json"?null:t);if(!(n instanceof D))throw new TypeError("TYTX payload did not decode to SourceBag");return n.bindBuilder(e)}var yu=/^[A-Za-z_][A-Za-z0-9_]*$/,Fp=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),jp=new Set(["framework","value","attribute"]),Up=new Map([["builtins.str",r=>typeof r=="string"],["builtins.int",r=>Number.isInteger(r)],["builtins.float",r=>typeof r=="number"&&Number.isFinite(r)],["builtins.bool",r=>typeof r=="boolean"],["builtins.list",r=>Array.isArray(r)],["builtins.dict",r=>r!==null&&typeof r=="object"&&!Array.isArray(r)],["builtins.tuple",r=>Array.isArray(r)],["builtins.set",r=>Array.isArray(r)||r instanceof Set],["builtins.NoneType",r=>r===null],["builtins.object",r=>!0]]);function Vt(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function T(r,e){throw new TypeError(`${r}: ${e}`)}function Ke(r,e,t,n){Vt(r)||T(n,"must be an object");for(let s of Object.keys(r))e.includes(s)||T(n,`unknown field '${s}'`);for(let s of t)Object.hasOwn(r,s)||T(n,`missing field '${s}'`)}function Ht(r,e){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(Array.isArray(r))return r.forEach((t,n)=>Ht(t,`${e}[${n}]`));if(Vt(r))return Object.entries(r).forEach(([t,n])=>Ht(n,`${e}.${t}`));T(e,"must be lossless JSON data")}}function qp(r,e){let t="",n=!1;for(let s=0;s<r.length;s++){let i=r[s];if(i==="\\"){t+=i+(r[++s]??"");continue}i==="["&&(n=!0),!n&&i==="."&&!(e&16)?t+="[^\\n]":!n&&i==="^"&&e&8?t+="(?:^|(?<=\\n))":!n&&i==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=i,i==="]"&&(n=!1)}return t}function qt(r,e,t=!1,n=null){if(r===null)return null;switch(Ke(r,["kind","dtype","module","name","origin","arguments","items","values","base","metadata","pattern","flags","ge","le","gt","lt","value"],["kind"],e),r.kind){case"custom":return Ke(r,["kind","name"],["kind","name"],e),n||T(e,"custom references require a catalog; nested catalog references are unsupported"),n.resolve(r.name,e);case"dtype":{Ke(r,["kind","dtype"],["kind","dtype"],e);let s=r.dtype;typeof s!="string"&&T(e,"dtype must be a string");let i=wn(s);return!i&&s!=="NN"&&T(e,`unknown dtype '${s}'`),{...r,test:a=>s==="NN"?a===null:s==="N"?fe(a)&&!["NaN","Infinity","-Infinity"].includes(a.toString()):i===Number?typeof a=="number"&&Number.isFinite(a)&&(s!=="L"||Number.isInteger(a)):i===String?typeof a=="string":i===Boolean?typeof a=="boolean":i===Date?a instanceof Date&&Number.isFinite(a.getTime()):i===Object?Vt(a)&&[Object.prototype,null].includes(Object.getPrototypeOf(a)):a instanceof i}}case"any":return{...r,test:s=>!0};case"type":{(typeof r.module!="string"||typeof r.name!="string")&&T(e,"type requires string module/name");let s=`${r.module}.${r.name}`;if(s==="collections.abc.Callable")return{...r,test:o=>typeof o=="function",portable:!1};let i=Up.get(s);return i||T(e,`unsupported type '${s}'`),{...r,test:i}}case"union":{(!Array.isArray(r.items)||!r.items.length)&&T(e,"union items must be non-empty");let s=r.items.map((i,o)=>qt(i,`${e}.items[${o}]`,!0,n));return{...r,items:s,inputConstraint:s.some(i=>i.inputConstraint),test:i=>s.some(o=>o.test&&o.test(i))}}case"literal":return Array.isArray(r.values)||T(e,"literal values must be an array"),r.values.forEach((s,i)=>Ht(s,`${e}.values[${i}]`)),{...r,test:s=>r.values.some(i=>Object.is(i,s))};case"annotated":{Array.isArray(r.metadata)||T(e,"annotated metadata must be an array"),r.metadata.some(o=>!["regex","range","value"].includes(o?.kind))&&T(e,"unsupported annotation metadata kind");let s=qt(r.base,`${e}.base`,!0,n),i=r.metadata.map((o,a)=>qt(o,`${e}.metadata[${a}]`,!0,n));return{...r,base:s,metadata:i,inputConstraint:s.inputConstraint,test:o=>s.test(o)&&i.every(a=>!a.test||a.test(o))}}case"range":{for(let s of["ge","le","gt","lt"])Object.hasOwn(r,s)||T(e,`range missing '${s}'`);for(let s of["ge","le","gt","lt"])r[s]!==null&&(typeof r[s]!="number"||!Number.isFinite(r[s]))&&T(e,`${s} must be finite number or null`);return{...r,test:s=>typeof s=="number"&&(r.ge===null||s>=r.ge)&&(r.le===null||s<=r.le)&&(r.gt===null||s>r.gt)&&(r.lt===null||s<r.lt)}}case"regex":{(typeof r.pattern!="string"||!Number.isInteger(r.flags)||r.flags<0)&&T(e,"regex requires pattern and non-negative integer flags");let s=r.flags&-59;s&&T(e,`unsupported Python regex flags ${s}`),r.flags&2&&T(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(r.pattern.replaceAll(String.raw`[\s\S]`,"."))&&T(e,"regex uses a non-portable construct or character class");let i="uy";r.flags&16&&(i+="s");let o;try{o=new RegExp(`(?:${qp(r.pattern,r.flags)})(?![\\s\\S])`,i)}catch(a){T(e,`invalid portable regex: ${a.message}`)}return{...r,test:a=>typeof a!="string"?!1:(o.lastIndex=0,o.test(a))}}case"value":return Ht(r.value,`${e}.value`),{...r};case"generic":{let s=qt(r.origin,`${e}.origin`,!0,n);(r.origin?.kind!=="type"||r.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(r.origin.name))&&T(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(r.arguments)||T(e,"generic arguments must be an array");let i=r.arguments.map((o,a)=>qt(o,`${e}.arguments[${a}]`,!0,n));return{...r,origin:s,arguments:i,inputConstraint:i.some(o=>o.inputConstraint),test:o=>s.test(o)&&Vp(r.origin,i,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"),{...r};default:T(e,`unknown annotation kind '${r.kind}'`)}}function Vp(r,e,t){let n=`${r.module}.${r.name}`;return n==="builtins.tuple"&&e.length&&e[1]?.kind!=="ellipsis"?t.length===e.length&&t.every((s,i)=>e[i].test(s)):n==="builtins.list"||n==="builtins.set"||n==="builtins.tuple"?[...t].every(s=>!e[0]?.test||e[0].test(s)):n==="builtins.dict"?Object.entries(t).every(([s,i])=>(!e[0]?.test||e[0].test(s))&&(!e[1]?.test||e[1].test(i))):!1}function vu(r,e){if(r===null)return null;if(typeof r!="string"&&T(e,"must be string or null"),r==="")return new Map;let t=new Map;for(let n of r.split(",")){let s=n.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(s)&&T(e,`invalid cardinality item '${n}'`);let i=s.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);i||T(e,`invalid cardinality item '${n}'`);let[,o,a,l,u]=i;t.has(o)&&T(e,`duplicate tag '${o}'`);let c=0,d=1/0;s.includes("[")&&(s.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 Eu(r,e){if(r===null)return null;typeof r!="string"&&T(e,"must be string or null");let t=new Set;for(let n of r.split(",")){let s=n.trim();s&&((!yu.test(s)||t.has(s))&&T(e,`invalid or duplicate parent '${n}'`),t.add(s))}return t}function Hp(r,e,t){if(r===null)return null;Ke(r,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let n=r.parameters??[];Array.isArray(n)||T(e,"parameters must be an array"),r={parameters:n,accepts_var_keyword:n.some(l=>l.kind==="var_keyword"),accepts_var_positional:n.some(l=>l.kind==="var_positional"),...r},(!Array.isArray(r.parameters)||typeof r.accepts_var_keyword!="boolean"||typeof r.accepts_var_positional!="boolean")&&T(e,"invalid signature descriptor");let s=new Set,i=!1,o=!1,a=r.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"||!yu.test(l.name)||s.has(l.name))&&T(c,"invalid or duplicate parameter name"),s.add(l.name),(!Fp.has(l.kind)||!jp.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&&Ht(l.default,`${c}.default`),i||=l.kind==="var_keyword",o||=l.kind==="var_positional",{...l,annotation:qt(l.annotation,`${c}.annotation`,!1,t)}});return(i!==r.accepts_var_keyword||o!==r.accepts_var_positional)&&T(e,"variadic summary flags do not match parameters"),{...r,parameters:a}}function wu(r,e,t,n){let s=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];Ke(r,s,[],e),r={...Object.fromEntries(s.map(i=>[i,null])),...r};for(let i of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])r[i]!==null&&typeof r[i]!="string"&&T(e,`${i} must be string or null`);return r._meta!==null&&(Vt(r._meta)||T(e,"_meta must be object or null"),Ht(r._meta,`${e}._meta`)),vu(r.sub_tags,`${e}.sub_tags`),Eu(r.parent_tags,`${e}.parent_tags`),{...r,attributes:Hp(r.attributes,`${e}.attributes`,n)}}function ku(r){return r?r.split(",").map(e=>e.trim()).filter(Boolean):[]}function Au(r,e){let t={...e};for(let[n,s]of Object.entries(r))n==="inherits_from"||n.startsWith("_")||t[n]||(t[n]=s);return t._meta={...r._meta||{},...e._meta||{}},t}function Tu(r){let e={...r};return e._subSpec=Object.hasOwn(e,"sub_tags")?vu(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?Eu(e.parent_tags,"resolved.parent_tags"):null,e}function xu(r,e,t,n){if(t.get(r)===1&&T(n,`inheritance cycle at '${r}'`),t.get(r)===2)return e[r];let s=e[r];s||T(n,`unknown abstract '${r}'`),t.set(r,1);let i={...s};for(let o of ku(s.inherits_from))i=Au(xu(o,e,t,n),i);return i=Tu(i),t.set(r,2),e[r]=i,i}function Bo({abstracts:r={},elements:e={}}){let t={...r},n=new Map;for(let i of Object.keys(t))xu(i,t,n,`abstracts.${i}.inherits_from`);let s={};for(let[i,o]of Object.entries(e)){let a={...o};for(let l of ku(o.inherits_from)){let u=t[l];u||T(`elements.${i}.inherits_from`,`unknown abstract '${l}'`),a=Au(u,a)}s[i]=Tu(a)}return{abstracts:t,elements:s}}function Ro(r){Ke(r,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),Ke(r.document_format,["name","version"],["name","version"],"document_format"),(r.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(r.document_format.version))&&T("document_format","expected builder_grammar version 1.1 or 1.2"),Ke(r.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof r.grammar.name!="string"||!r.grammar.name)&&T("grammar.name","must be non-empty string");for(let s of["version","title","description"])r.grammar[s]!==null&&typeof r.grammar[s]!="string"&&T(`grammar.${s}`,"must be string or null");(!Vt(r.abstracts)||!Vt(r.elements))&&T("grammar document","abstracts/elements must be objects"),Object.hasOwn(r,"custom_types")&&r.document_format.version!=="1.2"&&T("custom_types","requires version 1.2");let e=Br.fromJSON(r.custom_types??{}),t={};for(let[s,i]of Object.entries(r.abstracts))(!s||s.startsWith("_"))&&T("abstracts",`invalid public name '${s}'`),t[s]=wu(i,`abstracts.${s}`,!1,e);let n={};for(let[s,i]of Object.entries(r.elements))(!s||s.startsWith("_"))&&T("elements",`invalid public name '${s}'`),n[s]=wu(i,`elements.${s}`,!0,e);return{grammar:structuredClone(r.grammar),abstracts:t,elements:n}}function Du(r,e,t,n){let s=e.attributes;if(!s)return;let i={...n};t!=null&&(i.node_value=t);let o=new Set(s.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(!s.accepts_var_keyword)for(let u of Object.keys(n))!o.has(u)&&!a.has(u)&&T(r,`unknown attribute '${u}'`);let l=e._meta?.component?s.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of s.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(i,u.name);!c&&!u.has_default&&T(r,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(i[u.name]))&&T(r,`invalid value for ${u.role} '${u.name}'`)}}var Br=class r{#e=new Map;#t=new Map;register(e,t,n){let s=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),i=s.has(t)?{kind:"type",module:"builtins",name:s.get(t)}:t;return this.#r(e,{kind:"annotated",base:i,metadata:[n]})}#r(e,t){(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/.test(e)||e in this||["to_dict","from_dict"].includes(e)||zp.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 n=t.metadata[0].kind==="regex"?["str"]:["int","float"];(t.base?.kind!=="type"||t.base.module!=="builtins"||!n.includes(t.base.name))&&T(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Ht(t,`custom_types.${e}`);let s=structuredClone(t),i=qt(s,`custom_types.${e}`),o=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:o,enumerable:!0}),this.#e.set(e,s),this.#t.set(e,{...o,inputConstraint:!0,test:i.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){Vt(e)||T("custom_types","must be an object");let t=new r;for(let[n,s]of Object.entries(e))t.#r(n,s);return t}},zp=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 Su(r,e,t,n){let s=e?.attributes;if(s)for(let i of s.parameters){if(!i.annotation?.inputConstraint||i.role==="framework"||["var_keyword","var_positional"].includes(i.kind))continue;let o=i.role==="value"?t:n[i.name];o!==void 0&&(i.annotation.test(o)||T(r,`invalid input for '${i.name}' (custom type)`))}}function Cu(r,e,t=[]){if(e===null)return structuredClone(r);if(t.length===2&&t[0]==="custom_types"&&r!==void 0){if(!Mo(r,e))throw new TypeError(`conflicting custom type '${t[1]}'`);return structuredClone(r)}if(t.length===2&&["abstracts","elements"].includes(t[0]))return structuredClone(e);if(it(r)&&it(e)){let n=structuredClone(r);for(let[s,i]of Object.entries(e))i!==null&&Object.defineProperty(n,s,{value:Cu(n[s],i,[...t,s]),enumerable:!0,writable:!0,configurable:!0});return n}return structuredClone(e)}function Mo(r,e){return Object.is(r,e)?!0:Array.isArray(r)&&Array.isArray(e)?r.length===e.length&&r.every((t,n)=>Mo(t,e[n])):it(r)&&it(e)?Object.keys(r).length===Object.keys(e).length&&Object.keys(r).every(t=>Object.hasOwn(e,t)&&Mo(r[t],e[t])):!1}function it(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)&&Object.getPrototypeOf(r)===Object.prototype}function $o(r){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(Array.isArray(r)){r.forEach($o);return}if(it(r)){Object.values(r).forEach($o);return}throw new TypeError("collection must contain only finite JSON values")}}var ot=class r{#e;constructor(e){$o(e);let t=["document_format","grammar","abstracts","elements"];if(!it(e)||Object.keys(e).some(s=>![...t,"custom_types"].includes(s))||t.some(s=>!Object.hasOwn(e,s)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let n=e.document_format;if(!it(n)||Object.keys(n).length!==2||n.name!=="builder_grammar"||!["1.1","1.2"].includes(n.version))throw new TypeError("expected builder_grammar version 1.1 or 1.2");for(let s of["grammar","abstracts","elements"])if(!it(e[s]))throw new TypeError(`${s} must be an object`);if(Object.hasOwn(e,"custom_types")&&(n.version!=="1.2"||!it(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 r(e),n=Cu(this.#e,t.#e);return(this.#e.document_format.version==="1.2"||t.#e.document_format.version==="1.2")&&(n.document_format.version="1.2"),this.#e=n,this}toDocument(){return structuredClone(this.#e)}};var zt=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 n=e.getRenderer();return this.renders.set(e,n),n}render(e,t={}){let n=e.builder,[s,i]=n.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,i,t);let o=this.getRender(n),a;return[a,i]=o._handleMeta(e,i),e._getMeta("subbuilder")||(i=o.adaptAttrs(i)),e.value instanceof D&&(s=this.renderChildren(e.value,t)),o.renderedItem(e,s,i,{tag:a,...t})}renderChildren(e,t={}){let n=[];for(let s of e.getNodes()){let i=this.render(s,t);i!==null&&(Array.isArray(i)?n.push(...i):n.push(i))}return n}_renderComponent(e,t,n){let[s,i,o,a]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,s,o,a,n);if(i==null)return[];if(!(i instanceof C))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${i?.constructor?.name||typeof i}`);return i.getNodes().map(l=>this._expandBlock(e,s,o,{node_label:l.label},n))}_expansionInputs(e,t){let n=e.builder,s=n.componentMethod(e.nodeTag),i=s&&n[s];if(typeof i!="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[i,o,a,t]}_expandBlock(e,t,n,s,i){let o=e.builder._expansionRoot(n);t.call(e.builder,Tn(o),s);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={...i,depthOffset:this._nodeDepth(e,i.depthOffset||0)};return this.render(a[0],l)}preprocess(e){return e}renderedItem(e,t,n,s){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[n,s]=e._getMeta("render_tag,render_attributes"),i=An(e.nodeTag,{renderTag:n,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!i)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return s&&(t={...t,...s}),[i,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,n={}){let s=this._composeStringFragments(e);if(t==null)return s;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(s),null;if(typeof t.write=="function")return t.write(s),null;if(typeof t=="function")return t(s),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("&","&").replaceAll("<","<").replaceAll(">",">")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',""")}_nodeDepth(e,t=0){let s=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(s-1,0)+t}};var Wt=class extends zt{static mode="xml";renderedItem(e,t,n,{tag:s,pretty:i=!1,depthOffset:o=0}={}){let a=this._formatAttrs(n),l=i?" ".repeat(this._nodeDepth(e,o)):"",u=i?`
|
|
23
|
-
`:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${s}${a}>${u}${c}${l}</${s}>${u}`}return t==null?`${l}<${s}${a}></${s}>${u}`:`${l}<${s}${a}>${this._escapeText(t)}</${s}>${u}`}finalize(e,t=null,{docHeader:n=null}={}){let s=this._composeStringFragments(e);return n===!0?s=`<?xml version='1.0' encoding='UTF-8'?>${s}`:typeof n=="string"&&(s=n+s),super.finalize(s,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,n])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(n)}"`).join("")}};var Nu={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 Iu(r){let e=[];for(;r&&r!==Function.prototype;)e.push(r),r=Object.getPrototypeOf(r);return e.reverse()}function Gp(r){let e=Object.create(null),t=(n,s)=>{let i=n.toLowerCase(),o=e[i];if(o!==void 0&&o!==s)throw new Error(`container '${n}' is already tied to implementation method '${o}' (cannot rebind to '${s}')`);e[i]=s};for(let n of Iu(r))if(Object.hasOwn(n,"containers"))for(let s of n.containers||[])t(s,s);return e}function xn(r){let e=Object.create(null);for(let t of Object.keys(r)){let n=t.toLowerCase();if(Object.hasOwn(e,n))throw new Error(`element declaration '${t}' has a case-insensitive collision with '${e[n]}'`);e[n]=t}return e}var Dn="_root_",Sn="_root_",Ou=new Set(["destination","func","value","_on_start"]),ye=class r{static _sourceClass=D;static registerBuilder(e){if(typeof e!="function"||!(e.prototype instanceof r))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 n=r._registry.get(t);if(n&&n!==e)throw new Error(`Builder name '${t}' is already registered to ${n.name}; cannot register ${e.name}`);return r._registry.set(t,e),e}static getBuilderClass(e){let t=r._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 C,this._dataroot.setBackref(),this._dataroot.setItem(Sn,new C),this.data=this._dataroot.getItem(Sn),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(Dn,new t(null,this)),this.source=this._sourceroot.getItem(Dn)}wrapSource(e){if(e=te(e),!(e instanceof D)&&!(e instanceof we))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=_u(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 n=r.getBuilderClass(e);t=new n,this._subbuilders.set(e,t)}return t._dataroot=this._dataroot,t.data=this.data,t}_resolveSubbuilderReference(e,t,n){if(typeof e!="string"||!e)throw new Error(`'${n}': subbuilder declaration must be a non-empty string`);if(e.includes(":"))throw new Error(`'${n}': runtime subbuilder reference '${e}' is unsupported`);return this.getSubbuilder(e)}static defineGrammar(e){let t=this._classCollection,n=t?new ot(t.toDocument()).update(e):new ot(e),s=Ro(n.toDocument()),i=Bo(s),o=xn(i.elements);this._classCollection=n,this._classSchema=i.elements,this._abstracts=i.abstracts,this._tagNames=o}static{this.defineGrammar(Nu)}get _containers(){return Gp(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??=xn(this.schema):this.constructor._tagNames??=xn(this.schema)}schemaTag(e){let t=e.toLowerCase(),n=this.schemaTagNames[t];if(n)return n;let s=`${this.constructor._name}_`;return t.startsWith(s)&&this.schemaTagNames[t.slice(s.length)]||null}loadGrammar(e,{replace:t=!1}={}){let n=this._collection||this.constructor._classCollection,s=t?new ot(e):new ot(n.toDocument()).update(e),i=Ro(s.toDocument()),o=Bo(i),a=xn(o.elements);return this._collection=s,this._schemaOverride=o.elements,this._tagNamesOverride=a,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,n=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;Su(e.nodeTag,n.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,n={}){let s=this.schemaTag(e);if(!s)throw new Error(`unknown element '${e}'`);return Du(s,this.schema[s],t,n),!0}validateNode(e,{value:t,attrs:n,childTags:s}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let i=t!==void 0?t:e.value instanceof D?null:e.value;this.validateNodeValues(e.nodeTag,i,n||e.getAttr?.()||{});let o=this.schema[this.schemaTag(e.nodeTag)],a=s||(e.value instanceof D?e.value.getNodes().map(l=>l.nodeTag):null);return a&&this._validateChildren(e.nodeTag,o,a,!1),!0}validateChildren(e,t,{includeMinimum:n=!1}={}){let s=this.schemaTag(e);if(!s)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(i=>typeof i!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(s,this.schema[s],t,n)}validateParent(e,t=null){let n=this.schemaTag(e);if(!n)throw new Error(`unknown element '${e}'`);let s=this.schema[n];if(!this._countsForGrammar(s))return!0;let i=s._parentSpec;if(i==null||i.has("*"))return!0;if(t===null)throw new Error(`'${n}' requires a declared parent`);let o=this.schemaTag(t);if(!o)throw new Error(`unknown parent element '${t}'`);return this._validateParent(n,s,o),!0}bagCall(e,t,n,s){return this.setChild(e,t,n,s)}commandOnNode(e,t,n,s){if(e=te(e),e.value instanceof D)return this.setChild(e.value,t,n,s);let i=e.value,o=new e.parentBag.constructor(null,e.builder||this),a=this.setChild(o,t,n,s,e);return this.promoteNodeValue(e,i,o),a}promoteNodeValue(e,t,n){e.setValue(n)}setChild(e,t,n,s,i=null){let o={...s},a=this.schema[t];if(!a)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,n,o);let l=a._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,o,t))||this,d=n instanceof D?n._builderBindingPlan(c):null,f=i?.rootBuilder||e.root._builder||this;if(o.nodeId!=null&&f.source.getNodeByAttr("nodeId",o.nodeId))throw new Error(`Duplicate nodeId '${o.nodeId}'`);n instanceof D&&this._validateChildren(t,a,n.getNodes().map(w=>w.nodeTag),!1);let h=i||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 g=o.node_label;delete o.node_label;let b;if(p?.collection_key){if(g!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);b=this._collectionLabel(p.collection_key,t,o)}else{let w=p?._subSpec?.get(t);if(w&&w.max===1){if(g!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);b=t}else b=g||a.node_label||this._autoLabel(e,t)}if(e.node(b)!=null)throw new Error(`duplicate node label '${b}'`);return e._setBuilderItem(c,d,b,n,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,n){let s=t._parentSpec;if(!(s==null||s.has("*")||!this._countsForGrammar(t))&&!s.has(n))throw new Error(`'${e}' not allowed as child of '${n}'`)}_validateChildren(e,t,n,s){let i=t._subSpec;if(i==null||i.has("*")||t._meta?.subbuilder)return[];let o=new Map;for(let a of n){let l=this.schema[a];if(l&&!this._countsForGrammar(l))continue;let u=i.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 s?[...i].filter(([a,l])=>(o.get(a)||0)<l.min).map(([a])=>a):[]}_collectionLabel(e,t,n){let s=i=>{if(n[i]===null||n[i]===void 0)throw new Error(`'${t}': collection key needs attribute '${i}'`);return String(n[i])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(i,o)=>s(o)):s(e)}validateSource(){let e=[],t=(n,s="")=>{for(let i of n.getNodes()){let o=s?`${s}.${i.label}`:i.label,a=i.builder;a.validateCustomTypes(i);let l=a.schema[i.nodeTag];if(l&&!i._getMeta("data_element,subbuilder,component").some(Boolean)){let u=i.value instanceof D?i.value.getNodes().map(d=>d.nodeTag):[],c=a._validateChildren(i.nodeTag,l,u,!0);c.length&&e.push([o,c])}i.value instanceof D&&t(i.value,o)}};return t(this.source),e}_autoLabel(e,t){let n=0;for(;e.node(`${t}_${n}`)!==null&&e.node(`${t}_${n}`)!==void 0;)n+=1;return`${t}_${n}`}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,n={},s=e.runtimeToEvaluate(),i=new Set(s.keys()),o=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...s])if(!(typeof c!="string"||!V(d)))for(let f of He(e,d))s.has(f)||s.set(f,o.get(f));let a=e._getMeta("data_element");for(let[c,d]of s){if(d instanceof Z){t.set(c,d.resolve());continue}let f=typeof c=="string"?V(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===Or){let p=this.data.getNode(h);p&&Object.assign(n,p.getAttr("_wdg"))}}let l=la(s,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(Or);l.delete(Or);for(let c of l.keys())i.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...n}]}evaluatePointerExpression(e,t,n,s,i){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 s=(typeof t=="function"?t:t.constructor)[e];if(typeof s=="function")return s}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),n={};for(let[s,i]of Object.entries(t))Ou.has(s)||(n[s]=i);return n}computeLogic(e){for(let t of e)this._computeNode(t)}_computeNode(e){let t=e.getAttr()||{};if(e.nodeTag==="dataSetter"){let n={};for(let[s,i]of Object.entries(t))s!=="destination"&&s!=="value"&&!s.startsWith("_")&&(n[s]=i);e.setRelativeData(t.destination,t.value,{attributes:Object.keys(n).length?n:null})}else if(e.nodeTag==="dataFormula"){let n=this._resolveLogicFunc(t.func);e.setRelativeData(t.destination,n(this._bindings(e)))}else e.nodeTag==="dataController"&&this._resolveLogicFunc(t.func)(e,this._bindings(e))}_dataElementNodes(){let e=[],t=n=>{for(let s of n.getNodes())s._getMeta("data_element")&&e.push(s),s.value instanceof D&&t(s.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 Iu(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},n={};for(let[a,l]of Object.entries(e))t[a]={sub_tags:"",_meta:{component:!0}},n[a.toLowerCase()]=l;let s=xn(t),i=this._collection||this.constructor._classCollection,o=i.toDocument();o.abstracts={},o.elements=Object.fromEntries(Object.keys(e).map(a=>[a,t[a]])),this._collection=new ot(i.toDocument()).update(o),this._schemaOverride=t,this._componentMap=n,this._tagNamesOverride=s}_expansionRoot(e=null){let t=this.constructor._sourceClass,n=new t(null,this);return n.setBackref(),n.setItem(Dn,new t(null,this),e?{datapath:e}:null),n.getItem(Dn)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Wt(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 n=this.getRenderer(e),s=n.renderChildren(n.preprocess(this.source),t);return this.materialized[e]=s,s}setRenderTarget(e,t=null){t??=this.constructor._defaultRenderMode,this._defaultTargets.set(t,e)}render({mode:e=null,target:t=null,...n}={}){e??=this.constructor._defaultRenderMode;let s=this.getRenderer(e);if(t===!1&&s.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let i=t===!1?null:t||this._defaultTargets.get(s.mode)||null,o={...i?.renderOpts,...n};return s.finalize(this.materialize(e,o),i,o)}};ye._registry=new Map;var Xp=new Set(["short","medium","long","full"]),Yp=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Zp(r,e){if(!(r instanceof Date))throw new TypeError("Temporal formats require a typed Date value");if(!Number.isFinite(r.getTime()))throw new RangeError("Invalid date");let t=e||W(r).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function Jp(r,e,t,n){let s=e.match(Yp)||[];if(s.join("")!==e)throw new RangeError("Unclosed format literal");let i=(c,d=2)=>String(c).padStart(d,"0"),o=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(r),u={...n==="H"?{}:{y:()=>String(r.getUTCFullYear()),yy:()=>i(r.getUTCFullYear()%100),yyyy:()=>i(r.getUTCFullYear(),4),M:()=>String(r.getUTCMonth()+1),MM:()=>i(r.getUTCMonth()+1),MMM:()=>o({month:"short"}),MMMM:()=>o({month:"long"}),d:()=>String(r.getUTCDate()),dd:()=>i(r.getUTCDate()),EEE:()=>o({weekday:"short"}),EEEE:()=>o({weekday:"long"})},...n==="D"?{}:{H:()=>String(r.getUTCHours()),HH:()=>i(r.getUTCHours()),h:()=>String(r.getUTCHours()%12||12),hh:()=>i(r.getUTCHours()%12||12),m:()=>String(r.getUTCMinutes()),mm:()=>i(r.getUTCMinutes()),s:()=>String(r.getUTCSeconds()),ss:()=>i(r.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(r).find(c=>c.type==="dayPeriod").value}};return s.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 Bu(r,{format:e,mask:t,locale:n,dtype:s,places:i}={}){let o=r==null?"":String(r);if(r!=null&&r!==""&&(e!=null&&e!==""||i!=null))if(typeof r=="number"||fe(r))o=Qp(r,{format:e,locale:n,places:i});else{let a=Zp(r,s);if(Xp.has(e)){let l={timeZone:"UTC"};a!=="H"&&(l.dateStyle=e),a!=="D"&&(l.timeStyle=e),o=new Intl.DateTimeFormat(n||void 0,l).format(r)}else o=Jp(r,String(e),n||void 0,a)}return t==null?o:String(t).replaceAll("%s",()=>o)}function Kp({format:r="decimal",places:e}={}){let t={maximumFractionDigits:20};if(!r||r==="decimal")t.style="decimal";else if(r==="percent")t.style="percent";else if(r==="scientific")t.notation="scientific";else{let n=/^(0|#,##0)(?:\.(0*)(#*))?$/.exec(r);if(!n||r.includes(".")&&!n[2]&&!n[3])throw new RangeError(`Unsupported number format: ${r}`);t.useGrouping=n[1].includes(","),t.minimumFractionDigits=(n[2]||"").length,t.maximumFractionDigits=(n[2]||"").length+(n[3]||"").length}if(e!=null&&e!==""){let n=Number(e);if(!Number.isInteger(n)||n<0||n>20)throw new RangeError("places must be an integer from 0 to 20");t.minimumFractionDigits=n,t.maximumFractionDigits=n}return t}function Qp(r,e={}){if(typeof r!="number"&&!fe(r))throw new TypeError("Number formatting requires a Number or Decimal");if(!Number.isFinite(Number(r)))throw new RangeError("Number must be finite");let t=new Intl.NumberFormat(e.locale||void 0,Kp(e));if(fe(r)&&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(r)?r.toString():r)}var em=new Set(["style","script"]),tm=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"]),Ru=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"]),Cn=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),Mu=r=>r===!0?"true":r===!1?"false":String(r),Gs=r=>typeof r=="number"&&Number.isFinite(r)?`${r}px`:String(r);function rm(r){if(Ru.has(r))return!0;for(let e of Ru)if(r.startsWith(`${e}_`))return!0;return!1}function nm(r){let e=new Map;if(!r)return e;let t=[],n=0,s=null,i=!1,o=!1,a=0,l=String(r);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(i){i=!1;continue}if(c==="\\"){i=!0;continue}if(s){c===s&&(s=null);continue}c==='"'||c==="'"?s=c:c==="/"&&d==="*"?(o=!0,u+=1):"([{".includes(c)?a+=1:")]}".includes(c)&&a>0?a-=1:c===";"&&a===0&&(t.push(l.slice(n,u)),n=u+1)}t.push(l.slice(n));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 Gt=class extends zt{static mode="html";renderedItem(e,t,n,{tag:s,xml:i=!0,pretty:o=!1,depthOffset:a=0,includeDatapath:l=!1}={}){e.parentNode?._getMeta("subbuilder")==="html"&&(n={xmlns:"http://www.w3.org/1999/xhtml",...n});let{format:c,mask:d,locale:f,places:h,dtype:p,...m}=n;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=Bu(t,{format:c,mask:d,places:h,dtype:p,locale:this._displayLocale(e,f)}));let g=this._formatAttrs(m);if(l){if(!Object.hasOwn(n,"id")){let k=this.builder.targetId(e);k!==null&&(g+=` id="${this._htmlAttrValue(k)}"`)}for(let[k,A]of Object.entries(e.getAttr()))e.pointerType(A)&&(g+=` data-${this.adapt(k)}-pointer="${this._htmlAttrValue(e.absDatapath(A))}"`)}let b=o?" ".repeat(this._nodeDepth(e,a)):"",y=o?`
|
|
24
|
-
`:"";if(e._getMeta("void"))return`${b}<${s}${g}${i?"/":""}>${y}`;if(Array.isArray(t)){let k=this._composeStringFragments(t);return`${b}<${s}${g}>${y}${k}${b}</${s}>${y}`}if(t==null)return`${b}<${s}${g}></${s}>${y}`;let w=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):em.has(s)?String(t):this._escapeText(t);return`${b}<${s}${g}>${w}</${s}>${y}`}_displayLocale(e,t){if(t)return t;for(let n=e.parentNode;n;n=n.parentNode){let s=n.getAttr("locale");if(s==null)continue;let i=n.pointerType(s)?n.data.getItem(n.absDatapath(s)):s;if(i)return i}}adaptAttrs(e){let t={},n={};for(let[i,o]of Object.entries(e||{}))if(i.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(i)]=o;else if(i==="dtype")t.dtype=o;else{if(this.builder.constructor.retainedAttrPrefixes.some(a=>i.startsWith(a)))continue;this._isStyleContribution(i)?n[i]=o:t[i]=o}let s=this._adaptStyle(n);return s&&(t.style=s),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||Cn.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&Cn.has(t)||rm(e)}_adaptStyle(e){let t=nm(e.style),n=new Map,s=new Map;for(let[i,o]of Object.entries(e))if(i!=="style")if(i.startsWith("style_"))t.set(i.slice(6).replaceAll("_","-"),Mu(o));else if(Cn.has(i))n.set(i,o);else{let a=i.indexOf("_"),l=a<0?i:i.slice(0,a);a>=0&&Cn.has(l)?(s.has(l)||s.set(l,{}),s.get(l)[i.slice(a+1)]=o):t.set(i.replaceAll("_","-"),Mu(o))}for(let i of Cn)(n.has(i)||s.has(i))&&this[`_macro_${i}`](n.get(i),s.get(i)||{},t);return[...t].map(([i,o])=>`${i}: ${o}`).join("; ")}_formatAttrs(e){let t=[];for(let[n,s]of Object.entries(e||{}))tm.has(n)?s&&t.push(` ${n}`):t.push(` ${n}="${this._htmlAttrValue(s)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}_macro_rounded(e,t,n){let s=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[i,o]of Object.entries(t))if(i==="top"||i==="bottom")s[`${i}_left`]=o,s[`${i}_right`]=o;else if(i==="left"||i==="right")s[`top_${i}`]=o,s[`bottom_${i}`]=o;else if(["top_left","top_right","bottom_left","bottom_right"].includes(i))s[i]=o;else throw new TypeError(`rounded: unknown sub-kwarg '${i}'`);for(let[i,o]of Object.entries(s))n.set(`border-${i.replaceAll("_","-")}-radius`,Gs(o))}_macro_transform(e,t,n){let s=e===void 0?[]:[String(e)];for(let[i,o]of Object.entries(t))i==="rotate"?s.push(`rotate(${o}deg)`):i==="scale"||i==="translate"?s.push(`${i}(${o})`):i==="translate_x"?s.push(`translateX(${Gs(o)})`):i==="translate_y"?s.push(`translateY(${Gs(o)})`):i==="skew_x"?s.push(`skewX(${o}deg)`):i==="skew_y"?s.push(`skewY(${o}deg)`):s.push(`${i.replaceAll("_","-")}(${o})`);s.length&&n.set("transform",s.join(" "))}_macro_filter(e,t,n){let s=e===void 0?[]:[String(e)];for(let[i,o]of Object.entries(t))i==="rotate"?s.push(`hue-rotate(${o}deg)`):i==="blur"?s.push(`blur(${Gs(o)})`):i==="drop_shadow"?s.push(`drop-shadow(${o})`):s.push(`${i.replaceAll("_","-")}(${o})`);s.length&&n.set("filter",s.join(" "))}_macro_transition(e,t,n){e!==void 0&&n.set("transition",String(e));for(let[s,i]of Object.entries(t))n.set(`transition-${s.replaceAll("_","-")}`,String(i))}_macro_zoom(e,t,n){e!==void 0&&n.set("zoom",String(e))}_macro_shadow(e,t,n){e!==void 0&&n.set("box-shadow",String(e));for(let[s,i]of Object.entries(t))n.set(`box-shadow-${s.replaceAll("_","-")}`,String(i))}_macro_gradient(e,t,n){e!==void 0&&n.set("background-image",String(e))}};var sm=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 Xs(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[sm.has(e)?e.replaceAll("_","-"):e,t]))}var Xt=class extends Wt{static mode="svg";adaptAttrs(e){return Xs(e)}};var $u={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($u)}get renderer_html(){return new Gt(this)}};ye.registerBuilder(Tt);var Lu={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 xt=class extends ye{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(Lu)}get renderer_svg(){return new Xt(this)}};ye.registerBuilder(xt);var Yt=class r{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=Br.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 r(e.pattern,e.flags)}toJSON(){return{kind:"regex",pattern:this.pattern,flags:this.flags}}matches(e){return this.#e(e)}},Nn=new Yt(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 am=/^[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,lm=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function at(r){let e=r.code;if(typeof e!="string"||am.exec(e)?.[0]!==e||!e.includes("-")||lm.has(e))throw new TypeError("webcomponent: code must be a literal custom-element name");return e}function Lo(r){for(let e of Object.values(r))e&&typeof e=="object"&&Lo(e);return Object.freeze(r)}function Pu(r){if(typeof r.dtype!="string"&&!Array.isArray(r.dtype))throw new TypeError("Component parameter requires dtype");let e=(Array.isArray(r.dtype)?r.dtype:[r.dtype]).map(t=>({kind:"dtype",dtype:t}));return r.nullable&&e.push({kind:"dtype",dtype:"NN"}),r.binding&&r.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 Rr({name:r,tag:e,base:t,mixins:n=[],parameters:s={},subTags:i="",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(r))throw new TypeError("Invalid component authoring name");let p={...t.parameters};for(let m of n)for(let[g,b]of Object.entries(m.parameters)){if(Object.hasOwn(p,g))throw new Error(`Duplicate mixin parameter: ${g}`);p[g]=b}Object.assign(p,s);for(let m of Object.values(p))Pu(m);return Object.freeze({name:r,tag:e,base:t,subTags:i,presentationDefaults:Object.freeze([...o]),dataScope:a,command:l,bagStore:d,mixins:Object.freeze([...n]),parameters:Lo(structuredClone(p)),childParameters:Lo(structuredClone(u)),sourceContext:c,dragSource:f,implementation:h})}var Zt=class{#e=new WeakMap;constructor({name:e,components:t}){this.name=e,this.components=Object.freeze([...t]);let n=new Set,s=new Set;for(let i of t){if(n.has(i.name.toLowerCase())||s.has(i.tag))throw new Error(`Duplicate component: ${i.name}`);n.add(i.name.toLowerCase()),s.add(i.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,n])=>({name:t,kind:"keyword_only",role:"attribute",annotation:Pu(n),has_default:!0,default:n.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 n of this.components){if(e.customElements.get(n.tag))throw new Error(`Custom element already registered: ${n.tag}`);let s=n.base(e.HTMLElement);for(let o of n.mixins)s=o(s);let i=n.implementation(s);Object.defineProperty(i,"gramlotComponent",{value:n}),t.push([n.tag,i])}for(let[n,s]of t)e.customElements.define(n,s);this.#e.set(e,t)}};function Fu(r){return new Zt(r)}function Ys(r,e){return r.parameters=Object.fromEntries(Object.entries(r.constructor.gramlotComponent.parameters).map(([t,n])=>[t,Object.hasOwn(e,t)?e[t]:n.default])),Object.fromEntries(Object.entries(e).filter(([t])=>!Object.hasOwn(r.parameters,t)))}function ju(r,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(r==="")return[];let t=new Set;return r.split(e).map(n=>{let s=n.indexOf(":"),i=s<0?n:n.slice(0,s),o=s<0?n:n.slice(s+1);if(!i||t.has(i))throw new Error("Invalid or duplicate choice code");return t.add(i),{id:i,caption:o}})}function Zs(r){return class extends r{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}
|
|
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,"&").replace(/</g,"<").replace(/>/g,">")}_escapeAttr(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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("&","&").replaceAll("<","<").replaceAll(">",">")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',""")}_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("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}_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}
|
|
25
25
|
input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
|
|
26
26
|
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
|
|
27
|
-
appearance:none;box-sizing:border-box;border:1px solid var(--gramlot-border-control,#7a8798);
|
|
27
|
+
appearance:none;box-sizing:border-box;width:100%;border:1px solid var(--gramlot-border-control,#7a8798);
|
|
28
28
|
border-radius:var(--gramlot-radius-sm,4px);background:var(--gramlot-field-background,Canvas);color:var(--gramlot-ink,CanvasText);
|
|
29
29
|
min-height:var(--gramlot-field-height,28px);padding:var(--gramlot-field-padding,.25em .5em);font-size:var(--gramlot-field-font-size,1em);line-height:var(--gramlot-field-line-height,inherit)}
|
|
30
30
|
input:read-only:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea:read-only{
|
|
@@ -36,7 +36,68 @@ ${" ".repeat(s)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
36
36
|
input[type=range],input[type=color],button{min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
|
|
37
37
|
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
38
|
.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 Ys(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 um(r){return class extends Zs(r){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 n=super.projectAttributes(e,t),{disabled:s,readonly:i}=this.parameters;this.control.disabled=!!s,this.control.readOnly=!!i;for(let[o,a]of Object.entries(this.constructor.gramlotComponent.parameters)){if(a.target==="control"){let l=this.parameters[o]??"";String(this.control[o])!==String(l)&&(this.control[o]=l)}a.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[o]??"")}return n}}}um.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function cm(r){return class extends Zs(r){#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)")],n=t.indexOf(e.target);if(n<0)return;e.preventDefault();let s=e.key==="Home"?0:e.key==="End"?t.length-1:Math.max(0,Math.min(t.length-1,n+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));t[s].focus()})}projectAttributes(e,t){let n=super.projectAttributes(e,t),s=this.parameters.values??"";if(s!==this.#t){let o=ju(s),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=s}let i=this.parameters.cols;if(!Number.isInteger(i)||i<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${i}, 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 n}readControlValue(){if(this.multiple){let t=(this.#r?this.#r.split(","):[]).filter(n=>!this.#e.has(n)||this.#e.get(n).input.checked);for(let[n,{input:s}]of this.#e)s.checked&&!t.includes(n)&&t.push(n);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[n,{input:s}]of this.#e)s.checked=this.multiple?t.has(n):n===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>this.writeControlValue(t))}focus(e){let t=[...this.#e.values()];(t.find(({input:n})=>n.checked&&!n.disabled)??t.find(({input:n})=>!n.disabled))?.input.focus(e)}}}cm.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Uu(r,e,{align:t="start",matchWidth:n=!1,inset:s=0}={}){let i=e.ownerDocument.defaultView,o=e.getBoundingClientRect(),a=Math.max(0,i.innerWidth-16);r.style.setProperty("--gramlot-popup-available-width",`${a}px`),n&&(r.style.width=`${Math.min(Math.max(0,o.width-2*s),a)}px`),r.style.removeProperty("--gramlot-popup-available-height");let l=r.getBoundingClientRect(),u=Math.max(0,i.innerHeight-8-o.bottom-3),c=Math.max(0,o.top-8-3),d=l.height>u&&c>u;r.style.setProperty("--gramlot-popup-available-height",`${d?c:u}px`);let f=r.getBoundingClientRect(),h=t==="end"?o.right-f.width-s:o.left+s,p=d?o.top-f.height-3:o.bottom+3;r.style.left=`${Math.max(8,Math.min(h,i.innerWidth-f.width-8))}px`,r.style.top=`${Math.max(8,Math.min(p,i.innerHeight-f.height-8))}px`}function In(r){return class extends Zs(r){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}
|
|
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=`
|
|
40
|
+
:host([role=toolbar]){min-width:0;min-height:0;max-width:100%;width:100%;flex-shrink:1;gap:0}
|
|
41
|
+
:host([role=toolbar][aria-orientation=vertical]){width:auto;height:100%;max-height:100%}
|
|
42
|
+
.toolbar-viewport{display:contents}
|
|
43
|
+
:host([role=toolbar]) .toolbar-viewport{display:flex;align-items:center;gap:var(--gramlot-toolbar-gap,4px);flex:1 1 0%;min-width:0;min-height:0;overflow-x:auto;overflow-y:hidden}
|
|
44
|
+
:host([role=toolbar][aria-orientation=vertical]) .toolbar-viewport{flex-direction:column;align-items:stretch;overflow-x:hidden;overflow-y:auto;width:100%}
|
|
45
|
+
:host([role=toolbar]) ::slotted(*){flex-shrink:0}
|
|
46
|
+
.toolbar-more{flex:0 0 auto;width:max(var(--gramlot-field-height,32px),var(--gramlot-touch-target,0px));height:max(var(--gramlot-field-height,32px),var(--gramlot-touch-target,0px));padding:0;border:0;border-radius:4px;background:transparent;color:inherit;font:inherit;display:grid;place-items:center}
|
|
47
|
+
.toolbar-more svg{display:block;width:18px;height:18px;pointer-events:none}
|
|
48
|
+
.toolbar-more:hover,.toolbar-more:focus-visible{background:var(--gramlot-selected,Highlight)}
|
|
49
|
+
:host([role=toolbar][aria-orientation=vertical]) .toolbar-more{width:100%}
|
|
50
|
+
.toolbar-more[hidden]{display:none}
|
|
51
|
+
.toolbar-overflow{position:fixed;inset:auto;margin:0;padding:5px;box-sizing:border-box;min-width:min(16rem,var(--gramlot-popup-available-width));width:max-content;
|
|
52
|
+
max-width:var(--gramlot-popup-available-width);max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
53
|
+
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
|
+
.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)}
|
|
56
|
+
: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
|
+
max-width:min(28rem,var(--gramlot-popup-available-width));max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
58
|
+
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}
|
|
59
|
+
:host([role=toolbar][aria-orientation=vertical]){flex-direction:column;align-items:stretch}
|
|
60
|
+
:host([role=toolbar]){display:flex;gap:var(--gramlot-toolbar-gap,4px);align-items:center}
|
|
61
|
+
:host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
|
|
62
|
+
: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
|
+
: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}
|
|
65
|
+
.menu-check:empty,.menu-arrow:empty{display:none}
|
|
66
|
+
button.menu-row{display:grid;grid-template-columns:1em 1.15em minmax(0,1fr) .7em;column-gap:.5em;
|
|
67
|
+
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);
|
|
68
|
+
line-height:1.3;text-align:left;border:0;border-radius:var(--gramlot-radius-sm,5px);background:transparent;cursor:default}
|
|
69
|
+
.menu-row .menu-check,.menu-row .icon,.menu-row .menu-arrow{display:flex;align-items:center;justify-content:center;min-width:0}
|
|
70
|
+
.menu-row .menu-check{grid-column:1}.menu-row .icon{grid-column:2}
|
|
71
|
+
.menu-row .menu-caption{grid-column:3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
72
|
+
.menu-row .menu-arrow{grid-column:4;font-size:1.2em;line-height:1}
|
|
73
|
+
button.menu-row:hover:not(:disabled),button.menu-row:focus-visible,button.menu-row[aria-expanded=true]{
|
|
74
|
+
background:var(--gramlot-selected,Highlight);color:var(--gramlot-action-hover,HighlightText);outline:none}
|
|
75
|
+
button.menu-row:disabled{opacity:.45;cursor:default}
|
|
76
|
+
:host button.toolbar-button{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--gramlot-button-gap,6px);
|
|
77
|
+
box-sizing:border-box;width:100%;height:100%;min-width:max(var(--gramlot-field-height,38px),var(--gramlot-touch-target,0px));min-height:max(var(--gramlot-field-height,38px),var(--gramlot-touch-target,0px));padding:var(--gramlot-button-padding,6px 5px);border:1px solid transparent;border-radius:var(--gramlot-radius-sm,8px);
|
|
78
|
+
background:transparent;cursor:pointer;line-height:1.2;white-space:nowrap}
|
|
79
|
+
:host button.toolbar-button .icon{display:inline-flex;align-items:center;justify-content:center;
|
|
80
|
+
width:var(--gramlot-toolbar-icon-size);height:var(--gramlot-toolbar-icon-size);font-size:var(--gramlot-toolbar-icon-size);line-height:1}
|
|
81
|
+
:host button.toolbar-button .icon:empty{display:none}
|
|
82
|
+
:host button.toolbar-button:hover:not(:disabled){background:color-mix(in srgb,currentColor 10%,transparent)}
|
|
83
|
+
:host button.toolbar-button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
|
|
84
|
+
:host button.toolbar-button[aria-checked=true],:host button.toolbar-button[aria-expanded=true]{background:var(--gramlot-selected,color-mix(in srgb,currentColor 14%,transparent))}
|
|
85
|
+
:host button.toolbar-button:disabled{opacity:.45;cursor:default}
|
|
86
|
+
:host button.toolbar-below{flex-direction:column;gap:3px;min-width:54px}
|
|
87
|
+
:host button.toolbar-below .menu-caption{font-size:11px;line-height:1.2}
|
|
88
|
+
:host button.toolbar-tooltip .menu-caption{display:none}
|
|
89
|
+
:host button.toolbar-button .menu-check{display:none}
|
|
90
|
+
:host button.toolbar-tooltip .menu-arrow{position:absolute;right:3px;top:50%;transform:translateY(-50%);font-size:12px}
|
|
91
|
+
:host button.toolbar-below .menu-arrow{position:absolute;inset:4px 3px auto auto;font-size:12px}`,t.textContent+=`
|
|
92
|
+
:host([role=group]){display:block;min-width:0}
|
|
93
|
+
:host([role=group]) .control-box{display:none}
|
|
94
|
+
.menu-group{display:flex;align-items:center;gap:var(--gramlot-toolbar-gap,4px);flex-wrap:nowrap}
|
|
95
|
+
.menu-group ::slotted(*){flex-shrink:0}
|
|
96
|
+
.menu-group[hidden]{display:none}
|
|
97
|
+
:host([data-menu-overflow]) .menu-group,:host([data-menu-group-rows]) .menu-group{flex-direction:column;align-items:stretch;padding:3px 0}
|
|
98
|
+
:host([data-menu-overflow][role=group]){border-block-end:1px solid var(--gramlot-border-control,#888);margin-block-end:4px}
|
|
99
|
+
: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}
|
|
40
101
|
button{display:inline-flex;align-items:center;justify-content:center;gap:var(--gramlot-button-gap,.35em);font:inherit;
|
|
41
102
|
color:var(--gramlot-ink,CanvasText);background:var(--gramlot-button-background,var(--gramlot-field-background,Canvas));
|
|
42
103
|
border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,4px);
|
|
@@ -46,7 +107,7 @@ ${" ".repeat(s)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
46
107
|
:host(.button--quiet) button{background:transparent;color:var(--gramlot-action,CanvasText);border-color:transparent}
|
|
47
108
|
:host(.button--quiet) button:hover:not(:disabled){background:var(--gramlot-selected,Highlight);color:var(--gramlot-action-hover,CanvasText);border-color:transparent}
|
|
48
109
|
button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:2px}
|
|
49
|
-
button:disabled{opacity:.55;cursor:not-allowed} .icon:empty{display:none}
|
|
110
|
+
button:disabled{opacity:.55;cursor:not-allowed} .icon:empty{display:none} .icon img{display:block;width:100%;height:100%;object-fit:contain} .icon:has(img){width:1em;height:1em}
|
|
50
111
|
.led{display:inline-block;width:.6em;height:.6em;border-radius:50%;background:var(--gramlot-button-led-off,#888)}
|
|
51
112
|
[aria-pressed=true] .led{background:var(--gramlot-button-led-on,#2b9a46)}
|
|
52
113
|
.arrow{border-start-start-radius:0;border-end-start-radius:0;border-inline-start:0}
|
|
@@ -55,18 +116,38 @@ ${" ".repeat(s)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}
|
|
|
55
116
|
max-width:var(--gramlot-popup-available-width);max-height:var(--gramlot-popup-available-height);
|
|
56
117
|
border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,4px);
|
|
57
118
|
color:var(--gramlot-ink,CanvasText);background:var(--gramlot-field-background,Canvas);box-shadow:0 3px 12px #0003}
|
|
58
|
-
:host([role=menuitem]){display:block} :host([role=menuitem]) button{width:100%;justify-content:start;border:0;background:transparent}
|
|
119
|
+
:host(:is([role=menuitem],[role=menuitemcheckbox])){display:block} :host(:is([role=menuitem],[role=menuitemcheckbox])) button{width:100%;justify-content:start;border:0;background:transparent}
|
|
59
120
|
:host([role=separator]){display:block;border-top:1px solid var(--gramlot-border-control,#888);margin:.25em}
|
|
60
|
-
: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 n=super.projectAttributes(e,t);return this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly,this.icon.textContent=this.parameters.icon??"",e["aria-label"]!=null?this.control.setAttribute("aria-label",e["aria-label"]):this.control.removeAttribute("aria-label"),n}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}In.parameters={disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"}};var dm=Rr({name:"button",tag:"gramlot-button",base:In,command:!0,subTags:"*",implementation:r=>class extends r{}}),fm=Rr({name:"toggleButton",tag:"gramlot-toggle-button",base:In,command:!0,subTags:"*",parameters:{value:{dtype:"B",default:!1,binding:"twoWay"},readonly:{dtype:"B",default:!1,binding:"read"}},implementation:r=>class extends r{#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)}}});function hm(r){return class extends r{constructor(){super(),this.attachShadow({mode:"open"}).append(this.ownerDocument.createElement("slot"))}connectedCallback(){this.slot="menu",this.setAttribute("role","menu")}projectAttributes(e){return Ys(this,e)}}}var pm=Rr({name:"menu",tag:"gramlot-menu",base:hm,subTags:"menuline",implementation:r=>class extends r{}}),mm=Rr({name:"menuline",tag:"gramlot-menu-line",base:In,command:!0,subTags:"*",parameters:{code:{dtype:"T",nullable:!0}},implementation:r=>class extends r{attachCommand(){let e=this.textContent.trim()==="-";if(!e&&!this.parameters.code)throw new TypeError("menuline requires a stable code");this.setAttribute("role",e?"separator":"menuitem"),this.control.tabIndex=-1,this.disabled||=e}get disabled(){return super.disabled||!!this.closest("gramlot-drop-down-button")?.parameters.disabled}set disabled(e){super.disabled=e}prepareCommand(e){return super.prepareCommand(e)?(this.closest("gramlot-drop-down-button").selectCommand(this,e.shiftKey),!0):!1}}}),gm=Rr({name:"dropDownButton",tag:"gramlot-drop-down-button",base:In,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:r=>class extends r{#e=null;#t=null;#r=null;#s=null;#n;#i;#o;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#o=e.createElement("span"),this.#o.hidden=!0,this.control.append(this.#o),this.#i=e.createElement("button"),this.#i.type="button",this.#i.className="arrow",this.#i.textContent="\u25BE",this.#i.setAttribute("aria-label","Open menu"),this.#i.setAttribute("aria-haspopup","menu"),this.#i.setAttribute("aria-expanded","false"),this.controlBox.append(this.#i),this.#n=e.createElement("div"),this.#n.className="popup",this.#n.id="menu",this.#n.setAttribute("popover","auto"),this.#i.setAttribute("aria-controls","menu");let t=e.createElement("slot");t.name="menu",this.#n.append(t),this.shadowRoot.append(this.#n),this.#i.addEventListener("click",n=>{n.stopPropagation(),this.#n.matches(":popover-open")?this.closeMenu():this.openMenu()}),this.#i.addEventListener("keydown",n=>{(n.key==="ArrowDown"||n.key==="ArrowUp")&&(n.preventDefault(),this.openMenu(n.key==="ArrowUp"))}),this.addEventListener("keydown",n=>{if(!this.#n.matches(":popover-open"))return;let s=this.menuItems.filter(a=>!a.disabled),i=s.indexOf(n.composedPath().find(a=>s.includes(a))),o;n.key==="ArrowDown"&&(o=(i+1)%s.length),n.key==="ArrowUp"&&(o=(i-1+s.length)%s.length),n.key==="Home"&&(o=0),n.key==="End"&&(o=s.length-1),o!==void 0&&(n.preventDefault(),s[o]?.focus()),(n.key==="Escape"||n.key==="Tab")&&(n.key==="Escape"&&n.preventDefault(),this.closeMenu())}),this.#n.addEventListener("toggle",()=>{let n=this.#n.matches(":popover-open");this.#i.setAttribute("aria-expanded",String(n)),n||(this.#r?.abort(),this.#r=null)})}get menuItems(){return[...this.querySelectorAll(":scope > gramlot-menu > gramlot-menu-line")]}projectAttributes(e,t){let n=super.projectAttributes(e,t);return this.#i.disabled=this.disabled,this.disabled&&this.#n.matches(":popover-open")&&this.closeMenu(),this.#a(),n}attachCommand(){if(this.parameters.persist){if(!this.id)throw new TypeError("dropDownButton persist requires an explicit id");this.#s=`gramlot:command:${this.ownerDocument.location.pathname}${this.ownerDocument.location.search}:${this.id}`;try{this.#e=this.ownerDocument.defaultView.localStorage.getItem(this.#s)}catch{}}this.#a(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#a()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.#t=null,this.#r?.abort(),this.#r=null,this.#n.matches(":popover-open")&&this.#n.hidePopover()}commandTarget(e){return e?.composedPath().includes(this.#n)?null:this.menuItems.find(t=>t.parameters.code===this.#e)??this}selectCommand(e,t){if(t){if(this.#e=e.parameters.code,this.#s)try{this.ownerDocument.defaultView.localStorage.setItem(this.#s,this.#e)}catch{}this.#a()}this.closeMenu()}#a(){let e=this.menuItems.filter(s=>s.parameters.code).map(s=>s.parameters.code);if(new Set(e).size!==e.length)throw new TypeError("Dropdown menu codes must be unique");let t=this.commandTarget(),n=t!==this;this.caption.hidden=n,this.#o.hidden=!n,this.#o.textContent=n?t.textContent:"",this.icon.textContent=n?t.parameters.icon:this.parameters.icon}openMenu(e=!1){if(this.disabled)return;let t=this.menuItems.filter(i=>!i.disabled);if(!t.length)return;this.#n.showPopover(),this.#i.setAttribute("aria-expanded","true");let n=()=>Uu(this.#n,this.controlBox);n(),this.#r?.abort(),this.#r=new this.ownerDocument.defaultView.AbortController;let s={signal:this.#r.signal,capture:!0};this.ownerDocument.defaultView.addEventListener("resize",n,s),this.ownerDocument.addEventListener("scroll",n,s),t[e?t.length-1:0].focus()}closeMenu(){this.#n.matches(":popover-open")&&(this.#n.hidePopover(),this.#i.setAttribute("aria-expanded","false"),this.#r?.abort(),this.#r=null,this.#i.focus())}}}),Js=Fu({name:"buttons",components:[dm,fm,gm,pm,mm]});function qu(r){if(r!=null&&(typeof r!="string"||/[{}]/.test(r.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function Qs(r,e){return qu(e),e==null?r:e.replaceAll("{}",()=>r)}function bm(r){if(r instanceof Date)return vt(r);if(fe(r))return"N";if(typeof r=="number")return Number.isInteger(r)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function _m(r,e,{pattern:t="short",locale:n,timeZone:s}){if(!["short","medium","long","full"].includes(t))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof s!="string"||!s))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let i={timeZone:e==="DHZ"?s:"UTC"};return e!=="H"&&(i.dateStyle=t),e!=="D"&&(i.timeStyle=t),new Intl.DateTimeFormat(n,i).format(r)}function Ks(r){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(r);if(!e||e[1]==="("!=(e[4]===")")||r.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${r}`);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 wm(r){let e=r.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=Ks(e[0]);if(t.prefix||t.suffix)throw new RangeError("Positive-section affixes are not implemented");let n=e.length===3?e[1]:null;n!==null&&n!==""&&n!=="-"&&Ks(n);let s=e.length>1?Ks(e.at(-1)):null;return{positive:t,zero:n,negative:s}}function Vu(r,e={},t={}){if(r===null)return"";if(typeof e=="string"&&(e={pattern:e}),!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Format options must be a pattern string or an options object");for(let g of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(g))throw new RangeError(`Unsupported format option: ${g}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let n=e.dtype===void 0?bm(r):e.dtype,s=["D","H","DHZ"].includes(n);if(!s&&!["L","R","N"].includes(n))throw new RangeError(`Unsupported format dtype: ${n}`);if(s){if(!(r instanceof Date)||!Number.isFinite(r.getTime()))throw new TypeError(`${n} requires a valid Date object`)}else if(!(typeof r=="number"&&Number.isFinite(r))&&!(fe(r)&&!["NaN","Infinity","-Infinity"].includes(r.toString())))throw new TypeError(`${n} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(n==="L"&&!Number.isInteger(r))throw new TypeError("L formatting requires an integer");let{pattern:i,locale:o,mask:a}=e;if(!s&&typeof i!="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(!(s?Intl.DateTimeFormat:Intl.NumberFormat).supportedLocalesOf([o]).length)throw new RangeError(`Unsupported format locale: ${o}`);if(qu(a),s){let g=_m(r,n,e);return Qs(g,a)}let{positive:u,zero:c,negative:d}=wm(i),f=fe(r),h=f?r.eq(0):r===0,p=f?r.lt(0):r<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 g=Ks(c);m=g.prefix+new Intl.NumberFormat(o,g.intl).format(0)+g.suffix}}else{let g=p&&d?d:u,b=f?(p&&d?r.abs():r).toString():p&&d?-r:r===0?0:r;m=g.prefix+new Intl.NumberFormat(o,u.intl).format(b)+g.suffix}return Qs(m,a)}var Ue="http://www.w3.org/1999/xhtml",On="http://www.w3.org/2000/svg",ym=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"]),vm=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],Em={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},km=["format","mask","locale","timeZone","places","dtype"],Am=new Set(["href","src","action","formaction","xlink:href","xlink_href"]);function Dt(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!ym.has(e)&&!vm.some(n=>e.startsWith(n))))}function $r(r,e,t=[]){for(let[n,s]of Object.entries(e)){let i=t.find(a=>n.startsWith(a))??"",o=n.slice(i.length);if(["style","class","_class"].includes(o)&&s!=null&&typeof s!="string")throw new TypeError(`${r.nodeTag} '${r.label}': '${n}' must be a string or null`)}}function Lr(r,e,t=[]){if(r.nodeTag==="script"){let n=[["",r.staticValue],...he(r.getAttr()).filter(([s])=>["src","href","xlink:href","xlink_href","_text"].includes(s.slice((t.find(i=>s.startsWith(i))??"").length).toLowerCase()))];for(let[s,i]of n)if(r.pointerType(i)||Me(i))throw new Error(`script '${r.label}': '${s}' must be literal Source; script code and URLs cannot come from Data`)}if(e.onClose!=null&&!r.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose)throw new Error("onClose is only supported on a tab/stack panel");for(let[n,s]of Object.entries(Pr(Dt(e)))){let i=t.find(a=>n.startsWith(a)),o=i?n.slice(i.length):n;if(/^on./i.test(o))throw new Error(`${r.nodeTag} '${r.label}': '${n}' 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(Am.has(o.toLowerCase())&&Tm(s))throw new Error(`${r.nodeTag} '${r.label}': '${n}' holds a javascript: URL, run by the browser as code; write connect_onclick or the action of a button instead`)}}function Tm(r){return typeof r=="string"&&/^javascript:/i.test(r.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function Hu(r,e,t=[]){if(r.nodeTag!=="iframe")return e;let n=a=>{let l=t.find(u=>a.startsWith(u))??"";return[l,a.slice(l.length).toLowerCase()]},s=Object.fromEntries(he(r.getAttr())),i=[...Object.keys(s),...Object.keys(e)].find(a=>n(a)[1]==="srcdoc");if(i===void 0||Object.keys(s).some(a=>n(a)[1]==="sandbox")||r.pointerType(r.value)===null&&!(Object.hasOwn(s,i)&&(r.pointerType(s[i])!==null||Me(s[i]))))return e;let o=Object.fromEntries(Object.entries(e).filter(([a])=>n(a)[1]!=="sandbox"));return{[`${n(i)[0]}sandbox`]:"",...o}}function Pr(r){return Object.fromEntries(Object.entries(r).filter(([,e])=>e!=null))}function Bn(r){return Object.fromEntries(Object.entries(r).map(([e,t])=>e.startsWith("xmlns_")?[`xmlns:${e.slice(6)}`,t]:e.startsWith("data_")||e.startsWith("aria_")?[e.replaceAll("_","-"),t]:[e,t]))}function ei(r){let{_meta:e,...t}=r;return Bn(Pr(Dt(t)))}function zu(r,e){let t=Em[String(r).toLowerCase()]??[],n={},s={};for(let[i,o]of Object.entries(e))t.includes(i)?s[i]=o:n[i]=o;return[n,s]}function Mr(r){return String(r)}function Rn(r,e,t=null){let n={...e},{mask:s,format:i,locale:o,timeZone:a,dtype:l,places:u}=n;for(let d of km)delete n[d];let c=d=>{if(t&&i!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:i,mask:s,...o==null?{}:{locale:o},...a==null?{}:{timeZone:a},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=Mr(d)),s==null)return d;let f=d==null?"":Mr(d);return f===""?f:Qs(f,s)};return Array.isArray(r)?(Object.hasOwn(n,"_text")&&(n._text=c(n._text)),[r,n]):[c(r),n]}function Me(r){return typeof r=="string"&&r.startsWith("==")}function xm(r,e,t=r){let n=new Map,s=new Set,i=new Map;for(let[a,l]of e){if(typeof a!="string")continue;let u=V(l)?.pointer??l;i.set(a,u instanceof Z?u.resolve():r.pointerType(u)?t.getRelativeData(u):Me(u)?null:u)}let o=a=>{if(n.has(a))return n.get(a);if(!e.has(a))throw new Error(`Source attribute '${a}' does not exist`);if(s.has(a))throw new Error(`cyclic attribute dependency: ${[...s,a].join(" -> ")}`);s.add(a);let l=e.get(a),u=V(l),c=u?i.get(a):null,d,f=h=>h?o(h):c;try{if(u)if(u.expression){let h=zr(u.body),p=h.slots.map(f);d=r.rootBuilder.evaluatePointerExpression(r,a,l,h,p)}else d=Hr(u.body,f),c==null&&(d=null);else d=i.get(a);return n.set(a,d),d}finally{s.delete(a)}};return{resolve:o}}function St(r,e,t=r){let n=new Map([...Object.entries(r.getAttr()),...he(r.getAttr())]);return xm(r,n,t).resolve(e)}var Dm={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"]},Po=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],Sm=["_if","_else","_onRemote","_onCalling"],Fo=class{#e;#t=null;#r=null;#s=!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,n=this.#s;this.#s=!0;try{t=e()!==!1}finally{this.#s=n,!t&&!this.#t&&this.#n()}return t}submit(e,t,n){try{let s=W(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((i,o)=>{this.#r={method:e,text:s,perform:n,resolve:i,reject:o}}):(this.#r?.resolve(void 0),this.#r=null,this.#i(e,t,s,n))}catch(s){return Promise.reject(s)}}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()}#n(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#i(e.method,P(e.text),e.text,e.perform)}catch(n){t=Promise.reject(n)}t.then(e.resolve,e.reject)}#i(e,t,n,s){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let i=new AbortController,o={method:e,params:t,text:n,controller:i,ignored:!1};o.view=Object.freeze({method:e,get params(){return P(n)},sentAt:Date.now(),cancel:()=>this.#a(o)}),this.#t=o,i.signal.addEventListener("abort",()=>this.#o(o),{once:!0});let a;try{a=Promise.resolve(s(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.#n())}#a(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#s||this.#n())}};function Wu(r){return typeof r=="string"&&r.startsWith("==")}var Jt=class extends we{#e=new Set;#t=null;#r=null;get requests(){return this.#r??=new Fo(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...Dm[this.nodeTag]??[],...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters??{}).filter(([,n])=>n.inline).map(([n])=>n),...this._getMeta("gramlot_component")?.command?["action","_ask_if"]:[],...typeof this.getAttr("remote")=="string"?Sm:[]],t=[];for(let[n,s]of Object.entries(this.getAttr()??{}))typeof s=="string"&&(e.includes(n)||n==="validate_call"||n==="validate__onResult"||n==="validate_onAccept"||n==="validate_onReject"||/^validate_\w+_if$/.test(n)||n.startsWith("connect_on")||n.startsWith("subscribe_")||n.startsWith("selfsubscribe_"))&&t.push([n,s]);for(let n of["ask","_ask"]){let s=this.getAttr(n);if(s&&typeof s=="object")for(let i of["_if","askIf"])typeof s[i]=="string"&&t.push([`${n}.${i}`,s[i]])}for(let[n,s]of he(this.getAttr()))if(Wu(s)&&t.push([n,s]),this.nodeTag==="script"&&typeof s=="string"){let i=this.builder.constructor.dialectPrefixes.find(o=>n.startsWith(o))??"";["src","href","xlink:href","xlink_href","_text"].includes(n.slice(i.length).toLowerCase())&&t.push([n,s])}return(Wu(this.staticValue)||this.nodeTag==="script"&&typeof this.staticValue=="string")&&t.push(["",this.staticValue]),t}activateCode(){let e=new Map;for(let[t,n]of this.codeAttributes()){if(this.pointerType(n))throw new Error(`${this.nodeTag} '${this.label}': '${t}' is inline code and cannot be the pointer '${n}'; inline code is never read from Data`);e.set(t,n)}for(let[t,n]of[...he(this.getAttr()),["datapath",this.getAttr("datapath")]])V(n)?.expression&&e.set(t,n);this.#t=e}activatedCode(e){return this.#t?.get(e)??null}remote(e,t={}){let n=this.rootBuilder.nameSyntax;if(typeof e!="string"||!(this.pointerType(e)||n.matches(e)))throw new TypeError(`${this.nodeTag} '${this.label}': remote name must be a pointer or match ${n.pattern}, not ${JSON.stringify(e)}`);let s=Object.keys(t).find(o=>o.startsWith("_")&&!Po.includes(o));if(s)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${s}' is not accepted; the control attributes are ${Po.join(", ")}`);let i={remote:e};for(let[o,a]of Object.entries(t))i[Po.includes(o)?o:`remote_${o}`]=a;return this.setAttr(i),Tn(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=V(e)?He(this,e):new Set,n=super.pointers().filter(([s,i])=>!t.has(s)&&!this.#i(s,i)).map(([s,i])=>[s,V(i)?.pointer??i]);for(let s of t){let i=this.getAttr(s);this.pointerType(i)==="^"&&n.push(["datapath",V(i)?.pointer??i])}return n}runtimeToEvaluate(){let e=super.runtimeToEvaluate();for(let[t,n]of e)if(this.pointerType(n)){if(V(n)){if(typeof t!="string")throw new Error(`${this.nodeTag} '${this.label}': pointer suffixes belong to attributes; use format/mask for node text`);this.absDatapath(n)===null&&e.set(t,new jt(()=>St(this,t)));continue}this.#i(t,n)?e.set(t,n.slice(1)):this.absDatapath(n)===null&&e.set(t,null)}return e}pathAttribute(e){let t=this.getAttr(e);return V(t)?St(this,e):this.pointerType(t)&&this.#i(e,t)?t.slice(1):t}getRelativeData(e,t=null,n={}){return this.absDatapath(e)===null?null:super.getRelativeData(e,t,n)}setRelativeData(e,t,n={}){this.#o(e),super.setRelativeData(e,t,n)}PUT(e,t){this.#o(e),this.data.setItem(this.absDatapath(e),t,null,">",!1,!0,this,!1,!1)}FIRE(e,t=!0,n=null){t===null&&(t=!0),this.#o(e);let s=this.absDatapath(e);if(s.includes("?")){this.#s(s,t);return}this.data.getNode(s)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:n})}finally{this.data.getNode(s)?.setValue(null,!1)}}#s(e,t){let[n,s]=e.split("?",2),i=this.data;i.getNode(n)?.setAttr({[s]:null},!1);try{let o=i.getNode(n);o?o.setValue(o.staticValue,!0,{[s]:t},!0,!0,!0,!0):i.setItem(n,null,{[s]:t},">",!0,!0,!0,!0)}finally{i.getNode(n)?.setAttr({[s]:null},!1)}}FIRE_AFTER(e,t=!0,n=10){this.#o(e);let s=this.rootBuilder?.binding?.bindingFor(this)??null,i=null,o=setTimeout(()=>{i?.(),this.FIRE(e,t)},n);return i=s?.track(()=>clearTimeout(o))??null,()=>{clearTimeout(o),i?.()}}absDatapath(e){e=V(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[n,s]=t.split("?",2),i=super.absDatapath(n);return i===null?null:`${i}?${s}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let n=this;for(;n!==null&&e.startsWith(".");){let s=n.getAttr("datapath");if(this.pointerType(s)&&(s=this.#n(n,s),s===null))return null;if(s!=null&&(e=e==="."?s:s+e),e.startsWith("#"))return n.parentNode._resolveSymbolicDatapath(e,t);n=n.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 n=e.slice(1).split(".",1)[0];if(n==="FORM"||n==="ANCHOR")return super._resolveSymbolicDatapath(e,t);let s=this.rootBuilder?.binding;if(!s)return super._resolveSymbolicDatapath(e,t);let i=s.nodeIds.get(n);if(!i)throw new Error(`#<id>: cannot resolve ${t}`);let o=e.slice(n.length+2);return i.absDatapath(o?`.${o}`:".")}#n(e,t){if(V(t)){let i=St(e,"datapath",e.parentNode);return i==null||i===""?null:i}let n=e.parentNode.absDatapath(t);if(n===null)return null;let s=this.data.getItem(n);return s==null||s===""?null:s}#i(e,t){return V(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 r extends D{get nodeClass(){return Jt}authorizedCopy(e){let t=new this.constructor;for(let n of this.getNodes()){let s=n.getAttr("auth")??null;if(s!==null){if(typeof s!="string")throw new TypeError(`${n.nodeTag} '${n.label}': 'auth' must be a string rule, not ${typeof s}`);if(e(s)!==null)continue}let i=n.staticValue;i instanceof r&&(i=i.authorizedCopy(e));let{auth:o,...a}=n.getAttr(),l=t.setItem(n.label,i,a,">",!1,!1,null,!1,!0,null,n.nodeTag);l.xmlTag=n.xmlTag}return t}activateCode(){for(let e of this.getNodes())e.activateCode(),e.staticValue instanceof r&&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");Ft(le.tytxSuffix,{...Re(le.tytxSuffix),GramlotBuilderBag:le});var Cm=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"]),Mn=class extends Xt{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let n=this.owner.evaluateExpressions(e,t);Lr(e,n);let[s,i]=super._handleMeta(e,n);return $r(e,i),e._getMeta("subbuilder")?[s,Xs(ei(i))]:[s,i]}adaptAttrs(e){let{_meta:t,...n}=e;return Bn(super.adaptAttrs(Pr(Dt(n))))}renderedItem(e,t,n,s={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,n,s);let{_text:i,...o}=n;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&i!=null&&(t=[this._escapeText(Mr(i)),...t]),Cm.has(s.tag)?`${s.pretty?" ".repeat(this._nodeDepth(e,s.depthOffset??0)):""}<${s.tag}${this._formatAttrs(o)} />${s.pretty?`
|
|
61
|
-
`:""}`:super.renderedItem(e,t,o,s)}};var Kt=class extends Gt{#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 xt&&this.addRender(e,new Mn(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[n,s]=e.rootBuilder.runtimeValues(e),i=this.getRender(e.builder),[o,a]=i._handleMeta(e,s);return e._getMeta("subbuilder")||(a=i.adaptAttrs(a)),i.renderedItem(e,e.value instanceof D?this.renderChildren(e.value,t):n,a,{tag:o,...t})}_handleMeta(e,t){let n=this.builder.constructor.dialectPrefixes,s=this.evaluateExpressions(e,t);Lr(e,s,n);let[i,o]=super._handleMeta(e,Hu(e,s,n));if($r(e,o,n),e.nodeTag==="webcomponent"){i=at(e.getAttr());let{code:u,...c}=o;o=c}if(e._getMeta("subbuilder")){let u=ei(o);return e._getMeta("subbuilder")==="html"&&(u.xmlns=On),[i,u]}let[a,l]=zu(i,o);return Object.keys(l).length&&this.#e.set(e,l),[i,a]}evaluateExpressions(e,t){let n=this.inlineCompiler,s=(o,a)=>n?n.compileExpression(e,o,a)(t):null,i={...t};for(let[o,a]of he(e.getAttr()))Me(a)&&Object.hasOwn(i,o)&&(i[o]=s(o,a));return Me(e.value)&&this.#t.set(e,s("",e.value)),i}expressionValue(e,t){return Me(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let n=this.#e.get(e);return n?(this.#e.delete(e),{...t,...Pr(n)}):t}adaptAttrs(e){let{_meta:t,...n}=e,s=`${this.builder.constructor._name}_`,i=this.builder.constructor.dialectPrefixes,o={},a={};for(let[l,u]of Object.entries(Dt(n))){if(u==null)continue;if(l.startsWith(s))throw new Error(`${l}: the attribute prefix '${s}' is not accepted; use the prefix '${i[0]}'`);let c=i.find(d=>l.startsWith(d));c?o[l.slice(c.length)]=u:a[l]=u}return Bn({...super.adaptAttrs(a),...o})}renderedItem(e,t,n,s={}){let i;[t,i]=Rn(this.expressionValue(e,t),this.restoreNativeAttributes(e,n));let{_text:o,...a}=i;Array.isArray(t)&&o!=null&&(t=[this._escapeText(Mr(o)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:Ue,...a}:a;return super.renderedItem(e,t,l,s)}finalize(e,t=null,n={}){if(!n.doctype)return super.finalize(e,t,n);let s=this._composeStringFragments(e),i=this.builder.source.getNodes().filter(o=>!o._getMeta("data_element"));return i.length===1&&i[0].nodeTag==="html"||(s=`<html>${s}</html>`),super.finalize(`<!doctype html>${s}`,t,n)}};var Gu={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"}}}};var Xu={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 xe(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),r=>r.toString(16).padStart(2,"0")).join("")}var Om="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",Bm=new Set,Rm=new Set(["serverpath","dbenv","shared_id"]),Mm=["formsubscribe_"],$m={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},Lm={dataFormula:"formula",dataController:"script"};function Yu(r,e){if(["input","textarea","select","webcomponent"].includes(r)&&V(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(r==="html_button"&&Object.keys(e).some(s=>["action","ask","_delay","fire"].includes(s)||s.startsWith("fire_")))return"plain HTML button: use button for action, ask, fire or _delay";if(Object.hasOwn(e,"ask")&&!["button","toggleButton","dropDownButton","menuline"].includes(r))return"'ask' is supported on buttons";if(Object.hasOwn(e,"_ask")&&!["dataController","dataFormula","dataRpc"].includes(r))return"'_ask' requires a controller, formula or RPC";if(["dataSetter","dataRemote"].includes(r)&&Object.keys(e).some(s=>s.startsWith("subscribe_")||s.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=$m[r];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let n=Lm[r];return n&&e[n]!=null&&e.func!=null?`'func' and '${n}' cannot be declared on the same node`:n&&e._if!=null&&e.func!=null?"'_if' is inline and cannot be declared with 'func': write the condition in the method":null}function Zu(r){return Object.keys(r).find(e=>Rm.has(e)||Mm.some(t=>e.startsWith(t)))}var qe=class r extends Tt{static _name="gramlot";static _sourceClass=le;static{this.defineGrammar(Gu)}static{this.defineGrammar(Xu)}static{this.defineGrammar(Js.toDocument())}static get dialectPrefixes(){let e=[];for(let t=Object.getPrototypeOf(r);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:n=null,nameSyntax:s=Nn}={}){if(!(s instanceof Yt))throw new TypeError(`nameSyntax must be a NameSyntax, not ${s}`);super(e),this._binding=null,this._auth=n,this._nameSyntax=s;for(let i of t)this.loadCollection(i)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,n,s,i){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,n,s.text)(i):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 Zt?e.toDocument():e),this}schemaTag(e){let t=e.toLowerCase(),n=r.dialectPrefixes;if(t.startsWith(`${r._name}_`))throw new Error(`${e}: the tag prefix '${r._name}_' is not accepted; use the prefix '${n[0]}'`);if(Bm.has(t))throw new Error(`${e}: excluded from Gramlot`);let s=this.schemaTagNames[t];if(s)return s;for(let i of n)if(t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)])return t;return null}bagCall(e,t,n,s){return super.bagCall(e,this.#e(t),n,s)}commandOnNode(e,t,n,s){return super.commandOnNode(e,this.#e(t),n,s)}validateNodeValues(e,t,n={}){if(this.schema[e]?._meta?.gramlot_component&&V(n.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&at(n);let s=Zu(n);if(s)throw new Error(`${e}: attribute '${s}' is excluded from Gramlot`);let i=Yu(e,n);if(i)throw new Error(`${e}: ${i}`);return super.validateNodeValues(e,t,n)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&V((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&at(t.attrs??e.getAttr());let n=Zu(t.attrs??e.getAttr());if(n)throw new Error(`${e.nodeTag} '${e.label}': attribute '${n}' is excluded from Gramlot`);let s=Yu(e.nodeTag,t.attrs??e.getAttr());if(s)throw new Error(`${e.nodeTag} '${e.label}': ${s}`);return super.validateNode(e,t)}_validateChildren(e,t,n,s){return super._validateChildren(e,t,n.map(i=>i==="html_button"?"button":i),s)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,n,s,i=null){s=Object.fromEntries(Object.entries(s??{}).map(([l,u])=>[l,te(u)instanceof we?this.reference(u):u]));let a=t==="dataSetter"&&s?.value!==null&&typeof s?.value=="object"&&Object.getPrototypeOf(s.value)===Object.prototype?{...s,value:new C(s.value)}:s;return super.setChild(e,t,n,a,i)}#e(e){if(e==="data")throw new Error(Om);if(this.schemaTagNames[e.toLowerCase()]===e)return e;let t=r.dialectPrefixes.find(n=>e.startsWith(n));return this.schemaTagNames[e.slice(t.length)]}get renderer_html(){return new Kt(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,n){let s=t!=null?{_text:t}:null;e.setValue(n,!0,s,!0)}reference(e,t="node"){if(e=te(e),!(e instanceof we)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let n=e.getAttr("__ref");return n==null&&(n=xe(),e.setAttr({__ref:n})),{$gramlotRef:n,kind:t}}toTytx(){return W(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function $n(r){return typeof r=="string"&&!["null","true","false"].includes(r)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(r)}function Qt(r,e,t,n){let{group:s,method:i}=r.logicRegistry.resolve(t,e);return i.call(s,e,n)}function Qe(r,e,t,n,s,i=Object.keys(s)){return $n(n)?Qt(r,e,n,s):r.inlineCompiler.compile(e,t,n,i)(s)}var Pm=new Set(["input","select","textarea"]),Fm=["type","multiple","group"];function Ju(r,e){let t=r.getAttr(e);return r.pointerType(t)?r.getRelativeData(t):t}var be=class r{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#s;#n=!1;#i=!1;#o=!1;static for(e,t){let n=r.classFor(t.element,t.attrs);return n?new n(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"?Ho:jo;if(e.localName==="textarea")return et;if(e.localName==="select")return Ln;if(e.localName!=="input")return null;let n=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(Ku,n)?Ku[n]: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||!Pm.has(e.localName)?null:JSON.stringify(Fm.map(n=>t[n]??null))}constructor(e,t){this.#r=e,this.#s=t}get binding(){return this.#r}get element(){return this.#s.element}get node(){return this.binding.node}get eventElement(){return this.element}get resolved(){return this.#s.resolved}get live(){return!!this.resolved.live}get writeEvent(){return this.constructor.liveWrites&&this.live?"input":"change"}project(e,t){if(this.#i){this.#o=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)||(this.#e=e,this.#t=!0,!(this.#n&&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.#s.text.data!==t&&(this.#s.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.#n=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#n=!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.#i=!0;return}if(e.type==="compositionend"){this.#i=!1,this.writeEvent==="input"&&this.commit(e),this.#o&&(this.#o=!1,this.binding.runtime.renderer.project(this.node));return}this.#i||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},jo=class extends be{static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.element.setPageContext(Qu(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||ec(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},Uo=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)}},qo=class extends be{static liveWrites=!0;read(){return Number(this.element.value)}},Ln=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 n=new Set((e??[]).map(String));for(let s of t.options){let i=n.has(s.value);s.selected!==i&&(s.selected=i)}}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((n,s)=>Object.is(n,e[s])):super.same(e,t)}},er=class extends be{read(){return this.element.value===""?null:this.element.value}},Vo=class extends be{},ti=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()}},ri=class extends ti{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,n=zo(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,n)}super.attach(),t!=null&&(this.#e=this.groups.join(this,t,n),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=zo(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 n=this.node;if(Ju(n,"value")&&this.groups.peersOf(e,t).some(s=>!s.binding.closed&&s.read()))throw new Error(`${n.nodeTag} '${n.label}': several true values in radio group '${e}'`)}project(e,t){let n=!this.#t;this.#t=!0;let s=this.read();super.project(e,t),!n&&!s&&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),Ju(e.node,"value")&&e.commit(null))}}},Ho=class extends ri{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||ec(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(Qu(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,zo(this.node)).filter(o=>!o.binding.closed&&!o.element.disabled),n=t.indexOf(this);if(n<0)return;e.preventDefault();let s=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,i=t[(n+s+t.length)%t.length];i.element.focus(),i.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}))}}}},ni=class{#e;#t=new Map;#r=new Map;#s=new WeakMap;#n=0;constructor(e){this.#e=e}join(e,t,n){let s=this.nameOf(t,n);return this.#t.has(s)||this.#t.set(s,new Set),this.#t.get(s).add(e),this.#r.set(e,s),s}leave(e){let t=this.#r.get(e);this.#r.delete(e);let n=this.#t.get(t);n?.delete(e),n?.size===0&&this.#t.delete(t)}peers(e){let t=this.#r.get(e);return[...this.#t.get(t)??[]].filter(n=>n!==e)}peersOf(e,t){return[...this.#t.get(this.nameOf(e,t))??[]]}nameOf(e,t){t!==null&&!this.#s.has(t)&&this.#s.set(t,this.#n++);let n=t===null?"page":`form${this.#s.get(t)}`;return`gramlot-${this.#e.instanceId}-${n}-${e}`}};function zo(r){for(let e=r;e;e=e.parentNode){let t=e.getAttr()??{};if(t.formId!=null||t.form===!0)return e}return null}var Ku={text:et,password:et,email:et,url:et,tel:et,search:et,number:Uo,range:qo,color:Vo,date:er,time:er,month:er,week:er,"datetime-local":er,checkbox:ti,radio:ri,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function Qu(r){let{binding:e,node:t}=r,n=e.runtime.gramlot,s=(i,o,a,l=!1)=>l?e.runtime.inlineCompiler.compile(t,i,o,Object.keys(a),`return (${o});`)(a):Qe(e.runtime,t,i,o,a);return{locale:n.locale,timeZone:n.timeZone,createDecimal:Et,isDecimal:fe,getDecimalLibrary:To,publish:(i,o)=>t.publish(i,o),isActive:()=>!e.closed,callLogic:(i,o)=>Qt(e.runtime,t,i,o),format:(i,o)=>n.format(i,o),invoke:s,remote:(i,o,a)=>n.rpc.call("data",i,o,{signal:a}),validationCurrent:()=>{let i=t.getAttr("value"),o=t.pointerType(i)?t.absDatapath(i):null;return()=>!e.closed&&t.getAttr("value")===i&&(o===null||t.absDatapath(i)===o)},finishValidation:({ok:i,result:o,rules:a})=>{if(e.closed)return;if(i)for(let u of o.datachanges)t.getRelativeData(".").update(u);let l=i?"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=s(l,a[l],{value:o.value,result:o,validations:c,userChange:!0});d instanceof Promise&&d.catch(u)}catch(c){u(c)}}},checkDataPatch:i=>{if(!(i instanceof C))throw new TypeError("Validation data changes must be a Bag.");if(!(t.getRelativeData(".")instanceof C))throw new TypeError("Validation data changes require a Bag datapath.")}}}function ec(r,e,t){let n=s=>{s.ok&&s.isCurrent()&&(t(s),r.finishValidation(s))};e instanceof Promise?e.then(n).catch(s=>console.error("Validation notification failed:",s)):n(e)}var Wo=Symbol("source text"),tc={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},jm=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"]),Um=new Set(["checked","muted","selected","value"]),qm=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function Vm(r){let e=r.replace(/-([a-z])/g,(t,n)=>n.toUpperCase());return qm.get(e.toLowerCase())??e}var si=class{constructor({metadataAttributes:e=[],invokeScript:t=null,callLogic:n=null}={}){this.invokeScript=t,this.callLogic=n,this.metadataAttributes=new Set([...Ut,"_text",...e])}definition(e){let t=e.builder,s={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},i=e.nodeTag==="webcomponent"?at(e.getAttr()):An(e.nodeTag,{renderTag:s.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),o=i==="foreignObject"?On:s.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof xt?On:Ue);return{meta:s,namespace:o,tag:i}}validate(e,t=e.builder){let n=e.value instanceof D,s=n?e.getAttr("_text"):e.value;if(s!=null&&!["string","number","boolean"].includes(typeof s))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)&&!(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 i=Object.fromEntries(Object.entries(e.attr).filter(([a])=>!this.metadataAttributes.has(a))),o=n?e.value.getNodes().map(a=>a.nodeTag).filter(Boolean):[];t.validateNode(e,{value:s,attrs:i,childTags:o})}create(e,t,n=null,s=e.attr,i=null){let{tag:o,namespace:a,meta:l}=this.definition(e);n??=o;let u=a===Ue?t.createElement(n):t.createElementNS(a,n);if(l.gramlot_component&&u.constructor.gramlotComponent?.tag!==n)throw new Error(`Component collection must be activated before rendering ${n}`);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:n};return this.update(d,e,s,Wo,i),d}matches(e,t){let{tag:n,namespace:s}=this.definition(t);return(s===Ue?e.tag.toLowerCase()===n.toLowerCase():e.tag===n)&&e.element.namespaceURI===s}writeParameter(e,t,n){let s=e.getAttr(t);e.pointerType(s)==="^"&&!V(s)&&!Object.is(e.getRelativeData(s.slice(1)),n)&&e.setRelativeData(s.slice(1),n)}compose(e,t,n){e.text.data=t??"";for(let s of n)e.element.append(s)}update(e,t,n=t.attr,s=Wo,i=null){if(t.nodeTag==="script"){for(let[g,b]of t.codeAttributes())if(t.activatedCode(g)!==b)throw new Error(`script '${t.label}': '${g}' 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=g=>(Lr(t,g,t.builder.constructor.dialectPrefixes),$r(t,g,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(g)),f=t.parentNode;f?._getMeta("gramlot_component")?.childParameters&&(n=o.ownerDocument.defaultView.customElements.get(f._getMeta("render_tag")).projectChild(o,n,{adapt:d,invoke:(b,y,w)=>this.invokeScript(t,b,y,w),publish:(b,y)=>t.publish(b,y),publishParent:(b,y)=>f.publish(b,y),writeParameter:(b,y)=>this.writeParameter(t,b,y),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"))),n=o.projectAttributes(n,d)),n=Object.fromEntries(he({...n,...u}));let h=be.classFor(o,n)!==null;s===Wo&&(s=this.text(t));let p=s==null?"":String(s);a.data!==p&&(a.data=p);let m=[...new Set([...Object.keys(c),...Object.keys(n)])];m.sort((g,b)=>(b==="sandbox")-(g==="sandbox"));for(let g of m){if(this.metadataAttributes.has(g)||["ask","_ask"].includes(g)||h&&g==="value")continue;let b=n[g],y=g,w=Vm(y),k=l&&jm.has(w)&&typeof o[w]=="boolean",A=y==="xmlns"?"xmlns":y.includes(":")?y.split(":")[0]:"",v=Object.hasOwn(tc,A)?tc[A]:null;if(Object.is(c[g],b)||(b==null||k&&!b?v?o.removeAttributeNS(v,y.split(":").at(-1)):o.removeAttribute(y):v?o.setAttributeNS(v,y,String(b)):o.setAttribute(y,k?"":String(b))),l&&(k||Um.has(w))&&w in o){let N=w==="value"?b==null?"":String(b):!!b;o[w]!==N&&(o[w]=N)}}i===!1?o.style.visibility!=="hidden"&&(o.style.visibility="hidden"):e.visible===!1&&(n.style==null?o.removeAttribute("style"):o.setAttribute("style",String(n.style))),e.visible=i,e.attrs=n}text(e){return e.value instanceof D?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};var ii=class r{#e;#t;#r=null;#s=0;static for(e,t){return t.element?.constructor.gramlotComponent?.command?new r(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 n=e.getAttr()??{},s=[];if(t.length&&s.push("controller"),n.action!=null&&s.push("action"),rc(n).length&&s.push("fire"),s.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${s.join(" and ")} together; a button has one click mechanism`);return s[0]??null}attach(){this.refresh(),this.element.activateCommand=e=>this.onClick(e),this.element.attachCommand(),this.element.addEventListener("click",this)}refresh(){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?.()}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)||!this.mechanism||(e.stopPropagation(),this.element.disabled))return;let s=this.binding.countClick(),i=this.node;for(;i&&i.getAttr("_delay")==null;)i=i.parentNode;let o=i?i.rootBuilder.runtimeValues(i)[1]._delay:0;if(o>0){let a=this.#s+1;this.#r?.(),this.#s=a;let l=setTimeout(()=>{u(),this.#r=null,this.#s=0,this.#n(e,a)},o),u=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(l),u(),this.#r=null,this.#s=0};return}return this.#r?.(),this.#n(e,s)}#n(e,t){if(this.binding.closed||this.element.disabled)return;let n=this.mechanism;if(!n)return;let s=this.node,i=Hm(e);if(n==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t});else if(n==="action"){let o=()=>{let[,c]=s.rootBuilder.runtimeValues(s),d=Object.fromEntries(Object.entries(c).filter(([f])=>f!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(d),event:e,_counter:t,modifiers:i}},a=c=>{if(this.binding.closed||this.element.disabled||c===null)return;let d={...o(),...c};c&&(d._askResult=c),Qe(this.binding.runtime,s,"action",s.getAttr("action"),d)},l=s.getAttr("ask"),u=this.binding.runtime.askDialog;if(l&&u.required(this.binding,l,o(),"ask"))return u.show(this.binding,l,o()).then(a);a(void 0)}else{let o={modifier:i,_counter:t},a=s.getAttr("fire");if(a!=null){s.FIRE(a,i||!0,o);return}for(let[l,u]of rc(s.getAttr())){if(this.binding.closed)return;s.FIRE(u,l.slice(5),o)}}}};function rc(r){return Object.entries(r??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function Hm(r){return["shift","ctrl","alt","meta"].filter(e=>r[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var oi="connect_on",Pn=class{#e;#t;#r;#s;#n;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,n])=>t.startsWith(oi)&&t.length>oi.length&&n!=null).map(([t,n])=>[t,t.slice(oi.length).toLowerCase(),n])}constructor(e,t,n,s,i=`${oi}${n}`){this.#e=e,this.#t=t,this.#r=n,this.#s=s,this.#n=i}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.#s}get attribute(){return this.#n}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,n=this.binding.runtime;if($n(this.handler))return Qt(n,t,this.handler,e);n.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function Ct(r,e=new Set){if(!r||typeof r!="object")return;let t=r.ownerDocument?.defaultView?.Node??r.defaultView?.Node;if(te(r)instanceof we||t&&r instanceof t)throw new TypeError("Live Source/DOM references cannot cross a transport boundary");if(e.has(r))throw new TypeError("Transport data cannot contain circular references");e.add(r);let n=r instanceof C?r.getNodes().flatMap(s=>[s.staticValue,s.getAttr()]):Object.values(r);for(let s of n)Ct(s,e);e.delete(r)}var Fn=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let n=new Map,s=i=>{for(let o of i.getNodes()){let a=o.getAttr("__ref");if(a){if(n.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");n.set(a,o)}o.value instanceof D&&s(o.value)}};s(e)}register(e,t){let n=e.getAttr("__ref");if(n){if(this.entries.has(n))throw new Error(`Duplicate Source reference: ${n}`);this.entries.set(n,{node:e,dom:t})}}remove(e){for(let[t,n]of this.entries)n.node===e&&this.entries.delete(t)}resolveArguments(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n&&typeof n=="object"&&Object.hasOwn(n,"$gramlotRef")?this.resolve(n):n]))}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 ai=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},Go=class{#e;#t;#r;#s;#n;#i=!0;#o;constructor(e,{path:t,attr:n,recipient:s,order:i,subtree:o=!1}){this.#e=e,this.#t=t,this.#r=n,this.#s=s,this.#n=i,this.#o=o}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#s}get subtree(){return this.#o}get active(){return this.#i}get order(){return this.#n}close(){this.active&&(this.#i=!1,this.router.unregister(this))}},Xo=class{constructor({evt:e,node:t,path:n,oldvalue:s,attrsDiff:i,reason:o,fired:a,level:l,registration:u}){this.evt=e,this.node=t,this.path=n,this.oldvalue=s,this.attrsDiff=i,this.reason=o,this.fired=a,this.level=l,this.registration=u}},li=class{#e;#t=new ai;#r=new Map;#s=0;#n=0;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return this.#s}register({path:e,attr:t=null,recipient:n,subtree:s=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let i=this.#t;for(let a of e.split(".")){let l=i.children.get(a);l||(l=new ai(i,a),i.children.set(a,l)),i=l}this.#n+=1;let o=new Go(this,{path:e,attr:t,recipient:n,order:this.#n,subtree:s});return i.registrations.add(o),this.#r.set(o,i),this.#s+=1,o}unregister(e){let t=this.#r.get(e);if(t)for(this.#r.delete(e),t.registrations.delete(e),this.#s-=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]!==Sn||e.reason==="autocreate")return;let n=t.slice(1),s=e.evt==="ins"||e.evt==="del";for(let i of Array.isArray(e.node)?e.node:[e.node]){let o=s?[...n,i.label]:n,a=o.join(".");for(let[l,u]of this.#i(o,e))l.active&&l.recipient.receive(new Xo({evt:e.evt,node:i,path:a,oldvalue:e.oldvalue??null,attrsDiff:e.attrs_diff??null,reason:e.reason??null,fired:e.fired??!1,level:u,registration:l}))}}#i(e,t){let n=[],s=this.#t;for(let o of e){for(let a of s.registrations)s!==this.#t&&this.#o(a,"child",t)&&n.push([a,"child"]);if(s=s.children.get(o),!s)return n.sort(([a],[l])=>a.order-l.order)}for(let o of s.registrations)this.#o(o,"node",t)&&n.push([o,"node"]);let i=[...s.children.values()];for(;i.length;){let o=i.pop();for(let a of o.registrations)this.#o(a,"container",t)&&n.push([a,"container"]);i.push(...o.children.values())}return n.sort(([o],[a])=>o.order-a.order)}#o(e,t,n){let{evt:s}=n;return e.subtree?t!=="container"||s!=="upd_attrs":e.attr===null?s==="upd_attrs"?!1:!(t==="child"&&n.fired):t==="child"?!1:t==="container"?s!=="upd_attrs":s==="ins"||s==="del"?!0:Object.hasOwn(n.attrs_diff??{},e.attr)}};var ui=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=jn(e),n=this.setterNodes(e);Zo(e);for(let s of n){let i=this.runtime.openBinding(s);i.hasStamp("installed")||(this.applySetter(s),i.stamp("installed"))}this.applyDefaults(t.filter(s=>s.nodeTag&&!s._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 n=e.getAttr("value")??null,s=Wm(e.getAttr()),i=this.runtime.data;if(n!==null)i.setItem(t,n,s,">",!1,!0,e),n instanceof C&&e.setAttr({value:null},!1);else{let o=i.getNode(t);o?s&&o.setAttr(s,!0):i.setItem(t,null,s,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let n=t.getAttr();for(let[s,i]of Object.entries(n)){if(!zm(t,s,i))continue;let o=s==="value"?n.default_value??n.default:n[`default_${s}`];o!=null&&this.#t(t,i,o)}this.#r(t,n)}}#t(e,t,n){let s=e.absDatapath(t);if(s===null)return;let[i,o=null]=s.split("?",2),a=this.runtime.data,l=a.getNode(i);if(o===null){if(l&&l.value!==null&&l.value!==void 0)return;a.setItem(i,n,null,">",!1,!0,e)}else if(l){let u=l.getAttr(o);u==null&&l.setAttr({[o]:n},!0)}else a.setItem(i,null,{[o]:n},">",!1,!0,e)}#r(e,t){let n={};for(let[o,a]of Object.entries(t))o.startsWith("attr_")&&(n[o.slice(5)]=V(a)?St(e,o):e.pointerType(a)?e.getRelativeData(a):a);if(!Object.keys(n).length)return;let s=[t.value,t.src].find(o=>e.pointerType(o));if(!s)return;let i=e.absDatapath(s);i!==null&&this.runtime.data.getNode(i.split("?",1)[0])?.setAttr(n,!0,!0,!1)}};function zm(r,e,t){return e==="_meta"||Ut.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:r.pointerType(t)!==null}function Wm(r){let e={};for(let[t,n]of Object.entries(Dt(r??{})))Ut.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||n!=null&&(e[t]=n);return Object.keys(e).length?e:null}function Gm(r){let e=r.builder;if(!(e instanceof qe))throw new Error(`dataSetter '${r.label}': dataSetter is not supported inside ${e.constructor._name}`)}function Zo(r){for(let e of jn(r))e.nodeTag==="dataSetter"&&Gm(e),Km(e)}var Xm=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],Ym=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),Zm=["_onCalling","_onResult","_onError"],Jm=["_delay","_timing","_userChanges"],Yo=["_init","_onBuilt","_onStart"];function Km(r){let e=i=>r.getAttr(i)!==null&&r.getAttr(i)!==void 0,t=!r._getMeta("data_element")&&typeof r.getAttr("remote")=="string";if(r.nodeTag!=="dataRpc"){let i=Zm.find(o=>e(o)&&!(o==="_onCalling"&&(r.nodeTag==="dataRemote"||t)));if(i){let o=i==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${r.nodeTag??"fragment"} '${r.label}': '${i}' is allowed only on ${o}`)}}if(Ym.has(r.nodeTag)){let i=Object.entries(r.getAttr()).find(([,a])=>Me(a));if(i)throw new Error(`${r.nodeTag} '${r.label}': '${i[0]}' is a == expression, not accepted on ${r.nodeTag}`);let o=r.nodeTag==="dataRemote"?Yo.find(e):null;if(o)throw new Error(`dataRemote '${r.label}': '${o}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let a of Yo){let l=r.getAttr(a);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${r.nodeTag} '${r.label}': '${a}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let n=Xm.find(i=>e(i)&&!(i==="_delay"&&!r._getMeta("data_element")&&r.nodeTag!=="html_button")&&!(t&&Jm.includes(i)));if(!n)return;let s=Yo.includes(n)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${r.nodeTag??"fragment"} '${r.label}': '${n}' is allowed only on ${s}`)}function jn(r){if(r instanceof D)return r.getNodes().flatMap(t=>jn(t));let e=[r];return r.value instanceof D&&e.push(...jn(r.value)),e}var Ve=class extends Z{static classKwargs={...Z.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(n=>this.#t(n));if(e===null)return null;let t=()=>{this.loading===e&&(this.loading=null)};return e.then(t,t),this.loading=e,e.catch(n=>{n?.name!=="AbortError"&&this.onError(n)}),e}resolveSync(e){return super.resolve(e)}prepareValue(e){return e}#e(){let e={...this._kw};for(let[t,n]of Object.entries(this.node?.attr??{}))this.constructor.internalParams.has(t)||(e[t]=n);return this._computeEffectiveFingerprint(e)}async#t(e){if(this.closed)return;let t=this.#e(),n=await this.loadAsync(e);if(this.closed||e.ignored)return;let s=this.prepareValue(n);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(s,this.cacheTime!==0):this.cachedValue=s}finally{this.writing=!1}return s}};var ci=class extends Ve{static internalParams=new Set([...Ve.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:n,cacheTime:s,onCalling:i=null,onError:o,sync:a=!1}){super({cacheTime:s,onError:o}),this.binding=e,this.sync=a,this.method=t,this.params=n,this.onCalling=i}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 Qm=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"]),Un=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let n=null,s=setTimeout(()=>{n(),this.#r=null,t()},e);n=this.binding.track(()=>clearTimeout(s)),this.#r=()=>{clearTimeout(s),n(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let n=setInterval(t,e*1e3),s=this.binding.track(()=>clearInterval(n));this.#t=()=>{clearInterval(n),s(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},Fr=class{#e;#t=[];#r=new Set;#s;#n=null;#i=!1;constructor(e){this.#e=e,this.#s=new Un(e),e.track(()=>{this.cancel(),this.#m(),this.#p()})}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 n=this.binding.runtime.router,s=He(e,e.getAttr("_timing"));for(let[i,o]of e.pointers()){if(i==="datapath")continue;let a=e.absDatapath(o);if(a===null)continue;let[l,u=null]=a.split("?",2),c=n.register({path:l,attr:u,recipient:this});this.#t.push(c),(i==="_timing"||s.has(i))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(i,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.#s.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},n=this.#a("_delay");n>0?this.#s.debounce(n,()=>this.invoke(t)):this.invoke(t)}invoke(e){if(this.binding.closed)return;let t=this.node,n=this.kind==="formula",s=this.kind==="rpc",i=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]=[n?"formula":"script",t.getAttr(n?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,o,!1)){if(i&&this.#p(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(s||i){this.#l(u,c,c,o,!0);return}}if(s)return this.#f(o);if(i)return this.#u(o);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,n?`return ${c}`:c,o,!0);else if(f==null){if(!n)return;h=new C(di(o))}else{let{group:p,method:m}=this.binding.runtime.logicRegistry.resolve(f,t);h=n?m.call(p,o):m.call(p,t,o)}n&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,n]=t.rootBuilder.runtimeValues(t),s=Object.fromEntries(Object.entries(n).filter(([l])=>!Qm.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),i={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(s)};e.kind==="subscription"&&(i._subscription_kwargs=e.payload);let o=e.change??null,a=o?o.level:e.kind==="subscription"?e.topic:e.kind;return i._node=o?o.node:null,i._triggerpars={kw:o,trigger_reason:a},i._reason=a,e.kind==="click"&&Object.assign(i,eg(e)),i}cancel(){this.#s.cancel()}#o(){this.#s.startTiming(this.#a("_timing"),()=>this.invoke({kind:"timing",change:null}))}#a(e){let t=this.node,n=t.getAttr(e);return V(n)?St(t,e):t.pointerType(n)?t.getRelativeData(n):n??null}#l(e,t,n,s,i){let o=[...i?["_kwargs"]:[],...nc,...sc,...Object.keys(di(s))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?Qe(this.binding.runtime,this.node,e,t,{...s,_kwargs:s},o):this.binding.runtime.inlineCompiler.compile(this.node,e,t,o,n)({...s,_kwargs:s})}async#f(e){let t=this.node,[n,s,i]=["_onCalling","_onResult","_onError"].map(a=>t.getAttr(a)),o=t.requests;if(o.calling(n?()=>this.#l("_onCalling",n,n,e,!0):null))return o.submit(this.#a("method"),di(e),a=>this.#h(a,e,s,i))}async#h(e,t,n,s){if(this.binding.closed)return;let i=this.node,o=this.#a("timeout"),a=o>0?setTimeout(()=>{let c=new Error(`${i.nodeTag} '${i.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(!s)throw l.error;this.#l("_onError",s,s,{...t,error:l.error},!0);return}let{result:u}=l;i.getAttr("result_path")!=null&&i.setRelativeData(i.pathAttribute("result_path"),u),n&&this.#l("_onResult",n,n,{...t,result:u},!0)}#u(e){this.#p();let t=this.#i;this.#i=!1;let n=this.node,s=n.absDatapath(n.pathAttribute("destination_path"));if(s===null)return;let i=n.getAttr("_onCalling"),o=new ci({binding:this.binding,method:this.#a("method"),params:di(e),cacheTime:this.#a("cacheTime"),sync:this.#a("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:i?()=>this.#l("_onCalling",i,i,e,!0):null,onError:a=>{throw new Error(`${n.nodeTag} '${n.label}': dataRemote '${o.method}' failed: ${a.message}`,{cause:a})}});this.binding.runtime.data.setResolver(s,o),this.#n={path:s,resolver:o},t&&o.refresh()}#p(){if(!this.#n)return;let{path:e,resolver:t}=this.#n;this.#n=null,this.#i=t.loaded||t.loading!==null;let n=this.binding.runtime.data.getNode(e);n?.resolver===t&&(n.resolver=null)}#m(){for(let e of this.#t.splice(0))e.close();this.#r.clear()}},fi=class extends Fr{get kind(){return"formula"}},hi=class extends Fr{get kind(){return"controller"}},pi=class extends Fr{get kind(){return"rpc"}},mi=class extends Fr{get kind(){return"remote"}},nc=["_node","_triggerpars","_reason","_subscription_kwargs","_askResult"],sc=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function di(r){let e={...r};for(let t of[...nc,...sc])delete e[t];return e}function eg({event:r,counter:e}){return{_evt:r,button_counter:e,button_shift:!!r.shiftKey,button_ctrl:!!r.ctrlKey,button_alt:!!r.altKey,button_meta:!!r.metaKey}}var tg=[[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 "]],rg=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,ng=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"]),gi=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,n){let s=n.trim();if(rg.test(s))throw new Error(`${qn(e,t)}: the PUBLISH macro is excluded from Gramlot`);let i=s.replace(/\$(\d+)/g,(o,a)=>`arguments[${parseInt(a,10)-1}]`);for(let[o,a,l]of tg)o&&(i=i.replace(o,`; ${o.source.slice(1)}`)),i=i.replace(a,l);return i!==s&&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`),i}compile(e,t,n,s,i=n){if(e.activatedCode(t)!==n)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!==i&&(a={source:i,text:this.preprocess(e,t,i),key:null,run:null},o.set(t,a));let l=s.filter(sg),u=l.join(",");if(a.key!==u){let c=ig(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,n){let s=n.slice(2).trim(),i=he(e.getAttr()).filter(([,a])=>!Me(a)),o=this.compile(e,t,n,[...i.map(([a])=>a).filter(a=>a!=="_F"),"_F"],`return ${s}`);return a=>{let l={};for(let[u,c]of i)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,n,s){let i=this.compile(e,t,n,["_pointerValues","_F"],`return (${s}
|
|
62
|
-
)`);return o=>
|
|
63
|
-
)`)():new Function(...
|
|
64
|
-
`)}catch(
|
|
65
|
-
${t}`,{cause:s})}}var bi=class{#e;#t;#r=!1;#s=null;#n=null;constructor(e){this.#e=e,this.#t=new Un(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),n=t.remote,s={};for(let[l,u]of Object.entries(t))l.startsWith("remote_")&&(s[l.slice(7)]=u);let i=e.getAttr("_if");if(i&&!this.#a("_if",i,`return (${i})`,s)){let l=e.getAttr("_else");l&&this.#a("_else",l,l,s);return}let o;try{let l=W(s);if(t._cachedRemote&&this.#i(n,l))return;let u=e.getAttr("_onCalling");if(!e.requests.calling(u?()=>this.#a("_onCalling",u,u,s):null))return;o=await this.binding.runtime.gramlot.src.remoteSource(e,n,s)}catch(l){throw new Error(`${e.nodeTag} '${e.label}': remote '${n}' failed: ${l.message}`,{cause:l})}let a=e.getAttr("_onRemote");!this.closed&&o&&a&&this.#a("_onRemote",a,a,s)}fragmentMounted(e,t){this.#s=e,this.#n=t}#i(e,t){let n=this.node.requests.inflight;return n?n.method===e&&W(n.params)===t:e===this.#s&&t===this.#n}#o(e){let[,t]=this.node.rootBuilder.runtimeValues(this.node);return t[e]??null}#a(e,t,n,s){return e==="_onRemote"?Qe(this.binding.runtime,this.node,e,t,s):this.binding.runtime.inlineCompiler.compile(this.node,e,t,Object.keys(s),n)(s)}};var og=new Set(["title","msg","fields","_if","askIf"]),ag=new Set(["name","lbl","tag","type","default_value","required","min","max","step","placeholder"]),_i=class{#e;#t=null;#r=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}required(e,t,n,s){let i=(o,a)=>typeof a=="boolean"?a:e.runtime.inlineCompiler.compile(e.node,o,a,Object.keys(n),`return (${a});`)(n);if(typeof t=="string"){let o=e.node.getAttr("_ask_if");return!o||!!i("_ask_if",o)}return t?.askIf&&i(`${s}.askIf`,t.askIf),!t?._if||!!i(`${s}._if`,t._if)}show(e,t,n,s="Parameters"){let i=typeof t=="string"?{msg:t,title:s}:t;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ask requires text or a parameter description");for(let d of Object.keys(i))if(!og.has(d))throw new Error(`Unsupported ask option: ${d}`);let o=i.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(!ag.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.#s(),c=this.#r;return new Promise((d,f)=>{let h=`ask_${xe()}`,p=!1,m=()=>{},g=(b,y=null)=>{if(p)return;p=!0;let w=b?Object.fromEntries(o.map(k=>[k.name,l.data.getItem(`${h}.${k.name}`)])):null;c.delete(h),m();try{l.src.source.popNode(h),l.data.getNode(h)&&l.data.popNode(h),y?f(y):d(w)}catch(k){f(k)}};c.set(h,{finish:g}),m=e.track(()=>g(!1));try{let b=new qe,y=b.root.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;"});y.h2(i.title??s,{id:`${h}_title`,style:"font-size:1.1em;margin:0 0 12px;"}),i.msg&&y.p(i.msg);let w=y.form({request:h,connect_onsubmit:`${u}.confirm`});for(let v of o){w.dataSetter({destination_path:`.${v.name}`,value:Object.hasOwn(n,v.name)?n[v.name]:v.default_value??(v.type==="checkbox"?!1:"")});let N=w.div({style:"margin:8px 0;"});N.html_label(v.lbl??v.name,{for:`${h}_${v.name}`,style:"display:block;margin-bottom:4px;"});let L={id:`${h}_${v.name}`,value:`^.${v.name}`,live:!0};for(let U of["required","min","max","step","placeholder"])v[U]!==void 0&&(L[U]=v[U]);v.tag==="textarea"?N.textarea(L):N.input({...L,type:v.type??"text"})}let k=w.div({style:"display:flex;justify-content:flex-end;gap:8px;margin-top:16px;"});k.html_button("Cancel",{type:"button",request:h,connect_onclick:`${u}.cancel`}),k.html_button("Confirm",{type:"submit",autofocus:o.length===0}),l.src.source.setItem(h,l.src.prepareSource(b.source));let A=l.src.binding.nodeIds.get(h);l.dom.getDomNode(A).showModal()}catch(b){g(!1,b)}})}#s(){if(this.#t===null){let e=`ask_${xe()}`,t=this.#r;class n{confirm(i,o){o.preventDefault(),t.get(i.getAttr("request"))?.finish(!0)}cancel(i,o){o.preventDefault(),t.get(i.getAttr("request"))?.finish(!1)}}this.runtime.logicRegistry.register(n,{group:e,resource:"gramlot:ask"}),this.#t=e}return this.#t}};var ic={dataFormula:fi,dataController:hi,dataRpc:pi,dataRemote:mi},lg=["datapath","_anchor","nodeId","form","formId"],jr=class{#e;#t=new Map;#r=new Map;#s;#n;#i;#o;#a;#l=`gramlot-data-${xe()}`;#f=!1;constructor(e,{subscriptions:t}){this.#e=e,this.#a=t,this.#s=new li(this),this.#n=new ui(this),this.#i=new gi(this),this.#o=new _i(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.#f}get router(){return this.#s}get installer(){return this.#n}get inlineCompiler(){return this.#i}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 Jo(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof D)for(let s of e.value.getNodes())try{this.closeBranch(s)}catch(i){t.push(i)}let n=this.bindingFor(e);if(n){this.#t.delete(e);let s=e.getAttr("nodeId");this.nodeIds.get(s)===e&&this.nodeIds.delete(s);try{n.close()}catch(i){t.push(i)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#d(e);for(let n of t)this.bindingFor(n)?.rebind();for(let n of t)this.renderer.project(n);for(let n of t)this.bindingFor(n)?.remote?.update()}handleSourceEvent(e){let{evt:t,node:n}=e,s=[],i=o=>{try{this.closeBranch(o)}catch(a){s.push(a)}};try{if(t==="ins")this.#h(n);else if(t==="del")for(let o of Array.isArray(n)?n:[n])i(o);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof D)for(let o of e.oldvalue.getNodes())i(o);this.inlineCompiler.release(n,[""]),t==="upd_value_attr"?this.#m(n,e.attrs_diff):this.#c(n).rebind(),n.value instanceof D&&this.#h(n.value)}else if(t==="upd_attrs")this.#m(n,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(o){throw s.length?new AggregateError([...s,o],"Source event failed"):o}return s}branchBuilt(e){let t=[];for(let n of this.#d(e)){let s=this.bindingFor(n);!s||s.hasStamp("built")||!this.renderer.attached(n)||(s.stamp("built"),t.push(s))}for(let n of t)this.renderer.attached(n.node)&&this.#p(n,"built","_onBuilt");if(this.gramlot.state==="started")for(let n of t)this.renderer.attached(n.node)&&this.#u(n)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#u(e)}dispose(){if(this.disposed)return;this.#f=!0,this.root.unsubscribe(this.#l,{any:!0}),this.nodeIds.clear();let e=[];for(let[t,n]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{n.close()}catch(s){e.push(s)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#h(e){if(!(e instanceof D)&&this.bindingFor(e))return;let t=e instanceof D?e.getNodes().flatMap(i=>this.#d(i)):this.#d(e),n=new Set(t.filter(i=>this.bindingFor(i))),s=new Map;for(let i of t){let o=i.getAttr("nodeId");if(o!=null){if(s.has(o)||this.nodeIds.has(o)&&this.nodeIds.get(o)!==i)throw new Error(`Duplicate nodeId '${o}'`);s.set(o,i)}}for(let[i,o]of s)this.nodeIds.set(i,o);try{for(let i of t)this.openBinding(i);this.installer.install(e);for(let i of t)this.bindingFor(i).registerPointers()}catch(i){let o=[i];for(let a of t.filter(l=>!n.has(l)).reverse()){let l=a.getAttr("nodeId");s.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"):i}for(let i of t){let o=this.bindingFor(i);if(!(!o||o.hasStamp("init")||!this.renderer.attached(i))&&(o.stamp("init"),oc(i.getAttr("_init"))))for(let a of o.providers)a.invoke({kind:"init",change:null})}}#u(e){e.hasStamp("start")||(e.stamp("start"),this.#p(e,"start","_onStart"),e.remote?.update())}#p(e,t,n){let s=e.node.getAttr(n);if(oc(s))for(let i of e.providers){if(typeof s!="number"||s<=0){i.invoke({kind:t,change:null});continue}let o=null,a=setTimeout(()=>{o(),i.invoke({kind:t,change:null})},s);o=e.track(()=>clearTimeout(a))}}#m(e,t){let n=this.#c(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:s,new:i}=t.nodeId;if(i!=null&&this.nodeIds.has(i)&&this.nodeIds.get(i)!==e)throw new Error(`Duplicate nodeId '${i}'`);this.nodeIds.get(s)===e&&this.nodeIds.delete(s),i!=null&&this.nodeIds.set(i,e)}lg.some(s=>Object.hasOwn(t,s))?this.rebindBranch(e):n.rebind()}#c(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}#d(e){let t=[e];if(e.value instanceof D)for(let n of e.value.getNodes())t.push(...this.#d(n));return t}};function oc(r){return r===!0||typeof r=="number"}var Jo=class{#e;#t;#r=!1;#s=[];#n=[];#i=new Set;#o=null;#a=null;#l=new Set;#f=new Set;#h=0;#u=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.#n]}get providers(){return this.#o?[this.#o]:[]}get remote(){return this.#a}get clickCount(){return this.#h}countClick(){return++this.#h}hasStamp(e){return this.#i.has(e)}stamp(e){this.#i.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&&!ic[e.nodeTag])return;!t&&typeof e.getAttr("remote")=="string"?this.#a??=new bi(this):this.#a&&(this.#a.close(),this.#a=null);let n=new Set;if(e._getMeta("gramlot_component")?.bagStore){let i=e.getAttr("storepath");if(typeof i!="string"||!i||/^[\^=]/.test(i)||i.includes("?"))throw new TypeError("storepath requires a plain Bag data path");let o=e.absDatapath(i);this.#n.push(this.runtime.router.register({path:o,recipient:this,subtree:!0}))}let s=this.remote?He(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[i,o]of Object.entries(e.getAttr()))if(i.startsWith("remote_"))for(let a of He(e,o))n.add(a)}for(let[i,o]of e.pointers()){if(t&&i!=="datapath")continue;let l=(i==="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.#n.push(d),i==="datapath"&&this.#u.add(d),this.remote&&(i==="remote"||i.startsWith("remote_")||n.has(i))&&this.#l.add(d),this.remote&&(i==="_timing"||s.has(i))&&this.#f.add(d)}if(!t){this.#p(),this.remote?.register();return}this.#o??=new ic[e.nodeTag](this),this.#o.register()}#p(){let e=this.node;this.#n.push(...this.runtime.subscriptions.subscribeNode(e,(t,n)=>{if(typeof n!="string"||!n)throw new TypeError(`${t} requires a handler`);return s=>{if(this.closed)return;if($n(n))return Qt(this.runtime,e,n,s);let[,i]=e.rootBuilder.runtimeValues(e),o=Object.fromEntries(Object.entries(i).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),a={...this.runtime.renderer.references.resolveArguments(o),p_0:s};return this.runtime.inlineCompiler.compile(e,t,n,Object.keys(a))(a)}}))}rebind(){this.#m(),this.registerPointers()}receive(e){if(this.#u.has(e.registration)){this.runtime.rebindBranch(this.node);return}this.#l.has(e.registration)&&this.remote.receive(e),this.#f.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.#s.push(e),()=>{let t=this.#s.indexOf(e);t!==-1&&this.#s.splice(t,1)}}async call(e,t){let{controller:n}=t,s=this.track(()=>n.abort());try{let i=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:n.signal});if(n.signal.aborted)throw n.signal.reason;return i}finally{s()}}callSync(e,t,n){return this.node.requests.submitSync(t,()=>this.runtime.gramlot.rpc.callSync(e,t,n))}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.#s.splice(0).reverse())try{t()}catch(n){e.push(n)}if(e.length)throw new AggregateError(e,`NodeBinding of '${this.node.label}' cleanup failed`)}#m(){for(let e of this.#n.splice(0))e.close();this.#u.clear(),this.#l.clear(),this.#f.clear()}};var wi=class{constructor(e){this.renderer=e}prepare(e,t){let n=this.renderer.records.get(e);if(!n||n.resolved.draggable!==!0)return null;let s=e._getMeta("gramlot_component")?.dragSource?n.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(s===null)return null;let{dragValues:i,item:o,path:a}=s;if(n.resolved.onDrag){let u=this.renderer.html.callLogic(e,n.resolved.onDrag,{dragValues:i,item:o,path:a});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return Ct(i),{dragValues:Object.fromEntries(Object.entries(i).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(W(c))]})),item:o,path:a}}};var Nt=class{static isTarget(e){return e.dropTarget===!0||!!e.dropTargetCb||Object.entries(e).some(([t,n])=>t.startsWith("dropTargetCb_")&&!!n)}static acceptedTypes(e,t="",n=[]){let s=t.split(",").map(i=>i.trim()).filter(Boolean).map(i=>{let o=i.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${o.join(".*")}$`)});return e.filter(i=>i!=="dragTags"&&(n.includes(i)||s.some(o=>o.test(i))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let n=new Set(e.split(",").map(s=>s.trim()).filter(Boolean));return n.size?t.split(",").some(s=>s.split(" AND ").every(i=>(i=i.trim(),!i||i==="!"?!1:i.startsWith("!")?!n.has(i.slice(1)):n.has(i)))):!1}static acceptsEffect(e="all",t="move"){let n={all:["copy","move","link"],none:[],copy:["copy"],move:["move"],link:["link"],copyMove:["copy","move"],copyLink:["copy","link"],linkMove:["link","move"]};if(!Object.hasOwn(n,e))throw new TypeError(`Invalid effectAllowed: ${e}`);if(!["copy","move","link"].includes(t))throw new TypeError(`Invalid dropEffect: ${t}`);return n[e].includes(t)}static evaluate(e,t,n,s,i=[]){let o=this.acceptedTypes(e,s.dropTypes,i),a=s.dropEffect??"move",l=this.isTarget(s)&&o.length>0&&this.acceptsTags(t,s.dropTags)&&this.acceptsEffect(n,a);return{accepted:l,types:o,dropEffect:l?a:"none"}}};var ac=["dragstart","dragover","dragleave","drop","dragend"],yi=class{#e;#t;#r=null;#s=null;#n=null;#i;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of ac)this.#t.addEventListener(t,this);this.#i=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#i)}handleEvent(e){e.type==="dragstart"?this.#l(e):e.type==="dragend"?this.#b(e.dataTransfer.dropEffect):e.type==="dragleave"?this.#c():e.type==="dragover"?this.#u(e):e.type==="drop"&&this.#p(e)}#o(e,t){for(let n of e.composedPath()){let s=this.#e.elements.get(n);if(s&&t(s.resolved))return s}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,n=>n.draggable===!0);if(t){this.#b("none");try{let n=this.#e.prepareDrag(t.node,e);if(!n||!t.element.isConnected||this.#e.records.get(t.node)!==t){e.preventDefault();return}let s=this.#a(t,e);if(!s){e.preventDefault();return}let i=new Map(Object.entries(n.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:W(c)]));if(!i.size){e.preventDefault();return}let o=t.resolved.effectAllowed??"all";Nt.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:i,effectAllowed:o,phase:"active",tags:[a,n.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:n.path??null},preview:null,release:null};e.dataTransfer.clearData();for(let[u,c]of i)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=o,this.#n=this.#t.createElement("style"),this.#n.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.#n),this.#f(l,s.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(n){e.preventDefault(),this.#g(),this.#_(n)}}}#f(e,t,n){let s=t.cloneNode(!0);s.removeAttribute("id");for(let i of s.querySelectorAll("[id]"))i.removeAttribute("id");s.setAttribute("aria-hidden","true"),s.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(s.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(s),e.preview=s,n.setDragImage(s,0,0)}#h(e){let t=this.#r,n=this.#o(e,u=>Nt.isTarget(u));if(!n)return null;let s=this.#a(n,e);if(!s)return{record:n,element:n.element,accepted:!1};let i=Nt.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,n.resolved),a={dropValues:Object.fromEntries(i.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):P(t.wires.get(u))])),item:s.item,path:s.path,source:{...t.source},selfdrop:n===t.record,dropEffect:i.dropEffect,dataAvailable:!0},l=i.accepted&&this.#e.checkDropTarget(n.node,a)&&this.#e.records.get(n.node)===n&&s.element.isConnected;return{record:n,element:s.element,accepted:l,context:a}}#u(e){if(!this.#r){this.#o(e,t=>Nt.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,n=this.#h(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=n?.accepted?n.context.dropEffect:"none",this.#c(),n&&this.#m(n.element,n.accepted)}catch(t){e.dataTransfer.dropEffect="none",this.#r&&(this.#r.phase="rejected"),this.#d(),this.#_(t)}}async#p(e){if(!this.#r){this.#o(e,n=>Nt.isTarget(n))&&e.preventDefault();return}if(e.preventDefault(),this.#r.phase!=="active")return;let t=this.#r;try{let n=this.#h(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}if(t.phase="dropped",this.#d(),!n?.accepted){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=n.context.dropEffect,n.record.node.publish("onDrop",n.context),await this.#e.invokeDrop(n.record.node,n.context)}catch(n){this.#r===t&&(t.phase="rejected",this.#d()),this.#_(n)}}#m(e,t){let n=t?"canBeDropped":"cannotBeDropped",s=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#s={element:e,name:n,hadClass:e.classList.contains(n),hadPart:s.includes(n)},e.classList.add(n),s.includes(n)||e.setAttribute("part",[...s,n].join(" "))}#c(){if(!this.#s)return;let{element:e,name:t,hadClass:n,hadPart:s}=this.#s;n||e.classList.remove(t),s||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(i=>i!==t).join(" ")),this.#s=null}#d(){this.#c(),this.#r&&(this.#r.preview?.remove(),this.#r.preview=null,this.#r.wires.clear())}#g(){let e=this.#r;return this.#d(),this.#r=null,e?.release?.(),this.#n?.remove(),this.#n=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(n=>this.#_(n))}#_(e){console.error("Gramlot drag/drop failed:",e)}dispose(){this.#g();for(let e of ac)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#i)}};var Vn=class extends Kt{static renderType="object";#e=new Set;#t=new WeakMap;#r=new WeakMap;#s=new WeakMap;constructor(e,t,n,{binding:s}={}){if(super(e),!(e instanceof ye)||!(t instanceof le)||n?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(s instanceof jr))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");this._binding=s,this.source=t,this.destination=n,this.html=new si({metadataAttributes:["__ref"],callLogic:(i,o,a)=>{let{group:l,method:u}=s.gramlot.src.logicRegistry.resolve(o,i);return u.call(l,i,a)},invokeScript:(i,o,a,l)=>Qe(s,i,o,a,l,i.parentNode._getMeta("gramlot_component").childParameters[o].inline)}),this.records=new Map,this.references=new Fn(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new wi(this),this.instanceId=xe(),this.radioGroups=new ni(this),this.dragDrop=new yi(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:i=>this.receive(i)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:n,path:s,source:i,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:n,path:s,source:i,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:n,path:s,source:i,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:n,path:s,source:i,selfdrop:o,dropEffect:a,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:n},s){let i={source:t,dropEffect:n},o=[],a=this.records.get(e);try{a&&!a.binding.closed&&a.resolved.onDragEnd&&await this.html.callLogic(e,a.resolved.onDragEnd,i)}catch(l){o.push(l)}try{this.binding.gramlot.publish(s,i)}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 n=this.#r.get(e)??super.evaluateExpressions(e,t),s=e._getMeta("gramlot_component");if(s?.presentationDefaults.length){let i=e.getAttr();this.#s.set(e,Object.fromEntries(Object.entries(n).filter(([o])=>Object.hasOwn(i,o)&&s.presentationDefaults.some(a=>o.startsWith(a)))))}if(s&&(s.parameters.value?.binding==="twoWay"||s.presentationDefaults.length)){let i=[];for(let o=e.parentNode;o;o=o.parentNode)this.#s.has(o)&&i.unshift(this.#s.get(o));n=Object.assign({},...i,n)}return this.#r.delete(e),this.#t.set(e,n),n}render(e,t={}){if(!(e instanceof Jt))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 D))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,...n}={}){let s=t.createDocumentFragment(),i={node:e,binding:this.#c(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,i),this.elements.set(s,i),s.append(i.start);for(let o of e.value.getNodes()){let a=this.render(o,{document:t,...n});if(a===null)continue;s.append(a);let l=this.elements.get(a);l&&(l.parent=i,i.children.add(o))}return s.append(i.end),s}renderedItem(e,t,n,{tag:s,document:i=this.destination.ownerDocument}={}){let o=n;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(o=this.restoreNativeAttributes(e,n),e._getMeta("gramlot_component")||([t,o]=Rn(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.#c(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,i,s,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.#u(c,e,o,null));let f=ii.for(c.binding,c);f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),this.#p(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 n=new Set,s=i=>{if(!n.has(i)){n.add(i);for(let o of this.records.get(i)?.children??[])s(o);if(i.value instanceof D)for(let o of i.value.getNodes())s(o)}};for(let i of this.records.get(t)?.children??[])s(i);if(t?.value instanceof D)for(let i of t.value.getNodes())s(i);return this.#n(e,t?t.nodeTag:null),Zo(e),this.references?.validate(e,n),e}#n(e,t=null){let n=new Set,s=(i,o=null)=>{if(!(i instanceof le)||n.has(i))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(i._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");n.add(i);for(let a of i.getNodes()){if(!(a instanceof Jt))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")?i._builder:a.builder;this.html.validate(a,l),a._getMeta("subbuilder")||a.builder.validateParent(a.nodeTag,o)}else{if(!(a.value instanceof D))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 D&&s(a.value,a._getMeta("subbuilder")?null:a.nodeTag??o)}};s(e,t)}freeze(e){e=te(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=te(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let n=s=>{delete s.frozen;for(let i of s.children)n(this.records.get(i))};n(t),!this.#i(e)&&(this.attached(e)?this.#d(e):this.remove(e))}#i(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){if(Array.isArray(e.node)){let t=e.node.filter(n=>!this.#e.has(n));if(!t.length)return;e={...e,node:t}}else if(this.#e.has(e.node))return;if(this.pending.push(e),!this.building){this.building=!0;try{for(;this.pending.length;){let t=this.pending.shift();if(t.evt!=="del"&&!this.attached(t.node))continue;t.evt!=="del"&&t.evt!=="upd_attrs"&&this.#l(t);let n=this.binding.handleSourceEvent(t);try{this.#o(t,n)}catch(s){if(!n.length)throw s;n.push(s)}if(n.length)throw n.length===1?n[0]:new AggregateError(n,"Source cleanup failed")}}catch(t){throw this.pending.length=0,t}finally{this.building=!1}}}}#o(e,t){if(e.evt==="del"){for(let n of Array.isArray(e.node)?e.node:[e.node]){if(this.#i(n))continue;let s=this.records.get(n)?.parent??null;try{this.remove(n)}catch(i){t.push(i)}this.#m(s)}return}if(!this.#i(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(n=>Array.isArray(n.node)?n.node:[n.node]));for(let n=e;n;n=n.parentBag?.parentNode)if(t.has(n))return!0;return!1}#l(e){let t=n=>{if(!(n instanceof Jt))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(n.value instanceof D){if(!(n.value instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");for(let s of n.value.getNodes())t(s)}};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),n=t?.element??t?.container??this.destination,s=e.parentBag.getNodes(),i=t?.end??null;for(let o=s.indexOf(e)+1;o<s.length;o++){let a=this.records.get(s[o]);if(a){i=a.element??a.start;break}}this.buildNode(e,n,i,t)}buildNode(e,t,n=null,s=null){this.#e.add(e);let i;try{i=this.render(e,{document:t.ownerDocument})}catch(a){this.#f(e,a)}finally{this.#e.delete(e)}let o=this.records.get(e);return t.insertBefore(i,n),o.parent=s,this.assignContainer(o,t),s?.children.add(e),this.#m(s),this.binding.branchBuilt(e),o}#f(e,t){let n=[t],s=[],i=o=>{if(s.push(o),o.value instanceof D)for(let a of o.value.getNodes())i(a)};i(e);for(let o of s.reverse())try{this.remove(o)}catch(a){n.push(a)}throw n.length===1?t:new AggregateError(n,"Source build and cleanup failed")}assignContainer(e,t){e.container=t;let n=e.element??t;for(let s of e.children){let i=this.records.get(s);i&&this.assignContainer(i,n)}}update(e,t){let n=this.records.get(e);if(!n){this.insert(e);return}let s=e.value==null||["string","number","boolean"].includes(typeof e.value),i=t==="upd_value"&&s&&n.element&&n.children.size===0&&this.html.matches(n,e);(t==="upd_attrs"||i)&&n.element&&this.html.matches(n,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)===n&&(this.references?.remove(e),this.references?.register(e,n.element))):this.#d(e)}project(e,t=null){let n=this.records.get(e);if(!n?.element)return;let s=this.getRender(e.builder),i=this.#s.get(e),[o,a]=e.rootBuilder.runtimeValues(e),[,l]=s._handleMeta(e,a),u=this.#t.get(e);if(n.shape!==be.shape(n.element,u)){if(this.#i(e))return;this.#r.set(e,u);try{this.#d(e)}finally{this.#r.delete(e)}return}n.resolved=u;let c=e._getMeta("subbuilder")?l:s.adaptAttrs(l),d=e.value instanceof D,f=d?[]:this.expressionValue(e,o);s===this&&(c=this.restoreNativeAttributes(e,c),e._getMeta("gramlot_component")||([f,c]=Rn(f,c,(p,m)=>this._binding.gramlot.format(p,m)))),c=this.componentAttributes(e,c),this.html.update(n,e,c,d?c._text:f,u.visible??null),this.#u(n,e,c,t),n.control?.refresh(),n.button?.refresh(),this.#p(n);let h=this.#s.get(e);if(h){let p=new Set([...Object.keys(i??{}),...Object.keys(h)].filter(m=>!Object.is(i?.[m],h[m])));p.size&&this.#h(e,p)}(n.element.localName==="option"||n.element.localName==="optgroup")&&this.#m(n.parent)}#h(e,t){if(e.value instanceof D)for(let n of e.value.getNodes()){let s=n._getMeta("gramlot_component"),i=n.getAttr(),o=t;s?.presentationDefaults.length?o=new Set([...t].filter(a=>!Object.hasOwn(i,a))):s?.parameters.value?.binding==="twoWay"&&[...t].some(a=>!Object.hasOwn(i,a))&&this.project(n),o.size&&this.#h(n,o)}}componentAttributes(e,t){let n=e._getMeta("gramlot_component"),s=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!n&&!s)return t;let i=this.#t.get(e),o=Object.fromEntries([...new Set([...Object.keys(n?.parameters??{}),...Object.keys(s??{}),...Object.keys(i).filter(a=>a.startsWith("validate_"))])].filter(a=>Object.hasOwn(i,a)).map(a=>[a,i[a]]));return{...t,...o}}#u(e,t,n,s){if(!e.control)return;let i=t.getAttr("value")!=null;(i||e.valueDeclared)&&e.control.project(n.value??null,s),e.valueDeclared=i}#p(e){let t=new Map(Pn.declared(e.node).map(n=>[n[0],n]));if(!e.events){if(!t.size)return;e.events=new Map,e.cleanup.push(()=>{for(let n of e.events.values())n.detach();e.events.clear()})}for(let[n,s]of[...e.events])t.get(n)?.[2]!==s.handler&&(s.detach(),e.events.delete(n));for(let[n,[,s,i]]of t){if(e.events.has(n))continue;let o=new Pn(e.binding,e,s,i,n);o.attach(),e.events.set(n,o)}}#m(e){for(let t=e;t;t=t.parent){if(t.control instanceof Ln){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=te(e),n=this.records.get(t);return n&&this.attached(t)?n.element??null:null}getBaseSourceNode(e){for(let t=e;t;t=t.parentNode){let n=t.nodeType===1?this.elements.get(t):null;if(n)return this.attached(n.node)?n.node:null}return null}#c(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#d(e){let t=this.records.get(e),n=t.element?.nextSibling??t.end?.nextSibling??null,s=t.container,i=t.parent,o=null;try{this.remove(e)}catch(a){o=a}try{this.buildNode(e,s,n,i)}catch(a){throw o?new AggregateError([o,a],"Source replacement cleanup and commit failed"):a}if(o)throw o}onDispose(e,t){let n=this.records.get(e);if(!n)throw new Error("Source node is not mounted");return n.cleanup.push(t),()=>{let s=n.cleanup.indexOf(t);s!==-1&&n.cleanup.splice(s,1)}}remove(e){let t=this.records.get(e);if(!t)return;let n=[];for(let s of[...t.children])try{this.remove(s)}catch(i){n.push(i)}for(let s of t.cleanup.splice(0).reverse())try{s()}catch(i){n.push(i)}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.#s.delete(e),n.length)throw new AggregateError(n,"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(([,n])=>!n.parent).map(([n])=>n);for(let n of t)try{this.remove(n)}catch(s){e.push(s)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var ug=new Set(["page","constructor"]);function lc(r,e){if(r===null)return[];let t=r.split("/");for(let n of t)if(ug.has(n))throw new Error(`${e}: a logic group cannot be named '${n}' (group '${r}')`);return t}var cg=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function dg(r){return/^[\w$]/.test(r)?cg.has(r):r!==")"&&r!=="]"}function fg(r,e){let t=!1;for(let n=e+1;n<r.length;n++){let s=r[n];if(s===`
|
|
66
|
-
`)return-1;if(
|
|
67
|
-
`,s),s<0)break;continue}if(i==="/"&&r[s+1]==="*"){let o=r.indexOf("*/",s+2);if(o>=0){s=o+1;continue}}if(i==="/"&&dg(n)){let o=fg(r,s);if(o>=0){s=o,n=")";continue}}if(i==='"'||i==="'"||i==="`"){let o=s+1;for(;o<r.length&&r[o]!==i;)o+=r[o]==="\\"?2:1;e===1&&(t+=r.slice(s+1,o)==="constructor"?" constructor":' ""'),s=o,n=")";continue}if(/[\w$]/.test(i)){let o=s+1;for(;o<r.length&&/[\w$]/.test(r[o]);)o++;e===1&&(t+=r.slice(s,o)),n=r.slice(s,o),s=o-1;continue}if(/\s/.test(i)||(n=i),i==="{"){++e===2&&(t+=" {}");continue}if(i==="}"){e--;continue}e===1&&(t+=i)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function uc(r,e){if(r===void 0)return[];if(typeof r!="function"||!/^class\b/.test(Function.prototype.toString.call(r)))throw new Error(`${e}: the module exports no class Logic`);if(Object.getPrototypeOf(r)!==Function.prototype||Object.getPrototypeOf(r.prototype)!==Object.prototype)throw new Error(`${e}: class Logic cannot extend another class`);if(hg(Function.prototype.toString.call(r)))throw new Error(`${e}: class Logic cannot declare a constructor; state lives on the group or the page`);let t=[];for(let n of Reflect.ownKeys(r.prototype)){if(n==="constructor")continue;if(typeof n=="symbol")throw new Error(`${e}: class Logic cannot declare symbol keys (${String(n)})`);let s=Object.getOwnPropertyDescriptor(r.prototype,n);if(s.get||s.set)throw new Error(`${e}: class Logic cannot declare the accessor '${n}'`);if(typeof s.value!="function")throw new Error(`${e}: Logic.prototype.${n} is not a method`);if(n==="page")throw new Error(`${e}: a logic method cannot be named 'page'`);t.push([n,s.value])}return t}function cc(r,e,t){Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var tr=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},Ur=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new tr(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:n,resource:s}of e){let i=lc(n,s);for(let o=0;o<i.length;o++){let a=i.slice(0,o).join("/");t.has(a)||t.set(a,new Set),t.get(a).add(i[o])}}for(let{logicClass:n,group:s,resource:i}of e){let o=t.get(s??"")??new Set;for(let[a]of uc(n,i))if(o.has(a))throw new Error(`${i}: the logic method '${a}' has the name of a child group`)}}register(e,{group:t=null,resource:n}){let s=lc(t,n),i=uc(e,n),o=this.#e.logic;for(let a of s){let l=Object.getOwnPropertyDescriptor(o,a)?.value;if(l===void 0){let u=new tr(this,this.#e);cc(o,a,u),o=u}else if(l instanceof tr)o=l;else throw new Error(`${n}: the group '${a}' has the name of a logic method`)}for(let[a,l]of i){if(Object.getOwnPropertyDescriptor(o,a)?.value instanceof tr)throw new Error(`${n}: the logic method '${a}' has the name of a child group`);cc(o,a,l)}this.#t.has(o)||this.#t.set(o,[]),this.#t.get(o).push(n)}resolve(e,t){let n=e.split("."),s=n.pop(),i=this.#e.logic;for(let a=0;a<n.length;a++)if(i=Object.getOwnPropertyDescriptor(i,n[a])?.value,!(i instanceof tr))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${n.slice(0,a+1).join("/")}'`);let o=Object.getOwnPropertyDescriptor(i,s)?.value;if(typeof o!="function"){let a=this.#t.get(i)??[],l=n.length?`the group '${n.join("/")}'`:"the page logic";throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: ${l} has no method '${s}' (resources: ${a.join(", ")||"none"})`)}return{group:i,method:o}}};var Hn=class extends Se{constructor(e,{collections:t,destination:n,subscriptions:s,nameSyntax:i}){super(e),e.src=this,this.logicRegistry=new Ur(e),this.builder=new qe(null,{collections:t,nameSyntax:i}),this.binding=new jr(e,{subscriptions:s}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new Vn(this.builder,this.source,n,{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){let t=this.prepareSource(e);this.renderer.validateCandidate(t);try{this.source.setItem("main",t)}catch(n){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),n}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof D){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 n=Oo(e,t);if(!(n instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");return n.activateCode()}async remoteSource(e,t,n={}){if(!this.gramlot.rpc.transport?.call)throw new Error("Remote Source is unavailable without a server transport");let i=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!i)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,n,o=>this.#e(e,i,o))??!1}async#e(e,t,n){if(t.closed||this.gramlot.state==="disposed")return!1;let s=!1,i=()=>this.gramlot.state!=="disposed"&&!n.ignored&&!t.closed;try{let o=await t.call("source",n);if(!i())return!1;let a=this.prepareSource(o,e.builder);return i()?(this.renderer.validateCandidate(a,{replacingNode:e}),s=!0,e.setValue(a,!0,{_text:null},!0),t.remote?.fragmentMounted(n.method,n.text),!0):!1}catch(o){if(!s&&!i())return!1;throw o}}};var zn=class extends Error{name="RpcError";constructor({code:e,name:t,message:n,details:s}){super(n),this.code=e,this.remoteName=t,s!==void 0&&(this.details=s)}},Wn=class extends Se{constructor(e,{rpcUrl:t,closeUrl:n,document:s,transport:i}){super(e),this.transport=i===!1?null:i??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:n,document:s}),this.remoteRequests=new Map}get supportsCallSync(){return this.transport?.supportsCallSync===!0}callSync(e,t,n={}){if(!this.supportsCallSync)throw new Error(`rpc '${t}': the transport of this page has no synchronous call`);if(Ct(n),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let s=xe(),i=P(this.transport.callSync(W({id:s,pageId:this.gramlot.pageId,contentType:e,name:t,params:n})));if(i.id!==s)throw new Error("rpc response id mismatch");if(i.error)throw new zn(i.error);return i.value}async call(e,t,n={},{signal:s=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);Ct(n);let i=xe(),o=W({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:n}),a=s?[this.gramlot.abort.signal,s]:[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(i),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(i,u);try{let f=P(await Promise.race([this.transport.call(o,u.signal),d]));if(f.id!==i)throw new Error("rpc response id mismatch");if(f.error)throw new zn(f.error);return f.value}finally{this.remoteRequests.delete(i);for(let f of a)f.removeEventListener("abort",c)}}};var Gn=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 dc="gramlot:publish",vi=class{#e;#t;#r;#s=xe();#n=new Map;#i=!1;#o;#a;#l;#f;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#o=s=>this.#m(s),this.#a=s=>{if(s.target?.localName!=="iframe")return;let i=this.#g(s.target);i&&(this.#u(i.window),this.#c(i,{kind:"hello"}))},this.#t.addEventListener("message",this.#o),this.#l=()=>this.#h(),this.#f=()=>this.ready(),this.#t.addEventListener("pagehide",this.#l),this.#t.addEventListener("pageshow",this.#f),t.addEventListener("load",this.#a,!0);let n=this.#d();n&&this.#c(n,{kind:"hello"})}ready(){if(this.#i||this.#e.state!=="started")return;let e=this.#d();e&&this.#c(e,{kind:"ready"});for(let t of this.#r.getElementsByTagName("iframe")){let n=this.#g(t);n&&this.#c(n,{kind:"hello"})}}prepare(e,t){let n=[];if(e.parent){let o=this.#d();if(!o)throw new Error("This page has no parent frame");n.push(o)}if(e.iframe!==void 0){let o=e.iframe,a=te(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");n.push(u)}let s=n.map(o=>{let a=this.#n.get(o.window);if(!a||a.origin!==o.origin)throw new Error("Destination page is not ready");return{...o,session:a.session}});Ct(t);let i=W(t);return()=>{if(!this.#i)for(let o of s){let a=this.#_(o.window);if(!a||a.origin!==o.origin||this.#n.get(o.window)?.session!==o.session)throw new Error("Destination page disconnected before publication");this.#c(o,{kind:"publish",recipient:o.session,topic:e.topic,wire:i})}}}dispose(){this.#i||(this.#h(),this.#i=!0,this.#t.removeEventListener("message",this.#o),this.#t.removeEventListener("pagehide",this.#l),this.#t.removeEventListener("pageshow",this.#f),this.#r.removeEventListener("load",this.#a,!0))}#h(){for(let[e,t]of this.#n)this.#c({window:e,origin:t.origin},{kind:"close"});for(let e of this.#n.keys())this.#u(e)}#u(e){this.#n.get(e)?.release?.(),this.#n.delete(e)}#p(e,t){this.#u(e.window);let n={session:t,origin:e.origin};e.node&&(n.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#c(e,{kind:"close"}),this.#u(e.window)})),this.#n.set(e.window,n)}#m(e){if(this.#i||e.data?.type!==dc)return;let t=this.#_(e.source);if(!t||e.origin!==t.origin)return;let n=e.data;if(!(typeof n.session!="string"||!n.session)){if(n.kind==="hello")this.#u(t.window),n.ready===!0&&this.#p(t,n.session),this.#e.state==="started"&&this.#c(t,{kind:"ready"});else if(n.kind==="ready"){let s=this.#n.get(t.window)?.session!==n.session;this.#p(t,n.session),s&&this.#e.state==="started"&&this.#c(t,{kind:"ready"})}else if(n.kind==="close")this.#n.get(t.window)?.session===n.session&&this.#u(t.window);else if(n.kind==="publish"){if(this.#e.state!=="started"||n.recipient!==this.#s||this.#n.get(t.window)?.session!==n.session||typeof n.topic!="string"||!n.topic||typeof n.wire!="string")return;this.#e.publish(n.topic,P(n.wire))}}}#c(e,t){e.window.postMessage({type:dc,session:this.#s,ready:this.#e.state==="started",...t},e.origin==="null"?"*":e.origin)}#d(){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 n=e.getAttribute("sandbox"),i=n!==null&&!n.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:i,node:t}}#b(e){let t=new URL(e,this.#r.baseURI);return t.protocol==="file:"?"null":t.origin}#_(e){let t=this.#d();if(t?.window===e)return t;for(let n of this.#r.getElementsByTagName("iframe")){let s=this.#g(n);if(s?.window===e)return s}return null}};var Ei=class extends Se{#e=new Map;#t=new WeakSet;#r=new WeakMap;#s=0;#n=!1;#i;attach(e){this.#i=new vi(this.gramlot,e)}ready(){this.#i.ready()}subscribe(e,t){if(this.#l(),this.#a(e),typeof t!="function")throw new TypeError("subscribe requires a callback");let n=Object.freeze({});return this.#t.add(n),this.#e.has(e)||this.#e.set(e,new Map),this.#e.get(e).set(n,t),n}unsubscribe(e){if(!this.#t.has(e))throw new TypeError("Unknown subscription registration");for(let[t,n]of this.#e)n.delete(e)&&!n.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(i=>!["topic","nodeId","parent","iframe"].includes(i)))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 s=e.parent||e.iframe!==void 0?this.#i.prepare(e,t):null;if(Object.hasOwn(e,"nodeId")){let i=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!i)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(i,e.topic,t)}this.#o(e.topic,t),s?.()}topicFor(e,t){this.#a(t),e=te(e);let n=this.gramlot.src.binding.bindingFor(e);if(!n||n.closed)throw new Error("Topic target is not an active Source node of this page");let s=e.getAttr("nodeId");return s==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#s}`),s=this.#r.get(e)),`${s}_${t}`}publishNode(e,t,n={}){return this.publish(this.topicFor(e,t),n)}subscribeNode(e,t){let n=[];for(let[s,i]of Object.entries(e.getAttr())){let o=s.startsWith("selfsubscribe_")?"selfsubscribe_":s.startsWith("subscribe_")?"subscribe_":null;if(!o)continue;let a=o==="selfsubscribe_"?this.topicFor(e,s.slice(o.length)):s.slice(o.length);this.#a(a),n.push([a,t(s,i,a)])}return this.#l(),n.map(([s,i])=>{let o=this.subscribe(s,i);return{close:()=>this.unsubscribe(o)}})}dispose(){this.#n=!0,this.#i.dispose(),this.#e.clear()}#o(e,t){this.#a(e);let n=this.#e.get(e);if(n)for(let[s,i]of[...n]){if(this.#n)break;n.has(s)&&i(t)}}#a(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#l(){if(this.#n)throw new Error("Gramlot subscriptions are disposed")}};var fc=2e3;function pg(r){if(!(r instanceof Date))return String(r??"");let e=r.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}var Xn=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof C))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],n=(s,i)=>{for(let o of s.getNodes()){let a=i+o.label;o.value instanceof C?n(o.value,`${a}.`):t.push(`${a}: ${pg(o.value)}`)}};return n(this.branch(e),""),t.join(`
|
|
68
|
-
`)}mailtoUrl(e,t){let
|
|
69
|
-
<${i}>${s.toXml()}</${i}>`,t,"application/xml")}}saveText(e,t,n){let s=this.document.defaultView,i=s.URL.createObjectURL(new s.Blob([e],{type:n}));this.open(i,t),s.setTimeout(()=>s.URL.revokeObjectURL(i),1e3)}open(e,t=null){let n=this.document.createElement("a");n.href=e,t!==null&&(n.download=t),n.click()}};var Yn=class extends Se{constructor(e,t){super(e),this.inout=new Xn(e,t)}};var Zn=class{constructor({pageId:e,rpcUrl:t="/gramlot/rpc",closeUrl:n="/gramlot/close",rootId:s="gramlot-root",capabilities:i=[],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}={}){Js.register(a.defaultView);for(let g of u)g instanceof Zt&&g.register(a.defaultView);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 Ei(this)}),this.capabilities=Object.freeze([...i]),this.serverAdapter=h,this.src=new Hn(this,{collections:u,destination:o??a.getElementById(s),subscriptions:this._subscriptions,nameSyntax:p===null?Nn:Yt.fromJSON(p)}),this.data=this.src.builder.data,this.rpc=new Wn(this,{rpcUrl:t,closeUrl:n,document:a,transport:l}),this.dom=new Gn(this),this.utl=new Yn(this,a),this.state="ready",this._subscriptions.attach(a),this.abort=new AbortController,this.rpc.transport&&(this.pagehide=g=>{g.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 Vu(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.call("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)}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 Ko=class{constructor({config:e,resources:t,document:n=globalThis.document}){this.config=e,this.resources=t,this.document=n,this.serverAdapter=new ut}async run(){let{config:e,resources:t,document:n}=this,s=n.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));for(let c of t.css){let d=n.createElement("link");d.rel="stylesheet",d.href=c,n.head.append(d)}let i=!1,o=c=>{c.persisted||i||(i=!0,this.closePage())};s.addEventListener("pagehide",o);let a,l;try{let c=await Promise.allSettled(t.js.map(({url:d})=>import(new URL(d,n.baseURI).href)));if(i||(a=t.js.map(({url:d,group:f},h)=>{let p=c[h];if(p.status==="rejected")throw new Error(`${d}: import failed: ${p.reason?.message??p.reason}`,{cause:p.reason});return{logicClass:p.value.Logic,group:f,resource:d}}),Ur.check(a),l=await Promise.all((t.collections??[]).map(async d=>{try{return(await import(new URL(d,n.baseURI).href)).default}catch(f){throw new Error(`${d}: collection import failed: ${f.message}`,{cause:f})}})),i))return null;for(let d of l)d.register(s)}catch(c){throw this.closePage(),c}finally{s.removeEventListener("pagehide",o)}let u=new Zn({...e,document:n,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...l.map(c=>c.toDocument())]});for(let{logicClass:c,group:d,resource:f}of a)u.src.logicRegistry.register(c,{group:d,resource:f});return s.gramlot=u,await u.start(),u}async loadServerAdapter(e){let t;try{t=await import(new URL(e,this.document.baseURI).href)}catch(n){throw new Error(`${e}: server adapter import failed: ${n.message}`,{cause:n})}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 ki=Symbol("gramlot.source"),Qo=Symbol("gramlot.endpoint"),mg=new Map([[ki,"registerSource"],[Qo,"registerEndpoint"]]);function hc(r,e,t,n){let s=mg.get(t);if(e==="main")throw new TypeError(`${s} cannot declare main`);let i=Object.getOwnPropertyDescriptor(r.prototype,e)?.value;if(typeof i!="function")throw new TypeError(`${s} requires an own method of ${r.name}: ${String(e)}`);if(i[t])throw new TypeError(`${t===ki?"Source method":"Endpoint"} already registered: ${e}`);if(i[ki]||i[Qo])throw new TypeError(`${e} is declared both as Source method and endpoint`);i[t]={auth:n}}var Ai=class{static registerSource(e,{auth:t=null}={}){hc(this,e,ki,t)}static registerEndpoint(e,{auth:t=null}={}){hc(this,e,Qo,t)}},Jn=class extends Ai{static title="Gramlot";static devices=[];static locale=null;static timeZone=null;static installable=!1;static appIcon=null;manifest({baseUrl:e="./"}={}){let{title:t,appIcon:n}=this.constructor;if(typeof n!="string"||!n)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+n.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 qr=class extends Jn{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}),n=t.borderContainer({node_label:"frame",height:"100%",flex:"1",min_height:0});for(let s of["top","bottom","left","right","center"])if(this[s]!==void 0){let i=n.contentPane({region:s,node_label:s});this[s](i)}this.behavior(t)}center(e){}behavior(e){}};var Kn=class extends qr{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:n}=this.constructor;if(!(t instanceof C))throw new TypeError("IndexPage.navigation must be a Bag");e.dataSetter({destination_path:`${n}.navigation`,value:t}),e.dataSetter({destination_path:`${n}.navigationSelection`,value:null}),e.dataSetter({destination_path:`${n}.active`,value:null}),e.dataSetter({destination_path:`${n}.opened`,value:new C}),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})}};Kn.registerSource("index_panel");function ea(r,e,t=()=>{},n=()=>{},{state:s=e.builder.data.getItem(e.getAttr("datapath")),createEntry:i=null,onLoad:o=()=>{}}={}){let a=s.getItem("navigation");if(!(a instanceof C))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=s.getItem("opened");for(let A of m.getNodes()){let{url:v,path:N,title:L}=A.attr,U=l.value.getNode(A.label),ve={url:v,path:N,title:L,pane:U,node:a.getNode(N),loading:!1};n(ve),c.set(v,ve),h++}let g=A=>{if(!d){f=!0;try{s.setItem("active",A.url),s.setItem("navigationSelection",A.path),t(c,A.url)}finally{f=!1}}};async function b(A){let v=a.getNode(A);if(!v)throw new Error(`Unknown index navigation path: ${A}`);let N=v.attr.url;if(N==null)return;if(typeof N!="string"||!N)throw new TypeError("IndexPage URL must be nonempty text");p=N;let L=c.get(N);if(L){L.path=A,g(L);return}for(;l.value!==null&&l.value.getNode(`page${h}`);)h++;let U=te(u.wrapSource(l).contentPane({node_label:`page${h++}`,title:v.attr.title??v.label,pageName:N,height:"100%"})),ve=s.getItem("active");L={url:N,path:A,node:v,pane:U,title:v.attr.title??v.label,loading:!0},c.set(N,L);try{if(g(L),o(N,"loading"),i)await i(L);else{let Y=new C;if(Y.setItem(v.label,null,{...v.attr}),!await r.binding.gramlot.src.remoteSource(U,"index_panel",{selection:Y}))throw new Error("Panel loading was cancelled")}if(d)return;L.loading=!1,m.setItem(U.label,null,{url:N,path:L.path,title:L.title}),n(L),p===N&&(o(N,"ready"),g(L))}catch(Y){if(c.delete(N),m.getNode(U.label)&&m.popNode(U.label),U.parentBag&&U.parentBag.popNode(U.label),!d&&p===N){o(N,"error",Y);let ne=c.get(ve);if(p=ne?.url??null,ne)g(ne);else{f=!0;try{s.setItem("active",null),s.setItem("navigationSelection",null),t(c,null)}finally{f=!1}}}}}let y=`${e.getAttr("id")}-selection`;s.subscribe(y,{any:A=>{if(!(f||d)){if(A.node===s.getNode("navigationSelection")){let v=s.getItem("navigationSelection");v!==null&&b(v)}else if(A.node===s.getNode("active")){let v=c.get(s.getItem("active"));v&&(p=v.url,g(v))}}}});let w=()=>{if(!d){d=!0,s.unsubscribe(y,{any:!0});for(let A of c.values())A.loading&&A.pane.parentBag&&A.pane.parentBag.popNode(A.pane.label)}};r.onDispose(e,w);let k=c.get(s.getItem("active"));return k?g(k):s.getItem("navigationSelection")!==null&&b(s.getItem("navigationSelection")),{entries:c,dispose:w}}var Ti=class{indexMount(e,{shell_id:t}){let n=this.page.src.renderer,s=n.destination.ownerDocument.getElementById(t);this.index=ea(n,n.elements.get(s).node)}};function xi(r,{datapath:e,value:t,language:n="text",height:s="420px",...i}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let o=r.borderContainer({datapath:e,height:s,class:"gramlot-editor-options"}),a={language:n,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({...i,value:t,height:"100%",...Object.fromEntries(Object.keys(a).map(d=>[d,`^.settings.${d}`]))}),o}var Qn=class r extends Ve{static internalParams=new Set([...Ve.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:n="",onError:s}){super({cacheTime:-1,onError:s}),this.gramlot=e,this.method="directory_tree",this.params={root:t,path:n},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:n}){let{signal:s}=e,i,o=new Promise((a,l)=>{i=()=>l(s.reason),s.addEventListener("abort",i,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,n,{signal:s}),o]);if(s.aborted)throw s.reason;return a}finally{s.removeEventListener("abort",i),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof C))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 n=new r({gramlot:this.gramlot,root:this.params.root,path:t.attr.path,onError:this.onError});this.children.add(n),e.setResolver(t.label,n)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}},es=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 n=await this.gramlot.rpc.call("data","workspace_open",{root:e},{signal:t.signal});if(this.disposed||t.signal.aborted)return null;let s=new Qn({gramlot:this.gramlot,root:n.root,onError:o=>this.state.setItem("status",o.message)}),i=s.prepareValue(n.entries);return this.resolver?.abort(),this.resolver=s,this.state.setItem("selectedPath",null),this.state.setItem("store",i),this.state.setItem("root",n.root),this.state.setItem("status",""),n.root}catch(n){return!this.disposed&&!t.signal.aborted&&this.state.setItem("status",n.message),null}finally{this.request===t&&(this.request=null)}}dispose(){this.disposed=!0,this.request?.abort(),this.resolver?.abort()}},rr=class{fileSystemMount(e){this.fileSystems??=new WeakMap;let t=e.parentNode,n=t.getRelativeData("."),s=new es(this.page,n);this.fileSystems.set(n,s),this.page.src.renderer.onDispose(t,()=>s.dispose())}fileSystemOpen(e,{root:t}){if(t)return this.fileSystems.get(e.getRelativeData(".")).open(t)}};function pc(r,{datapath:e,...t}){let n=r.div({datapath:e,class:"gramlot-filesystem",...t});return n.dataSetter({destination_path:".store",value:new C}),n.dataSetter({destination_path:".root",value:null}),n.dataSetter({destination_path:".requestedRoot",value:null}),n.dataSetter({destination_path:".selectedPath",value:null}),n.dataSetter({destination_path:".status",value:""}),n.dataController({func:"fileSystemMount",_onBuilt:!0}),n.dataController({func:"fileSystemOpen",root:"^.requestedRoot"}),n.tree({storepath:".store",selectedPath:"^.selectedPath",labelAttribute:"caption",hideValues:!0,class:"gramlot-filesystem-tree"}),n.div("^.status",{role:"status",class:"gramlot-filesystem-status"}),n}var gg=(r,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([r,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Di=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 n=gg(e,t),s=this.documents.getNodes().find(a=>!a.value.getItem("isNew")&&a.value.getItem("root")===e&&a.value.getItem("path")===t);if(s)return s.label;if(this.pending.has(n))return this.pending.get(n).promise;let i=new AbortController,o=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:i.signal}).then(a=>{if(this.disposed||i.signal.aborted)return null;let l=new C;for(let[u,c]of Object.entries({...a,root:e,saved:a.content,busy:!1}))l.setItem(u,c);return this.documents.setItem(n,l),n}).finally(()=>this.pending.delete(n));return this.pending.set(n,{request:i,promise:o}),o}newDocument(e,t,n=""){let s=`new_${crypto.randomUUID().replaceAll("-","")}`,i=new C;for(let[o,a]of Object.entries({language:e,root:n,path:`Untitled${t}`,content:"",saved:"",writable:!0,busy:!1,isNew:!0,createHidden:!0,saveRoot:n,savePath:`Untitled${t}`}))i.setItem(o,a);return this.documents.setItem(s,i),s}async create(e){let t=this.documents.getItem(e);if(!t||!t.getItem("isNew")||this.pending.has(e))return!1;let n=t.getItem("saveRoot"),s=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==s.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let i=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let a=this.gramlot.rpc.call("data","document_create",{root:n,path:s,content:i},{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",i),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 n=t.getItem("content"),s=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 i=this.gramlot.rpc.call("data","document_render_typst",{content:n},{signal:s.signal}).then(o=>this.disposed||s.signal.aborted||t.getItem("content")!==n?!1:(t.setItem("typstSource",o.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(o=>(!this.disposed&&!s.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:s,promise:i}),i}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 n=t.getItem("content"),s=new AbortController;t.setItem("busy",!0);let i=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:n,revision:t.getItem("revision")},{signal:s.signal}).then(o=>this.disposed||s.signal.aborted?!1:(t.setItem("revision",o.revision),t.setItem("saved",n),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:s,promise:i}),i}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()}},Si=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(n=>typeof n!="string"||!n))throw new TypeError("Invalid recent workspace preference");return t.slice(0,6)}remember(e){let t=[e,...this.read().filter(n=>n!==e)].slice(0,6);return this.storage.setItem(this.key,JSON.stringify(t)),t}choices(e=this.read()){let t=new C;return e.forEach((n,s)=>t.setItem(`r${s}`,n,{caption:n})),t}};var Ci=class{fileSystemMount(e){return rr.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return rr.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){this.ideRoot=e.parentNode,this.ideState=e.getRelativeData("."),this.ideDocuments=new Di(this.page,this.ideState),this.idePanels=new Map,this.ideDisposed=!1,this.ideRequested=0,this.ideRecent=new Si(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 n=this.ideState.getItem("browser");n.subscribe("ide-browser",{any:s=>{if(s.node===n.getNode("root")){let i=n.getItem("root");this.ideState.setItem("workspace",i),this.ideState.setItem("recent",this.ideRecent.choices(this.ideRecent.remember(i))),this.ideState.setItem("status",`Workspace: ${i}`)}else if(s.node===n.getNode("selectedPath")){let i=n.getItem("selectedPath"),o=i===null?null:n.getItem("store").getNode(i);o&&!o.attr.is_directory&&this.ideOpenDocument(n.getItem("root"),o.attr.path)}}}),this.ideDocuments.documents.subscribe("ide-documents",{any:s=>{if(["content","saved","busy","writable","view","isNew","path","root"].includes(s.node.label))for(let[i,o]of this.idePanels){let a=this.ideDocuments.documents.getItem(i);a&&(s.node===a.getNode("content")&&this.ideDocuments.invalidateRecipe(i),this.ideDocumentState(i),o.setAttr({title:`${this.ideDocuments.dirty(i)?"\u25CF ":""}${a.getItem("path")}`}))}}}),this.page.src.renderer.onDispose(this.ideRoot,()=>{this.ideDisposed=!0,n.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),n=!this.ideDocuments.dirty(e)&&!t.getItem("isNew")||t.getItem("busy");t.setItem("saveDisabled",!!(n||!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 n=++this.ideRequested;try{let s=await this.ideDocuments.open(e,t);if(s===null||this.ideDisposed)return;this.ideShowDocument(s),n===this.ideRequested&&(this.ideState.setItem("active",s),this.ideState.setItem("status",`${t}${this.ideDocuments.documents.getItem(s).getItem("writable")?"":" (read only)"}`))}catch(s){this.ideDisposed||this.ideState.setItem("status",s.message)}}ideNew(){let e=this.ideState.getItem("newType"),t=e==="typstRecipe"?"python":e,n={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"},s=this.ideDocuments.newDocument(t,n[e],this.ideState.getItem("workspace"));++this.ideRequested,this.ideShowDocument(s),this.ideState.setItem("active",s),this.ideState.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e){let n=this.ideDocuments.documents.getItem(e).getItem("path");if(!this.idePanels.has(e)){let s=this.ideDocuments.documents.getItem(e),i=n.endsWith(".typ.py");i&&this.ideDocuments.invalidateRecipe(e),s.setItem("readonly",!s.getItem("writable")),this.ideDocumentState(e),s.setItem("view","code"),s.setItem("createHidden",!0),s.setItem("undoDisabled",!0),s.setItem("redoDisabled",!0);let o=this.ideRoot.value.getNode("frame.center.tabs"),a=te(o.builder.wrapSource(o).contentPane({node_label:e,title:n,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 ${n}`});for(let[w,k,A,v]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 N=u.button({title:A,"aria-label":A,disabled:`^.${w}Disabled`,class:`button--quiet gramlot-ide-${w}`});N.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:k}),N.dataController({func:v,documentKey:e})}i&&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=s.getItem("language")==="html",h=s.getItem("language")==="markdown",p=f||h,m=s.getItem("language")==="typst",g=p||m||i,b=g?d.tabContainer({height:"100%",selectedPage:`^.documents.${e}.view`}):null,y=g?b.contentPane({title:"Code",pageName:"code",height:"100%"}):d;if(xi(y,{datapath:`.documents.${e}`,value:"^.content",language:s.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&&b.contentPane({title:"Preview",pageName:"preview",height:"100%"}).typstPreview({value:`^.documents.${e}.content`,filename:`^.documents.${e}.pdfFilename`,height:"100%"}),i){let w=b.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}),b.contentPane({title:"Generated Typst",pageName:"generated",height:"100%"}).codeMirror({value:`^.documents.${e}.typstSource`,language:"typst",readonly:!0,height:"100%"})}if(p){let w=b.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});h&&(s.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`}:{}}),b.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 n=await this.ideDocuments.create(t);if(!this.ideDisposed&&n){this.ideState.setItem("status","File created.");let s=this.ideState.getItem("browser");s.getItem("root")&&await this.fileSystems.get(s).open(s.getItem("root"))}}catch(n){this.ideDisposed||this.ideState.setItem("status",n.message)}}async ideSave(e,{documentKey:t=null}={}){let n=t??this.ideState.getItem("active");if(!n||this.ideDocuments.documents.getItem(n).getItem("saveDisabled"))return;let s=this.ideDocuments.documents.getItem(n);if(s.getItem("isNew")){s.setItem("createHidden",!1);return}this.ideState.setItem("status","Saving\u2026");try{let i=await this.ideDocuments.save(n);this.ideDisposed||this.ideState.setItem("status",i?"Saved.":"Document is read only or a request is pending.")}catch(i){this.ideDisposed||this.ideState.setItem("status",i.message)}}ideRevert(e,{documentKey:t}){this.ideDocuments.revert(t)&&this.ideState.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:n}){let s=e.getRelativeData("."),i=e.getAttr("editorView");s.setItem(`${i}CanUndo`,t),s.setItem(`${i}CanRedo`,n),this.ideHistoryState(s)}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",n=this.page.src.binding.nodeIds.get(`${t?"rich_":""}editor_${e}`);return this.page.src.renderer.records.get(n).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 n=this.ideDocuments.documents.getItem(e),s=this.ideState.getItem("browser"),i=s.getItem("selectedPath"),o=i===null?null:s.getItem("store").getNode(i);n&&s.getItem("root")===n.getItem("root")&&o?.attr.path===n.getItem("path")&&s.setItem("selectedPath",null),this.idePanels.delete(e),this.ideDocuments.close(e,t)}};var ta=class r extends Ve{static internalParams=new Set([...Ve.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:n,onError:s}){super({cacheTime:-1,onError:s}),this.gramlot=e,this.method=t,this.params={directory:n},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:n}){let{signal:s}=e,i,o=new Promise((a,l)=>{i=()=>l(s.reason),s.addEventListener("abort",i,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,n,{signal:s}),o]);if(s.aborted)throw s.reason;return a}finally{s.removeEventListener("abort",i),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof C))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 n=new r({gramlot:this.gramlot,method:this.method,directory:t.attr.directory,onError:this.onError});this.children.add(n),e.setResolver(t.label,n)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}};function nr(r,e){return e===2?r%4===0&&(r%100!==0||r%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function Ce(r,e,t){if(![r,e,t].every(Number.isInteger)||r<1||r>9999||e<1||e>12||t<1||t>nr(r,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(r).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function sr(r){if(typeof r!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(r))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=r.split("-").map(Number);return Ce(...e),e}function ts(r,e,t){let n=r-1,s=365*n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+t-1;for(let i=1;i<e;i++)s+=nr(r,i);return s}function rs(r,e){let t=ts(...sr(r))+e;if(!Number.isSafeInteger(t)||t<0||t>ts(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let n=1,s=1e4;for(;s-n>1;){let o=Math.floor((n+s)/2);ts(o,1,1)<=t?n=o:s=o}t-=ts(n,1,1);let i=1;for(;t>=nr(n,i);)t-=nr(n,i++);return Ce(n,i,t+1)}function ra(r){return rs(r,-(ts(...sr(r))%7))}function mc(r,e,t=0,n=1){let s=r*12+e-1+t,i=Math.floor(s/12),o=(s%12+12)%12+1,a=s+n-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:Ce(i,o,1),end:Ce(l,u,nr(l,u))}}var na={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 gc(r){if(typeof r!="string")throw new RangeError("A supported locale is required.");let e=r.replaceAll("-","_"),t=e.indexOf("_"),n=(t<0?e:e.slice(0,t)).toLowerCase(),s=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(na,n))throw new RangeError(`Unsupported locale: ${r}`);let i=na[n];return{dictionary:i,phrases:a=>[...new Set([...i.keywords[a],...na.en.keywords[a]])],order:i.date_order[s]??i.date_order.default}}var ir=/^(?:\d{4}|\d{2})$/,bc=/^\d{1,2}$/,ns=(r,e)=>({ok:!1,error:{code:r,message:e}}),ar=(r="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:r})},yc=(r,e)=>Object.hasOwn(r,e);function or(r,e){if(r.length===4)return Number(r);let t=e.year+e.twoDigitYearAhead-100;return t+((Number(r)-t)%100+100)%100}function bg(r,e){if(r.includes(";")){let s=r.split(";").map(i=>i.trim());return s.length!==2?ar("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:s,range:!0}}if(e.phrases("no_period").includes(r))return{bounds:["",""],range:!0};let t=e.phrases("to"),n=e.phrases("from");for(let s of t)if(r.startsWith(`${s} `))return{bounds:["",r.slice(s.length+1).trim()],range:!0};for(let s of t){let i=` ${s} `;if(!r.includes(i))continue;for(let a of n)if(r.startsWith(`${a} `)){r=r.slice(a.length+1);break}let o=r.split(i).map(a=>a.trim());return o.length!==2?ar("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let s of n)if(r.startsWith(`${s} `))return{bounds:[r.slice(s.length+1).trim(),""],range:!0};return{bounds:[r,r],range:!1}}function _g(r,e,t){let n=[[r,0]],s=/^(.+?)\s*([+-])\s*(\d+)$/.exec(r);s&&n.push([s[1],Number(s[2]+s[3])]);let i={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[o,a]of n)for(let[l,u]of Object.entries(i))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return rs(ra(e.workdate),(u+a)*7+(t?6:0));if(l.endsWith("_month")){let c=mc(e.year,e.month,u+a);return t?c.end:c.start}return rs(e.workdate,u+a)}return null}function wg(r,e,t){let n=Object.entries(e.dictionary.quarters).sort((s,i)=>i[0].length-s[0].length);for(let[s,i]of n){let o;if(r===s)o=null;else if(r.startsWith(s)&&ir.test(r.slice(s.length).trim()))o=or(r.slice(s.length).trim(),e);else if(r.endsWith(s)&&ir.test(r.slice(0,-s.length).trim()))o=or(r.slice(0,-s.length).trim(),e);else continue;return{year:o,month:t?i*3:i*3-2}}return null}function _c(r,e){if(yc(e.months,r))return e.months[r];let t=/^m(\d{1,2})$/.exec(r);return t&&Number(t[1])>=1&&Number(t[1])<=12?Number(t[1]):null}function yg(r,e){let t=r.split(/\s+/),n=t.map((u,c)=>_c(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!n.length)return null;if(n.length!==1)return ar();let s=n[0],i=_c(t[s],e.dictionary),o=t.slice(0,s),a=t.slice(s+1),l=[...o,...a];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(i>e.month?1:0),month:i};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(i<e.month?1:0),month:i};if(!l.length)return{year:null,month:i};if(!o.length&&a.length===1&&ir.test(a[0]))return{year:or(a[0],e),month:i};if(o.length===1&&bc.test(o[0])){if(!a.length)return Ce(e.year,i,Number(o[0]));if(a.length===1&&ir.test(a[0]))return Ce(or(a[0],e),i,Number(o[0]))}return!o.length&&a.length===2&&bc.test(a[0])&&ir.test(a[1])?Ce(or(a[1],e),i,Number(a[0])):ar()}function vg(r,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(r);if(t)return Ce(...t.slice(1).map(Number));let n=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(r),s={};if(n)e.order.split("").forEach((a,l)=>{s[a]=n[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(r)){let a=r.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;s[l]=r.slice(0,u),r=r.slice(u)}}else return null;if(!ir.test(s.Y)||s.D.length>2||s.M.length>2)return ar();let i=Number(s.D),o=Number(s.M);return n&&o>12&&i<=12&&([i,o]=[o,i]),Ce(or(s.Y,e),o,i)}function wc(r,e,t){if(!r)return null;let n=e.phrases("articles");if(r=r.split(/\s+/).filter(i=>!n.includes(i)).join(" "),!r)return ar();if(ir.test(r))return Ce(or(r,e),t?12:1,t?31:1);let s=_g(r,e,t)??wg(r,e,t)??yg(r,e);return s!==null?s:yc(e.dictionary.weekdays,r)?rs(ra(e.workdate),e.dictionary.weekdays[r]):vg(r,e)??ar()}function Eg(r,e,t){if(r===null||typeof r=="string")return r;let n=r.year??t.year,s=typeof e=="string"?sr(e)[0]:e?.year,i=typeof e=="string"?sr(e)[1]:e?.month;return s&&(n>s&&(n=s),n===s&&r.month>i&&n--),Ce(n,r.month,1)}function kg(r,e,t){if(r===null||typeof r=="string")return r;let n=r.year??t.year;if(e!==null){let[s,i]=sr(e);n<s&&(n=s),n===s&&i>r.month&&n++}return Ce(n,r.month,nr(n,r.month))}function Ag(r,e={}){if(!e||typeof e!="object"||Array.isArray(e))return ns("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:n="it-IT",workdate:s,twoDigitYearAhead:i=20}=e,[o,a]=sr(s);if(!Number.isInteger(i)||i<0||i>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...gc(n),workdate:s,year:o,month:a,twoDigitYearAhead:i}}catch(n){return ns("INVALID_CONTEXT",n.message)}if(typeof r!="string")return ns("INVALID_INPUT","Expression must be a string.");try{let n=r.toLowerCase().trim().replaceAll(",",""),{bounds:s,range:i}=bg(n,t),o=wc(s[1],t,!0),a=wc(s[0],t,!1),l=Eg(a,o,t),u=kg(o,l,t);return!i&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(n){if(n instanceof RangeError)return ns("INVALID_DATE",n.message);if(n instanceof SyntaxError)return ns(n.code,n.message);throw n}}export{C as Bag,Fe as BagNode,Qn as DirectoryResolver,Gn as DomHandler,Ai as Exposed,es as FileSystemController,rr as FileSystemLogic,qr as FramePage,Zn as Gramlot,qe as GramlotBuilder,Kt as GramlotHtmlRenderer,Vn as GramlotRenderer,Mn as GramlotSvgRenderer,Se as Handler,Vr as HttpTransport,Ci as IdeLogic,Xn as InOut,Ti as IndexLogic,Kn as IndexPage,ta as NavigationResolver,Jn as Page,Ko as PageBootstrap,Fn as References,zn as RpcError,Wn as RpcHandler,ut as ServerAdapter,Hn as SourceHandler,Yn as UtilitiesHandler,xi as codeMirrorWithOptions,Et as createDecimal,pc as fileSystemTree,ea as mountIndexPage,Ag as parseDateExpression};
|
|
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}
|
|
124
|
+
)`)():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("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()}},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")||!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()}},$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")?"":" (draft only \u2014 Remote Edit is disabled)"}`))}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.ideDocuments.documents.getItem(i).setItem("writable",this.ideState.getItem("browser.writable")===!0),++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",!1),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)}
|
|
141
|
+
input#control[aria-invalid="true"],textarea#control[aria-invalid="true"]{color:var(--gramlot-error,#8c1d18)}
|
|
142
|
+
#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
|
+
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}
|
|
145
|
+
#field-message[data-severity="warning"]{color:var(--gramlot-warning,#805600);border-color:var(--gramlot-warning,#805600);background:var(--gramlot-warning-background,#fff8df)}
|
|
146
|
+
#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";
|
|
149
|
+
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};
|
|
70
151
|
/*! Bundled license information:
|
|
71
152
|
|
|
72
153
|
decimal.js/decimal.mjs:
|