@authhero/saml 0.4.1 → 0.4.2

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/core.cjs CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var le=Object.defineProperty;var ce=(t,e,n)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var z=(t,e,n)=>ce(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@hono/zod-openapi"),N=i.z.object({"#text":i.z.string()}),K=i.z.object({"#text":i.z.string(),"@_xmlns:saml":i.z.string().optional()}),q=i.z.object({"samlp:AuthnRequest":i.z.object({"saml:Issuer":K,"@_xmlns:samlp":i.z.string(),"@_xmlns:saml":i.z.string().optional(),"@_ForceAuthn":i.z.string().transform(t=>t.toLowerCase()==="true").optional(),"@_ID":i.z.string(),"@_IssueInstant":i.z.string().datetime(),"@_Destination":i.z.string().url(),"@_AssertionConsumerServiceURL":i.z.string().url().optional(),"@_ProtocolBinding":i.z.string().optional(),"@_Version":i.z.string()})}),de=i.z.array(i.z.object({":@":i.z.object({"@_xmlns":i.z.string(),"@_entityID":i.z.string()}),EntityDescriptor:i.z.array(i.z.object({":@":i.z.object({"@_protocolSupportEnumeration":i.z.string()}),IDPSSODescriptor:i.z.array(i.z.union([i.z.object({KeyDescriptor:i.z.array(i.z.object({KeyInfo:i.z.array(i.z.object({X509Data:i.z.array(i.z.object({X509Certificate:i.z.array(N)}))})),":@":i.z.object({"@_xmlns":i.z.string()})})),":@":i.z.object({"@_use":i.z.string()})}),i.z.object({SingleLogoutService:i.z.array(i.z.object({})),":@":i.z.object({"@_Binding":i.z.string(),"@_Location":i.z.string()})}),i.z.object({NameIDFormat:i.z.array(N)}),i.z.object({SingleSignOnService:i.z.array(i.z.object({})),":@":i.z.object({"@_Binding":i.z.string(),"@_Location":i.z.string()})}),i.z.object({Attribute:i.z.array(i.z.object({})),":@":i.z.object({"@_Name":i.z.string(),"@_NameFormat":i.z.string(),"@_FriendlyName":i.z.string(),"@_xmlns":i.z.string()})})]))}))})),fe=i.z.object({"saml:Attribute":i.z.array(i.z.object({"saml:AttributeValue":i.z.array(i.z.object({"#text":i.z.string()})),":@":i.z.object({"@_xmlns:xs":i.z.string().optional(),"@_xmlns:xsi":i.z.string(),"@_xsi:type":i.z.string()}).optional()})),":@":i.z.object({"@_Name":i.z.string(),"@_NameFormat":i.z.string(),"@_FriendlyName":i.z.string().optional()})}),he=i.z.object({"ds:Transform":i.z.array(i.z.any()),":@":i.z.object({"@_Algorithm":i.z.string()})}),L=i.z.object({"ds:Signature":i.z.array(i.z.union([i.z.object({"ds:SignedInfo":i.z.array(i.z.union([i.z.object({"ds:CanonicalizationMethod":i.z.array(i.z.object({":@":i.z.object({"@_Algorithm":i.z.string()})}))}),i.z.object({"ds:SignatureMethod":i.z.array(i.z.object({":@":i.z.object({"@_Algorithm":i.z.string()})}))}),i.z.object({"ds:Reference":i.z.array(i.z.union([i.z.object({"ds:Transforms":i.z.array(he)}),i.z.object({"ds:DigestMethod":i.z.array(i.z.object({":@":i.z.object({"@_Algorithm":i.z.string()})}))}),i.z.object({"ds:DigestValue":i.z.array(N)})])),":@":i.z.object({"@_URI":i.z.string().optional()}).optional()})]))}),i.z.object({"ds:SignatureValue":i.z.array(N)}),i.z.object({"ds:KeyInfo":i.z.array(i.z.union([i.z.object({"ds:KeyValue":i.z.array(i.z.object({"ds:RSAKeyValue":i.z.array(i.z.union([i.z.object({"ds:Modulus":i.z.array(N)}),i.z.object({"ds:Exponent":i.z.array(N)})]))}))}),i.z.object({"ds:X509Data":i.z.array(i.z.object({"ds:X509Certificate":i.z.array(N)}))}),i.z.object({"ds:KeyValue":i.z.array(i.z.object({"ds:RSAKeyValue":i.z.array(i.z.union([i.z.object({"ds:Modulus":i.z.array(N)}),i.z.object({"ds:Exponent":i.z.array(N)})]))})),"ds:X509Data":i.z.array(i.z.object({"ds:X509Certificate":i.z.array(N)}))})]))})])),":@":i.z.object({"@_xmlns:ds":i.z.string().optional()}).optional()}),pe=i.z.array(i.z.object({"samlp:Response":i.z.array(i.z.union([i.z.object({"saml:Issuer":i.z.array(N)}),L,i.z.object({"samlp:Status":i.z.array(i.z.object({"samlp:StatusCode":i.z.array(N),":@":i.z.object({"@_Value":i.z.string()})}))}),i.z.object({"saml:Assertion":i.z.array(i.z.union([i.z.object({"saml:Issuer":i.z.array(N)}),L,i.z.object({"saml:Subject":i.z.array(i.z.union([i.z.object({"saml:NameID":i.z.array(N),":@":i.z.object({"@_Format":i.z.string()})}),i.z.object({"saml:SubjectConfirmation":i.z.array(i.z.object({"saml:SubjectConfirmationData":i.z.array(i.z.any()),":@":i.z.object({"@_InResponseTo":i.z.string(),"@_NotOnOrAfter":i.z.string(),"@_Recipient":i.z.string()})})),":@":i.z.object({"@_Method":i.z.string()})})]))}),i.z.object({"saml:Conditions":i.z.array(i.z.object({"saml:AudienceRestriction":i.z.array(i.z.object({"saml:Audience":i.z.array(N)}))})),":@":i.z.object({"@_NotBefore":i.z.string(),"@_NotOnOrAfter":i.z.string()})}),i.z.object({"saml:AuthnStatement":i.z.array(i.z.object({"saml:AuthnContext":i.z.array(i.z.object({"saml:AuthnContextClassRef":i.z.array(N)}))})),":@":i.z.object({"@_AuthnInstant":i.z.string(),"@_SessionIndex":i.z.string(),"@_SessionNotOnOrAfter":i.z.string()})}),i.z.object({"saml:AttributeStatement":i.z.array(fe)})])),":@":i.z.object({"@_xmlns":i.z.string(),"@_ID":i.z.string(),"@_IssueInstant":i.z.string(),"@_Version":i.z.string()})})])),":@":i.z.object({"@_xmlns:samlp":i.z.string(),"@_xmlns:saml":i.z.string(),"@_Destination":i.z.string(),"@_ID":i.z.string(),"@_InResponseTo":i.z.string(),"@_IssueInstant":i.z.string(),"@_Version":i.z.string()})}));var Z={},C={};(function(t){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",s="["+e+"]["+n+"]*",r=new RegExp("^"+s+"$"),o=function(l,f){const d=[];let h=f.exec(l);for(;h;){const m=[];m.startIndex=f.lastIndex-h[0].length;const b=h.length;for(let y=0;y<b;y++)m.push(h[y]);d.push(m),h=f.exec(l)}return d},a=function(l){const f=r.exec(l);return!(f===null||typeof f>"u")};t.isExist=function(l){return typeof l<"u"},t.isEmptyObject=function(l){return Object.keys(l).length===0},t.merge=function(l,f,d){if(f){const h=Object.keys(f),m=h.length;for(let b=0;b<m;b++)d==="strict"?l[h[b]]=[f[h[b]]]:l[h[b]]=f[h[b]]}},t.getValue=function(l){return t.isExist(l)?l:""};const c=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],u=["__proto__","constructor","prototype"];t.isName=a,t.getAllMatches=o,t.nameRegexp=s,t.DANGEROUS_PROPERTY_NAMES=c,t.criticalProperties=u})(C);const $=C,ge={allowBooleanAttributes:!1,unpairedTags:[]};Z.validate=function(t,e){e=Object.assign({},ge,e);const n=[];let s=!1,r=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let o=0;o<t.length;o++)if(t[o]==="<"&&t[o+1]==="?"){if(o+=2,o=B(t,o),o.err)return o}else if(t[o]==="<"){let a=o;if(o++,t[o]==="!"){o=U(t,o);continue}else{let c=!1;t[o]==="/"&&(c=!0,o++);let u="";for(;o<t.length&&t[o]!==">"&&t[o]!==" "&&t[o]!==" "&&t[o]!==`
2
- `&&t[o]!=="\r";o++)u+=t[o];if(u=u.trim(),u[u.length-1]==="/"&&(u=u.substring(0,u.length-1),o--),!ze(u)){let d;return u.trim().length===0?d="Invalid space after '<'.":d="Tag '"+u+"' is an invalid name.",g("InvalidTag",d,w(t,o))}const l=Ne(t,o);if(l===!1)return g("InvalidAttr","Attributes for '"+u+"' have open quote.",w(t,o));let f=l.value;if(o=l.index,f[f.length-1]==="/"){const d=o-f.length;f=f.substring(0,f.length-1);const h=k(f,e);if(h===!0)s=!0;else return g(h.err.code,h.err.msg,w(t,d+h.err.line))}else if(c)if(l.tagClosed){if(f.trim().length>0)return g("InvalidTag","Closing tag '"+u+"' can't have attributes or invalid starting.",w(t,a));if(n.length===0)return g("InvalidTag","Closing tag '"+u+"' has not been opened.",w(t,a));{const d=n.pop();if(u!==d.tagName){let h=w(t,d.tagStartPos);return g("InvalidTag","Expected closing tag '"+d.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+u+"'.",w(t,a))}n.length==0&&(r=!0)}}else return g("InvalidTag","Closing tag '"+u+"' doesn't have proper closing.",w(t,o));else{const d=k(f,e);if(d!==!0)return g(d.err.code,d.err.msg,w(t,o-f.length+d.err.line));if(r===!0)return g("InvalidXml","Multiple possible root nodes found.",w(t,o));e.unpairedTags.indexOf(u)!==-1||n.push({tagName:u,tagStartPos:a}),s=!0}for(o++;o<t.length;o++)if(t[o]==="<")if(t[o+1]==="!"){o++,o=U(t,o);continue}else if(t[o+1]==="?"){if(o=B(t,++o),o.err)return o}else break;else if(t[o]==="&"){const d=ye(t,o);if(d==-1)return g("InvalidChar","char '&' is not expected.",w(t,o));o=d}else if(r===!0&&!X(t[o]))return g("InvalidXml","Extra text at the end",w(t,o));t[o]==="<"&&o--}}else{if(X(t[o]))continue;return g("InvalidChar","char '"+t[o]+"' is not expected.",w(t,o))}if(s){if(n.length==1)return g("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",w(t,n[0].tagStartPos));if(n.length>0)return g("InvalidXml","Invalid '"+JSON.stringify(n.map(o=>o.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return g("InvalidXml","Start tag expected.",1);return!0};function X(t){return t===" "||t===" "||t===`
3
- `||t==="\r"}function B(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const s=t.substr(n,e-n);if(e>5&&s==="xml")return g("InvalidXml","XML declaration allowed only at the start of the document.",w(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function U(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let n=1;for(e+=8;e<t.length;e++)if(t[e]==="<")n++;else if(t[e]===">"&&(n--,n===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}const me='"',be="'";function Ne(t,e){let n="",s="",r=!1;for(;e<t.length;e++){if(t[e]===me||t[e]===be)s===""?s=t[e]:s!==t[e]||(s="");else if(t[e]===">"&&s===""){r=!0;break}n+=t[e]}return s!==""?!1:{value:n,index:e,tagClosed:r}}const we=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function k(t,e){const n=$.getAllMatches(t,we),s={};for(let r=0;r<n.length;r++){if(n[r][1].length===0)return g("InvalidAttr","Attribute '"+n[r][2]+"' has no space in starting.",I(n[r]));if(n[r][3]!==void 0&&n[r][4]===void 0)return g("InvalidAttr","Attribute '"+n[r][2]+"' is without value.",I(n[r]));if(n[r][3]===void 0&&!e.allowBooleanAttributes)return g("InvalidAttr","boolean attribute '"+n[r][2]+"' is not allowed.",I(n[r]));const o=n[r][2];if(!xe(o))return g("InvalidAttr","Attribute '"+o+"' is an invalid name.",I(n[r]));if(!s.hasOwnProperty(o))s[o]=1;else return g("InvalidAttr","Attribute '"+o+"' is repeated.",I(n[r]))}return!0}function Ee(t,e){let n=/\d/;for(t[e]==="x"&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(n))break}return-1}function ye(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Ee(t,e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(t[e]===";")break;return-1}return e}function g(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function xe(t){return $.isName(t)}function ze(t){return $.isName(t)}function w(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function I(t){return t.startIndex+t[1].length}var F={};const{DANGEROUS_PROPERTY_NAMES:H,criticalProperties:Ae}=C,W=t=>H.includes(t)?"__"+t:t,Q={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,onDangerousProperty:W};function Se(t,e){if(typeof t!="string")return;const n=t.toLowerCase();if(H.some(s=>n===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Ae.some(s=>n===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function D(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:D(!0)}const _e=function(t){const e=Object.assign({},Q,t),n=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:s,name:r}of n)s&&Se(s,r);return e.onDangerousProperty===null&&(e.onDangerousProperty=W),e.processEntities=D(e.processEntities),e};F.buildOptions=_e;F.defaultOptions=Q;class Te{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,n){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:n})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}var Ie=Te;const ee=C;let Oe=class{constructor(e){this.suppressValidationErr=!e,this.options=e||{}}readDocType(e,n){const s=Object.create(null);let r=0;if(e[n+3]==="O"&&e[n+4]==="C"&&e[n+5]==="T"&&e[n+6]==="Y"&&e[n+7]==="P"&&e[n+8]==="E"){n=n+9;let o=1,a=!1,c=!1,u="";for(;n<e.length;n++)if(e[n]==="<"&&!c){if(a&&A(e,"!ENTITY",n)){n+=7;let l,f;if([l,f,n]=this.readEntityExp(e,n+1,this.suppressValidationErr),f.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&r>=this.options.maxEntityCount)throw new Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const d=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[l]={regx:RegExp(`&${d};`,"g"),val:f},r++}}else if(a&&A(e,"!ELEMENT",n)){n+=8;const{index:l}=this.readElementExp(e,n+1);n=l}else if(a&&A(e,"!ATTLIST",n))n+=8;else if(a&&A(e,"!NOTATION",n)){n+=9;const{index:l}=this.readNotationExp(e,n+1,this.suppressValidationErr);n=l}else if(A(e,"!--",n))c=!0;else throw new Error("Invalid DOCTYPE");o++,u=""}else if(e[n]===">"){if(c?e[n-1]==="-"&&e[n-2]==="-"&&(c=!1,o--):o--,o===0)break}else e[n]==="["?a=!0:u+=e[n];if(o!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:n}}readEntityExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n])&&e[n]!=='"'&&e[n]!=="'";)s+=e[n],n++;if(O(s),n=E(e,n),!this.suppressValidationErr){if(e.substring(n,n+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[n]==="%")throw new Error("Parameter entities are not supported")}let r="";if([n,r]=this.readIdentifierVal(e,n,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${s}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return n--,[s,r,n]}readNotationExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;!this.suppressValidationErr&&O(s),n=E(e,n);const r=e.substring(n,n+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);n+=r.length,n=E(e,n);let o=null,a=null;if(r==="PUBLIC")[n,o]=this.readIdentifierVal(e,n,"publicIdentifier"),n=E(e,n),(e[n]==='"'||e[n]==="'")&&([n,a]=this.readIdentifierVal(e,n,"systemIdentifier"));else if(r==="SYSTEM"&&([n,a]=this.readIdentifierVal(e,n,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:s,publicIdentifier:o,systemIdentifier:a,index:--n}}readIdentifierVal(e,n,s){let r="";const o=e[n];if(o!=='"'&&o!=="'")throw new Error(`Expected quoted string, found "${o}"`);for(n++;n<e.length&&e[n]!==o;)r+=e[n],n++;if(e[n]!==o)throw new Error(`Unterminated ${s} value`);return n++,[n,r]}readElementExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;if(!this.suppressValidationErr&&!ee.isName(s))throw new Error(`Invalid element name: "${s}"`);n=E(e,n);let r="";if(e[n]==="E"&&A(e,"MPTY",n))n+=4;else if(e[n]==="A"&&A(e,"NY",n))n+=2;else if(e[n]==="("){for(n++;n<e.length&&e[n]!==")";)r+=e[n],n++;if(e[n]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[n]}"`);return{elementName:s,contentModel:r.trim(),index:n}}readAttlistExp(e,n){n=E(e,n);let s="";for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;O(s),n=E(e,n);let r="";for(;n<e.length&&!/\s/.test(e[n]);)r+=e[n],n++;if(!O(r))throw new Error(`Invalid attribute name: "${r}"`);n=E(e,n);let o="";if(e.substring(n,n+8).toUpperCase()==="NOTATION"){if(o="NOTATION",n+=8,n=E(e,n),e[n]!=="(")throw new Error(`Expected '(', found "${e[n]}"`);n++;let c=[];for(;n<e.length&&e[n]!==")";){let u="";for(;n<e.length&&e[n]!=="|"&&e[n]!==")";)u+=e[n],n++;if(u=u.trim(),!O(u))throw new Error(`Invalid notation name: "${u}"`);c.push(u),e[n]==="|"&&(n++,n=E(e,n))}if(e[n]!==")")throw new Error("Unterminated list of notations");n++,o+=" ("+c.join("|")+")"}else{for(;n<e.length&&!/\s/.test(e[n]);)o+=e[n],n++;const c=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!c.includes(o.toUpperCase()))throw new Error(`Invalid attribute type: "${o}"`)}n=E(e,n);let a="";return e.substring(n,n+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",n+=8):e.substring(n,n+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",n+=7):[n,a]=this.readIdentifierVal(e,n,"ATTLIST"),{elementName:s,attributeName:r,attributeType:o,defaultValue:a,index:n}}};const E=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function A(t,e,n){for(let s=0;s<e.length;s++)if(e[s]!==t[n+s+1])return!1;return!0}function O(t){if(ee.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var Ce=Oe;const Pe=/^[-+]?0x[a-fA-F0-9]+$/,Me=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Le={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function je(t,e={}){if(e=Object.assign({},Le,e),!t||typeof t!="string")return t;let n=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(n))return t;if(t==="0")return 0;if(e.hex&&Pe.test(n))return Ve(n,16);if(n.search(/[eE]/)!==-1){const s=n.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(s){if(e.leadingZeros)n=(s[1]||"")+s[3];else if(!(s[2]==="0"&&s[3][0]==="."))return t;return e.eNotation?Number(n):t}else return t}else{const s=Me.exec(n);if(s){const r=s[1],o=s[2];let a=ve(s[3]);if(!e.leadingZeros&&o.length>0&&r&&n[2]!==".")return t;if(!e.leadingZeros&&o.length>0&&!r&&n[1]!==".")return t;if(e.leadingZeros&&o===t)return 0;{const c=Number(n),u=""+c;return u.search(/[eE]/)!==-1?e.eNotation?c:t:n.indexOf(".")!==-1?u==="0"&&a===""||u===a||r&&u==="-"+a?c:t:o?a===u||r+a===u?c:t:n===u||n===r+u?c:t}}else return t}}function ve(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}function Ve(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}var $e=je;function Fe(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(const n of t)if(typeof n=="string"&&e===n||n instanceof RegExp&&n.test(e))return!0}:()=>!1}var te=Fe;const P=C,T=Ie,Re=Ce,Xe=$e,Be=te;let Ue=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,s)=>G(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,s)=>G(s,16,"&#x")}},this.addExternalEntities=ke,this.parseXml=qe,this.parseTextData=Ge,this.resolveNameSpace=Ye,this.buildAttributesMap=Ke,this.isItStopNode=Qe,this.replaceEntitiesValue=He,this.readStopNodeData=et,this.saveTextToParentTag=We,this.addChild=Ze,this.ignoreAttributesFn=Be(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let n=0;n<this.options.stopNodes.length;n++){const s=this.options.stopNodes[n];typeof s=="string"&&(s.startsWith("*.")?this.stopNodesWildcard.add(s.substring(2)):this.stopNodesExact.add(s))}}}};function ke(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const s=e[n],r=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+r+";","g"),val:t[s]}}}function Ge(t,e,n,s,r,o,a){if(t!==void 0&&(this.options.trimValues&&!s&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t,e,n));const c=this.options.tagValueProcessor(e,t,n,r,o);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?v(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?v(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function Ye(t){if(this.options.removeNSPrefix){const e=t.split(":"),n=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=n+e[1])}return t}const Je=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Ke(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const s=P.getAllMatches(t,Je),r=s.length,o={};for(let a=0;a<r;a++){const c=this.resolveNameSpace(s[a][1]);if(this.ignoreAttributesFn(c,e))continue;let u=s[a][4],l=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l=tt(l,this.options),u!==void 0){this.options.trimValues&&(u=u.trim()),u=this.replaceEntitiesValue(u,n,e);const f=this.options.attributeValueProcessor(c,u,e);f==null?o[l]=u:typeof f!=typeof u||f!==u?o[l]=f:o[l]=v(u,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[l]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=o,a}return o}}const qe=function(t){t=t.replace(/\r\n?/g,`
4
- `);const e=new T("!xml");let n=e,s="",r="";this.entityExpansionCount=0,this.currentExpandedLength=0;const o=new Re(this.options.processEntities);for(let a=0;a<t.length;a++)if(t[a]==="<")if(t[a+1]==="/"){const u=S(t,">",a,"Closing Tag is not closed.");let l=t.substring(a+2,u).trim();if(this.options.removeNSPrefix){const h=l.indexOf(":");h!==-1&&(l=l.substr(h+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&(s=this.saveTextToParentTag(s,n,r));const f=r.substring(r.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let d=0;f&&this.options.unpairedTags.indexOf(f)!==-1?(d=r.lastIndexOf(".",r.lastIndexOf(".")-1),this.tagsNodeStack.pop()):d=r.lastIndexOf("."),r=r.substring(0,d),n=this.tagsNodeStack.pop(),s="",a=u}else if(t[a+1]==="?"){let u=j(t,a,!1,"?>");if(!u)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,n,r),!(this.options.ignoreDeclaration&&u.tagName==="?xml"||this.options.ignorePiTags)){const l=new T(u.tagName);l.add(this.options.textNodeName,""),u.tagName!==u.tagExp&&u.attrExpPresent&&(l[":@"]=this.buildAttributesMap(u.tagExp,r,u.tagName)),this.addChild(n,l,r,a)}a=u.closeIndex+1}else if(t.substr(a+1,3)==="!--"){const u=S(t,"-->",a+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(a+4,u-2);s=this.saveTextToParentTag(s,n,r),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}a=u}else if(t.substr(a+1,2)==="!D"){const u=o.readDocType(t,a);this.docTypeEntities=u.entities,a=u.i}else if(t.substr(a+1,2)==="!["){const u=S(t,"]]>",a,"CDATA is not closed.")-2,l=t.substring(a+9,u);s=this.saveTextToParentTag(s,n,r);let f=this.parseTextData(l,n.tagname,r,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,f),a=u+2}else{let u=j(t,a,this.options.removeNSPrefix),l=u.tagName;const f=u.rawTagName;let d=u.tagExp,h=u.attrExpPresent,m=u.closeIndex;if(this.options.transformTagName){const p=this.options.transformTagName(l);d===l&&(d=p),l=p}if(this.options.strictReservedNames&&(l===this.options.commentPropName||l===this.options.cdataPropName||l===this.options.textNodeName||l===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${l}`);n&&s&&n.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,n,r,!1));const b=n;b&&this.options.unpairedTags.indexOf(b.tagname)!==-1&&(n=this.tagsNodeStack.pop(),r=r.substring(0,r.lastIndexOf("."))),l!==e.tagname&&(r+=r?"."+l:l);const y=a;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,r,l)){let p="";if(d.length>0&&d.lastIndexOf("/")===d.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),r=r.substr(0,r.length-1),d=l):d=d.substr(0,d.length-1),a=u.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)a=u.closeIndex;else{const M=this.readStopNodeData(t,f,m+1);if(!M)throw new Error(`Unexpected end of ${f}`);a=M.i,p=M.tagContent}const _=new T(l);l!==d&&h&&(_[":@"]=this.buildAttributesMap(d,r,l)),p&&(p=this.parseTextData(p,l,r,!0,h,!0,!0)),r=r.substr(0,r.lastIndexOf(".")),_.add(this.options.textNodeName,p),this.addChild(n,_,r,y)}else{if(d.length>0&&d.lastIndexOf("/")===d.length-1){if(l[l.length-1]==="/"?(l=l.substr(0,l.length-1),r=r.substr(0,r.length-1),d=l):d=d.substr(0,d.length-1),this.options.transformTagName){const _=this.options.transformTagName(l);d===l&&(d=_),l=_}const p=new T(l);l!==d&&h&&(p[":@"]=this.buildAttributesMap(d,r,l)),this.addChild(n,p,r,y),r=r.substr(0,r.lastIndexOf("."))}else if(this.options.unpairedTags.indexOf(l)!==-1){const p=new T(l);l!==d&&h&&(p[":@"]=this.buildAttributesMap(d,r)),this.addChild(n,p,r,y),r=r.substr(0,r.lastIndexOf(".")),a=u.closeIndex;continue}else{const p=new T(l);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(n),l!==d&&h&&(p[":@"]=this.buildAttributesMap(d,r,l)),this.addChild(n,p,r),n=p}s="",a=m}}else s+=t[a];return e.child};function Ze(t,e,n,s){this.options.captureMetaData||(s=void 0);const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e,s))}const He=function(t,e,n){if(t.indexOf("&")===-1)return t;const s=this.options.processEntities;if(!s.enabled||s.allowedTags&&!s.allowedTags.includes(e)||s.tagFilter&&!s.tagFilter(e,n))return t;for(let r in this.docTypeEntities){const o=this.docTypeEntities[r],a=t.match(o.regx);if(a){if(this.entityExpansionCount+=a.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);const c=t.length;if(t=t.replace(o.regx,o.val),s.maxExpandedLength&&(this.currentExpandedLength+=t.length-c,this.currentExpandedLength>s.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(const r of Object.keys(this.lastEntities)){const o=this.lastEntities[r],a=t.match(o.regex);if(a&&(this.entityExpansionCount+=a.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);t=t.replace(o.regex,o.val)}if(t.indexOf("&")===-1)return t;if(this.options.htmlEntities)for(const r of Object.keys(this.htmlEntities)){const o=this.htmlEntities[r],a=t.match(o.regex);if(a&&(this.entityExpansionCount+=a.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);t=t.replace(o.regex,o.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t};function We(t,e,n,s){return t&&(s===void 0&&(s=e.child.length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function Qe(t,e,n,s){return!!(e&&e.has(s)||t&&t.has(n))}function De(t,e,n=">"){let s,r="";for(let o=e;o<t.length;o++){let a=t[o];if(s)a===s&&(s="");else if(a==='"'||a==="'")s=a;else if(a===n[0])if(n[1]){if(t[o+1]===n[1])return{data:r,index:o}}else return{data:r,index:o};else a===" "&&(a=" ");r+=a}}function S(t,e,n,s){const r=t.indexOf(e,n);if(r===-1)throw new Error(s);return r+e.length-1}function j(t,e,n,s=">"){const r=De(t,e+1,s);if(!r)return;let o=r.data;const a=r.index,c=o.search(/\s/);let u=o,l=!0;c!==-1&&(u=o.substring(0,c),o=o.substring(c+1).trimStart());const f=u;if(n){const d=u.indexOf(":");d!==-1&&(u=u.substr(d+1),l=u!==r.data.substr(d+1))}return{tagName:u,tagExp:o,closeIndex:a,attrExpPresent:l,rawTagName:f}}function et(t,e,n){const s=n;let r=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const o=S(t,">",n,`${e} is not closed`);if(t.substring(n+2,o).trim()===e&&(r--,r===0))return{tagContent:t.substring(s,n),i:o};n=o}else if(t[n+1]==="?")n=S(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=S(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=S(t,"]]>",n,"StopNode is not closed.")-2;else{const o=j(t,n,">");o&&((o&&o.tagName)===e&&o.tagExp[o.tagExp.length-1]!=="/"&&r++,n=o.closeIndex)}}function v(t,e,n){if(e&&typeof t=="string"){const s=t.trim();return s==="true"?!0:s==="false"?!1:Xe(t,n)}else return P.isExist(t)?t:""}function G(t,e,n){const s=Number.parseInt(t,e);return s>=0&&s<=1114111?String.fromCodePoint(s):n+t+";"}function tt(t,e){if(P.criticalProperties.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return P.DANGEROUS_PROPERTY_NAMES.includes(t)?e.onDangerousProperty(t):t}var nt=Ue,ne={};function st(t,e){return se(t,e)}function se(t,e,n){let s;const r={};for(let o=0;o<t.length;o++){const a=t[o],c=rt(a);let u="";if(n===void 0?u=c:u=n+"."+c,c===e.textNodeName)s===void 0?s=a[c]:s+=""+a[c];else{if(c===void 0)continue;if(a[c]){let l=se(a[c],e,u);const f=ot(l,e);a[":@"]?it(l,a[":@"],u,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),r[c]!==void 0&&r.hasOwnProperty(c)?(Array.isArray(r[c])||(r[c]=[r[c]]),r[c].push(l)):e.isArray(c,u,f)?r[c]=[l]:r[c]=l}}}return typeof s=="string"?s.length>0&&(r[e.textNodeName]=s):s!==void 0&&(r[e.textNodeName]=s),r}function rt(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const s=e[n];if(s!==":@")return s}}function it(t,e,n,s){if(e){const r=Object.keys(e),o=r.length;for(let a=0;a<o;a++){const c=r[a];s.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function ot(t,e){const{textNodeName:n}=e,s=Object.keys(t).length;return!!(s===0||s===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}ne.prettify=st;const{buildOptions:at}=F,ut=nt,{prettify:lt}=ne,ct=Z;let dt=class{constructor(e){this.externalEntities={},this.options=at(e)}parse(e,n){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});const o=ct.validate(e,n);if(o!==!0)throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`)}const s=new ut(this.options);s.addExternalEntities(this.externalEntities);const r=s.parseXml(e);return this.options.preserveOrder||r===void 0?r:lt(r,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var ft=dt;const ht=`
5
- `;function pt(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=ht),re(t,e,"",n)}function re(t,e,n,s){let r="",o=!1;if(!Array.isArray(t)){if(t!=null){let a=t.toString();return a=V(a,e),a}return""}for(let a=0;a<t.length;a++){const c=t[a],u=gt(c);if(u===void 0)continue;let l="";if(n.length===0?l=u:l=`${n}.${u}`,u===e.textNodeName){let b=c[u];mt(l,e)||(b=e.tagValueProcessor(u,b),b=V(b,e)),o&&(r+=s),r+=b,o=!1;continue}else if(u===e.cdataPropName){o&&(r+=s),r+=`<![CDATA[${c[u][0][e.textNodeName]}]]>`,o=!1;continue}else if(u===e.commentPropName){r+=s+`<!--${c[u][0][e.textNodeName]}-->`,o=!0;continue}else if(u[0]==="?"){const b=Y(c[":@"],e),y=u==="?xml"?"":s;let p=c[u][0][e.textNodeName];p=p.length!==0?" "+p:"",r+=y+`<${u}${p}${b}?>`,o=!0;continue}let f=s;f!==""&&(f+=e.indentBy);const d=Y(c[":@"],e),h=s+`<${u}${d}`,m=re(c[u],e,l,f);e.unpairedTags.indexOf(u)!==-1?e.suppressUnpairedNode?r+=h+">":r+=h+"/>":(!m||m.length===0)&&e.suppressEmptyNode?r+=h+"/>":m&&m.endsWith(">")?r+=h+`>${m}${s}</${u}>`:(r+=h+">",m&&s!==""&&(m.includes("/>")||m.includes("</"))?r+=s+e.indentBy+m+s:r+=m,r+=`</${u}>`),o=!0}return r}function gt(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const s=e[n];if(Object.prototype.hasOwnProperty.call(t,s)&&s!==":@")return s}}function Y(t,e){let n="";if(t&&!e.ignoreAttributes)for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let r=e.attributeValueProcessor(s,t[s]);r=V(r,e),r===!0&&e.suppressBooleanAttributes?n+=` ${s.substr(e.attributeNamePrefix.length)}`:n+=` ${s.substr(e.attributeNamePrefix.length)}="${r}"`}return n}function mt(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let s in e.stopNodes)if(e.stopNodes[s]===t||e.stopNodes[s]==="*."+n)return!0;return!1}function V(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const s=e.entities[n];t=t.replace(s.regex,s.val)}return t}var bt=pt;const Nt=bt,wt=te,Et={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function x(t){this.options=Object.assign({},Et,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=wt(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=zt),this.processTextOrObjNode=yt,this.options.format?(this.indentate=xt,this.tagEndChar=`>
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);let t=require("@hono/zod-openapi");var n=t.z.object({"#text":t.z.string()}),r=t.z.object({"#text":t.z.string(),"@_xmlns:saml":t.z.string().optional()}),i=t.z.object({"samlp:AuthnRequest":t.z.object({"saml:Issuer":r,"@_xmlns:samlp":t.z.string(),"@_xmlns:saml":t.z.string().optional(),"@_ForceAuthn":t.z.string().transform(e=>e.toLowerCase()===`true`).optional(),"@_ID":t.z.string(),"@_IssueInstant":t.z.string().datetime(),"@_Destination":t.z.string().url(),"@_AssertionConsumerServiceURL":t.z.string().url().optional(),"@_ProtocolBinding":t.z.string().optional(),"@_Version":t.z.string()})}),a=t.z.array(t.z.object({":@":t.z.object({"@_xmlns":t.z.string(),"@_entityID":t.z.string()}),EntityDescriptor:t.z.array(t.z.object({":@":t.z.object({"@_protocolSupportEnumeration":t.z.string()}),IDPSSODescriptor:t.z.array(t.z.union([t.z.object({KeyDescriptor:t.z.array(t.z.object({KeyInfo:t.z.array(t.z.object({X509Data:t.z.array(t.z.object({X509Certificate:t.z.array(n)}))})),":@":t.z.object({"@_xmlns":t.z.string()})})),":@":t.z.object({"@_use":t.z.string()})}),t.z.object({SingleLogoutService:t.z.array(t.z.object({})),":@":t.z.object({"@_Binding":t.z.string(),"@_Location":t.z.string()})}),t.z.object({NameIDFormat:t.z.array(n)}),t.z.object({SingleSignOnService:t.z.array(t.z.object({})),":@":t.z.object({"@_Binding":t.z.string(),"@_Location":t.z.string()})}),t.z.object({Attribute:t.z.array(t.z.object({})),":@":t.z.object({"@_Name":t.z.string(),"@_NameFormat":t.z.string(),"@_FriendlyName":t.z.string(),"@_xmlns":t.z.string()})})]))}))})),o=t.z.object({"saml:Attribute":t.z.array(t.z.object({"saml:AttributeValue":t.z.array(t.z.object({"#text":t.z.string()})),":@":t.z.object({"@_xmlns:xs":t.z.string().optional(),"@_xmlns:xsi":t.z.string(),"@_xsi:type":t.z.string()}).optional()})),":@":t.z.object({"@_Name":t.z.string(),"@_NameFormat":t.z.string(),"@_FriendlyName":t.z.string().optional()})}),s=t.z.object({"ds:Transform":t.z.array(t.z.any()),":@":t.z.object({"@_Algorithm":t.z.string()})}),c=t.z.object({"ds:Signature":t.z.array(t.z.union([t.z.object({"ds:SignedInfo":t.z.array(t.z.union([t.z.object({"ds:CanonicalizationMethod":t.z.array(t.z.object({":@":t.z.object({"@_Algorithm":t.z.string()})}))}),t.z.object({"ds:SignatureMethod":t.z.array(t.z.object({":@":t.z.object({"@_Algorithm":t.z.string()})}))}),t.z.object({"ds:Reference":t.z.array(t.z.union([t.z.object({"ds:Transforms":t.z.array(s)}),t.z.object({"ds:DigestMethod":t.z.array(t.z.object({":@":t.z.object({"@_Algorithm":t.z.string()})}))}),t.z.object({"ds:DigestValue":t.z.array(n)})])),":@":t.z.object({"@_URI":t.z.string().optional()}).optional()})]))}),t.z.object({"ds:SignatureValue":t.z.array(n)}),t.z.object({"ds:KeyInfo":t.z.array(t.z.union([t.z.object({"ds:KeyValue":t.z.array(t.z.object({"ds:RSAKeyValue":t.z.array(t.z.union([t.z.object({"ds:Modulus":t.z.array(n)}),t.z.object({"ds:Exponent":t.z.array(n)})]))}))}),t.z.object({"ds:X509Data":t.z.array(t.z.object({"ds:X509Certificate":t.z.array(n)}))}),t.z.object({"ds:KeyValue":t.z.array(t.z.object({"ds:RSAKeyValue":t.z.array(t.z.union([t.z.object({"ds:Modulus":t.z.array(n)}),t.z.object({"ds:Exponent":t.z.array(n)})]))})),"ds:X509Data":t.z.array(t.z.object({"ds:X509Certificate":t.z.array(n)}))})]))})])),":@":t.z.object({"@_xmlns:ds":t.z.string().optional()}).optional()}),l=t.z.array(t.z.object({"samlp:Response":t.z.array(t.z.union([t.z.object({"saml:Issuer":t.z.array(n)}),c,t.z.object({"samlp:Status":t.z.array(t.z.object({"samlp:StatusCode":t.z.array(n),":@":t.z.object({"@_Value":t.z.string()})}))}),t.z.object({"saml:Assertion":t.z.array(t.z.union([t.z.object({"saml:Issuer":t.z.array(n)}),c,t.z.object({"saml:Subject":t.z.array(t.z.union([t.z.object({"saml:NameID":t.z.array(n),":@":t.z.object({"@_Format":t.z.string()})}),t.z.object({"saml:SubjectConfirmation":t.z.array(t.z.object({"saml:SubjectConfirmationData":t.z.array(t.z.any()),":@":t.z.object({"@_InResponseTo":t.z.string(),"@_NotOnOrAfter":t.z.string(),"@_Recipient":t.z.string()})})),":@":t.z.object({"@_Method":t.z.string()})})]))}),t.z.object({"saml:Conditions":t.z.array(t.z.object({"saml:AudienceRestriction":t.z.array(t.z.object({"saml:Audience":t.z.array(n)}))})),":@":t.z.object({"@_NotBefore":t.z.string(),"@_NotOnOrAfter":t.z.string()})}),t.z.object({"saml:AuthnStatement":t.z.array(t.z.object({"saml:AuthnContext":t.z.array(t.z.object({"saml:AuthnContextClassRef":t.z.array(n)}))})),":@":t.z.object({"@_AuthnInstant":t.z.string(),"@_SessionIndex":t.z.string(),"@_SessionNotOnOrAfter":t.z.string()})}),t.z.object({"saml:AttributeStatement":t.z.array(o)})])),":@":t.z.object({"@_xmlns":t.z.string(),"@_ID":t.z.string(),"@_IssueInstant":t.z.string(),"@_Version":t.z.string()})})])),":@":t.z.object({"@_xmlns:samlp":t.z.string(),"@_xmlns:saml":t.z.string(),"@_Destination":t.z.string(),"@_ID":t.z.string(),"@_InResponseTo":t.z.string(),"@_IssueInstant":t.z.string(),"@_Version":t.z.string()})})),u=e((e=>{var t=`[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*`,n=RegExp(`^[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`);e.isExist=function(e){return e!==void 0},e.isEmptyObject=function(e){return Object.keys(e).length===0},e.merge=function(e,t,n){if(t){let r=Object.keys(t),i=r.length;for(let a=0;a<i;a++)n===`strict`?e[r[a]]=[t[r[a]]]:e[r[a]]=t[r[a]]}},e.getValue=function(t){return e.isExist(t)?t:``},e.isName=function(e){return n.exec(e)!=null},e.getAllMatches=function(e,t){let n=[],r=t.exec(e);for(;r;){let i=[];i.startIndex=t.lastIndex-r[0].length;let a=r.length;for(let e=0;e<a;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n},e.nameRegexp=t,e.DANGEROUS_PROPERTY_NAMES=[`hasOwnProperty`,`toString`,`valueOf`,`__defineGetter__`,`__defineSetter__`,`__lookupGetter__`,`__lookupSetter__`],e.criticalProperties=[`__proto__`,`constructor`,`prototype`]})),d=e((e=>{var t=u(),n={allowBooleanAttributes:!1,unpairedTags:[]};e.validate=function(e,t){t=Object.assign({},n,t);let o=[],s=!1,l=!1;e[0]===``&&(e=e.substr(1));for(let n=0;n<e.length;n++)if(e[n]===`<`&&e[n+1]===`?`){if(n+=2,n=i(e,n),n.err)return n}else if(e[n]===`<`){let u=n;if(n++,e[n]===`!`){n=a(e,n);continue}else{let f=!1;e[n]===`/`&&(f=!0,n++);let h=``;for(;n<e.length&&e[n]!==`>`&&e[n]!==` `&&e[n]!==` `&&e[n]!==`
2
+ `&&e[n]!==`\r`;n++)h+=e[n];if(h=h.trim(),h[h.length-1]===`/`&&(h=h.substring(0,h.length-1),n--),!g(h)){let t;return t=h.trim().length===0?`Invalid space after '<'.`:`Tag '`+h+`' is an invalid name.`,m(`InvalidTag`,t,_(e,n))}let v=c(e,n);if(v===!1)return m(`InvalidAttr`,`Attributes for '`+h+`' have open quote.`,_(e,n));let y=v.value;if(n=v.index,y[y.length-1]===`/`){let r=n-y.length;y=y.substring(0,y.length-1);let i=d(y,t);if(i===!0)s=!0;else return m(i.err.code,i.err.msg,_(e,r+i.err.line))}else if(f){if(!v.tagClosed)return m(`InvalidTag`,`Closing tag '`+h+`' doesn't have proper closing.`,_(e,n));if(y.trim().length>0)return m(`InvalidTag`,`Closing tag '`+h+`' can't have attributes or invalid starting.`,_(e,u));if(o.length===0)return m(`InvalidTag`,`Closing tag '`+h+`' has not been opened.`,_(e,u));{let t=o.pop();if(h!==t.tagName){let n=_(e,t.tagStartPos);return m(`InvalidTag`,`Expected closing tag '`+t.tagName+`' (opened in line `+n.line+`, col `+n.col+`) instead of closing tag '`+h+`'.`,_(e,u))}o.length==0&&(l=!0)}}else{let r=d(y,t);if(r!==!0)return m(r.err.code,r.err.msg,_(e,n-y.length+r.err.line));if(l===!0)return m(`InvalidXml`,`Multiple possible root nodes found.`,_(e,n));t.unpairedTags.indexOf(h)!==-1||o.push({tagName:h,tagStartPos:u}),s=!0}for(n++;n<e.length;n++)if(e[n]===`<`)if(e[n+1]===`!`){n++,n=a(e,n);continue}else if(e[n+1]===`?`){if(n=i(e,++n),n.err)return n}else break;else if(e[n]===`&`){let t=p(e,n);if(t==-1)return m(`InvalidChar`,`char '&' is not expected.`,_(e,n));n=t}else if(l===!0&&!r(e[n]))return m(`InvalidXml`,`Extra text at the end`,_(e,n));e[n]===`<`&&n--}}else{if(r(e[n]))continue;return m(`InvalidChar`,`char '`+e[n]+`' is not expected.`,_(e,n))}return s?o.length==1?m(`InvalidTag`,`Unclosed tag '`+o[0].tagName+`'.`,_(e,o[0].tagStartPos)):o.length>0?m(`InvalidXml`,`Invalid '`+JSON.stringify(o.map(e=>e.tagName),null,4).replace(/\r?\n/g,``)+`' found.`,{line:1,col:1}):!0:m(`InvalidXml`,`Start tag expected.`,1)};function r(e){return e===` `||e===` `||e===`
3
+ `||e===`\r`}function i(e,t){let n=t;for(;t<e.length;t++)if(e[t]==`?`||e[t]==` `){let r=e.substr(n,t-n);if(t>5&&r===`xml`)return m(`InvalidXml`,`XML declaration allowed only at the start of the document.`,_(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function a(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t<e.length;t++)if(e[t]===`-`&&e[t+1]===`-`&&e[t+2]===`>`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t<e.length;t++)if(e[t]===`<`)n++;else if(e[t]===`>`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t<e.length;t++)if(e[t]===`]`&&e[t+1]===`]`&&e[t+2]===`>`){t+=2;break}}return t}var o=`"`,s=`'`;function c(e,t){let n=``,r=``,i=!1;for(;t<e.length;t++){if(e[t]===o||e[t]===s)r===``?r=e[t]:r!==e[t]||(r=``);else if(e[t]===`>`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}var l=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function d(e,n){let r=t.getAllMatches(e,l),i={};for(let e=0;e<r.length;e++){if(r[e][1].length===0)return m(`InvalidAttr`,`Attribute '`+r[e][2]+`' has no space in starting.`,v(r[e]));if(r[e][3]!==void 0&&r[e][4]===void 0)return m(`InvalidAttr`,`Attribute '`+r[e][2]+`' is without value.`,v(r[e]));if(r[e][3]===void 0&&!n.allowBooleanAttributes)return m(`InvalidAttr`,`boolean attribute '`+r[e][2]+`' is not allowed.`,v(r[e]));let t=r[e][2];if(!h(t))return m(`InvalidAttr`,`Attribute '`+t+`' is an invalid name.`,v(r[e]));if(!i.hasOwnProperty(t))i[t]=1;else return m(`InvalidAttr`,`Attribute '`+t+`' is repeated.`,v(r[e]))}return!0}function f(e,t){let n=/\d/;for(e[t]===`x`&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===`;`)return t;if(!e[t].match(n))break}return-1}function p(e,t){if(t++,e[t]===`;`)return-1;if(e[t]===`#`)return t++,f(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===`;`)break;return-1}return t}function m(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function h(e){return t.isName(e)}function g(e){return t.isName(e)}function _(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function v(e){return e.startIndex+e[1].length}})),f=e((e=>{var{DANGEROUS_PROPERTY_NAMES:t,criticalProperties:n}=u(),r=e=>t.includes(e)?`__`+e:e,i={preserveOrder:!1,attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,onDangerousProperty:r};function a(e,r){if(typeof e!=`string`)return;let i=e.toLowerCase();if(t.some(e=>i===e.toLowerCase())||n.some(e=>i===e.toLowerCase()))throw Error(`[SECURITY] Invalid ${r}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function o(e){return typeof e==`boolean`?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof e==`object`&&e?{enabled:e.enabled!==!1,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??1e3),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null}:o(!0)}e.buildOptions=function(e){let t=Object.assign({},i,e),n=[{value:t.attributeNamePrefix,name:`attributeNamePrefix`},{value:t.attributesGroupName,name:`attributesGroupName`},{value:t.textNodeName,name:`textNodeName`},{value:t.cdataPropName,name:`cdataPropName`},{value:t.commentPropName,name:`commentPropName`}];for(let{value:e,name:t}of n)e&&a(e,t);return t.onDangerousProperty===null&&(t.onDangerousProperty=r),t.processEntities=o(t.processEntities),t},e.defaultOptions=i})),p=e(((e,t)=>{t.exports=class{constructor(e){this.tagname=e,this.child=[],this[`:@`]={}}add(e,t){e===`__proto__`&&(e=`#__proto__`),this.child.push({[e]:t})}addChild(e){e.tagname===`__proto__`&&(e.tagname=`#__proto__`),e[`:@`]&&Object.keys(e[`:@`]).length>0?this.child.push({[e.tagname]:e.child,":@":e[`:@`]}):this.child.push({[e.tagname]:e.child})}}})),m=e(((e,t)=>{var n=u(),r=class{constructor(e){this.suppressValidationErr=!e,this.options=e||{}}readDocType(e,t){let n=Object.create(null),r=0;if(e[t+3]===`O`&&e[t+4]===`C`&&e[t+5]===`T`&&e[t+6]===`Y`&&e[t+7]===`P`&&e[t+8]===`E`){t+=9;let i=1,o=!1,s=!1,c=``;for(;t<e.length;t++)if(e[t]===`<`&&!s){if(o&&a(e,`!ENTITY`,t)){t+=7;let i,a;if([i,a,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),a.indexOf(`&`)===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&r>=this.options.maxEntityCount)throw Error(`Entity count (${r+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let e=i.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n[i]={regx:RegExp(`&${e};`,`g`),val:a},r++}}else if(o&&a(e,`!ELEMENT`,t)){t+=8;let{index:n}=this.readElementExp(e,t+1);t=n}else if(o&&a(e,`!ATTLIST`,t))t+=8;else if(o&&a(e,`!NOTATION`,t)){t+=9;let{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else if(a(e,`!--`,t))s=!0;else throw Error(`Invalid DOCTYPE`);i++,c=``}else if(e[t]===`>`){if(s?e[t-1]===`-`&&e[t-2]===`-`&&(s=!1,i--):i--,i===0)break}else e[t]===`[`?o=!0:c+=e[t];if(i!==0)throw Error(`Unclosed DOCTYPE`)}else throw Error(`Invalid Tag instead of DOCTYPE`);return{entities:n,i:t}}readEntityExp(e,t){t=i(e,t);let n=``;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!==`"`&&e[t]!==`'`;)n+=e[t],t++;if(o(n),t=i(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()===`SYSTEM`)throw Error(`External entities are not supported`);if(e[t]===`%`)throw Error(`Parameter entities are not supported`)}let r=``;if([t,r]=this.readIdentifierVal(e,t,`entity`),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw Error(`Entity "${n}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[n,r,t]}readNotationExp(e,t){t=i(e,t);let n=``;for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;!this.suppressValidationErr&&o(n),t=i(e,t);let r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!==`SYSTEM`&&r!==`PUBLIC`)throw Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=i(e,t);let a=null,s=null;if(r===`PUBLIC`)[t,a]=this.readIdentifierVal(e,t,`publicIdentifier`),t=i(e,t),(e[t]===`"`||e[t]===`'`)&&([t,s]=this.readIdentifierVal(e,t,`systemIdentifier`));else if(r===`SYSTEM`&&([t,s]=this.readIdentifierVal(e,t,`systemIdentifier`),!this.suppressValidationErr&&!s))throw Error(`Missing mandatory system identifier for SYSTEM notation`);return{notationName:n,publicIdentifier:a,systemIdentifier:s,index:--t}}readIdentifierVal(e,t,n){let r=``,i=e[t];if(i!==`"`&&i!==`'`)throw Error(`Expected quoted string, found "${i}"`);for(t++;t<e.length&&e[t]!==i;)r+=e[t],t++;if(e[t]!==i)throw Error(`Unterminated ${n} value`);return t++,[t,r]}readElementExp(e,t){t=i(e,t);let r=``;for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;if(!this.suppressValidationErr&&!n.isName(r))throw Error(`Invalid element name: "${r}"`);t=i(e,t);let o=``;if(e[t]===`E`&&a(e,`MPTY`,t))t+=4;else if(e[t]===`A`&&a(e,`NY`,t))t+=2;else if(e[t]===`(`){for(t++;t<e.length&&e[t]!==`)`;)o+=e[t],t++;if(e[t]!==`)`)throw Error(`Unterminated content model`)}else if(!this.suppressValidationErr)throw Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:r,contentModel:o.trim(),index:t}}readAttlistExp(e,t){t=i(e,t);let n=``;for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;o(n),t=i(e,t);let r=``;for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;if(!o(r))throw Error(`Invalid attribute name: "${r}"`);t=i(e,t);let a=``;if(e.substring(t,t+8).toUpperCase()===`NOTATION`){if(a=`NOTATION`,t+=8,t=i(e,t),e[t]!==`(`)throw Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&e[t]!==`)`;){let r=``;for(;t<e.length&&e[t]!==`|`&&e[t]!==`)`;)r+=e[t],t++;if(r=r.trim(),!o(r))throw Error(`Invalid notation name: "${r}"`);n.push(r),e[t]===`|`&&(t++,t=i(e,t))}if(e[t]!==`)`)throw Error(`Unterminated list of notations`);t++,a+=` (`+n.join(`|`)+`)`}else{for(;t<e.length&&!/\s/.test(e[t]);)a+=e[t],t++;if(!this.suppressValidationErr&&![`CDATA`,`ID`,`IDREF`,`IDREFS`,`ENTITY`,`ENTITIES`,`NMTOKEN`,`NMTOKENS`].includes(a.toUpperCase()))throw Error(`Invalid attribute type: "${a}"`)}t=i(e,t);let s=``;return e.substring(t,t+8).toUpperCase()===`#REQUIRED`?(s=`#REQUIRED`,t+=8):e.substring(t,t+7).toUpperCase()===`#IMPLIED`?(s=`#IMPLIED`,t+=7):[t,s]=this.readIdentifierVal(e,t,`ATTLIST`),{elementName:n,attributeName:r,attributeType:a,defaultValue:s,index:t}}},i=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function a(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function o(e){if(n.isName(e))return e;throw Error(`Invalid entity name ${e}`)}t.exports=r})),h=e(((e,t)=>{var n=/^[-+]?0x[a-fA-F0-9]+$/,r=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,i={hex:!0,leadingZeros:!0,decimalPoint:`.`,eNotation:!0};function a(e,t={}){if(t=Object.assign({},i,t),!e||typeof e!=`string`)return e;let a=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(a))return e;if(e===`0`)return 0;if(t.hex&&n.test(a))return s(a,16);if(a.search(/[eE]/)!==-1){let n=a.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(n){if(t.leadingZeros)a=(n[1]||``)+n[3];else if(!(n[2]===`0`&&n[3][0]===`.`))return e;return t.eNotation?Number(a):e}else return e}else{let n=r.exec(a);if(n){let r=n[1],i=n[2],s=o(n[3]);if(!t.leadingZeros&&i.length>0&&r&&a[2]!==`.`||!t.leadingZeros&&i.length>0&&!r&&a[1]!==`.`)return e;if(t.leadingZeros&&i===e)return 0;{let n=Number(a),o=``+n;return o.search(/[eE]/)===-1?a.indexOf(`.`)===-1?i?s===o||r+s===o?n:e:a===o||a===r+o?n:e:o===`0`&&s===``||o===s||r&&o===`-`+s?n:e:t.eNotation?n:e}}else return e}}function o(e){return e&&e.indexOf(`.`)!==-1?(e=e.replace(/0+$/,``),e===`.`?e=`0`:e[0]===`.`?e=`0`+e:e[e.length-1]===`.`&&(e=e.substr(0,e.length-1)),e):e}function s(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}t.exports=a})),g=e(((e,t)=>{function n(e){return typeof e==`function`?e:Array.isArray(e)?t=>{for(let n of e)if(typeof n==`string`&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}t.exports=n})),_=e(((e,t)=>{var n=u(),r=p(),i=m(),a=h(),o=g(),s=class{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:`'`},gt:{regex:/&(gt|#62|#x3E);/g,val:`>`},lt:{regex:/&(lt|#60|#x3C);/g,val:`<`},quot:{regex:/&(quot|#34|#x22);/g,val:`"`}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:`&`},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:` `},cent:{regex:/&(cent|#162);/g,val:`¢`},pound:{regex:/&(pound|#163);/g,val:`£`},yen:{regex:/&(yen|#165);/g,val:`¥`},euro:{regex:/&(euro|#8364);/g,val:`€`},copyright:{regex:/&(copy|#169);/g,val:`©`},reg:{regex:/&(reg|#174);/g,val:`®`},inr:{regex:/&(inr|#8377);/g,val:`₹`},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>O(t,10,`&#`)},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>O(t,16,`&#x`)}},this.addExternalEntities=c,this.parseXml=v,this.parseTextData=l,this.resolveNameSpace=d,this.buildAttributesMap=_,this.isItStopNode=S,this.replaceEntitiesValue=b,this.readStopNodeData=E,this.saveTextToParentTag=x,this.addChild=y,this.ignoreAttributesFn=o(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let e=0;e<this.options.stopNodes.length;e++){let t=this.options.stopNodes[e];typeof t==`string`&&(t.startsWith(`*.`)?this.stopNodesWildcard.add(t.substring(2)):this.stopNodesExact.add(t))}}}};function c(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n],i=r.replace(/[.\-+*:]/g,`\\.`);this.lastEntities[r]={regex:RegExp(`&`+i+`;`,`g`),val:e[r]}}}function l(e,t,n,r,i,a,o){if(e!==void 0&&(this.options.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e,t,n));let r=this.options.tagValueProcessor(t,e,n,i,a);return r==null?e:typeof r!=typeof e||r!==e?r:this.options.trimValues||e.trim()===e?D(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function d(e){if(this.options.removeNSPrefix){let t=e.split(`:`),n=e.charAt(0)===`/`?`/`:``;if(t[0]===`xmlns`)return``;t.length===2&&(e=n+t[1])}return e}var f=RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,`gm`);function _(e,t,r){if(this.options.ignoreAttributes!==!0&&typeof e==`string`){let i=n.getAllMatches(e,f),a=i.length,o={};for(let e=0;e<a;e++){let n=this.resolveNameSpace(i[e][1]);if(this.ignoreAttributesFn(n,t))continue;let a=i[e][4],s=this.options.attributeNamePrefix+n;if(n.length)if(this.options.transformAttributeName&&(s=this.options.transformAttributeName(s)),s=k(s,this.options),a!==void 0){this.options.trimValues&&(a=a.trim()),a=this.replaceEntitiesValue(a,r,t);let e=this.options.attributeValueProcessor(n,a,t);e==null?o[s]=a:typeof e!=typeof a||e!==a?o[s]=e:o[s]=D(a,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[s]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){let e={};return e[this.options.attributesGroupName]=o,e}return o}}var v=function(e){e=e.replace(/\r\n?/g,`
4
+ `);let t=new r(`!xml`),n=t,a=``,o=``;this.entityExpansionCount=0,this.currentExpandedLength=0;let s=new i(this.options.processEntities);for(let i=0;i<e.length;i++)if(e[i]===`<`)if(e[i+1]===`/`){let t=w(e,`>`,i,`Closing Tag is not closed.`),r=e.substring(i+2,t).trim();if(this.options.removeNSPrefix){let e=r.indexOf(`:`);e!==-1&&(r=r.substr(e+1))}this.options.transformTagName&&(r=this.options.transformTagName(r)),n&&(a=this.saveTextToParentTag(a,n,o));let s=o.substring(o.lastIndexOf(`.`)+1);if(r&&this.options.unpairedTags.indexOf(r)!==-1)throw Error(`Unpaired tag can not be used as closing tag: </${r}>`);let c=0;s&&this.options.unpairedTags.indexOf(s)!==-1?(c=o.lastIndexOf(`.`,o.lastIndexOf(`.`)-1),this.tagsNodeStack.pop()):c=o.lastIndexOf(`.`),o=o.substring(0,c),n=this.tagsNodeStack.pop(),a=``,i=t}else if(e[i+1]===`?`){let t=T(e,i,!1,`?>`);if(!t)throw Error(`Pi Tag is not closed.`);if(a=this.saveTextToParentTag(a,n,o),!(this.options.ignoreDeclaration&&t.tagName===`?xml`||this.options.ignorePiTags)){let e=new r(t.tagName);e.add(this.options.textNodeName,``),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[`:@`]=this.buildAttributesMap(t.tagExp,o,t.tagName)),this.addChild(n,e,o,i)}i=t.closeIndex+1}else if(e.substr(i+1,3)===`!--`){let t=w(e,`-->`,i+4,`Comment is not closed.`);if(this.options.commentPropName){let r=e.substring(i+4,t-2);a=this.saveTextToParentTag(a,n,o),n.add(this.options.commentPropName,[{[this.options.textNodeName]:r}])}i=t}else if(e.substr(i+1,2)===`!D`){let t=s.readDocType(e,i);this.docTypeEntities=t.entities,i=t.i}else if(e.substr(i+1,2)===`![`){let t=w(e,`]]>`,i,`CDATA is not closed.`)-2,r=e.substring(i+9,t);a=this.saveTextToParentTag(a,n,o);let s=this.parseTextData(r,n.tagname,o,!0,!1,!0,!0);s??=``,this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:r}]):n.add(this.options.textNodeName,s),i=t+2}else{let s=T(e,i,this.options.removeNSPrefix),c=s.tagName,l=s.rawTagName,u=s.tagExp,d=s.attrExpPresent,f=s.closeIndex;if(this.options.transformTagName){let e=this.options.transformTagName(c);u===c&&(u=e),c=e}if(this.options.strictReservedNames&&(c===this.options.commentPropName||c===this.options.cdataPropName||c===this.options.textNodeName||c===this.options.attributesGroupName))throw Error(`Invalid tag name: ${c}`);n&&a&&n.tagname!==`!xml`&&(a=this.saveTextToParentTag(a,n,o,!1));let p=n;p&&this.options.unpairedTags.indexOf(p.tagname)!==-1&&(n=this.tagsNodeStack.pop(),o=o.substring(0,o.lastIndexOf(`.`))),c!==t.tagname&&(o+=o?`.`+c:c);let m=i;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,o,c)){let t=``;if(u.length>0&&u.lastIndexOf(`/`)===u.length-1)c[c.length-1]===`/`?(c=c.substr(0,c.length-1),o=o.substr(0,o.length-1),u=c):u=u.substr(0,u.length-1),i=s.closeIndex;else if(this.options.unpairedTags.indexOf(c)!==-1)i=s.closeIndex;else{let n=this.readStopNodeData(e,l,f+1);if(!n)throw Error(`Unexpected end of ${l}`);i=n.i,t=n.tagContent}let a=new r(c);c!==u&&d&&(a[`:@`]=this.buildAttributesMap(u,o,c)),t&&=this.parseTextData(t,c,o,!0,d,!0,!0),o=o.substr(0,o.lastIndexOf(`.`)),a.add(this.options.textNodeName,t),this.addChild(n,a,o,m)}else{if(u.length>0&&u.lastIndexOf(`/`)===u.length-1){if(c[c.length-1]===`/`?(c=c.substr(0,c.length-1),o=o.substr(0,o.length-1),u=c):u=u.substr(0,u.length-1),this.options.transformTagName){let e=this.options.transformTagName(c);u===c&&(u=e),c=e}let e=new r(c);c!==u&&d&&(e[`:@`]=this.buildAttributesMap(u,o,c)),this.addChild(n,e,o,m),o=o.substr(0,o.lastIndexOf(`.`))}else if(this.options.unpairedTags.indexOf(c)!==-1){let e=new r(c);c!==u&&d&&(e[`:@`]=this.buildAttributesMap(u,o)),this.addChild(n,e,o,m),o=o.substr(0,o.lastIndexOf(`.`)),i=s.closeIndex;continue}else{let e=new r(c);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw Error(`Maximum nested tags exceeded`);this.tagsNodeStack.push(n),c!==u&&d&&(e[`:@`]=this.buildAttributesMap(u,o,c)),this.addChild(n,e,o),n=e}a=``,i=f}}else a+=e[i];return t.child};function y(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.updateTag(t.tagname,n,t[`:@`]);i===!1||(typeof i==`string`&&(t.tagname=i),e.addChild(t,r))}var b=function(e,t,n){if(e.indexOf(`&`)===-1)return e;let r=this.options.processEntities;if(!r.enabled||r.allowedTags&&!r.allowedTags.includes(t)||r.tagFilter&&!r.tagFilter(t,n))return e;for(let t in this.docTypeEntities){let n=this.docTypeEntities[t],i=e.match(n.regx);if(i){if(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions)throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);let t=e.length;if(e=e.replace(n.regx,n.val),r.maxExpandedLength&&(this.currentExpandedLength+=e.length-t,this.currentExpandedLength>r.maxExpandedLength))throw Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${r.maxExpandedLength}`)}}if(e.indexOf(`&`)===-1)return e;for(let t of Object.keys(this.lastEntities)){let n=this.lastEntities[t],i=e.match(n.regex);if(i&&(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);e=e.replace(n.regex,n.val)}if(e.indexOf(`&`)===-1)return e;if(this.options.htmlEntities)for(let t of Object.keys(this.htmlEntities)){let n=this.htmlEntities[t],i=e.match(n.regex);if(i&&(this.entityExpansionCount+=i.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions))throw Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${r.maxTotalExpansions}`);e=e.replace(n.regex,n.val)}return e=e.replace(this.ampEntity.regex,this.ampEntity.val),e};function x(e,t,n,r){return e&&=(r===void 0&&(r=t.child.length===0),e=this.parseTextData(e,t.tagname,n,!1,t[`:@`]?Object.keys(t[`:@`]).length!==0:!1,r),e!==void 0&&e!==``&&t.add(this.options.textNodeName,e),``),e}function S(e,t,n,r){return!!(t&&t.has(r)||e&&e.has(n))}function C(e,t,n=`>`){let r,i=``;for(let a=t;a<e.length;a++){let t=e[a];if(r)t===r&&(r=``);else if(t===`"`||t===`'`)r=t;else if(t===n[0])if(n[1]){if(e[a+1]===n[1])return{data:i,index:a}}else return{data:i,index:a};else t===` `&&(t=` `);i+=t}}function w(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}function T(e,t,n,r=`>`){let i=C(e,t+1,r);if(!i)return;let a=i.data,o=i.index,s=a.search(/\s/),c=a,l=!0;s!==-1&&(c=a.substring(0,s),a=a.substring(s+1).trimStart());let u=c;if(n){let e=c.indexOf(`:`);e!==-1&&(c=c.substr(e+1),l=c!==i.data.substr(e+1))}return{tagName:c,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:u}}function E(e,t,n){let r=n,i=1;for(;n<e.length;n++)if(e[n]===`<`)if(e[n+1]===`/`){let a=w(e,`>`,n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(r,n),i:a};n=a}else if(e[n+1]===`?`)n=w(e,`?>`,n+1,`StopNode is not closed.`);else if(e.substr(n+1,3)===`!--`)n=w(e,`-->`,n+3,`StopNode is not closed.`);else if(e.substr(n+1,2)===`![`)n=w(e,`]]>`,n,`StopNode is not closed.`)-2;else{let r=T(e,n,`>`);r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!==`/`&&i++,n=r.closeIndex)}}function D(e,t,r){if(t&&typeof e==`string`){let t=e.trim();return t===`true`?!0:t===`false`?!1:a(e,r)}else if(n.isExist(e))return e;else return``}function O(e,t,n){let r=Number.parseInt(e,t);return r>=0&&r<=1114111?String.fromCodePoint(r):n+e+`;`}function k(e,t){if(n.criticalProperties.includes(e))throw Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return n.DANGEROUS_PROPERTY_NAMES.includes(e)?t.onDangerousProperty(e):e}t.exports=s})),v=e((e=>{function t(e,t){return n(e,t)}function n(e,t,o){let s,c={};for(let l=0;l<e.length;l++){let u=e[l],d=r(u),f=``;if(f=o===void 0?d:o+`.`+d,d===t.textNodeName)s===void 0?s=u[d]:s+=``+u[d];else if(d===void 0)continue;else if(u[d]){let e=n(u[d],t,f),r=a(e,t);u[`:@`]?i(e,u[`:@`],f,t):Object.keys(e).length===1&&e[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?e=e[t.textNodeName]:Object.keys(e).length===0&&(t.alwaysCreateTextNode?e[t.textNodeName]=``:e=``),c[d]!==void 0&&c.hasOwnProperty(d)?(Array.isArray(c[d])||(c[d]=[c[d]]),c[d].push(e)):t.isArray(d,f,r)?c[d]=[e]:c[d]=e}}return typeof s==`string`?s.length>0&&(c[t.textNodeName]=s):s!==void 0&&(c[t.textNodeName]=s),c}function r(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let n=t[e];if(n!==`:@`)return n}}function i(e,t,n,r){if(t){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let a=i[o];r.isArray(a,n+`.`+a,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function a(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return!!(r===0||r===1&&(e[n]||typeof e[n]==`boolean`||e[n]===0))}e.prettify=t})),y=e(((e,t)=>{var{buildOptions:n}=f(),r=_(),{prettify:i}=v(),a=d();t.exports=class{constructor(e){this.externalEntities={},this.options=n(e)}parse(e,t){if(typeof e!=`string`)if(e.toString)e=e.toString();else throw Error(`XML data is accepted in String or Bytes[] form.`);if(t){t===!0&&(t={});let n=a.validate(e,t);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let n=new r(this.options);n.addExternalEntities(this.externalEntities);let o=n.parseXml(e);return this.options.preserveOrder||o===void 0?o:i(o,this.options)}addEntity(e,t){if(t.indexOf(`&`)!==-1)throw Error(`Entity value can't have '&'`);if(e.indexOf(`&`)!==-1||e.indexOf(`;`)!==-1)throw Error(`An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'`);if(t===`&`)throw Error(`An entity with value '&' is not permitted`);this.externalEntities[e]=t}}})),b=e(((e,t)=>{var n=`
5
+ `;function r(e,t){let r=``;return t.format&&t.indentBy.length>0&&(r=n),i(e,t,``,r)}function i(e,t,n,r){let l=``,u=!1;if(!Array.isArray(e)){if(e!=null){let n=e.toString();return n=c(n,t),n}return``}for(let d=0;d<e.length;d++){let f=e[d],p=a(f);if(p===void 0)continue;let m=``;if(m=n.length===0?p:`${n}.${p}`,p===t.textNodeName){let e=f[p];s(m,t)||(e=t.tagValueProcessor(p,e),e=c(e,t)),u&&(l+=r),l+=e,u=!1;continue}else if(p===t.cdataPropName){u&&(l+=r),l+=`<![CDATA[${f[p][0][t.textNodeName]}]]>`,u=!1;continue}else if(p===t.commentPropName){l+=r+`<!--${f[p][0][t.textNodeName]}-->`,u=!0;continue}else if(p[0]===`?`){let e=o(f[`:@`],t),n=p===`?xml`?``:r,i=f[p][0][t.textNodeName];i=i.length===0?``:` `+i,l+=n+`<${p}${i}${e}?>`,u=!0;continue}let h=r;h!==``&&(h+=t.indentBy);let g=r+`<${p}${o(f[`:@`],t)}`,_=i(f[p],t,m,h);t.unpairedTags.indexOf(p)===-1?(!_||_.length===0)&&t.suppressEmptyNode?l+=g+`/>`:_&&_.endsWith(`>`)?l+=g+`>${_}${r}</${p}>`:(l+=g+`>`,_&&r!==``&&(_.includes(`/>`)||_.includes(`</`))?l+=r+t.indentBy+_+r:l+=_,l+=`</${p}>`):t.suppressUnpairedNode?l+=g+`>`:l+=g+`/>`,u=!0}return l}function a(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(Object.prototype.hasOwnProperty.call(e,r)&&r!==`:@`)return r}}function o(e,t){let n=``;if(e&&!t.ignoreAttributes)for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=t.attributeValueProcessor(r,e[r]);i=c(i,t),i===!0&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${i}"`}return n}function s(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let n=e.substr(e.lastIndexOf(`.`)+1);for(let r in t.stopNodes)if(t.stopNodes[r]===e||t.stopNodes[r]===`*.`+n)return!0;return!1}function c(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){let r=t.entities[n];e=e.replace(r.regex,r.val)}return e}t.exports=r})),x=e(((e,t)=>{var n=b(),r=g(),i={attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:` `,suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:RegExp(`&`,`g`),val:`&amp;`},{regex:RegExp(`>`,`g`),val:`&gt;`},{regex:RegExp(`<`,`g`),val:`&lt;`},{regex:RegExp(`'`,`g`),val:`&apos;`},{regex:RegExp(`"`,`g`),val:`&quot;`}],processEntities:!0,stopNodes:[],oneListGroup:!1};function a(e){this.options=Object.assign({},i,e),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=r(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=c),this.processTextOrObjNode=o,this.options.format?(this.indentate=s,this.tagEndChar=`>
6
6
  `,this.newLine=`
7
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}x.prototype.build=function(t){return this.options.preserveOrder?Nt(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};x.prototype.j2x=function(t,e,n){let s="",r="";const o=n.join(".");for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(typeof t[a]>"u")this.isAttribute(a)&&(r+="");else if(t[a]===null)this.isAttribute(a)||a===this.options.cdataPropName?r+="":a[0]==="?"?r+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)r+=this.buildTextValNode(t[a],a,"",e);else if(typeof t[a]!="object"){const c=this.isAttribute(a);if(c&&!this.ignoreAttributesFn(c,o))s+=this.buildAttrPairStr(c,""+t[a]);else if(!c)if(a===this.options.textNodeName){let u=this.options.tagValueProcessor(a,""+t[a]);r+=this.replaceEntitiesValue(u)}else r+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){const c=t[a].length;let u="",l="";for(let f=0;f<c;f++){const d=t[a][f];if(!(typeof d>"u"))if(d===null)a[0]==="?"?r+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(typeof d=="object")if(this.options.oneListGroup){const h=this.j2x(d,e+1,n.concat(a));u+=h.val,this.options.attributesGroupName&&d.hasOwnProperty(this.options.attributesGroupName)&&(l+=h.attrStr)}else u+=this.processTextOrObjNode(d,a,e,n);else if(this.options.oneListGroup){let h=this.options.tagValueProcessor(a,d);h=this.replaceEntitiesValue(h),u+=h}else u+=this.buildTextValNode(d,a,"",e)}this.options.oneListGroup&&(u=this.buildObjectNode(u,a,l,e)),r+=u}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const c=Object.keys(t[a]),u=c.length;for(let l=0;l<u;l++)s+=this.buildAttrPairStr(c[l],""+t[a][c[l]])}else r+=this.processTextOrObjNode(t[a],a,e,n);return{attrStr:s,val:r}};x.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function yt(t,e,n,s){const r=this.j2x(t,n+1,s.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,r.attrStr,n):this.buildObjectNode(r.val,e,r.attrStr,n)}x.prototype.buildObjectNode=function(t,e,n,s){if(t==="")return e[0]==="?"?this.indentate(s)+"<"+e+n+"?"+this.tagEndChar:this.indentate(s)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let r="</"+e+this.tagEndChar,o="";return e[0]==="?"&&(o="?",r=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(s)+"<"+e+n+o+">"+t+r:this.options.commentPropName!==!1&&e===this.options.commentPropName&&o.length===0?this.indentate(s)+`<!--${t}-->`+this.newLine:this.indentate(s)+"<"+e+n+o+this.tagEndChar+t+this.indentate(s)+r}};x.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};x.prototype.buildTextValNode=function(t,e,n,s){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(s)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(s)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(s)+"<"+e+n+"?"+this.tagEndChar;{let r=this.options.tagValueProcessor(e,t);return r=this.replaceEntitiesValue(r),r===""?this.indentate(s)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(s)+"<"+e+n+">"+r+"</"+e+this.tagEndChar}};x.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const n=this.options.entities[e];t=t.replace(n.regex,n.val)}return t};function xt(t){return this.options.indentBy.repeat(t)}function zt(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var At=x;const St=ft,_t=At;var R={XMLParser:St,XMLBuilder:_t};class ie{constructor(e,n){z(this,"alphabet");z(this,"padding");z(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let s=0;s<e.length;s++)this.decodeMap.set(e[s],s)}encode(e,n){let s="",r=0,o=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],o+=8;o>=5;)o-=5,s+=this.alphabet[r>>o&31];if(o>0&&(s+=this.alphabet[r<<5-o&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-s.length%8)%8;for(let u=0;u<c;u++)s+="="}return s}decode(e,n){const s=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/8),o=[];for(let a=0;a<r;a++){let c=0;const u=[];for(let f=0;f<8;f++){const d=e[a*8+f];if(d==="="){if(a+1!==r)throw new Error(`Invalid character: ${d}`);c+=1;continue}if(d===void 0){if(s)throw new Error("Invalid data");c+=1;continue}const h=this.decodeMap.get(d)??null;if(h===null)throw new Error(`Invalid character: ${d}`);u.push(h)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const l=(u[0]<<3)+(u[1]>>2);if(o.push(l),c<6){const f=((u[1]&3)<<6)+(u[2]<<1)+(u[3]>>4);o.push(f)}if(c<4){const f=((u[3]&255)<<4)+(u[4]>>1);o.push(f)}if(c<3){const f=((u[4]&1)<<7)+(u[5]<<2)+(u[6]>>3);o.push(f)}if(c<1){const f=((u[6]&7)<<5)+u[7];o.push(f)}}return Uint8Array.from(o)}}new ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new ie("0123456789ABCDEFGHIJKLMNOPQRSTUV");class oe{constructor(e,n){z(this,"alphabet");z(this,"padding");z(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let s=0;s<e.length;s++)this.decodeMap.set(e[s],s)}encode(e,n){let s="",r=0,o=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],o+=8;o>=6;)o+=-6,s+=this.alphabet[r>>o&63];if(o>0&&(s+=this.alphabet[r<<6-o&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-s.length%4)%4;for(let u=0;u<c;u++)s+="="}return s}decode(e,n){const s=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/4),o=[];for(let a=0;a<r;a++){let c=0,u=0;for(let l=0;l<4;l++){const f=e[a*4+l];if(f==="="){if(a+1!==r)throw new Error(`Invalid character: ${f}`);c+=1;continue}if(f===void 0){if(s)throw new Error("Invalid data");c+=1;continue}const d=this.decodeMap.get(f)??null;if(d===null)throw new Error(`Invalid character: ${f}`);u+=d<<6*(3-l)}o.push(u>>16&255),c<2&&o.push(u>>8&255),c<1&&o.push(u&255)}return Uint8Array.from(o)}}const Tt=new oe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new oe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");let It="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",J=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=It[n[t]&63];return e};async function ae(t){const e=new DecompressionStream("deflate-raw"),n=new Uint8Array(t),s=new Blob([n]).stream().pipeThrough(e);return new Uint8Array(await new Response(s).arrayBuffer())}async function ue(t){const e=await Tt.decode(t.replace(/ /g,"+"));try{const n=await ae(e);return new TextDecoder().decode(n)}catch(n){return console.warn("Decompression failed, assuming data is not compressed:",n),new TextDecoder().decode(e)}}async function Ot(t){const e=await ue(t),s=new R.XMLParser({attributeNamePrefix:"@_",alwaysCreateTextNode:!0,ignoreAttributes:!1}).parse(e);return q.parse(s)}function Ct(t){const e=t.certificates.map(r=>({"@_use":"signing",KeyInfo:{"@_xmlns":"http://www.w3.org/2000/09/xmldsig#",X509Data:{X509Certificate:r}}})),n={EntityDescriptor:{"@_entityID":t.entityId,"@_xmlns":"urn:oasis:names:tc:SAML:2.0:metadata",IDPSSODescriptor:{"@_protocolSupportEnumeration":"urn:oasis:names:tc:SAML:2.0:protocol",KeyDescriptor:e,SingleLogoutService:[{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect","@_Location":t.singleLogoutServiceUrl},{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","@_Location":t.singleLogoutServiceUrl}],NameIDFormat:["urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress","urn:oasis:names:tc:SAML:2.0:nameid-format:persistent","urn:oasis:names:tc:SAML:2.0:nameid-format:transient"],SingleSignOnService:[{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect","@_Location":t.assertionConsumerServiceUrl},{"@_Binding":"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST","@_Location":t.assertionConsumerServiceUrl}],Attribute:[{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"E-Mail Address","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Given Name","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Name","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Surname","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"},{"@_Name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:uri","@_FriendlyName":"Name ID","@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion"}]}}};return new R.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:"@_"}).build(n)}async function Pt(t,e){const n=t.notBefore||new Date().toISOString(),s=t.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),r=t.issueInstant||n,o=t.sessionNotOnOrAfter||s,a=t.responseId||`_${J()}`,c=t.assertionId||`_${J()}`,u=[{"samlp:Response":[{"saml:Issuer":[{"#text":t.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":t.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":t.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":t.inResponseTo,"@_NotOnOrAfter":s,"@_Recipient":t.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":t.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":s}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":r,"@_SessionIndex":t.sessionIndex,"@_SessionNotOnOrAfter":o}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":t.userId}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":t.email}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"default-roles-master"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"offline_access"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"view-profile"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"uma_authorization"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account-links"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":c,"@_IssueInstant":r,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":t.destination,"@_ID":a,"@_InResponseTo":t.inResponseTo,"@_IssueInstant":r,"@_Version":"2.0"}}];let f=new R.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(u);return t.signature&&e&&(f=await e.signSAML(f,t.signature.privateKeyPem,t.signature.cert)),t.encode===!1?f:btoa(f)}class Mt{constructor(e){this.signUrl=e}async signSAML(e,n,s){const r=await fetch(this.signUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:e,privateKey:n,publicCert:s})});if(!r.ok)throw new Error(`Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`);return await r.text()}}exports.HttpSamlSigner=Mt;exports.createSamlMetadata=Ct;exports.createSamlResponse=Pt;exports.dsSignatureSchema=L;exports.inflateDecompress=ue;exports.inflateRaw=ae;exports.parseSamlRequestQuery=Ot;exports.samlIssuerSchema=K;exports.samlMetadataResponseSchema=de;exports.samlRequestSchema=q;exports.samlResponseJsonSchema=pe;
7
+ `):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``)}a.prototype.build=function(e){return this.options.preserveOrder?n(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)},a.prototype.j2x=function(e,t,n){let r=``,i=``,a=n.join(`.`);for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o))if(e[o]===void 0)this.isAttribute(o)&&(i+=``);else if(e[o]===null)this.isAttribute(o)||o===this.options.cdataPropName?i+=``:o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(e[o]instanceof Date)i+=this.buildTextValNode(e[o],o,``,t);else if(typeof e[o]!=`object`){let n=this.isAttribute(o);if(n&&!this.ignoreAttributesFn(n,a))r+=this.buildAttrPairStr(n,``+e[o]);else if(!n)if(o===this.options.textNodeName){let t=this.options.tagValueProcessor(o,``+e[o]);i+=this.replaceEntitiesValue(t)}else i+=this.buildTextValNode(e[o],o,``,t)}else if(Array.isArray(e[o])){let r=e[o].length,a=``,s=``;for(let c=0;c<r;c++){let r=e[o][c];if(r!==void 0)if(r===null)o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(typeof r==`object`)if(this.options.oneListGroup){let e=this.j2x(r,t+1,n.concat(o));a+=e.val,this.options.attributesGroupName&&r.hasOwnProperty(this.options.attributesGroupName)&&(s+=e.attrStr)}else a+=this.processTextOrObjNode(r,o,t,n);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(o,r);e=this.replaceEntitiesValue(e),a+=e}else a+=this.buildTextValNode(r,o,``,t)}this.options.oneListGroup&&(a=this.buildObjectNode(a,o,s,t)),i+=a}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){let t=Object.keys(e[o]),n=t.length;for(let i=0;i<n;i++)r+=this.buildAttrPairStr(t[i],``+e[o][t[i]])}else i+=this.processTextOrObjNode(e[o],o,t,n);return{attrStr:r,val:i}},a.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,``+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t===`true`?` `+e:` `+e+`="`+t+`"`};function o(e,t,n,r){let i=this.j2x(e,n+1,r.concat(t));return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,i.attrStr,n):this.buildObjectNode(i.val,t,i.attrStr,n)}a.prototype.buildObjectNode=function(e,t,n,r){if(e===``)return t[0]===`?`?this.indentate(r)+`<`+t+n+`?`+this.tagEndChar:this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar;{let i=`</`+t+this.tagEndChar,a=``;return t[0]===`?`&&(a=`?`,i=``),(n||n===``)&&e.indexOf(`<`)===-1?this.indentate(r)+`<`+t+n+a+`>`+e+i:this.options.commentPropName!==!1&&t===this.options.commentPropName&&a.length===0?this.indentate(r)+`<!--${e}-->`+this.newLine:this.indentate(r)+`<`+t+n+a+this.tagEndChar+e+this.indentate(r)+i}},a.prototype.closeTag=function(e){let t=``;return this.options.unpairedTags.indexOf(e)===-1?t=this.options.suppressEmptyNode?`/`:`></${e}`:this.options.suppressUnpairedNode||(t=`/`),t},a.prototype.buildTextValNode=function(e,t,n,r){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(r)+`<!--${e}-->`+this.newLine;if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),i===``?this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+`<`+t+n+`>`+i+`</`+t+this.tagEndChar}},a.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};function s(e){return this.options.indentBy.repeat(e)}function c(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}t.exports=a})),S=e(((e,t)=>{var n=d();t.exports={XMLParser:y(),XMLValidator:n,XMLBuilder:x()}}))(),C=class{alphabet;padding;decodeMap=new Map;constructor(e,t){if(e.length!==32)throw Error(`Invalid alphabet`);if(this.alphabet=e,this.padding=t?.padding??`=`,this.alphabet.includes(this.padding)||this.padding.length!==1)throw Error(`Invalid padding`);for(let t=0;t<e.length;t++)this.decodeMap.set(e[t],t)}encode(e,t){let n=``,r=0,i=0;for(let t=0;t<e.length;t++)for(r=r<<8|e[t],i+=8;i>=5;)i-=5,n+=this.alphabet[r>>i&31];if(i>0&&(n+=this.alphabet[r<<5-i&31]),t?.includePadding??!0){let e=(8-n.length%8)%8;for(let t=0;t<e;t++)n+=`=`}return n}decode(e,t){let n=t?.strict??!0,r=Math.ceil(e.length/8),i=[];for(let t=0;t<r;t++){let a=0,o=[];for(let i=0;i<8;i++){let s=e[t*8+i];if(s===`=`){if(t+1!==r)throw Error(`Invalid character: ${s}`);a+=1;continue}if(s===void 0){if(n)throw Error(`Invalid data`);a+=1;continue}let c=this.decodeMap.get(s)??null;if(c===null)throw Error(`Invalid character: ${s}`);o.push(c)}if(a===8||a===7||a===5||a===2)throw Error(`Invalid padding`);let s=(o[0]<<3)+(o[1]>>2);if(i.push(s),a<6){let e=((o[1]&3)<<6)+(o[2]<<1)+(o[3]>>4);i.push(e)}if(a<4){let e=((o[3]&255)<<4)+(o[4]>>1);i.push(e)}if(a<3){let e=((o[4]&1)<<7)+(o[5]<<2)+(o[6]>>3);i.push(e)}if(a<1){let e=((o[6]&7)<<5)+o[7];i.push(e)}}return Uint8Array.from(i)}};new C(`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`),new C(`0123456789ABCDEFGHIJKLMNOPQRSTUV`);var w=class{alphabet;padding;decodeMap=new Map;constructor(e,t){if(e.length!==64)throw Error(`Invalid alphabet`);if(this.alphabet=e,this.padding=t?.padding??`=`,this.alphabet.includes(this.padding)||this.padding.length!==1)throw Error(`Invalid padding`);for(let t=0;t<e.length;t++)this.decodeMap.set(e[t],t)}encode(e,t){let n=``,r=0,i=0;for(let t=0;t<e.length;t++)for(r=r<<8|e[t],i+=8;i>=6;)i+=-6,n+=this.alphabet[r>>i&63];if(i>0&&(n+=this.alphabet[r<<6-i&63]),t?.includePadding??!0){let e=(4-n.length%4)%4;for(let t=0;t<e;t++)n+=`=`}return n}decode(e,t){let n=t?.strict??!0,r=Math.ceil(e.length/4),i=[];for(let t=0;t<r;t++){let a=0,o=0;for(let i=0;i<4;i++){let s=e[t*4+i];if(s===`=`){if(t+1!==r)throw Error(`Invalid character: ${s}`);a+=1;continue}if(s===void 0){if(n)throw Error(`Invalid data`);a+=1;continue}let c=this.decodeMap.get(s)??null;if(c===null)throw Error(`Invalid character: ${s}`);o+=c<<6*(3-i)}i.push(o>>16&255),a<2&&i.push(o>>8&255),a<1&&i.push(o&255)}return Uint8Array.from(i)}},T=new w(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`);new w(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`);var E=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,D=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=E[n[e]&63];return t};async function O(e){let t=new DecompressionStream(`deflate-raw`),n=new Uint8Array(e),r=new Blob([n]).stream().pipeThrough(t);return new Uint8Array(await new Response(r).arrayBuffer())}async function k(e){let t=await T.decode(e.replace(/ /g,`+`));try{let e=await O(t);return new TextDecoder().decode(e)}catch(e){return console.warn(`Decompression failed, assuming data is not compressed:`,e),new TextDecoder().decode(t)}}async function A(e){let t=await k(e),n=new S.XMLParser({attributeNamePrefix:`@_`,alwaysCreateTextNode:!0,ignoreAttributes:!1}).parse(t);return i.parse(n)}function j(e){let t=e.certificates.map(e=>({"@_use":`signing`,KeyInfo:{"@_xmlns":`http://www.w3.org/2000/09/xmldsig#`,X509Data:{X509Certificate:e}}})),n={EntityDescriptor:{"@_entityID":e.entityId,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:metadata`,IDPSSODescriptor:{"@_protocolSupportEnumeration":`urn:oasis:names:tc:SAML:2.0:protocol`,KeyDescriptor:t,SingleLogoutService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.singleLogoutServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.singleLogoutServiceUrl}],NameIDFormat:[`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`,`urn:oasis:names:tc:SAML:2.0:nameid-format:persistent`,`urn:oasis:names:tc:SAML:2.0:nameid-format:transient`],SingleSignOnService:[{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect`,"@_Location":e.assertionConsumerServiceUrl},{"@_Binding":`urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST`,"@_Location":e.assertionConsumerServiceUrl}],Attribute:[{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`E-Mail Address`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Given Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Surname`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`},{"@_Name":`http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:uri`,"@_FriendlyName":`Name ID`,"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`}]}}};return new S.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!1,format:!0,attributeNamePrefix:`@_`}).build(n)}async function M(e,t){let n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+600*1e3).toISOString(),i=e.issueInstant||n,a=e.sessionNotOnOrAfter||r,o=e.responseId||`_${D()}`,s=e.assertionId||`_${D()}`,c=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":`urn:oasis:names:tc:SAML:2.0:status:Success`}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":`urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":`urn:oasis:names:tc:SAML:2.0:cm:bearer`}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":`urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified`}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":a}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_FriendlyName":`persistent`,"@_Name":`id`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`email`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`default-roles-master`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`offline_access`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`view-profile`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`uma_authorization`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":`manage-account-links`}],":@":{"@_xmlns:xs":`http://www.w3.org/2001/XMLSchema`,"@_xmlns:xsi":`http://www.w3.org/2001/XMLSchema-instance`,"@_xsi:type":`xs:string`}}],":@":{"@_Name":`Role`,"@_NameFormat":`urn:oasis:names:tc:SAML:2.0:attrname-format:basic`}}]}],":@":{"@_xmlns":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_ID":s,"@_IssueInstant":i,"@_Version":`2.0`}}],":@":{"@_xmlns:samlp":`urn:oasis:names:tc:SAML:2.0:protocol`,"@_xmlns:saml":`urn:oasis:names:tc:SAML:2.0:assertion`,"@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":`2.0`}}],l=new S.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(c);return e.signature&&t&&(l=await t.signSAML(l,e.signature.privateKeyPem,e.signature.cert)),e.encode===!1?l:btoa(l)}var N=class{signUrl;constructor(e){this.signUrl=e}async signSAML(e,t,n){let r=await fetch(this.signUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({xmlContent:e,privateKey:t,publicCert:n})});if(!r.ok)throw Error(`Failed to sign SAML via HTTP: ${r.status} ${r.statusText}`);return await r.text()}};exports.HttpSamlSigner=N,exports.createSamlMetadata=j,exports.createSamlResponse=M,exports.dsSignatureSchema=c,exports.inflateDecompress=k,exports.inflateRaw=O,exports.parseSamlRequestQuery=A,exports.samlIssuerSchema=r,exports.samlMetadataResponseSchema=a,exports.samlRequestSchema=i,exports.samlResponseJsonSchema=l;